From: Herbert Xu
Sent: 1/25/2006 6:45:50 PM
> Kris Katterjohn <[EMAIL PROTECTED]> wrote:
> >
> > @@ -1021,6 +1025,7 @@ static int packet_create(struct socket *
> >        po = pkt_sk(sk);
> >        sk->sk_family = PF_PACKET;
> >        po->num = protocol;
> > +       po->accumulate_stats = 0;
> 
> This is unnecessary as sk_alloc zeros the whole structure.
> 
> Cheers,

Okay.


From: jamal
Sent: 1/25/2006 6:52:55 PM
> On Wed, 2006-25-01 at 13:57 -0800, Kris Katterjohn wrote:
> 
> > Signed-off-by: Kris Katterjohn <[EMAIL PROTECTED]>
> > 
> > --- x/net/packet/af_packet.c        2006-01-25 15:48:17.000000000 -0600
> > +++ y/net/packet/af_packet.c        2006-01-25 15:48:12.000000000 -0600
> > @@ -41,6 +41,9 @@
> >   *                                 will simply extend the hardware address
> >   *                                 byte arrays at the end of sockaddr_ll 
> >   *                                 and packet_mreq.
> > + *         Kris Katterjohn :       Added PACKET_ACCUMULATE_STATISTICS
> > + *                                 [gs]etsockopt options and added
> > + *                                 PACKET_STATISTICS setsockopt option.
> >   *
> 
> This looks old school friend. Your name and comments go in the log text
> and not in the source file.
> 
> cheers,
> jamal

Okay.

Signed-off-by: Kris Katterjohn <[EMAIL PROTECTED]>

--- x/net/packet/af_packet.c    2006-01-25 21:33:08.000000000 -0600
+++ y/net/packet/af_packet.c    2006-01-25 21:32:42.000000000 -0600
@@ -190,6 +190,7 @@ struct packet_sock {
        /* struct sock has to be the first member of packet_sock */
        struct sock             sk;
        struct tpacket_stats    stats;
+       int                     accumulate_stats;
 #ifdef CONFIG_PACKET_MMAP
        char *                  *pg_vec;
        unsigned int            head;
@@ -1325,6 +1326,7 @@ static int
 packet_setsockopt(struct socket *sock, int level, int optname, char __user 
*optval, int optlen)
 {
        struct sock *sk = sock->sk;
+       struct packet_sock *po = pkt_sk(sk);
        int ret;
 
        if (level != SOL_PACKET)
@@ -1353,6 +1355,28 @@ packet_setsockopt(struct socket *sock, i
                return ret;
        }
 #endif
+
+       case PACKET_ACCUMULATE_STATISTICS:
+       {
+               int val;
+
+               if (optlen < sizeof(val))
+                       return -EINVAL;
+               if (optlen > sizeof(val))
+                       optlen = sizeof(val);
+               if (copy_from_user(&val, optval, optlen))
+                       return -EFAULT;
+
+               po->accumulate_stats = !!val;
+               return 0;
+       }
+
+       case PACKET_STATISTICS:
+               spin_lock_bh(&sk->sk_receive_queue.lock);
+               memset(&po->stats, 0, sizeof(po->stats));
+               spin_unlock_bh(&sk->sk_receive_queue.lock);
+               return 0;
+
 #ifdef CONFIG_PACKET_MMAP
        case PACKET_RX_RING:
        {
@@ -1399,6 +1423,17 @@ static int packet_getsockopt(struct sock
                return -EINVAL;
                
        switch(optname) {
+       case PACKET_ACCUMULATE_STATISTICS:
+       {
+               if (len < sizeof(po->accumulate_stats))
+                       return -EINVAL;
+               if (len > sizeof(po->accumulate_stats))
+                       len = sizeof(po->accumulate_stats);
+               if (copy_to_user(optval, &po->accumulate_stats, len))
+                       return -EFAULT;
+               break;
+       }
+
        case PACKET_STATISTICS:
        {
                struct tpacket_stats st;
@@ -1407,7 +1442,8 @@ static int packet_getsockopt(struct sock
                        len = sizeof(struct tpacket_stats);
                spin_lock_bh(&sk->sk_receive_queue.lock);
                st = po->stats;
-               memset(&po->stats, 0, sizeof(st));
+               if (!po->accumulate_stats)
+                       memset(&po->stats, 0, sizeof(po->stats));
                spin_unlock_bh(&sk->sk_receive_queue.lock);
                st.tp_packets += st.tp_drops;
 
--- x/include/linux/if_packet.h 2006-01-24 18:27:41.000000000 -0600
+++ y/include/linux/if_packet.h 2006-01-25 11:00:34.000000000 -0600
@@ -39,6 +39,7 @@ struct sockaddr_ll
 #define PACKET_RX_RING                 5
 #define PACKET_STATISTICS              6
 #define PACKET_COPY_THRESH             7
+#define PACKET_ACCUMULATE_STATISTICS   8
 
 struct tpacket_stats
 {


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to