Skip to content

Commit dd103c9

Browse files
q2venkuba-moo
authored andcommitted
neighbour: Remove __pneigh_lookup().
__pneigh_lookup() is the lockless version of pneigh_lookup(), but its only caller pndisc_is_router() holds the table lock and reads pneigh_netry.flags. This is because accessing pneigh_entry after pneigh_lookup() was illegal unless the caller holds RTNL or the table lock. Now, pneigh_entry is guaranteed to be alive during the RCU critical section. Let's call pneigh_lookup() and use READ_ONCE() for n->flags in pndisc_is_router() and remove __pneigh_lookup(). Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b9c89fa commit dd103c9

File tree

3 files changed

+2
-17
lines changed

3 files changed

+2
-17
lines changed

include/net/neighbour.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
381381
struct sk_buff *skb);
382382
struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net,
383383
const void *key, struct net_device *dev);
384-
struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl, struct net *net,
385-
const void *key, struct net_device *dev);
386384
struct pneigh_entry *pneigh_create(struct neigh_table *tbl, struct net *net,
387385
const void *key, struct net_device *dev);
388386
int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key,

net/core/neighbour.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,17 +737,6 @@ static struct pneigh_entry *__pneigh_lookup_1(struct pneigh_entry *n,
737737
return NULL;
738738
}
739739

740-
struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl,
741-
struct net *net, const void *pkey, struct net_device *dev)
742-
{
743-
unsigned int key_len = tbl->key_len;
744-
u32 hash_val = pneigh_hash(pkey, key_len);
745-
746-
return __pneigh_lookup_1(rcu_dereference_protected(tbl->phash_buckets[hash_val], 1),
747-
net, pkey, key_len, dev);
748-
}
749-
EXPORT_SYMBOL_GPL(__pneigh_lookup);
750-
751740
struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl,
752741
struct net *net, const void *pkey,
753742
struct net_device *dev)

net/ipv6/ndisc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,9 @@ static int pndisc_is_router(const void *pkey,
768768
struct pneigh_entry *n;
769769
int ret = -1;
770770

771-
read_lock_bh(&nd_tbl.lock);
772-
n = __pneigh_lookup(&nd_tbl, dev_net(dev), pkey, dev);
771+
n = pneigh_lookup(&nd_tbl, dev_net(dev), pkey, dev);
773772
if (n)
774-
ret = !!(n->flags & NTF_ROUTER);
775-
read_unlock_bh(&nd_tbl.lock);
773+
ret = !!(READ_ONCE(n->flags) & NTF_ROUTER);
776774

777775
return ret;
778776
}

0 commit comments

Comments
 (0)