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.

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%

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

authored by

Eric Dumazet and committed by
Jakub Kicinski
a35b6e48 fd241734

+7 -9
+7 -1
include/net/tcp.h
··· 1633 1633 bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, 1634 1634 enum skb_drop_reason *reason); 1635 1635 1636 + static inline int tcp_filter(struct sock *sk, struct sk_buff *skb, 1637 + enum skb_drop_reason *reason) 1638 + { 1639 + const struct tcphdr *th = (const struct tcphdr *)skb->data; 1636 1640 1637 - int tcp_filter(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason *reason); 1641 + return sk_filter_trim_cap(sk, skb, __tcp_hdrlen(th), reason); 1642 + } 1643 + 1638 1644 void tcp_set_state(struct sock *sk, int state); 1639 1645 void tcp_done(struct sock *sk); 1640 1646 int tcp_abort(struct sock *sk, int err);
-8
net/ipv4/tcp_ipv4.c
··· 2109 2109 } 2110 2110 EXPORT_IPV6_MOD(tcp_add_backlog); 2111 2111 2112 - int tcp_filter(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason *reason) 2113 - { 2114 - struct tcphdr *th = (struct tcphdr *)skb->data; 2115 - 2116 - return sk_filter_trim_cap(sk, skb, th->doff * 4, reason); 2117 - } 2118 - EXPORT_IPV6_MOD(tcp_filter); 2119 - 2120 2112 static void tcp_v4_restore_cb(struct sk_buff *skb) 2121 2113 { 2122 2114 memmove(IPCB(skb), &TCP_SKB_CB(skb)->header.h4,