[<prev] [next>] [day] [month] [year] [list]
Message-ID: <f5ce9d4c-3a38-40ea-1e7f-b62a721a20c5@virtuozzo.com>
Date: Mon, 12 Jul 2021 16:27:03 +0300
From: Vasily Averin <vvs@...tuozzo.com>
To: "David S. Miller" <davem@...emloft.net>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <eric.dumazet@...il.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH NET 4/7] ipv4: use pskb_realloc_headroom in ip_finish_output2
Unlike skb_realloc_headroom, new helper pskb_realloc_headroom
does not allocate a new skb if possible.
Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
---
net/ipv4/ip_output.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index c3efc7d..0f66483 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -198,19 +198,11 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s
} else if (rt->rt_type == RTN_BROADCAST)
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTBCAST, skb->len);
- /* Be paranoid, rather than too clever. */
if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
- struct sk_buff *skb2;
+ skb = pskb_realloc_headroom(skb, hh_len);
- skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
- if (!skb2) {
- kfree_skb(skb);
+ if (!skb)
return -ENOMEM;
- }
- if (skb->sk)
- skb_set_owner_w(skb2, skb->sk);
- consume_skb(skb);
- skb = skb2;
}
if (lwtunnel_xmit_redirect(dst->lwtstate)) {
--
1.8.3.1
Powered by blists - more mailing lists