mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 02:01:18 -04:00
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
2550def53b
commit
f033335937
@@ -82,6 +82,4 @@ static inline __sum16 udp_v6_check(int len,
|
||||
void udp6_set_csum(bool nocheck, struct sk_buff *skb,
|
||||
const struct in6_addr *saddr,
|
||||
const struct in6_addr *daddr, int len);
|
||||
|
||||
int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto);
|
||||
#endif
|
||||
|
||||
@@ -62,53 +62,6 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
|
||||
EXPORT_SYMBOL(csum_ipv6_magic);
|
||||
#endif
|
||||
|
||||
int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
|
||||
{
|
||||
int err;
|
||||
|
||||
UDP_SKB_CB(skb)->partial_cov = 0;
|
||||
UDP_SKB_CB(skb)->cscov = skb->len;
|
||||
|
||||
if (proto == IPPROTO_UDPLITE) {
|
||||
err = udplite_checksum_init(skb, uh);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (UDP_SKB_CB(skb)->partial_cov) {
|
||||
skb->csum = ip6_compute_pseudo(skb, proto);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels)
|
||||
* we accept a checksum of zero here. When we find the socket
|
||||
* for the UDP packet we'll check if that socket allows zero checksum
|
||||
* for IPv6 (set by socket option).
|
||||
*
|
||||
* Note, we are only interested in != 0 or == 0, thus the
|
||||
* force to int.
|
||||
*/
|
||||
err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
|
||||
ip6_compute_pseudo);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
|
||||
/* If SW calculated the value, we know it's bad */
|
||||
if (skb->csum_complete_sw)
|
||||
return 1;
|
||||
|
||||
/* HW says the value is bad. Let's validate that.
|
||||
* skb->csum is no longer the full packet checksum,
|
||||
* so don't treat is as such.
|
||||
*/
|
||||
skb_checksum_complete_unset(skb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(udp6_csum_init);
|
||||
|
||||
/* Function to set UDP checksum for an IPv6 UDP packet. This is intended
|
||||
* for the simple case like when setting the checksum for a UDP tunnel.
|
||||
*/
|
||||
|
||||
@@ -1069,6 +1069,52 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
|
||||
{
|
||||
int err;
|
||||
|
||||
UDP_SKB_CB(skb)->partial_cov = 0;
|
||||
UDP_SKB_CB(skb)->cscov = skb->len;
|
||||
|
||||
if (proto == IPPROTO_UDPLITE) {
|
||||
err = udplite_checksum_init(skb, uh);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (UDP_SKB_CB(skb)->partial_cov) {
|
||||
skb->csum = ip6_compute_pseudo(skb, proto);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels)
|
||||
* we accept a checksum of zero here. When we find the socket
|
||||
* for the UDP packet we'll check if that socket allows zero checksum
|
||||
* for IPv6 (set by socket option).
|
||||
*
|
||||
* Note, we are only interested in != 0 or == 0, thus the
|
||||
* force to int.
|
||||
*/
|
||||
err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
|
||||
ip6_compute_pseudo);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
|
||||
/* If SW calculated the value, we know it's bad */
|
||||
if (skb->csum_complete_sw)
|
||||
return 1;
|
||||
|
||||
/* HW says the value is bad. Let's validate that.
|
||||
* skb->csum is no longer the full packet checksum,
|
||||
* so don't treat is as such.
|
||||
*/
|
||||
skb_checksum_complete_unset(skb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
|
||||
int proto)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user