Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

udp: move udp6_csum_init() back to net/ipv6/udp.c

This function has a single caller in net/ipv6/udp.c.

Move it there so that the compiler can decide to (auto)inline
it if he prefers to. IBT glue is removed anyway.

With clang, we can see it was able to inline it and also
inlined one other helper at the same time.

UDPLITE removal will also help.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 1/0 up/down: 840/-785 (55)
Function old new delta
__udp6_lib_rcv 1247 2087 +840
__pfx_udp6_csum_init 16 - -16
udp6_csum_init 769 - -769
Total: Before=25074399, After=25074454, chg +0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260223093445.3696368-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
f0333359 2550def5

+46 -49
-2
include/net/ip6_checksum.h
··· 82 82 void udp6_set_csum(bool nocheck, struct sk_buff *skb, 83 83 const struct in6_addr *saddr, 84 84 const struct in6_addr *daddr, int len); 85 - 86 - int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto); 87 85 #endif
-47
net/ipv6/ip6_checksum.c
··· 62 62 EXPORT_SYMBOL(csum_ipv6_magic); 63 63 #endif 64 64 65 - int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto) 66 - { 67 - int err; 68 - 69 - UDP_SKB_CB(skb)->partial_cov = 0; 70 - UDP_SKB_CB(skb)->cscov = skb->len; 71 - 72 - if (proto == IPPROTO_UDPLITE) { 73 - err = udplite_checksum_init(skb, uh); 74 - if (err) 75 - return err; 76 - 77 - if (UDP_SKB_CB(skb)->partial_cov) { 78 - skb->csum = ip6_compute_pseudo(skb, proto); 79 - return 0; 80 - } 81 - } 82 - 83 - /* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels) 84 - * we accept a checksum of zero here. When we find the socket 85 - * for the UDP packet we'll check if that socket allows zero checksum 86 - * for IPv6 (set by socket option). 87 - * 88 - * Note, we are only interested in != 0 or == 0, thus the 89 - * force to int. 90 - */ 91 - err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check, 92 - ip6_compute_pseudo); 93 - if (err) 94 - return err; 95 - 96 - if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) { 97 - /* If SW calculated the value, we know it's bad */ 98 - if (skb->csum_complete_sw) 99 - return 1; 100 - 101 - /* HW says the value is bad. Let's validate that. 102 - * skb->csum is no longer the full packet checksum, 103 - * so don't treat is as such. 104 - */ 105 - skb_checksum_complete_unset(skb); 106 - } 107 - 108 - return 0; 109 - } 110 - EXPORT_SYMBOL(udp6_csum_init); 111 - 112 65 /* Function to set UDP checksum for an IPv6 UDP packet. This is intended 113 66 * for the simple case like when setting the checksum for a UDP tunnel. 114 67 */
+46
net/ipv6/udp.c
··· 1069 1069 return 0; 1070 1070 } 1071 1071 1072 + static int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto) 1073 + { 1074 + int err; 1075 + 1076 + UDP_SKB_CB(skb)->partial_cov = 0; 1077 + UDP_SKB_CB(skb)->cscov = skb->len; 1078 + 1079 + if (proto == IPPROTO_UDPLITE) { 1080 + err = udplite_checksum_init(skb, uh); 1081 + if (err) 1082 + return err; 1083 + 1084 + if (UDP_SKB_CB(skb)->partial_cov) { 1085 + skb->csum = ip6_compute_pseudo(skb, proto); 1086 + return 0; 1087 + } 1088 + } 1089 + 1090 + /* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels) 1091 + * we accept a checksum of zero here. When we find the socket 1092 + * for the UDP packet we'll check if that socket allows zero checksum 1093 + * for IPv6 (set by socket option). 1094 + * 1095 + * Note, we are only interested in != 0 or == 0, thus the 1096 + * force to int. 1097 + */ 1098 + err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check, 1099 + ip6_compute_pseudo); 1100 + if (err) 1101 + return err; 1102 + 1103 + if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) { 1104 + /* If SW calculated the value, we know it's bad */ 1105 + if (skb->csum_complete_sw) 1106 + return 1; 1107 + 1108 + /* HW says the value is bad. Let's validate that. 1109 + * skb->csum is no longer the full packet checksum, 1110 + * so don't treat is as such. 1111 + */ 1112 + skb_checksum_complete_unset(skb); 1113 + } 1114 + 1115 + return 0; 1116 + } 1117 + 1072 1118 int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, 1073 1119 int proto) 1074 1120 {