[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231203.205409.646024453190363727.syoshida@redhat.com>
Date: Sun, 03 Dec 2023 20:54:09 +0900 (JST)
From: Shigeru Yoshida <syoshida@...hat.com>
To: sumang@...vell.com
Cc: davem@...emloft.net, dsahern@...nel.org, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [EXT] [PATCH net v2] ipv4: ip_gre: Avoid skb_pull() failure in
ipgre_xmit()
Hi Suman,
On Sun, 3 Dec 2023 06:58:19 +0000, Suman Ghosh wrote:
> Hi Shigeru,
>
>>diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index
>>22a26d1d29a0..5169c3c72cff 100644
>>--- a/net/ipv4/ip_gre.c
>>+++ b/net/ipv4/ip_gre.c
>>@@ -635,15 +635,18 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
>> }
>>
>> if (dev->header_ops) {
>>+ int pull_len = tunnel->hlen + sizeof(struct iphdr);
>>+
>> if (skb_cow_head(skb, 0))
>> goto free_skb;
>>
>> tnl_params = (const struct iphdr *)skb->data;
>>
>>- /* Pull skb since ip_tunnel_xmit() needs skb->data pointing
>>- * to gre header.
>>- */
>>- skb_pull(skb, tunnel->hlen + sizeof(struct iphdr));
>>+ if (!pskb_network_may_pull(skb, pull_len))
> [Suman] Since this is transmit path, should we add unlikely() here?
Thanks for your comment.
I traced this function and found that pskb_may_pull_reason() seems to
have appropriate likely() and unlikely() as Eric says.
I'm new to Linux networking. Could you kindly explain the background
of your suggestion?
I understand that a transmit path must be as fast as possible, so we
should use unlikely() for rare cases such like this error path. Am I
correct?
Thanks,
Shigeru
>>+ goto free_skb;
>>+
>>+ /* ip_tunnel_xmit() needs skb->data pointing to gre header. */
>>+ skb_pull(skb, pull_len);
>> skb_reset_mac_header(skb);
>>
>> if (skb->ip_summed == CHECKSUM_PARTIAL &&
>>--
>>2.41.0
>>
>
Powered by blists - more mailing lists