aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sock.h11
-rw-r--r--net/core/sock.c1
-rw-r--r--net/ipv4/raw.c17
3 files changed, 19 insertions, 10 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 6e1542da33a1..f5b643714131 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -145,7 +145,8 @@ struct sock_common {
145 * @sk_forward_alloc: space allocated forward 145 * @sk_forward_alloc: space allocated forward
146 * @sk_allocation: allocation mode 146 * @sk_allocation: allocation mode
147 * @sk_sndbuf: size of send buffer in bytes 147 * @sk_sndbuf: size of send buffer in bytes
148 * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings 148 * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
149 * %SO_OOBINLINE settings
149 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets 150 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
150 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) 151 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
151 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) 152 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
@@ -153,9 +154,12 @@ struct sock_common {
153 * @sk_backlog: always used with the per-socket spinlock held 154 * @sk_backlog: always used with the per-socket spinlock held
154 * @sk_callback_lock: used with the callbacks in the end of this struct 155 * @sk_callback_lock: used with the callbacks in the end of this struct
155 * @sk_error_queue: rarely used 156 * @sk_error_queue: rarely used
156 * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance) 157 * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt,
158 * IPV6_ADDRFORM for instance)
157 * @sk_err: last error 159 * @sk_err: last error
158 * @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out' 160 * @sk_err_soft: errors that don't cause failure but are the cause of a
161 * persistent failure not just 'timed out'
162 * @sk_drops: raw drops counter
159 * @sk_ack_backlog: current listen backlog 163 * @sk_ack_backlog: current listen backlog
160 * @sk_max_ack_backlog: listen backlog set in listen() 164 * @sk_max_ack_backlog: listen backlog set in listen()
161 * @sk_priority: %SO_PRIORITY setting 165 * @sk_priority: %SO_PRIORITY setting
@@ -239,6 +243,7 @@ struct sock {
239 rwlock_t sk_callback_lock; 243 rwlock_t sk_callback_lock;
240 int sk_err, 244 int sk_err,
241 sk_err_soft; 245 sk_err_soft;
246 atomic_t sk_drops;
242 unsigned short sk_ack_backlog; 247 unsigned short sk_ack_backlog;
243 unsigned short sk_max_ack_backlog; 248 unsigned short sk_max_ack_backlog;
244 __u32 sk_priority; 249 __u32 sk_priority;
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;