[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iJfnuVx-sJdb70KwFgArz5mdC4jnkA6e7PADDbh2KxvGQ@mail.gmail.com>
Date: Wed, 19 Mar 2025 09:27:55 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, Simon Horman <horms@...nel.org>,
Sabrina Dubroca <sd@...asysnail.net>
Subject: Re: [PATCH v2] net: introduce per netns packet chains
On Tue, Mar 18, 2025 at 9:39 PM Paolo Abeni <pabeni@...hat.com> wrote:
>
> on 3/18/25 7:55 PM, Eric Dumazet wrote:
> > On Tue, Mar 18, 2025 at 7:03 PM Paolo Abeni <pabeni@...hat.com> wrote:
> >> @@ -2529,7 +2546,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
> >> pt_prev = ptype;
> >> }
> >>
> >> - if (ptype_list == &net_hotdata.ptype_all) {
> >> + if (ptype_list == &dev_net_rcu(dev)->ptype_all) {
> >
> > Using the following should be faster, generated code will be shorter.
>
> Right. I can do that in the next revision.
>
> >> @@ -5830,6 +5848,14 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
> >> deliver_ptype_list_skb(skb, &pt_prev, orig_dev, type,
> >> &ptype_base[ntohs(type) &
> >> PTYPE_HASH_MASK]);
> >> +
> >> + /* The only per net ptype user - packet socket - matches
> >> + * the target netns vs dev_net(skb->dev); we need to
> >> + * process only such netns even when orig_dev lays in a
> >> + * different one.
> >> + */
> >> + deliver_ptype_list_skb(skb, &pt_prev, orig_dev, type,
> >> + &dev_net_rcu(skb->dev)->ptype_specific);
> >
> > I am banging my head here. I probably need some sleep :)
>
> Let me rephrase. I think `skb->dev` and `orig_dev` potentially can be
> located in different netns; prior to this patch all the netns
> ptype_specific ptype for a given type were placed in the same ptype_base
> slot, and traversed by the first deliver_ptype_list_skb() call.
>
> Now we don't need to traverse the lists on both netns, as the ptype rcv
> function (packet_rcv) will ignore packets with dev_net(skb->dev) !=
> ptype->pf_packet_net.
>
> Does the above help?
Ah, I get it now, thanks.
Powered by blists - more mailing lists