net/tstun: don't return early from a partial tun.Read() (#6745)

Fixes #6730

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/6748/head
Jordan Whited 2 years ago committed by GitHub
parent 3a5fc233aa
commit 55b24009f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -187,8 +187,9 @@ type tunInjectedRead struct {
// tunVectorReadResult is the result of a tun.Read(), or an injected packet
// pretending to be a tun.Read().
type tunVectorReadResult struct {
// Only one of err, data, or injected should be set, and are read in that
// order of precedence.
// When err AND data are nil, injected will be set with meaningful data
// (injected packet). If either err OR data is non-nil, injected should be
// ignored (a "real" tun.Read).
err error
data [][]byte
injected tunInjectedRead
@ -543,7 +544,7 @@ func (t *Wrapper) Read(buffs [][]byte, sizes []int, offset int) (int, error) {
if !ok {
return 0, io.EOF
}
if res.err != nil {
if res.err != nil && len(res.data) == 0 {
return 0, res.err
}
if res.data == nil {
@ -595,7 +596,7 @@ func (t *Wrapper) Read(buffs [][]byte, sizes []int, offset int) (int, error) {
}
t.noteActivity()
return buffsPos, nil
return buffsPos, res.err
}
// injectedRead handles injected reads, which bypass filters.

Loading…
Cancel
Save