netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IPV4: add raw drops counter
@ 2007-11-13  9:57 Wang Chen
  2007-11-13 11:11 ` Eric Dumazet
  2007-11-14  3:12 ` [PATCH 1/2] SOCK: " Wang Chen
  0 siblings, 2 replies; 11+ messages in thread
From: Wang Chen @ 2007-11-13  9:57 UTC (permalink / raw)
  To: netdev

Add raw drops counter for IPv4 in /proc/net/raw .

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
 include/net/sock.h |    2 ++
 net/core/sock.c    |    1 +
 net/ipv4/raw.c     |   16 +++++++++-------
 3 files changed, 12 insertions(+), 7 deletions(-)

diff -Nurp linux-2.6.24-rc2.org/include/net/sock.h linux-2.6.24-rc2/include/net/sock.h
--- linux-2.6.24-rc2.org/include/net/sock.h	2007-11-09 16:37:08.000000000 +0800
+++ linux-2.6.24-rc2/include/net/sock.h	2007-11-13 15:19:20.000000000 +0800
@@ -156,6 +156,7 @@ struct sock_common {
   *	@sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
   *	@sk_err: last error
   *	@sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
+  *	@sk_drops: raw drops counter
   *	@sk_ack_backlog: current listen backlog
   *	@sk_max_ack_backlog: listen backlog set in listen()
   *	@sk_priority: %SO_PRIORITY setting
@@ -239,6 +240,7 @@ struct sock {
 	rwlock_t		sk_callback_lock;
 	int			sk_err,
 				sk_err_soft;
+	atomic_t		sk_drops;
 	unsigned short		sk_ack_backlog;
 	unsigned short		sk_max_ack_backlog;
 	__u32			sk_priority;
diff -Nurp linux-2.6.24-rc2.org/net/core/sock.c linux-2.6.24-rc2/net/core/sock.c
--- linux-2.6.24-rc2.org/net/core/sock.c	2007-11-09 16:37:40.000000000 +0800
+++ linux-2.6.24-rc2/net/core/sock.c	2007-11-13 15:20:53.000000000 +0800
@@ -1611,6 +1611,7 @@ void sock_init_data(struct socket *sock,
 	sk->sk_stamp = ktime_set(-1L, -1L);
 
 	atomic_set(&sk->sk_refcnt, 1);
+	atomic_set(&sk->sk_drops, 0);
 }
 
 void fastcall lock_sock_nested(struct sock *sk, int subclass)
diff -Nurp linux-2.6.24-rc2.org/net/ipv4/raw.c linux-2.6.24-rc2/net/ipv4/raw.c
--- linux-2.6.24-rc2.org/net/ipv4/raw.c	2007-11-09 16:37:56.000000000 +0800
+++ linux-2.6.24-rc2/net/ipv4/raw.c	2007-11-13 15:48:17.000000000 +0800
@@ -241,7 +241,7 @@ static int raw_rcv_skb(struct sock * sk,
 	/* Charge it to the socket. */
 
 	if (sock_queue_rcv_skb(sk, skb) < 0) {
-		/* FIXME: increment a raw drops counter here */
+		atomic_inc(&sk->sk_drops);	
 		kfree_skb(skb);
 		return NET_RX_DROP;
 	}
@@ -866,28 +866,30 @@ static __inline__ char *get_raw_sock(str
 	      srcp  = inet->num;
 
 	sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
+		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d",
 		i, src, srcp, dest, destp, sp->sk_state,
 		atomic_read(&sp->sk_wmem_alloc),
 		atomic_read(&sp->sk_rmem_alloc),
 		0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
-		atomic_read(&sp->sk_refcnt), sp);
+		atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
 	return tmpbuf;
 }
 
+#define TMPSZ 128
+
 static int raw_seq_show(struct seq_file *seq, void *v)
 {
-	char tmpbuf[129];
+	char tmpbuf[TMPSZ+1];
 
 	if (v == SEQ_START_TOKEN)
-		seq_printf(seq, "%-127s\n",
+		seq_printf(seq, "%-*s\n", TMPSZ-1,
 			       "  sl  local_address rem_address   st tx_queue "
 			       "rx_queue tr tm->when retrnsmt   uid  timeout "
-			       "inode");
+			       "inode  drops");
 	else {
 		struct raw_iter_state *state = raw_seq_private(seq);
 
-		seq_printf(seq, "%-127s\n",
+		seq_printf(seq, "%-*s\n", TMPSZ-1,
 			   get_raw_sock(v, tmpbuf, state->bucket));
 	}
 	return 0;



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] IPV4: add raw drops counter
  2007-11-13  9:57 [PATCH] IPV4: add raw drops counter Wang Chen
@ 2007-11-13 11:11 ` Eric Dumazet
  2007-11-14  1:27   ` Wang Chen
  2007-11-14  3:12 ` [PATCH 1/2] SOCK: " Wang Chen
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2007-11-13 11:11 UTC (permalink / raw)
  To: Wang Chen; +Cc: netdev

Wang Chen a écrit :
> Add raw drops counter for IPv4 in /proc/net/raw .
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
> ---
>  include/net/sock.h |    2 ++
>  net/core/sock.c    |    1 +
>  net/ipv4/raw.c     |   16 +++++++++-------
>  3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff -Nurp linux-2.6.24-rc2.org/include/net/sock.h linux-2.6.24-rc2/include/net/sock.h
> --- linux-2.6.24-rc2.org/include/net/sock.h	2007-11-09 16:37:08.000000000 +0800
> +++ linux-2.6.24-rc2/include/net/sock.h	2007-11-13 15:19:20.000000000 +0800
> @@ -156,6 +156,7 @@ struct sock_common {
>    *	@sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
>    *	@sk_err: last error
>    *	@sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
> +  *	@sk_drops: raw drops counter
>    *	@sk_ack_backlog: current listen backlog
>    *	@sk_max_ack_backlog: listen backlog set in listen()
>    *	@sk_priority: %SO_PRIORITY setting
> @@ -239,6 +240,7 @@ struct sock {
>  	rwlock_t		sk_callback_lock;
>  	int			sk_err,
>  				sk_err_soft;
> +	atomic_t		sk_drops;
>   
This doesnt need an atomic_t , just an 'unsigned int' is OK, since 
sock_queue_rcv_skb() is called on a locked socket.

Also, I suggest doing the sk_drops increment in sock_queue_rcv_skb() so 
that it can be used for other sockets as well ?

I like having this counter per socket, but only if an application can 
retrieve its value with a getsockopt() call, dont you think ?

getsockopt(sock, SOL_SOCKET, SO_DROPSCNT, &val, &vallen);






^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] IPV4: add raw drops counter
  2007-11-13 11:11 ` Eric Dumazet
@ 2007-11-14  1:27   ` Wang Chen
  2007-11-14  6:00     ` Eric Dumazet
  0 siblings, 1 reply; 11+ messages in thread
From: Wang Chen @ 2007-11-14  1:27 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev

Eric Dumazet said the following on 2007-11-13 19:11:
> Wang Chen a écrit :
>> Add raw drops counter for IPv4 in /proc/net/raw .
>>
>> +    atomic_t        sk_drops;
>>   
> This doesnt need an atomic_t , just an 'unsigned int' is OK, since
> sock_queue_rcv_skb() is called on a locked socket.
> 

Yes, sock_queue_rcv_skb() is called on a locked socket. But sk_drops
will not only used with sock_queue_rcv_skb(), but also with 
xfrm4_policy_check(), skb_checksum_complete(), skb_kill_datagram(),etc.
So, atomic_t ensure sk_drops will be atomic increment.

> Also, I suggest doing the sk_drops increment in sock_queue_rcv_skb() so
> that it can be used for other sockets as well ?
> 

As I described before, sk_drops will be used on different conditions,
on which the raw drop happens.
So doing sk_drops increment in upper caller is better than in 
sock_queue_rcv_skb().

Thank you for your suggestion, I will make a new patch to add sk_drops
increment in other places.

> I like having this counter per socket, but only if an application can
> retrieve its value with a getsockopt() call, dont you think ?
> 
> getsockopt(sock, SOL_SOCKET, SO_DROPSCNT, &val, &vallen);
> 
> 

Yes. I agree.
How do other people think about it?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] SOCK: add raw drops counter
  2007-11-13  9:57 [PATCH] IPV4: add raw drops counter Wang Chen
  2007-11-13 11:11 ` Eric Dumazet
@ 2007-11-14  3:12 ` Wang Chen
  2007-11-14  3:15   ` [PATCH 2/2] SOCK: add raw6 " Wang Chen
  2007-11-14  4:30   ` [PATCH 1/2] SOCK: add raw " David Miller
  1 sibling, 2 replies; 11+ messages in thread
From: Wang Chen @ 2007-11-14  3:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, dada1

Add raw drops counter for IPv4 in /proc/net/raw .

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
 include/net/sock.h |   11 ++++++++---
 net/core/sock.c    |    1 +
 net/ipv4/raw.c     |   17 ++++++++++-------
 3 files changed, 19 insertions(+), 10 deletions(-)

diff -Nurp linux-2.6.24-rc2.org/include/net/sock.h linux-2.6.24-rc2/include/net/sock.h
--- linux-2.6.24-rc2.org/include/net/sock.h	2007-11-09 16:37:08.000000000 +0800
+++ linux-2.6.24-rc2/include/net/sock.h	2007-11-14 10:57:51.000000000 +0800
@@ -145,7 +145,8 @@ struct sock_common {
   *	@sk_forward_alloc: space allocated forward
   *	@sk_allocation: allocation mode
   *	@sk_sndbuf: size of send buffer in bytes
-  *	@sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
+  *	@sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, 
+  *		   %SO_OOBINLINE settings
   *	@sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
   *	@sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
   *	@sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
@@ -153,9 +154,12 @@ struct sock_common {
   *	@sk_backlog: always used with the per-socket spinlock held
   *	@sk_callback_lock: used with the callbacks in the end of this struct
   *	@sk_error_queue: rarely used
-  *	@sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
+  *	@sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, 
+  *			  IPV6_ADDRFORM for instance)
   *	@sk_err: last error
-  *	@sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
+  *	@sk_err_soft: errors that don't cause failure but are the cause of a 
+  *		      persistent failure not just 'timed out'
+  *	@sk_drops: raw drops counter
   *	@sk_ack_backlog: current listen backlog
   *	@sk_max_ack_backlog: listen backlog set in listen()
   *	@sk_priority: %SO_PRIORITY setting
@@ -239,6 +243,7 @@ struct sock {
 	rwlock_t		sk_callback_lock;
 	int			sk_err,
 				sk_err_soft;
+	atomic_t		sk_drops;
 	unsigned short		sk_ack_backlog;
 	unsigned short		sk_max_ack_backlog;
 	__u32			sk_priority;
diff -Nurp linux-2.6.24-rc2.org/net/core/sock.c linux-2.6.24-rc2/net/core/sock.c
--- linux-2.6.24-rc2.org/net/core/sock.c	2007-11-09 16:37:40.000000000 +0800
+++ linux-2.6.24-rc2/net/core/sock.c	2007-11-13 15:20:53.000000000 +0800
@@ -1611,6 +1611,7 @@ void sock_init_data(struct socket *sock,
 	sk->sk_stamp = ktime_set(-1L, -1L);
 
 	atomic_set(&sk->sk_refcnt, 1);
+	atomic_set(&sk->sk_drops, 0);
 }
 
 void fastcall lock_sock_nested(struct sock *sk, int subclass)
diff -Nurp linux-2.6.24-rc2.org/net/ipv4/raw.c linux-2.6.24-rc2/net/ipv4/raw.c
--- linux-2.6.24-rc2.org/net/ipv4/raw.c	2007-11-09 16:37:56.000000000 +0800
+++ linux-2.6.24-rc2/net/ipv4/raw.c	2007-11-14 09:32:02.000000000 +0800
@@ -241,7 +241,7 @@ static int raw_rcv_skb(struct sock * sk,
 	/* Charge it to the socket. */
 
 	if (sock_queue_rcv_skb(sk, skb) < 0) {
-		/* FIXME: increment a raw drops counter here */
+		atomic_inc(&sk->sk_drops);	
 		kfree_skb(skb);
 		return NET_RX_DROP;
 	}
@@ -252,6 +252,7 @@ static int raw_rcv_skb(struct sock * sk,
 int raw_rcv(struct sock *sk, struct sk_buff *skb)
 {
 	if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
+		atomic_inc(&sk->sk_drops);
 		kfree_skb(skb);
 		return NET_RX_DROP;
 	}
@@ -866,28 +867,30 @@ static __inline__ char *get_raw_sock(str
 	      srcp  = inet->num;
 
 	sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
-		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
+		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d",
 		i, src, srcp, dest, destp, sp->sk_state,
 		atomic_read(&sp->sk_wmem_alloc),
 		atomic_read(&sp->sk_rmem_alloc),
 		0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
-		atomic_read(&sp->sk_refcnt), sp);
+		atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
 	return tmpbuf;
 }
 
+#define TMPSZ 128
+
 static int raw_seq_show(struct seq_file *seq, void *v)
 {
-	char tmpbuf[129];
+	char tmpbuf[TMPSZ+1];
 
 	if (v == SEQ_START_TOKEN)
-		seq_printf(seq, "%-127s\n",
+		seq_printf(seq, "%-*s\n", TMPSZ-1,
 			       "  sl  local_address rem_address   st tx_queue "
 			       "rx_queue tr tm->when retrnsmt   uid  timeout "
-			       "inode");
+			       "inode  drops");
 	else {
 		struct raw_iter_state *state = raw_seq_private(seq);
 
-		seq_printf(seq, "%-127s\n",
+		seq_printf(seq, "%-*s\n", TMPSZ-1,
 			   get_raw_sock(v, tmpbuf, state->bucket));
 	}
 	return 0;


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] SOCK: add raw6 drops counter
  2007-11-14  3:12 ` [PATCH 1/2] SOCK: " Wang Chen
@ 2007-11-14  3:15   ` Wang Chen
  2007-11-14  4:31     ` David Miller
  2007-11-14  5:48     ` Eric Dumazet
  2007-11-14  4:30   ` [PATCH 1/2] SOCK: add raw " David Miller
  1 sibling, 2 replies; 11+ messages in thread
From: Wang Chen @ 2007-11-14  3:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, dada1

Add raw drops counter for IPv6 in /proc/net/raw6 .

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
 raw.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff -Nurp linux-2.6.24-rc2.org/net/ipv6/raw.c linux-2.6.24-rc2/net/ipv6/raw.c
--- linux-2.6.24-rc2.org/net/ipv6/raw.c	2007-11-09 16:38:05.000000000 +0800
+++ linux-2.6.24-rc2/net/ipv6/raw.c	2007-11-14 09:46:54.000000000 +0800
@@ -354,14 +354,14 @@ static inline int rawv6_rcv_skb(struct s
 {
 	if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
 	    skb_checksum_complete(skb)) {
-		/* FIXME: increment a raw6 drops counter here */
+		atomic_inc(&sk->sk_drops);	
 		kfree_skb(skb);
 		return 0;
 	}
 
 	/* Charge it to the socket. */
 	if (sock_queue_rcv_skb(sk,skb)<0) {
-		/* FIXME: increment a raw6 drops counter here */
+		atomic_inc(&sk->sk_drops);
 		kfree_skb(skb);
 		return 0;
 	}
@@ -382,6 +382,7 @@ int rawv6_rcv(struct sock *sk, struct sk
 	struct raw6_sock *rp = raw6_sk(sk);
 
 	if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
+		atomic_inc(&sk->sk_drops);
 		kfree_skb(skb);
 		return NET_RX_DROP;
 	}
@@ -405,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk
 
 	if (inet->hdrincl) {
 		if (skb_checksum_complete(skb)) {
-			/* FIXME: increment a raw6 drops counter here */
+			atomic_inc(&sk->sk_drops);
 			kfree_skb(skb);
 			return 0;
 		}
@@ -496,7 +497,7 @@ csum_copy_err:
 	   as some normal condition.
 	 */
 	err = (flags&MSG_DONTWAIT) ? -EAGAIN : -EHOSTUNREACH;
-	/* FIXME: increment a raw6 drops counter here */
+	atomic_inc(&sk->sk_drops);
 	goto out;
 }
 
@@ -1251,7 +1252,7 @@ static void raw6_sock_seq_show(struct se
 	srcp  = inet_sk(sp)->num;
 	seq_printf(seq,
 		   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-		   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p\n",
+		   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
 		   i,
 		   src->s6_addr32[0], src->s6_addr32[1],
 		   src->s6_addr32[2], src->s6_addr32[3], srcp,
@@ -1263,7 +1264,7 @@ static void raw6_sock_seq_show(struct se
 		   0, 0L, 0,
 		   sock_i_uid(sp), 0,
 		   sock_i_ino(sp),
-		   atomic_read(&sp->sk_refcnt), sp);
+		   atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
 }
 
 static int raw6_seq_show(struct seq_file *seq, void *v)
@@ -1274,7 +1275,7 @@ static int raw6_seq_show(struct seq_file
 			   "local_address                         "
 			   "remote_address                        "
 			   "st tx_queue rx_queue tr tm->when retrnsmt"
-			   "   uid  timeout inode\n");
+			   "   uid  timeout inode  drops\n");
 	else
 		raw6_sock_seq_show(seq, v, raw6_seq_private(seq)->bucket);
 	return 0;


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] SOCK: add raw drops counter
  2007-11-14  3:12 ` [PATCH 1/2] SOCK: " Wang Chen
  2007-11-14  3:15   ` [PATCH 2/2] SOCK: add raw6 " Wang Chen
@ 2007-11-14  4:30   ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2007-11-14  4:30 UTC (permalink / raw)
  To: wangchen; +Cc: netdev, dada1

From: Wang Chen <wangchen@cn.fujitsu.com>
Date: Wed, 14 Nov 2007 11:12:18 +0800

> Add raw drops counter for IPv4 in /proc/net/raw .
> 
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>

Applied to net-2.6.25, but your patch a lot of whitespace
problems:

Adds trailing whitespace.
diff:9:  *	@sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, 
Adds trailing whitespace.
diff:19:  *	@sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, 
Adds trailing whitespace.
diff:23:  *	@sk_err_soft: errors that don't cause failure but are the cause of a 
Adds trailing whitespace.
diff:56:		atomic_inc(&sk->sk_drops);	
warning: 4 lines add whitespace errors.

I fixed it by hand this time, but please fix this yourself before
future submissions.

Thank you.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] SOCK: add raw6 drops counter
  2007-11-14  3:15   ` [PATCH 2/2] SOCK: add raw6 " Wang Chen
@ 2007-11-14  4:31     ` David Miller
  2007-11-14  4:50       ` Wang Chen
  2007-11-14  5:48     ` Eric Dumazet
  1 sibling, 1 reply; 11+ messages in thread
From: David Miller @ 2007-11-14  4:31 UTC (permalink / raw)
  To: wangchen; +Cc: netdev, dada1

From: Wang Chen <wangchen@cn.fujitsu.com>
Date: Wed, 14 Nov 2007 11:15:57 +0800

> Add raw drops counter for IPv6 in /proc/net/raw6 .
> 
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>

Applied to net-2.6.25, but again more whitespace problems:

Adds trailing whitespace.
diff:9:		atomic_inc(&sk->sk_drops);	

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] SOCK: add raw6 drops counter
  2007-11-14  4:31     ` David Miller
@ 2007-11-14  4:50       ` Wang Chen
  0 siblings, 0 replies; 11+ messages in thread
From: Wang Chen @ 2007-11-14  4:50 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

David Miller said the following on 2007-11-14 12:31:
> From: Wang Chen <wangchen@cn.fujitsu.com>
> Date: Wed, 14 Nov 2007 11:15:57 +0800
> 
>> Add raw drops counter for IPv6 in /proc/net/raw6 .
>>
>> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
> 
> Applied to net-2.6.25, but again more whitespace problems:
> 
> Adds trailing whitespace.
> diff:9:		atomic_inc(&sk->sk_drops);	
> 

Sorry for that. I will pay more attention to it.
Thank you.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] SOCK: add raw6 drops counter
  2007-11-14  3:15   ` [PATCH 2/2] SOCK: add raw6 " Wang Chen
  2007-11-14  4:31     ` David Miller
@ 2007-11-14  5:48     ` Eric Dumazet
  2007-11-14  6:45       ` Wang Chen
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2007-11-14  5:48 UTC (permalink / raw)
  To: Wang Chen; +Cc: davem, netdev

Wang Chen a écrit :
> Add raw drops counter for IPv6 in /proc/net/raw6 .
> 
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
> ---
>  raw.c |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff -Nurp linux-2.6.24-rc2.org/net/ipv6/raw.c linux-2.6.24-rc2/net/ipv6/raw.c
> --- linux-2.6.24-rc2.org/net/ipv6/raw.c	2007-11-09 16:38:05.000000000 +0800
> +++ linux-2.6.24-rc2/net/ipv6/raw.c	2007-11-14 09:46:54.000000000 +0800
> @@ -354,14 +354,14 @@ static inline int rawv6_rcv_skb(struct s
>  {
>  	if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
>  	    skb_checksum_complete(skb)) {
> -		/* FIXME: increment a raw6 drops counter here */
> +		atomic_inc(&sk->sk_drops);	

I am not sure the comment was refering to a per socket counter here.

If the frame checksum is bad, we can not be sure the socket is OK, since the 
garbaged bits could be in the tuple that identify the socket.

Maybe here we want to increment a global raw6 drop counter (well, for the 
given ipv6 instance)

>  		kfree_skb(skb);
>  		return 0;
>  	}
>  
>  	/* Charge it to the socket. */
>  	if (sock_queue_rcv_skb(sk,skb)<0) {
> -		/* FIXME: increment a raw6 drops counter here */
> +		atomic_inc(&sk->sk_drops);
>  		kfree_skb(skb);
>  		return 0;
>  	}
> @@ -382,6 +382,7 @@ int rawv6_rcv(struct sock *sk, struct sk
>  	struct raw6_sock *rp = raw6_sk(sk);
>  
>  	if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
> +		atomic_inc(&sk->sk_drops);
>  		kfree_skb(skb);
>  		return NET_RX_DROP;
>  	}
> @@ -405,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk
>  
>  	if (inet->hdrincl) {
>  		if (skb_checksum_complete(skb)) {
> -			/* FIXME: increment a raw6 drops counter here */
> +			atomic_inc(&sk->sk_drops);

Same remark here.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] IPV4: add raw drops counter
  2007-11-14  1:27   ` Wang Chen
@ 2007-11-14  6:00     ` Eric Dumazet
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2007-11-14  6:00 UTC (permalink / raw)
  To: Wang Chen; +Cc: netdev

Wang Chen a écrit :
> Eric Dumazet said the following on 2007-11-13 19:11:
>> Wang Chen a écrit :
>>> Add raw drops counter for IPv4 in /proc/net/raw .
>>>
>>> +    atomic_t        sk_drops;
>>>   
>> This doesnt need an atomic_t , just an 'unsigned int' is OK, since
>> sock_queue_rcv_skb() is called on a locked socket.
>>
> 
> Yes, sock_queue_rcv_skb() is called on a locked socket. But sk_drops
> will not only used with sock_queue_rcv_skb(), but also with 
> xfrm4_policy_check(), skb_checksum_complete(), skb_kill_datagram(),etc.
> So, atomic_t ensure sk_drops will be atomic increment.
> 
>> Also, I suggest doing the sk_drops increment in sock_queue_rcv_skb() so
>> that it can be used for other sockets as well ?
>>
> 
> As I described before, sk_drops will be used on different conditions,
> on which the raw drop happens.
> So doing sk_drops increment in upper caller is better than in 
> sock_queue_rcv_skb().
> 
> Thank you for your suggestion, I will make a new patch to add sk_drops
> increment in other places.
> 

Thank you for clarifications, I was not aware upcoming patches were planed.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] SOCK: add raw6 drops counter
  2007-11-14  5:48     ` Eric Dumazet
@ 2007-11-14  6:45       ` Wang Chen
  0 siblings, 0 replies; 11+ messages in thread
From: Wang Chen @ 2007-11-14  6:45 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, netdev

Eric Dumazet said the following on 2007-11-14 13:48:
>> diff -Nurp linux-2.6.24-rc2.org/net/ipv6/raw.c
>> linux-2.6.24-rc2/net/ipv6/raw.c
>> --- linux-2.6.24-rc2.org/net/ipv6/raw.c    2007-11-09
>> 16:38:05.000000000 +0800
>> +++ linux-2.6.24-rc2/net/ipv6/raw.c    2007-11-14 09:46:54.000000000
>> +0800
>> @@ -354,14 +354,14 @@ static inline int rawv6_rcv_skb(struct s
>>  {
>>      if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
>>          skb_checksum_complete(skb)) {
>> -        /* FIXME: increment a raw6 drops counter here */
>> +        atomic_inc(&sk->sk_drops);   
> 
> I am not sure the comment was refering to a per socket counter here.
> 
> If the frame checksum is bad, we can not be sure the socket is OK, since
> the garbaged bits could be in the tuple that identify the socket.
> 
> Maybe here we want to increment a global raw6 drop counter (well, for
> the given ipv6 instance)
> 

What the /proc/net/raw6 shows is statistical information about raw socket
in IPv6 stack. And the information is per socket per row. 
So I think it's better to count it to per socket.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-11-14  6:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-13  9:57 [PATCH] IPV4: add raw drops counter Wang Chen
2007-11-13 11:11 ` Eric Dumazet
2007-11-14  1:27   ` Wang Chen
2007-11-14  6:00     ` Eric Dumazet
2007-11-14  3:12 ` [PATCH 1/2] SOCK: " Wang Chen
2007-11-14  3:15   ` [PATCH 2/2] SOCK: add raw6 " Wang Chen
2007-11-14  4:31     ` David Miller
2007-11-14  4:50       ` Wang Chen
2007-11-14  5:48     ` Eric Dumazet
2007-11-14  6:45       ` Wang Chen
2007-11-14  4:30   ` [PATCH 1/2] SOCK: add raw " David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).