mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
wgengine/tstun: inform userspaceEngine about injected outbound packets in tundev
Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
e7caad61fb
commit
07c3df13c6
@ -259,6 +259,8 @@ func (t *TUN) IdleDuration() time.Duration {
|
||||
func (t *TUN) Read(buf []byte, offset int) (int, error) {
|
||||
var n int
|
||||
|
||||
wasInjectedPacket := false
|
||||
|
||||
select {
|
||||
case <-t.closed:
|
||||
return 0, io.EOF
|
||||
@ -273,9 +275,7 @@ func (t *TUN) Read(buf []byte, offset int) (int, error) {
|
||||
t.bufferConsumed <- struct{}{}
|
||||
} else {
|
||||
// If the packet is not from t.buffer, then it is an injected packet.
|
||||
// In this case, we return early to bypass filtering
|
||||
t.noteActivity()
|
||||
return n, nil
|
||||
wasInjectedPacket = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,6 +289,12 @@ func (t *TUN) Read(buf []byte, offset int) (int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// For injected packets, we return early to bypass filtering.
|
||||
if wasInjectedPacket {
|
||||
t.noteActivity()
|
||||
return n, nil
|
||||
}
|
||||
|
||||
if !t.disableFilter {
|
||||
response := t.filterOut(p)
|
||||
if response != filter.Accept {
|
||||
|
Loading…
Reference in New Issue
Block a user