Skip to content

Commit 1781f7f

Browse files
herbertxdavem330
authored andcommitted
[UDP]: Restore missing inDatagrams increments
The previous move of the the UDP inDatagrams counter caused the counting of encapsulated packets, SUNRPC data (as opposed to call) packets and RXRPC packets to go missing. This patch restores all of these. Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 27ab256 commit 1781f7f

File tree

8 files changed

+42
-14
lines changed

8 files changed

+42
-14
lines changed

include/net/ipv6.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
164164
#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
165165
_DEVINC(icmpv6msg, _USER, idev, field)
166166

167-
DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
168-
DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
169-
#define UDP6_INC_STATS_BH(field, is_udplite) do { \
170-
if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
171-
else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
172-
#define UDP6_INC_STATS_USER(field, is_udplite) do { \
173-
if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
174-
else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
175-
176167
struct ip6_ra_chain
177168
{
178169
struct ip6_ra_chain *next;

include/net/udp.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
139139
int (*push_pending_frames)(struct sock *));
140140

141141
DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
142+
DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
143+
144+
/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
145+
DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
146+
DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
147+
142148
/*
143149
* SNMP statistics for UDP and UDP-Lite
144150
*/
@@ -149,6 +155,25 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
149155
if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
150156
else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
151157

158+
#define UDP6_INC_STATS_BH(field, is_udplite) do { \
159+
if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
160+
else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
161+
#define UDP6_INC_STATS_USER(field, is_udplite) do { \
162+
if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
163+
else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
164+
165+
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
166+
#define UDPX_INC_STATS_BH(sk, field) \
167+
do { \
168+
if ((sk)->sk_family == AF_INET) \
169+
UDP_INC_STATS_BH(field, 0); \
170+
else \
171+
UDP6_INC_STATS_BH(field, 0); \
172+
} while (0);
173+
#else
174+
#define UDPX_INC_STATS_BH(sk, field) UDP_INC_STATS_BH(field, 0)
175+
#endif
176+
152177
/* /proc */
153178
struct udp_seq_afinfo {
154179
struct module *owner;

include/net/udplite.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
extern struct proto udplite_prot;
1414
extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
1515

16-
/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
17-
DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
18-
1916
/*
2017
* Checksum computation is all in software, hence simpler getfrag.
2118
*/

net/ipv4/udp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
*/
111111

112112
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
113+
EXPORT_SYMBOL(udp_statistics);
113114

114115
struct hlist_head udp_hash[UDP_HTABLE_SIZE];
115116
DEFINE_RWLOCK(udp_hash_lock);
@@ -969,8 +970,11 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
969970
int ret;
970971

971972
ret = (*up->encap_rcv)(sk, skb);
972-
if (ret <= 0)
973+
if (ret <= 0) {
974+
UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS,
975+
is_udplite);
973976
return -ret;
977+
}
974978
}
975979

976980
/* FALLTHROUGH -- it's a UDP Packet */

net/ipv6/proc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <net/ip.h>
2828
#include <net/sock.h>
2929
#include <net/tcp.h>
30+
#include <net/udp.h>
3031
#include <net/transp_v6.h>
3132
#include <net/ipv6.h>
3233

net/ipv6/udp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/ipv6.h>
3535
#include <linux/icmpv6.h>
3636
#include <linux/init.h>
37+
#include <linux/module.h>
3738
#include <linux/skbuff.h>
3839
#include <asm/uaccess.h>
3940

@@ -51,6 +52,7 @@
5152
#include "udp_impl.h"
5253

5354
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
55+
EXPORT_SYMBOL(udp_stats_in6);
5456

5557
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
5658
{

net/rxrpc/ar-input.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <net/sock.h>
2121
#include <net/af_rxrpc.h>
2222
#include <net/ip.h>
23+
#include <net/udp.h>
2324
#include "ar-internal.h"
2425

2526
unsigned long rxrpc_ack_timeout = 1;
@@ -707,10 +708,13 @@ void rxrpc_data_ready(struct sock *sk, int count)
707708
if (skb_checksum_complete(skb)) {
708709
rxrpc_free_skb(skb);
709710
rxrpc_put_local(local);
711+
UDP_INC_STATS_BH(UDP_MIB_INERRORS, 0);
710712
_leave(" [CSUM failed]");
711713
return;
712714
}
713715

716+
UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, 0);
717+
714718
/* the socket buffer we have is owned by UDP, with UDP's data all over
715719
* it, but we really want our own */
716720
skb_orphan(skb);

net/sunrpc/xprtsock.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,12 @@ static void xs_udp_data_ready(struct sock *sk, int len)
838838
copied = repsize;
839839

840840
/* Suck it into the iovec, verify checksum if not done by hw. */
841-
if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
841+
if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
842+
UDPX_INC_STATS_BH(sk, UDP_MIB_INERRORS);
842843
goto out_unlock;
844+
}
845+
846+
UDPX_INC_STATS_BH(sk, UDP_MIB_INDATAGRAMS);
843847

844848
/* Something worked... */
845849
dst_confirm(skb->dst);

0 commit comments

Comments
 (0)