[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201111234301.GA3058@salvia>
Date: Thu, 12 Nov 2020 00:43:01 +0100
From: Pablo Neira Ayuso <pablo@...filter.org>
To: Martin Willi <martin@...ongswan.org>
Cc: David Ahern <dsahern@...nel.org>,
Shrijeet Mukherjee <shrijeet@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
netfilter-devel@...r.kernel.org
Subject: Re: [PATCH net] vrf: Fix fast path output packet handling with async
Netfilter rules
Hi Martin,
On Tue, Nov 10, 2020 at 04:02:13PM +0100, Martin Willi wrote:
> Hi Pablo,
>
> > > +static int vrf_output6_direct_finish(struct net *net, struct sock *sk,
> > > + struct sk_buff *skb)
> > > +{
> > > + vrf_finish_direct(skb);
> > > +
> > > + return vrf_ip6_local_out(net, sk, skb);
> > > +}
> > > +
> > > static int vrf_output6_direct(struct net *net, struct sock *sk,
> > > struct sk_buff *skb)
> > > {
> > > + int err = 1;
> > > +
> > > skb->protocol = htons(ETH_P_IPV6);
> > >
> > > - return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
> > > - net, sk, skb, NULL, skb->dev,
> > > - vrf_finish_direct,
> > > - !(IPCB(skb)->flags & IPSKB_REROUTED));
> > > + if (!(IPCB(skb)->flags & IPSKB_REROUTED))
> > > + err = nf_hook(NFPROTO_IPV6, NF_INET_POST_ROUTING, net, sk, skb,
> > > + NULL, skb->dev, vrf_output6_direct_finish);
> >
> > I might missing something... this looks very similar to NF_HOOK_COND
> > but it's open-coded.
> >
> > My question, could you still use NF_HOOK_COND?
> >
> > ret = NF_HOOK_COND(NFPROTO_IPV6, ..., vrf_output6_direct_finish);
> >
> > just update the okfn.
>
> I don't think this will work. The point of the patch is to have
> different paths for sync and async Netfilter rules: In the async case
> we call vrf_output6_direct_finish() to additionally do dst_output(). In
> the (existing) synchronous path we just do vrf_finish_direct() and let
> the caller do the dst_output().
>
> If we prefer a common okfn(), we could return 0 to omit dst_output() in
> ip/ip6_local_out(). This changes/extends the call stack for the common
> case, though, and this is what I've tried to avoid.
thanks for explaining.
> > > + if (likely(err == 1))
> >
> > I'd suggest you remove likely() here and elsewhere in this patch.
> > Just let the branch predictor make its work instead of assuming that
> > the ruleset accepts traffic.
>
> The likely() may be questionable, but I seems that is done in most
> places when checking for synchronous Netfilter completion. But I'm fine
> with changing these hunks, if you prefer.
I see, this likely() assumes that IPCB(skb)->flags & IPSKB_REROUTED is
actually unlikely to happen.
no objections from my side to this patch, thanks.
Powered by blists - more mailing lists