udp: add drop count for packets in udp_prod_queue
Subsystems (3)
PATCH 1/1 udp: add drop count for packets in udp_prod_queue
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit b650bf0977d3 ("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.
---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes to unlikely(to_drop) branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachable UDP_MIB_RCVBUFERRORS code
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/
--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
net/ipv4/udp.c +18 -1
@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++; to_drop = skb->next;skb_mark_not_on_list (skb); -/* TODO: update SNMP values. */ sk_skb_reason_drop (sk, skb,SKB_DROP_REASON_PROTO_MEM ); }numa_drop_add (&udp_sk (sk)->drop_counters, nb); +if (err_ipv4 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_MEMERRORS , + err_ipv4); +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_INERRORS , + err_ipv4); + } +if (err_ipv6 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_MEMERRORS , + err_ipv6); +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_INERRORS , + err_ipv6); + } }atomic_sub (total_size, &udp_prod_queue->rmem_alloc);
Signature · 1 line
2.34.1
Willem de Bruijn
maintainerQuoted 27 lines · Mahdi Faramarzpour
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit
b650bf0977d3("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.Signed-off-by Mahdi Faramarzpour <[email protected]>---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes tounlikely(to_drop)branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachableUDP_MIB_RCVBUFERRORScode
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/udp.c +0
-0
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1797
Quoted 5 lines
net/ipv4/udp.c +2
-0@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;
nit: whitespace between variable definition and code block
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1803
Quoted 6 lines
net/ipv4/udp.c +4
-0for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++;
No need for separate counters.
All counters will either update IPv4 or IPv6 stats. Similar to how the caller of _udp_enqueue_schedule_sk is either __udp_queue_rcv_skb or __udpv6_queue_rcv_skb and chooses the SNMP stat based on that.
Can check sk_family == PF_INET6 once.
Quoted 24 lines
net/ipv4/udp.c +12
-1to_drop = skb->next;skb_mark_not_on_list (skb); -/* TODO: update SNMP values. */ sk_skb_reason_drop (sk, skb,SKB_DROP_REASON_PROTO_MEM ); }numa_drop_add (&udp_sk (sk)->drop_counters, nb); +if (err_ipv4 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_MEMERRORS , + err_ipv4); +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_INERRORS , + err_ipv4); + } +if (err_ipv6 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_MEMERRORS , + err_ipv6); +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_INERRORS , + err_ipv6); + } }atomic_sub (total_size, &udp_prod_queue->rmem_alloc);Signature · 1 line
2.34.1
Paolo Abeni
maintainerQuoted 45 lines · Willem de Bruijn
Quoted 27 lines · Mahdi Faramarzpour
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit
b650bf0977d3("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.Signed-off-by Mahdi Faramarzpour <[email protected]>---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes tounlikely(to_drop)branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachableUDP_MIB_RCVBUFERRORScode
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/udp.c +0
-0net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1797
Quoted 5 lines
net/ipv4/udp.c +2
-0@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;nit: whitespace between variable definition and code block
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1803
Quoted 6 lines
net/ipv4/udp.c +4
-0for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++;No need for separate counters.
Quoted 5 lines
All counters will either update IPv4 or IPv6 stats. Similar to how the caller of
_udp_enqueue_schedule_skis either__udp_queue_rcv_skbor__udpv6_queue_rcv_skband chooses the SNMP stat based on that.Can check
sk_family==PF_INET6once.
I think that doing the SNMP accounting in __udp_enqueue_schedule_skb() (for to_drop), __udp_queue_rcv_skb() and __udpv6_queue_rcv_skb() (for skb) is a little confusing and possible error prone in the long run.
I'm wondering if something alike the following (completely untested, not even built! just to give the idea) would be better?
Note that the additional argument in __udp_enqueue_schedule_skb() could be avoided piggybacking the to_drop return argument into the __udp_enqueue_schedule_skb() return value.
---
include/net/udp.h +0 -0
@@ -399,7 +399,8 @@ static inline bool udp_sk_bound_dev_eq(const struct
net *net, int bound_dev_if,
/* net/ipv4/udp.c */
void udp_destruct_common(struct sock *sk);
void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len);
-int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb); +int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb,
+ struct sk_buff *to_drop);
void udp_skb_destructor(struct sock *sk, struct sk_buff *skb); struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags, int
*off,
int *err);
@@ -411,6 +412,21 @@ static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
return __skb_recv_udp(sk, flags, &off, err);
}
+static inline int udp_drop_skbs(struct sock *sk, struct sk_buff *to_drop) +{
+ struct sk_buff *skb;
+ int nb;
+
+ for (nb = 0; to_drop != NULL; nb++) {
+ skb = to_drop;
+ to_drop = skb->next;
+ skb_mark_not_on_list(skb);
+ sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PROTO_MEM);
+ }
+ numa_drop_add(&udp_sk(sk)->drop_counters, nb);
+ return nb;
+}
+
enum skb_drop_reason udp_v4_early_demux(struct sk_buff *skb); bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst); int udp_err(struct sk_buff *, u32);
net/ipv4/udp.c +0 -0
@@ -1696,14 +1696,15 @@ static int udp_rmem_schedule(struct sock *sk,
int size)
return 0;
}
-int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) +int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb,
+ struct sk_buff **to_drop)
{
struct sk_buff_head *list = &sk->sk_receive_queue; struct udp_prod_queue *udp_prod_queue;
- struct sk_buff *next, *to_drop = NULL;
struct llist_node *ll_list;
unsigned int rmem, rcvbuf;
int size, err = -ENOMEM;
+ struct sk_buff *next;
int total_size = 0;
int q_size = 0;
int dropcount;
@@ -1761,8 +1762,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
err = udp_rmem_schedule(sk, size);
if (unlikely(err)) {
/* Free the skbs outside of locked section. */
- skb->next = to_drop;
- to_drop = skb;
+ skb->next = *to_drop;
+ *to_drop = skb;
continue;
}
@@ -1792,17 +1793,6 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
}
}
- if (unlikely(to_drop)) {
- for (nb = 0; to_drop != NULL; nb++) {
- skb = to_drop;
- to_drop = skb->next;
- skb_mark_not_on_list(skb);
- /* TODO: update SNMP values. */
- sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PROTO_MEM);
- }
- numa_drop_add(&udp_sk(sk)->drop_counters, nb);
- }
-
atomic_sub(total_size, &udp_prod_queue->rmem_alloc);
return 0;
@@ -2333,6 +2323,7 @@ void udp_v4_rehash(struct sock *sk)
static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) {
+ struct sk_buff *to_drop = NULL;
int rc;
if (inet_sk(sk)->inet_daddr) {
@@ -2343,7 +2334,13 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
sk_mark_napi_id_once(sk, skb);
}
- rc = __udp_enqueue_schedule_skb(sk, skb);
+ rc = __udp_enqueue_schedule_skb(sk, skb, &to_drop);
+ if (unlikely(to_drop)) {
+ int cnt = udp_drop_skb_list(sk, to_drop);
+
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_MEMERRORS, cnt);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_INERRORS, cnt);
+ }
if (rc < 0) {
int is_udplite = IS_UDPLITE(sk);
int drop_reason;
net/ipv6/udp.c +0 -0
@@ -782,6 +782,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct
inet6_skb_parm *opt,
static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) {
+ struct sk_buff *to_drop = NULL;
int rc;
if (!ipv6_addr_any(&sk->sk_v6_daddr)) {
@@ -792,7 +793,13 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
sk_mark_napi_id_once(sk, skb);
}
- rc = __udp_enqueue_schedule_skb(sk, skb);
+ rc = __udp_enqueue_schedule_skb(sk, skb, &to_drop);
+ if (unlikely(to_drop)) {
+ int cnt = udp_drop_skb_list(sk, to_drop);
+
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_MEMERRORS, cnt);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_INERRORS, cnt);
+ }
if (rc < 0) {
int is_udplite = IS_UDPLITE(sk);
enum skb_drop_reason drop_reason;
Willem de Bruijn
maintainerQuoted 50 lines · Paolo Abeni
Quoted 49 lines · Willem de Bruijn
Quoted 27 lines · Mahdi Faramarzpour
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit
b650bf0977d3("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.Signed-off-by Mahdi Faramarzpour <[email protected]>---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes tounlikely(to_drop)branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachableUDP_MIB_RCVBUFERRORScode
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/udp.c +0
-0net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1797
Quoted 5 lines
net/ipv4/udp.c +2
-0@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;nit: whitespace between variable definition and code block
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1803
Quoted 6 lines
net/ipv4/udp.c +4
-0for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++;No need for separate counters.
All counters will either update IPv4 or IPv6 stats. Similar to how the caller of
_udp_enqueue_schedule_skis either__udp_queue_rcv_skbor__udpv6_queue_rcv_skband chooses the SNMP stat based on that.
Quoted 8 lines
Quoted 1 line
Can check
sk_family==PF_INET6once.I think that doing the SNMP accounting in
__udp_enqueue_schedule_skb()(forto_drop),__udp_queue_rcv_skb()and__udpv6_queue_rcv_skb()(forskb) is a little confusing and possible error prone in the long run.I'm wondering if something alike the following (completely untested, not even built! just to give the idea) would be better?
I don't see the error prone issue with the simpler patch. But SGTM if you prefer this.
Quoted 3 lines
Note that the additional argument in
__udp_enqueue_schedule_skb()could be avoided piggybacking theto_dropreturn argument into the__udp_enqueue_schedule_skb()return value.
Paolo Abeni
maintainerQuoted 10 lines · Willem de Bruijn
Quoted 6 lines · Paolo Abeni
I think that doing the SNMP accounting in
__udp_enqueue_schedule_skb()(forto_drop),__udp_queue_rcv_skb()and__udpv6_queue_rcv_skb()(forskb) is a little confusing and possible error prone in the long run.I'm wondering if something alike the following (completely untested, not even built! just to give the idea) would be better?
I don't see the error prone issue with the simpler patch. But SGTM if you prefer this.
It's not a big deal but if we need to update the UDP MIB someday having to look in different places could cause missing something.
The code I proposed could be made smaller with something alike the following (still completely untested), which in turn looks quite alike what this patch is heading, I guess. So really it's not a big deal.
---
net/ipv4/udp.c +0 -0
@@ -1793,6 +1795,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk,
struct sk_buff *skb)
}
}
+ atomic_sub(total_size, &udp_prod_queue->rmem_alloc);
if (unlikely(to_drop)) {
for (nb = 0; to_drop != NULL; nb++) {
skb = to_drop;
@@ -1802,10 +1805,9 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PROTO_MEM);
}
numa_drop_add(&udp_sk(sk)->drop_counters, nb);
+ return nb;
}
- atomic_sub(total_size, &udp_prod_queue->rmem_alloc);
-
return 0;
drop:
@@ -2345,6 +2347,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
}
rc = __udp_enqueue_schedule_skb(sk, skb);
+ if (likely(!rc))
+ return 0;
+
if (rc < 0) {
int is_udplite = IS_UDPLITE(sk);
int drop_reason;
@@ -2365,6 +2370,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
return -1;
}
+ /* rc > 0, packets dropped after dequeueing from prod_queue */
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_MEMERRORS, rc);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, true), UDP_MIB_INERRORS, rc);
return 0;
}
net/ipv6/udp.c +0 -0
@@ -793,6 +793,9 @@ static int __udpv6_queue_rcv_skb(struct sock *sk,
struct sk_buff *skb)
}
rc = __udp_enqueue_schedule_skb(sk, skb);
+ if (likely(!rc))
+ return 0;
+
if (rc < 0) {
int is_udplite = IS_UDPLITE(sk);
enum skb_drop_reason drop_reason;
@@ -813,6 +816,9 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
return -1;
}
+ /* rc > 0, packets dropped after dequeueing from prod_queue */
+ SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_MEMERRORS, rc);
+ SNMP_ADD_STATS(__UDPX_MIB(sk, false), UDP_MIB_INERRORS, rc);
return 0;
}
Willem de Bruijn
maintainerQuoted 83 lines · Paolo Abeni
Quoted 10 lines · Willem de Bruijn
Quoted 6 lines · Paolo Abeni
I think that doing the SNMP accounting in
__udp_enqueue_schedule_skb()(forto_drop),__udp_queue_rcv_skb()and__udpv6_queue_rcv_skb()(forskb) is a little confusing and possible error prone in the long run.I'm wondering if something alike the following (completely untested, not even built! just to give the idea) would be better?
I don't see the error prone issue with the simpler patch. But SGTM if you prefer this.
It's not a big deal but if we need to update the UDP MIB someday having to look in different places could cause missing something.
The code I proposed could be made smaller with something alike the following (still completely untested), which in turn looks quite alike what this patch is heading, I guess. So really it's not a big deal.
---net/ipv4/udp.c +1
-0@@ -1793,6 +1795,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) } } +atomic_sub (total_size, &udp_prod_queue->rmem_alloc);if (unlikely (to_drop)) {for (nb =0 ; to_drop !=NULL ; nb++) {net/ipv4/udp.c +1
-2skb = to_drop;@@ -1802,10 +1805,9 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)sk_skb_reason_drop (sk ,skb ,SKB_DROP_REASON_PROTO_MEM ); }numa_drop_add (&udp_sk (sk)->drop_counters, nb); +return nb; } -atomic_sub (total_size, &udp_prod_queue->rmem_alloc); -return 0 ;drop:
net/ipv4/udp.c +3
-0@@ -2345,6 +2347,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) } rc =__udp_enqueue_schedule_skb (sk, skb); +if (likely (!rc)) +return 0 ; +if (rc <0 ) {int is_udplite =IS_UDPLITE (sk);net/ipv4/udp.c +3
-0int drop_reason;@@ -2365,6 +2370,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)return -1 ; } +/* rc > 0, packets dropped after dequeueing from prod_queue */ +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_MEMERRORS , rc); +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_INERRORS , rc);return 0 ; }net/ipv6/udp.c +3
-0@@ -793,6 +793,9 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) } rc =__udp_enqueue_schedule_skb (sk, skb); +if (likely (!rc)) +return 0 ; +if (rc <0 ) {int is_udplite =IS_UDPLITE (sk);net/ipv6/udp.c +0
-0enum skb_drop_reason drop_reason;
net/ipv6/udp.c static int __udpv6_queue_rcv_skb(struct sock *sk, · line 824
Quoted 9 lines
net/ipv6/udp.c +3
-0@@ -813,6 +816,9 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)return -1 ; } +/* rc > 0, packets dropped after dequeueing from prod_queue */ +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_MEMERRORS , rc); +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_INERRORS , rc);return 0 ; }
Honestly, I don't see this plumbing of nb as simpler than incrementing the counters right where nb is known. All it takes there is to make the second arg to UDPX_MIB conditional on sk_family. But again I don't care strongly, so SGTM if you do.
Quoted 44 lines · Willem de Bruijn
Quoted 27 lines · Mahdi Faramarzpour
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit
b650bf0977d3("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.Signed-off-by Mahdi Faramarzpour <[email protected]>---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes tounlikely(to_drop)branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachableUDP_MIB_RCVBUFERRORScode
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/udp.c +0
-0net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1797
Quoted 5 lines
net/ipv4/udp.c +2
-0@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;nit: whitespace between variable definition and code block
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1803
Quoted 6 lines
net/ipv4/udp.c +4
-0for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++;
Quoted 7 lines
No need for separate counters.
All counters will either update IPv4 or IPv6 stats. Similar to how the caller of
_udp_enqueue_schedule_skis either__udp_queue_rcv_skbor__udpv6_queue_rcv_skband chooses the SNMP stat based on that.Can check
sk_family==PF_INET6once.
I doubt this. How does this work in case of a dual-stack socket?
Quoted 27 lines
Quoted 25 lines
net/ipv4/udp.c +12
-2to_drop = skb->next;skb_mark_not_on_list (skb); -/* TODO: update SNMP values. */ sk_skb_reason_drop (sk, skb,SKB_DROP_REASON_PROTO_MEM ); }numa_drop_add (&udp_sk (sk)->drop_counters, nb); +if (err_ipv4 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_MEMERRORS , + err_ipv4); +SNMP_ADD_STATS (__UDPX_MIB (sk, true),UDP_MIB_INERRORS , + err_ipv4); + } +if (err_ipv6 >0 ) { +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_MEMERRORS , + err_ipv6); +SNMP_ADD_STATS (__UDPX_MIB (sk, false),UDP_MIB_INERRORS , + err_ipv6); + } }atomic_sub (total_size, &udp_prod_queue->rmem_alloc); --2.34.1
Willem de Bruijn
maintainerQuoted 46 lines · Mahdi Faramarzpour
Quoted 44 lines · Willem de Bruijn
Quoted 27 lines · Mahdi Faramarzpour
This commit adds SNMP drop count increment for the packets in per NUMA queues which were introduced in commit
b650bf0977d3("udp: remove busylock and add per NUMA queues"). note that SNMP counters are incremented currently by the caller for skb. And that these skbs on the intermediate queue cannot be counted there so need similar logic in their error path.Signed-off-by Mahdi Faramarzpour <[email protected]>---
v5:
- check if drop counts are non-zero before increasing countrers
v4: https://lore.kernel.org/netdev/[email protected]/
- move all changes tounlikely(to_drop)branch
v3: https://lore.kernel.org/netdev/[email protected]/
- remove the unreachableUDP_MIB_RCVBUFERRORScode
v2: https://lore.kernel.org/netdev/[email protected]/
- change ENOMEM to ENOBUFS
v1: https://lore.kernel.org/netdev/[email protected]/--- net/ipv4/udp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/udp.c +0
-0net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1797
Quoted 5 lines
net/ipv4/udp.c +2
-0@@ -1793,14 +1793,31 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) }if (unlikely (to_drop)) { +int err_ipv4 =0 ; +int err_ipv6 =0 ;nit: whitespace between variable definition and code block
Quoted 6 lines
net/ipv4/udp.c +4
-0for (nb =0 ; to_drop !=NULL ; nb++) { skb = to_drop; +if (skb->protocol ==htons (ETH_P_IP )) + err_ipv4++; +else + err_ipv6++;
Quoted 8 lines
Quoted 7 lines
No need for separate counters.
All counters will either update IPv4 or IPv6 stats. Similar to how the caller of
_udp_enqueue_schedule_skis either__udp_queue_rcv_skbor__udpv6_queue_rcv_skband chooses the SNMP stat based on that.Can check
sk_family==PF_INET6once.I doubt this. How does this work in case of a dual-stack socket?
I see your point. The question is whether the stats represent socket family or individual datagrams arriving on that socket. There is something to be said for the latter.
But given that __udpv6_queue_rcv_skb unconditionally increments UDP6 stats on drop in __udp_enqueue_schedule_skb, the established behavior seems to be to follow the socket family.