Message ID | 1447349202.22599.30.camel@edumazet-glaptop2.roam.corp.google.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
Hello Eric 2015-11-12, 09:26:42 -0800, Eric Dumazet wrote: > Note that the following patch (and corresponding part for ipv6) might > also have solve the issue ? > > This would supposedly save some cycles when MSG_PEEK is used and user > provides short buffers. Your patch looks correct to me, feel free to submit it. Since some stable trees already include my patch, maybe it should be reverted there to keep all trees in sync and ease future backports? Thanks,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 24ec14f9825c..387acab1ab5c 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1272,6 +1272,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, int err; int is_udplite = IS_UDPLITE(sk); bool slow; + bool checksum_valid = false; if (flags & MSG_ERRQUEUE) return ip_recv_error(sk, msg, len, addr_len); @@ -1296,11 +1297,12 @@ try_again: */ if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { - if (udp_lib_checksum_complete(skb)) + checksum_valid = !udp_lib_checksum_complete(skb); + if (!checksum_valid) goto csum_copy_err; } - if (skb_csum_unnecessary(skb)) + if (checksum_valid || skb_csum_unnecessary(skb)) err = skb_copy_datagram_msg(skb, sizeof(struct udphdr), msg, copied); else {