lkml.org 
[lkml]   [2021]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH IPV6 1/1] ipv6: allocate enough headroom in ip6_finish_output2()
From
Date
On 7/7/21 8:41 PM, Eric Dumazet wrote:
> On 7/7/21 6:42 PM, Jakub Kicinski wrote:
>> On Wed, 7 Jul 2021 08:45:13 -0600 David Ahern wrote:
>>> On 7/7/21 8:04 AM, Vasily Averin wrote:
>>>> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
>>>> index ff4f9eb..e5af740 100644
>>>> --- a/net/ipv6/ip6_output.c
>>>> +++ b/net/ipv6/ip6_output.c
>>>> @@ -61,9 +61,24 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *
>>>> struct dst_entry *dst = skb_dst(skb);
>>>> struct net_device *dev = dst->dev;
>>>> const struct in6_addr *nexthop;
>>>> + unsigned int hh_len = LL_RESERVED_SPACE(dev);
>>>> struct neighbour *neigh;
>>>> int ret;
>>>>
>>>> + /* Be paranoid, rather than too clever. */
>>>> + if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
>>>> + struct sk_buff *skb2;
>>>> +
>>>> + skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
>>>
>>> why not use hh_len here?
>>
>> Is there a reason for the new skb? Why not pskb_expand_head()?
>
> pskb_expand_head() might crash, if skb is shared.
>
> We possibly can add a helper, factorizing all this,
> and eventually use pskb_expand_head() if safe.

Thank you for feedback, I'll do it in 2nd version.
Vasily Averin

\
 
 \ /
  Last update: 2021-07-07 19:53    [W:0.376 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site