On Thu, Mar 24, 2016 at 1:35 PM, Eric Dumazet <eric.duma...@gmail.com> wrote:
> On Thu, 2016-03-24 at 12:25 -0700, Cong Wang wrote:
>
>>  void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu)
>>  {
>> -     ip6_update_pmtu(skb, sock_net(sk), mtu,
>> -                     sk->sk_bound_dev_if, sk->sk_mark);
>> +     const struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
>> +     struct net *net = sock_net(sk);
>> +     struct dst_entry *ndst, *dst;
>> +     struct flowi6 fl6;
>> +     bool new = false;
>> +
>> +     memset(&fl6, 0, sizeof(fl6));
>> +
>> +     bh_lock_sock(sk);
>> +
>
>
> This is not clear why you need to acquire socket lock.
>
> sk_dst_cache is protected by an atomic operation.
>
> udp for example calls ip6_dst_store() without socket being locked.

My understanding is that bh_lock_sock() prevents concurrent
access to sock struct. Since this is in softirq context, multiple
CPU's could call this function concurrently, the whole pmtu
update needs to be done atomically.

UDP, on the other hand, doesn't do this logic, it just looks up
for dst and save it in sk_dst_cache.

Reply via email to