[PATCH v2 net-next 12/13] neighbour: Remove unnecessary net_eq().
Kuniyuki Iwashima <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
neigh_table is now per-netns, and net_eq() is no longer needed. Let's remove them. As a bonus, each netns can configure the default table param (ifindex==0) and GC parameters via RTM_SETNEIGHTBL. Signed-off-by: Kuniyuki Iwashima <[email protected]> --- v2: Split pneigh part into the prev patch --- net/core/neighbour.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 23ce17de23e3..e22b0fe4b952 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1732,13 +1732,13 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, } static inline struct neigh_parms *lookup_neigh_parms(struct neigh_table *tbl, - struct net *net, int ifindex) + int ifindex) { struct neigh_parms *p; list_for_each_entry(p, &tbl->parms_list, list) { - if ((p->dev && p->dev->ifindex == ifindex && net_eq(neigh_parms_net(p), net)) || - (!p->dev && !ifindex && net_eq(net, &init_net))) + if ((p->dev && p->dev->ifindex == ifindex) || + (!p->dev && !ifindex)) return p; } @@ -2456,8 +2456,8 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, if (tbp[NDTPA_IFINDEX]) ifindex = nla_get_u32(tbp[NDTPA_IFINDEX]); - p = lookup_neigh_parms(tbl, net, ifindex); - if (p == NULL) { + p = lookup_neigh_parms(tbl, ifindex); + if (!p) { err = -ENOENT; goto errout_tbl_lock; } @@ -2538,12 +2538,6 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, } } - err = -ENOENT; - if ((tb[NDTA_THRESH1] || tb[NDTA_THRESH2] || - tb[NDTA_THRESH3] || tb[NDTA_GC_INTERVAL]) && - !net_eq(net, &init_net)) - goto errout_tbl_lock; - if (tb[NDTA_THRESH1]) WRITE_ONCE(tbl->gc_thresh1, nla_get_u32(tb[NDTA_THRESH1])); @@ -2626,9 +2620,6 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) nidx = 0; p = list_next_entry(&tbl->parms, list); list_for_each_entry_from_rcu(p, &tbl->parms_list, list) { - if (!net_eq(neigh_parms_net(p), net)) - continue; - if (nidx < neigh_skip) goto next; @@ -2806,12 +2797,11 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, struct netlink_callback *cb, struct neigh_dump_filter *filter) { - struct net *net = sock_net(skb->sk); - struct neighbour *n; - int err = 0, h, s_h = cb->args[1]; int idx, s_idx = idx = cb->args[2]; - struct neigh_hash_table *nht; + int err = 0, h, s_h = cb->args[1]; unsigned int flags = NLM_F_MULTI; + struct neigh_hash_table *nht; + struct neighbour *n; if (filter->dev_idx || filter->master_idx) flags |= NLM_F_DUMP_FILTERED; @@ -2823,7 +2813,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, s_idx = 0; idx = 0; neigh_for_each_in_bucket_rcu(n, &nht->hash_heads[h]) { - if (idx < s_idx || !net_eq(dev_net(n->dev), net)) + if (idx < s_idx) goto next; if (neigh_ifindex_filtered(n->dev, filter->dev_idx) || neigh_master_filtered(n->dev, filter->master_idx)) @@ -3228,10 +3218,6 @@ static struct neighbour *neigh_get_valid(struct seq_file *seq, loff_t *pos) { struct neigh_seq_state *state = seq->private; - struct net *net = seq_file_net(seq); - - if (!net_eq(dev_net(n->dev), net)) - return NULL; if (state->neigh_sub_iter) { loff_t fakep = 0; -- 2.55.0.679.g6767b8d81c-goog