[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9Su1r_EE51ErT3w@krikkit>
Date: Fri, 14 Mar 2025 23:33:58 +0100
From: Sabrina Dubroca <sd@...asysnail.net>
To: Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Simon Horman <horms@...nel.org>,
Jonathan Corbet <corbet@....net>
Subject: Re: [RFC PATCH 1/2] net: introduce per netns packet chains
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
Powered by blists - more mailing lists