tcp: avoid dst->ops->check() call in tcp_v{4,6}_do_rcv()
Subsystems (3)
PATCH 1/1 tcp: avoid dst->ops->check() call in tcp_v{4,6}_do_rcv()
If incoming skb dst matches the socket cached one, there is no need to call again dst->ops->check().
Network layer already validated the skb dst for us, usually from tcp_v{4,6}_early_demux().
--- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_ipv4.c +1 -1
@@ -1855,7 +1855,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)sock_rps_save_rxhash (sk, skb);sk_mark_napi_id (sk, skb); -if (dst) { +if (dst &&unlikely (dst !=skb_dst (skb))) {if (sk->sk_rx_dst_ifindex != skb->skb_iif || !INDIRECT_CALL_1 (dst->ops->check, ipv4_dst_check, dst,0 )) {
net/ipv6/tcp_ipv6.c +1 -1
@@ -1596,7 +1596,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)sock_rps_save_rxhash (sk, skb);sk_mark_napi_id (sk, skb); -if (dst) { +if (dst &&unlikely (dst !=skb_dst (skb))) {if (sk->sk_rx_dst_ifindex != skb->skb_iif ||INDIRECT_CALL_1 (dst->ops->check, ip6_dst_check, dst, sk->sk_rx_dst_cookie) ==NULL ) {
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Quoted 8 lines · Eric Dumazet
If incoming skb dst matches the socket cached one, there is no need to call again
dst->ops->check().Network layer already validated the skb dst for us, usually from tcp_v{4,6}_early_demux().
Signed-off-by Eric Dumazet <[email protected]>
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 9 lines · On Fri, 6 Mar 2026 15:43:22 +0000 you wrote:
If incoming skb dst matches the socket cached one, there is no need to call again
dst->ops->check().Network layer already validated the skb dst for us, usually from tcp_v{4,6}_early_demux().
Signed-off-by Eric Dumazet <[email protected]>[...]
Here is the summary with links:
- [net-next] tcp: avoid dst->ops->check() call in tcp_v{4,6}_do_rcv()
https://git.kernel.org/netdev/net-next/c/82f36517a13e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html