Skip to content

Commit e2c91f2

Browse files
committed
netstack/dispatcher: add to bytes read if +ve
1 parent d711153 commit e2c91f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

intra/netstack/dispatchers.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,14 @@ func (d *readVDispatcher) io(fds *fds) (bool, tcpip.Error) {
281281
}
282282

283283
if settings.Debug {
284-
log.VV("ns: tun(%d): dispatch: start iov: %d", fds.tun(), len(iov))
284+
log.VV("ns: tun(%d): dispatch: start; iov: %d", fds.tun(), len(iov))
285285
}
286286

287287
start := time.Now()
288288

289289
// github.com/google/gvisor/blob/d59375d82/pkg/tcpip/link/fdbased/packet_dispatchers.go#L186
290290
n, errno := rawfile.BlockingReadvUntilStopped(fds.eve(), fds.tun(), iov)
291291

292-
fds.read.Add(int64(n)) // update read bytes
293292
fds.lastRead.Store(time.Now().UnixMilli()) // update last read time
294293

295294
if settings.Debug {
@@ -304,6 +303,8 @@ func (d *readVDispatcher) io(fds *fds) (bool, tcpip.Error) {
304303
return abort, tcpip.TranslateErrno(errno)
305304
}
306305

306+
fds.read.Add(int64(n)) // update read bytes
307+
307308
b, ok := d.buf.pullBuffer(n) // not thread safe
308309
if !ok {
309310
log.E("ns: tun(%d): dispatch: pullBuffer err; n: %d", fds.tun(), n)

0 commit comments

Comments
 (0)