Skip to content

Commit 215eb9f

Browse files
LiangChen77kuba-moo
authored andcommitted
veth: Avoid NAPI scheduling on failed SKB forwarding
When an skb fails to be forwarded to the peer(e.g., skb data buffer length exceeds MTU), it will not be added to the peer's receive queue. Therefore, we should schedule the peer's NAPI poll function only when skb forwarding is successful to avoid unnecessary overhead. Signed-off-by: Liang Chen <liangchen.linux@gmail.com> Link: https://lore.kernel.org/r/20230824123131.7673-1-liangchen.linux@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent bebfbf0 commit 215eb9f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/net/veth.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,13 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
373373
if (likely(veth_forward_skb(rcv, skb, rq, use_napi) == NET_RX_SUCCESS)) {
374374
if (!use_napi)
375375
dev_lstats_add(dev, length);
376+
else
377+
__veth_xdp_flush(rq);
376378
} else {
377379
drop:
378380
atomic64_inc(&priv->dropped);
379381
}
380382

381-
if (use_napi)
382-
__veth_xdp_flush(rq);
383-
384383
rcu_read_unlock();
385384

386385
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)