Skip to content

Commit df01eaa

Browse files
magnus-karlssonkernel-patches-bot
authored andcommitted
From: Magnus Karlsson <magnus.karlsson@intel.com>
Fix the sending of a single packet (or small burst) in xdpsock when executing in copy mode. Currently, the l2fwd application in xdpsock only transmits the packets after a batch of them has been received, which might be confusing if you only send one packet and expect that it is returned pronto. Fix this by calling sendto() more often and add a comment in the code that states that this can be optimized if needed. Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Reported-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com> --- samples/bpf/xdpsock_user.c | 8 ++++++++ 1 file changed, 8 insertions(+)
1 parent 6f1aa78 commit df01eaa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

samples/bpf/xdpsock_user.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,14 @@ static inline void complete_tx_l2fwd(struct xsk_socket_info *xsk,
897897
if (!xsk->outstanding_tx)
898898
return;
899899

900+
/* In copy mode, Tx is driven by a syscall so we need to use e.g. sendto() to
901+
* really send the packets. In zero-copy mode we do not have to do this, since Tx
902+
* is driven by the NAPI loop. So as an optimization, we do not have to call
903+
* sendto() all the time in zero-copy mode for l2fwd.
904+
*/
905+
if (opt_xdp_bind_flags & XDP_COPY)
906+
kick_tx(xsk);
907+
900908
ndescs = (xsk->outstanding_tx > opt_batch_size) ? opt_batch_size :
901909
xsk->outstanding_tx;
902910

0 commit comments

Comments
 (0)