[Enhance] - systemtap dropwatch.stp consider to add drop reason
xili@redhat.com
xili@redhat.com
Wed Sep 24 23:58:04 GMT 2025
Hi Systemtap Team,
Good day.
I notice that if the kernel with patch below, we can now the "reason"
in02'kfree_skb' tracepoint.
~~~
commit 4a0269b22519c17c6df1f066e92cd3e1776e9c88
Author: Antoine Tenart <atenart@redhat.com>
Date: Wed Jan 19 10:23:54 2022 +0100
net: skb: introduce kfree_skb_reason()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041931
Upstream Status: linux.git
Tested: Instructions in bz
commit c504e5c2f9648a1e5c2be01e8c3f59d394192bd3
Author: Menglong Dong <imagedong@tencent.com>
Date: Sun Jan 9 14:36:26 2022 +0800
net: skb: introduce kfree_skb_reason()
Introduce the interface kfree_skb_reason(), which is able to pass
the reason why the skb is dropped to 'kfree_skb' tracepoint.
Add the 'reason' field to 'trace_kfree_skb', therefor user can get
more detail information about abnormal skb with 'drop_monitor' or
eBPF.
All drop reasons are defined in the enum 'skb_drop_reason', and
they will be print as string in 'kfree_skb' tracepoint in format
of 'reason: XXX'.
( Maybe the reasons should be defined in a uapi header file, so that
user space can use them? )
~~~
More detail as blow02
~~~
# stap -L 'kernel.trace("kfree_skb")'
kernel.trace("skb:kfree_skb") $skb:struct sk_buff* $location:void*
$reason:enum skb_drop_reason $rx_sk:struct sock*
~~~
Currently, we have "
/usr/share/systemtap/examples/network/dropwatch.stp" as below02
~~~
# Array to hold the list of drop points we find
global locations
# Note when we turn the monitor on and off
probe begin { printf("Monitoring for dropped packets\n") }
probe end { printf("Stopping dropped packet monitor\n") }
# increment a drop counter for every location we drop at
probe kernel.trace("kfree_skb") { locations[$location] <<< 1 }
# Every 5 seconds report our drop locations
probe timer.sec(5)
{
printf("\n%s\n", ctime(gettimeofday_s()))
foreach (l in locations-) {
printf("%d packets dropped at %s\n",
@count(locations[l]), symdata(l))
}
delete locations
}
~~~
With drop reason patch, we can add this to dropwatch.stp as below to
show more info02
~~~
# Array to hold the list of drop points we find
global locations
# Note when we turn the monitor on and off
probe begin { printf("Monitoring for dropped packets with reason\n") }
probe end { printf("Stopping dropped packet monitor\n") }
#increment a drop counter for every location we drop at
probe kernel.trace("kfree_skb") { locations[$location,$reason] <<< 1 }
#Every 5 seconds report our drop locations
probe timer.sec(5)
{
printf("\n%s\n", ctime(gettimeofday_s()))
foreach ([l,r] in locations-) { printf("%d packets dropped at %s for
reason: %d\n", @count(locations[l,r]), symdata(l),r) }
delete locations
}
~~~
Example output will look like02
~~~
Wed Sep 24 04:14:20 2025
52 packets dropped at 0xffffffffb6232a1f for reason: 77
3 packets dropped at 0xffffffffb637909d for reason: 2
3 packets dropped at 0xffffffffb637bee0 for reason: 2
1 packets dropped at 0xffffffffb631baa1 for reason: 3
~~~
Then we can know the reason from kernel code "dropreason-core.h" 02; so
i think that would provide more info and help to understand the reason.
~~~
77 represents "SKB_DROP_REASON_QUEUE_PURGE" 02/**
@SKB_DROP_REASON_QUEUE_PURGE: bulk free. */
2 represents "SKB_DROP_REASON_NOT_SPECIFIED" /**
@SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */
3 represents "SKB_DROP_REASON_NO_SOCKET" /**
@SKB_DROP_REASON_NO_SOCKET: socket not found */
~~~
Any comments would be appreciated.
Regards
Sam
More information about the Systemtap
mailing list