diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-09-04 20:31:34 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-09-04 20:31:50 -0700 |
commit | 2b1655914000ebb61743d5a6932ffc7efb79a2fa (patch) | |
tree | d6234aac837d9733f57554ed48054e3f34baeaf7 /pcap-linux.c | |
parent | d8eb59c33e6db12063c0c244f6b92d844fdf6370 (diff) |
With a timeout of zero, specify a maximum-size retire timeout.
A timeout of zero means "wait indefinitely", not "wait for some
kernel-chosen default block retirement timeout".
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 91e8e310..ed80b2da 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -4858,7 +4858,26 @@ retry: #ifdef HAVE_TPACKET3 /* timeout value to retire block - use the configured buffering timeout, or default if <0. */ - req.tp_retire_blk_tov = (handlep->timeout>=0)?handlep->timeout:0; + if (handlep->timeout > 0) { + /* Use the user specified timeout as the block timeout */ + req.tp_retire_blk_tov = handlep->timeout; + } else if (handlep->timeout == 0) { + /* + * In pcap, this means "infinite timeout"; TPACKET_V3 + * doesn't support that, so just set it to UINT_MAX + * milliseconds. In the TPACKET_V3 loop, if the + * timeout is 0, and we haven't yet seen any packets, + * and we block and still don't have any packets, we + * keep blocking until we do. + */ + req.tp_retire_blk_tov = UINT_MAX; + } else { + /* + * XXX - this is not valid; use 0, meaning "have the + * kernel pick a default", for now. + */ + req.tp_retire_blk_tov = 0; + } /* private data not used */ req.tp_sizeof_priv = 0; /* Rx ring - feature request bits - none (rxhash will not be filled) */ |