aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorWang Chen <wangchen@cn.fujitsu.com>2007-11-13 23:30:01 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:53:33 -0500
commit33c732c36169d7022ad7d6eb474b0c9be43a2dc1 (patch)
treea9ac2b8a488cc288bfd2f407d8ad9dd592b29055 /net
parent6ff7751d06f63131830102ffa0c9a38b313f100e (diff)
[IPV4]: Add raw drops counter.
Add raw drops counter for IPv4 in /proc/net/raw . Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/sock.c1
-rw-r--r--net/ipv4/raw.c17
2 files changed, 11 insertions, 7 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index c519b439b8b1..2029d095b4c5 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1611,6 +1611,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
1611 sk->sk_stamp = ktime_set(-1L, -1L); 1611 sk->sk_stamp = ktime_set(-1L, -1L);
1612 1612
1613 atomic_set(&sk->sk_refcnt, 1); 1613 atomic_set(&sk->sk_refcnt, 1);
1614 atomic_set(&sk->sk_drops, 0);
1614} 1615}
1615 1616
1616void fastcall lock_sock_nested(struct sock *sk, int subclass) 1617void fastcall lock_sock_nested(struct sock *sk, int subclass)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index e7050f8eabeb..761056ef4932 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -241,7 +241,7 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
241 /* Charge it to the socket. */ 241 /* Charge it to the socket. */
242 242
243 if (sock_queue_rcv_skb(sk, skb) < 0) { 243 if (sock_queue_rcv_skb(sk, skb) < 0) {
244 /* FIXME: increment a raw drops counter here */ 244 atomic_inc(&sk->sk_drops);
245 kfree_skb(skb); 245 kfree_skb(skb);
246 return NET_RX_DROP; 246 return NET_RX_DROP;
247 } 247 }
@@ -252,6 +252,7 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
252int raw_rcv(struct sock *sk, struct sk_buff *skb) 252int raw_rcv(struct sock *sk, struct sk_buff *skb)
253{ 253{
254 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { 254 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
255 atomic_inc(&sk->sk_drops);
255 kfree_skb(skb); 256 kfree_skb(skb);
256 return NET_RX_DROP; 257 return NET_RX_DROP;
257 } 258 }
@@ -871,28 +872,30 @@ static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
871 srcp = inet->num; 872 srcp = inet->num;
872 873
873 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" 874 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
874 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p", 875 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d",
875 i, src, srcp, dest, destp, sp->sk_state, 876 i, src, srcp, dest, destp, sp->sk_state,
876 atomic_read(&sp->sk_wmem_alloc), 877 atomic_read(&sp->sk_wmem_alloc),
877 atomic_read(&sp->sk_rmem_alloc), 878 atomic_read(&sp->sk_rmem_alloc),
878 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp), 879 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
879 atomic_read(&sp->sk_refcnt), sp); 880 atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
880 return tmpbuf; 881 return tmpbuf;
881} 882}
882 883
884#define TMPSZ 128
885
883static int raw_seq_show(struct seq_file *seq, void *v) 886static int raw_seq_show(struct seq_file *seq, void *v)
884{ 887{
885 char tmpbuf[129]; 888 char tmpbuf[TMPSZ+1];
886 889
887 if (v == SEQ_START_TOKEN) 890 if (v == SEQ_START_TOKEN)
888 seq_printf(seq, "%-127s\n", 891 seq_printf(seq, "%-*s\n", TMPSZ-1,
889 " sl local_address rem_address st tx_queue " 892 " sl local_address rem_address st tx_queue "
890 "rx_queue tr tm->when retrnsmt uid timeout " 893 "rx_queue tr tm->when retrnsmt uid timeout "
891 "inode"); 894 "inode drops");
892 else { 895 else {
893 struct raw_iter_state *state = raw_seq_private(seq); 896 struct raw_iter_state *state = raw_seq_private(seq);
894 897
895 seq_printf(seq, "%-127s\n", 898 seq_printf(seq, "%-*s\n", TMPSZ-1,
896 get_raw_sock(v, tmpbuf, state->bucket)); 899 get_raw_sock(v, tmpbuf, state->bucket));
897 } 900 }
898 return 0; 901 return 0;