net: use net_eq to compare nets

Generated with the following semantic patch

@@
struct net *n1;
struct net *n2;
@@
- n1 == n2
+ net_eq(n1, n2)

@@
struct net *n1;
struct net *n2;
@@
- n1 != n2
+ !net_eq(n1, n2)

applied over {include,net,drivers/net}.

Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Octavian Purdila 2009-11-25 15:14:13 -08:00 committed by David S. Miller
parent 4ba3eb034f
commit 09ad9bc752
46 changed files with 74 additions and 72 deletions

View file

@ -186,7 +186,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
struct ethhdr *eth; struct ethhdr *eth;
struct bpqdev *bpq; struct bpqdev *bpq;
if (dev_net(dev) != &init_net) if (!net_eq(dev_net(dev), &init_net))
goto drop; goto drop;
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
@ -552,7 +552,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
{ {
struct net_device *dev = (struct net_device *)ptr; struct net_device *dev = (struct net_device *)ptr;
if (dev_net(dev) != &init_net) if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE; return NOTIFY_DONE;
if (!dev_is_ethdev(dev)) if (!dev_is_ethdev(dev))

View file

@ -207,7 +207,7 @@ static __net_init int loopback_net_init(struct net *net)
out_free_netdev: out_free_netdev:
free_netdev(dev); free_netdev(dev);
out: out:
if (net == &init_net) if (net_eq(net, &init_net))
panic("loopback: Failed to register netdevice: %d\n", err); panic("loopback: Failed to register netdevice: %d\n", err);
return err; return err;
} }

View file

@ -57,7 +57,7 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
{ {
struct hdlc_device *hdlc = dev_to_hdlc(dev); struct hdlc_device *hdlc = dev_to_hdlc(dev);
if (dev_net(dev) != &init_net) { if (!net_eq(dev_net(dev), &init_net)) {
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
@ -102,7 +102,7 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
unsigned long flags; unsigned long flags;
int on; int on;
if (dev_net(dev) != &init_net) if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE; return NOTIFY_DONE;
if (!(dev->priv_flags & IFF_WAN_HDLC)) if (!(dev->priv_flags & IFF_WAN_HDLC))

View file

@ -1023,7 +1023,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk; struct sock *sk;
int rc = -ESOCKTNOSUPPORT; int rc = -ESOCKTNOSUPPORT;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* /*

View file

@ -655,7 +655,7 @@ static int svc_create(struct net *net, struct socket *sock, int protocol,
{ {
int error; int error;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
sock->ops = &svc_proto_ops; sock->ops = &svc_proto_ops;

View file

@ -805,7 +805,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk; struct sock *sk;
ax25_cb *ax25; ax25_cb *ax25;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
switch (sock->type) { switch (sock->type) {

View file

@ -126,7 +126,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
if (protocol < 0 || protocol >= CAN_NPROTO) if (protocol < 0 || protocol >= CAN_NPROTO)
return -EINVAL; return -EINVAL;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES

View file

@ -985,7 +985,7 @@ rollback:
/* For now only devices in the initial network namespace /* For now only devices in the initial network namespace
* are in sysfs. * are in sysfs.
*/ */
if (net == &init_net) { if (net_eq(net, &init_net)) {
ret = device_rename(&dev->dev, dev->name); ret = device_rename(&dev->dev, dev->name);
if (ret) { if (ret) {
memcpy(dev->name, oldname, IFNAMSIZ); memcpy(dev->name, oldname, IFNAMSIZ);
@ -4792,7 +4792,7 @@ static void rollback_registered_many(struct list_head *head)
list_for_each_entry_safe(dev, aux, head, unreg_list) { list_for_each_entry_safe(dev, aux, head, unreg_list) {
int new_net = 1; int new_net = 1;
list_for_each_entry(fdev, &pernet_list, unreg_list) { list_for_each_entry(fdev, &pernet_list, unreg_list) {
if (dev_net(dev) == dev_net(fdev)) { if (net_eq(dev_net(dev), dev_net(fdev))) {
new_net = 0; new_net = 0;
dev_put(dev); dev_put(dev);
break; break;

View file

@ -2092,7 +2092,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
if (h > s_h) if (h > s_h)
s_idx = 0; s_idx = 0;
for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) {
if (dev_net(n->dev) != net) if (!net_eq(dev_net(n->dev), net))
continue; continue;
if (idx < s_idx) if (idx < s_idx)
goto next; goto next;

View file

@ -525,7 +525,7 @@ void netdev_unregister_kobject(struct net_device * net)
kobject_get(&dev->kobj); kobject_get(&dev->kobj);
if (dev_net(net) != &init_net) if (!net_eq(dev_net(net), &init_net))
return; return;
device_del(dev); device_del(dev);
@ -559,7 +559,7 @@ int netdev_register_kobject(struct net_device *net)
#endif #endif
#endif /* CONFIG_SYSFS */ #endif /* CONFIG_SYSFS */
if (dev_net(net) != &init_net) if (!net_eq(dev_net(net), &init_net))
return 0; return 0;
return device_add(dev); return device_add(dev);

View file

@ -280,7 +280,7 @@ out_undo:
list_del(&ops->list); list_del(&ops->list);
if (ops->exit) { if (ops->exit) {
for_each_net(undo_net) { for_each_net(undo_net) {
if (undo_net == net) if (net_eq(undo_net, net))
goto undone; goto undone;
ops->exit(undo_net); ops->exit(undo_net);
} }

View file

@ -134,7 +134,7 @@ static __net_init int sysctl_core_net_init(struct net *net)
net->core.sysctl_somaxconn = SOMAXCONN; net->core.sysctl_somaxconn = SOMAXCONN;
tbl = netns_core_table; tbl = netns_core_table;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL); tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
if (tbl == NULL) if (tbl == NULL)
goto err_dup; goto err_dup;

View file

@ -1126,7 +1126,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
u32 pid = skb ? NETLINK_CB(skb).pid : 0; u32 pid = skb ? NETLINK_CB(skb).pid : 0;
int ret = -EINVAL; int ret = -EINVAL;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX, ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX,

View file

@ -680,7 +680,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
{ {
struct sock *sk; struct sock *sk;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
switch(sock->type) { switch(sock->type) {

View file

@ -636,7 +636,7 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct dn_ifaddr *ifa, **ifap; struct dn_ifaddr *ifa, **ifap;
int err = -EINVAL; int err = -EINVAL;
if (net != &init_net) if (!net_eq(net, &init_net))
goto errout; goto errout;
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy); err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
@ -675,7 +675,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
int err; int err;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy); err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
@ -789,7 +789,7 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
struct dn_dev *dn_db; struct dn_dev *dn_db;
struct dn_ifaddr *ifa; struct dn_ifaddr *ifa;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
skip_ndevs = cb->args[0]; skip_ndevs = cb->args[0];

View file

@ -509,7 +509,7 @@ static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
struct rtattr **rta = arg; struct rtattr **rta = arg;
struct rtmsg *r = NLMSG_DATA(nlh); struct rtmsg *r = NLMSG_DATA(nlh);
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
if (dn_fib_check_attr(r, rta)) if (dn_fib_check_attr(r, rta))
@ -529,7 +529,7 @@ static int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
struct rtattr **rta = arg; struct rtattr **rta = arg;
struct rtmsg *r = NLMSG_DATA(nlh); struct rtmsg *r = NLMSG_DATA(nlh);
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
if (dn_fib_check_attr(r, rta)) if (dn_fib_check_attr(r, rta))

View file

@ -1517,7 +1517,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
struct sk_buff *skb; struct sk_buff *skb;
struct flowi fl; struct flowi fl;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
@ -1602,7 +1602,7 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
int h, s_h; int h, s_h;
int idx, s_idx; int idx, s_idx;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg)) if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg))

View file

@ -471,7 +471,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct hlist_node *node; struct hlist_node *node;
int dumped = 0; int dumped = 0;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) && if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) &&

View file

@ -612,7 +612,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol,
struct econet_sock *eo; struct econet_sock *eo;
int err; int err;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* Econet only provides datagram services. */ /* Econet only provides datagram services. */

View file

@ -241,7 +241,7 @@ static int ieee802154_create(struct net *net, struct socket *sock,
struct proto *proto; struct proto *proto;
const struct proto_ops *ops; const struct proto_ops *ops;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
switch (sock->type) { switch (sock->type) {

View file

@ -1605,7 +1605,7 @@ static __net_init int devinet_init_net(struct net *net)
all = &ipv4_devconf; all = &ipv4_devconf;
dflt = &ipv4_devconf_dflt; dflt = &ipv4_devconf_dflt;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL); all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
if (all == NULL) if (all == NULL)
goto err_alloc_all; goto err_alloc_all;

View file

@ -228,7 +228,7 @@ static struct fib_info *fib_find_info(const struct fib_info *nfi)
head = &fib_info_hash[hash]; head = &fib_info_hash[hash];
hlist_for_each_entry(fi, node, head, fib_hash) { hlist_for_each_entry(fi, node, head, fib_hash) {
if (fi->fib_net != nfi->fib_net) if (!net_eq(fi->fib_net, nfi->fib_net))
continue; continue;
if (fi->fib_nhs != nfi->fib_nhs) if (fi->fib_nhs != nfi->fib_nhs)
continue; continue;
@ -1047,7 +1047,7 @@ int fib_sync_down_addr(struct net *net, __be32 local)
return 0; return 0;
hlist_for_each_entry(fi, node, head, fib_lhash) { hlist_for_each_entry(fi, node, head, fib_lhash) {
if (fi->fib_net != net) if (!net_eq(fi->fib_net, net))
continue; continue;
if (fi->fib_prefsrc == local) { if (fi->fib_prefsrc == local) {
fi->fib_flags |= RTNH_F_DEAD; fi->fib_flags |= RTNH_F_DEAD;

View file

@ -112,7 +112,7 @@ again:
hashinfo->bhash_size)]; hashinfo->bhash_size)];
spin_lock(&head->lock); spin_lock(&head->lock);
inet_bind_bucket_for_each(tb, node, &head->chain) inet_bind_bucket_for_each(tb, node, &head->chain)
if (ib_net(tb) == net && tb->port == rover) { if (net_eq(ib_net(tb), net) && tb->port == rover) {
if (tb->fastreuse > 0 && if (tb->fastreuse > 0 &&
sk->sk_reuse && sk->sk_reuse &&
sk->sk_state != TCP_LISTEN && sk->sk_state != TCP_LISTEN &&
@ -158,7 +158,7 @@ have_snum:
hashinfo->bhash_size)]; hashinfo->bhash_size)];
spin_lock(&head->lock); spin_lock(&head->lock);
inet_bind_bucket_for_each(tb, node, &head->chain) inet_bind_bucket_for_each(tb, node, &head->chain)
if (ib_net(tb) == net && tb->port == snum) if (net_eq(ib_net(tb), net) && tb->port == snum)
goto tb_found; goto tb_found;
} }
tb = NULL; tb = NULL;

View file

@ -454,7 +454,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
* unique enough. * unique enough.
*/ */
inet_bind_bucket_for_each(tb, node, &head->chain) { inet_bind_bucket_for_each(tb, node, &head->chain) {
if (ib_net(tb) == net && tb->port == port) { if (net_eq(ib_net(tb), net) &&
tb->port == port) {
if (tb->fastreuse >= 0) if (tb->fastreuse >= 0)
goto next_port; goto next_port;
WARN_ON(hlist_empty(&tb->owners)); WARN_ON(hlist_empty(&tb->owners));

View file

@ -658,7 +658,7 @@ static int ip4_frags_ns_ctl_register(struct net *net)
struct ctl_table_header *hdr; struct ctl_table_header *hdr;
table = ip4_frags_ns_ctl_table; table = ip4_frags_ns_ctl_table;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL); table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
if (table == NULL) if (table == NULL)
goto err_alloc; goto err_alloc;
@ -676,7 +676,7 @@ static int ip4_frags_ns_ctl_register(struct net *net)
return 0; return 0;
err_reg: err_reg:
if (net != &init_net) if (!net_eq(net, &init_net))
kfree(table); kfree(table);
err_alloc: err_alloc:
return -ENOMEM; return -ENOMEM;

View file

@ -164,7 +164,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
if (sk && inet_sk(sk)->inet_num == protocol && if (sk && inet_sk(sk)->inet_num == protocol &&
(!sk->sk_bound_dev_if || (!sk->sk_bound_dev_if ||
sk->sk_bound_dev_if == dev->ifindex) && sk->sk_bound_dev_if == dev->ifindex) &&
sock_net(sk) == dev_net(dev)) { net_eq(sock_net(sk), dev_net(dev))) {
if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) { if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) {
read_unlock(&ip_ra_lock); read_unlock(&ip_ra_lock);

View file

@ -500,7 +500,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
if (event == NETLINK_URELEASE && if (event == NETLINK_URELEASE &&
n->protocol == NETLINK_FIREWALL && n->pid) { n->protocol == NETLINK_FIREWALL && n->pid) {
write_lock_bh(&queue_lock); write_lock_bh(&queue_lock);
if ((n->net == &init_net) && (n->pid == peer_pid)) if ((net_eq(n->net, &init_net)) && (n->pid == peer_pid))
__ipq_reset(); __ipq_reset();
write_unlock_bh(&queue_lock); write_unlock_bh(&queue_lock);
} }

View file

@ -703,7 +703,7 @@ static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
static inline int compare_netns(struct rtable *rt1, struct rtable *rt2) static inline int compare_netns(struct rtable *rt1, struct rtable *rt2)
{ {
return dev_net(rt1->u.dst.dev) == dev_net(rt2->u.dst.dev); return net_eq(dev_net(rt1->u.dst.dev), dev_net(rt2->u.dst.dev));
} }
static inline int rt_is_expired(struct rtable *rth) static inline int rt_is_expired(struct rtable *rth)
@ -3310,7 +3310,7 @@ static __net_init int sysctl_route_net_init(struct net *net)
struct ctl_table *tbl; struct ctl_table *tbl;
tbl = ipv4_route_flush_table; tbl = ipv4_route_flush_table;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL); tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
if (tbl == NULL) if (tbl == NULL)
goto err_dup; goto err_dup;

View file

@ -818,7 +818,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
struct ctl_table *table; struct ctl_table *table;
table = ipv4_net_table; table = ipv4_net_table;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
if (table == NULL) if (table == NULL)
goto err_alloc; goto err_alloc;
@ -849,7 +849,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
return 0; return 0;
err_reg: err_reg:
if (net != &init_net) if (!net_eq(net, &init_net))
kfree(table); kfree(table);
err_alloc: err_alloc:
return -ENOMEM; return -ENOMEM;

View file

@ -4498,7 +4498,7 @@ static int addrconf_init_net(struct net *net)
all = &ipv6_devconf; all = &ipv6_devconf;
dflt = &ipv6_devconf_dflt; dflt = &ipv6_devconf_dflt;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL); all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL);
if (all == NULL) if (all == NULL)
goto err_alloc_all; goto err_alloc_all;
@ -4546,7 +4546,7 @@ static void addrconf_exit_net(struct net *net)
__addrconf_sysctl_unregister(net->ipv6.devconf_dflt); __addrconf_sysctl_unregister(net->ipv6.devconf_dflt);
__addrconf_sysctl_unregister(net->ipv6.devconf_all); __addrconf_sysctl_unregister(net->ipv6.devconf_all);
#endif #endif
if (net != &init_net) { if (!net_eq(net, &init_net)) {
kfree(net->ipv6.devconf_dflt); kfree(net->ipv6.devconf_dflt);
kfree(net->ipv6.devconf_all); kfree(net->ipv6.devconf_all);
} }

View file

@ -67,7 +67,7 @@ static inline struct ip6_flowlabel *__fl_lookup(struct net *net, __be32 label)
struct ip6_flowlabel *fl; struct ip6_flowlabel *fl;
for (fl=fl_ht[FL_HASH(label)]; fl; fl = fl->next) { for (fl=fl_ht[FL_HASH(label)]; fl; fl = fl->next) {
if (fl->label == label && fl->fl_net == net) if (fl->label == label && net_eq(fl->fl_net, net))
return fl; return fl;
} }
return NULL; return NULL;
@ -163,7 +163,8 @@ static void ip6_fl_purge(struct net *net)
struct ip6_flowlabel *fl, **flp; struct ip6_flowlabel *fl, **flp;
flp = &fl_ht[i]; flp = &fl_ht[i];
while ((fl = *flp) != NULL) { while ((fl = *flp) != NULL) {
if (fl->fl_net == net && atomic_read(&fl->users) == 0) { if (net_eq(fl->fl_net, net) &&
atomic_read(&fl->users) == 0) {
*flp = fl->next; *flp = fl->next;
fl_free(fl); fl_free(fl);
atomic_dec(&fl_size); atomic_dec(&fl_size);
@ -630,7 +631,7 @@ static struct ip6_flowlabel *ip6fl_get_first(struct seq_file *seq)
for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) { for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) {
fl = fl_ht[state->bucket]; fl = fl_ht[state->bucket];
while (fl && fl->fl_net != net) while (fl && !net_eq(fl->fl_net, net))
fl = fl->next; fl = fl->next;
if (fl) if (fl)
break; break;
@ -645,7 +646,7 @@ static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flo
fl = fl->next; fl = fl->next;
try_again: try_again:
while (fl && fl->fl_net != net) while (fl && !net_eq(fl->fl_net, net))
fl = fl->next; fl = fl->next;
while (!fl) { while (!fl) {

View file

@ -502,7 +502,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
if (event == NETLINK_URELEASE && if (event == NETLINK_URELEASE &&
n->protocol == NETLINK_IP6_FW && n->pid) { n->protocol == NETLINK_IP6_FW && n->pid) {
write_lock_bh(&queue_lock); write_lock_bh(&queue_lock);
if ((n->net == &init_net) && (n->pid == peer_pid)) if ((net_eq(n->net, &init_net)) && (n->pid == peer_pid))
__ipq_reset(); __ipq_reset();
write_unlock_bh(&queue_lock); write_unlock_bh(&queue_lock);
} }

View file

@ -681,7 +681,7 @@ static int ip6_frags_ns_sysctl_register(struct net *net)
struct ctl_table_header *hdr; struct ctl_table_header *hdr;
table = ip6_frags_ns_ctl_table; table = ip6_frags_ns_ctl_table;
if (net != &init_net) { if (!net_eq(net, &init_net)) {
table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL); table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
if (table == NULL) if (table == NULL)
goto err_alloc; goto err_alloc;
@ -699,7 +699,7 @@ static int ip6_frags_ns_sysctl_register(struct net *net)
return 0; return 0;
err_reg: err_reg:
if (net != &init_net) if (!net_eq(net, &init_net))
kfree(table); kfree(table);
err_alloc: err_alloc:
return -ENOMEM; return -ENOMEM;

View file

@ -1362,7 +1362,7 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol,
int rc = -ESOCKTNOSUPPORT; int rc = -ESOCKTNOSUPPORT;
struct sock *sk; struct sock *sk;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* /*

View file

@ -158,7 +158,7 @@ static int llc_ui_create(struct net *net, struct socket *sock, int protocol,
if (!capable(CAP_NET_RAW)) if (!capable(CAP_NET_RAW))
return -EPERM; return -EPERM;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) { if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {

View file

@ -678,7 +678,7 @@ nfulnl_rcv_nl_event(struct notifier_block *this,
struct hlist_head *head = &instance_table[i]; struct hlist_head *head = &instance_table[i];
hlist_for_each_entry_safe(inst, tmp, t2, head, hlist) { hlist_for_each_entry_safe(inst, tmp, t2, head, hlist) {
if ((n->net == &init_net) && if ((net_eq(n->net, &init_net)) &&
(n->pid == inst->peer_pid)) (n->pid == inst->peer_pid))
__instance_destroy(inst); __instance_destroy(inst);
} }

View file

@ -1092,7 +1092,7 @@ static inline int do_one_set_err(struct sock *sk,
if (sk == p->exclude_sk) if (sk == p->exclude_sk)
goto out; goto out;
if (sock_net(sk) != sock_net(p->exclude_sk)) if (!net_eq(sock_net(sk), sock_net(p->exclude_sk)))
goto out; goto out;
if (nlk->pid == p->pid || p->group - 1 >= nlk->ngroups || if (nlk->pid == p->pid || p->group - 1 >= nlk->ngroups ||

View file

@ -431,7 +431,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk; struct sock *sk;
struct nr_sock *nr; struct nr_sock *nr;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (sock->type != SOCK_SEQPACKET || protocol != 0) if (sock->type != SOCK_SEQPACKET || protocol != 0)

View file

@ -365,7 +365,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
if (skb->pkt_type == PACKET_LOOPBACK) if (skb->pkt_type == PACKET_LOOPBACK)
goto out; goto out;
if (dev_net(dev) != sock_net(sk)) if (!net_eq(dev_net(dev), sock_net(sk)))
goto out; goto out;
skb = skb_share_check(skb, GFP_ATOMIC); skb = skb_share_check(skb, GFP_ATOMIC);
@ -553,7 +553,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
sk = pt->af_packet_priv; sk = pt->af_packet_priv;
po = pkt_sk(sk); po = pkt_sk(sk);
if (dev_net(dev) != sock_net(sk)) if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop; goto drop;
skb->dev = dev; skb->dev = dev;
@ -674,7 +674,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
sk = pt->af_packet_priv; sk = pt->af_packet_priv;
po = pkt_sk(sk); po = pkt_sk(sk);
if (dev_net(dev) != sock_net(sk)) if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop; goto drop;
if (dev->header_ops) { if (dev->header_ops) {

View file

@ -518,7 +518,7 @@ static int rose_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk; struct sock *sk;
struct rose_sock *rose; struct rose_sock *rose;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (sock->type != SOCK_SEQPACKET || protocol != 0) if (sock->type != SOCK_SEQPACKET || protocol != 0)

View file

@ -616,7 +616,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol,
_enter("%p,%d", sock, protocol); _enter("%p,%d", sock, protocol);
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* we support transport protocol UDP only */ /* we support transport protocol UDP only */

View file

@ -969,7 +969,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
u32 pid = skb ? NETLINK_CB(skb).pid : 0; u32 pid = skb ? NETLINK_CB(skb).pid : 0;
int ret = 0, ovr = 0; int ret = 0, ovr = 0;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
@ -1052,7 +1052,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
struct nlattr *kind = find_dump_kind(cb->nlh); struct nlattr *kind = find_dump_kind(cb->nlh);
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
if (kind == NULL) { if (kind == NULL) {

View file

@ -137,7 +137,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
int err; int err;
int tp_created = 0; int tp_created = 0;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
replay: replay:
@ -418,7 +418,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
const struct Qdisc_class_ops *cops; const struct Qdisc_class_ops *cops;
struct tcf_dump_args arg; struct tcf_dump_args arg;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))

View file

@ -947,7 +947,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
struct Qdisc *p = NULL; struct Qdisc *p = NULL;
int err; int err;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
@ -1009,7 +1009,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
struct Qdisc *q, *p; struct Qdisc *q, *p;
int err; int err;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
replay: replay:
@ -1274,7 +1274,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
int s_idx, s_q_idx; int s_idx, s_q_idx;
struct net_device *dev; struct net_device *dev;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
s_idx = cb->args[0]; s_idx = cb->args[0];
@ -1334,7 +1334,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
u32 qid = TC_H_MAJ(clid); u32 qid = TC_H_MAJ(clid);
int err; int err;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EINVAL; return -EINVAL;
if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
@ -1576,7 +1576,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
struct net_device *dev; struct net_device *dev;
int t, s_t; int t, s_t;
if (net != &init_net) if (!net_eq(net, &init_net))
return 0; return 0;
if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))

View file

@ -195,7 +195,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
/* Validate arguments */ /* Validate arguments */
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (unlikely(protocol != 0)) if (unlikely(protocol != 0))

View file

@ -514,7 +514,7 @@ static int x25_create(struct net *net, struct socket *sock, int protocol,
struct x25_sock *x25; struct x25_sock *x25;
int rc = -ESOCKTNOSUPPORT; int rc = -ESOCKTNOSUPPORT;
if (net != &init_net) if (!net_eq(net, &init_net))
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (sock->type != SOCK_SEQPACKET || protocol) if (sock->type != SOCK_SEQPACKET || protocol)