* [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check()
@ 2026-02-23 10:07 Eric Dumazet
2026-02-23 10:07 ` [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check() Eric Dumazet
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Eric Dumazet @ 2026-02-23 10:07 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
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%
Eric Dumazet (3):
tcp: inline __tcp_v4_send_check()
tcp: move tcp_v6_send_check() to tcp_output.c
tcp: make tcp_v{4,6}_send_check() static
include/net/inet_connection_sock.h | 3 +--
include/net/tcp.h | 12 +++++++++---
net/ipv4/tcp_ipv4.c | 19 -------------------
net/ipv4/tcp_output.c | 27 +++++++++++++++++++++++----
net/ipv6/tcp_ipv6.c | 7 -------
net/mptcp/subflow.c | 1 -
net/tls/tls_device_fallback.c | 3 ---
7 files changed, 33 insertions(+), 39 deletions(-)
--
2.53.0.345.g96ddfc5eaa-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check()
2026-02-23 10:07 [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() Eric Dumazet
@ 2026-02-23 10:07 ` Eric Dumazet
2026-02-23 18:50 ` Kuniyuki Iwashima
2026-02-23 10:07 ` [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c Eric Dumazet
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2026-02-23 10:07 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
Inline __tcp_v4_send_check(), like __tcp_v6_send_check().
Move tcp_v4_send_check() to tcp_output.c close to
its fast path caller (__tcp_transmit_skb()).
Note __tcp_v4_send_check() is still out-of-line for tcp4_gso_segment()
because it is called in an unlikely() section.
$ scripts/bloat-o-meter -t vmlinux.0 vmlinux.1
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-9 (-9)
Function old new delta
__tcp_v4_send_check 130 121 -9
Total: Before=25143100, After=25143091, chg -0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/tcp.h | 10 +++++++++-
net/ipv4/tcp_ipv4.c | 18 ------------------
net/ipv4/tcp_output.c | 10 +++++++++-
3 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 40e72b9cb85f08714d3f458c0bd1402a5fb1eb4e..3c84433f3d57b1bb29b10f41a5d9981145134237 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2382,7 +2382,15 @@ void tcp_gro_complete(struct sk_buff *skb);
static inline void tcp_gro_complete(struct sk_buff *skb) { }
#endif
-void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr);
+static inline void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr,
+ __be32 daddr)
+{
+ struct tcphdr *th = tcp_hdr(skb);
+
+ th->check = ~tcp_v4_check(skb->len, saddr, daddr, 0);
+ skb->csum_start = skb_transport_header(skb) - skb->head;
+ skb->csum_offset = offsetof(struct tcphdr, check);
+}
static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
{
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6264fc0b2be53854598d7c37ce1c7928d2e0b507..da708aff06230615bdc9cc19fcd8b2bd91462eff 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -661,24 +661,6 @@ int tcp_v4_err(struct sk_buff *skb, u32 info)
return 0;
}
-void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr)
-{
- struct tcphdr *th = tcp_hdr(skb);
-
- th->check = ~tcp_v4_check(skb->len, saddr, daddr, 0);
- skb->csum_start = skb_transport_header(skb) - skb->head;
- skb->csum_offset = offsetof(struct tcphdr, check);
-}
-
-/* This routine computes an IPv4 TCP checksum. */
-void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
-{
- const struct inet_sock *inet = inet_sk(sk);
-
- __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr);
-}
-EXPORT_IPV6_MOD(tcp_v4_send_check);
-
#define REPLY_OPTIONS_LEN (MAX_TCP_OPTION_SPACE / sizeof(__be32))
static bool tcp_v4_ao_sign_reset(const struct sock *sk, struct sk_buff *skb,
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 326b58ff1118d02fc396753d56f210f9d3007c7f..29056d6fc787ec4ad4e3126634e5d52dacf6d700 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1496,7 +1496,15 @@ static void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
INDIRECT_CALLABLE_DECLARE(int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl));
INDIRECT_CALLABLE_DECLARE(int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl));
-INDIRECT_CALLABLE_DECLARE(void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb));
+
+/* This routine computes an IPv4 TCP checksum. */
+void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
+{
+ const struct inet_sock *inet = inet_sk(sk);
+
+ __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr);
+}
+EXPORT_IPV6_MOD(tcp_v4_send_check);
/* This routine actually transmits TCP packets queued in by
* tcp_do_sendmsg(). This is used by both the initial
--
2.53.0.345.g96ddfc5eaa-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c
2026-02-23 10:07 [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() Eric Dumazet
2026-02-23 10:07 ` [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check() Eric Dumazet
@ 2026-02-23 10:07 ` Eric Dumazet
2026-02-23 18:53 ` Kuniyuki Iwashima
2026-02-23 10:07 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static Eric Dumazet
2026-02-25 1:50 ` [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() patchwork-bot+netdevbpf
3 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2026-02-23 10:07 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
Move tcp_v6_send_check() so that __tcp_transmit_skb() can inline it.
$ scripts/bloat-o-meter -t vmlinux.1 vmlinux.2
add/remove: 0/0 grow/shrink: 1/0 up/down: 105/0 (105)
Function old new delta
__tcp_transmit_skb 3321 3426 +105
Total: Before=25143091, After=25143196, chg +0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/tcp.h | 3 ++-
net/ipv4/tcp_output.c | 19 ++++++++++++++++---
net/ipv6/tcp_ipv6.c | 5 -----
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3c84433f3d57b1bb29b10f41a5d9981145134237..feaddce9d80523a9e7bd9db4c691736859c48c91 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1132,7 +1132,8 @@ static inline int tcp_v6_sdif(const struct sk_buff *skb)
extern const struct inet_connection_sock_af_ops ipv6_specific;
-INDIRECT_CALLABLE_DECLARE(void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb));
+void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb);
+
INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *skb));
void tcp_v6_early_demux(struct sk_buff *skb);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 29056d6fc787ec4ad4e3126634e5d52dacf6d700..fdddb16630a5108607496bfdc4d603baa43de621 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1506,6 +1506,16 @@ void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
}
EXPORT_IPV6_MOD(tcp_v4_send_check);
+#if IS_ENABLED(CONFIG_IPV6)
+#include <net/ip6_checksum.h>
+
+void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
+{
+ __tcp_v6_send_check(skb, &sk->sk_v6_rcv_saddr, &sk->sk_v6_daddr);
+}
+EXPORT_IPV6_MOD(tcp_v6_send_check);
+#endif
+
/* This routine actually transmits TCP packets queued in by
* tcp_do_sendmsg(). This is used by both the initial
* transmission and possible later retransmissions.
@@ -1667,9 +1677,12 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
/* BPF prog is the last one writing header option */
bpf_skops_write_hdr_opt(sk, skb, NULL, NULL, 0, &opts);
- INDIRECT_CALL_INET(icsk->icsk_af_ops->send_check,
- tcp_v6_send_check, tcp_v4_send_check,
- sk, skb);
+#if IS_ENABLED(CONFIG_IPV6)
+ if (likely(icsk->icsk_af_ops->send_check == tcp_v6_send_check))
+ tcp_v6_send_check(sk, skb);
+ else
+#endif
+ tcp_v4_send_check(sk, skb);
if (likely(tcb->tcp_flags & TCPHDR_ACK))
tcp_event_ack_sent(sk, rcv_nxt);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d10487b4e5bff87d4ff2a7b912a826964101a163..306ca0585b4a60fcaafcbc9656a5fe36ad21d1b2 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2015,11 +2015,6 @@ static struct timewait_sock_ops tcp6_timewait_sock_ops = {
.twsk_obj_size = sizeof(struct tcp6_timewait_sock),
};
-INDIRECT_CALLABLE_SCOPE void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
-{
- __tcp_v6_send_check(skb, &sk->sk_v6_rcv_saddr, &sk->sk_v6_daddr);
-}
-
const struct inet_connection_sock_af_ops ipv6_specific = {
.queue_xmit = inet6_csk_xmit,
.send_check = tcp_v6_send_check,
--
2.53.0.345.g96ddfc5eaa-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static
2026-02-23 10:07 [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() Eric Dumazet
2026-02-23 10:07 ` [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check() Eric Dumazet
2026-02-23 10:07 ` [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c Eric Dumazet
@ 2026-02-23 10:07 ` Eric Dumazet
2026-02-23 18:55 ` Kuniyuki Iwashima
2026-02-25 11:57 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static: manual merge Matthieu Baerts
2026-02-25 1:50 ` [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() patchwork-bot+netdevbpf
3 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2026-02-23 10:07 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
tcp_v{4,6}_send_check() are only called from tcp_output.c
and should be made static so that the compiler does not need
to put an out of line copy of them.
Remove (struct inet_connection_sock_af_ops) send_check field
and use instead @net_header_len.
Move @net_header_len close to @queue_xmit for data locality
as both are used in TCP tx fast path.
$ scripts/bloat-o-meter -t vmlinux.2 vmlinux.3
add/remove: 0/2 grow/shrink: 0/3 up/down: 0/-172 (-172)
Function old new delta
__tcp_transmit_skb 3426 3423 -3
tcp_v4_send_check 136 132 -4
mptcp_subflow_init 777 763 -14
__pfx_tcp_v6_send_check 16 - -16
tcp_v6_send_check 135 - -135
Total: Before=25143196, After=25143024, chg -0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/inet_connection_sock.h | 3 +--
include/net/tcp.h | 3 ---
net/ipv4/tcp_ipv4.c | 1 -
net/ipv4/tcp_output.c | 8 +++-----
net/ipv6/tcp_ipv6.c | 2 --
net/mptcp/subflow.c | 1 -
net/tls/tls_device_fallback.c | 3 ---
7 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index ecb362025c4e5183ec78aef4b45c249da87c19ea..bbc9355871c767b51e3d1a4d2436022a8556416c 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -34,7 +34,7 @@ struct tcp_congestion_ops;
*/
struct inet_connection_sock_af_ops {
int (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
- void (*send_check)(struct sock *sk, struct sk_buff *skb);
+ u16 net_header_len;
int (*rebuild_header)(struct sock *sk);
void (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
int (*conn_request)(struct sock *sk, struct sk_buff *skb);
@@ -43,7 +43,6 @@ struct inet_connection_sock_af_ops {
struct dst_entry *dst,
struct request_sock *req_unhash,
bool *own_req);
- u16 net_header_len;
int (*setsockopt)(struct sock *sk, int level, int optname,
sockptr_t optval, unsigned int optlen);
int (*getsockopt)(struct sock *sk, int level, int optname,
diff --git a/include/net/tcp.h b/include/net/tcp.h
index feaddce9d80523a9e7bd9db4c691736859c48c91..dfcd38089f113389b82d90e5f45a54a618f2d590 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -531,7 +531,6 @@ u16 tcp_get_syncookie_mss(struct request_sock_ops *rsk_ops,
* TCP v4 functions exported for the inet6 API
*/
-void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
void tcp_v4_mtu_reduced(struct sock *sk);
void tcp_req_err(struct sock *sk, u32 seq, bool abort);
void tcp_ld_RTO_revert(struct sock *sk, u32 seq);
@@ -1132,8 +1131,6 @@ static inline int tcp_v6_sdif(const struct sk_buff *skb)
extern const struct inet_connection_sock_af_ops ipv6_specific;
-void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb);
-
INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *skb));
void tcp_v6_early_demux(struct sk_buff *skb);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index da708aff06230615bdc9cc19fcd8b2bd91462eff..bd613e401d4865dcb658409b7a54d1a77e1e065c 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2405,7 +2405,6 @@ EXPORT_IPV6_MOD(inet_sk_rx_dst_set);
const struct inet_connection_sock_af_ops ipv4_specific = {
.queue_xmit = ip_queue_xmit,
- .send_check = tcp_v4_send_check,
.rebuild_header = inet_sk_rebuild_header,
.sk_rx_dst_set = inet_sk_rx_dst_set,
.conn_request = tcp_v4_conn_request,
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index fdddb16630a5108607496bfdc4d603baa43de621..1ef419c66a0ebad6422be73a57afaba044467148 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1498,22 +1498,20 @@ INDIRECT_CALLABLE_DECLARE(int ip_queue_xmit(struct sock *sk, struct sk_buff *skb
INDIRECT_CALLABLE_DECLARE(int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl));
/* This routine computes an IPv4 TCP checksum. */
-void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
+static void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
{
const struct inet_sock *inet = inet_sk(sk);
__tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr);
}
-EXPORT_IPV6_MOD(tcp_v4_send_check);
#if IS_ENABLED(CONFIG_IPV6)
#include <net/ip6_checksum.h>
-void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
+static void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
{
__tcp_v6_send_check(skb, &sk->sk_v6_rcv_saddr, &sk->sk_v6_daddr);
}
-EXPORT_IPV6_MOD(tcp_v6_send_check);
#endif
/* This routine actually transmits TCP packets queued in by
@@ -1678,7 +1676,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
bpf_skops_write_hdr_opt(sk, skb, NULL, NULL, 0, &opts);
#if IS_ENABLED(CONFIG_IPV6)
- if (likely(icsk->icsk_af_ops->send_check == tcp_v6_send_check))
+ if (likely(icsk->icsk_af_ops->net_header_len == sizeof(struct ipv6hdr)))
tcp_v6_send_check(sk, skb);
else
#endif
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 306ca0585b4a60fcaafcbc9656a5fe36ad21d1b2..f17da56b449ef30675469e033e0173059791443f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2017,7 +2017,6 @@ static struct timewait_sock_ops tcp6_timewait_sock_ops = {
const struct inet_connection_sock_af_ops ipv6_specific = {
.queue_xmit = inet6_csk_xmit,
- .send_check = tcp_v6_send_check,
.rebuild_header = inet6_sk_rebuild_header,
.sk_rx_dst_set = inet6_sk_rx_dst_set,
.conn_request = tcp_v6_conn_request,
@@ -2049,7 +2048,6 @@ static const struct tcp_sock_af_ops tcp_sock_ipv6_specific = {
*/
static const struct inet_connection_sock_af_ops ipv6_mapped = {
.queue_xmit = ip_queue_xmit,
- .send_check = tcp_v4_send_check,
.rebuild_header = inet_sk_rebuild_header,
.sk_rx_dst_set = inet_sk_rx_dst_set,
.conn_request = tcp_v6_conn_request,
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f66129f1e649248e00215d254c925f66c3fffa6a..dd79c5b37a6b62750b62443d911c9fedd67d9d17 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -2190,7 +2190,6 @@ void __init mptcp_subflow_init(void)
subflow_v6m_specific = subflow_v6_specific;
subflow_v6m_specific.queue_xmit = ipv4_specific.queue_xmit;
- subflow_v6m_specific.send_check = ipv4_specific.send_check;
subflow_v6m_specific.net_header_len = ipv4_specific.net_header_len;
subflow_v6m_specific.mtu_reduced = ipv4_specific.mtu_reduced;
subflow_v6m_specific.rebuild_header = subflow_rebuild_header;
diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
index 03d508a45aaee9218bb2deed542534785f2019d6..de7d86bdd7ec99df5be4215ff79dbd5e86e49934 100644
--- a/net/tls/tls_device_fallback.c
+++ b/net/tls/tls_device_fallback.c
@@ -149,9 +149,6 @@ static int tls_enc_records(struct aead_request *aead_req,
return rc;
}
-/* Can't use icsk->icsk_af_ops->send_check here because the ip addresses
- * might have been changed by NAT.
- */
static void update_chksum(struct sk_buff *skb, int headln)
{
struct tcphdr *th = tcp_hdr(skb);
--
2.53.0.345.g96ddfc5eaa-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check()
2026-02-23 10:07 ` [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check() Eric Dumazet
@ 2026-02-23 18:50 ` Kuniyuki Iwashima
0 siblings, 0 replies; 9+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-23 18:50 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Neal Cardwell, netdev, eric.dumazet
On Mon, Feb 23, 2026 at 2:07 AM Eric Dumazet <edumazet@google.com> wrote:
>
> Inline __tcp_v4_send_check(), like __tcp_v6_send_check().
>
> Move tcp_v4_send_check() to tcp_output.c close to
> its fast path caller (__tcp_transmit_skb()).
>
> Note __tcp_v4_send_check() is still out-of-line for tcp4_gso_segment()
> because it is called in an unlikely() section.
>
> $ scripts/bloat-o-meter -t vmlinux.0 vmlinux.1
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-9 (-9)
> Function old new delta
> __tcp_v4_send_check 130 121 -9
> Total: Before=25143100, After=25143091, chg -0.00%
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c
2026-02-23 10:07 ` [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c Eric Dumazet
@ 2026-02-23 18:53 ` Kuniyuki Iwashima
0 siblings, 0 replies; 9+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-23 18:53 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Neal Cardwell, netdev, eric.dumazet
On Mon, Feb 23, 2026 at 2:07 AM Eric Dumazet <edumazet@google.com> wrote:
>
> Move tcp_v6_send_check() so that __tcp_transmit_skb() can inline it.
>
> $ scripts/bloat-o-meter -t vmlinux.1 vmlinux.2
> add/remove: 0/0 grow/shrink: 1/0 up/down: 105/0 (105)
> Function old new delta
> __tcp_transmit_skb 3321 3426 +105
> Total: Before=25143091, After=25143196, chg +0.00%
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static
2026-02-23 10:07 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static Eric Dumazet
@ 2026-02-23 18:55 ` Kuniyuki Iwashima
2026-02-25 11:57 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static: manual merge Matthieu Baerts
1 sibling, 0 replies; 9+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-23 18:55 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Neal Cardwell, netdev, eric.dumazet
On Mon, Feb 23, 2026 at 2:07 AM Eric Dumazet <edumazet@google.com> wrote:
>
> tcp_v{4,6}_send_check() are only called from tcp_output.c
> and should be made static so that the compiler does not need
> to put an out of line copy of them.
>
> Remove (struct inet_connection_sock_af_ops) send_check field
> and use instead @net_header_len.
>
> Move @net_header_len close to @queue_xmit for data locality
> as both are used in TCP tx fast path.
>
> $ scripts/bloat-o-meter -t vmlinux.2 vmlinux.3
> add/remove: 0/2 grow/shrink: 0/3 up/down: 0/-172 (-172)
> Function old new delta
> __tcp_transmit_skb 3426 3423 -3
> tcp_v4_send_check 136 132 -4
> mptcp_subflow_init 777 763 -14
> __pfx_tcp_v6_send_check 16 - -16
> tcp_v6_send_check 135 - -135
> Total: Before=25143196, After=25143024, chg -0.00%
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check()
2026-02-23 10:07 [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() Eric Dumazet
` (2 preceding siblings ...)
2026-02-23 10:07 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static Eric Dumazet
@ 2026-02-25 1:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-25 1:50 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, horms, ncardwell, kuniyu, netdev,
eric.dumazet
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 23 Feb 2026 10:07:26 +0000 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v2,net-next,1/3] tcp: inline __tcp_v4_send_check()
https://git.kernel.org/netdev/net-next/c/bd5e5e1d41d3
- [v2,net-next,2/3] tcp: move tcp_v6_send_check() to tcp_output.c
https://git.kernel.org/netdev/net-next/c/255688652b8c
- [v2,net-next,3/3] tcp: make tcp_v{4,6}_send_check() static
https://git.kernel.org/netdev/net-next/c/fcd3d039fab6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static: manual merge
2026-02-23 10:07 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static Eric Dumazet
2026-02-23 18:55 ` Kuniyuki Iwashima
@ 2026-02-25 11:57 ` Matthieu Baerts
1 sibling, 0 replies; 9+ messages in thread
From: Matthieu Baerts @ 2026-02-25 11:57 UTC (permalink / raw)
To: Eric Dumazet
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni,
Mark Brown
Hi Eric,
Thank you for the patch!
On 23/02/2026 11:07, Eric Dumazet wrote:
> tcp_v{4,6}_send_check() are only called from tcp_output.c
> and should be made static so that the compiler does not need
> to put an out of line copy of them.
>
> Remove (struct inet_connection_sock_af_ops) send_check field
> and use instead @net_header_len.
>
> Move @net_header_len close to @queue_xmit for data locality
> as both are used in TCP tx fast path.
(...)
> diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
> index ecb362025c4e5183ec78aef4b45c249da87c19ea..bbc9355871c767b51e3d1a4d2436022a8556416c 100644
> --- a/include/net/inet_connection_sock.h
> +++ b/include/net/inet_connection_sock.h
> @@ -34,7 +34,7 @@ struct tcp_congestion_ops;
> */
> struct inet_connection_sock_af_ops {
> int (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
> - void (*send_check)(struct sock *sk, struct sk_buff *skb);
> + u16 net_header_len;
> int (*rebuild_header)(struct sock *sk);
> void (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
> int (*conn_request)(struct sock *sk, struct sk_buff *skb);
> @@ -43,7 +43,6 @@ struct inet_connection_sock_af_ops {
> struct dst_entry *dst,
> struct request_sock *req_unhash,
> bool *own_req);
> - u16 net_header_len;
FYI, I got a small conflict when merging 'net' in 'net-next' in the
MPTCP tree due to this patch applied in 'net':
858d2a4f67ff ("tcp: fix potential race in tcp_v6_syn_recv_sock()")
and this one from 'net-next':
fcd3d039fab6 ("tcp: make tcp_v{4,6}_send_check() static")
The conflict was in the context: here 'net_header_len' has been moved,
while in net-next, the line above has been modified. I'm sharing the 3w
patch resolving the conflict, just in case it can help others. Rerere
cache is available as well:
https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/d58bc4b
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
------------------------ 8< ------------------------
diff --cc include/net/inet_connection_sock.h
index 5cb3056d6ddc,bbc9355871c7..433c2df23076
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@@ -42,10 -42,7 +42,9 @@@ struct inet_connection_sock_af_ops
struct request_sock *req,
struct dst_entry *dst,
struct request_sock *req_unhash,
- bool *own_req);
+ bool *own_req,
+ void (*opt_child_init)(struct sock *newsk,
+ const struct sock *sk));
- u16 net_header_len;
int (*setsockopt)(struct sock *sk, int level, int optname,
sockptr_t optval, unsigned int optlen);
int (*getsockopt)(struct sock *sk, int level, int optname,
------------------------ 8< ------------------------
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-02-25 11:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 10:07 [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() Eric Dumazet
2026-02-23 10:07 ` [PATCH v2 net-next 1/3] tcp: inline __tcp_v4_send_check() Eric Dumazet
2026-02-23 18:50 ` Kuniyuki Iwashima
2026-02-23 10:07 ` [PATCH v2 net-next 2/3] tcp: move tcp_v6_send_check() to tcp_output.c Eric Dumazet
2026-02-23 18:53 ` Kuniyuki Iwashima
2026-02-23 10:07 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static Eric Dumazet
2026-02-23 18:55 ` Kuniyuki Iwashima
2026-02-25 11:57 ` [PATCH v2 net-next 3/3] tcp: make tcp_v{4,6}_send_check() static: manual merge Matthieu Baerts
2026-02-25 1:50 ` [PATCH v2 net-next 0/3] tcp: rework tcp_v{4,6}_send_check() patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox