From: Paolo Abeni <pabeni@redhat.com>
To: Jesper Dangaard Brouer <hawk@kernel.org>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Cc: bpf@vger.kernel.org, "Eric Dumazet" <eric.dumazet@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Toke Høiland-Jørgensen" <toke@toke.dk>,
kernel-team@cloudflare.com, mfleming@cloudflare.com
Subject: Re: [PATCH net-next V2] net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC
Date: Tue, 13 May 2025 13:04:28 +0200 [thread overview]
Message-ID: <aac5b03d-1380-437a-9763-1069aff1fd8b@redhat.com> (raw)
In-Reply-To: <174680137188.1282310.4154030185267079690.stgit@firesoul>
On 5/9/25 4:36 PM, Jesper Dangaard Brouer wrote:
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index f5cf4d35d83e..cb31be77dd7e 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -1073,12 +1073,21 @@ bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
> return set_memory_rox((unsigned long)hdr, hdr->size >> PAGE_SHIFT);
> }
>
> -int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap);
> +int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap,
> + enum skb_drop_reason *reason);
> static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
> {
> - return sk_filter_trim_cap(sk, skb, 1);
> + enum skb_drop_reason ignore_reason;
> +
> + return sk_filter_trim_cap(sk, skb, 1, &ignore_reason);
> +}
I'm sorry to nit-pick but checkpatch is not happy about the lack of
black lines here, and I think an empty line would make the code more
readable.
[...]
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 03d20a98f8b7..a1e10a13f7c8 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5910,7 +5910,11 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
> dev_core_stats_rx_dropped_inc(skb->dev);
> else
> dev_core_stats_rx_nohandler_inc(skb->dev);
> - kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
> +
> + if (pfmemalloc)
> + kfree_skb_reason(skb, SKB_DROP_REASON_PFMEMALLOC);
> + else
> + kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
AFAICS we can reach here even if skb_orphan_frags_rx() fails and that
will be accounted as 'SKB_DROP_REASON_UNHANDLED_PROTO'. Perhaps it would
be better to let the 'goto out' caller set the drop reason? And also set
it to 'SKB_DROP_REASON_UNHANDLED_PROTO' in this block before the 'out:'
label.
[...]
> @@ -2637,6 +2635,7 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
> int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
> int proto)
> {
> + enum skb_drop_reason drop_reason;
> struct sock *sk = NULL;
> struct udphdr *uh;
> unsigned short ulen;
> @@ -2644,7 +2643,6 @@ 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;
>
> drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
>
The above 2 chunks look unrelated/unneeded. Since the patch is already
pretty big, I think it would be better to not include them.
Thanks,
Paolo
prev parent reply other threads:[~2025-05-13 11:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 14:36 [PATCH net-next V2] net: track pfmemalloc drops via SKB_DROP_REASON_PFMEMALLOC Jesper Dangaard Brouer
2025-05-13 11:04 ` Paolo Abeni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aac5b03d-1380-437a-9763-1069aff1fd8b@redhat.com \
--to=pabeni@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=hawk@kernel.org \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=mfleming@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=toke@toke.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox