From: Sabrina Dubroca <sd@queasysnail.net>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [RFC PATCH 1/2] net: introduce per netns packet chains
Date: Fri, 14 Mar 2025 23:33:58 +0100 [thread overview]
Message-ID: <Z9Su1r_EE51ErT3w@krikkit> (raw)
In-Reply-To: <19ab1d1a4e222833c407002ba5e6c64018d92b3e.1741957452.git.pabeni@redhat.com>
2025-03-14, 14:05:00 +0100, Paolo Abeni wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6fa6ed5b57987..00bdd8316cb5e 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -572,11 +572,19 @@ static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
>
> static inline struct list_head *ptype_head(const struct packet_type *pt)
> {
> - if (pt->type == htons(ETH_P_ALL))
> - return pt->dev ? &pt->dev->ptype_all : &net_hotdata.ptype_all;
> - else
> + if (pt->type == htons(ETH_P_ALL)) {
> + if (!pt->af_packet_net && !pt->dev)
> + return NULL;
> +
> return pt->dev ? &pt->dev->ptype_specific :
s/specific/all/ ?
(ie ETH_P_ALL with pt->dev should go on &pt->dev->ptype_all like before)
> - &ptype_base[ntohs(pt->type) & PTYPE_HASH_MASK];
> + &pt->af_packet_net->ptype_all;
> + }
> +
> + if (pt->dev)
> + return &pt->dev->ptype_specific;
> +
> + return pt->af_packet_net ? &pt->af_packet_net->ptype_specific :
> + &ptype_base[ntohs(pt->type) & PTYPE_HASH_MASK];
> }
[...]
> diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
> index fa6d3969734a6..8a5d93eb9d77a 100644
> --- a/net/core/net-procfs.c
> +++ b/net/core/net-procfs.c
[...]
> @@ -232,16 +233,15 @@ static void *ptype_seq_next(struct seq_file *seq, void *v, loff_t *pos)
> goto found;
> }
> }
> -
> - nxt = net_hotdata.ptype_all.next;
> - goto ptype_all;
> + nxt = net->ptype_all.next;
> + goto net_ptype_all;
> }
>
> - if (pt->type == htons(ETH_P_ALL)) {
> -ptype_all:
> - if (nxt != &net_hotdata.ptype_all)
> + if (pt->af_packet_net) {
> +net_ptype_all:
> + if (nxt != &net->ptype_all)
> goto found;
This is missing similar code to find items on the new
net->ptype_specific list.
I think something like:
if (pt->af_packet_net) {
net_ptype_all:
- if (nxt != &net->ptype_all)
+ if (nxt != &net->ptype_all && nxt != &net->ptype_specific)
goto found;
+ if (nxt == &net->ptype_all) {
+ /* continue with ->ptype_specific if it's not empty */
+ nxt = net->ptype_specific.next;
+ if (nxt != &net->ptype_specific)
+ goto found;
+ }
nxt = ptype_base[0].next;
} else
(and probably something in ptype_get_idx as well)
> - hash = 0;
hash will now be used uninitialized in the loop a bit later in the
function?
while (nxt == &ptype_base[hash]) {
> +
> nxt = ptype_base[0].next;
--
Sabrina
next prev parent reply other threads:[~2025-03-14 22:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 13:04 [RFC PATCH 0/2] net: introduce per netns packet type chains Paolo Abeni
2025-03-14 13:05 ` [RFC PATCH 1/2] net: introduce per netns packet chains Paolo Abeni
2025-03-14 22:33 ` Sabrina Dubroca [this message]
2025-03-17 8:40 ` Paolo Abeni
2025-03-17 8:43 ` Eric Dumazet
2025-03-17 9:23 ` Paolo Abeni
2025-03-17 10:46 ` Eric Dumazet
2025-03-14 13:05 ` [RFC PATCH 2/2] net: hotdata optimization for netns ptypes Paolo Abeni
2025-03-17 9:18 ` Paolo Abeni
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=Z9Su1r_EE51ErT3w@krikkit \
--to=sd@queasysnail.net \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.