[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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
1781f7f580
commit
a59322be07
@@ -827,6 +827,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
|
||||
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, struct sock *sk, struct msghdr *msg,
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user