Skip to content

Commit a35b6e4

Browse files
edumazetkuba-moo
authored andcommitted
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>
1 parent fd24173 commit a35b6e4

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

include/net/tcp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,8 +1633,14 @@ static inline bool tcp_checksum_complete(struct sk_buff *skb)
16331633
bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
16341634
enum skb_drop_reason *reason);
16351635

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;
1640+
1641+
return sk_filter_trim_cap(sk, skb, __tcp_hdrlen(th), reason);
1642+
}
16361643

1637-
int tcp_filter(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason *reason);
16381644
void tcp_set_state(struct sock *sk, int state);
16391645
void tcp_done(struct sock *sk);
16401646
int tcp_abort(struct sock *sk, int err);

net/ipv4/tcp_ipv4.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,14 +2109,6 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
21092109
}
21102110
EXPORT_IPV6_MOD(tcp_add_backlog);
21112111

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-
21202112
static void tcp_v4_restore_cb(struct sk_buff *skb)
21212113
{
21222114
memmove(IPCB(skb), &TCP_SKB_CB(skb)->header.h4,

0 commit comments

Comments
 (0)