Skip to content

Commit 67a5178

Browse files
Paolo Abenidavem330
authored andcommitted
ipv6: udp: leverage scratch area helpers
The commit b65ac44 ("udp: try to avoid 2 cache miss on dequeue") leveraged the scratched area helpers for UDP v4 but I forgot to update accordingly the IPv6 code path. This change extends the scratch area usage to the IPv6 code, synching the two implementations and giving some performance benefit. IPv6 is again almost on the same level of IPv4, performance-wide. Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b26bbda commit 67a5178

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/ipv6/udp.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
362362
if (!skb)
363363
return err;
364364

365-
ulen = skb->len;
365+
ulen = udp_skb_len(skb);
366366
copied = len;
367367
if (copied > ulen - off)
368368
copied = ulen - off;
@@ -379,14 +379,18 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
379379

380380
if (copied < ulen || peeking ||
381381
(is_udplite && UDP_SKB_CB(skb)->partial_cov)) {
382-
checksum_valid = !udp_lib_checksum_complete(skb);
382+
checksum_valid = udp_skb_csum_unnecessary(skb) ||
383+
!__udp_lib_checksum_complete(skb);
383384
if (!checksum_valid)
384385
goto csum_copy_err;
385386
}
386387

387-
if (checksum_valid || skb_csum_unnecessary(skb))
388-
err = skb_copy_datagram_msg(skb, off, msg, copied);
389-
else {
388+
if (checksum_valid || udp_skb_csum_unnecessary(skb)) {
389+
if (udp_skb_is_linear(skb))
390+
err = copy_linear_skb(skb, copied, off, &msg->msg_iter);
391+
else
392+
err = skb_copy_datagram_msg(skb, off, msg, copied);
393+
} else {
390394
err = skb_copy_and_csum_datagram_msg(skb, off, msg);
391395
if (err == -EINVAL)
392396
goto csum_copy_err;

0 commit comments

Comments
 (0)