From 84b6574fd1b9d75dd6db63d650813ff8db543810 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 30 Jun 2021 13:28:52 -0700 Subject: [PATCH] net/tstun: simplify code Unifying the exit paths here is easier than duplicating them. Signed-off-by: Josh Bleecher Snyder --- net/tstun/wrap.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/net/tstun/wrap.go b/net/tstun/wrap.go index c65b65c88..2d5e1a6cf 100644 --- a/net/tstun/wrap.go +++ b/net/tstun/wrap.go @@ -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