aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet/af_packet.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 13:26:21 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 15:39:55 -0400
commit3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 (patch)
tree09edb35f32ebcfb1b4dad904425128a110ef16ee /net/packet/af_packet.c
parentc346dca10840a874240c78efe3f39acf4312a1f2 (diff)
[NET] NETNS: Omit sock->sk_net without CONFIG_NET_NS.
Introduce per-sock inlines: sock_net(), sock_net_set() and per-inet_timewait_sock inlines: twsk_net(), twsk_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r--net/packet/af_packet.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index baa290d3444a..25070240d4ae 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -263,7 +263,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct
263 if (skb->pkt_type == PACKET_LOOPBACK) 263 if (skb->pkt_type == PACKET_LOOPBACK)
264 goto out; 264 goto out;
265 265
266 if (dev_net(dev) != sk->sk_net) 266 if (dev_net(dev) != sock_net(sk))
267 goto out; 267 goto out;
268 268
269 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) 269 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
@@ -337,7 +337,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
337 */ 337 */
338 338
339 saddr->spkt_device[13] = 0; 339 saddr->spkt_device[13] = 0;
340 dev = dev_get_by_name(sk->sk_net, saddr->spkt_device); 340 dev = dev_get_by_name(sock_net(sk), saddr->spkt_device);
341 err = -ENODEV; 341 err = -ENODEV;
342 if (dev == NULL) 342 if (dev == NULL)
343 goto out_unlock; 343 goto out_unlock;
@@ -451,7 +451,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
451 sk = pt->af_packet_priv; 451 sk = pt->af_packet_priv;
452 po = pkt_sk(sk); 452 po = pkt_sk(sk);
453 453
454 if (dev_net(dev) != sk->sk_net) 454 if (dev_net(dev) != sock_net(sk))
455 goto drop; 455 goto drop;
456 456
457 skb->dev = dev; 457 skb->dev = dev;
@@ -568,7 +568,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
568 sk = pt->af_packet_priv; 568 sk = pt->af_packet_priv;
569 po = pkt_sk(sk); 569 po = pkt_sk(sk);
570 570
571 if (dev_net(dev) != sk->sk_net) 571 if (dev_net(dev) != sock_net(sk))
572 goto drop; 572 goto drop;
573 573
574 if (dev->header_ops) { 574 if (dev->header_ops) {
@@ -728,7 +728,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
728 } 728 }
729 729
730 730
731 dev = dev_get_by_index(sk->sk_net, ifindex); 731 dev = dev_get_by_index(sock_net(sk), ifindex);
732 err = -ENXIO; 732 err = -ENXIO;
733 if (dev == NULL) 733 if (dev == NULL)
734 goto out_unlock; 734 goto out_unlock;
@@ -800,7 +800,7 @@ static int packet_release(struct socket *sock)
800 if (!sk) 800 if (!sk)
801 return 0; 801 return 0;
802 802
803 net = sk->sk_net; 803 net = sock_net(sk);
804 po = pkt_sk(sk); 804 po = pkt_sk(sk);
805 805
806 write_lock_bh(&net->packet.sklist_lock); 806 write_lock_bh(&net->packet.sklist_lock);
@@ -914,7 +914,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
914 return -EINVAL; 914 return -EINVAL;
915 strlcpy(name,uaddr->sa_data,sizeof(name)); 915 strlcpy(name,uaddr->sa_data,sizeof(name));
916 916
917 dev = dev_get_by_name(sk->sk_net, name); 917 dev = dev_get_by_name(sock_net(sk), name);
918 if (dev) { 918 if (dev) {
919 err = packet_do_bind(sk, dev, pkt_sk(sk)->num); 919 err = packet_do_bind(sk, dev, pkt_sk(sk)->num);
920 dev_put(dev); 920 dev_put(dev);
@@ -941,7 +941,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
941 941
942 if (sll->sll_ifindex) { 942 if (sll->sll_ifindex) {
943 err = -ENODEV; 943 err = -ENODEV;
944 dev = dev_get_by_index(sk->sk_net, sll->sll_ifindex); 944 dev = dev_get_by_index(sock_net(sk), sll->sll_ifindex);
945 if (dev == NULL) 945 if (dev == NULL)
946 goto out; 946 goto out;
947 } 947 }
@@ -1135,7 +1135,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
1135 return -EOPNOTSUPP; 1135 return -EOPNOTSUPP;
1136 1136
1137 uaddr->sa_family = AF_PACKET; 1137 uaddr->sa_family = AF_PACKET;
1138 dev = dev_get_by_index(sk->sk_net, pkt_sk(sk)->ifindex); 1138 dev = dev_get_by_index(sock_net(sk), pkt_sk(sk)->ifindex);
1139 if (dev) { 1139 if (dev) {
1140 strlcpy(uaddr->sa_data, dev->name, 15); 1140 strlcpy(uaddr->sa_data, dev->name, 15);
1141 dev_put(dev); 1141 dev_put(dev);
@@ -1160,7 +1160,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
1160 sll->sll_family = AF_PACKET; 1160 sll->sll_family = AF_PACKET;
1161 sll->sll_ifindex = po->ifindex; 1161 sll->sll_ifindex = po->ifindex;
1162 sll->sll_protocol = po->num; 1162 sll->sll_protocol = po->num;
1163 dev = dev_get_by_index(sk->sk_net, po->ifindex); 1163 dev = dev_get_by_index(sock_net(sk), po->ifindex);
1164 if (dev) { 1164 if (dev) {
1165 sll->sll_hatype = dev->type; 1165 sll->sll_hatype = dev->type;
1166 sll->sll_halen = dev->addr_len; 1166 sll->sll_halen = dev->addr_len;
@@ -1212,7 +1212,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
1212 rtnl_lock(); 1212 rtnl_lock();
1213 1213
1214 err = -ENODEV; 1214 err = -ENODEV;
1215 dev = __dev_get_by_index(sk->sk_net, mreq->mr_ifindex); 1215 dev = __dev_get_by_index(sock_net(sk), mreq->mr_ifindex);
1216 if (!dev) 1216 if (!dev)
1217 goto done; 1217 goto done;
1218 1218
@@ -1266,7 +1266,7 @@ static int packet_mc_drop(struct sock *sk, struct packet_mreq_max *mreq)
1266 if (--ml->count == 0) { 1266 if (--ml->count == 0) {
1267 struct net_device *dev; 1267 struct net_device *dev;
1268 *mlp = ml->next; 1268 *mlp = ml->next;
1269 dev = dev_get_by_index(sk->sk_net, ml->ifindex); 1269 dev = dev_get_by_index(sock_net(sk), ml->ifindex);
1270 if (dev) { 1270 if (dev) {
1271 packet_dev_mc(dev, ml, -1); 1271 packet_dev_mc(dev, ml, -1);
1272 dev_put(dev); 1272 dev_put(dev);
@@ -1294,7 +1294,7 @@ static void packet_flush_mclist(struct sock *sk)
1294 struct net_device *dev; 1294 struct net_device *dev;
1295 1295
1296 po->mclist = ml->next; 1296 po->mclist = ml->next;
1297 if ((dev = dev_get_by_index(sk->sk_net, ml->ifindex)) != NULL) { 1297 if ((dev = dev_get_by_index(sock_net(sk), ml->ifindex)) != NULL) {
1298 packet_dev_mc(dev, ml, -1); 1298 packet_dev_mc(dev, ml, -1);
1299 dev_put(dev); 1299 dev_put(dev);
1300 } 1300 }
@@ -1540,7 +1540,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
1540 case SIOCGIFDSTADDR: 1540 case SIOCGIFDSTADDR:
1541 case SIOCSIFDSTADDR: 1541 case SIOCSIFDSTADDR:
1542 case SIOCSIFFLAGS: 1542 case SIOCSIFFLAGS:
1543 if (sk->sk_net != &init_net) 1543 if (sock_net(sk) != &init_net)
1544 return -ENOIOCTLCMD; 1544 return -ENOIOCTLCMD;
1545 return inet_dgram_ops.ioctl(sock, cmd, arg); 1545 return inet_dgram_ops.ioctl(sock, cmd, arg);
1546#endif 1546#endif