net: skb: to use (function, line) pair as reason for kfree_skb_reason()
Subsystems (7)
cover net: skb: to use (function, line) pair as reason for kfree_skb_reason()
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=1116drivers/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
RFC PATCH 1/4 net: skb: use line number to trace dropped skb
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.
--- 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(-)
include/linux/skbuff.h +4 -17
@@ -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);
include/trace/events/skb.h +6 -29
@@ -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,
net/core/dev.c +1 -1
@@ -4900,7 +4900,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)trace_consume_skb (skb); elsetrace_kfree_skb (skb ,net_tx_action , -SKB_DROP_REASON_NOT_SPECIFIED ); +SKB_DROP_LINE );if (skb->fclone !=SKB_FCLONE_UNAVAILABLE )__kfree_skb (skb);
net/core/skbuff.c +4 -5
@@ -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);
net/ipv4/tcp_ipv4.c +7 -7
@@ -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:
net/ipv4/udp.c +7 -7
@@ -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 ; }
Signature · 1 line
2.17.1
Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
Quoted 4 lines · Dongli Zhang
Sometimes the kernel may not directly call
kfree_skb()to drop thesk_buff. Instead, it "goto drop" and callkfree_skb()at 'drop'. This make it difficult to track the reason that thesk_buffis dropped.
Quoted 8 lines
The commit
c504e5c2f964("net: skb: introducekfree_skb_reason()") has introduced thekfree_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 thesk_buffis 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.
Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
Hi David,
Quoted 19 lines · David Ahern
Quoted 4 lines · Dongli Zhang
Sometimes the kernel may not directly call
kfree_skb()to drop thesk_buff. Instead, it "goto drop" and callkfree_skb()at 'drop'. This make it difficult to track the reason that thesk_buffis dropped.Quoted 8 lines
The commit
c504e5c2f964("net: skb: introducekfree_skb_reason()") has introduced thekfree_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 thesk_buffis 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_skbthat 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.
Quoted 8 lines
When I watch drop monitor for
kfree_skbI 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
Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
In reply to Dongli ZhangQuoted 38 lines · Dongli Zhang
Sometimes the kernel may not directly call
kfree_skb()to drop thesk_buff. Instead, it "goto drop" and callkfree_skb()at 'drop'. This make it difficult to track the reason that thesk_buffis dropped.The commit
c504e5c2f964("net: skb: introducekfree_skb_reason()") has introduced thekfree_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 thesk_buffis dropped. As a result, the reason will be generated automatically.Cc Joao Martins <[email protected]>Cc Joe Jin <[email protected]>Signed-off-by Dongli Zhang <[email protected]>--- 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(-)include/linux/skbuff.h +0
-5@@ -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.
include/linux/skbuff.h struct sk_buff_head { · line 324
Quoted 10 lines
include/linux/skbuff.h +0
-10-*/ -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.
Re: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
Hi Eric,
Quoted 53 lines · Eric Dumazet
Quoted 38 lines · Dongli Zhang
Sometimes the kernel may not directly call
kfree_skb()to drop thesk_buff. Instead, it "goto drop" and callkfree_skb()at 'drop'. This make it difficult to track the reason that thesk_buffis dropped.The commit
c504e5c2f964("net: skb: introducekfree_skb_reason()") has introduced thekfree_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 thesk_buffis dropped. As a result, the reason will be generated automatically.Cc Joao Martins <[email protected]>Cc Joe Jin <[email protected]>Signed-off-by Dongli Zhang <[email protected]>--- 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(-)include/linux/skbuff.h +0
-5@@ -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. include/linux/skbuff.h struct sk_buff_head { · line 324
Quoted 10 lines
include/linux/skbuff.h +0
-10-*/ -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.
Quoted 4 lines
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
Quoted 3 lines
I say no to this patch.
kernel test robot
build botRe: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
In reply to Dongli Zhang[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Dongli,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net/master]
[also build test WARNING on horms-ipvs/master net-next/master linus/master v5.17-rc2 next-20220203] [cannot apply to rostedt-trace/for-next mst-vhost/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 4a81f6da9cb2d1ef911131a6fd8bd15cb61fc772 config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220204/202202040234.v2s33Nzf-lkp(a)intel.com/config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f4f541c242dc39728703547e3088572a7f7e2f38
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 git checkout f4f541c242dc39728703547e3088572a7f7e2f38
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash net/core/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> net/core/drop_monitor.c:114:38: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
114 | enum skb_drop_reason reason);
| ^~~~~~~~~~~~~~~
net/core/drop_monitor.c:268:38: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
268 | enum skb_drop_reason reason)
| ^~~~~~~~~~~~~~~
net/core/drop_monitor.c:268:54: error: parameter 4 ('reason') has incomplete type
268 | enum skb_drop_reason reason)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~
net/core/drop_monitor.c:266:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
266 | static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb,
| ^~~~~~~~~~~~~~~~~~~
net/core/drop_monitor.c:497:52: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
497 | enum skb_drop_reason reason)
| ^~~~~~~~~~~~~~~
net/core/drop_monitor.c:497:68: error: parameter 4 ('reason') has incomplete type
497 | enum skb_drop_reason reason)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~
net/core/drop_monitor.c:494:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
494 | static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/core/drop_monitor.c: In function 'net_dm_trace_on_set':
net/core/drop_monitor.c:1136:42: error: passing argument 1 of 'register_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1136 | rc = register_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:260:38: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
260 | register_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~
net/core/drop_monitor.c:1151:39: error: passing argument 1 of 'unregister_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1151 | unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:273:40: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
273 | unregister_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~
net/core/drop_monitor.c: In function 'net_dm_trace_off_set':
net/core/drop_monitor.c:1175:39: error: passing argument 1 of 'unregister_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1175 | unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:273:40: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
273 | unregister_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~cc1: some warnings being treated as errors
vim +114 net/core/drop_monitor.c
28315f7999870b Ido Schimmel 2019-08-11 110
28315f7999870b Ido Schimmel 2019-08-11 111 struct net_dm_alert_ops {
28315f7999870b Ido Schimmel 2019-08-11 112 void (*kfree_skb_probe)(void *ignore, struct sk_buff *skb,
c504e5c2f9648a Menglong Dong 2022-01-09 113 void *location,
c504e5c2f9648a Menglong Dong 2022-01-09 @114 enum skb_drop_reason reason);
28315f7999870b Ido Schimmel 2019-08-11 115 void (*napi_poll_probe)(void *ignore, struct napi_struct *napi,
28315f7999870b Ido Schimmel 2019-08-11 116 int work, int budget);
28315f7999870b Ido Schimmel 2019-08-11 117 void (*work_item_func)(struct work_struct *work);
5e58109b1ea454 Ido Schimmel 2019-08-17 118 void (*hw_work_item_func)(struct work_struct *work);
5855357cd40e8b Ido Schimmel 2020-09-29 119 void (*hw_trap_probe)(void *ignore, const struct devlink *devlink,
5855357cd40e8b Ido Schimmel 2020-09-29 120 struct sk_buff *skb,
5855357cd40e8b Ido Schimmel 2020-09-29 121 const struct devlink_trap_metadata *metadata);
28315f7999870b Ido Schimmel 2019-08-11 122 };28315f7999870b Ido Schimmel 2019-08-11 123
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH RFC 1/4] net: skb: use line number to trace dropped skb
In reply to Dongli Zhang[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Dongli,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on net/master]
[also build test ERROR on horms-ipvs/master net-next/master linus/master v5.17-rc2 next-20220203] [cannot apply to rostedt-trace/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 4a81f6da9cb2d1ef911131a6fd8bd15cb61fc772 config: s390-randconfig-r044-20220130 (https://download.01.org/0day-ci/archive/20220204/202202040444.13eiIxgB-lkp(a)intel.com/config) compiler: s390-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f4f541c242dc39728703547e3088572a7f7e2f38
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 git checkout f4f541c242dc39728703547e3088572a7f7e2f38
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=s390 SHELL=/bin/bash net/core/
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
>> net/core/drop_monitor.c:114:38: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
114 | enum skb_drop_reason reason);
| ^~~~~~~~~~~~~~~
net/core/drop_monitor.c:268:38: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
268 | enum skb_drop_reason reason)
| ^~~~~~~~~~~~~~~
>> net/core/drop_monitor.c:268:54: error: parameter 4 ('reason') has incomplete type
268 | enum skb_drop_reason reason)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~
>> net/core/drop_monitor.c:266:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
266 | static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb,
| ^~~~~~~~~~~~~~~~~~~
net/core/drop_monitor.c:497:52: warning: 'enum skb_drop_reason' declared inside parameter list will not be visible outside of this definition or declaration
497 | enum skb_drop_reason reason)
| ^~~~~~~~~~~~~~~
net/core/drop_monitor.c:497:68: error: parameter 4 ('reason') has incomplete type
497 | enum skb_drop_reason reason)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~
net/core/drop_monitor.c:494:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
494 | static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/core/drop_monitor.c: In function 'net_dm_trace_on_set':
>> net/core/drop_monitor.c:1136:42: error: passing argument 1 of 'register_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1136 | rc = register_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:260:38: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
260 | register_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~
>> net/core/drop_monitor.c:1151:39: error: passing argument 1 of 'unregister_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1151 | unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:273:40: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
273 | unregister_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~
net/core/drop_monitor.c: In function 'net_dm_trace_off_set':
net/core/drop_monitor.c:1175:39: error: passing argument 1 of 'unregister_trace_kfree_skb' from incompatible pointer type [-Werror=incompatible-pointer-types]
1175 | unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
| ~~~^~~~~~~~~~~~~~~~~
| |
| void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)
In file included from include/trace/events/skb.h:10,
from net/core/drop_monitor.c:34:
include/linux/tracepoint.h:273:40: note: expected 'void (*)(void *, struct sk_buff *, void *, unsigned int)' but argument is of type 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)'
273 | unregister_trace_##name(void (*probe)(data_proto), void *data) \
| ~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 | __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
| ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
| ^~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: in expansion of macro 'TRACE_EVENT'
15 | TRACE_EVENT(kfree_skb,
| ^~~~~~~~~~~cc1: some warnings being treated as errors
vim +114 net/core/drop_monitor.c
28315f7999870b Ido Schimmel 2019-08-11 110
28315f7999870b Ido Schimmel 2019-08-11 111 struct net_dm_alert_ops {
28315f7999870b Ido Schimmel 2019-08-11 112 void (*kfree_skb_probe)(void *ignore, struct sk_buff *skb,
c504e5c2f9648a Menglong Dong 2022-01-09 113 void *location,
c504e5c2f9648a Menglong Dong 2022-01-09 @114 enum skb_drop_reason reason);
28315f7999870b Ido Schimmel 2019-08-11 115 void (*napi_poll_probe)(void *ignore, struct napi_struct *napi,
28315f7999870b Ido Schimmel 2019-08-11 116 int work, int budget);
28315f7999870b Ido Schimmel 2019-08-11 117 void (*work_item_func)(struct work_struct *work);
5e58109b1ea454 Ido Schimmel 2019-08-17 118 void (*hw_work_item_func)(struct work_struct *work);
5855357cd40e8b Ido Schimmel 2020-09-29 119 void (*hw_trap_probe)(void *ignore, const struct devlink *devlink,
5855357cd40e8b Ido Schimmel 2020-09-29 120 struct sk_buff *skb,
5855357cd40e8b Ido Schimmel 2020-09-29 121 const struct devlink_trap_metadata *metadata);
28315f7999870b Ido Schimmel 2019-08-11 122 };
28315f7999870b Ido Schimmel 2019-08-11 123
ca30707dee2bc8 Ido Schimmel 2019-08-11 124 struct net_dm_skb_cb {
5e58109b1ea454 Ido Schimmel 2019-08-17 125 union {
a848c05f4bb6c2 Ido Schimmel 2020-09-29 126 struct devlink_trap_metadata *hw_metadata;
ca30707dee2bc8 Ido Schimmel 2019-08-11 127 void *pc;
ca30707dee2bc8 Ido Schimmel 2019-08-11 128 };
5e58109b1ea454 Ido Schimmel 2019-08-17 129 };
ca30707dee2bc8 Ido Schimmel 2019-08-11 130
ca30707dee2bc8 Ido Schimmel 2019-08-11 131 #define NET_DM_SKB_CB(__skb) ((struct net_dm_skb_cb *)&((__skb)->cb[0]))
ca30707dee2bc8 Ido Schimmel 2019-08-11 132
bec4596b4e6770 Eric Dumazet 2012-06-04 133 static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
9a8afc8d3962f3 Neil Horman 2009-03-11 134 {
9a8afc8d3962f3 Neil Horman 2009-03-11 135 size_t al;
9a8afc8d3962f3 Neil Horman 2009-03-11 136 struct net_dm_alert_msg *msg;
683703a26e4677 Neil Horman 2009-04-27 137 struct nlattr *nla;
3885ca785a3618 Neil Horman 2012-04-27 138 struct sk_buff *skb;
bec4596b4e6770 Eric Dumazet 2012-06-04 139 unsigned long flags;
4200462d88f47f Reiter Wolfgang 2016-12-31 140 void *msg_header;
9a8afc8d3962f3 Neil Horman 2009-03-11 141
9a8afc8d3962f3 Neil Horman 2009-03-11 142 al = sizeof(struct net_dm_alert_msg);
9a8afc8d3962f3 Neil Horman 2009-03-11 143 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
683703a26e4677 Neil Horman 2009-04-27 144 al += sizeof(struct nlattr);
683703a26e4677 Neil Horman 2009-04-27 145
3885ca785a3618 Neil Horman 2012-04-27 146 skb = genlmsg_new(al, GFP_KERNEL);
3885ca785a3618 Neil Horman 2012-04-27 147
4200462d88f47f Reiter Wolfgang 2016-12-31 148 if (!skb)
4200462d88f47f Reiter Wolfgang 2016-12-31 149 goto err;
4200462d88f47f Reiter Wolfgang 2016-12-31 150
4200462d88f47f Reiter Wolfgang 2016-12-31 151 msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
9a8afc8d3962f3 Neil Horman 2009-03-11 152 0, NET_DM_CMD_ALERT);
4200462d88f47f Reiter Wolfgang 2016-12-31 153 if (!msg_header) {
4200462d88f47f Reiter Wolfgang 2016-12-31 154 nlmsg_free(skb);
4200462d88f47f Reiter Wolfgang 2016-12-31 155 skb = NULL;
4200462d88f47f Reiter Wolfgang 2016-12-31 156 goto err;
4200462d88f47f Reiter Wolfgang 2016-12-31 157 }
3885ca785a3618 Neil Horman 2012-04-27 158 nla = nla_reserve(skb, NLA_UNSPEC,
3885ca785a3618 Neil Horman 2012-04-27 159 sizeof(struct net_dm_alert_msg));
4200462d88f47f Reiter Wolfgang 2016-12-31 160 if (!nla) {
4200462d88f47f Reiter Wolfgang 2016-12-31 161 nlmsg_free(skb);
4200462d88f47f Reiter Wolfgang 2016-12-31 162 skb = NULL;
4200462d88f47f Reiter Wolfgang 2016-12-31 163 goto err;
4200462d88f47f Reiter Wolfgang 2016-12-31 164 }
683703a26e4677 Neil Horman 2009-04-27 165 msg = nla_data(nla);
9a8afc8d3962f3 Neil Horman 2009-03-11 166 memset(msg, 0, al);
4200462d88f47f Reiter Wolfgang 2016-12-31 167 goto out;
9a8afc8d3962f3 Neil Horman 2009-03-11 168
4200462d88f47f Reiter Wolfgang 2016-12-31 169 err:
4200462d88f47f Reiter Wolfgang 2016-12-31 170 mod_timer(&data->send_timer, jiffies + HZ / 10);
4200462d88f47f Reiter Wolfgang 2016-12-31 171 out:
bec4596b4e6770 Eric Dumazet 2012-06-04 172 spin_lock_irqsave(&data->lock, flags);
bec4596b4e6770 Eric Dumazet 2012-06-04 173 swap(data->skb, skb);
bec4596b4e6770 Eric Dumazet 2012-06-04 174 spin_unlock_irqrestore(&data->lock, flags);
bec4596b4e6770 Eric Dumazet 2012-06-04 175
3b48ab2248e614 Reiter Wolfgang 2017-01-03 176 if (skb) {
3b48ab2248e614 Reiter Wolfgang 2017-01-03 177 struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
3b48ab2248e614 Reiter Wolfgang 2017-01-03 178 struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
3b48ab2248e614 Reiter Wolfgang 2017-01-03 179
3b48ab2248e614 Reiter Wolfgang 2017-01-03 180 genlmsg_end(skb, genlmsg_data(gnlh));
3b48ab2248e614 Reiter Wolfgang 2017-01-03 181 }
3b48ab2248e614 Reiter Wolfgang 2017-01-03 182
bec4596b4e6770 Eric Dumazet 2012-06-04 183 return skb;
3885ca785a3618 Neil Horman 2012-04-27 184 }
3885ca785a3618 Neil Horman 2012-04-27 185
85bae4bd8ae0a1 stephen hemminger 2016-08-31 186 static const struct genl_multicast_group dropmon_mcgrps[] = {
2a94fe48f32ccf Johannes Berg 2013-11-19 187 { .name = "events", },
e5dcecba015f97 Johannes Berg 2013-11-19 188 };
e5dcecba015f97 Johannes Berg 2013-11-19 189
bec4596b4e6770 Eric Dumazet 2012-06-04 190 static void send_dm_alert(struct work_struct *work)
9a8afc8d3962f3 Neil Horman 2009-03-11 191 {
9a8afc8d3962f3 Neil Horman 2009-03-11 192 struct sk_buff *skb;
bec4596b4e6770 Eric Dumazet 2012-06-04 193 struct per_cpu_dm_data *data;
4fdcfa12843bca Neil Horman 2012-05-01 194
bec4596b4e6770 Eric Dumazet 2012-06-04 195 data = container_of(work, struct per_cpu_dm_data, dm_alert_work);
9a8afc8d3962f3 Neil Horman 2009-03-11 196
bec4596b4e6770 Eric Dumazet 2012-06-04 197 skb = reset_per_cpu_data(data);
9a8afc8d3962f3 Neil Horman 2009-03-11 198
3885ca785a3618 Neil Horman 2012-04-27 199 if (skb)
68eb55031da7c9 Johannes Berg 2013-11-19 200 genlmsg_multicast(&net_drop_monitor_family, skb, 0,
2a94fe48f32ccf Johannes Berg 2013-11-19 201 0, GFP_KERNEL);
9a8afc8d3962f3 Neil Horman 2009-03-11 202 }
9a8afc8d3962f3 Neil Horman 2009-03-11 203
9a8afc8d3962f3 Neil Horman 2009-03-11 204 /*
9a8afc8d3962f3 Neil Horman 2009-03-11 205 * This is the timer function to delay the sending of an alert
9a8afc8d3962f3 Neil Horman 2009-03-11 206 * in the event that more drops will arrive during the
bec4596b4e6770 Eric Dumazet 2012-06-04 207 * hysteresis period.
9a8afc8d3962f3 Neil Horman 2009-03-11 208 */
e99e88a9d2b067 Kees Cook 2017-10-16 209 static void sched_send_work(struct timer_list *t)
9a8afc8d3962f3 Neil Horman 2009-03-11 210 {
e99e88a9d2b067 Kees Cook 2017-10-16 211 struct per_cpu_dm_data *data = from_timer(data, t, send_timer);
9a8afc8d3962f3 Neil Horman 2009-03-11 212
bec4596b4e6770 Eric Dumazet 2012-06-04 213 schedule_work(&data->dm_alert_work);
9a8afc8d3962f3 Neil Horman 2009-03-11 214 }
9a8afc8d3962f3 Neil Horman 2009-03-11 215
4ea7e38696c7e7 Neil Horman 2009-05-21 216 static void trace_drop_common(struct sk_buff *skb, void *location)
9a8afc8d3962f3 Neil Horman 2009-03-11 217 {
9a8afc8d3962f3 Neil Horman 2009-03-11 218 struct net_dm_alert_msg *msg;
dc30b4059f6e2a Arnd Bergmann 2020-04-30 219 struct net_dm_drop_point *point;
9a8afc8d3962f3 Neil Horman 2009-03-11 220 struct nlmsghdr *nlh;
683703a26e4677 Neil Horman 2009-04-27 221 struct nlattr *nla;
9a8afc8d3962f3 Neil Horman 2009-03-11 222 int i;
3885ca785a3618 Neil Horman 2012-04-27 223 struct sk_buff *dskb;
bec4596b4e6770 Eric Dumazet 2012-06-04 224 struct per_cpu_dm_data *data;
bec4596b4e6770 Eric Dumazet 2012-06-04 225 unsigned long flags;
3885ca785a3618 Neil Horman 2012-04-27 226
bec4596b4e6770 Eric Dumazet 2012-06-04 227 local_irq_save(flags);
903ceff7ca7b4d Christoph Lameter 2014-08-17 228 data = this_cpu_ptr(&dm_cpu_data);
bec4596b4e6770 Eric Dumazet 2012-06-04 229 spin_lock(&data->lock);
bec4596b4e6770 Eric Dumazet 2012-06-04 230 dskb = data->skb;
9a8afc8d3962f3 Neil Horman 2009-03-11 231
3885ca785a3618 Neil Horman 2012-04-27 232 if (!dskb)
3885ca785a3618 Neil Horman 2012-04-27 233 goto out;
9a8afc8d3962f3 Neil Horman 2009-03-11 234
3885ca785a3618 Neil Horman 2012-04-27 235 nlh = (struct nlmsghdr *)dskb->data;
683703a26e4677 Neil Horman 2009-04-27 236 nla = genlmsg_data(nlmsg_data(nlh));
683703a26e4677 Neil Horman 2009-04-27 237 msg = nla_data(nla);
dc30b4059f6e2a Arnd Bergmann 2020-04-30 238 point = msg->points;
9a8afc8d3962f3 Neil Horman 2009-03-11 239 for (i = 0; i < msg->entries; i++) {
dc30b4059f6e2a Arnd Bergmann 2020-04-30 240 if (!memcmp(&location, &point->pc, sizeof(void *))) {
dc30b4059f6e2a Arnd Bergmann 2020-04-30 241 point->count++;
9a8afc8d3962f3 Neil Horman 2009-03-11 242 goto out;
9a8afc8d3962f3 Neil Horman 2009-03-11 243 }
dc30b4059f6e2a Arnd Bergmann 2020-04-30 244 point++;
9a8afc8d3962f3 Neil Horman 2009-03-11 245 }
bec4596b4e6770 Eric Dumazet 2012-06-04 246 if (msg->entries == dm_hit_limit)
bec4596b4e6770 Eric Dumazet 2012-06-04 247 goto out;
9a8afc8d3962f3 Neil Horman 2009-03-11 248 /*
9a8afc8d3962f3 Neil Horman 2009-03-11 249 * We need to create a new entry
9a8afc8d3962f3 Neil Horman 2009-03-11 250 */
3885ca785a3618 Neil Horman 2012-04-27 251 __nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point));
683703a26e4677 Neil Horman 2009-04-27 252 nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
dc30b4059f6e2a Arnd Bergmann 2020-04-30 253 memcpy(point->pc, &location, sizeof(void *));
dc30b4059f6e2a Arnd Bergmann 2020-04-30 254 point->count = 1;
9a8afc8d3962f3 Neil Horman 2009-03-11 255 msg->entries++;
9a8afc8d3962f3 Neil Horman 2009-03-11 256
9a8afc8d3962f3 Neil Horman 2009-03-11 257 if (!timer_pending(&data->send_timer)) {
9a8afc8d3962f3 Neil Horman 2009-03-11 258 data->send_timer.expires = jiffies + dm_delay * HZ;
bec4596b4e6770 Eric Dumazet 2012-06-04 259 add_timer(&data->send_timer);
9a8afc8d3962f3 Neil Horman 2009-03-11 260 }
9a8afc8d3962f3 Neil Horman 2009-03-11 261
9a8afc8d3962f3 Neil Horman 2009-03-11 262 out:
bec4596b4e6770 Eric Dumazet 2012-06-04 263 spin_unlock_irqrestore(&data->lock, flags);
9a8afc8d3962f3 Neil Horman 2009-03-11 264 }
9a8afc8d3962f3 Neil Horman 2009-03-11 265
c504e5c2f9648a Menglong Dong 2022-01-09 @266 static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb,
c504e5c2f9648a Menglong Dong 2022-01-09 267 void *location,
c504e5c2f9648a Menglong Dong 2022-01-09 @268 enum skb_drop_reason reason)
4ea7e38696c7e7 Neil Horman 2009-05-21 269 {
4ea7e38696c7e7 Neil Horman 2009-05-21 270 trace_drop_common(skb, location);
4ea7e38696c7e7 Neil Horman 2009-05-21 271 }
4ea7e38696c7e7 Neil Horman 2009-05-21 272 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
RFC PATCH 2/4 net: skb: add function name as part of reason
In reply to Dongli ZhangIn 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.
--- 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(-)
include/linux/skbuff.h +5 -2
@@ -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);
include/trace/events/skb.h +6 -4
@@ -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,
net/core/dev.c +1 -0
@@ -4900,6 +4900,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)trace_consume_skb (skb); elsetrace_kfree_skb (skb ,net_tx_action , +SKB_DROP_FUNC ,SKB_DROP_LINE );if (skb->fclone !=SKB_FCLONE_UNAVAILABLE )
net/core/skbuff.c +6 -3
@@ -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);
net/ipv4/tcp_ipv4.c +1 -1
@@ -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:
net/ipv4/udp.c +2 -2
@@ -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 ; }
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH RFC 2/4] net: skb: add function name as part of reason
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Dongli,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on net/master]
[also build test ERROR on horms-ipvs/master net-next/master linus/master v5.17-rc2 next-20220203] [cannot apply to rostedt-trace/for-next mst-vhost/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 4a81f6da9cb2d1ef911131a6fd8bd15cb61fc772 config: i386-randconfig-r012-20220131 (https://download.01.org/0day-ci/archive/20220204/202202040814.dnMvgmym-lkp(a)intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a73e4ce6a59b01f0e37037761c1e6889d539d233)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f23dbdfcd70917e6ee216f97a477bb3387731628
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dongli-Zhang/net-skb-to-use-function-line-pair-as-reason-for-kfree_skb_reason/20220203-234047 git checkout f23dbdfcd70917e6ee216f97a477bb3387731628
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash mm/ net/core/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
net/core/drop_monitor.c:114:10: warning: declaration of 'enum skb_drop_reason' will not be visible outside of this function [-Wvisibility]
enum skb_drop_reason reason);
^
net/core/drop_monitor.c:268:10: warning: declaration of 'enum skb_drop_reason' will not be visible outside of this function [-Wvisibility]
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:268:26: error: variable has incomplete type 'enum skb_drop_reason'
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:268:10: note: forward declaration of 'enum skb_drop_reason'
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:487:21: error: incompatible function pointer types initializing 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)' with an expression of type 'void (void *, struct sk_buff *, void *, enum skb_drop_reason)' [-Werror,-Wincompatible-function-pointer-types]
.kfree_skb_probe = trace_kfree_skb_hit,
^~~~~~~~~~~~~~~~~~~
net/core/drop_monitor.c:497:17: warning: declaration of 'enum skb_drop_reason' will not be visible outside of this function [-Wvisibility]
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:497:33: error: variable has incomplete type 'enum skb_drop_reason'
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:497:17: note: forward declaration of 'enum skb_drop_reason'
enum skb_drop_reason reason)
^
net/core/drop_monitor.c:986:21: error: incompatible function pointer types initializing 'void (*)(void *, struct sk_buff *, void *, enum skb_drop_reason)' with an expression of type 'void (void *, struct sk_buff *, void *, enum skb_drop_reason)' [-Werror,-Wincompatible-function-pointer-types]
.kfree_skb_probe = net_dm_packet_trace_kfree_skb_hit,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/core/drop_monitor.c:1136:32: error: incompatible function pointer types passing 'void (*const)(void *, struct sk_buff *, void *, enum skb_drop_reason)' to parameter of type 'void (*)(void *, struct sk_buff *, void *, const char *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types]
rc = register_trace_kfree_skb(ops->kfree_skb_probe, NULL);
^~~~~~~~~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: passing argument to parameter 'probe' here
TRACE_EVENT(kfree_skb,
^
include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
^
include/linux/tracepoint.h:419:2: note: expanded from macro 'DECLARE_TRACE'
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
^
include/linux/tracepoint.h:260:31: note: expanded from macro '__DECLARE_TRACE'
register_trace_##name(void (*probe)(data_proto), void *data) \
^
net/core/drop_monitor.c:1151:29: error: incompatible function pointer types passing 'void (*const)(void *, struct sk_buff *, void *, enum skb_drop_reason)' to parameter of type 'void (*)(void *, struct sk_buff *, void *, const char *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types]
unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
^~~~~~~~~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: passing argument to parameter 'probe' here
TRACE_EVENT(kfree_skb,
^
include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
^
include/linux/tracepoint.h:419:2: note: expanded from macro 'DECLARE_TRACE'
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
^
include/linux/tracepoint.h:273:33: note: expanded from macro '__DECLARE_TRACE'
unregister_trace_##name(void (*probe)(data_proto), void *data) \
^
net/core/drop_monitor.c:1175:29: error: incompatible function pointer types passing 'void (*const)(void *, struct sk_buff *, void *, enum skb_drop_reason)' to parameter of type 'void (*)(void *, struct sk_buff *, void *, const char *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types]
unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
^~~~~~~~~~~~~~~~~~~~
include/trace/events/skb.h:15:1: note: passing argument to parameter 'probe' here
TRACE_EVENT(kfree_skb,
^
include/linux/tracepoint.h:553:2: note: expanded from macro 'TRACE_EVENT'
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
^
include/linux/tracepoint.h:419:2: note: expanded from macro 'DECLARE_TRACE'
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
^
include/linux/tracepoint.h:273:33: note: expanded from macro '__DECLARE_TRACE'
unregister_trace_##name(void (*probe)(data_proto), void *data) \
^3 warnings and 7 errors generated.
vim +1136 net/core/drop_monitor.c
8e94c3bc922e70 Ido Schimmel 2019-08-17 1109
7c747838a55818 Ido Schimmel 2019-08-11 1110 static int net_dm_trace_on_set(struct netlink_ext_ack *extack)
9a8afc8d3962f3 Neil Horman 2009-03-11 1111 {
28315f7999870b Ido Schimmel 2019-08-11 1112 const struct net_dm_alert_ops *ops;
70c69274f354ec Ido Schimmel 2019-08-11 1113 int cpu, rc;
4b706372f18de5 Neil Horman 2010-07-20 1114
28315f7999870b Ido Schimmel 2019-08-11 1115 ops = net_dm_alert_ops_arr[net_dm_alert_mode];
28315f7999870b Ido Schimmel 2019-08-11 1116
cad456d5abbb63 Neil Horman 2012-05-17 1117 if (!try_module_get(THIS_MODULE)) {
965100966efe85 Ido Schimmel 2019-08-06 1118 NL_SET_ERR_MSG_MOD(extack, "Failed to take reference on module");
7c747838a55818 Ido Schimmel 2019-08-11 1119 return -ENODEV;
cad456d5abbb63 Neil Horman 2012-05-17 1120 }
cad456d5abbb63 Neil Horman 2012-05-17 1121
70c69274f354ec Ido Schimmel 2019-08-11 1122 for_each_possible_cpu(cpu) {
70c69274f354ec Ido Schimmel 2019-08-11 1123 struct per_cpu_dm_data *data = &per_cpu(dm_cpu_data, cpu);
44075f56379388 Ido Schimmel 2019-08-11 1124 struct sk_buff *skb;
70c69274f354ec Ido Schimmel 2019-08-11 1125
28315f7999870b Ido Schimmel 2019-08-11 1126 INIT_WORK(&data->dm_alert_work, ops->work_item_func);
70c69274f354ec Ido Schimmel 2019-08-11 1127 timer_setup(&data->send_timer, sched_send_work, 0);
44075f56379388 Ido Schimmel 2019-08-11 1128 /* Allocate a new per-CPU skb for the summary alert message and
44075f56379388 Ido Schimmel 2019-08-11 1129 * free the old one which might contain stale data from
44075f56379388 Ido Schimmel 2019-08-11 1130 * previous tracing.
44075f56379388 Ido Schimmel 2019-08-11 1131 */
44075f56379388 Ido Schimmel 2019-08-11 1132 skb = reset_per_cpu_data(data);
44075f56379388 Ido Schimmel 2019-08-11 1133 consume_skb(skb);
70c69274f354ec Ido Schimmel 2019-08-11 1134 }
70c69274f354ec Ido Schimmel 2019-08-11 1135
28315f7999870b Ido Schimmel 2019-08-11 @1136 rc = register_trace_kfree_skb(ops->kfree_skb_probe, NULL);
7c747838a55818 Ido Schimmel 2019-08-11 1137 if (rc) {
7c747838a55818 Ido Schimmel 2019-08-11 1138 NL_SET_ERR_MSG_MOD(extack, "Failed to connect probe to kfree_skb() tracepoint");
7c747838a55818 Ido Schimmel 2019-08-11 1139 goto err_module_put;
7c747838a55818 Ido Schimmel 2019-08-11 1140 }
cad456d5abbb63 Neil Horman 2012-05-17 1141
28315f7999870b Ido Schimmel 2019-08-11 1142 rc = register_trace_napi_poll(ops->napi_poll_probe, NULL);
7c747838a55818 Ido Schimmel 2019-08-11 1143 if (rc) {
7c747838a55818 Ido Schimmel 2019-08-11 1144 NL_SET_ERR_MSG_MOD(extack, "Failed to connect probe to napi_poll() tracepoint");
7c747838a55818 Ido Schimmel 2019-08-11 1145 goto err_unregister_trace;
7c747838a55818 Ido Schimmel 2019-08-11 1146 }
7c747838a55818 Ido Schimmel 2019-08-11 1147
7c747838a55818 Ido Schimmel 2019-08-11 1148 return 0;
7c747838a55818 Ido Schimmel 2019-08-11 1149
7c747838a55818 Ido Schimmel 2019-08-11 1150 err_unregister_trace:
28315f7999870b Ido Schimmel 2019-08-11 1151 unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
7c747838a55818 Ido Schimmel 2019-08-11 1152 err_module_put:
9398e9c0b1d44e Ido Schimmel 2021-03-10 1153 for_each_possible_cpu(cpu) {
9398e9c0b1d44e Ido Schimmel 2021-03-10 1154 struct per_cpu_dm_data *data = &per_cpu(dm_cpu_data, cpu);
9398e9c0b1d44e Ido Schimmel 2021-03-10 1155 struct sk_buff *skb;
9398e9c0b1d44e Ido Schimmel 2021-03-10 1156
9398e9c0b1d44e Ido Schimmel 2021-03-10 1157 del_timer_sync(&data->send_timer);
9398e9c0b1d44e Ido Schimmel 2021-03-10 1158 cancel_work_sync(&data->dm_alert_work);
9398e9c0b1d44e Ido Schimmel 2021-03-10 1159 while ((skb = __skb_dequeue(&data->drop_queue)))
9398e9c0b1d44e Ido Schimmel 2021-03-10 1160 consume_skb(skb);
9398e9c0b1d44e Ido Schimmel 2021-03-10 1161 }
7c747838a55818 Ido Schimmel 2019-08-11 1162 module_put(THIS_MODULE);
7c747838a55818 Ido Schimmel 2019-08-11 1163 return rc;
7c747838a55818 Ido Schimmel 2019-08-11 1164 }
7c747838a55818 Ido Schimmel 2019-08-11 1165 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
RFC PATCH 3/4 net: tun: track dropped skb via kfree_skb_reason()
In reply to Dongli ZhangThe 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.
--- drivers/net/tun.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/net/tun.c +25 -8
@@ -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; }
Signature · 1 line
2.17.1
RFC PATCH 4/4 net: tap: track dropped skb via kfree_skb_reason()
In reply to Dongli ZhangThe 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.
--- drivers/net/tap.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
drivers/net/tap.c +22 -8
@@ -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 ();
Signature · 1 line
2.17.1