Skip to contentSkip to conversation

tcp: inline tcp_filter()

PATCH Applied Eric Dumazet 3 participants 3 messages Feb 5 – Feb 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: inline tcp_filter()

This helper is already (auto)inlined from IPv4 TCP stack.

Make it an inline function to benefit IPv6 as well.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 1/0 up/down: 30/-49 (-19)
Function                                     old     new   delta
tcp_v6_rcv                                  3448    3478     +30
__pfx_tcp_filter                              16       -     -16
tcp_filter                                    33       -     -33
Total: Before=24891904, After=24891885, chg -0.00%
---
 include/net/tcp.h   | 8 +++++++-
 net/ipv4/tcp_ipv4.c | 8 --------
 2 files changed, 7 insertions(+), 9 deletions(-)
include/net/tcp.h +7 -1
index 8f9f52f3408c2e87adaad3e26ffc7162776309f1..40e72b9cb85f08714d3f458c0bd1402a5fb1eb4e 100644
@@ -1633,8 +1633,14 @@ static inline bool tcp_checksum_complete(struct sk_buff *skb)
 bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
 		     enum skb_drop_reason *reason);
 
+static inline int tcp_filter(struct sock *sk, struct sk_buff *skb,
+			     enum skb_drop_reason *reason)
+{
+	const struct tcphdr *th = (const struct tcphdr *)skb->data;
+
+	return sk_filter_trim_cap(sk, skb, __tcp_hdrlen(th), reason);
+}
 
-int tcp_filter(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason *reason);
 void tcp_set_state(struct sock *sk, int state);
 void tcp_done(struct sock *sk);
 int tcp_abort(struct sock *sk, int err);
net/ipv4/tcp_ipv4.c +0 -8
index 01fd563472608cc10744d3a5d4fb998b83c4be97..6264fc0b2be53854598d7c37ce1c7928d2e0b507 100644
@@ -2109,14 +2109,6 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
 }
 EXPORT_IPV6_MOD(tcp_add_backlog);
 
-int tcp_filter(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason *reason)
-{
-	struct tcphdr *th = (struct tcphdr *)skb->data;
-
-	return sk_filter_trim_cap(sk, skb, th->doff * 4, reason);
-}
-EXPORT_IPV6_MOD(tcp_filter);
-
 static void tcp_v4_restore_cb(struct sk_buff *skb)
 {
 	memmove(IPCB(skb), &TCP_SKB_CB(skb)->header.h4,
Signature · 1 line
2.53.0.rc2.204.g2597b5adb4-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Eric Dumazet

This helper is already (auto)inlined from IPv4 TCP stack.

Make it an inline function to benefit IPv6 as well.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 1/0 up/down: 30/-49 (-19)
Function                                     old     new   delta
tcp_v6_rcv                                  3448    3478     +30
__pfx_tcp_filter                              16       -     -16
tcp_filter                                    33       -     -33
Total: Before=24891904, After=24891885, chg -0.00%
Quoted 1 line
#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 12 lines · On Thu, 5 Feb 2026 16:43:29 +0000 you wrote:

This helper is already (auto)inlined from IPv4 TCP stack.

Make it an inline function to benefit IPv6 as well.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 1/0 up/down: 30/-49 (-19)
Function                                     old     new   delta
tcp_v6_rcv                                  3448    3478     +30
__pfx_tcp_filter                              16       -     -16
tcp_filter                                    33       -     -33
Total: Before=24891904, After=24891885, chg -0.00%
Quoted 1 line

[...]

Here is the summary with links:
- [net-next] tcp: inline tcp_filter()

    https://git.kernel.org/netdev/net-next/c/a35b6e4863d8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html