Commit cb61cb9b authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

udp: sk_drops handling

In commits 33c732c3 ([IPV4]: Add raw
drops counter) and a92aa318 ([IPV6]:
Add raw drops counter), Wang Chen added raw drops counter for
/proc/net/raw & /proc/net/raw6

This patch adds this capability to UDP sockets too (/proc/net/udp &
/proc/net/udp6).

This means that 'RcvbufErrors' errors found in /proc/net/snmp can be also
be examined for each udp socket.

# grep Udp: /proc/net/snmp
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors
Udp: 23971006 75 899420 16390693 146348 0

# cat /proc/net/udp
 sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt  ---
uid  timeout inode ref pointer drops
 75: 00000000:02CB 00000000:0000 07 00000000:00000000 00:00000000 00000000  ---
  0        0 2358 2 ffff81082a538c80 0
111: 00000000:006F 00000000:0000 07 00000000:00000000 00:00000000 00000000  ---
  0        0 2286 2 ffff81042dd35c80 146348

In this example, only port 111 (0x006F) was flooded by messages that
user program could not read fast enough. 146348 messages were lost.
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe2c802a
...@@ -166,7 +166,7 @@ struct sock_common { ...@@ -166,7 +166,7 @@ struct sock_common {
* @sk_err: last error * @sk_err: last error
* @sk_err_soft: errors that don't cause failure but are the cause of a * @sk_err_soft: errors that don't cause failure but are the cause of a
* persistent failure not just 'timed out' * persistent failure not just 'timed out'
* @sk_drops: raw drops counter * @sk_drops: raw/udp drops counter
* @sk_ack_backlog: current listen backlog * @sk_ack_backlog: current listen backlog
* @sk_max_ack_backlog: listen backlog set in listen() * @sk_max_ack_backlog: listen backlog set in listen()
* @sk_priority: %SO_PRIORITY setting * @sk_priority: %SO_PRIORITY setting
......
...@@ -944,7 +944,7 @@ static int raw_seq_show(struct seq_file *seq, void *v) ...@@ -944,7 +944,7 @@ static int raw_seq_show(struct seq_file *seq, void *v)
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
seq_printf(seq, " sl local_address rem_address st tx_queue " seq_printf(seq, " sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode drops\n"); "inode ref pointer drops\n");
else else
raw_sock_seq_show(seq, v, raw_seq_private(seq)->bucket); raw_sock_seq_show(seq, v, raw_seq_private(seq)->bucket);
return 0; return 0;
......
...@@ -1040,8 +1040,10 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) ...@@ -1040,8 +1040,10 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
/* Note that an ENOMEM error is charged twice */ /* Note that an ENOMEM error is charged twice */
if (rc == -ENOMEM) if (rc == -ENOMEM) {
UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite); UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite);
atomic_inc(&sk->sk_drops);
}
goto drop; goto drop;
} }
...@@ -1629,12 +1631,13 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f, ...@@ -1629,12 +1631,13 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
__u16 srcp = ntohs(inet->sport); __u16 srcp = ntohs(inet->sport);
seq_printf(f, "%4d: %08X:%04X %08X:%04X" seq_printf(f, "%4d: %08X:%04X %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",
bucket, src, srcp, dest, destp, sp->sk_state, bucket, src, srcp, dest, destp, sp->sk_state,
atomic_read(&sp->sk_wmem_alloc), atomic_read(&sp->sk_wmem_alloc),
atomic_read(&sp->sk_rmem_alloc), atomic_read(&sp->sk_rmem_alloc),
0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp), 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
atomic_read(&sp->sk_refcnt), sp, len); atomic_read(&sp->sk_refcnt), sp,
atomic_read(&sp->sk_drops), len);
} }
int udp4_seq_show(struct seq_file *seq, void *v) int udp4_seq_show(struct seq_file *seq, void *v)
...@@ -1643,7 +1646,7 @@ int udp4_seq_show(struct seq_file *seq, void *v) ...@@ -1643,7 +1646,7 @@ int udp4_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "%-127s\n", seq_printf(seq, "%-127s\n",
" sl local_address rem_address st tx_queue " " sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout " "rx_queue tr tm->when retrnsmt uid timeout "
"inode"); "inode ref pointer drops");
else { else {
struct udp_iter_state *state = seq->private; struct udp_iter_state *state = seq->private;
int len; int len;
......
...@@ -1251,7 +1251,7 @@ static int raw6_seq_show(struct seq_file *seq, void *v) ...@@ -1251,7 +1251,7 @@ static int raw6_seq_show(struct seq_file *seq, void *v)
"local_address " "local_address "
"remote_address " "remote_address "
"st tx_queue rx_queue tr tm->when retrnsmt" "st tx_queue rx_queue tr tm->when retrnsmt"
" uid timeout inode drops\n"); " uid timeout inode ref pointer drops\n");
else else
raw6_sock_seq_show(seq, v, raw_seq_private(seq)->bucket); raw6_sock_seq_show(seq, v, raw_seq_private(seq)->bucket);
return 0; return 0;
......
...@@ -297,8 +297,10 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) ...@@ -297,8 +297,10 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
/* Note that an ENOMEM error is charged twice */ /* Note that an ENOMEM error is charged twice */
if (rc == -ENOMEM) if (rc == -ENOMEM) {
UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite); UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite);
atomic_inc(&sk->sk_drops);
}
goto drop; goto drop;
} }
...@@ -955,7 +957,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket ...@@ -955,7 +957,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
srcp = ntohs(inet->sport); srcp = ntohs(inet->sport);
seq_printf(seq, seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " "%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",
bucket, bucket,
src->s6_addr32[0], src->s6_addr32[1], src->s6_addr32[0], src->s6_addr32[1],
src->s6_addr32[2], src->s6_addr32[3], srcp, src->s6_addr32[2], src->s6_addr32[3], srcp,
...@@ -967,7 +969,8 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket ...@@ -967,7 +969,8 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
0, 0L, 0, 0, 0L, 0,
sock_i_uid(sp), 0, sock_i_uid(sp), 0,
sock_i_ino(sp), sock_i_ino(sp),
atomic_read(&sp->sk_refcnt), sp); atomic_read(&sp->sk_refcnt), sp,
atomic_read(&sp->sk_drops));
} }
int udp6_seq_show(struct seq_file *seq, void *v) int udp6_seq_show(struct seq_file *seq, void *v)
...@@ -978,7 +981,7 @@ int udp6_seq_show(struct seq_file *seq, void *v) ...@@ -978,7 +981,7 @@ int udp6_seq_show(struct seq_file *seq, void *v)
"local_address " "local_address "
"remote_address " "remote_address "
"st tx_queue rx_queue tr tm->when retrnsmt" "st tx_queue rx_queue tr tm->when retrnsmt"
" uid timeout inode\n"); " uid timeout inode ref pointer drops\n");
else else
udp6_sock_seq_show(seq, v, ((struct udp_iter_state *)seq->private)->bucket); udp6_sock_seq_show(seq, v, ((struct udp_iter_state *)seq->private)->bucket);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment