neigh_lookup() accepts struct neigh_table *tbl and struct net_device *dev, and both of them must exist in the same netns. It is error-prone to require callers to fetch a netns and get neigh_table, which might belong to a different netns than dev_net(dev). Let's add IPv4-specific wrappers for neigh_lookup() and neigh_create() that always fetch netns from dev. Note that we do not add wrappers for __neigh_lookup() and __neigh_lookup_errno(), which we will remove later. __neigh_lookup_errno() is a simple combo of neigh_lookup() and neigh_create(). __neigh_lookup() is almost the same but converts errno from neigh_create() to NULL. So both names are confusing. For IPv4, __neigh_lookup_errno() is only used in arp_req_set() and is not worth a new wrapper. Instead, it should be inlined. arp_process() uses __neigh_lookup(create=0) but it should simply be neigh_lookup(), and then __neigh_lookup(create=1) is only used in arp_process(), so this should be inlined too. Signed-off-by: Kuniyuki Iwashima --- include/net/arp.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/net/arp.h b/include/net/arp.h index e932def63d62..329a5456987a 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -51,6 +51,22 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 return n; } +static inline struct neighbour *ipv4_neigh_lookup(struct net_device *dev, + const void *pkey) +{ + struct neigh_table *tbl = arp_table(dev_net(dev)); + + return neigh_lookup(tbl, pkey, dev); +} + +static inline struct neighbour *ipv4_neigh_create(struct net_device *dev, + const void *pkey) +{ + struct neigh_table *tbl = arp_table(dev_net(dev)); + + return neigh_create(tbl, pkey, dev); +} + static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key) { struct neighbour *n; -- 2.56.0.rc1.315.gc6ed9934b7-goog