aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-07-21 17:57:59 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-23 21:01:10 -0400
commit40d4e3dfc2f56ad85ecca29c7f9a0194bbb833c0 (patch)
tree3273e0f2f7081dd08092ca0e9100e6a8ee6fe94d /net/packet
parentc9a73cdb772a487b2c59c2711ad8b10d58cbaca8 (diff)
af_packet: style cleanups
Some style cleanups to match current code practices. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r--net/packet/af_packet.c246
1 files changed, 122 insertions, 124 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ebe5718baa31..d3d52c66cdc2 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -137,8 +137,7 @@ dev->hard_header == NULL (ll header is added by device, we cannot control it)
137 137
138/* Private packet socket structures. */ 138/* Private packet socket structures. */
139 139
140struct packet_mclist 140struct packet_mclist {
141{
142 struct packet_mclist *next; 141 struct packet_mclist *next;
143 int ifindex; 142 int ifindex;
144 int count; 143 int count;
@@ -149,8 +148,7 @@ struct packet_mclist
149/* identical to struct packet_mreq except it has 148/* identical to struct packet_mreq except it has
150 * a longer address field. 149 * a longer address field.
151 */ 150 */
152struct packet_mreq_max 151struct packet_mreq_max {
153{
154 int mr_ifindex; 152 int mr_ifindex;
155 unsigned short mr_type; 153 unsigned short mr_type;
156 unsigned short mr_alen; 154 unsigned short mr_alen;
@@ -162,7 +160,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req,
162 int closing, int tx_ring); 160 int closing, int tx_ring);
163 161
164struct packet_ring_buffer { 162struct packet_ring_buffer {
165 char * *pg_vec; 163 char **pg_vec;
166 unsigned int head; 164 unsigned int head;
167 unsigned int frames_per_block; 165 unsigned int frames_per_block;
168 unsigned int frame_size; 166 unsigned int frame_size;
@@ -239,7 +237,7 @@ static void __packet_set_status(struct packet_sock *po, void *frame, int status)
239 flush_dcache_page(virt_to_page(&h.h2->tp_status)); 237 flush_dcache_page(virt_to_page(&h.h2->tp_status));
240 break; 238 break;
241 default: 239 default:
242 printk(KERN_ERR "TPACKET version not supported\n"); 240 pr_err("TPACKET version not supported\n");
243 BUG(); 241 BUG();
244 } 242 }
245 243
@@ -265,7 +263,7 @@ static int __packet_get_status(struct packet_sock *po, void *frame)
265 flush_dcache_page(virt_to_page(&h.h2->tp_status)); 263 flush_dcache_page(virt_to_page(&h.h2->tp_status));
266 return h.h2->tp_status; 264 return h.h2->tp_status;
267 default: 265 default:
268 printk(KERN_ERR "TPACKET version not supported\n"); 266 pr_err("TPACKET version not supported\n");
269 BUG(); 267 BUG();
270 return 0; 268 return 0;
271 } 269 }
@@ -327,7 +325,7 @@ static void packet_sock_destruct(struct sock *sk)
327 WARN_ON(atomic_read(&sk->sk_wmem_alloc)); 325 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
328 326
329 if (!sock_flag(sk, SOCK_DEAD)) { 327 if (!sock_flag(sk, SOCK_DEAD)) {
330 printk("Attempt to release alive packet socket: %p\n", sk); 328 pr_err("Attempt to release alive packet socket: %p\n", sk);
331 return; 329 return;
332 } 330 }
333 331
@@ -339,7 +337,8 @@ static const struct proto_ops packet_ops;
339 337
340static const struct proto_ops packet_ops_spkt; 338static const struct proto_ops packet_ops_spkt;
341 339
342static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) 340static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
341 struct packet_type *pt, struct net_device *orig_dev)
343{ 342{
344 struct sock *sk; 343 struct sock *sk;
345 struct sockaddr_pkt *spkt; 344 struct sockaddr_pkt *spkt;
@@ -368,7 +367,8 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct
368 if (dev_net(dev) != sock_net(sk)) 367 if (dev_net(dev) != sock_net(sk))
369 goto out; 368 goto out;
370 369
371 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) 370 skb = skb_share_check(skb, GFP_ATOMIC);
371 if (skb == NULL)
372 goto oom; 372 goto oom;
373 373
374 /* drop any routing info */ 374 /* drop any routing info */
@@ -394,7 +394,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct
394 * to prevent sockets using all the memory up. 394 * to prevent sockets using all the memory up.
395 */ 395 */
396 396
397 if (sock_queue_rcv_skb(sk,skb) == 0) 397 if (sock_queue_rcv_skb(sk, skb) == 0)
398 return 0; 398 return 0;
399 399
400out: 400out:
@@ -413,25 +413,23 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
413 struct msghdr *msg, size_t len) 413 struct msghdr *msg, size_t len)
414{ 414{
415 struct sock *sk = sock->sk; 415 struct sock *sk = sock->sk;
416 struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name; 416 struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name;
417 struct sk_buff *skb; 417 struct sk_buff *skb;
418 struct net_device *dev; 418 struct net_device *dev;
419 __be16 proto=0; 419 __be16 proto = 0;
420 int err; 420 int err;
421 421
422 /* 422 /*
423 * Get and verify the address. 423 * Get and verify the address.
424 */ 424 */
425 425
426 if (saddr) 426 if (saddr) {
427 {
428 if (msg->msg_namelen < sizeof(struct sockaddr)) 427 if (msg->msg_namelen < sizeof(struct sockaddr))
429 return(-EINVAL); 428 return -EINVAL;
430 if (msg->msg_namelen==sizeof(struct sockaddr_pkt)) 429 if (msg->msg_namelen == sizeof(struct sockaddr_pkt))
431 proto=saddr->spkt_protocol; 430 proto = saddr->spkt_protocol;
432 } 431 } else
433 else 432 return -ENOTCONN; /* SOCK_PACKET must be sent giving an address */
434 return(-ENOTCONN); /* SOCK_PACKET must be sent giving an address */
435 433
436 /* 434 /*
437 * Find the device first to size check it 435 * Find the device first to size check it
@@ -448,8 +446,8 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
448 goto out_unlock; 446 goto out_unlock;
449 447
450 /* 448 /*
451 * You may not queue a frame bigger than the mtu. This is the lowest level 449 * You may not queue a frame bigger than the mtu. This is the lowest level
452 * raw protocol and you must do your own fragmentation at this level. 450 * raw protocol and you must do your own fragmentation at this level.
453 */ 451 */
454 452
455 err = -EMSGSIZE; 453 err = -EMSGSIZE;
@@ -460,9 +458,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
460 skb = sock_wmalloc(sk, len + LL_RESERVED_SPACE(dev), 0, GFP_KERNEL); 458 skb = sock_wmalloc(sk, len + LL_RESERVED_SPACE(dev), 0, GFP_KERNEL);
461 459
462 /* 460 /*
463 * If the write buffer is full, then tough. At this level the user gets to 461 * If the write buffer is full, then tough. At this level the user
464 * deal with the problem - do your own algorithmic backoffs. That's far 462 * gets to deal with the problem - do your own algorithmic backoffs.
465 * more flexible. 463 * That's far more flexible.
466 */ 464 */
467 465
468 if (skb == NULL) 466 if (skb == NULL)
@@ -488,7 +486,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
488 } 486 }
489 487
490 /* Returns -EFAULT on error */ 488 /* Returns -EFAULT on error */
491 err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); 489 err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
492 skb->protocol = proto; 490 skb->protocol = proto;
493 skb->dev = dev; 491 skb->dev = dev;
494 skb->priority = sk->sk_priority; 492 skb->priority = sk->sk_priority;
@@ -501,7 +499,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
501 499
502 dev_queue_xmit(skb); 500 dev_queue_xmit(skb);
503 dev_put(dev); 501 dev_put(dev);
504 return(len); 502 return len;
505 503
506out_free: 504out_free:
507 kfree_skb(skb); 505 kfree_skb(skb);
@@ -537,12 +535,13 @@ static inline unsigned int run_filter(struct sk_buff *skb, struct sock *sk,
537 we will not harm anyone. 535 we will not harm anyone.
538 */ 536 */
539 537
540static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) 538static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
539 struct packet_type *pt, struct net_device *orig_dev)
541{ 540{
542 struct sock *sk; 541 struct sock *sk;
543 struct sockaddr_ll *sll; 542 struct sockaddr_ll *sll;
544 struct packet_sock *po; 543 struct packet_sock *po;
545 u8 * skb_head = skb->data; 544 u8 *skb_head = skb->data;
546 int skb_len = skb->len; 545 int skb_len = skb->len;
547 unsigned int snaplen, res; 546 unsigned int snaplen, res;
548 547
@@ -648,7 +647,8 @@ drop:
648} 647}
649 648
650#ifdef CONFIG_PACKET_MMAP 649#ifdef CONFIG_PACKET_MMAP
651static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) 650static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
651 struct packet_type *pt, struct net_device *orig_dev)
652{ 652{
653 struct sock *sk; 653 struct sock *sk;
654 struct packet_sock *po; 654 struct packet_sock *po;
@@ -658,7 +658,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
658 struct tpacket2_hdr *h2; 658 struct tpacket2_hdr *h2;
659 void *raw; 659 void *raw;
660 } h; 660 } h;
661 u8 * skb_head = skb->data; 661 u8 *skb_head = skb->data;
662 int skb_len = skb->len; 662 int skb_len = skb->len;
663 unsigned int snaplen, res; 663 unsigned int snaplen, res;
664 unsigned long status = TP_STATUS_LOSING|TP_STATUS_USER; 664 unsigned long status = TP_STATUS_LOSING|TP_STATUS_USER;
@@ -821,7 +821,7 @@ ring_is_full:
821static void tpacket_destruct_skb(struct sk_buff *skb) 821static void tpacket_destruct_skb(struct sk_buff *skb)
822{ 822{
823 struct packet_sock *po = pkt_sk(skb->sk); 823 struct packet_sock *po = pkt_sk(skb->sk);
824 void * ph; 824 void *ph;
825 825
826 BUG_ON(skb == NULL); 826 BUG_ON(skb == NULL);
827 827
@@ -836,9 +836,9 @@ static void tpacket_destruct_skb(struct sk_buff *skb)
836 sock_wfree(skb); 836 sock_wfree(skb);
837} 837}
838 838
839static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff * skb, 839static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
840 void * frame, struct net_device *dev, int size_max, 840 void *frame, struct net_device *dev, int size_max,
841 __be16 proto, unsigned char * addr) 841 __be16 proto, unsigned char *addr)
842{ 842{
843 union { 843 union {
844 struct tpacket_hdr *h1; 844 struct tpacket_hdr *h1;
@@ -867,8 +867,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff * skb,
867 break; 867 break;
868 } 868 }
869 if (unlikely(tp_len > size_max)) { 869 if (unlikely(tp_len > size_max)) {
870 printk(KERN_ERR "packet size is too long (%d > %d)\n", 870 pr_err("packet size is too long (%d > %d)\n", tp_len, size_max);
871 tp_len, size_max);
872 return -EMSGSIZE; 871 return -EMSGSIZE;
873 } 872 }
874 873
@@ -883,12 +882,11 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff * skb,
883 NULL, tp_len); 882 NULL, tp_len);
884 if (unlikely(err < 0)) 883 if (unlikely(err < 0))
885 return -EINVAL; 884 return -EINVAL;
886 } else if (dev->hard_header_len ) { 885 } else if (dev->hard_header_len) {
887 /* net device doesn't like empty head */ 886 /* net device doesn't like empty head */
888 if (unlikely(tp_len <= dev->hard_header_len)) { 887 if (unlikely(tp_len <= dev->hard_header_len)) {
889 printk(KERN_ERR "packet size is too short " 888 pr_err("packet size is too short (%d < %d)\n",
890 "(%d < %d)\n", tp_len, 889 tp_len, dev->hard_header_len);
891 dev->hard_header_len);
892 return -EINVAL; 890 return -EINVAL;
893 } 891 }
894 892
@@ -917,9 +915,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff * skb,
917 nr_frags = skb_shinfo(skb)->nr_frags; 915 nr_frags = skb_shinfo(skb)->nr_frags;
918 916
919 if (unlikely(nr_frags >= MAX_SKB_FRAGS)) { 917 if (unlikely(nr_frags >= MAX_SKB_FRAGS)) {
920 printk(KERN_ERR "Packet exceed the number " 918 pr_err("Packet exceed the number of skb frags(%lu)\n",
921 "of skb frags(%lu)\n", 919 MAX_SKB_FRAGS);
922 MAX_SKB_FRAGS);
923 return -EFAULT; 920 return -EFAULT;
924 } 921 }
925 922
@@ -944,8 +941,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
944 struct net_device *dev; 941 struct net_device *dev;
945 __be16 proto; 942 __be16 proto;
946 int ifindex, err, reserve = 0; 943 int ifindex, err, reserve = 0;
947 void * ph; 944 void *ph;
948 struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name; 945 struct sockaddr_ll *saddr = (struct sockaddr_ll *)msg->msg_name;
949 int tp_len, size_max; 946 int tp_len, size_max;
950 unsigned char *addr; 947 unsigned char *addr;
951 int len_sum = 0; 948 int len_sum = 0;
@@ -1038,8 +1035,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
1038 goto out_xmit; 1035 goto out_xmit;
1039 packet_increment_head(&po->tx_ring); 1036 packet_increment_head(&po->tx_ring);
1040 len_sum += tp_len; 1037 len_sum += tp_len;
1041 } 1038 } while (likely((ph != NULL) || ((!(msg->msg_flags & MSG_DONTWAIT))
1042 while (likely((ph != NULL) || ((!(msg->msg_flags & MSG_DONTWAIT))
1043 && (atomic_read(&po->tx_ring.pending)))) 1039 && (atomic_read(&po->tx_ring.pending))))
1044 ); 1040 );
1045 1041
@@ -1064,7 +1060,7 @@ static int packet_snd(struct socket *sock,
1064 struct msghdr *msg, size_t len) 1060 struct msghdr *msg, size_t len)
1065{ 1061{
1066 struct sock *sk = sock->sk; 1062 struct sock *sk = sock->sk;
1067 struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name; 1063 struct sockaddr_ll *saddr = (struct sockaddr_ll *)msg->msg_name;
1068 struct sk_buff *skb; 1064 struct sk_buff *skb;
1069 struct net_device *dev; 1065 struct net_device *dev;
1070 __be16 proto; 1066 __be16 proto;
@@ -1110,7 +1106,7 @@ static int packet_snd(struct socket *sock,
1110 1106
1111 skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev), 1107 skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev),
1112 msg->msg_flags & MSG_DONTWAIT, &err); 1108 msg->msg_flags & MSG_DONTWAIT, &err);
1113 if (skb==NULL) 1109 if (skb == NULL)
1114 goto out_unlock; 1110 goto out_unlock;
1115 1111
1116 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 1112 skb_reserve(skb, LL_RESERVED_SPACE(dev));
@@ -1122,7 +1118,7 @@ static int packet_snd(struct socket *sock,
1122 goto out_free; 1118 goto out_free;
1123 1119
1124 /* Returns -EFAULT on error */ 1120 /* Returns -EFAULT on error */
1125 err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); 1121 err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
1126 if (err) 1122 if (err)
1127 goto out_free; 1123 goto out_free;
1128 1124
@@ -1140,7 +1136,7 @@ static int packet_snd(struct socket *sock,
1140 1136
1141 dev_put(dev); 1137 dev_put(dev);
1142 1138
1143 return(len); 1139 return len;
1144 1140
1145out_free: 1141out_free:
1146 kfree_skb(skb); 1142 kfree_skb(skb);
@@ -1283,9 +1279,10 @@ out_unlock:
1283 * Bind a packet socket to a device 1279 * Bind a packet socket to a device
1284 */ 1280 */
1285 1281
1286static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int addr_len) 1282static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
1283 int addr_len)
1287{ 1284{
1288 struct sock *sk=sock->sk; 1285 struct sock *sk = sock->sk;
1289 char name[15]; 1286 char name[15];
1290 struct net_device *dev; 1287 struct net_device *dev;
1291 int err = -ENODEV; 1288 int err = -ENODEV;
@@ -1296,7 +1293,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
1296 1293
1297 if (addr_len != sizeof(struct sockaddr)) 1294 if (addr_len != sizeof(struct sockaddr))
1298 return -EINVAL; 1295 return -EINVAL;
1299 strlcpy(name,uaddr->sa_data,sizeof(name)); 1296 strlcpy(name, uaddr->sa_data, sizeof(name));
1300 1297
1301 dev = dev_get_by_name(sock_net(sk), name); 1298 dev = dev_get_by_name(sock_net(sk), name);
1302 if (dev) { 1299 if (dev) {
@@ -1308,8 +1305,8 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
1308 1305
1309static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 1306static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1310{ 1307{
1311 struct sockaddr_ll *sll = (struct sockaddr_ll*)uaddr; 1308 struct sockaddr_ll *sll = (struct sockaddr_ll *)uaddr;
1312 struct sock *sk=sock->sk; 1309 struct sock *sk = sock->sk;
1313 struct net_device *dev = NULL; 1310 struct net_device *dev = NULL;
1314 int err; 1311 int err;
1315 1312
@@ -1404,7 +1401,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol)
1404 sk_add_node(sk, &net->packet.sklist); 1401 sk_add_node(sk, &net->packet.sklist);
1405 sock_prot_inuse_add(net, &packet_proto, 1); 1402 sock_prot_inuse_add(net, &packet_proto, 1);
1406 write_unlock_bh(&net->packet.sklist_lock); 1403 write_unlock_bh(&net->packet.sklist_lock);
1407 return(0); 1404 return 0;
1408out: 1405out:
1409 return err; 1406 return err;
1410} 1407}
@@ -1441,7 +1438,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1441 * but then it will block. 1438 * but then it will block.
1442 */ 1439 */
1443 1440
1444 skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err); 1441 skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);
1445 1442
1446 /* 1443 /*
1447 * An error occurred so return it. Because skb_recv_datagram() 1444 * An error occurred so return it. Because skb_recv_datagram()
@@ -1469,10 +1466,9 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1469 */ 1466 */
1470 1467
1471 copied = skb->len; 1468 copied = skb->len;
1472 if (copied > len) 1469 if (copied > len) {
1473 { 1470 copied = len;
1474 copied=len; 1471 msg->msg_flags |= MSG_TRUNC;
1475 msg->msg_flags|=MSG_TRUNC;
1476 } 1472 }
1477 1473
1478 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); 1474 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
@@ -1539,7 +1535,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
1539 struct net_device *dev; 1535 struct net_device *dev;
1540 struct sock *sk = sock->sk; 1536 struct sock *sk = sock->sk;
1541 struct packet_sock *po = pkt_sk(sk); 1537 struct packet_sock *po = pkt_sk(sk);
1542 struct sockaddr_ll *sll = (struct sockaddr_ll*)uaddr; 1538 struct sockaddr_ll *sll = (struct sockaddr_ll *)uaddr;
1543 1539
1544 if (peer) 1540 if (peer)
1545 return -EOPNOTSUPP; 1541 return -EOPNOTSUPP;
@@ -1584,14 +1580,15 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
1584 else 1580 else
1585 return dev_unicast_delete(dev, i->addr); 1581 return dev_unicast_delete(dev, i->addr);
1586 break; 1582 break;
1587 default:; 1583 default:
1584 break;
1588 } 1585 }
1589 return 0; 1586 return 0;
1590} 1587}
1591 1588
1592static void packet_dev_mclist(struct net_device *dev, struct packet_mclist *i, int what) 1589static void packet_dev_mclist(struct net_device *dev, struct packet_mclist *i, int what)
1593{ 1590{
1594 for ( ; i; i=i->next) { 1591 for ( ; i; i = i->next) {
1595 if (i->ifindex == dev->ifindex) 1592 if (i->ifindex == dev->ifindex)
1596 packet_dev_mc(dev, i, what); 1593 packet_dev_mc(dev, i, what);
1597 } 1594 }
@@ -1693,7 +1690,8 @@ static void packet_flush_mclist(struct sock *sk)
1693 struct net_device *dev; 1690 struct net_device *dev;
1694 1691
1695 po->mclist = ml->next; 1692 po->mclist = ml->next;
1696 if ((dev = dev_get_by_index(sock_net(sk), ml->ifindex)) != NULL) { 1693 dev = dev_get_by_index(sock_net(sk), ml->ifindex);
1694 if (dev != NULL) {
1697 packet_dev_mc(dev, ml, -1); 1695 packet_dev_mc(dev, ml, -1);
1698 dev_put(dev); 1696 dev_put(dev);
1699 } 1697 }
@@ -1723,7 +1721,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1723 return -EINVAL; 1721 return -EINVAL;
1724 if (len > sizeof(mreq)) 1722 if (len > sizeof(mreq))
1725 len = sizeof(mreq); 1723 len = sizeof(mreq);
1726 if (copy_from_user(&mreq,optval,len)) 1724 if (copy_from_user(&mreq, optval, len))
1727 return -EFAULT; 1725 return -EFAULT;
1728 if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address))) 1726 if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address)))
1729 return -EINVAL; 1727 return -EINVAL;
@@ -1740,9 +1738,9 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1740 { 1738 {
1741 struct tpacket_req req; 1739 struct tpacket_req req;
1742 1740
1743 if (optlen<sizeof(req)) 1741 if (optlen < sizeof(req))
1744 return -EINVAL; 1742 return -EINVAL;
1745 if (copy_from_user(&req,optval,sizeof(req))) 1743 if (copy_from_user(&req, optval, sizeof(req)))
1746 return -EFAULT; 1744 return -EFAULT;
1747 return packet_set_ring(sk, &req, 0, optname == PACKET_TX_RING); 1745 return packet_set_ring(sk, &req, 0, optname == PACKET_TX_RING);
1748 } 1746 }
@@ -1750,9 +1748,9 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1750 { 1748 {
1751 int val; 1749 int val;
1752 1750
1753 if (optlen!=sizeof(val)) 1751 if (optlen != sizeof(val))
1754 return -EINVAL; 1752 return -EINVAL;
1755 if (copy_from_user(&val,optval,sizeof(val))) 1753 if (copy_from_user(&val, optval, sizeof(val)))
1756 return -EFAULT; 1754 return -EFAULT;
1757 1755
1758 pkt_sk(sk)->copy_thresh = val; 1756 pkt_sk(sk)->copy_thresh = val;
@@ -1985,51 +1983,51 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
1985 struct sock *sk = sock->sk; 1983 struct sock *sk = sock->sk;
1986 1984
1987 switch (cmd) { 1985 switch (cmd) {
1988 case SIOCOUTQ: 1986 case SIOCOUTQ:
1989 { 1987 {
1990 int amount = sk_wmem_alloc_get(sk); 1988 int amount = sk_wmem_alloc_get(sk);
1991 1989
1992 return put_user(amount, (int __user *)arg); 1990 return put_user(amount, (int __user *)arg);
1993 } 1991 }
1994 case SIOCINQ: 1992 case SIOCINQ:
1995 { 1993 {
1996 struct sk_buff *skb; 1994 struct sk_buff *skb;
1997 int amount = 0; 1995 int amount = 0;
1998 1996
1999 spin_lock_bh(&sk->sk_receive_queue.lock); 1997 spin_lock_bh(&sk->sk_receive_queue.lock);
2000 skb = skb_peek(&sk->sk_receive_queue); 1998 skb = skb_peek(&sk->sk_receive_queue);
2001 if (skb) 1999 if (skb)
2002 amount = skb->len; 2000 amount = skb->len;
2003 spin_unlock_bh(&sk->sk_receive_queue.lock); 2001 spin_unlock_bh(&sk->sk_receive_queue.lock);
2004 return put_user(amount, (int __user *)arg); 2002 return put_user(amount, (int __user *)arg);
2005 } 2003 }
2006 case SIOCGSTAMP: 2004 case SIOCGSTAMP:
2007 return sock_get_timestamp(sk, (struct timeval __user *)arg); 2005 return sock_get_timestamp(sk, (struct timeval __user *)arg);
2008 case SIOCGSTAMPNS: 2006 case SIOCGSTAMPNS:
2009 return sock_get_timestampns(sk, (struct timespec __user *)arg); 2007 return sock_get_timestampns(sk, (struct timespec __user *)arg);
2010 2008
2011#ifdef CONFIG_INET 2009#ifdef CONFIG_INET
2012 case SIOCADDRT: 2010 case SIOCADDRT:
2013 case SIOCDELRT: 2011 case SIOCDELRT:
2014 case SIOCDARP: 2012 case SIOCDARP:
2015 case SIOCGARP: 2013 case SIOCGARP:
2016 case SIOCSARP: 2014 case SIOCSARP:
2017 case SIOCGIFADDR: 2015 case SIOCGIFADDR:
2018 case SIOCSIFADDR: 2016 case SIOCSIFADDR:
2019 case SIOCGIFBRDADDR: 2017 case SIOCGIFBRDADDR:
2020 case SIOCSIFBRDADDR: 2018 case SIOCSIFBRDADDR:
2021 case SIOCGIFNETMASK: 2019 case SIOCGIFNETMASK:
2022 case SIOCSIFNETMASK: 2020 case SIOCSIFNETMASK:
2023 case SIOCGIFDSTADDR: 2021 case SIOCGIFDSTADDR:
2024 case SIOCSIFDSTADDR: 2022 case SIOCSIFDSTADDR:
2025 case SIOCSIFFLAGS: 2023 case SIOCSIFFLAGS:
2026 if (!net_eq(sock_net(sk), &init_net)) 2024 if (!net_eq(sock_net(sk), &init_net))
2027 return -ENOIOCTLCMD; 2025 return -ENOIOCTLCMD;
2028 return inet_dgram_ops.ioctl(sock, cmd, arg); 2026 return inet_dgram_ops.ioctl(sock, cmd, arg);
2029#endif 2027#endif
2030 2028
2031 default: 2029 default:
2032 return -ENOIOCTLCMD; 2030 return -ENOIOCTLCMD;
2033 } 2031 }
2034 return 0; 2032 return 0;
2035} 2033}
@@ -2039,7 +2037,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
2039#define packet_poll datagram_poll 2037#define packet_poll datagram_poll
2040#else 2038#else
2041 2039
2042static unsigned int packet_poll(struct file * file, struct socket *sock, 2040static unsigned int packet_poll(struct file *file, struct socket *sock,
2043 poll_table *wait) 2041 poll_table *wait)
2044{ 2042{
2045 struct sock *sk = sock->sk; 2043 struct sock *sk = sock->sk;
@@ -2069,7 +2067,7 @@ static unsigned int packet_poll(struct file * file, struct socket *sock,
2069static void packet_mm_open(struct vm_area_struct *vma) 2067static void packet_mm_open(struct vm_area_struct *vma)
2070{ 2068{
2071 struct file *file = vma->vm_file; 2069 struct file *file = vma->vm_file;
2072 struct socket * sock = file->private_data; 2070 struct socket *sock = file->private_data;
2073 struct sock *sk = sock->sk; 2071 struct sock *sk = sock->sk;
2074 2072
2075 if (sk) 2073 if (sk)
@@ -2079,7 +2077,7 @@ static void packet_mm_open(struct vm_area_struct *vma)
2079static void packet_mm_close(struct vm_area_struct *vma) 2077static void packet_mm_close(struct vm_area_struct *vma)
2080{ 2078{
2081 struct file *file = vma->vm_file; 2079 struct file *file = vma->vm_file;
2082 struct socket * sock = file->private_data; 2080 struct socket *sock = file->private_data;
2083 struct sock *sk = sock->sk; 2081 struct sock *sk = sock->sk;
2084 2082
2085 if (sk) 2083 if (sk)
@@ -2087,8 +2085,8 @@ static void packet_mm_close(struct vm_area_struct *vma)
2087} 2085}
2088 2086
2089static struct vm_operations_struct packet_mmap_ops = { 2087static struct vm_operations_struct packet_mmap_ops = {
2090 .open = packet_mm_open, 2088 .open = packet_mm_open,
2091 .close =packet_mm_close, 2089 .close = packet_mm_close,
2092}; 2090};
2093 2091
2094static void free_pg_vec(char **pg_vec, unsigned int order, unsigned int len) 2092static void free_pg_vec(char **pg_vec, unsigned int order, unsigned int len)
@@ -2239,8 +2237,8 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req,
2239 skb_queue_purge(rb_queue); 2237 skb_queue_purge(rb_queue);
2240#undef XC 2238#undef XC
2241 if (atomic_read(&po->mapped)) 2239 if (atomic_read(&po->mapped))
2242 printk(KERN_DEBUG "packet_mmap: vma is busy: %d\n", 2240 pr_err("packet_mmap: vma is busy: %d\n",
2243 atomic_read(&po->mapped)); 2241 atomic_read(&po->mapped));
2244 } 2242 }
2245 mutex_unlock(&po->pg_vec_lock); 2243 mutex_unlock(&po->pg_vec_lock);
2246 2244
@@ -2303,7 +2301,7 @@ static int packet_mmap(struct file *file, struct socket *sock,
2303 int pg_num; 2301 int pg_num;
2304 2302
2305 for (pg_num = 0; pg_num < rb->pg_vec_pages; 2303 for (pg_num = 0; pg_num < rb->pg_vec_pages;
2306 pg_num++,page++) { 2304 pg_num++, page++) {
2307 err = vm_insert_page(vma, start, page); 2305 err = vm_insert_page(vma, start, page);
2308 if (unlikely(err)) 2306 if (unlikely(err))
2309 goto out; 2307 goto out;
@@ -2372,7 +2370,7 @@ static struct net_proto_family packet_family_ops = {
2372}; 2370};
2373 2371
2374static struct notifier_block packet_netdev_notifier = { 2372static struct notifier_block packet_netdev_notifier = {
2375 .notifier_call =packet_notifier, 2373 .notifier_call = packet_notifier,
2376}; 2374};
2377 2375
2378#ifdef CONFIG_PROC_FS 2376#ifdef CONFIG_PROC_FS
@@ -2402,7 +2400,7 @@ static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2402 ++*pos; 2400 ++*pos;
2403 return (v == SEQ_START_TOKEN) 2401 return (v == SEQ_START_TOKEN)
2404 ? sk_head(&net->packet.sklist) 2402 ? sk_head(&net->packet.sklist)
2405 : sk_next((struct sock*)v) ; 2403 : sk_next((struct sock *)v) ;
2406} 2404}
2407 2405
2408static void packet_seq_stop(struct seq_file *seq, void *v) 2406static void packet_seq_stop(struct seq_file *seq, void *v)
@@ -2430,7 +2428,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)
2430 po->running, 2428 po->running,
2431 atomic_read(&s->sk_rmem_alloc), 2429 atomic_read(&s->sk_rmem_alloc),
2432 sock_i_uid(s), 2430 sock_i_uid(s),
2433 sock_i_ino(s) ); 2431 sock_i_ino(s));
2434 } 2432 }
2435 2433
2436 return 0; 2434 return 0;