netmap: fix bug in netmap_poll() optimization

The bug was introduced by r339639, although it is present in the upstream
netmap code since 2015. It is due to resetting the want_rx variable to
POLLIN, rather than resetting it to POLLIN|POLLRDNORM.
It only affects select(), which uses POLLRDNORM. poll() is not affected,
because it uses POLLIN.
Also, it only affects FreeBSD, because Linux skips the optimization
implemented by the piece of code where the bug occurs.

MFC after:	3 days
Sponsored by:	Sunny Valley Networks
This commit is contained in:
vmaffione 2018-12-22 15:15:45 +00:00
parent 4d2367c8e9
commit 058483a0c3

View File

@ -3304,16 +3304,19 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
}
if (want_rx) {
enum txrx t = NR_RX;
want_rx = 0; /* look for a reason to run the handlers */
int rxsync_needed = 0;
/* look for a reason to run the handlers */
for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
kring = NMR(na, t)[i];
if (kring->ring->cur == kring->ring->tail /* try fetch new buffers */
|| kring->rhead != kring->ring->head /* release buffers */) {
want_rx = 1;
rxsync_needed = 1;
break;
}
}
if (!want_rx)
revents |= events & (POLLIN | POLLRDNORM); /* we have data */
if (!rxsync_needed)
revents |= want_rx; /* we have data */
}
#endif