net: tcp_drop adds `reason` parameter for tracing v2
Subsystems (4)
PATCH 1/1 net: tcp_drop adds `reason` parameter for tracing v2
In this version, fix and modify some code issues. Changed the reason for tcp_drop from an enumeration to a mask and enumeration usage in the trace output.
By shifting __LINE__ left by 6 bits to accommodate the tcp_drop call method source, 6 bits are enough to use. This allows for a more granular identification of the reason for calling tcp_drop without conflicts and essentially without overflow. Example.
```
enum {
TCP_OFO_QUEUE = 1
}
reason = __LINE__ << 6
reason |= TCP_OFO_QUEUE
```Suggestions from Jakub Kicinski, Eric Dumazet, much appreciated.
Modified the expression of the enumeration, and the use of the output under the trace definition. Suggestion from Steven Rostedt. Thanks.
--- include/net/tcp.h | 18 +++--- include/trace/events/tcp.h | 39 +++++++++++-- net/ipv4/tcp_input.c | 114 ++++++++++++++++++++++--------------- 3 files changed, 112 insertions(+), 59 deletions(-)
include/net/tcp.h +11 -7
@@ -256,15 +256,19 @@ extern unsigned long tcp_memory_pressure;enum tcp_drop_reason {TCP_OFO_QUEUE =1 , -TCP_DATA_QUEUE_OFO =2 , -TCP_DATA_QUEUE =3 , -TCP_PRUNE_OFO_QUEUE =4 , -TCP_VALIDATE_INCOMING =5 , -TCP_RCV_ESTABLISHED =6 , -TCP_RCV_SYNSENT_STATE_PROCESS =7 , -TCP_RCV_STATE_PROCESS =8 +TCP_DATA_QUEUE_OFO , +TCP_DATA_QUEUE , +TCP_PRUNE_OFO_QUEUE , +TCP_VALIDATE_INCOMING , +TCP_RCV_ESTABLISHED , +TCP_RCV_SYNSENT_STATE_PROCESS , +TCP_RCV_STATE_PROCESS }; +#define TCP_DROP_MASK (line, code) ((line << 6) | code)/* reason for masking */ +#define TCP_DROP_LINE (mask) (mask >> 6)/* Cause decode to get unique identifier */ +#define TCP_DROP_CODE (mask) (mask&0x3F)/* Cause decode get function code */ +/* optimized version of sk_under_memory_pressure() for TCP sockets */ static inline bool tcp_under_memory_pressure (const struct sock *sk) {
include/trace/events/tcp.h +33 -6
@@ -371,8 +371,26 @@ DEFINE_EVENT(tcp_event_skb, tcp_bad_csum,TP_ARGS (skb) ); +// from author @{Steven Rostedt} +#define TCP_DROP_REASON \ + REASON_STRING(TCP_OFO_QUEUE, ofo_queue) \ + REASON_STRING(TCP_DATA_QUEUE_OFO, data_queue_ofo) \ + REASON_STRING(TCP_DATA_QUEUE, data_queue) \ + REASON_STRING(TCP_PRUNE_OFO_QUEUE, prune_ofo_queue) \ + REASON_STRING(TCP_VALIDATE_INCOMING, validate_incoming) \ + REASON_STRING(TCP_RCV_ESTABLISHED, rcv_established) \ + REASON_STRING(TCP_RCV_SYNSENT_STATE_PROCESS, rcv_synsent_state_process) \ + REASON_STRINGe(TCP_RCV_STATE_PROCESS, rcv_state_proces) + +#undef REASON_STRING +#undef REASON_STRINGe + +#define REASON_STRING (code, name) {code , #name}, +#define REASON_STRINGe (code, name) {code, #name} + + TRACE_EVENT(tcp_drop, - TP_PROTO(struct sock *sk, struct sk_buff *skb, enum tcp_drop_reason reason), + TP_PROTO(struct sock *sk, struct sk_buff *skb, __u32 reason), TP_ARGS(sk, skb, reason),
@@ -392,6 +410,8 @@ TRACE_EVENT(tcp_drop, __field(__u32, rcv_wnd) __field(__u64, sock_cookie) __field(__u32, reason) + __field(__u32, reason_code) +__field (__u32, reason_line) ), TP_fast_assign(
@@ -415,16 +435,23 @@ TRACE_EVENT(tcp_drop, __entry->snd_wnd = tp->snd_wnd; __entry->rcv_wnd = tp->rcv_wnd; __entry->ssthresh =tcp_current_ssthresh (sk); - __entry->srtt = tp->srtt_us >>3 ; - __entry->sock_cookie =sock_gen_cookie (sk); - __entry->reason = reason; + __entry->srtt = tp->srtt_us >>3 ; + __entry->sock_cookie =sock_gen_cookie (sk); + __entry->reason = reason; + __entry->reason_code =TCP_DROP_CODE (reason); + __entry->reason_line =TCP_DROP_LINE (reason); ), -TP_printk ("src=%pISpc dest=%pISpc mark=%#x data_len=%d snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u sock_cookie=%llx reason=%d" , +TP_printk ("src=%pISpc dest=%pISpc mark=%#x data_len=%d snd_nxt=%#x snd_una=%#x \ +snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u \ +sock_cookie=%llx reason=%d reason_type=%s reason_line=%d" , __entry->saddr, __entry->daddr, __entry->mark, __entry->data_len, __entry->snd_nxt, __entry->snd_una, __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd, - __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie, __entry->reason) + __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie, + __entry->reason, +__print_symbolic (__entry->reason_code,TCP_DROP_REASON ), + __entry->reason_line) );#endif /* _TRACE_TCP_H */
net/ipv4/tcp_input.c +68 -46
268 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 5 lines · Zhongya Yan
In this version, fix and modify some code issues. Changed the reason for
tcp_dropfrom an enumeration to a mask and enumeration usage in the trace output.
By shifting__LINE__left by 6 bits to accommodate thetcp_dropcall method source, 6 bits are enough to use. This allows for a more granular identification of the reason for callingtcp_dropwithout conflicts and essentially without overflow. Example.
```
...
*/
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));
I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.
If you really want to include __FILE__ and __LINE__, these both can be stringified and included in the report, with the help of macros.
Jakub Kicinski
maintainerQuoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines · Zhongya Yan
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057
Yeah, the line number seems like a particularly bad idea. Hopefully strings won't be problematic, given we can expect most serious users to feed the tracepoints via BPF. enum would be more convenient there, I'd think.
Quoted 3 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.
I'm slightly surprised by this angle. Are there downstream kernels with heavily modified TCP other than Google's?
Quoted 2 lines
If you really want to include
__FILE__and__LINE__, these both can be stringified and included in the report, with the help of macros.
Quoted 19 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines · Zhongya Yan
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057Yeah, the line number seems like a particularly bad idea. Hopefully strings won't be problematic, given we can expect most serious users to feed the tracepoints via BPF. enum would be more convenient there, I'd think.
Quoted 6 lines
Quoted 3 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.I'm slightly surprised by this angle. Are there downstream kernels with heavily modified TCP other than Google's?
Not sure why Google is mentioned here ?
Have you ever received a public report about TCP behavior in a Google kernel ?
Over the years, we received hundreds of TCP bug reports on netdev@vger, where users claim to use kernel version 4.19 (or other), when in fact they use 4.19.xxx
It takes in general multiple emails exchange before we get a more realistic version number.
Not to mention distro kernels, or even worse private kernels, which are not exactly easy to track for us upstream developers.
Jakub Kicinski
maintainerQuoted 15 lines · On Wed, 25 Aug 2021 09:20:37 -0700 Eric Dumazet wrote:
Quoted 14 lines · Jakub Kicinski
Quoted 3 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet wrote:
I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057Yeah, the line number seems like a particularly bad idea. Hopefully strings won't be problematic, given we can expect most serious users to feed the tracepoints via BPF. enum would be more convenient there, I'd think.
Quoted 3 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.
Quoted 5 lines
Quoted 2 lines
I'm slightly surprised by this angle. Are there downstream kernels with heavily modified TCP other than Google's?
Not sure why Google is mentioned here ?
Have you ever received a public report about TCP behavior in a Google kernel ?
That's a rhetorical question quite likely, but to be clear - what I meant is that Google is the main contributor to Linux TCP and has the expertise to make changes. I don't know of any others hence the question.
Quoted 7 lines
Over the years, we received hundreds of TCP bug reports on netdev@vger, where users claim to use kernel version 4.19 (or other), when in fact they use 4.19.xxx
It takes in general multiple emails exchange before we get a more realistic version number.
Not to mention distro kernels, or even worse private kernels, which are not exactly easy to track for us upstream developers.
Right but for backports values come from original patch, enum or string.
I don't mean to dispute your preference tho, if you want strings, strings it is.
Steven Rostedt
maintainerQuoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet <[email protected]> wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057
Quoted 6 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.If you really want to include
__FILE__and__LINE__, these both can be stringified and included in the report, with the help of macros.
I agree the __LINE__ is pointless, but if this has a tracepoint involved, then you can simply enable the stacktrace trigger to it and it will save a stack trace in the ring buffer for you.
echo stacktrace > /sys/kernel/tracing/events/tcp/tcp_drop/trigger
And when the event triggers it will record a stack trace. You can also even add a filter to do it only for specific reasons.
echo 'stacktrace if reason == 1' > /sys/kernel/tracing/events/tcp/tcp_drop/trigger
And it even works for flags:
echo 'stacktrace if reason & 0xa' > /sys/kernel/tracing/events/tcp/tcp_drop/trigger
Which gives another reason to use an enum over a string.
-- Steve
Quoted 31 lines · Steven Rostedt
Quoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet <[email protected]> wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057Quoted 6 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.If you really want to include
__FILE__and__LINE__, these both can be stringified and included in the report, with the help of macros.I agree the
__LINE__is pointless, but if this has a tracepoint involved, then you can simply enable the stacktrace trigger to it and it will save a stack trace in the ring buffer for you.echo stacktrace >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd when the event triggers it will record a stack trace. You can also even add a filter to do it only for specific reasons.
Quoted 7 lines
echo 'stacktrace if reason == 1' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd it even works for flags:
echo 'stacktrace if reason & 0xa' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerWhich gives another reason to use an enum over a string.
You can't do string comparisons? The more string support Ftrace has, the more convenient they will be. Using bpftrace as an example of convenience and showing drop frequency counted by human-readable reason and stack trace:
# bpftrace -e 'k:tcp_drop { @[str(arg2), kstack] = count(); }'Don't need further translation beyond the str(arg2). And filtering on backlog drops:
bpftrace -e 'k:tcp_drop /str(arg2) == "SYN backlog drop"/ { @[kstack] = count(); }'
etc. (Although ultimately we'll want a tracepoint added in tcp_drop with those arguments.) If it's a enum I'll need to translate it back, and deal with enum additions that my tool might not be coded for. I can do it, it just needs maintenance, e.g. [0]. Plus the kernel code needs maintenance. For a narrow observability use case, it starts to feel like overkill to maintain an enum.
I wouldn't mind an optional _additional_ reason argument that's the enum SNMP counter if appropriate. E.g.:
tcpdrop(sk, skb, "Accept backlog full", LINUX_MIB_LISTENDROPS); tcpdrop(sk, skb, "No route", LINUX_MIB_LISTENDROPS);
So you could trace LINUX_MIB_LISTENDROPS and see different string reasons for each different code path.
I don't feel strongly about having __LINE__. I'd look it up from the stack trace anyway.
Brendan
Steven Rostedt
maintainerQuoted 36 lines · On Thu, 26 Aug 2021 15:13:07 +1000 Brendan Gregg <[email protected]>…
Quoted 35 lines · Steven Rostedt
Quoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet <[email protected]> wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057Quoted 6 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.If you really want to include
__FILE__and__LINE__, these both can be stringified and included in the report, with the help of macros.I agree the
__LINE__is pointless, but if this has a tracepoint involved, then you can simply enable the stacktrace trigger to it and it will save a stack trace in the ring buffer for you.echo stacktrace >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd when the event triggers it will record a stack trace. You can also even add a filter to do it only for specific reasons.
echo 'stacktrace if reason == 1' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd it even works for flags:
Quoted 8 lines
Quoted 3 lines
echo 'stacktrace if reason & 0xa' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerWhich gives another reason to use an enum over a string.
You can't do string comparisons? The more string support Ftrace has, the more convenient they will be. Using bpftrace as an example of convenience and showing drop frequency counted by human-readable reason and stack trace:
Yes, you can (and pretty much always had this ability), but having flags is usually makes it easier (and faster).
You can have 'stacktrace if reason ~ "*string*"' which will match anything with "string" in it.
My main argument against strings is more of the space they take up in the ring buffer than the ability to filter.
-- Steve
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity and top posting.
Quoted 49 lines · Steven Rostedt
Quoted 36 lines · On Thu, 26 Aug 2021 15:13:07 +1000 Brendan Gregg <[email protected]>…
Quoted 35 lines · Steven Rostedt
Quoted 11 lines · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet <[email protected]> wrote:
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, · line 5703
Quoted 6 lines
net/ipv4/tcp_input.c +1
-1@@ -5703,15 +5700,15 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,TCP_INC_STATS (sock_net (sk),TCP_MIB_INERRS );NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPSYNCHALLENGE );tcp_send_challenge_ack (sk, skb); - goto discard; +tcp_drop (sk, skb,TCP_DROP_MASK (__LINE__,TCP_VALIDATE_INCOMING ));I'd rather use a string. So that we can more easily identify _why_ the packet was drop, without looking at the source code
of the exact kernel version to locate line number 1057Quoted 6 lines
You can be sure that we will get reports in the future from users of heavily modified kernels.
Having to download a git tree, or apply semi-private patches is a no go.If you really want to include
__FILE__and__LINE__, these both can be stringified and included in the report, with the help of macros.I agree the
__LINE__is pointless, but if this has a tracepoint involved, then you can simply enable the stacktrace trigger to it and it will save a stack trace in the ring buffer for you.echo stacktrace >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd when the event triggers it will record a stack trace. You can also even add a filter to do it only for specific reasons.
echo 'stacktrace if reason == 1' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerAnd it even works for flags:
Quoted 8 lines
Quoted 3 lines
echo 'stacktrace if reason & 0xa' > /sys/kernel/tracing/events/tcp/tcp_drop/triggerWhich gives another reason to use an enum over a string.
You can't do string comparisons? The more string support Ftrace has, the more convenient they will be. Using bpftrace as an example of convenience and showing drop frequency counted by human-readable reason and stack trace:
Quoted 8 lines
Yes, you can (and pretty much always had this ability), but having flags is usually makes it easier (and faster).
You can have 'stacktrace if reason ~ "*string*"' which will match anything with "string" in it.
My main argument against strings is more of the space they take up in the ring buffer than the ability to filter.
Understood the concern about size, but it seems the trace includes many things. Can we have an estimate of the size needed per event ?
If we do not use symbolic, but numbers, I am afraid this trace event will only be used by a few TCP experts.
+ TP_printk("src=%pISpc dest=%pISpc mark=%#x data_len=%d
snd_nxt=%#x snd_una=%#x \
+ snd_cwnd=%u ssthresh=%u snd_wnd=%u
srtt=%u rcv_wnd=%u \
+ sock_cookie=%llx reason=%d
reason_type=%s reason_line=%d",
__entry->saddr, __entry->daddr, __entry->mark,
__entry->data_len, __entry->snd_nxt,
__entry->snd_una,
__entry->snd_cwnd, __entry->ssthresh,__entry->snd_wnd,
- __entry->srtt, __entry->rcv_wnd,__entry->sock_cookie, __entry->reason)
+ __entry->srtt, __entry->rcv_wnd,__entry->sock_cookie,
+ __entry->reason,
+ __print_symbolic(__entry->reason_code,TCP_DROP_REASON),
+ __entry->reason_line)
);
Steven Rostedt
maintainerQuoted 73 lines · Eric Dumazet
Quoted 5 lines · Steven Rostedt
Quoted 1 line · On Thu, 26 Aug 2021 15:13:07 +1000 Brendan Gregg <[email protected]>…
On Thu, Aug 26, 2021 at 1:20 PM Steven Rostedt
Quoted 5 lines · <[email protected]> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 1 line · On Wed, 25 Aug 2021 08:47:46 -0700 Eric Dumazet <[email protected]> wrote:
Review static bool
Quoted 1 line
(quoted diff) +0
-0@@ -5703,15 +5700,15 @@ static booltcp_validate_incoming(struct sock *sk, struct
sk_buff*skb,Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review static bool · line 5700
Quoted 1 line
(quoted diff) +0
-0TCP_INC_STATS(sock_net(sk),
TCP_MIB_INERRS);Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review static bool · line 5701
Quoted 1 line
(quoted diff) +0
-0NET_INC_STATS(sock_net(sk),
LINUX_MIB_TCPSYNCHALLENGE);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
net/ipv4/tcp_input.c static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
Quoted 3 lines
net/ipv4/tcp_input.c +1
-1tcp_send_challenge_ack (sk, skb); - goto discard; + tcp_drop(sk, skb, TCP_DROP_MASK(__LINE__,
TCP_VALIDATE_INCOMING));Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I'd rather use a string. So that we can more easily identify
_why_ the
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
packet was drop, without looking at the source code of the exact kernel version to locate line number 1057
You can be sure that we will get reports in the future from
users of
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
heavily modified kernels.
Having to download a git tree, or apply semi-private patches isa no go.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If you really want to include
__FILE__and__LINE__, these bothcan be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
stringified and included in the report, with the help of
macros.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I agree the
__LINE__is pointless, but if this has a tracepoint involved, then you can simply enable the stacktrace trigger to itand
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
it will save a stack trace in the ring buffer for you.
echo stacktrace >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
And when the event triggers it will record a stack trace. You can
also
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
even add a filter to do it only for specific reasons.
echo 'stacktrace if reason == 1' >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
And it even works for flags:
echo 'stacktrace if reason & 0xa' >
/sys/kernel/tracing/events/tcp/tcp_drop/triggerQuoted 4 lines
Quoted 4 lines
Quoted 2 lines
Which gives another reason to use an enum over a string.
You can't do string comparisons? The more string support Ftrace
has,
Quoted 10 lines
Quoted 3 lines
the more convenient they will be. Using bpftrace as an example of convenience and showing drop frequency counted by human-readable reason and stack trace:
Yes, you can (and pretty much always had this ability), but having flags is usually makes it easier (and faster).
You can have 'stacktrace if reason ~ "*string*"' which will match anything with "string" in it.
Quoted 8 lines
Quoted 2 lines
My main argument against strings is more of the space they take up in the ring buffer than the ability to filter.
Understood the concern about size, but it seems the trace includes many things.
Can we have an estimate of the size needed per event ?
If we do not use symbolic, but numbers, I am afraid this trace event will only be used by a few TCP experts.
Note, the output is still text, not numeric, as the __print_symbolic() macro will convert the numbers to text.
Or is there another issue you have with the enum?
-- Steve
Quoted 21 lines
+ TP_printk("src=%pISpc dest=%pISpc mark=%#x data_len=%d
snd_nxt=%#x snd_una=%#x \
+ snd_cwnd=%u ssthresh=%u snd_wnd=%u
srtt=%u rcv_wnd=%u \
+ sock_cookie=%llx reason=%d
reason_type=%s reason_line=%d",__entry->saddr, __entry->daddr, __entry->mark, __entry->data_len, __entry->snd_nxt, __entry->snd_una, __entry->snd_cwnd, __entry->ssthresh,
__entry->snd_wnd,
-__entry->srtt,__entry->rcv_wnd,__entry->sock_cookie,__entry->reason)
+__entry->srtt,__entry->rcv_wnd,__entry->sock_cookie,(quoted diff) +2
-0+ __entry->reason, + __print_symbolic(__entry->reason_code,
TCP_DROP_REASON),
+__entry->reason_line)
);
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity and top posting.