--- zzzz-none-000/linux-2.6.13.1/net/packet/af_packet.c 2005-09-10 02:42:58.000000000 +0000 +++ ohio-7170-487/linux-2.6.13.1/net/packet/af_packet.c 2007-08-17 12:10:39.000000000 +0000 @@ -11,7 +11,7 @@ * Fred N. van Kempen, * Alan Cox, * - * Fixes: + * Fixes: * Alan Cox : verify_area() now used correctly * Alan Cox : new skbuff lists, look ma no backlogs! * Alan Cox : tidied skbuff lists. @@ -34,7 +34,7 @@ * Alexey Kuznetsov : Untied from IPv4 stack. * Cyrus Durgin : Fixed kerneld for kmod. * Michal Ostrowski : Module initialization cleanup. - * Ulises Alonso : Frame number limit removal and + * Ulises Alonso : Frame number limit removal and * packet_set_ring memory leak. * * This program is free software; you can redistribute it and/or @@ -43,7 +43,7 @@ * 2 of the License, or (at your option) any later version. * */ - + #include #include #include @@ -209,7 +209,7 @@ frame_offset = position % po->frames_per_block; frame = po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size); - + return frame; } #endif @@ -252,7 +252,7 @@ */ sk = pt->af_packet_priv; - + /* * Yank back the headers [hope the device set this * right or kerboom...] @@ -308,7 +308,7 @@ * Output a raw packet to a device layer. This bypasses all the other * protocol layers and you must therefore supply it with a complete frame */ - + static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { @@ -318,9 +318,9 @@ struct net_device *dev; unsigned short proto=0; int err; - + /* - * Get and verify the address. + * Get and verify the address. */ if (saddr) @@ -334,7 +334,7 @@ return(-ENOTCONN); /* SOCK_PACKET must be sent giving an address */ /* - * Find the device first to size check it + * Find the device first to size check it */ saddr->spkt_device[13] = 0; @@ -342,12 +342,12 @@ err = -ENODEV; if (dev == NULL) goto out_unlock; - + /* * You may not queue a frame bigger than the mtu. This is the lowest level * raw protocol and you must do your own fragmentation at this level. */ - + err = -EMSGSIZE; if(len>dev->mtu+dev->hard_header_len) goto out_unlock; @@ -360,14 +360,14 @@ * deal with the problem - do your own algorithmic backoffs. That's far * more flexible. */ - - if (skb == NULL) + + if (skb == NULL) goto out_unlock; /* - * Fill it in + * Fill it in */ - + /* FIXME: Save some space for broken drivers that write a * hard header at transmission time by themselves. PPP is the * notable one here. This should really be fixed at the driver level. @@ -616,7 +616,7 @@ spin_lock(&sk->sk_receive_queue.lock); h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head); - + if (h->tp_status) goto ring_is_full; po->head = po->head != po->frame_max ? po->head+1 : 0; @@ -635,7 +635,7 @@ h->tp_snaplen = snaplen; h->tp_mac = macoff; h->tp_net = netoff; - if (skb->stamp.tv_sec == 0) { + if (skb->stamp.tv_sec == 0) { do_gettimeofday(&skb->stamp); sock_enable_timestamp(sk); } @@ -703,9 +703,9 @@ int ifindex, err, reserve = 0; /* - * Get and verify the address. + * Get and verify the address. */ - + if (saddr == NULL) { struct packet_sock *po = pkt_sk(sk); @@ -912,11 +912,11 @@ char name[15]; struct net_device *dev; int err = -ENODEV; - + /* * Check legality */ - + if(addr_len!=sizeof(struct sockaddr)) return -EINVAL; strlcpy(name,uaddr->sa_data,sizeof(name)); @@ -941,7 +941,7 @@ /* * Check legality */ - + if (addr_len < sizeof(struct sockaddr_ll)) return -EINVAL; if (sll->sll_family != AF_PACKET) @@ -968,7 +968,7 @@ }; /* - * Create a packet of type SOCK_PACKET. + * Create a packet of type SOCK_PACKET. */ static int packet_create(struct socket *sock, int protocol) @@ -1078,7 +1078,7 @@ skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err); /* - * An error occurred so return it. Because skb_recv_datagram() + * An error occurred so return it. Because skb_recv_datagram() * handles the blocking we don't see and worry about blocking * retries. */ @@ -1312,7 +1312,7 @@ switch(optname) { #ifdef CONFIG_PACKET_MULTICAST - case PACKET_ADD_MEMBERSHIP: + case PACKET_ADD_MEMBERSHIP: case PACKET_DROP_MEMBERSHIP: { struct packet_mreq mreq; @@ -1371,7 +1371,7 @@ if (len < 0) return -EINVAL; - + switch(optname) { case PACKET_STATISTICS: { @@ -1476,7 +1476,7 @@ } case SIOCGSTAMP: return sock_get_timestamp(sk, (struct timeval __user *)arg); - + #ifdef CONFIG_INET case SIOCADDRT: case SIOCDELRT: @@ -1538,7 +1538,7 @@ struct inode *inode = file->f_dentry->d_inode; struct socket * sock = SOCKET_I(inode); struct sock *sk = sock->sk; - + if (sk) atomic_inc(&pkt_sk(sk)->mapped); } @@ -1549,7 +1549,7 @@ struct inode *inode = file->f_dentry->d_inode; struct socket * sock = SOCKET_I(inode); struct sock *sk = sock->sk; - + if (sk) atomic_dec(&pkt_sk(sk)->mapped); } @@ -1588,7 +1588,7 @@ struct packet_sock *po = pkt_sk(sk); int was_running, num, order = 0; int err = 0; - + if (req->tp_block_nr) { int i, l; @@ -1643,7 +1643,7 @@ int k; for (k=0; kframes_per_block; k++) { - + header = (struct tpacket_hdr*)ptr; header->tp_status = TP_STATUS_KERNEL; ptr += req->tp_frame_size; @@ -1668,7 +1668,7 @@ __sock_put(sk); } spin_unlock(&po->bind_lock); - + synchronize_net(); err = -EBUSY; @@ -1784,7 +1784,7 @@ .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, - .getname = packet_getname, + .getname = packet_getname, .poll = packet_poll, .ioctl = packet_ioctl, .listen = sock_no_listen, @@ -1829,17 +1829,17 @@ static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos) { ++*pos; - return (v == SEQ_START_TOKEN) - ? sk_head(&packet_sklist) + return (v == SEQ_START_TOKEN) + ? sk_head(&packet_sklist) : sk_next((struct sock*)v) ; } static void packet_seq_stop(struct seq_file *seq, void *v) { - read_unlock(&packet_sklist_lock); + read_unlock(&packet_sklist_lock); } -static int packet_seq_show(struct seq_file *seq, void *v) +static int packet_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) seq_puts(seq, "sk RefCnt Type Proto Iface R Rmem User Inode\n"); @@ -1887,7 +1887,9 @@ static void __exit packet_exit(void) { +#if defined(CONFIG_PROC_FS) proc_net_remove("packet"); +#endif /*--- #if defined(CONFIG_PROC_FS) ---*/ unregister_netdevice_notifier(&packet_netdev_notifier); sock_unregister(PF_PACKET); proto_unregister(&packet_proto); @@ -1902,7 +1904,9 @@ sock_register(&packet_family_ops); register_netdevice_notifier(&packet_netdev_notifier); +#if defined(CONFIG_PROC_FS) proc_net_fops_create("packet", 0, &packet_seq_fops); +#endif /*--- #if defined(CONFIG_PROC_FS) ---*/ out: return rc; }