[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1459198950.6473.129.camel@edumazet-glaptop3.roam.corp.google.com>
Date: Mon, 28 Mar 2016 14:02:30 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Tom Herbert <tom@...bertland.com>
Cc: Eric Dumazet <edumazet@...gle.com>,
"David S . Miller" <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>
Subject: Re: [RFC net-next 2/2] udp: No longer use SLAB_DESTROY_BY_RCU
On Fri, 2016-03-25 at 17:08 -0700, Tom Herbert wrote:
> On Fri, Mar 25, 2016 at 3:29 PM, Eric Dumazet <edumazet@...gle.com> wrote:
> > +/* Must be called under rcu_read_lock().
>
>
> It might be just as easy to do the rcu_read_lock() within the
> function. That way we don't need to require callers to do it now.
>
> > + * Does increment socket refcount.
> > + */
> > +#if IS_ENABLED(CONFIG_NETFILTER_XT_MATCH_SOCKET) || \
> > + IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY)
> > struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
> > __be32 daddr, __be16 dport, int dif)
> > {
> > - return __udp4_lib_lookup(net, saddr, sport, daddr, dport, dif,
> > - &udp_table, NULL);
> > + struct sock *sk;
> > +
> > + sk = __udp4_lib_lookup(net, saddr, sport, daddr, dport,
> > + dif, &udp_table, NULL);
> > + if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
> > + sk = NULL;
> > + return sk;
> > }
> > EXPORT_SYMBOL_GPL(udp4_lib_lookup);
> > +#endif
Well, these callers already run with rcu_read_lock(), I simply added a
comment to remind this assumption.
As I said, we might later avoid the refcounting if callers are modified
to not call sock_put(). This is why I prefer to maintain the reuirement
of rcu_read_lock() being held by callers anyway.
Powered by blists - more mailing lists