Commit f2d27282 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

samples/bpf: Use recvfrom() in xdpsock/rxdrop

Start using recvfrom() the rxdrop scenario.
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20201130185205.196029-8-bjorn.topel@gmail.com
parent b02e5a0e
...@@ -1170,7 +1170,7 @@ static inline void complete_tx_only(struct xsk_socket_info *xsk, ...@@ -1170,7 +1170,7 @@ static inline void complete_tx_only(struct xsk_socket_info *xsk,
} }
} }
static void rx_drop(struct xsk_socket_info *xsk, struct pollfd *fds) static void rx_drop(struct xsk_socket_info *xsk)
{ {
unsigned int rcvd, i; unsigned int rcvd, i;
u32 idx_rx = 0, idx_fq = 0; u32 idx_rx = 0, idx_fq = 0;
...@@ -1180,7 +1180,7 @@ static void rx_drop(struct xsk_socket_info *xsk, struct pollfd *fds) ...@@ -1180,7 +1180,7 @@ static void rx_drop(struct xsk_socket_info *xsk, struct pollfd *fds)
if (!rcvd) { if (!rcvd) {
if (xsk_ring_prod__needs_wakeup(&xsk->umem->fq)) { if (xsk_ring_prod__needs_wakeup(&xsk->umem->fq)) {
xsk->app_stats.rx_empty_polls++; xsk->app_stats.rx_empty_polls++;
ret = poll(fds, num_socks, opt_timeout); recvfrom(xsk_socket__fd(xsk->xsk), NULL, 0, MSG_DONTWAIT, NULL, NULL);
} }
return; return;
} }
...@@ -1191,7 +1191,7 @@ static void rx_drop(struct xsk_socket_info *xsk, struct pollfd *fds) ...@@ -1191,7 +1191,7 @@ static void rx_drop(struct xsk_socket_info *xsk, struct pollfd *fds)
exit_with_error(-ret); exit_with_error(-ret);
if (xsk_ring_prod__needs_wakeup(&xsk->umem->fq)) { if (xsk_ring_prod__needs_wakeup(&xsk->umem->fq)) {
xsk->app_stats.fill_fail_polls++; xsk->app_stats.fill_fail_polls++;
ret = poll(fds, num_socks, opt_timeout); recvfrom(xsk_socket__fd(xsk->xsk), NULL, 0, MSG_DONTWAIT, NULL, NULL);
} }
ret = xsk_ring_prod__reserve(&xsk->umem->fq, rcvd, &idx_fq); ret = xsk_ring_prod__reserve(&xsk->umem->fq, rcvd, &idx_fq);
} }
...@@ -1233,7 +1233,7 @@ static void rx_drop_all(void) ...@@ -1233,7 +1233,7 @@ static void rx_drop_all(void)
} }
for (i = 0; i < num_socks; i++) for (i = 0; i < num_socks; i++)
rx_drop(xsks[i], fds); rx_drop(xsks[i]);
if (benchmark_done) if (benchmark_done)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment