Skip to content

Commit

Permalink
net: use net_eq to compare nets
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Octavian Purdila authored and davem330 committed Nov 25, 2009
1 parent 4ba3eb0 commit 09ad9bc
Show file tree
Hide file tree
Showing 46 changed files with 74 additions and 72 deletions.
4 changes: 2 additions & 2 deletions drivers/net/hamradio/bpqether.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
struct ethhdr *eth;
struct bpqdev *bpq;

if (dev_net(dev) != &init_net)
if (!net_eq(dev_net(dev), &init_net))
goto drop;

if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
Expand Down Expand Up @@ -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;

if (dev_net(dev) != &init_net)
if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;

if (!dev_is_ethdev(dev))
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static __net_init int loopback_net_init(struct net *net)
out_free_netdev:
free_netdev(dev);
out:
if (net == &init_net)
if (net_eq(net, &init_net))
panic("loopback: Failed to register netdevice: %d\n", err);
return err;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wan/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *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);
return 0;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
unsigned long flags;
int on;

if (dev_net(dev) != &init_net)
if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;

if (!(dev->priv_flags & IFF_WAN_HDLC))
Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk;
int rc = -ESOCKTNOSUPPORT;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

/*
Expand Down
2 changes: 1 addition & 1 deletion net/atm/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static int svc_create(struct net *net, struct socket *sock, int protocol,
{
int error;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

sock->ops = &svc_proto_ops;
Expand Down
2 changes: 1 addition & 1 deletion net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk;
ax25_cb *ax25;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

switch (sock->type) {
Expand Down
2 changes: 1 addition & 1 deletion net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
if (protocol < 0 || protocol >= CAN_NPROTO)
return -EINVAL;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

#ifdef CONFIG_MODULES
Expand Down
4 changes: 2 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ int dev_change_name(struct net_device *dev, const char *newname)
/* For now only devices in the initial network namespace
* are in sysfs.
*/
if (net == &init_net) {
if (net_eq(net, &init_net)) {
ret = device_rename(&dev->dev, dev->name);
if (ret) {
memcpy(dev->name, oldname, IFNAMSIZ);
Expand Down Expand Up @@ -4792,7 +4792,7 @@ static void rollback_registered_many(struct list_head *head)
list_for_each_entry_safe(dev, aux, head, unreg_list) {
int new_net = 1;
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;
dev_put(dev);
break;
Expand Down
2 changes: 1 addition & 1 deletion net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
if (h > s_h)
s_idx = 0;
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;
if (idx < s_idx)
goto next;
Expand Down
4 changes: 2 additions & 2 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void netdev_unregister_kobject(struct net_device * net)

kobject_get(&dev->kobj);

if (dev_net(net) != &init_net)
if (!net_eq(dev_net(net), &init_net))
return;

device_del(dev);
Expand Down Expand Up @@ -559,7 +559,7 @@ int netdev_register_kobject(struct net_device *net)
#endif
#endif /* CONFIG_SYSFS */

if (dev_net(net) != &init_net)
if (!net_eq(dev_net(net), &init_net))
return 0;

return device_add(dev);
Expand Down
2 changes: 1 addition & 1 deletion net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int register_pernet_operations(struct list_head *list,
list_del(&ops->list);
if (ops->exit) {
for_each_net(undo_net) {
if (undo_net == net)
if (net_eq(undo_net, net))
goto undone;
ops->exit(undo_net);
}
Expand Down
2 changes: 1 addition & 1 deletion net/core/sysctl_net_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static __net_init int sysctl_core_net_init(struct net *net)
net->core.sysctl_somaxconn = SOMAXCONN;

tbl = netns_core_table;
if (net != &init_net) {
if (!net_eq(net, &init_net)) {
tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
if (tbl == NULL)
goto err_dup;
Expand Down
2 changes: 1 addition & 1 deletion net/dcb/dcbnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
int ret = -EINVAL;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EINVAL;

ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX,
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
{
struct sock *sk;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

switch(sock->type) {
Expand Down
6 changes: 3 additions & 3 deletions net/decnet/dn_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct dn_ifaddr *ifa, **ifap;
int err = -EINVAL;

if (net != &init_net)
if (!net_eq(net, &init_net))
goto errout;

err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
Expand Down Expand Up @@ -675,7 +675,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct dn_ifaddr *ifa;
int err;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EINVAL;

err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
Expand Down Expand Up @@ -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_ifaddr *ifa;

if (net != &init_net)
if (!net_eq(net, &init_net))
return 0;

skip_ndevs = cb->args[0];
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
struct rtattr **rta = arg;
struct rtmsg *r = NLMSG_DATA(nlh);

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EINVAL;

if (dn_fib_check_attr(r, rta))
Expand All @@ -529,7 +529,7 @@ static int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *
struct rtattr **rta = arg;
struct rtmsg *r = NLMSG_DATA(nlh);

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EINVAL;

if (dn_fib_check_attr(r, rta))
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
struct sk_buff *skb;
struct flowi fl;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EINVAL;

memset(&fl, 0, sizeof(fl));
Expand Down Expand Up @@ -1602,7 +1602,7 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
int h, s_h;
int idx, s_idx;

if (net != &init_net)
if (!net_eq(net, &init_net))
return 0;

if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg))
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct hlist_node *node;
int dumped = 0;

if (net != &init_net)
if (!net_eq(net, &init_net))
return 0;

if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) &&
Expand Down
2 changes: 1 addition & 1 deletion net/econet/af_econet.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol,
struct econet_sock *eo;
int err;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

/* Econet only provides datagram services. */
Expand Down
2 changes: 1 addition & 1 deletion net/ieee802154/af_ieee802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static int ieee802154_create(struct net *net, struct socket *sock,
struct proto *proto;
const struct proto_ops *ops;

if (net != &init_net)
if (!net_eq(net, &init_net))
return -EAFNOSUPPORT;

switch (sock->type) {
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ static __net_init int devinet_init_net(struct net *net)
all = &ipv4_devconf;
dflt = &ipv4_devconf_dflt;

if (net != &init_net) {
if (!net_eq(net, &init_net)) {
all = kmemdup(all, sizeof(ipv4_devconf), GFP_KERNEL);
if (all == NULL)
goto err_alloc_all;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/fib_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static struct fib_info *fib_find_info(const struct fib_info *nfi)
head = &fib_info_hash[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;
if (fi->fib_nhs != nfi->fib_nhs)
continue;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ int fib_sync_down_addr(struct net *net, __be32 local)
return 0;

hlist_for_each_entry(fi, node, head, fib_lhash) {
if (fi->fib_net != net)
if (!net_eq(fi->fib_net, net))
continue;
if (fi->fib_prefsrc == local) {
fi->fib_flags |= RTNH_F_DEAD;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/inet_connection_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
hashinfo->bhash_size)];
spin_lock(&head->lock);
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 &&
sk->sk_reuse &&
sk->sk_state != TCP_LISTEN &&
Expand Down Expand Up @@ -158,7 +158,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
hashinfo->bhash_size)];
spin_lock(&head->lock);
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;
}
tb = NULL;
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/inet_hashtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
* unique enough.
*/
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)
goto next_port;
WARN_ON(hlist_empty(&tb->owners));
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/ip_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ static int ip4_frags_ns_ctl_register(struct net *net)
struct ctl_table_header *hdr;

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);
if (table == NULL)
goto err_alloc;
Expand All @@ -676,7 +676,7 @@ static int ip4_frags_ns_ctl_register(struct net *net)
return 0;

err_reg:
if (net != &init_net)
if (!net_eq(net, &init_net))
kfree(table);
err_alloc:
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
if (sk && inet_sk(sk)->inet_num == protocol &&
(!sk->sk_bound_dev_if ||
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_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) {
read_unlock(&ip_ra_lock);
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
if (event == NETLINK_URELEASE &&
n->protocol == NETLINK_FIREWALL && n->pid) {
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();
write_unlock_bh(&queue_lock);
}
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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)
Expand Down Expand Up @@ -3310,7 +3310,7 @@ static __net_init int sysctl_route_net_init(struct net *net)
struct ctl_table *tbl;

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);
if (tbl == NULL)
goto err_dup;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/sysctl_net_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
struct ctl_table *table;

table = ipv4_net_table;
if (net != &init_net) {
if (!net_eq(net, &init_net)) {
table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
if (table == NULL)
goto err_alloc;
Expand Down Expand Up @@ -849,7 +849,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
return 0;

err_reg:
if (net != &init_net)
if (!net_eq(net, &init_net))
kfree(table);
err_alloc:
return -ENOMEM;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4498,7 +4498,7 @@ static int addrconf_init_net(struct net *net)
all = &ipv6_devconf;
dflt = &ipv6_devconf_dflt;

if (net != &init_net) {
if (!net_eq(net, &init_net)) {
all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL);
if (all == NULL)
goto err_alloc_all;
Expand Down Expand Up @@ -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_all);
#endif
if (net != &init_net) {
if (!net_eq(net, &init_net)) {
kfree(net->ipv6.devconf_dflt);
kfree(net->ipv6.devconf_all);
}
Expand Down
Loading

0 comments on commit 09ad9bc

Please sign in to comment.