diff options
author | Liang Chen <liangchen.linux@gmail.com> | 2023-08-24 14:31:31 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-08-26 03:52:11 +0200 |
commit | 215eb9f962091ebaab96be2c18cf5d0f5174a4d6 (patch) | |
tree | dc415f7b9179259e12e6e044d215fb826d7d81b5 | |
parent | Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf... (diff) | |
download | linux-215eb9f962091ebaab96be2c18cf5d0f5174a4d6.tar.xz linux-215eb9f962091ebaab96be2c18cf5d0f5174a4d6.zip |
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>
-rw-r--r-- | drivers/net/veth.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index da44bb1331ff..d43e62ebc2fc 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -373,14 +373,13 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) if (likely(veth_forward_skb(rcv, skb, rq, use_napi) == NET_RX_SUCCESS)) { if (!use_napi) dev_lstats_add(dev, length); + else + __veth_xdp_flush(rq); } else { drop: atomic64_inc(&priv->dropped); } - if (use_napi) - __veth_xdp_flush(rq); - rcu_read_unlock(); return NETDEV_TX_OK; |