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.

Merge branch 'tcp-rework-tcp_v-4-6-_send_check'

Eric Dumazet says:

====================
tcp: rework tcp_v{4,6}_send_check()

tcp_v{4,6}_send_check() are only called from __tcp_transmit_skb()

They currently are in different files (tcp_ipv4.c and tcp_ipv6.c)
thus out of line.

This series move them close to their caller so that compiler
can inline them.

For all patches in the series:

$ scripts/bloat-o-meter -t vmlinux.0 vmlinux.3
add/remove: 0/2 grow/shrink: 1/3 up/down: 102/-178 (-76)
Function old new delta
__tcp_transmit_skb 3321 3423 +102
tcp_v4_send_check 136 132 -4
__tcp_v4_send_check 130 121 -9
mptcp_subflow_init 777 763 -14
__pfx_tcp_v6_send_check 16 - -16
tcp_v6_send_check 135 - -135
Total: Before=25143100, After=25143024, chg -0.00%
====================

Link: https://patch.msgid.link/20260223100729.3761597-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+33 -39
+1 -2
include/net/inet_connection_sock.h
··· 34 34 */ 35 35 struct inet_connection_sock_af_ops { 36 36 int (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl); 37 - void (*send_check)(struct sock *sk, struct sk_buff *skb); 37 + u16 net_header_len; 38 38 int (*rebuild_header)(struct sock *sk); 39 39 void (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb); 40 40 int (*conn_request)(struct sock *sk, struct sk_buff *skb); ··· 43 43 struct dst_entry *dst, 44 44 struct request_sock *req_unhash, 45 45 bool *own_req); 46 - u16 net_header_len; 47 46 int (*setsockopt)(struct sock *sk, int level, int optname, 48 47 sockptr_t optval, unsigned int optlen); 49 48 int (*getsockopt)(struct sock *sk, int level, int optname,
+9 -3
include/net/tcp.h
··· 531 531 * TCP v4 functions exported for the inet6 API 532 532 */ 533 533 534 - void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb); 535 534 void tcp_v4_mtu_reduced(struct sock *sk); 536 535 void tcp_req_err(struct sock *sk, u32 seq, bool abort); 537 536 void tcp_ld_RTO_revert(struct sock *sk, u32 seq); ··· 1131 1132 1132 1133 extern const struct inet_connection_sock_af_ops ipv6_specific; 1133 1134 1134 - INDIRECT_CALLABLE_DECLARE(void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)); 1135 1135 INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *skb)); 1136 1136 void tcp_v6_early_demux(struct sk_buff *skb); 1137 1137 ··· 2380 2382 static inline void tcp_gro_complete(struct sk_buff *skb) { } 2381 2383 #endif 2382 2384 2383 - void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr); 2385 + static inline void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, 2386 + __be32 daddr) 2387 + { 2388 + struct tcphdr *th = tcp_hdr(skb); 2389 + 2390 + th->check = ~tcp_v4_check(skb->len, saddr, daddr, 0); 2391 + skb->csum_start = skb_transport_header(skb) - skb->head; 2392 + skb->csum_offset = offsetof(struct tcphdr, check); 2393 + } 2384 2394 2385 2395 static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp) 2386 2396 {
-19
net/ipv4/tcp_ipv4.c
··· 661 661 return 0; 662 662 } 663 663 664 - void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr) 665 - { 666 - struct tcphdr *th = tcp_hdr(skb); 667 - 668 - th->check = ~tcp_v4_check(skb->len, saddr, daddr, 0); 669 - skb->csum_start = skb_transport_header(skb) - skb->head; 670 - skb->csum_offset = offsetof(struct tcphdr, check); 671 - } 672 - 673 - /* This routine computes an IPv4 TCP checksum. */ 674 - void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb) 675 - { 676 - const struct inet_sock *inet = inet_sk(sk); 677 - 678 - __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr); 679 - } 680 - EXPORT_IPV6_MOD(tcp_v4_send_check); 681 - 682 664 #define REPLY_OPTIONS_LEN (MAX_TCP_OPTION_SPACE / sizeof(__be32)) 683 665 684 666 static bool tcp_v4_ao_sign_reset(const struct sock *sk, struct sk_buff *skb, ··· 2405 2423 2406 2424 const struct inet_connection_sock_af_ops ipv4_specific = { 2407 2425 .queue_xmit = ip_queue_xmit, 2408 - .send_check = tcp_v4_send_check, 2409 2426 .rebuild_header = inet_sk_rebuild_header, 2410 2427 .sk_rx_dst_set = inet_sk_rx_dst_set, 2411 2428 .conn_request = tcp_v4_conn_request,
+23 -4
net/ipv4/tcp_output.c
··· 1496 1496 1497 1497 INDIRECT_CALLABLE_DECLARE(int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)); 1498 1498 INDIRECT_CALLABLE_DECLARE(int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)); 1499 - INDIRECT_CALLABLE_DECLARE(void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)); 1499 + 1500 + /* This routine computes an IPv4 TCP checksum. */ 1501 + static void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb) 1502 + { 1503 + const struct inet_sock *inet = inet_sk(sk); 1504 + 1505 + __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr); 1506 + } 1507 + 1508 + #if IS_ENABLED(CONFIG_IPV6) 1509 + #include <net/ip6_checksum.h> 1510 + 1511 + static void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb) 1512 + { 1513 + __tcp_v6_send_check(skb, &sk->sk_v6_rcv_saddr, &sk->sk_v6_daddr); 1514 + } 1515 + #endif 1500 1516 1501 1517 /* This routine actually transmits TCP packets queued in by 1502 1518 * tcp_do_sendmsg(). This is used by both the initial ··· 1675 1659 /* BPF prog is the last one writing header option */ 1676 1660 bpf_skops_write_hdr_opt(sk, skb, NULL, NULL, 0, &opts); 1677 1661 1678 - INDIRECT_CALL_INET(icsk->icsk_af_ops->send_check, 1679 - tcp_v6_send_check, tcp_v4_send_check, 1680 - sk, skb); 1662 + #if IS_ENABLED(CONFIG_IPV6) 1663 + if (likely(icsk->icsk_af_ops->net_header_len == sizeof(struct ipv6hdr))) 1664 + tcp_v6_send_check(sk, skb); 1665 + else 1666 + #endif 1667 + tcp_v4_send_check(sk, skb); 1681 1668 1682 1669 if (likely(tcb->tcp_flags & TCPHDR_ACK)) 1683 1670 tcp_event_ack_sent(sk, rcv_nxt);
-7
net/ipv6/tcp_ipv6.c
··· 2015 2015 .twsk_obj_size = sizeof(struct tcp6_timewait_sock), 2016 2016 }; 2017 2017 2018 - INDIRECT_CALLABLE_SCOPE void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb) 2019 - { 2020 - __tcp_v6_send_check(skb, &sk->sk_v6_rcv_saddr, &sk->sk_v6_daddr); 2021 - } 2022 - 2023 2018 const struct inet_connection_sock_af_ops ipv6_specific = { 2024 2019 .queue_xmit = inet6_csk_xmit, 2025 - .send_check = tcp_v6_send_check, 2026 2020 .rebuild_header = inet6_sk_rebuild_header, 2027 2021 .sk_rx_dst_set = inet6_sk_rx_dst_set, 2028 2022 .conn_request = tcp_v6_conn_request, ··· 2048 2054 */ 2049 2055 static const struct inet_connection_sock_af_ops ipv6_mapped = { 2050 2056 .queue_xmit = ip_queue_xmit, 2051 - .send_check = tcp_v4_send_check, 2052 2057 .rebuild_header = inet_sk_rebuild_header, 2053 2058 .sk_rx_dst_set = inet_sk_rx_dst_set, 2054 2059 .conn_request = tcp_v6_conn_request,
-1
net/mptcp/subflow.c
··· 2190 2190 2191 2191 subflow_v6m_specific = subflow_v6_specific; 2192 2192 subflow_v6m_specific.queue_xmit = ipv4_specific.queue_xmit; 2193 - subflow_v6m_specific.send_check = ipv4_specific.send_check; 2194 2193 subflow_v6m_specific.net_header_len = ipv4_specific.net_header_len; 2195 2194 subflow_v6m_specific.mtu_reduced = ipv4_specific.mtu_reduced; 2196 2195 subflow_v6m_specific.rebuild_header = subflow_rebuild_header;
-3
net/tls/tls_device_fallback.c
··· 149 149 return rc; 150 150 } 151 151 152 - /* Can't use icsk->icsk_af_ops->send_check here because the ip addresses 153 - * might have been changed by NAT. 154 - */ 155 152 static void update_chksum(struct sk_buff *skb, int headln) 156 153 { 157 154 struct tcphdr *th = tcp_hdr(skb);