net/tstun: simplify code

Unifying the exit paths here is easier than duplicating them.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2021-06-30 13:28:52 -07:00
parent ec52760a3d
commit 84b6574fd1

View File

@ -357,13 +357,8 @@ func (t *Wrapper) 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 {
// Do not filter injected packets.
if !wasInjectedPacket && !t.disableFilter {
response := t.filterOut(p)
if response != filter.Accept {
// Wireguard considers read errors fatal; pretend nothing was read