Skip to contentSkip to conversation

tcp: prefer sk_skb_reason_drop()

PATCH Applied Eric Dumazet 4 participants 6 messages Sep 18, 2025 – Sep 20, 2025

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

PATCH 1/1 tcp: prefer sk_skb_reason_drop()

Replace two calls to kfree_skb_reason() with sk_skb_reason_drop().

Cc Daniel Zahka <[email protected]>
Cc Dmitry Safonov <[email protected]>
---
 net/ipv4/tcp_output.c | 2 +-
 net/psp/psp_sock.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +1 -1
index 223d7feeb19d4671fcbc9f21caf588c661b4bbe0..bb3576ac0ad7d7330ef272e1d9dc1f19bb8f86bb 100644
@@ -1586,7 +1586,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
 		err = tcp_ao_transmit_skb(sk, skb, key.ao_key, th,
 					  opts.hash_location);
 		if (err) {
-			kfree_skb_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
+			sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
 			return -ENOMEM;
 		}
 	}
net/psp/psp_sock.c +1 -1
index d19e37e939672c1f8fc0ebb62e50a3fb32cc8d25..5324a7603bed64d3f1f71b66dd44f622048519a6 100644
@@ -37,7 +37,7 @@ psp_validate_xmit(struct sock *sk, struct net_device *dev, struct sk_buff *skb)
 	good = !pas || rcu_access_pointer(dev->psp_dev) == pas->psd;
 	rcu_read_unlock();
 	if (!good) {
-		kfree_skb_reason(skb, SKB_DROP_REASON_PSP_OUTPUT);
+		sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PSP_OUTPUT);
 		return NULL;
 	}
 
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eric Dumazet

Replace two calls to kfree_skb_reason() with sk_skb_reason_drop().

Cc Daniel Zahka <[email protected]>
Cc Dmitry Safonov <[email protected]>

LGTM, thanks!

Side-note: I see that tcp_ao_transmit_skb() can currently fail only due to ENOMEM, IIRC I haven't found more specific reason at that time than just SKB_DROP_REASON_NOT_SPECIFIED, unsure if worth changing that.

Quoted 32 lines
---
 net/ipv4/tcp_output.c | 2 +-
 net/psp/psp_sock.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +1 -1
index 223d7feeb19d4671fcbc9f21caf588c661b4bbe0..bb3576ac0ad7d7330ef272e1d9dc1f19bb8f86bb 100644
@@ -1586,7 +1586,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
                err = tcp_ao_transmit_skb(sk, skb, key.ao_key, th,
                                          opts.hash_location);
                if (err) {
-                       kfree_skb_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
+                       sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
                        return -ENOMEM;
                }
        }
net/psp/psp_sock.c +1 -2
index d19e37e939672c1f8fc0ebb62e50a3fb32cc8d25..5324a7603bed64d3f1f71b66dd44f622048519a6 100644
@@ -37,7 +37,7 @@ psp_validate_xmit(struct sock *sk, struct net_device *dev, struct sk_buff *skb)
        good = !pas || rcu_access_pointer(dev->psp_dev) == pas->psd;
        rcu_read_unlock();
        if (!good) {
-               kfree_skb_reason(skb, SKB_DROP_REASON_PSP_OUTPUT);
+               sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_PSP_OUTPUT);
                return NULL;
        }
 
--
Quoted 2 lines

2.51.0.384.g4c02a37b29-goog

--
Dmitry

#2 lore raw
Quoted 9 lines · Dmitry Safonov
Quoted 6 lines · Eric Dumazet

Replace two calls to kfree_skb_reason() with sk_skb_reason_drop().

Cc Daniel Zahka <[email protected]>
Cc Dmitry Safonov <[email protected]>
Quoted 8 lines

LGTM, thanks!

Side-note: I see that tcp_ao_transmit_skb() can currently fail only due to ENOMEM, IIRC I haven't found more specific reason at that time than just SKB_DROP_REASON_NOT_SPECIFIED, unsure if worth changing that.

We could then use SKB_DROP_REASON_NOMEM.

#3 lore raw
Quoted 13 lines · Eric Dumazet
Quoted 11 lines · Dmitry Safonov
Quoted 6 lines · Eric Dumazet

Replace two calls to kfree_skb_reason() with sk_skb_reason_drop().

Cc Daniel Zahka <[email protected]>
Cc Dmitry Safonov <[email protected]>

LGTM, thanks!

Quoted 8 lines
Quoted 6 lines

Side-note: I see that tcp_ao_transmit_skb() can currently fail only due to ENOMEM, IIRC I haven't found more specific reason at that time than just SKB_DROP_REASON_NOT_SPECIFIED, unsure if worth changing that.

We could then use SKB_DROP_REASON_NOMEM.

Yeah, I think I wasn't sure if it's worth just due to one place. But if it's generally useful, I'd say we could :-)

Thanks,
Dmitry

#5 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 9 lines · On Thu, 18 Sep 2025 13:20:07 +0000 you wrote:

Replace two calls to kfree_skb_reason() with sk_skb_reason_drop().

Cc Daniel Zahka <[email protected]>
Cc Dmitry Safonov <[email protected]>
---
 net/ipv4/tcp_output.c | 2 +-
 net/psp/psp_sock.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
- [net-next] tcp: prefer sk_skb_reason_drop()

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

You are awesome, thank you!

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