summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-03-06 15:43:22 +0000
committerJakub Kicinski <kuba@kernel.org>2026-03-09 18:52:56 -0700
commit82f36517a13e6339ddd9737d8a310949e057e596 (patch)
tree57a9f6164b9482a6daf4114f57f77a1da3682376 /net
parent6927430735802bd8bc5dbe352edbd94a04459567 (diff)
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(). Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260306154322.1086539-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv6/tcp_ipv6.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f27995a64561..2ea8253b737a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -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)) {
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 164dceb842af..074b83c9a551 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -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) {