Skip to contentSkip to conversation

net: use IP_OUTNOROUTES drop reason

PATCH Applied Eric Dumazet 2 participants 5 messages May 11 – May 13

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

v2 cover net: use IP_OUTNOROUTES drop reason

First patch changes sk_skb_reason_drop() sock to be const.

Second and last patch add SKB_DROP_REASON_IP_OUTNOROUTES to both tcp_v6_send_response() and inet6_csk_xmit().

Eric Dumazet (3):
net: constify sk_skb_reason_drop() sock parameter
tcp: use SKB_DROP_REASON_IP_OUTNOROUTES in tcp_v6_send_response()
ipv6: use SKB_DROP_REASON_IP_OUTNOROUTES in inet6_csk_xmit()

 include/linux/skbuff.h           | 3 ++-
 include/trace/events/skb.h       | 4 ++--
 net/core/drop_monitor.c          | 6 +++---
 net/core/skbuff.c                | 5 +++--
 net/ipv6/inet6_connection_sock.c | 3 ++-
 net/ipv6/tcp_ipv6.c              | 2 +-
 6 files changed, 13 insertions(+), 10 deletions(-)
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
#1 lore raw

PATCH v2 1/3 net: constify sk_skb_reason_drop() sock parameter

sk_skb_reason_drop() does not change sock parameter, make it const so that we can call it from TCP stack without a cast on a (const) listener socket.

---
v2: includes changes to net/core/drop_monitor.c

 include/linux/skbuff.h     | 3 ++-
 include/trace/events/skb.h | 4 ++--
 net/core/drop_monitor.c    | 6 +++---
 net/core/skbuff.c          | 5 +++--
 4 files changed, 10 insertions(+), 8 deletions(-)
include/linux/skbuff.h +2 -1
index 2bcf78a4de7b9edb0d1342319d4340c0a9997eeb..746e741a8ef99b3052ad581650e5d0db2a95dbb3 100644
@@ -1313,7 +1313,8 @@ static inline bool skb_data_unref(const struct sk_buff *skb,
 	return true;
 }
 
-void __fix_address sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb,
+void __fix_address sk_skb_reason_drop(const struct sock *sk,
+				      struct sk_buff *skb,
 				      enum skb_drop_reason reason);
 
 static inline void
include/trace/events/skb.h +2 -2
index b877133cd93a80f6b130fab64f334ecdeab8c8fd..2945aa7fe9a7ded5bdec5be3a67382de95239517 100644
@@ -24,14 +24,14 @@ DEFINE_DROP_REASON(FN, FN)
 TRACE_EVENT(kfree_skb,
 
 	TP_PROTO(struct sk_buff *skb, void *location,
-		 enum skb_drop_reason reason, struct sock *rx_sk),
+		 enum skb_drop_reason reason, const struct sock *rx_sk),
 
 	TP_ARGS(skb, location, reason, rx_sk),
 
 	TP_STRUCT__entry(
 		__field(void *,		skbaddr)
 		__field(void *,		location)
-		__field(void *,		rx_sk)
+		__field(const void *,	rx_sk)
 		__field(unsigned short,	protocol)
 		__field(enum skb_drop_reason,	reason)
 	),
net/core/drop_monitor.c +3 -3
index f23cea9e1aafb1e98a17f75e6b9c10ce3e2b9d45..2bf3cab5e557a15dd3fa7197098d6b0abcc01fab 100644
@@ -110,7 +110,7 @@ struct net_dm_alert_ops {
 	void (*kfree_skb_probe)(void *ignore, struct sk_buff *skb,
 				void *location,
 				enum skb_drop_reason reason,
-				struct sock *rx_sk);
+				const struct sock *rx_sk);
 	void (*napi_poll_probe)(void *ignore, struct napi_struct *napi,
 				int work, int budget);
 	void (*work_item_func)(struct work_struct *work);
@@ -266,7 +266,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
 static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb,
 				void *location,
 				enum skb_drop_reason reason,
-				struct sock *rx_sk)
+				const struct sock *rx_sk)
 {
 	trace_drop_common(skb, location);
 }
@@ -493,7 +493,7 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
 					      struct sk_buff *skb,
 					      void *location,
 					      enum skb_drop_reason reason,
-					      struct sock *rx_sk)
+					      const struct sock *rx_sk)
 {
 	ktime_t tstamp = ktime_get_real();
 	struct per_cpu_dm_data *data;
net/core/skbuff.c +3 -2
index 7dad68e3b5186cf622a3ed5a6e87c09d46bc3fd6..acca1365672c4f98b004c2548133d70c9cf5ddc1 100644
@@ -1206,7 +1206,7 @@ void __kfree_skb(struct sk_buff *skb)
 EXPORT_SYMBOL(__kfree_skb);
 
 static __always_inline
-bool __sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb,
+bool __sk_skb_reason_drop(const struct sock *sk, struct sk_buff *skb,
 			  enum skb_drop_reason reason)
 {
 	if (unlikely(!skb_unref(skb)))
@@ -1235,7 +1235,8 @@ bool __sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb,
  *	'kfree_skb' tracepoint.
  */
 void __fix_address
-sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason reason)
+sk_skb_reason_drop(const struct sock *sk, struct sk_buff *skb,
+		   enum skb_drop_reason reason)
 {
 	if (__sk_skb_reason_drop(sk, skb, reason))
 		__kfree_skb(skb);
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
#2 lore raw

PATCH v2 2/3 tcp: use SKB_DROP_REASON_IP_OUTNOROUTES in tcp_v6_send_response()

In reply to Eric Dumazet

Replace a bare kfree_skb() with a modern sk_skb_reason_drop() call, and provide IP_OUTNOROUTES drop reason.

---
 net/ipv6/tcp_ipv6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/tcp_ipv6.c +1 -1
index d13d49bfef19457cc5902cb556605a80f4c0ab2c..0d5e2b0a3f579a240e3457881bfe6c647cb3d2d9 100644
@@ -982,7 +982,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
 		return;
 	}
 
-	kfree_skb(buff);
+	sk_skb_reason_drop(sk, buff, SKB_DROP_REASON_IP_OUTNOROUTES);
 }
 
 static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb,
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
#3 lore raw

PATCH v2 3/3 ipv6: use SKB_DROP_REASON_IP_OUTNOROUTES in inet6_csk_xmit()

In reply to Eric Dumazet

Replace a bare kfree_skb() with a modern sk_skb_reason_drop() call, and provide IP_OUTNOROUTES drop reason.

---
 net/ipv6/inet6_connection_sock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/inet6_connection_sock.c +2 -1
index 37534e1168992c44e1400dacab87e79d04c64a41..4665d84a7380d90b7d180a429017f577fcb6936a 100644
@@ -102,7 +102,8 @@ int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl_unused
 		if (IS_ERR(dst)) {
 			WRITE_ONCE(sk->sk_err_soft, -PTR_ERR(dst));
 			sk->sk_route_caps = 0;
-			kfree_skb(skb);
+			sk_skb_reason_drop(sk, skb,
+					   SKB_DROP_REASON_IP_OUTNOROUTES);
 			return PTR_ERR(dst);
 		}
 		/* Restore final destination back after routing done */
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
#4 lore raw
In reply to Eric Dumazet
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Mon, 11 May 2026 07:23:07 +0000 you wrote:

First patch changes sk_skb_reason_drop() sock to be const.

Second and last patch add SKB_DROP_REASON_IP_OUTNOROUTES to both tcp_v6_send_response() and inet6_csk_xmit().

Eric Dumazet (3):
net: constify sk_skb_reason_drop() sock parameter
tcp: use SKB_DROP_REASON_IP_OUTNOROUTES in tcp_v6_send_response()
ipv6: use SKB_DROP_REASON_IP_OUTNOROUTES in inet6_csk_xmit()

[...]

Here is the summary with links:
- [v2,net-next,1/3] net: constify sk_skb_reason_drop() sock parameter

    https://git.kernel.org/netdev/net-next/c/5c4b709b5fc1
  - [v2,net-next,2/3] tcp: use SKB_DROP_REASON_IP_OUTNOROUTES in tcp_v6_send_response()
    https://git.kernel.org/netdev/net-next/c/254084223f93
  - [v2,net-next,3/3] ipv6: use SKB_DROP_REASON_IP_OUTNOROUTES in inet6_csk_xmit()
    https://git.kernel.org/netdev/net-next/c/4a64f9732577

You are awesome, thank you!

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