* [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking
@ 2007-12-04 12:58 Herbert Xu
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-05 9:52 ` [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking David Miller
0 siblings, 2 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-04 12:58 UTC (permalink / raw)
To: David S. Miller, netdev
[UDP]: Avoid repeated counting of checksum errors due to peeking
Currently it is possible for two processes to peek on the same socket
and end up incrementing the error counter twice for the same packet.
This patch fixes it by making skb_kill_datagram return whether it
succeeded in unlinking the packet and only incrementing the counter
if it did.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/skbuff.h | 2 +-
net/core/datagram.c | 9 ++++++++-
net/ipv4/udp.c | 5 ++---
net/ipv6/udp.c | 4 ++--
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1552,7 +1552,7 @@ extern int skb_copy_and_csum_data
int hlen,
struct iovec *iov);
extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
-extern void skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
+extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
unsigned int flags);
extern __wsum skb_checksum(const struct sk_buff *skb, int offset,
int len, __wsum csum);
diff --git a/net/core/datagram.c b/net/core/datagram.c
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -217,20 +217,27 @@ void skb_free_datagram(struct sock *sk,
* This function currently only disables BH when acquiring the
* sk_receive_queue lock. Therefore it must not be used in a
* context where that lock is acquired in an IRQ context.
+ *
+ * It returns 0 if the packet was removed by us.
*/
-void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
+int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
{
+ int err = 0;
+
if (flags & MSG_PEEK) {
+ err = -ENOENT;
spin_lock_bh(&sk->sk_receive_queue.lock);
if (skb == skb_peek(&sk->sk_receive_queue)) {
__skb_unlink(skb, &sk->sk_receive_queue);
atomic_dec(&skb->users);
+ err = 0;
}
spin_unlock_bh(&sk->sk_receive_queue.lock);
}
kfree_skb(skb);
+ return err;
}
EXPORT_SYMBOL(skb_kill_datagram);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -899,9 +899,8 @@ out:
return err;
csum_copy_err:
- UDP_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
-
- skb_kill_datagram(sk, skb, flags);
+ if (!skb_kill_datagram(sk, skb, flags))
+ UDP_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
if (noblock)
return -EAGAIN;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -207,8 +207,8 @@ out:
return err;
csum_copy_err:
- UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
- skb_kill_datagram(sk, skb, flags);
+ if (!skb_kill_datagram(sk, skb, flags))
+ UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
if (flags & MSG_DONTWAIT)
return -EAGAIN;
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-04 12:58 [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking Herbert Xu
@ 2007-12-04 13:01 ` Herbert Xu
2007-12-04 13:03 ` [PATCH 3/3] [UDP]: Only increment counter on first peek/recv Herbert Xu
` (2 more replies)
2007-12-05 9:52 ` [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking David Miller
1 sibling, 3 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-04 13:01 UTC (permalink / raw)
To: David S. Miller, netdev
Hi Dave:
You were right about the SUNRPC stuff being missing after all. I'd
only looked in svcsock.c and missed the call in xprtsock.c.
[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 <herbert@gondor.apana.org.au>
---
include/net/udp.h | 4 ++++
include/net/udplite.h | 3 ---
net/ipv4/udp.c | 6 +++++-
net/rxrpc/ar-input.c | 4 ++++
net/sunrpc/xprtsock.c | 6 +++++-
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/include/net/udp.h b/include/net/udp.h
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -139,6 +139,10 @@ extern int udp_lib_setsockopt(struct so
int (*push_pending_frames)(struct sock *));
DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
+
+/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
+DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
+
/*
* SNMP statistics for UDP and UDP-Lite
*/
diff --git a/include/net/udplite.h b/include/net/udplite.h
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -13,9 +13,6 @@
extern struct proto udplite_prot;
extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
-/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
-DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
-
/*
* Checksum computation is all in software, hence simpler getfrag.
*/
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -110,6 +110,7 @@
*/
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
+EXPORT_SYMBOL(udp_statistics);
struct hlist_head udp_hash[UDP_HTABLE_SIZE];
DEFINE_RWLOCK(udp_hash_lock);
@@ -969,8 +970,11 @@ int udp_queue_rcv_skb(struct sock * sk,
int ret;
ret = (*up->encap_rcv)(sk, skb);
- if (ret <= 0)
+ if (ret <= 0) {
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS,
+ is_udplite);
return -ret;
+ }
}
/* FALLTHROUGH -- it's a UDP Packet */
diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
--- a/net/rxrpc/ar-input.c
+++ b/net/rxrpc/ar-input.c
@@ -20,6 +20,7 @@
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <net/ip.h>
+#include <net/udp.h>
#include "ar-internal.h"
unsigned long rxrpc_ack_timeout = 1;
@@ -707,10 +708,13 @@ void rxrpc_data_ready(struct sock *sk, i
if (skb_checksum_complete(skb)) {
rxrpc_free_skb(skb);
rxrpc_put_local(local);
+ UDP_INC_STATS_USER(UDP_MIB_INERRORS, 0);
_leave(" [CSUM failed]");
return;
}
+ UDP_INC_STATS_USER(UDP_MIB_INDATAGRAMS, 0);
+
/* the socket buffer we have is owned by UDP, with UDP's data all over
* it, but we really want our own */
skb_orphan(skb);
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -838,8 +838,12 @@ static void xs_udp_data_ready(struct soc
copied = repsize;
/* Suck it into the iovec, verify checksum if not done by hw. */
- if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
+ if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
+ UDP_INC_STATS_USER(UDP_MIB_INERRORS, 0);
goto out_unlock;
+ }
+
+ UDP_INC_STATS_USER(UDP_MIB_INDATAGRAMS, 0);
/* Something worked... */
dst_confirm(skb->dst);
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/3] [UDP]: Only increment counter on first peek/recv
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
@ 2007-12-04 13:03 ` Herbert Xu
2007-12-05 9:54 ` David Miller
2007-12-05 1:02 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-05 1:42 ` Wang Chen
2 siblings, 1 reply; 21+ messages in thread
From: Herbert Xu @ 2007-12-04 13:03 UTC (permalink / raw)
To: David S. Miller, netdev
[UDP]: Only increment counter on first peek/recv
The previous move of the the UDP inDatagrams counter caused each
peek of the same packet to be counted separately. This may be
undesirable.
This patch fixes this by adding a bit to sk_buff to record whether
this packet has already been seen through skb_recv_datagram. We
then only increment the counter when the packet is seen for the
first time.
The only dodgy part is the fact that skb_recv_datagram doesn't have
a good way of returning this new bit of information. So I've added
a new function __skb_recv_datagram that does return this and made
skb_recv_datagram a wrapper around it.
The plan is to eventually replace all uses of skb_recv_datagram with
this new function at which time it can be renamed its proper name.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/skbuff.h | 3 +++
net/core/datagram.c | 41 ++++++++++++++++++++++++++---------------
net/ipv4/udp.c | 7 +++++--
net/ipv6/udp.c | 7 +++++--
4 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -291,6 +291,7 @@ struct sk_buff {
__u8 pkt_type:3,
fclone:2,
ipvs_property:1,
+ peeked:1,
nf_trace:1;
__be16 protocol;
@@ -1541,6 +1542,8 @@ static inline int pskb_trim_rcsum(struct
skb = skb->prev)
+extern struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
+ int *peeked, int *err);
extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
int noblock, int *err);
extern unsigned int datagram_poll(struct file *file, struct socket *sock,
diff --git a/net/core/datagram.c b/net/core/datagram.c
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -115,10 +115,10 @@ out_noerr:
}
/**
- * skb_recv_datagram - Receive a datagram skbuff
+ * __skb_recv_datagram - Receive a datagram skbuff
* @sk: socket
* @flags: MSG_ flags
- * @noblock: blocking operation?
+ * @peeked: returns non-zero if this packet has been seen before
* @err: error code returned
*
* Get a datagram skbuff, understands the peeking, nonblocking wakeups
@@ -143,8 +143,8 @@ out_noerr:
* quite explicitly by POSIX 1003.1g, don't change them without having
* the standard around please.
*/
-struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
- int noblock, int *err)
+struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
+ int *peeked, int *err)
{
struct sk_buff *skb;
long timeo;
@@ -156,7 +156,7 @@ struct sk_buff *skb_recv_datagram(struct
if (error)
goto no_packet;
- timeo = sock_rcvtimeo(sk, noblock);
+ timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
do {
/* Again only user level code calls this function, so nothing
@@ -165,18 +165,19 @@ struct sk_buff *skb_recv_datagram(struct
* Look at current nfs client by the way...
* However, this function was corrent in any case. 8)
*/
- if (flags & MSG_PEEK) {
- unsigned long cpu_flags;
+ unsigned long cpu_flags;
- spin_lock_irqsave(&sk->sk_receive_queue.lock,
- cpu_flags);
- skb = skb_peek(&sk->sk_receive_queue);
- if (skb)
+ spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
+ skb = skb_peek(&sk->sk_receive_queue);
+ if (skb) {
+ *peeked = skb->peeked;
+ if (flags & MSG_PEEK) {
+ skb->peeked = 1;
atomic_inc(&skb->users);
- spin_unlock_irqrestore(&sk->sk_receive_queue.lock,
- cpu_flags);
- } else
- skb = skb_dequeue(&sk->sk_receive_queue);
+ } else
+ __skb_unlink(skb, &sk->sk_receive_queue);
+ }
+ spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
if (skb)
return skb;
@@ -194,6 +195,16 @@ no_packet:
*err = error;
return NULL;
}
+EXPORT_SYMBOL(__skb_recv_datagram);
+
+struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
+ int noblock, int *err)
+{
+ int peeked;
+
+ return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
+ &peeked, err);
+}
void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
{
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -827,6 +827,7 @@ int udp_recvmsg(struct kiocb *iocb, stru
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb;
unsigned int ulen, copied;
+ int peeked;
int err;
int is_udplite = IS_UDPLITE(sk);
@@ -840,7 +841,8 @@ int udp_recvmsg(struct kiocb *iocb, stru
return ip_recv_error(sk, msg, len);
try_again:
- skb = skb_recv_datagram(sk, flags, noblock, &err);
+ skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
+ &peeked, &err);
if (!skb)
goto out;
@@ -875,7 +877,8 @@ try_again:
if (err)
goto out_free;
- UDP_INC_STATS_USER(UDP_MIB_INDATAGRAMS, is_udplite);
+ if (!peeked)
+ UDP_INC_STATS_USER(UDP_MIB_INDATAGRAMS, is_udplite);
sock_recv_timestamp(msg, sk, skb);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -121,6 +121,7 @@ int udpv6_recvmsg(struct kiocb *iocb, st
struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb;
unsigned int ulen, copied;
+ int peeked;
int err;
int is_udplite = IS_UDPLITE(sk);
@@ -131,7 +132,8 @@ int udpv6_recvmsg(struct kiocb *iocb, st
return ipv6_recv_error(sk, msg, len);
try_again:
- skb = skb_recv_datagram(sk, flags, noblock, &err);
+ skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
+ &peeked, &err);
if (!skb)
goto out;
@@ -164,7 +166,8 @@ try_again:
if (err)
goto out_free;
- UDP6_INC_STATS_USER(UDP_MIB_INDATAGRAMS, is_udplite);
+ if (!peeked)
+ UDP6_INC_STATS_USER(UDP_MIB_INDATAGRAMS, is_udplite);
sock_recv_timestamp(msg, sk, skb);
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-04 13:03 ` [PATCH 3/3] [UDP]: Only increment counter on first peek/recv Herbert Xu
@ 2007-12-05 1:02 ` Herbert Xu
2007-12-05 1:42 ` Wang Chen
2 siblings, 0 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 1:02 UTC (permalink / raw)
To: David S. Miller, netdev
On Wed, Dec 05, 2007 at 12:01:09AM +1100, Herbert Xu wrote:
>
> [UDP]: Restore missing inDatagrams increments
Oops, I got the mode wrong for the SNMP calls.
[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 <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/include/net/udp.h b/include/net/udp.h
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -139,6 +139,10 @@ extern int udp_lib_setsockopt(struct so
int (*push_pending_frames)(struct sock *));
DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
+
+/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
+DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
+
/*
* SNMP statistics for UDP and UDP-Lite
*/
diff --git a/include/net/udplite.h b/include/net/udplite.h
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -13,9 +13,6 @@
extern struct proto udplite_prot;
extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
-/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
-DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
-
/*
* Checksum computation is all in software, hence simpler getfrag.
*/
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -110,6 +110,7 @@
*/
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
+EXPORT_SYMBOL(udp_statistics);
struct hlist_head udp_hash[UDP_HTABLE_SIZE];
DEFINE_RWLOCK(udp_hash_lock);
@@ -969,8 +970,11 @@ int udp_queue_rcv_skb(struct sock * sk,
int ret;
ret = (*up->encap_rcv)(sk, skb);
- if (ret <= 0)
+ if (ret <= 0) {
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS,
+ is_udplite);
return -ret;
+ }
}
/* FALLTHROUGH -- it's a UDP Packet */
diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
--- a/net/rxrpc/ar-input.c
+++ b/net/rxrpc/ar-input.c
@@ -20,6 +20,7 @@
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <net/ip.h>
+#include <net/udp.h>
#include "ar-internal.h"
unsigned long rxrpc_ack_timeout = 1;
@@ -707,10 +708,13 @@ void rxrpc_data_ready(struct sock *sk, i
if (skb_checksum_complete(skb)) {
rxrpc_free_skb(skb);
rxrpc_put_local(local);
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS, 0);
_leave(" [CSUM failed]");
return;
}
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, 0);
+
/* the socket buffer we have is owned by UDP, with UDP's data all over
* it, but we really want our own */
skb_orphan(skb);
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -838,8 +838,12 @@ static void xs_udp_data_ready(struct soc
copied = repsize;
/* Suck it into the iovec, verify checksum if not done by hw. */
- if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
+ if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS, 0);
goto out_unlock;
+ }
+
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, 0);
/* Something worked... */
dst_confirm(skb->dst);
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-04 13:03 ` [PATCH 3/3] [UDP]: Only increment counter on first peek/recv Herbert Xu
2007-12-05 1:02 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
@ 2007-12-05 1:42 ` Wang Chen
2007-12-05 2:15 ` Herbert Xu
2 siblings, 1 reply; 21+ messages in thread
From: Wang Chen @ 2007-12-05 1:42 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
Herbert Xu said the following on 2007-12-4 21:01:
> Hi Dave:
>
> You were right about the SUNRPC stuff being missing after all. I'd
> only looked in svcsock.c and missed the call in xprtsock.c.
>
> [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.
>
I apologize for my miss in previous patch.
Herbert, don't you think the udp6inDatagrams should be counted too
in xprtsock?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 1:42 ` Wang Chen
@ 2007-12-05 2:15 ` Herbert Xu
2007-12-05 8:39 ` Wang Chen
` (2 more replies)
0 siblings, 3 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 2:15 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, netdev
On Wed, Dec 05, 2007 at 09:42:45AM +0800, Wang Chen wrote:
>
> I apologize for my miss in previous patch.
>
> Herbert, don't you think the udp6inDatagrams should be counted too
> in xprtsock?
Good point. Here's a better version.
[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 <herbert@gondor.apana.org.au>
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e90f962..a84f3f6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -164,15 +164,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
_DEVINC(icmpv6msg, _USER, idev, field)
-DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
-DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
-#define UDP6_INC_STATS_BH(field, is_udplite) do { \
- if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
- else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
-#define UDP6_INC_STATS_USER(field, is_udplite) do { \
- if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
- else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
-
struct ip6_ra_chain
{
struct ip6_ra_chain *next;
diff --git a/include/net/udp.h b/include/net/udp.h
index 98755eb..87170bb 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -139,6 +139,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
int (*push_pending_frames)(struct sock *));
DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
+DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
+
+/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
+DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
+DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
+
/*
* SNMP statistics for UDP and UDP-Lite
*/
@@ -149,6 +155,21 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
+#define UDP6_INC_STATS_BH(field, is_udplite) do { \
+ if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
+ else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
+#define UDP6_INC_STATS_USER(field, is_udplite) do { \
+ if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
+ else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
+
+#define UDPX_INC_STATS_BH(sk, field) \
+ do { \
+ if ((sk)->sk_family == AF_INET) \
+ UDP_INC_STATS_BH(field, 0); \
+ else \
+ UDP6_INC_STATS_BH(field, 0); \
+ } while (0);
+
/* /proc */
struct udp_seq_afinfo {
struct module *owner;
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 635b0ea..b76b2e3 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -13,9 +13,6 @@
extern struct proto udplite_prot;
extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
-/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
-DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
-
/*
* Checksum computation is all in software, hence simpler getfrag.
*/
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f50de5d..78cfcb4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -110,6 +110,7 @@
*/
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
+EXPORT_SYMBOL(udp_statistics);
struct hlist_head udp_hash[UDP_HTABLE_SIZE];
DEFINE_RWLOCK(udp_hash_lock);
@@ -969,8 +970,11 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
int ret;
ret = (*up->encap_rcv)(sk, skb);
- if (ret <= 0)
+ if (ret <= 0) {
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS,
+ is_udplite);
return -ret;
+ }
}
/* FALLTHROUGH -- it's a UDP Packet */
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 8631ed7..9fc2428 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -27,6 +27,7 @@
#include <net/ip.h>
#include <net/sock.h>
#include <net/tcp.h>
+#include <net/udp.h>
#include <net/transp_v6.h>
#include <net/ipv6.h>
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 87bccec..36bdcd2 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -34,6 +34,7 @@
#include <linux/ipv6.h>
#include <linux/icmpv6.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <linux/skbuff.h>
#include <asm/uaccess.h>
@@ -51,6 +52,7 @@
#include "udp_impl.h"
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
+EXPORT_SYMBOL(udp_stats_in6);
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
{
diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
index 91b5bbb..bc31ba5 100644
--- a/net/rxrpc/ar-input.c
+++ b/net/rxrpc/ar-input.c
@@ -20,6 +20,7 @@
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <net/ip.h>
+#include <net/udp.h>
#include "ar-internal.h"
unsigned long rxrpc_ack_timeout = 1;
@@ -707,10 +708,13 @@ void rxrpc_data_ready(struct sock *sk, int count)
if (skb_checksum_complete(skb)) {
rxrpc_free_skb(skb);
rxrpc_put_local(local);
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS, 0);
_leave(" [CSUM failed]");
return;
}
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, 0);
+
/* the socket buffer we have is owned by UDP, with UDP's data all over
* it, but we really want our own */
skb_orphan(skb);
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 2f630a5..6fa52f4 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -838,8 +838,12 @@ static void xs_udp_data_ready(struct sock *sk, int len)
copied = repsize;
/* Suck it into the iovec, verify checksum if not done by hw. */
- if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
+ if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
+ UDPX_INC_STATS_BH(sk, UDP_MIB_INERRORS);
goto out_unlock;
+ }
+
+ UDPX_INC_STATS_BH(sk, UDP_MIB_INDATAGRAMS);
/* Something worked... */
dst_confirm(skb->dst);
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 2:15 ` Herbert Xu
@ 2007-12-05 8:39 ` Wang Chen
2007-12-05 9:02 ` Herbert Xu
2007-12-05 9:36 ` Eric Dumazet
2007-12-05 9:53 ` David Miller
2 siblings, 1 reply; 21+ messages in thread
From: Wang Chen @ 2007-12-05 8:39 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
Herbert Xu said the following on 2007-12-5 10:15:
> +#define UDPX_INC_STATS_BH(sk, field) \
> + do { \
> + if ((sk)->sk_family == AF_INET) \
> + UDP_INC_STATS_BH(field, 0); \
> + else \
> + UDP6_INC_STATS_BH(field, 0); \
> + } while (0);
> +
Because there are lot of address families, not only AF_INET
and AF_INET6.
How about?
---
switch (sk->sk_family) {
case AF_INET:
...
case AF_INET6:
...
default:
}
--
WCN
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 8:39 ` Wang Chen
@ 2007-12-05 9:02 ` Herbert Xu
2007-12-05 9:04 ` Wang Chen
0 siblings, 1 reply; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 9:02 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, netdev
On Wed, Dec 05, 2007 at 04:39:48PM +0800, Wang Chen wrote:
> Herbert Xu said the following on 2007-12-5 10:15:
> > +#define UDPX_INC_STATS_BH(sk, field) \
> > + do { \
> > + if ((sk)->sk_family == AF_INET) \
> > + UDP_INC_STATS_BH(field, 0); \
> > + else \
> > + UDP6_INC_STATS_BH(field, 0); \
> > + } while (0);
> > +
>
> Because there are lot of address families, not only AF_INET
> and AF_INET6.
There may be a lot of families but only two run UDP, or rather, only
two are supported by sunrpc :)
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:02 ` Herbert Xu
@ 2007-12-05 9:04 ` Wang Chen
2007-12-05 9:10 ` Herbert Xu
0 siblings, 1 reply; 21+ messages in thread
From: Wang Chen @ 2007-12-05 9:04 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
Herbert Xu said the following on 2007-12-5 17:02:
> On Wed, Dec 05, 2007 at 04:39:48PM +0800, Wang Chen wrote:
>> Herbert Xu said the following on 2007-12-5 10:15:
>>> +#define UDPX_INC_STATS_BH(sk, field) \
>>> + do { \
>>> + if ((sk)->sk_family == AF_INET) \
>>> + UDP_INC_STATS_BH(field, 0); \
>>> + else \
>>> + UDP6_INC_STATS_BH(field, 0); \
>>> + } while (0);
>>> +
>> Because there are lot of address families, not only AF_INET
>> and AF_INET6.
>
> There may be a lot of families but only two run UDP, or rather, only
> two are supported by sunrpc :)
>
Yes, now, sunrpc only supports INET and INET6.
But UDPX_INC_STATS_BH is defined in udp.h, in case others use it :)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:04 ` Wang Chen
@ 2007-12-05 9:10 ` Herbert Xu
2007-12-05 9:20 ` Wang Chen
0 siblings, 1 reply; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 9:10 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, netdev
On Wed, Dec 05, 2007 at 05:04:48PM +0800, Wang Chen wrote:
>
> Yes, now, sunrpc only supports INET and INET6.
> But UDPX_INC_STATS_BH is defined in udp.h, in case others use it :)
Which other family would that be :)
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:10 ` Herbert Xu
@ 2007-12-05 9:20 ` Wang Chen
2007-12-05 9:26 ` Herbert Xu
0 siblings, 1 reply; 21+ messages in thread
From: Wang Chen @ 2007-12-05 9:20 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
Herbert Xu said the following on 2007-12-5 17:10:
> On Wed, Dec 05, 2007 at 05:04:48PM +0800, Wang Chen wrote:
>> Yes, now, sunrpc only supports INET and INET6.
>> But UDPX_INC_STATS_BH is defined in udp.h, in case others use it :)
>
> Which other family would that be :)
>
Maybe AF_UNSPEC? It's joke:)
I just more like switch to avoid false positive problem.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:20 ` Wang Chen
@ 2007-12-05 9:26 ` Herbert Xu
0 siblings, 0 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 9:26 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, netdev
On Wed, Dec 05, 2007 at 05:20:25PM +0800, Wang Chen wrote:
>
> Maybe AF_UNSPEC? It's joke:)
> I just more like switch to avoid false positive problem.
We should check for things like that when a socket is constructed
and not when it's used.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 2:15 ` Herbert Xu
2007-12-05 8:39 ` Wang Chen
@ 2007-12-05 9:36 ` Eric Dumazet
2007-12-05 9:51 ` Herbert Xu
2007-12-05 9:53 ` David Miller
2 siblings, 1 reply; 21+ messages in thread
From: Eric Dumazet @ 2007-12-05 9:36 UTC (permalink / raw)
To: Herbert Xu; +Cc: Wang Chen, David S. Miller, netdev
Herbert Xu a écrit :
> On Wed, Dec 05, 2007 at 09:42:45AM +0800, Wang Chen wrote:
>> I apologize for my miss in previous patch.
>>
>> Herbert, don't you think the udp6inDatagrams should be counted too
>> in xprtsock?
>
> Good point. Here's a better version.
>
> [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 <herbert@gondor.apana.org.au>
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index e90f962..a84f3f6 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -164,15 +164,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
> #define ICMP6MSGIN_INC_STATS_USER(idev, field) \
> _DEVINC(icmpv6msg, _USER, idev, field)
>
> -DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
> -DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
> -#define UDP6_INC_STATS_BH(field, is_udplite) do { \
> - if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
> - else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
> -#define UDP6_INC_STATS_USER(field, is_udplite) do { \
> - if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
> - else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
> -
> struct ip6_ra_chain
> {
> struct ip6_ra_chain *next;
> diff --git a/include/net/udp.h b/include/net/udp.h
> index 98755eb..87170bb 100644
> --- a/include/net/udp.h
> +++ b/include/net/udp.h
> @@ -139,6 +139,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
> int (*push_pending_frames)(struct sock *));
>
> DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
> +DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
> +
> +/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
> +DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
> +DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
> +
> /*
> * SNMP statistics for UDP and UDP-Lite
> */
> @@ -149,6 +155,21 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
> if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
> else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
>
> +#define UDP6_INC_STATS_BH(field, is_udplite) do { \
> + if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
> + else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
> +#define UDP6_INC_STATS_USER(field, is_udplite) do { \
> + if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
> + else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
> +
> +#define UDPX_INC_STATS_BH(sk, field) \
> + do { \
> + if ((sk)->sk_family == AF_INET) \
> + UDP_INC_STATS_BH(field, 0); \
> + else \
> + UDP6_INC_STATS_BH(field, 0); \
> + } while (0);
> +
Hum, what happens if I have in my .config file :
CONFIG_IPV6=n
I suggest something like
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
# define UDPX_INC_STATS_BH(sk, field) \
do { \
if ((sk)->sk_family == AF_INET) \
UDP_INC_STATS_BH(field, 0); \
else \
UDP6_INC_STATS_BH(field, 0); \
} while (0);
#else
# define UDPX_INC_STATS_BH(sk, field) \
UDP_INC_STATS_BH(field, 0);
#endif
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:36 ` Eric Dumazet
@ 2007-12-05 9:51 ` Herbert Xu
2007-12-05 10:02 ` David Miller
0 siblings, 1 reply; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 9:51 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Wang Chen, David S. Miller, netdev
On Wed, Dec 05, 2007 at 10:36:40AM +0100, Eric Dumazet wrote:
>
> Hum, what happens if I have in my .config file :
>
> CONFIG_IPV6=n
Thanks. Obviously I shouldn't have touched this stuff at all :)
Let's hope this is the last problem.
[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 <herbert@gondor.apana.org.au>
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e90f962..a84f3f6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -164,15 +164,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
_DEVINC(icmpv6msg, _USER, idev, field)
-DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
-DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
-#define UDP6_INC_STATS_BH(field, is_udplite) do { \
- if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
- else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
-#define UDP6_INC_STATS_USER(field, is_udplite) do { \
- if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
- else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
-
struct ip6_ra_chain
{
struct ip6_ra_chain *next;
diff --git a/include/net/udp.h b/include/net/udp.h
index 98755eb..98cb09c 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -139,6 +139,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
int (*push_pending_frames)(struct sock *));
DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
+DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
+
+/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
+DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
+DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
+
/*
* SNMP statistics for UDP and UDP-Lite
*/
@@ -149,6 +155,25 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
+#define UDP6_INC_STATS_BH(field, is_udplite) do { \
+ if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
+ else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
+#define UDP6_INC_STATS_USER(field, is_udplite) do { \
+ if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
+ else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#define UDPX_INC_STATS_BH(sk, field) \
+ do { \
+ if ((sk)->sk_family == AF_INET) \
+ UDP_INC_STATS_BH(field, 0); \
+ else \
+ UDP6_INC_STATS_BH(field, 0); \
+ } while (0);
+#else
+#define UDPX_INC_STATS_BH(sk, field) UDP_INC_STATS_BH(field, 0)
+#endif
+
/* /proc */
struct udp_seq_afinfo {
struct module *owner;
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 635b0ea..b76b2e3 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -13,9 +13,6 @@
extern struct proto udplite_prot;
extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
-/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
-DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
-
/*
* Checksum computation is all in software, hence simpler getfrag.
*/
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f50de5d..78cfcb4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -110,6 +110,7 @@
*/
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
+EXPORT_SYMBOL(udp_statistics);
struct hlist_head udp_hash[UDP_HTABLE_SIZE];
DEFINE_RWLOCK(udp_hash_lock);
@@ -969,8 +970,11 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
int ret;
ret = (*up->encap_rcv)(sk, skb);
- if (ret <= 0)
+ if (ret <= 0) {
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS,
+ is_udplite);
return -ret;
+ }
}
/* FALLTHROUGH -- it's a UDP Packet */
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 8631ed7..9fc2428 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -27,6 +27,7 @@
#include <net/ip.h>
#include <net/sock.h>
#include <net/tcp.h>
+#include <net/udp.h>
#include <net/transp_v6.h>
#include <net/ipv6.h>
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 87bccec..36bdcd2 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -34,6 +34,7 @@
#include <linux/ipv6.h>
#include <linux/icmpv6.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <linux/skbuff.h>
#include <asm/uaccess.h>
@@ -51,6 +52,7 @@
#include "udp_impl.h"
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
+EXPORT_SYMBOL(udp_stats_in6);
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
{
diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
index 91b5bbb..f446d9b 100644
--- a/net/rxrpc/ar-input.c
+++ b/net/rxrpc/ar-input.c
@@ -20,6 +20,7 @@
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <net/ip.h>
+#include <net/udp.h>
#include "ar-internal.h"
unsigned long rxrpc_ack_timeout = 1;
@@ -707,10 +708,13 @@ void rxrpc_data_ready(struct sock *sk, int count)
if (skb_checksum_complete(skb)) {
rxrpc_free_skb(skb);
rxrpc_put_local(local);
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS, 0);
_leave(" [CSUM failed]");
return;
}
+ UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, 0);
+
/* the socket buffer we have is owned by UDP, with UDP's data all over
* it, but we really want our own */
skb_orphan(skb);
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 2f630a5..6fa52f4 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -838,8 +838,12 @@ static void xs_udp_data_ready(struct sock *sk, int len)
copied = repsize;
/* Suck it into the iovec, verify checksum if not done by hw. */
- if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
+ if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb)) {
+ UDPX_INC_STATS_BH(sk, UDP_MIB_INERRORS);
goto out_unlock;
+ }
+
+ UDPX_INC_STATS_BH(sk, UDP_MIB_INDATAGRAMS);
/* Something worked... */
dst_confirm(skb->dst);
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking
2007-12-04 12:58 [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking Herbert Xu
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
@ 2007-12-05 9:52 ` David Miller
1 sibling, 0 replies; 21+ messages in thread
From: David Miller @ 2007-12-05 9:52 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Tue, 4 Dec 2007 23:58:44 +1100
> [UDP]: Avoid repeated counting of checksum errors due to peeking
>
> Currently it is possible for two processes to peek on the same socket
> and end up incrementing the error counter twice for the same packet.
>
> This patch fixes it by making skb_kill_datagram return whether it
> succeeded in unlinking the packet and only incrementing the counter
> if it did.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied, thanks Herbert.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 2:15 ` Herbert Xu
2007-12-05 8:39 ` Wang Chen
2007-12-05 9:36 ` Eric Dumazet
@ 2007-12-05 9:53 ` David Miller
2007-12-05 9:54 ` Herbert Xu
2 siblings, 1 reply; 21+ messages in thread
From: David Miller @ 2007-12-05 9:53 UTC (permalink / raw)
To: herbert; +Cc: wangchen, netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 5 Dec 2007 13:15:59 +1100
> On Wed, Dec 05, 2007 at 09:42:45AM +0800, Wang Chen wrote:
> >
> > I apologize for my miss in previous patch.
> >
> > Herbert, don't you think the udp6inDatagrams should be counted too
> > in xprtsock?
>
> Good point. Here's a better version.
>
> [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 <herbert@gondor.apana.org.au>
Applied.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 3/3] [UDP]: Only increment counter on first peek/recv
2007-12-04 13:03 ` [PATCH 3/3] [UDP]: Only increment counter on first peek/recv Herbert Xu
@ 2007-12-05 9:54 ` David Miller
0 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2007-12-05 9:54 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 5 Dec 2007 00:03:10 +1100
> [UDP]: Only increment counter on first peek/recv
>
> The previous move of the the UDP inDatagrams counter caused each
> peek of the same packet to be counted separately. This may be
> undesirable.
>
> This patch fixes this by adding a bit to sk_buff to record whether
> this packet has already been seen through skb_recv_datagram. We
> then only increment the counter when the packet is seen for the
> first time.
>
> The only dodgy part is the fact that skb_recv_datagram doesn't have
> a good way of returning this new bit of information. So I've added
> a new function __skb_recv_datagram that does return this and made
> skb_recv_datagram a wrapper around it.
>
> The plan is to eventually replace all uses of skb_recv_datagram with
> this new function at which time it can be renamed its proper name.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied, thanks for fixing all of this Herbert.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:53 ` David Miller
@ 2007-12-05 9:54 ` Herbert Xu
0 siblings, 0 replies; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 9:54 UTC (permalink / raw)
To: David Miller; +Cc: wangchen, netdev
On Wed, Dec 05, 2007 at 01:53:01AM -0800, David Miller wrote:
>
> > [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 <herbert@gondor.apana.org.au>
>
> Applied.
Sorry, Eric spotted a build problem in my patch. So you'll need to
replace this with the fixed version that I sent literally minutes ago :)
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 9:51 ` Herbert Xu
@ 2007-12-05 10:02 ` David Miller
2007-12-05 10:04 ` Herbert Xu
0 siblings, 1 reply; 21+ messages in thread
From: David Miller @ 2007-12-05 10:02 UTC (permalink / raw)
To: herbert; +Cc: dada1, wangchen, netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 5 Dec 2007 20:51:59 +1100
> On Wed, Dec 05, 2007 at 10:36:40AM +0100, Eric Dumazet wrote:
> >
> > Hum, what happens if I have in my .config file :
> >
> > CONFIG_IPV6=n
>
> Thanks. Obviously I shouldn't have touched this stuff at all :)
> Let's hope this is the last problem.
>
> [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 <herbert@gondor.apana.org.au>
Herbert, I applied the buggered patch and pushed it out
already, can you send me this fix relative?
I'll combine them on my next rebase, thanks.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 10:02 ` David Miller
@ 2007-12-05 10:04 ` Herbert Xu
2007-12-05 10:08 ` David Miller
0 siblings, 1 reply; 21+ messages in thread
From: Herbert Xu @ 2007-12-05 10:04 UTC (permalink / raw)
To: David Miller; +Cc: dada1, wangchen, netdev
On Wed, Dec 05, 2007 at 02:02:48AM -0800, David Miller wrote:
>
> Herbert, I applied the buggered patch and pushed it out
> already, can you send me this fix relative?
>
> I'll combine them on my next rebase, thanks.
Sure, here it is.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/include/net/udp.h b/include/net/udp.h
index 87170bb..98cb09c 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -162,6 +162,7 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#define UDPX_INC_STATS_BH(sk, field) \
do { \
if ((sk)->sk_family == AF_INET) \
@@ -169,6 +170,9 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
else \
UDP6_INC_STATS_BH(field, 0); \
} while (0);
+#else
+#define UDPX_INC_STATS_BH(sk, field) UDP_INC_STATS_BH(field, 0)
+#endif
/* /proc */
struct udp_seq_afinfo {
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/3] [UDP]: Restore missing inDatagrams increments
2007-12-05 10:04 ` Herbert Xu
@ 2007-12-05 10:08 ` David Miller
0 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2007-12-05 10:08 UTC (permalink / raw)
To: herbert; +Cc: dada1, wangchen, netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 5 Dec 2007 21:04:52 +1100
> On Wed, Dec 05, 2007 at 02:02:48AM -0800, David Miller wrote:
> >
> > Herbert, I applied the buggered patch and pushed it out
> > already, can you send me this fix relative?
> >
> > I'll combine them on my next rebase, thanks.
>
> Sure, here it is.
Applied, thanks a lot.
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2007-12-05 10:08 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-04 12:58 [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking Herbert Xu
2007-12-04 13:01 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-04 13:03 ` [PATCH 3/3] [UDP]: Only increment counter on first peek/recv Herbert Xu
2007-12-05 9:54 ` David Miller
2007-12-05 1:02 ` [PATCH 2/3] [UDP]: Restore missing inDatagrams increments Herbert Xu
2007-12-05 1:42 ` Wang Chen
2007-12-05 2:15 ` Herbert Xu
2007-12-05 8:39 ` Wang Chen
2007-12-05 9:02 ` Herbert Xu
2007-12-05 9:04 ` Wang Chen
2007-12-05 9:10 ` Herbert Xu
2007-12-05 9:20 ` Wang Chen
2007-12-05 9:26 ` Herbert Xu
2007-12-05 9:36 ` Eric Dumazet
2007-12-05 9:51 ` Herbert Xu
2007-12-05 10:02 ` David Miller
2007-12-05 10:04 ` Herbert Xu
2007-12-05 10:08 ` David Miller
2007-12-05 9:53 ` David Miller
2007-12-05 9:54 ` Herbert Xu
2007-12-05 9:52 ` [PATCH 1/3] [UDP]: Avoid repeated counting of checksum errors due to peeking David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).