mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-06 22:49:15 +08:00
xsk: remove @first_frag from xsk_build_skb()
Instead of using auxiliary boolean that tracks if we are at first frag when gathering all elements of skb, same functionality can be achieved with checking if skb_shared_info::nr_frags is 0. Remove @first_frag but be careful around xsk_build_skb_zerocopy() and NULL the skb pointer when it failed so that common error path does not incorrectly interpret it during decision whether to call kfree_skb(). Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com> Acked-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20250925160009.2474816-3-maciej.fijalkowski@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
c30d084960
commit
6b9c129c2f
@@ -730,13 +730,13 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
|
||||
struct xsk_tx_metadata *meta = NULL;
|
||||
struct net_device *dev = xs->dev;
|
||||
struct sk_buff *skb = xs->skb;
|
||||
bool first_frag = false;
|
||||
int err;
|
||||
|
||||
if (dev->priv_flags & IFF_TX_SKB_NO_LINEAR) {
|
||||
skb = xsk_build_skb_zerocopy(xs, desc);
|
||||
if (IS_ERR(skb)) {
|
||||
err = PTR_ERR(skb);
|
||||
skb = NULL;
|
||||
goto free_err;
|
||||
}
|
||||
} else {
|
||||
@@ -747,8 +747,6 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
|
||||
len = desc->len;
|
||||
|
||||
if (!skb) {
|
||||
first_frag = true;
|
||||
|
||||
hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom));
|
||||
tr = dev->needed_tailroom;
|
||||
skb = sock_alloc_send_skb(&xs->sk, hr + len + tr, 1, &err);
|
||||
@@ -798,7 +796,7 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
|
||||
list_add_tail(&xsk_addr->addr_node, &XSKCB(skb)->addrs_list);
|
||||
}
|
||||
|
||||
if (first_frag && desc->options & XDP_TX_METADATA) {
|
||||
if (!skb_shinfo(skb)->nr_frags && desc->options & XDP_TX_METADATA) {
|
||||
if (unlikely(xs->pool->tx_metadata_len == 0)) {
|
||||
err = -EINVAL;
|
||||
goto free_err;
|
||||
@@ -840,7 +838,7 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
|
||||
return skb;
|
||||
|
||||
free_err:
|
||||
if (first_frag && skb)
|
||||
if (skb && !skb_shinfo(skb)->nr_frags)
|
||||
kfree_skb(skb);
|
||||
|
||||
if (err == -EOVERFLOW) {
|
||||
|
||||
Reference in New Issue
Block a user