aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-07-20 01:34:43 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-20 01:34:43 -0400
commit721499e8931c5732202481ae24f2dfbf9910f129 (patch)
treec94d8d681966109bb41f712f21f3a9825ae2172d /net/ipv4
parent407d819cf0fd54c6fc1138a509225696aecafd15 (diff)
netns: Use net_eq() to compare net-namespaces for optimization.
Without CONFIG_NET_NS, namespace is always &init_net. Compiler will be able to omit namespace comparisons with this patch. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/igmp.c26
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/netfilter/ip_queue.c2
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c2
5 files changed, 18 insertions, 18 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 68e84a933e90..6203ece53606 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1196,7 +1196,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1196 1196
1197 ASSERT_RTNL(); 1197 ASSERT_RTNL();
1198 1198
1199 if (dev_net(in_dev->dev) != &init_net) 1199 if (!net_eq(dev_net(in_dev->dev), &init_net))
1200 return; 1200 return;
1201 1201
1202 for (im=in_dev->mc_list; im; im=im->next) { 1202 for (im=in_dev->mc_list; im; im=im->next) {
@@ -1278,7 +1278,7 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
1278 1278
1279 ASSERT_RTNL(); 1279 ASSERT_RTNL();
1280 1280
1281 if (dev_net(in_dev->dev) != &init_net) 1281 if (!net_eq(dev_net(in_dev->dev), &init_net))
1282 return; 1282 return;
1283 1283
1284 for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { 1284 for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) {
@@ -1308,7 +1308,7 @@ void ip_mc_down(struct in_device *in_dev)
1308 1308
1309 ASSERT_RTNL(); 1309 ASSERT_RTNL();
1310 1310
1311 if (dev_net(in_dev->dev) != &init_net) 1311 if (!net_eq(dev_net(in_dev->dev), &init_net))
1312 return; 1312 return;
1313 1313
1314 for (i=in_dev->mc_list; i; i=i->next) 1314 for (i=in_dev->mc_list; i; i=i->next)
@@ -1331,7 +1331,7 @@ void ip_mc_init_dev(struct in_device *in_dev)
1331{ 1331{
1332 ASSERT_RTNL(); 1332 ASSERT_RTNL();
1333 1333
1334 if (dev_net(in_dev->dev) != &init_net) 1334 if (!net_eq(dev_net(in_dev->dev), &init_net))
1335 return; 1335 return;
1336 1336
1337 in_dev->mc_tomb = NULL; 1337 in_dev->mc_tomb = NULL;
@@ -1357,7 +1357,7 @@ void ip_mc_up(struct in_device *in_dev)
1357 1357
1358 ASSERT_RTNL(); 1358 ASSERT_RTNL();
1359 1359
1360 if (dev_net(in_dev->dev) != &init_net) 1360 if (!net_eq(dev_net(in_dev->dev), &init_net))
1361 return; 1361 return;
1362 1362
1363 ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); 1363 ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS);
@@ -1376,7 +1376,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev)
1376 1376
1377 ASSERT_RTNL(); 1377 ASSERT_RTNL();
1378 1378
1379 if (dev_net(in_dev->dev) != &init_net) 1379 if (!net_eq(dev_net(in_dev->dev), &init_net))
1380 return; 1380 return;
1381 1381
1382 /* Deactivate timers */ 1382 /* Deactivate timers */
@@ -1760,7 +1760,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1760 if (!ipv4_is_multicast(addr)) 1760 if (!ipv4_is_multicast(addr))
1761 return -EINVAL; 1761 return -EINVAL;
1762 1762
1763 if (sock_net(sk) != &init_net) 1763 if (!net_eq(sock_net(sk), &init_net))
1764 return -EPROTONOSUPPORT; 1764 return -EPROTONOSUPPORT;
1765 1765
1766 rtnl_lock(); 1766 rtnl_lock();
@@ -1831,7 +1831,7 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
1831 u32 ifindex; 1831 u32 ifindex;
1832 int ret = -EADDRNOTAVAIL; 1832 int ret = -EADDRNOTAVAIL;
1833 1833
1834 if (sock_net(sk) != &init_net) 1834 if (!net_eq(sock_net(sk), &init_net))
1835 return -EPROTONOSUPPORT; 1835 return -EPROTONOSUPPORT;
1836 1836
1837 rtnl_lock(); 1837 rtnl_lock();
@@ -1879,7 +1879,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1879 if (!ipv4_is_multicast(addr)) 1879 if (!ipv4_is_multicast(addr))
1880 return -EINVAL; 1880 return -EINVAL;
1881 1881
1882 if (sock_net(sk) != &init_net) 1882 if (!net_eq(sock_net(sk), &init_net))
1883 return -EPROTONOSUPPORT; 1883 return -EPROTONOSUPPORT;
1884 1884
1885 rtnl_lock(); 1885 rtnl_lock();
@@ -2015,7 +2015,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
2015 msf->imsf_fmode != MCAST_EXCLUDE) 2015 msf->imsf_fmode != MCAST_EXCLUDE)
2016 return -EINVAL; 2016 return -EINVAL;
2017 2017
2018 if (sock_net(sk) != &init_net) 2018 if (!net_eq(sock_net(sk), &init_net))
2019 return -EPROTONOSUPPORT; 2019 return -EPROTONOSUPPORT;
2020 2020
2021 rtnl_lock(); 2021 rtnl_lock();
@@ -2098,7 +2098,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2098 if (!ipv4_is_multicast(addr)) 2098 if (!ipv4_is_multicast(addr))
2099 return -EINVAL; 2099 return -EINVAL;
2100 2100
2101 if (sock_net(sk) != &init_net) 2101 if (!net_eq(sock_net(sk), &init_net))
2102 return -EPROTONOSUPPORT; 2102 return -EPROTONOSUPPORT;
2103 2103
2104 rtnl_lock(); 2104 rtnl_lock();
@@ -2163,7 +2163,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2163 if (!ipv4_is_multicast(addr)) 2163 if (!ipv4_is_multicast(addr))
2164 return -EINVAL; 2164 return -EINVAL;
2165 2165
2166 if (sock_net(sk) != &init_net) 2166 if (!net_eq(sock_net(sk), &init_net))
2167 return -EPROTONOSUPPORT; 2167 return -EPROTONOSUPPORT;
2168 2168
2169 rtnl_lock(); 2169 rtnl_lock();
@@ -2250,7 +2250,7 @@ void ip_mc_drop_socket(struct sock *sk)
2250 if (inet->mc_list == NULL) 2250 if (inet->mc_list == NULL)
2251 return; 2251 return;
2252 2252
2253 if (sock_net(sk) != &init_net) 2253 if (!net_eq(sock_net(sk), &init_net))
2254 return; 2254 return;
2255 2255
2256 rtnl_lock(); 2256 rtnl_lock();
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index b88aa9afa42e..42065fff46c4 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -432,7 +432,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
432 unsigned char *sha, *tha; /* s for "source", t for "target" */ 432 unsigned char *sha, *tha; /* s for "source", t for "target" */
433 struct ic_device *d; 433 struct ic_device *d;
434 434
435 if (dev_net(dev) != &init_net) 435 if (!net_eq(dev_net(dev), &init_net))
436 goto drop; 436 goto drop;
437 437
438 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) 438 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
@@ -852,7 +852,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
852 struct ic_device *d; 852 struct ic_device *d;
853 int len, ext_len; 853 int len, ext_len;
854 854
855 if (dev_net(dev) != &init_net) 855 if (!net_eq(dev_net(dev), &init_net))
856 goto drop; 856 goto drop;
857 857
858 /* Perform verifications before taking the lock. */ 858 /* Perform verifications before taking the lock. */
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 033c712c3a5d..c519b8d30eee 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1124,7 +1124,7 @@ static int ipmr_device_event(struct notifier_block *this, unsigned long event, v
1124 struct vif_device *v; 1124 struct vif_device *v;
1125 int ct; 1125 int ct;
1126 1126
1127 if (dev_net(dev) != &init_net) 1127 if (!net_eq(dev_net(dev), &init_net))
1128 return NOTIFY_DONE; 1128 return NOTIFY_DONE;
1129 1129
1130 if (event != NETDEV_UNREGISTER) 1130 if (event != NETDEV_UNREGISTER)
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index aa33a4a7a715..432ce9d1c11c 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -477,7 +477,7 @@ ipq_rcv_dev_event(struct notifier_block *this,
477{ 477{
478 struct net_device *dev = ptr; 478 struct net_device *dev = ptr;
479 479
480 if (dev_net(dev) != &init_net) 480 if (!net_eq(dev_net(dev), &init_net))
481 return NOTIFY_DONE; 481 return NOTIFY_DONE;
482 482
483 /* Drop any packets associated with the downed device */ 483 /* Drop any packets associated with the downed device */
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index 84c26dd27d81..0841aefaa503 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -120,7 +120,7 @@ static int masq_device_event(struct notifier_block *this,
120{ 120{
121 const struct net_device *dev = ptr; 121 const struct net_device *dev = ptr;
122 122
123 if (dev_net(dev) != &init_net) 123 if (!net_eq(dev_net(dev), &init_net))
124 return NOTIFY_DONE; 124 return NOTIFY_DONE;
125 125
126 if (event == NETDEV_DOWN) { 126 if (event == NETDEV_DOWN) {