提交 878628fb 编写于 作者: Y YOSHIFUJI Hideaki

[NET] NETNS: Omit namespace comparision without CONFIG_NET_NS.

Introduce an inline net_eq() to compare two namespaces.
Without CONFIG_NET_NS, since no namespace other than &init_net
exists, it is always 1.

We do not need to convert 1) inline vs inline and
2) inline vs &init_net comparisons.
Signed-off-by: NYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
上级 57da52c1
...@@ -118,6 +118,12 @@ static inline void release_net(struct net *net) ...@@ -118,6 +118,12 @@ static inline void release_net(struct net *net)
{ {
atomic_dec(&net->use_count); atomic_dec(&net->use_count);
} }
static inline
int net_eq(const struct net *net1, const struct net *net2)
{
return net1 == net2;
}
#else #else
static inline struct net *get_net(struct net *net) static inline struct net *get_net(struct net *net)
{ {
...@@ -141,6 +147,12 @@ static inline struct net *maybe_get_net(struct net *net) ...@@ -141,6 +147,12 @@ static inline struct net *maybe_get_net(struct net *net)
{ {
return net; return net;
} }
static inline
int net_eq(const struct net *net1, const struct net *net2)
{
return 1;
}
#endif #endif
#define for_each_net(VAR) \ #define for_each_net(VAR) \
......
...@@ -4136,7 +4136,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char ...@@ -4136,7 +4136,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
/* Get out if there is nothing todo */ /* Get out if there is nothing todo */
err = 0; err = 0;
if (dev_net(dev) == net) if (net_eq(dev_net(dev), net))
goto out; goto out;
/* Pick the destination device name, and ensure /* Pick the destination device name, and ensure
......
...@@ -388,7 +388,7 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net, ...@@ -388,7 +388,7 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net,
hash_val = tbl->hash(pkey, NULL); hash_val = tbl->hash(pkey, NULL);
for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) {
if (!memcmp(n->primary_key, pkey, key_len) && if (!memcmp(n->primary_key, pkey, key_len) &&
dev_net(n->dev) == net) { net_eq(dev_net(n->dev), net)) {
neigh_hold(n); neigh_hold(n);
NEIGH_CACHE_STAT_INC(tbl, hits); NEIGH_CACHE_STAT_INC(tbl, hits);
break; break;
...@@ -483,7 +483,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl, ...@@ -483,7 +483,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
for (n = tbl->phash_buckets[hash_val]; n; n = n->next) { for (n = tbl->phash_buckets[hash_val]; n; n = n->next) {
if (!memcmp(n->key, pkey, key_len) && if (!memcmp(n->key, pkey, key_len) &&
(pneigh_net(n) == net) && net_eq(pneigh_net(n), net) &&
(n->dev == dev || !n->dev)) { (n->dev == dev || !n->dev)) {
read_unlock_bh(&tbl->lock); read_unlock_bh(&tbl->lock);
goto out; goto out;
...@@ -542,7 +542,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey, ...@@ -542,7 +542,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
for (np = &tbl->phash_buckets[hash_val]; (n = *np) != NULL; for (np = &tbl->phash_buckets[hash_val]; (n = *np) != NULL;
np = &n->next) { np = &n->next) {
if (!memcmp(n->key, pkey, key_len) && n->dev == dev && if (!memcmp(n->key, pkey, key_len) && n->dev == dev &&
(pneigh_net(n) == net)) { net_eq(pneigh_net(n), net)) {
*np = n->next; *np = n->next;
write_unlock_bh(&tbl->lock); write_unlock_bh(&tbl->lock);
if (tbl->pdestructor) if (tbl->pdestructor)
...@@ -1286,7 +1286,7 @@ static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl, ...@@ -1286,7 +1286,7 @@ static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl,
struct neigh_parms *p; struct neigh_parms *p;
for (p = &tbl->parms; p; p = p->next) { for (p = &tbl->parms; p; p = p->next) {
if ((p->dev && p->dev->ifindex == ifindex && neigh_parms_net(p) == net) || if ((p->dev && p->dev->ifindex == ifindex && net_eq(neigh_parms_net(p), net)) ||
(!p->dev && !ifindex)) (!p->dev && !ifindex))
return p; return p;
} }
...@@ -1964,7 +1964,7 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1964,7 +1964,7 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
break; break;
for (nidx = 0, p = tbl->parms.next; p; p = p->next) { for (nidx = 0, p = tbl->parms.next; p; p = p->next) {
if (net != neigh_parms_net(p)) if (!net_eq(neigh_parms_net(p), net))
continue; continue;
if (nidx++ < neigh_skip) if (nidx++ < neigh_skip)
...@@ -2161,7 +2161,7 @@ static struct neighbour *neigh_get_first(struct seq_file *seq) ...@@ -2161,7 +2161,7 @@ static struct neighbour *neigh_get_first(struct seq_file *seq)
n = tbl->hash_buckets[bucket]; n = tbl->hash_buckets[bucket];
while (n) { while (n) {
if (dev_net(n->dev) != net) if (!net_eq(dev_net(n->dev), net))
goto next; goto next;
if (state->neigh_sub_iter) { if (state->neigh_sub_iter) {
loff_t fakep = 0; loff_t fakep = 0;
...@@ -2204,7 +2204,7 @@ static struct neighbour *neigh_get_next(struct seq_file *seq, ...@@ -2204,7 +2204,7 @@ static struct neighbour *neigh_get_next(struct seq_file *seq,
while (1) { while (1) {
while (n) { while (n) {
if (dev_net(n->dev) != net) if (!net_eq(dev_net(n->dev), net))
goto next; goto next;
if (state->neigh_sub_iter) { if (state->neigh_sub_iter) {
void *v = state->neigh_sub_iter(state, n, pos); void *v = state->neigh_sub_iter(state, n, pos);
...@@ -2260,7 +2260,7 @@ static struct pneigh_entry *pneigh_get_first(struct seq_file *seq) ...@@ -2260,7 +2260,7 @@ static struct pneigh_entry *pneigh_get_first(struct seq_file *seq)
state->flags |= NEIGH_SEQ_IS_PNEIGH; state->flags |= NEIGH_SEQ_IS_PNEIGH;
for (bucket = 0; bucket <= PNEIGH_HASHMASK; bucket++) { for (bucket = 0; bucket <= PNEIGH_HASHMASK; bucket++) {
pn = tbl->phash_buckets[bucket]; pn = tbl->phash_buckets[bucket];
while (pn && (pneigh_net(pn) != net)) while (pn && !net_eq(pneigh_net(pn), net))
pn = pn->next; pn = pn->next;
if (pn) if (pn)
break; break;
...@@ -2283,7 +2283,7 @@ static struct pneigh_entry *pneigh_get_next(struct seq_file *seq, ...@@ -2283,7 +2283,7 @@ static struct pneigh_entry *pneigh_get_next(struct seq_file *seq,
if (++state->bucket > PNEIGH_HASHMASK) if (++state->bucket > PNEIGH_HASHMASK)
break; break;
pn = tbl->phash_buckets[state->bucket]; pn = tbl->phash_buckets[state->bucket];
while (pn && (pneigh_net(pn) != net)) while (pn && !net_eq(pneigh_net(pn), net))
pn = pn->next; pn = pn->next;
if (pn) if (pn)
break; break;
......
...@@ -139,7 +139,7 @@ static struct sock *inet_lookup_listener_slow(struct net *net, ...@@ -139,7 +139,7 @@ static struct sock *inet_lookup_listener_slow(struct net *net,
sk_for_each(sk, node, head) { sk_for_each(sk, node, head) {
const struct inet_sock *inet = inet_sk(sk); const struct inet_sock *inet = inet_sk(sk);
if (sock_net(sk) == net && inet->num == hnum && if (net_eq(sock_net(sk), net) && inet->num == hnum &&
!ipv6_only_sock(sk)) { !ipv6_only_sock(sk)) {
const __be32 rcv_saddr = inet->rcv_saddr; const __be32 rcv_saddr = inet->rcv_saddr;
int score = sk->sk_family == PF_INET ? 1 : 0; int score = sk->sk_family == PF_INET ? 1 : 0;
...@@ -182,7 +182,7 @@ struct sock *__inet_lookup_listener(struct net *net, ...@@ -182,7 +182,7 @@ struct sock *__inet_lookup_listener(struct net *net,
if (inet->num == hnum && !sk->sk_node.next && if (inet->num == hnum && !sk->sk_node.next &&
(!inet->rcv_saddr || inet->rcv_saddr == daddr) && (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
(sk->sk_family == PF_INET || !ipv6_only_sock(sk)) && (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
!sk->sk_bound_dev_if && sock_net(sk) == net) !sk->sk_bound_dev_if && net_eq(sock_net(sk), net))
goto sherry_cache; goto sherry_cache;
sk = inet_lookup_listener_slow(net, head, daddr, hnum, dif); sk = inet_lookup_listener_slow(net, head, daddr, hnum, dif);
} }
......
...@@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk, ...@@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
sk_for_each_from(sk, node) { sk_for_each_from(sk, node) {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
if (sock_net(sk) == net && inet->num == num && if (net_eq(sock_net(sk), net) && inet->num == num &&
!(inet->daddr && inet->daddr != raddr) && !(inet->daddr && inet->daddr != raddr) &&
!(inet->rcv_saddr && inet->rcv_saddr != laddr) && !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
!(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
......
...@@ -1196,7 +1196,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, ...@@ -1196,7 +1196,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
rth->fl.oif != ikeys[k] || rth->fl.oif != ikeys[k] ||
rth->fl.iif != 0 || rth->fl.iif != 0 ||
rth->rt_genid != atomic_read(&rt_genid) || rth->rt_genid != atomic_read(&rt_genid) ||
dev_net(rth->u.dst.dev) != net) { !net_eq(dev_net(rth->u.dst.dev), net)) {
rthp = &rth->u.dst.rt_next; rthp = &rth->u.dst.rt_next;
continue; continue;
} }
...@@ -1455,7 +1455,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, ...@@ -1455,7 +1455,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
rth->rt_src == iph->saddr && rth->rt_src == iph->saddr &&
rth->fl.iif == 0 && rth->fl.iif == 0 &&
!(dst_metric_locked(&rth->u.dst, RTAX_MTU)) && !(dst_metric_locked(&rth->u.dst, RTAX_MTU)) &&
dev_net(rth->u.dst.dev) == net && net_eq(dev_net(rth->u.dst.dev), net) &&
rth->rt_genid == atomic_read(&rt_genid)) { rth->rt_genid == atomic_read(&rt_genid)) {
unsigned short mtu = new_mtu; unsigned short mtu = new_mtu;
...@@ -2085,7 +2085,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -2085,7 +2085,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
rth->fl.oif == 0 && rth->fl.oif == 0 &&
rth->fl.mark == skb->mark && rth->fl.mark == skb->mark &&
rth->fl.fl4_tos == tos && rth->fl.fl4_tos == tos &&
dev_net(rth->u.dst.dev) == net && net_eq(dev_net(rth->u.dst.dev), net) &&
rth->rt_genid == atomic_read(&rt_genid)) { rth->rt_genid == atomic_read(&rt_genid)) {
dst_use(&rth->u.dst, jiffies); dst_use(&rth->u.dst, jiffies);
RT_CACHE_STAT_INC(in_hit); RT_CACHE_STAT_INC(in_hit);
...@@ -2487,7 +2487,7 @@ int __ip_route_output_key(struct net *net, struct rtable **rp, ...@@ -2487,7 +2487,7 @@ int __ip_route_output_key(struct net *net, struct rtable **rp,
rth->fl.mark == flp->mark && rth->fl.mark == flp->mark &&
!((rth->fl.fl4_tos ^ flp->fl4_tos) & !((rth->fl.fl4_tos ^ flp->fl4_tos) &
(IPTOS_RT_MASK | RTO_ONLINK)) && (IPTOS_RT_MASK | RTO_ONLINK)) &&
dev_net(rth->u.dst.dev) == net && net_eq(dev_net(rth->u.dst.dev), net) &&
rth->rt_genid == atomic_read(&rt_genid)) { rth->rt_genid == atomic_read(&rt_genid)) {
dst_use(&rth->u.dst, jiffies); dst_use(&rth->u.dst, jiffies);
RT_CACHE_STAT_INC(out_hit); RT_CACHE_STAT_INC(out_hit);
...@@ -2796,7 +2796,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2796,7 +2796,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
rcu_read_lock_bh(); rcu_read_lock_bh();
for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt; for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt;
rt = rcu_dereference(rt->u.dst.rt_next), idx++) { rt = rcu_dereference(rt->u.dst.rt_next), idx++) {
if (dev_net(rt->u.dst.dev) != net || idx < s_idx) if (!net_eq(dev_net(rt->u.dst.dev), net) || idx < s_idx)
continue; continue;
if (rt->rt_genid != atomic_read(&rt_genid)) if (rt->rt_genid != atomic_read(&rt_genid))
continue; continue;
......
...@@ -1974,7 +1974,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur) ...@@ -1974,7 +1974,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
while (1) { while (1) {
while (req) { while (req) {
if (req->rsk_ops->family == st->family && if (req->rsk_ops->family == st->family &&
sock_net(req->sk) == net) { net_eq(sock_net(req->sk), net)) {
cur = req; cur = req;
goto out; goto out;
} }
...@@ -1998,7 +1998,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur) ...@@ -1998,7 +1998,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
} }
get_sk: get_sk:
sk_for_each_from(sk, node) { sk_for_each_from(sk, node) {
if (sk->sk_family == st->family && sock_net(sk) == net) { if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
cur = sk; cur = sk;
goto out; goto out;
} }
...@@ -2049,7 +2049,7 @@ static void *established_get_first(struct seq_file *seq) ...@@ -2049,7 +2049,7 @@ static void *established_get_first(struct seq_file *seq)
read_lock_bh(lock); read_lock_bh(lock);
sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
if (sk->sk_family != st->family || if (sk->sk_family != st->family ||
sock_net(sk) != net) { !net_eq(sock_net(sk), net)) {
continue; continue;
} }
rc = sk; rc = sk;
...@@ -2059,7 +2059,7 @@ static void *established_get_first(struct seq_file *seq) ...@@ -2059,7 +2059,7 @@ static void *established_get_first(struct seq_file *seq)
inet_twsk_for_each(tw, node, inet_twsk_for_each(tw, node,
&tcp_hashinfo.ehash[st->bucket].twchain) { &tcp_hashinfo.ehash[st->bucket].twchain) {
if (tw->tw_family != st->family || if (tw->tw_family != st->family ||
twsk_net(tw) != net) { !net_eq(twsk_net(tw), net)) {
continue; continue;
} }
rc = tw; rc = tw;
...@@ -2086,7 +2086,7 @@ static void *established_get_next(struct seq_file *seq, void *cur) ...@@ -2086,7 +2086,7 @@ static void *established_get_next(struct seq_file *seq, void *cur)
tw = cur; tw = cur;
tw = tw_next(tw); tw = tw_next(tw);
get_tw: get_tw:
while (tw && (tw->tw_family != st->family || twsk_net(tw) != net)) { while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
tw = tw_next(tw); tw = tw_next(tw);
} }
if (tw) { if (tw) {
...@@ -2107,7 +2107,7 @@ static void *established_get_next(struct seq_file *seq, void *cur) ...@@ -2107,7 +2107,7 @@ static void *established_get_next(struct seq_file *seq, void *cur)
sk = sk_next(sk); sk = sk_next(sk);
sk_for_each_from(sk, node) { sk_for_each_from(sk, node) {
if (sk->sk_family == st->family && sock_net(sk) == net) if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
goto found; goto found;
} }
......
...@@ -137,7 +137,7 @@ static inline int __udp_lib_lport_inuse(struct net *net, __u16 num, ...@@ -137,7 +137,7 @@ static inline int __udp_lib_lport_inuse(struct net *net, __u16 num,
struct hlist_node *node; struct hlist_node *node;
sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)]) sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)])
if (sock_net(sk) == net && sk->sk_hash == num) if (net_eq(sock_net(sk), net) && sk->sk_hash == num)
return 1; return 1;
return 0; return 0;
} }
...@@ -218,7 +218,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum, ...@@ -218,7 +218,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
sk_for_each(sk2, node, head) sk_for_each(sk2, node, head)
if (sk2->sk_hash == snum && if (sk2->sk_hash == snum &&
sk2 != sk && sk2 != sk &&
sock_net(sk2) == net && net_eq(sock_net(sk2), net) &&
(!sk2->sk_reuse || !sk->sk_reuse) && (!sk2->sk_reuse || !sk->sk_reuse) &&
(!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if
|| sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
...@@ -269,7 +269,7 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, ...@@ -269,7 +269,7 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
if (sock_net(sk) == net && sk->sk_hash == hnum && if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
!ipv6_only_sock(sk)) { !ipv6_only_sock(sk)) {
int score = (sk->sk_family == PF_INET ? 1 : 0); int score = (sk->sk_family == PF_INET ? 1 : 0);
if (inet->rcv_saddr) { if (inet->rcv_saddr) {
...@@ -1511,7 +1511,7 @@ static struct sock *udp_get_first(struct seq_file *seq) ...@@ -1511,7 +1511,7 @@ static struct sock *udp_get_first(struct seq_file *seq)
for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) { for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
struct hlist_node *node; struct hlist_node *node;
sk_for_each(sk, node, state->hashtable + state->bucket) { sk_for_each(sk, node, state->hashtable + state->bucket) {
if (sock_net(sk) != net) if (!net_eq(sock_net(sk), net))
continue; continue;
if (sk->sk_family == state->family) if (sk->sk_family == state->family)
goto found; goto found;
...@@ -1531,7 +1531,7 @@ static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk) ...@@ -1531,7 +1531,7 @@ static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
sk = sk_next(sk); sk = sk_next(sk);
try_again: try_again:
; ;
} while (sk && (sock_net(sk) != net || sk->sk_family != state->family)); } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
if (!sk && ++state->bucket < UDP_HTABLE_SIZE) { if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
sk = sk_head(state->hashtable + state->bucket); sk = sk_head(state->hashtable + state->bucket);
......
...@@ -1217,7 +1217,7 @@ int ipv6_chk_addr(struct net *net, struct in6_addr *addr, ...@@ -1217,7 +1217,7 @@ int ipv6_chk_addr(struct net *net, struct in6_addr *addr,
read_lock_bh(&addrconf_hash_lock); read_lock_bh(&addrconf_hash_lock);
for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
if (dev_net(ifp->idev->dev) != net) if (!net_eq(dev_net(ifp->idev->dev), net))
continue; continue;
if (ipv6_addr_equal(&ifp->addr, addr) && if (ipv6_addr_equal(&ifp->addr, addr) &&
!(ifp->flags&IFA_F_TENTATIVE)) { !(ifp->flags&IFA_F_TENTATIVE)) {
...@@ -1239,7 +1239,7 @@ int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr, ...@@ -1239,7 +1239,7 @@ int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
u8 hash = ipv6_addr_hash(addr); u8 hash = ipv6_addr_hash(addr);
for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
if (dev_net(ifp->idev->dev) != net) if (!net_eq(dev_net(ifp->idev->dev), net))
continue; continue;
if (ipv6_addr_equal(&ifp->addr, addr)) { if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev) if (dev == NULL || ifp->idev->dev == dev)
...@@ -1257,7 +1257,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, struct in6_addr *addr, ...@@ -1257,7 +1257,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, struct in6_addr *addr,
read_lock_bh(&addrconf_hash_lock); read_lock_bh(&addrconf_hash_lock);
for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) { for(ifp = inet6_addr_lst[hash]; ifp; ifp=ifp->lst_next) {
if (dev_net(ifp->idev->dev) != net) if (!net_eq(dev_net(ifp->idev->dev), net))
continue; continue;
if (ipv6_addr_equal(&ifp->addr, addr)) { if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev || if (dev == NULL || ifp->idev->dev == dev ||
...@@ -2771,7 +2771,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq) ...@@ -2771,7 +2771,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq)
for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) { for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
ifa = inet6_addr_lst[state->bucket]; ifa = inet6_addr_lst[state->bucket];
while (ifa && dev_net(ifa->idev->dev) != net) while (ifa && !net_eq(dev_net(ifa->idev->dev), net))
ifa = ifa->lst_next; ifa = ifa->lst_next;
if (ifa) if (ifa)
break; break;
...@@ -2787,7 +2787,7 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, struct inet6_ifad ...@@ -2787,7 +2787,7 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, struct inet6_ifad
ifa = ifa->lst_next; ifa = ifa->lst_next;
try_again: try_again:
if (ifa) { if (ifa) {
if (dev_net(ifa->idev->dev) != net) { if (!net_eq(dev_net(ifa->idev->dev), net)) {
ifa = ifa->lst_next; ifa = ifa->lst_next;
goto try_again; goto try_again;
} }
...@@ -2905,7 +2905,7 @@ int ipv6_chk_home_addr(struct net *net, struct in6_addr *addr) ...@@ -2905,7 +2905,7 @@ int ipv6_chk_home_addr(struct net *net, struct in6_addr *addr)
u8 hash = ipv6_addr_hash(addr); u8 hash = ipv6_addr_hash(addr);
read_lock_bh(&addrconf_hash_lock); read_lock_bh(&addrconf_hash_lock);
for (ifp = inet6_addr_lst[hash]; ifp; ifp = ifp->lst_next) { for (ifp = inet6_addr_lst[hash]; ifp; ifp = ifp->lst_next) {
if (dev_net(ifp->idev->dev) != net) if (!net_eq(dev_net(ifp->idev->dev), net))
continue; continue;
if (ipv6_addr_cmp(&ifp->addr, addr) == 0 && if (ipv6_addr_cmp(&ifp->addr, addr) == 0 &&
(ifp->flags & IFA_F_HOMEADDRESS)) { (ifp->flags & IFA_F_HOMEADDRESS)) {
......
...@@ -105,7 +105,7 @@ struct sock *inet6_lookup_listener(struct net *net, ...@@ -105,7 +105,7 @@ struct sock *inet6_lookup_listener(struct net *net,
read_lock(&hashinfo->lhash_lock); read_lock(&hashinfo->lhash_lock);
sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) {
if (sock_net(sk) == net && inet_sk(sk)->num == hnum && if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum &&
sk->sk_family == PF_INET6) { sk->sk_family == PF_INET6) {
const struct ipv6_pinfo *np = inet6_sk(sk); const struct ipv6_pinfo *np = inet6_sk(sk);
......
...@@ -76,7 +76,7 @@ static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk, ...@@ -76,7 +76,7 @@ static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
if (inet_sk(sk)->num == num) { if (inet_sk(sk)->num == num) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
if (sock_net(sk) != net) if (!net_eq(sock_net(sk), net))
continue; continue;
if (!ipv6_addr_any(&np->daddr) && if (!ipv6_addr_any(&np->daddr) &&
......
...@@ -70,7 +70,7 @@ static struct sock *__udp6_lib_lookup(struct net *net, ...@@ -70,7 +70,7 @@ static struct sock *__udp6_lib_lookup(struct net *net,
sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
if (sock_net(sk) == net && sk->sk_hash == hnum && if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
sk->sk_family == PF_INET6) { sk->sk_family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
int score = 0; int score = 0;
......
...@@ -228,7 +228,7 @@ static inline struct sock *netlink_lookup(struct net *net, int protocol, ...@@ -228,7 +228,7 @@ static inline struct sock *netlink_lookup(struct net *net, int protocol,
read_lock(&nl_table_lock); read_lock(&nl_table_lock);
head = nl_pid_hashfn(hash, pid); head = nl_pid_hashfn(hash, pid);
sk_for_each(sk, node, head) { sk_for_each(sk, node, head) {
if (sock_net(sk) == net && (nlk_sk(sk)->pid == pid)) { if (net_eq(sock_net(sk), net) && (nlk_sk(sk)->pid == pid)) {
sock_hold(sk); sock_hold(sk);
goto found; goto found;
} }
...@@ -348,7 +348,7 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 pid) ...@@ -348,7 +348,7 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 pid)
head = nl_pid_hashfn(hash, pid); head = nl_pid_hashfn(hash, pid);
len = 0; len = 0;
sk_for_each(osk, node, head) { sk_for_each(osk, node, head) {
if (sock_net(osk) == net && (nlk_sk(osk)->pid == pid)) if (net_eq(sock_net(osk), net) && (nlk_sk(osk)->pid == pid))
break; break;
len++; len++;
} }
...@@ -532,7 +532,7 @@ static int netlink_autobind(struct socket *sock) ...@@ -532,7 +532,7 @@ static int netlink_autobind(struct socket *sock)
netlink_table_grab(); netlink_table_grab();
head = nl_pid_hashfn(hash, pid); head = nl_pid_hashfn(hash, pid);
sk_for_each(osk, node, head) { sk_for_each(osk, node, head) {
if (sock_net(osk) != net) if (!net_eq(sock_net(osk), net))
continue; continue;
if (nlk_sk(osk)->pid == pid) { if (nlk_sk(osk)->pid == pid) {
/* Bind collision, search negative pid values. */ /* Bind collision, search negative pid values. */
...@@ -962,7 +962,7 @@ static inline int do_one_broadcast(struct sock *sk, ...@@ -962,7 +962,7 @@ static inline int do_one_broadcast(struct sock *sk,
!test_bit(p->group - 1, nlk->groups)) !test_bit(p->group - 1, nlk->groups))
goto out; goto out;
if (sock_net(sk) != p->net) if (!net_eq(sock_net(sk), p->net))
goto out; goto out;
if (p->failure) { if (p->failure) {
......
...@@ -252,7 +252,7 @@ static struct sock *__unix_find_socket_byname(struct net *net, ...@@ -252,7 +252,7 @@ static struct sock *__unix_find_socket_byname(struct net *net,
sk_for_each(s, node, &unix_socket_table[hash ^ type]) { sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
struct unix_sock *u = unix_sk(s); struct unix_sock *u = unix_sk(s);
if (sock_net(s) != net) if (!net_eq(sock_net(s), net))
continue; continue;
if (u->addr->len == len && if (u->addr->len == len &&
...@@ -289,7 +289,7 @@ static struct sock *unix_find_socket_byinode(struct net *net, struct inode *i) ...@@ -289,7 +289,7 @@ static struct sock *unix_find_socket_byinode(struct net *net, struct inode *i)
&unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) {
struct dentry *dentry = unix_sk(s)->dentry; struct dentry *dentry = unix_sk(s)->dentry;
if (sock_net(s) != net) if (!net_eq(sock_net(s), net))
continue; continue;
if(dentry && dentry->d_inode == i) if(dentry && dentry->d_inode == i)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册