netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] doc: extend description of fib expression
Date: Tue, 22 Oct 2024 13:34:37 +0200	[thread overview]
Message-ID: <ZxeNzTZLxw1NdgL2@calendula> (raw)
In-Reply-To: <20241018120825.GC28324@breakpoint.cc>

On Fri, Oct 18, 2024 at 02:08:25PM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > -|Keyword| Description| Type
> > > +|flag| Description
> > > +|daddr| Perform a normal route lookup: search fib for route to the *destination address* of the packet.
> > > +|saddr| Perform a reverse route lookup: search the fib for route to the *source address* of the packet.
> > > +|mark | consider the packet mark (nfmark) when querying the fib.
> > > +|iif  | fail fib lookup unless route exists and its output interface is identical to the packets input interface
> > 
> > maybe easier to understand?
> > 
> >            if fib lookups provides a route then check its output interface is identical to the packets *input* interface.
> > 
> > > +|oif  | fail fib lookup unless route exists and its output interface is identical to the packets output interface.
> > 
> >            if fib lookups provides a route then check its output interface is identical to the packets *output* interface.
> 
> Its better, updated, thanks.
> 
> > > This flag can only be used with the *type* result.
> > 
> > Are you sure 'oif' can only be used with type? I can see NFTA_FIB_F_OIF is available in nft_fib4_eval()
> > 
> >         if (priv->flags & NFTA_FIB_F_OIF)
> >                 oif = nft_out(pkt);
> >         else if (priv->flags & NFTA_FIB_F_IIF)
> >                 oif = nft_in(pkt);
> >         else
> >                 oif = NULL;
> 
> Seems to be dead code.  nft_fib_init() has:
>         switch (priv->result) {
>         case NFT_FIB_RESULT_OIF:
>                 if (priv->flags & NFTA_FIB_F_OIF)
>                         return -EINVAL;
>                 len = sizeof(int);
>                 break;
>         case NFT_FIB_RESULT_OIFNAME:
>                 if (priv->flags & NFTA_FIB_F_OIF)
>                         return -EINVAL;
>                 len = IFNAMSIZ;
> 
> 
> since _OIF and _OIFNAME was restricted to prerouting, nf hookfn has NULL
> output interface, so there is nothing we could compare against.
> 
> Now its available in forward too so it could be selectively relaxed for
> this, but, what is the use case?
> 
> Do a RPF in forward, then we need to compare vs. incoming interface.

This is for an esoteric scenario: Policy-based routing using input
interface as key. The fib rule for RPF does not work from prerouting
because iif cannot be inferred, there is no way to know if route in
the reverse direction exists until the route lookup for this direction
is done.

commit be8be04e5ddb9842d4ff2c1e4eaeec6ca801c573
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Thu Mar 31 17:14:47 2022 +0200

    netfilter: nft_fib: reverse path filter for policy-based routing on iif

    If policy-based routing using the iif selector is used, then the fib
    expression fails to look up for the reverse path from the prerouting
    hook because the input interface cannot be inferred. In order to support
    this scenario, extend the fib expression to allow to use after the route
    lookup, from the forward hook.

> But for outgoing interface, we'd do a normal route lookup, but the stack
> already did that for us (as packet is already being forwarded).
>
> So what would be the desired outcome for a 'fib daddr . oif' check?

Hm, this always evaluates true from forward and any later hook.

I missing now, what is the point of . oif in general?

  reply	other threads:[~2024-10-22 11:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 13:37 [PATCH nft] doc: extend description of fib expression Florian Westphal
2024-10-12 16:35 ` Pablo Neira Ayuso
2024-10-18 12:08   ` Florian Westphal
2024-10-22 11:34     ` Pablo Neira Ayuso [this message]
2024-10-24 10:41       ` Florian Westphal
2024-10-28 23:05         ` Pablo Neira Ayuso

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=ZxeNzTZLxw1NdgL2@calendula \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).