netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason()
@ 2022-02-03 15:37 Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 15:37 UTC (permalink / raw)
  To: netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

This RFC is to seek for suggestion to track the reason that the sk_buff is
dropped.

Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
Instead, it "goto drop" and call kfree_skb() at 'drop'. This makes it
difficult to track the reason that the sk_buff is dropped.

The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
introduced the kfree_skb_reason() to help track the reason. However, we may
need to define many reasons for each driver/subsystem.

I am going to trace the "goto drop" in TUN and TAP drivers. However, I will
need to introduce many new reasons if I re-use kfree_skb_reason().


There are some other options.

1. The 1st option is to introduce a new tracepoint, e.g., trace_drop_skb()
as below to track the function and line number. We would call
trace_drop_skb() before "goto drop".

TP_PROTO(struct sk_buff *skb, struct net_device *dev,
         const char *function, unsigned int line),


2. The 2nd option is to directly call trace_kfree_skb() before "goto drop".
And we may replace kfree_skb() with below kfree_skb_notrace() as suggested
by Joao Martins.

/**
 * kfree_skb_notrace - free an sk_buff without tracing
 * @skb: buffer to free
 *
 * Drop a reference to the buffer and free it if the usage count has
 * hit zero.
 */
void kfree_skb_notrace(struct sk_buff *skb)
{
    if (!skb_unref(skb))
        return;

    __kfree_skb(skb);
}


3. The last option is this RFC. To avoid introducing so many new reasons,
we use (__func__, __LINE__) to uniquely identify the location of
each "goto drop". The 'reason' introduced by the
commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") is replaced
by the (function, line) pair.

The below is the sample output from trace_pipe by this RFC, when the
sk_buff is dropped by TUN driver.


          <idle>-0       [016] ..s1.   432.701987: kfree_skb: skbaddr=00000000a65c0a72 protocol=0 location=000000008a49d80c function=none line=0
          <idle>-0       [003] b.s2.   432.704397: kfree_skb: skbaddr=00000000665e5ccd protocol=2048 location=00000000ec3b7129 function=tun_net_xmit line=1116
          <idle>-0       [003] ..s1.   432.704400: kfree_skb: skbaddr=00000000e4c806f8 protocol=2048 location=000000002929642d function=none line=0
          <idle>-0       [002] b.s2.   432.734617: kfree_skb: skbaddr=00000000079749b3 protocol=2048 location=00000000ec3b7129 function=tun_net_xmit line=1116
          <idle>-0       [015] b.s2.   432.880571: kfree_skb: skbaddr=00000000e1542f1e protocol=34525 location=00000000ec3b7129 function=tun_net_xmit line=1116
          <idle>-0       [015] ..s1.   432.880577: kfree_skb: skbaddr=000000004f3022b6 protocol=34525 location=00000000547c5c25 function=none line=0
          <idle>-0       [002] b.s2.   432.886247: kfree_skb: skbaddr=0000000062990a71 protocol=2054 location=00000000ec3b7129 function=tun_net_xmit line=1116


 drivers/net/tap.c          | 30 ++++++++++++++++++++++--------
 drivers/net/tun.c          | 33 +++++++++++++++++++++++++--------
 include/linux/skbuff.h     | 24 +++++++-----------------
 include/trace/events/skb.h | 37 ++++++++-----------------------------
 net/core/dev.c             |  3 ++-
 net/core/skbuff.c          | 10 ++++++----
 net/ipv4/tcp_ipv4.c        | 14 +++++++-------
 net/ipv4/udp.c             | 14 +++++++-------
 8 files changed, 84 insertions(+), 81 deletions(-)


Would you please share your suggestion and feedback?

Thank you very much!

Dongli Zhang



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
  2022-02-03 15:37 [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason() Dongli Zhang
@ 2022-02-03 15:37 ` Dongli Zhang
  2022-02-03 15:48   ` David Ahern
  2022-02-03 15:59   ` Eric Dumazet
  2022-02-03 15:37 ` [PATCH RFC 2/4] net: skb: add function name as part of reason Dongli Zhang
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 15:37 UTC (permalink / raw)
  To: netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
Instead, it "goto drop" and call kfree_skb() at 'drop'. This make it
difficult to track the reason that the sk_buff is dropped.

The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
introduced the kfree_skb_reason() to help track the reason. However, we may
need to define many reasons for each driver/subsystem.

To avoid introducing so many new reasons, this is to use line number
("__LINE__") to trace where the sk_buff is dropped. As a result, the reason
will be generated automatically.

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 include/linux/skbuff.h     | 21 ++++-----------------
 include/trace/events/skb.h | 35 ++++++-----------------------------
 net/core/dev.c             |  2 +-
 net/core/skbuff.c          |  9 ++++-----
 net/ipv4/tcp_ipv4.c        | 14 +++++++-------
 net/ipv4/udp.c             | 14 +++++++-------
 6 files changed, 29 insertions(+), 66 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8a636e678902..471268a4a497 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -307,21 +307,8 @@ struct sk_buff_head {
 
 struct sk_buff;
 
-/* The reason of skb drop, which is used in kfree_skb_reason().
- * en...maybe they should be splited by group?
- *
- * Each item here should also be in 'TRACE_SKB_DROP_REASON', which is
- * used to translate the reason to string.
- */
-enum skb_drop_reason {
-	SKB_DROP_REASON_NOT_SPECIFIED,
-	SKB_DROP_REASON_NO_SOCKET,
-	SKB_DROP_REASON_PKT_TOO_SMALL,
-	SKB_DROP_REASON_TCP_CSUM,
-	SKB_DROP_REASON_SOCKET_FILTER,
-	SKB_DROP_REASON_UDP_CSUM,
-	SKB_DROP_REASON_MAX,
-};
+#define SKB_DROP_LINE_NONE	0
+#define SKB_DROP_LINE		__LINE__
 
 /* To allow 64K frame to be packed as single skb without frag_list we
  * require 64K/PAGE_SIZE pages plus 1 additional page to allow for
@@ -1103,7 +1090,7 @@ static inline bool skb_unref(struct sk_buff *skb)
 	return true;
 }
 
-void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason);
+void kfree_skb_reason(struct sk_buff *skb, unsigned int line);
 
 /**
  *	kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason
@@ -1111,7 +1098,7 @@ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason);
  */
 static inline void kfree_skb(struct sk_buff *skb)
 {
-	kfree_skb_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
+	kfree_skb_reason(skb, SKB_DROP_LINE_NONE);
 }
 
 void skb_release_head_state(struct sk_buff *skb);
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index a8a64b97504d..45d1a1757ff1 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -9,56 +9,33 @@
 #include <linux/netdevice.h>
 #include <linux/tracepoint.h>
 
-#define TRACE_SKB_DROP_REASON					\
-	EM(SKB_DROP_REASON_NOT_SPECIFIED, NOT_SPECIFIED)	\
-	EM(SKB_DROP_REASON_NO_SOCKET, NO_SOCKET)		\
-	EM(SKB_DROP_REASON_PKT_TOO_SMALL, PKT_TOO_SMALL)	\
-	EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM)			\
-	EM(SKB_DROP_REASON_SOCKET_FILTER, SOCKET_FILTER)	\
-	EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM)			\
-	EMe(SKB_DROP_REASON_MAX, MAX)
-
-#undef EM
-#undef EMe
-
-#define EM(a, b)	TRACE_DEFINE_ENUM(a);
-#define EMe(a, b)	TRACE_DEFINE_ENUM(a);
-
-TRACE_SKB_DROP_REASON
-
-#undef EM
-#undef EMe
-#define EM(a, b)	{ a, #b },
-#define EMe(a, b)	{ a, #b }
-
 /*
  * Tracepoint for free an sk_buff:
  */
 TRACE_EVENT(kfree_skb,
 
 	TP_PROTO(struct sk_buff *skb, void *location,
-		 enum skb_drop_reason reason),
+		 unsigned int line),
 
-	TP_ARGS(skb, location, reason),
+	TP_ARGS(skb, location, line),
 
 	TP_STRUCT__entry(
 		__field(void *,		skbaddr)
 		__field(void *,		location)
 		__field(unsigned short,	protocol)
-		__field(enum skb_drop_reason,	reason)
+		__field(unsigned int,	line)
 	),
 
 	TP_fast_assign(
 		__entry->skbaddr = skb;
 		__entry->location = location;
 		__entry->protocol = ntohs(skb->protocol);
-		__entry->reason = reason;
+		__entry->line = line;
 	),
 
-	TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
+	TP_printk("skbaddr=%p protocol=%u location=%p line: %u",
 		  __entry->skbaddr, __entry->protocol, __entry->location,
-		  __print_symbolic(__entry->reason,
-				   TRACE_SKB_DROP_REASON))
+		  __entry->line)
 );
 
 TRACE_EVENT(consume_skb,
diff --git a/net/core/dev.c b/net/core/dev.c
index 1baab07820f6..448f390d35d3 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4900,7 +4900,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)
 				trace_consume_skb(skb);
 			else
 				trace_kfree_skb(skb, net_tx_action,
-						SKB_DROP_REASON_NOT_SPECIFIED);
+						SKB_DROP_LINE);
 
 			if (skb->fclone != SKB_FCLONE_UNAVAILABLE)
 				__kfree_skb(skb);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 0118f0afaa4f..8572c3bce264 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -761,18 +761,17 @@ EXPORT_SYMBOL(__kfree_skb);
 /**
  *	kfree_skb_reason - free an sk_buff with special reason
  *	@skb: buffer to free
- *	@reason: reason why this skb is dropped
+ *	@line: the line where this skb is dropped
  *
  *	Drop a reference to the buffer and free it if the usage count has
- *	hit zero. Meanwhile, pass the drop reason to 'kfree_skb'
- *	tracepoint.
+ *	hit zero. Meanwhile, pass the drop line to 'kfree_skb' tracepoint.
  */
-void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
+void kfree_skb_reason(struct sk_buff *skb, unsigned int line)
 {
 	if (!skb_unref(skb))
 		return;
 
-	trace_kfree_skb(skb, __builtin_return_address(0), reason);
+	trace_kfree_skb(skb, __builtin_return_address(0), line);
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb_reason);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fec656f5a39e..f23af94d1186 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1971,10 +1971,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	const struct tcphdr *th;
 	bool refcounted;
 	struct sock *sk;
-	int drop_reason;
+	unsigned int drop_line;
 	int ret;
 
-	drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
+	drop_line = SKB_DROP_LINE_NONE;
 	if (skb->pkt_type != PACKET_HOST)
 		goto discard_it;
 
@@ -1987,7 +1987,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	th = (const struct tcphdr *)skb->data;
 
 	if (unlikely(th->doff < sizeof(struct tcphdr) / 4)) {
-		drop_reason = SKB_DROP_REASON_PKT_TOO_SMALL;
+		drop_line = SKB_DROP_LINE;
 		goto bad_packet;
 	}
 	if (!pskb_may_pull(skb, th->doff * 4))
@@ -2095,7 +2095,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	nf_reset_ct(skb);
 
 	if (tcp_filter(sk, skb)) {
-		drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
+		drop_line = SKB_DROP_LINE;
 		goto discard_and_relse;
 	}
 	th = (const struct tcphdr *)skb->data;
@@ -2130,7 +2130,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	return ret;
 
 no_tcp_socket:
-	drop_reason = SKB_DROP_REASON_NO_SOCKET;
+	drop_line = SKB_DROP_LINE;
 	if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
 		goto discard_it;
 
@@ -2138,7 +2138,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 
 	if (tcp_checksum_complete(skb)) {
 csum_error:
-		drop_reason = SKB_DROP_REASON_TCP_CSUM;
+		drop_line = SKB_DROP_LINE;
 		trace_tcp_bad_csum(skb);
 		__TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);
 bad_packet:
@@ -2149,7 +2149,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 
 discard_it:
 	/* Discard frame. */
-	kfree_skb_reason(skb, drop_reason);
+	kfree_skb_reason(skb, drop_line);
 	return 0;
 
 discard_and_relse:
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 090360939401..f0715d1072d7 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2411,9 +2411,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	__be32 saddr, daddr;
 	struct net *net = dev_net(skb->dev);
 	bool refcounted;
-	int drop_reason;
+	unsigned int drop_line;
 
-	drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
+	drop_line = SKB_DROP_LINE_NONE;
 
 	/*
 	 *  Validate the packet.
@@ -2469,7 +2469,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	if (udp_lib_checksum_complete(skb))
 		goto csum_error;
 
-	drop_reason = SKB_DROP_REASON_NO_SOCKET;
+	drop_line = SKB_DROP_LINE;
 	__UDP_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
 	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
 
@@ -2477,11 +2477,11 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 * Hmm.  We got an UDP packet to a port to which we
 	 * don't wanna listen.  Ignore it.
 	 */
-	kfree_skb_reason(skb, drop_reason);
+	kfree_skb_reason(skb, drop_line);
 	return 0;
 
 short_packet:
-	drop_reason = SKB_DROP_REASON_PKT_TOO_SMALL;
+	drop_line = SKB_DROP_LINE;
 	net_dbg_ratelimited("UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n",
 			    proto == IPPROTO_UDPLITE ? "Lite" : "",
 			    &saddr, ntohs(uh->source),
@@ -2494,7 +2494,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 * RFC1122: OK.  Discards the bad packet silently (as far as
 	 * the network is concerned, anyway) as per 4.1.3.4 (MUST).
 	 */
-	drop_reason = SKB_DROP_REASON_UDP_CSUM;
+	drop_line = SKB_DROP_LINE;
 	net_dbg_ratelimited("UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n",
 			    proto == IPPROTO_UDPLITE ? "Lite" : "",
 			    &saddr, ntohs(uh->source), &daddr, ntohs(uh->dest),
@@ -2502,7 +2502,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
 drop:
 	__UDP_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
-	kfree_skb_reason(skb, drop_reason);
+	kfree_skb_reason(skb, drop_line);
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 2/4] net: skb: add function name as part of reason
  2022-02-03 15:37 [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason() Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
@ 2022-02-03 15:37 ` Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 3/4] net: tun: track dropped skb via kfree_skb_reason() Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 4/4] net: tap: " Dongli Zhang
  3 siblings, 0 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 15:37 UTC (permalink / raw)
  To: netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

In addition to the line number ("__LINE__"), this is to make the
function name ("__func__", which is the caller of kfree_skb_reason())
as part of reason.

The (function, line) combination is able to uniquely represent where the
sk_buff is dropped.

The existing trace_kfree_skb() is able to trace the 'location'. While it
is fine to either echo 'stacktrace' to the trigger, or trace at
userspace via ebpf, the TP_printk will only print %p.

With the function name, the TP_printk will tell the function and the
line number that the sk_buff is dropped.

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 include/linux/skbuff.h     |  7 +++++--
 include/trace/events/skb.h | 10 ++++++----
 net/core/dev.c             |  1 +
 net/core/skbuff.c          |  9 ++++++---
 net/ipv4/tcp_ipv4.c        |  2 +-
 net/ipv4/udp.c             |  4 ++--
 6 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 471268a4a497..10bcbe4f690f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -309,6 +309,8 @@ struct sk_buff;
 
 #define SKB_DROP_LINE_NONE	0
 #define SKB_DROP_LINE		__LINE__
+#define SKB_DROP_FUNC_NONE	"none"
+#define SKB_DROP_FUNC		__func__
 
 /* To allow 64K frame to be packed as single skb without frag_list we
  * require 64K/PAGE_SIZE pages plus 1 additional page to allow for
@@ -1090,7 +1092,8 @@ static inline bool skb_unref(struct sk_buff *skb)
 	return true;
 }
 
-void kfree_skb_reason(struct sk_buff *skb, unsigned int line);
+void kfree_skb_reason(struct sk_buff *skb, const char *func,
+		      unsigned int line);
 
 /**
  *	kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason
@@ -1098,7 +1101,7 @@ void kfree_skb_reason(struct sk_buff *skb, unsigned int line);
  */
 static inline void kfree_skb(struct sk_buff *skb)
 {
-	kfree_skb_reason(skb, SKB_DROP_LINE_NONE);
+	kfree_skb_reason(skb, SKB_DROP_FUNC_NONE, SKB_DROP_LINE_NONE);
 }
 
 void skb_release_head_state(struct sk_buff *skb);
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 45d1a1757ff1..b63bf724809e 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -15,14 +15,15 @@
 TRACE_EVENT(kfree_skb,
 
 	TP_PROTO(struct sk_buff *skb, void *location,
-		 unsigned int line),
+		 const char *function, unsigned int line),
 
-	TP_ARGS(skb, location, line),
+	TP_ARGS(skb, location, function, line),
 
 	TP_STRUCT__entry(
 		__field(void *,		skbaddr)
 		__field(void *,		location)
 		__field(unsigned short,	protocol)
+		__string(function, function)
 		__field(unsigned int,	line)
 	),
 
@@ -30,12 +31,13 @@ TRACE_EVENT(kfree_skb,
 		__entry->skbaddr = skb;
 		__entry->location = location;
 		__entry->protocol = ntohs(skb->protocol);
+		__assign_str(function, function);
 		__entry->line = line;
 	),
 
-	TP_printk("skbaddr=%p protocol=%u location=%p line: %u",
+	TP_printk("skbaddr=%p protocol=%u location=%p function=%s line=%u",
 		  __entry->skbaddr, __entry->protocol, __entry->location,
-		  __entry->line)
+		  __get_str(function), __entry->line)
 );
 
 TRACE_EVENT(consume_skb,
diff --git a/net/core/dev.c b/net/core/dev.c
index 448f390d35d3..3dccd3248de9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4900,6 +4900,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)
 				trace_consume_skb(skb);
 			else
 				trace_kfree_skb(skb, net_tx_action,
+						SKB_DROP_FUNC,
 						SKB_DROP_LINE);
 
 			if (skb->fclone != SKB_FCLONE_UNAVAILABLE)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8572c3bce264..f7bceb310912 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -761,17 +761,20 @@ EXPORT_SYMBOL(__kfree_skb);
 /**
  *	kfree_skb_reason - free an sk_buff with special reason
  *	@skb: buffer to free
+ *	@func: the function where this skb is dropped
  *	@line: the line where this skb is dropped
  *
  *	Drop a reference to the buffer and free it if the usage count has
- *	hit zero. Meanwhile, pass the drop line to 'kfree_skb' tracepoint.
+ *	hit zero. Meanwhile, pass the drop function and line to 'kfree_skb'
+ *	tracepoint.
  */
-void kfree_skb_reason(struct sk_buff *skb, unsigned int line)
+void kfree_skb_reason(struct sk_buff *skb, const char *func,
+		      unsigned int line)
 {
 	if (!skb_unref(skb))
 		return;
 
-	trace_kfree_skb(skb, __builtin_return_address(0), line);
+	trace_kfree_skb(skb, __builtin_return_address(0), func, line);
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb_reason);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f23af94d1186..a1cb1252370b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2149,7 +2149,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
 
 discard_it:
 	/* Discard frame. */
-	kfree_skb_reason(skb, drop_line);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 	return 0;
 
 discard_and_relse:
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f0715d1072d7..ae86ab56a7dd 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2477,7 +2477,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 * Hmm.  We got an UDP packet to a port to which we
 	 * don't wanna listen.  Ignore it.
 	 */
-	kfree_skb_reason(skb, drop_line);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 	return 0;
 
 short_packet:
@@ -2502,7 +2502,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
 drop:
 	__UDP_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
-	kfree_skb_reason(skb, drop_line);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 3/4] net: tun: track dropped skb via kfree_skb_reason()
  2022-02-03 15:37 [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason() Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 2/4] net: skb: add function name as part of reason Dongli Zhang
@ 2022-02-03 15:37 ` Dongli Zhang
  2022-02-03 15:37 ` [PATCH RFC 4/4] net: tap: " Dongli Zhang
  3 siblings, 0 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 15:37 UTC (permalink / raw)
  To: netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

The TUN can be used as vhost-net backend. E.g, the tun_net_xmit() is the
interface to forward the skb from TUN to vhost-net/virtio-net.

However, there are many "goto drop" in the TUN driver. Therefore, the
kfree_skb_reason() is involved at each "goto drop" to help userspace
ftrace/ebpf to track the reason for the loss of packets.

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 drivers/net/tun.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index fed85447701a..8f6c6d23a787 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1062,13 +1062,16 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 	struct netdev_queue *queue;
 	struct tun_file *tfile;
 	int len = skb->len;
+	unsigned int drop_line = SKB_DROP_LINE_NONE;
 
 	rcu_read_lock();
 	tfile = rcu_dereference(tun->tfiles[txq]);
 
 	/* Drop packet if interface is not attached */
-	if (!tfile)
+	if (!tfile) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
 	if (!rcu_dereference(tun->steering_prog))
 		tun_automq_xmit(tun, skb);
@@ -1078,19 +1081,27 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* Drop if the filter does not like it.
 	 * This is a noop if the filter is disabled.
 	 * Filter can be enabled only for the TAP devices. */
-	if (!check_filter(&tun->txflt, skb))
+	if (!check_filter(&tun->txflt, skb)) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
 	if (tfile->socket.sk->sk_filter &&
-	    sk_filter(tfile->socket.sk, skb))
+	    sk_filter(tfile->socket.sk, skb)) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
 	len = run_ebpf_filter(tun, skb, len);
-	if (len == 0 || pskb_trim(skb, len))
+	if (len == 0 || pskb_trim(skb, len)) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
-	if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC)))
+	if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC))) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
 	skb_tx_timestamp(skb);
 
@@ -1101,8 +1112,10 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	nf_reset_ct(skb);
 
-	if (ptr_ring_produce(&tfile->tx_ring, skb))
+	if (ptr_ring_produce(&tfile->tx_ring, skb)) {
+		drop_line = SKB_DROP_LINE;
 		goto drop;
+	}
 
 	/* NETIF_F_LLTX requires to do our own update of trans_start */
 	queue = netdev_get_tx_queue(dev, txq);
@@ -1119,7 +1132,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 drop:
 	atomic_long_inc(&dev->tx_dropped);
 	skb_tx_error(skb);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 	rcu_read_unlock();
 	return NET_XMIT_DROP;
 }
@@ -1717,6 +1730,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 	u32 rxhash = 0;
 	int skb_xdp = 1;
 	bool frags = tun_napi_frags_enabled(tfile);
+	unsigned int drop_line = SKB_DROP_LINE_NONE;
 
 	if (!(tun->flags & IFF_NO_PI)) {
 		if (len < sizeof(pi))
@@ -1820,9 +1834,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 
 		if (err) {
 			err = -EFAULT;
+			drop_line = SKB_DROP_LINE;
 drop:
 			atomic_long_inc(&tun->dev->rx_dropped);
-			kfree_skb(skb);
+			kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 			if (frags) {
 				tfile->napi.skb = NULL;
 				mutex_unlock(&tfile->napi_mutex);
@@ -1868,6 +1883,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 		break;
 	case IFF_TAP:
 		if (frags && !pskb_may_pull(skb, ETH_HLEN)) {
+			drop_line = SKB_DROP_LINE;
 			err = -ENOMEM;
 			goto drop;
 		}
@@ -1922,6 +1938,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 	if (unlikely(!(tun->dev->flags & IFF_UP))) {
 		err = -EIO;
 		rcu_read_unlock();
+		drop_line = SKB_DROP_LINE;
 		goto drop;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 4/4] net: tap: track dropped skb via kfree_skb_reason()
  2022-02-03 15:37 [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason() Dongli Zhang
                   ` (2 preceding siblings ...)
  2022-02-03 15:37 ` [PATCH RFC 3/4] net: tun: track dropped skb via kfree_skb_reason() Dongli Zhang
@ 2022-02-03 15:37 ` Dongli Zhang
  3 siblings, 0 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 15:37 UTC (permalink / raw)
  To: netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

The TAP can be used as vhost-net backend. E.g., the tap_handle_frame() is
the interface to forward the skb from TAP to vhost-net/virtio-net.

However, there are many "goto drop" in the TAP driver. Therefore, the
kfree_skb_reason() is involved at each "goto drop" to help userspace
ftrace/ebpf to track the reason for the loss of packets.

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 drivers/net/tap.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 8e3a28ba6b28..78828dd1b74b 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -322,6 +322,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
 	struct tap_dev *tap;
 	struct tap_queue *q;
 	netdev_features_t features = TAP_FEATURES;
+	unsigned int drop_line = SKB_DROP_LINE_NONE;
 
 	tap = tap_dev_get_rcu(dev);
 	if (!tap)
@@ -343,12 +344,16 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
 		struct sk_buff *segs = __skb_gso_segment(skb, features, false);
 		struct sk_buff *next;
 
-		if (IS_ERR(segs))
+		if (IS_ERR(segs)) {
+			drop_line = SKB_DROP_LINE;
 			goto drop;
+		}
 
 		if (!segs) {
-			if (ptr_ring_produce(&q->ring, skb))
+			if (ptr_ring_produce(&q->ring, skb)) {
+				drop_line = SKB_DROP_LINE;
 				goto drop;
+			}
 			goto wake_up;
 		}
 
@@ -369,10 +374,14 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
 		 */
 		if (skb->ip_summed == CHECKSUM_PARTIAL &&
 		    !(features & NETIF_F_CSUM_MASK) &&
-		    skb_checksum_help(skb))
+		    skb_checksum_help(skb)) {
+			drop_line = SKB_DROP_LINE;
 			goto drop;
-		if (ptr_ring_produce(&q->ring, skb))
+		}
+		if (ptr_ring_produce(&q->ring, skb)) {
+			drop_line = SKB_DROP_LINE;
 			goto drop;
+		}
 	}
 
 wake_up:
@@ -383,7 +392,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
 	/* Count errors/drops only here, thus don't care about args. */
 	if (tap->count_rx_dropped)
 		tap->count_rx_dropped(tap);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 	return RX_HANDLER_CONSUMED;
 }
 EXPORT_SYMBOL_GPL(tap_handle_frame);
@@ -632,6 +641,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
 	int depth;
 	bool zerocopy = false;
 	size_t linear;
+	unsigned int drop_line = SKB_DROP_LINE_NONE;
 
 	if (q->flags & IFF_VNET_HDR) {
 		vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz);
@@ -696,8 +706,10 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
 	else
 		err = skb_copy_datagram_from_iter(skb, 0, from, len);
 
-	if (err)
+	if (err) {
+		drop_line = SKB_DROP_LINE;
 		goto err_kfree;
+	}
 
 	skb_set_network_header(skb, ETH_HLEN);
 	skb_reset_mac_header(skb);
@@ -706,8 +718,10 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
 	if (vnet_hdr_len) {
 		err = virtio_net_hdr_to_skb(skb, &vnet_hdr,
 					    tap_is_little_endian(q));
-		if (err)
+		if (err) {
+			drop_line = SKB_DROP_LINE;
 			goto err_kfree;
+		}
 	}
 
 	skb_probe_transport_header(skb);
@@ -738,7 +752,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
 	return total_len;
 
 err_kfree:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_FUNC, drop_line);
 
 err:
 	rcu_read_lock();
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
  2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
@ 2022-02-03 15:48   ` David Ahern
  2022-02-03 17:13     ` Dongli Zhang
  2022-02-03 15:59   ` Eric Dumazet
  1 sibling, 1 reply; 9+ messages in thread
From: David Ahern @ 2022-02-03 15:48 UTC (permalink / raw)
  To: Dongli Zhang, netdev, bpf
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin

On 2/3/22 8:37 AM, Dongli Zhang wrote:
> Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
> Instead, it "goto drop" and call kfree_skb() at 'drop'. This make it
> difficult to track the reason that the sk_buff is dropped.
> 
> The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
> introduced the kfree_skb_reason() to help track the reason. However, we may
> need to define many reasons for each driver/subsystem.
> 
> To avoid introducing so many new reasons, this is to use line number
> ("__LINE__") to trace where the sk_buff is dropped. As a result, the reason
> will be generated automatically.
> 

I don't agree with this approach. It is only marginally better than the
old kfree_skb that only gave the instruction pointer. That tells you the
function that dropped the packet, but not why the packet is dropped.
Adding the line number only makes users have to consult the source code.

When I watch drop monitor for kfree_skb I want to know *why* the packet
was dropped, not the line number in the source code. e.g., dropmon
showing OTHERHOST means too many packets are sent to this host (e.g.,
hypervisor) that do not belong to the host or the VMs running on it, or
packets have invalid checksum (IP, TCP, UDP). Usable information by
everyone, not just someone with access to the source code for that
specific kernel.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
  2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
  2022-02-03 15:48   ` David Ahern
@ 2022-02-03 15:59   ` Eric Dumazet
  2022-02-03 17:14     ` Dongli Zhang
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2022-02-03 15:59 UTC (permalink / raw)
  To: Dongli Zhang
  Cc: netdev, bpf, LKML, Steven Rostedt, Ingo Molnar, David Miller,
	Jakub Kicinski, Hideaki YOSHIFUJI, David Ahern,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Menglong Dong, Joao Martins, joe.jin

On Thu, Feb 3, 2022 at 7:38 AM Dongli Zhang <dongli.zhang@oracle.com> wrote:
>
> Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
> Instead, it "goto drop" and call kfree_skb() at 'drop'. This make it
> difficult to track the reason that the sk_buff is dropped.
>
> The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
> introduced the kfree_skb_reason() to help track the reason. However, we may
> need to define many reasons for each driver/subsystem.
>
> To avoid introducing so many new reasons, this is to use line number
> ("__LINE__") to trace where the sk_buff is dropped. As a result, the reason
> will be generated automatically.
>
> Cc: Joao Martins <joao.m.martins@oracle.com>
> Cc: Joe Jin <joe.jin@oracle.com>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
>  include/linux/skbuff.h     | 21 ++++-----------------
>  include/trace/events/skb.h | 35 ++++++-----------------------------
>  net/core/dev.c             |  2 +-
>  net/core/skbuff.c          |  9 ++++-----
>  net/ipv4/tcp_ipv4.c        | 14 +++++++-------
>  net/ipv4/udp.c             | 14 +++++++-------
>  6 files changed, 29 insertions(+), 66 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 8a636e678902..471268a4a497 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -307,21 +307,8 @@ struct sk_buff_head {
>
>  struct sk_buff;
>
> -/* The reason of skb drop, which is used in kfree_skb_reason().
> - * en...maybe they should be splited by group?
> - *
> - * Each item here should also be in 'TRACE_SKB_DROP_REASON', which is
> - * used to translate the reason to string.
> - */
> -enum skb_drop_reason {
> -       SKB_DROP_REASON_NOT_SPECIFIED,
> -       SKB_DROP_REASON_NO_SOCKET,
> -       SKB_DROP_REASON_PKT_TOO_SMALL,
> -       SKB_DROP_REASON_TCP_CSUM,
> -       SKB_DROP_REASON_SOCKET_FILTER,
> -       SKB_DROP_REASON_UDP_CSUM,
> -       SKB_DROP_REASON_MAX,
> -};


Seriously, we have to stop messing with things like that.

Your patch comes too late, another approach has been taken.

Please continue this effort by providing patches that improve things,
instead of throwing away effort already done.

I say no to this patch.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
  2022-02-03 15:48   ` David Ahern
@ 2022-02-03 17:13     ` Dongli Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 17:13 UTC (permalink / raw)
  To: David Ahern
  Cc: linux-kernel, rostedt, mingo, davem, kuba, edumazet, yoshfuji,
	dsahern, ast, daniel, andrii, imagedong, joao.m.martins, joe.jin,
	netdev, bpf


Hi David,

On 2/3/22 7:48 AM, David Ahern wrote:
> On 2/3/22 8:37 AM, Dongli Zhang wrote:
>> Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
>> Instead, it "goto drop" and call kfree_skb() at 'drop'. This make it
>> difficult to track the reason that the sk_buff is dropped.
>>
>> The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
>> introduced the kfree_skb_reason() to help track the reason. However, we may
>> need to define many reasons for each driver/subsystem.
>>
>> To avoid introducing so many new reasons, this is to use line number
>> ("__LINE__") to trace where the sk_buff is dropped. As a result, the reason
>> will be generated automatically.
>>
> 
> I don't agree with this approach. It is only marginally better than the
> old kfree_skb that only gave the instruction pointer. That tells you the
> function that dropped the packet, but not why the packet is dropped.
> Adding the line number only makes users have to consult the source code.
> 
> When I watch drop monitor for kfree_skb I want to know *why* the packet
> was dropped, not the line number in the source code. e.g., dropmon
> showing OTHERHOST means too many packets are sent to this host (e.g.,
> hypervisor) that do not belong to the host or the VMs running on it, or
> packets have invalid checksum (IP, TCP, UDP). Usable information by
> everyone, not just someone with access to the source code for that
> specific kernel.
> 
Thank you very much for the suggestion!

I will not follow this approach. I will introduce new reasons to TUN and TAP
drivers.

Dongli Zhang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
  2022-02-03 15:59   ` Eric Dumazet
@ 2022-02-03 17:14     ` Dongli Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Dongli Zhang @ 2022-02-03 17:14 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, bpf, LKML, Steven Rostedt, Ingo Molnar, David Miller,
	Jakub Kicinski, Hideaki YOSHIFUJI, David Ahern,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Menglong Dong, Joao Martins, joe.jin

Hi Eric,

On 2/3/22 7:59 AM, Eric Dumazet wrote:
> On Thu, Feb 3, 2022 at 7:38 AM Dongli Zhang <dongli.zhang@oracle.com> wrote:
>>
>> Sometimes the kernel may not directly call kfree_skb() to drop the sk_buff.
>> Instead, it "goto drop" and call kfree_skb() at 'drop'. This make it
>> difficult to track the reason that the sk_buff is dropped.
>>
>> The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
>> introduced the kfree_skb_reason() to help track the reason. However, we may
>> need to define many reasons for each driver/subsystem.
>>
>> To avoid introducing so many new reasons, this is to use line number
>> ("__LINE__") to trace where the sk_buff is dropped. As a result, the reason
>> will be generated automatically.
>>
>> Cc: Joao Martins <joao.m.martins@oracle.com>
>> Cc: Joe Jin <joe.jin@oracle.com>
>> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
>> ---
>>  include/linux/skbuff.h     | 21 ++++-----------------
>>  include/trace/events/skb.h | 35 ++++++-----------------------------
>>  net/core/dev.c             |  2 +-
>>  net/core/skbuff.c          |  9 ++++-----
>>  net/ipv4/tcp_ipv4.c        | 14 +++++++-------
>>  net/ipv4/udp.c             | 14 +++++++-------
>>  6 files changed, 29 insertions(+), 66 deletions(-)
>>
>> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
>> index 8a636e678902..471268a4a497 100644
>> --- a/include/linux/skbuff.h
>> +++ b/include/linux/skbuff.h
>> @@ -307,21 +307,8 @@ struct sk_buff_head {
>>
>>  struct sk_buff;
>>
>> -/* The reason of skb drop, which is used in kfree_skb_reason().
>> - * en...maybe they should be splited by group?
>> - *
>> - * Each item here should also be in 'TRACE_SKB_DROP_REASON', which is
>> - * used to translate the reason to string.
>> - */
>> -enum skb_drop_reason {
>> -       SKB_DROP_REASON_NOT_SPECIFIED,
>> -       SKB_DROP_REASON_NO_SOCKET,
>> -       SKB_DROP_REASON_PKT_TOO_SMALL,
>> -       SKB_DROP_REASON_TCP_CSUM,
>> -       SKB_DROP_REASON_SOCKET_FILTER,
>> -       SKB_DROP_REASON_UDP_CSUM,
>> -       SKB_DROP_REASON_MAX,
>> -};
> 
> 
> Seriously, we have to stop messing with things like that.
> 
> Your patch comes too late, another approach has been taken.
> 
> Please continue this effort by providing patches that improve things,
> instead of throwing away effort already done.

Thank you very much for the suggestion!

I will introduce new reasons to TUN and TAP drivers, in order to track the
dropped sk_buff.

Dongli Zhang

> 
> I say no to this patch.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-03 17:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 15:37 [PATCH RFC 0/4] net: skb: to use (function, line) pair as reason for kfree_skb_reason() Dongli Zhang
2022-02-03 15:37 ` [PATCH RFC 1/4] net: skb: use line number to trace dropped skb Dongli Zhang
2022-02-03 15:48   ` David Ahern
2022-02-03 17:13     ` Dongli Zhang
2022-02-03 15:59   ` Eric Dumazet
2022-02-03 17:14     ` Dongli Zhang
2022-02-03 15:37 ` [PATCH RFC 2/4] net: skb: add function name as part of reason Dongli Zhang
2022-02-03 15:37 ` [PATCH RFC 3/4] net: tun: track dropped skb via kfree_skb_reason() Dongli Zhang
2022-02-03 15:37 ` [PATCH RFC 4/4] net: tap: " Dongli Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).