Re: [PATCH] net: tcp_drop adds `reason` parameter for tracing

From: Jakub Kicinski
Date: Tue Aug 24 2021 - 10:20:52 EST


On Tue, 24 Aug 2021 05:51:40 -0700 Zhongya Yan wrote:
> +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
> +};

This is basically tracking the caller, each may have multiple reasons
for dropping. Is tracking the caller sufficient? Should we at least
make this a bitmask so we can set multiple bits (caller and more
precise reason)? Or are we going to add another field in that case?

> -static void tcp_drop(struct sock *sk, struct sk_buff *skb)
> +static void __tcp_drop(struct sock *sk,
> + struct sk_buff *skb)
> {
> sk_drops_add(sk, skb);
> __kfree_skb(skb);
> }

Why keep this function if there is only one caller?

> +/* tcp_drop whit reason,for epbf trace
> + */

This comment is (a) misspelled, (b) doesn't add much value.

> +static void tcp_drop(struct sock *sk, struct sk_buff *skb,
> + enum tcp_drop_reason reason)
> +{
> + trace_tcp_drop(sk, skb, reason);
> + __tcp_drop(sk, skb);
> +}