diff options
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index b8b827c7062d..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->nd_net != 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->nd_net != 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->nd_net != 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 | } |
@@ -1450,7 +1450,7 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void | |||
1450 | struct sock *sk; | 1450 | struct sock *sk; |
1451 | struct hlist_node *node; | 1451 | struct hlist_node *node; |
1452 | struct net_device *dev = data; | 1452 | struct net_device *dev = data; |
1453 | struct net *net = dev->nd_net; | 1453 | struct net *net = dev_net(dev); |
1454 | 1454 | ||
1455 | read_lock(&net->packet.sklist_lock); | 1455 | read_lock(&net->packet.sklist_lock); |
1456 | sk_for_each(sk, node, &net->packet.sklist) { | 1456 | sk_for_each(sk, node, &net->packet.sklist) { |
@@ -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 |
@@ -1658,7 +1658,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing | |||
1658 | int err = 0; | 1658 | int err = 0; |
1659 | 1659 | ||
1660 | if (req->tp_block_nr) { | 1660 | if (req->tp_block_nr) { |
1661 | int i, l; | 1661 | int i; |
1662 | 1662 | ||
1663 | /* Sanity tests and some calculations */ | 1663 | /* Sanity tests and some calculations */ |
1664 | 1664 | ||
@@ -1687,7 +1687,6 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing | |||
1687 | if (unlikely(!pg_vec)) | 1687 | if (unlikely(!pg_vec)) |
1688 | goto out; | 1688 | goto out; |
1689 | 1689 | ||
1690 | l = 0; | ||
1691 | for (i = 0; i < req->tp_block_nr; i++) { | 1690 | for (i = 0; i < req->tp_block_nr; i++) { |
1692 | char *ptr = pg_vec[i]; | 1691 | char *ptr = pg_vec[i]; |
1693 | struct tpacket_hdr *header; | 1692 | struct tpacket_hdr *header; |