* [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector
@ 2024-05-17 15:38 Eric Garver
2024-05-17 15:44 ` Eric Garver
2024-05-20 9:36 ` Pablo Neira Ayuso
0 siblings, 2 replies; 5+ messages in thread
From: Eric Garver @ 2024-05-17 15:38 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso, Florian Westphal
This removes the restriction of needing iif selector in the
forward/input hooks for fib lookups when requested result is
oif/oifname.
Removing this restriction allows "loose" lookups from the forward hooks.
Signed-off-by: Eric Garver <eric@garver.life>
---
net/ipv4/netfilter/nft_fib_ipv4.c | 3 +--
net/ipv6/netfilter/nft_fib_ipv6.c | 3 +--
net/netfilter/nft_fib.c | 8 +++-----
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
index 9eee535c64dd..975a4a809058 100644
--- a/net/ipv4/netfilter/nft_fib_ipv4.c
+++ b/net/ipv4/netfilter/nft_fib_ipv4.c
@@ -116,8 +116,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
fl4.daddr = iph->daddr;
fl4.saddr = get_saddr(iph->saddr);
} else {
- if (nft_hook(pkt) == NF_INET_FORWARD &&
- priv->flags & NFTA_FIB_F_IIF)
+ if (nft_hook(pkt) == NF_INET_FORWARD)
fl4.flowi4_iif = nft_out(pkt)->ifindex;
fl4.daddr = iph->saddr;
diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
index 36dc14b34388..f95e39e235d3 100644
--- a/net/ipv6/netfilter/nft_fib_ipv6.c
+++ b/net/ipv6/netfilter/nft_fib_ipv6.c
@@ -30,8 +30,7 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
fl6->daddr = iph->daddr;
fl6->saddr = iph->saddr;
} else {
- if (nft_hook(pkt) == NF_INET_FORWARD &&
- priv->flags & NFTA_FIB_F_IIF)
+ if (nft_hook(pkt) == NF_INET_FORWARD)
fl6->flowi6_iif = nft_out(pkt)->ifindex;
fl6->daddr = iph->saddr;
diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
index 37cfe6dd712d..b58f62195ff3 100644
--- a/net/netfilter/nft_fib.c
+++ b/net/netfilter/nft_fib.c
@@ -35,11 +35,9 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
switch (priv->result) {
case NFT_FIB_RESULT_OIF:
case NFT_FIB_RESULT_OIFNAME:
- hooks = (1 << NF_INET_PRE_ROUTING);
- if (priv->flags & NFTA_FIB_F_IIF) {
- hooks |= (1 << NF_INET_LOCAL_IN) |
- (1 << NF_INET_FORWARD);
- }
+ hooks = (1 << NF_INET_PRE_ROUTING) |
+ (1 << NF_INET_LOCAL_IN) |
+ (1 << NF_INET_FORWARD);
break;
case NFT_FIB_RESULT_ADDRTYPE:
if (priv->flags & NFTA_FIB_F_IIF)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector
2024-05-17 15:38 [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector Eric Garver
@ 2024-05-17 15:44 ` Eric Garver
2024-05-20 9:31 ` Pablo Neira Ayuso
2024-05-20 9:36 ` Pablo Neira Ayuso
1 sibling, 1 reply; 5+ messages in thread
From: Eric Garver @ 2024-05-17 15:44 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso, Florian Westphal
This is of course for nf-next, not net-next. I failed to update the
subject after sending it to the wrong list.
On Fri, May 17, 2024 at 11:38:06AM -0400, Eric Garver wrote:
> This removes the restriction of needing iif selector in the
> forward/input hooks for fib lookups when requested result is
> oif/oifname.
>
> Removing this restriction allows "loose" lookups from the forward hooks.
>
> Signed-off-by: Eric Garver <eric@garver.life>
> ---
> net/ipv4/netfilter/nft_fib_ipv4.c | 3 +--
> net/ipv6/netfilter/nft_fib_ipv6.c | 3 +--
> net/netfilter/nft_fib.c | 8 +++-----
> 3 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
> index 9eee535c64dd..975a4a809058 100644
> --- a/net/ipv4/netfilter/nft_fib_ipv4.c
> +++ b/net/ipv4/netfilter/nft_fib_ipv4.c
> @@ -116,8 +116,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
> fl4.daddr = iph->daddr;
> fl4.saddr = get_saddr(iph->saddr);
> } else {
> - if (nft_hook(pkt) == NF_INET_FORWARD &&
> - priv->flags & NFTA_FIB_F_IIF)
> + if (nft_hook(pkt) == NF_INET_FORWARD)
> fl4.flowi4_iif = nft_out(pkt)->ifindex;
>
> fl4.daddr = iph->saddr;
> diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
> index 36dc14b34388..f95e39e235d3 100644
> --- a/net/ipv6/netfilter/nft_fib_ipv6.c
> +++ b/net/ipv6/netfilter/nft_fib_ipv6.c
> @@ -30,8 +30,7 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
> fl6->daddr = iph->daddr;
> fl6->saddr = iph->saddr;
> } else {
> - if (nft_hook(pkt) == NF_INET_FORWARD &&
> - priv->flags & NFTA_FIB_F_IIF)
> + if (nft_hook(pkt) == NF_INET_FORWARD)
> fl6->flowi6_iif = nft_out(pkt)->ifindex;
>
> fl6->daddr = iph->saddr;
> diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
> index 37cfe6dd712d..b58f62195ff3 100644
> --- a/net/netfilter/nft_fib.c
> +++ b/net/netfilter/nft_fib.c
> @@ -35,11 +35,9 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
> switch (priv->result) {
> case NFT_FIB_RESULT_OIF:
> case NFT_FIB_RESULT_OIFNAME:
> - hooks = (1 << NF_INET_PRE_ROUTING);
> - if (priv->flags & NFTA_FIB_F_IIF) {
> - hooks |= (1 << NF_INET_LOCAL_IN) |
> - (1 << NF_INET_FORWARD);
> - }
> + hooks = (1 << NF_INET_PRE_ROUTING) |
> + (1 << NF_INET_LOCAL_IN) |
> + (1 << NF_INET_FORWARD);
> break;
> case NFT_FIB_RESULT_ADDRTYPE:
> if (priv->flags & NFTA_FIB_F_IIF)
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector
2024-05-17 15:44 ` Eric Garver
@ 2024-05-20 9:31 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-05-20 9:31 UTC (permalink / raw)
To: Eric Garver, netfilter-devel, Florian Westphal
Hi Eric,
On Fri, May 17, 2024 at 11:44:21AM -0400, Eric Garver wrote:
> This is of course for nf-next, not net-next. I failed to update the
> subject after sending it to the wrong list.
Thanks for your patch. Alternatively, I can place this in nf.git instead:
Fixes: be8be04e5ddb ("netfilter: nft_fib: reverse path filter for policy-based routing on iif")
> On Fri, May 17, 2024 at 11:38:06AM -0400, Eric Garver wrote:
> > This removes the restriction of needing iif selector in the
> > forward/input hooks for fib lookups when requested result is
> > oif/oifname.
> >
> > Removing this restriction allows "loose" lookups from the forward hooks.
> >
> > Signed-off-by: Eric Garver <eric@garver.life>
> > ---
> > net/ipv4/netfilter/nft_fib_ipv4.c | 3 +--
> > net/ipv6/netfilter/nft_fib_ipv6.c | 3 +--
> > net/netfilter/nft_fib.c | 8 +++-----
> > 3 files changed, 5 insertions(+), 9 deletions(-)
> >
> > diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
> > index 9eee535c64dd..975a4a809058 100644
> > --- a/net/ipv4/netfilter/nft_fib_ipv4.c
> > +++ b/net/ipv4/netfilter/nft_fib_ipv4.c
> > @@ -116,8 +116,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
> > fl4.daddr = iph->daddr;
> > fl4.saddr = get_saddr(iph->saddr);
> > } else {
> > - if (nft_hook(pkt) == NF_INET_FORWARD &&
> > - priv->flags & NFTA_FIB_F_IIF)
> > + if (nft_hook(pkt) == NF_INET_FORWARD)
> > fl4.flowi4_iif = nft_out(pkt)->ifindex;
> >
> > fl4.daddr = iph->saddr;
> > diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
> > index 36dc14b34388..f95e39e235d3 100644
> > --- a/net/ipv6/netfilter/nft_fib_ipv6.c
> > +++ b/net/ipv6/netfilter/nft_fib_ipv6.c
> > @@ -30,8 +30,7 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
> > fl6->daddr = iph->daddr;
> > fl6->saddr = iph->saddr;
> > } else {
> > - if (nft_hook(pkt) == NF_INET_FORWARD &&
> > - priv->flags & NFTA_FIB_F_IIF)
> > + if (nft_hook(pkt) == NF_INET_FORWARD)
> > fl6->flowi6_iif = nft_out(pkt)->ifindex;
> >
> > fl6->daddr = iph->saddr;
> > diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
> > index 37cfe6dd712d..b58f62195ff3 100644
> > --- a/net/netfilter/nft_fib.c
> > +++ b/net/netfilter/nft_fib.c
> > @@ -35,11 +35,9 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
> > switch (priv->result) {
> > case NFT_FIB_RESULT_OIF:
> > case NFT_FIB_RESULT_OIFNAME:
> > - hooks = (1 << NF_INET_PRE_ROUTING);
> > - if (priv->flags & NFTA_FIB_F_IIF) {
> > - hooks |= (1 << NF_INET_LOCAL_IN) |
> > - (1 << NF_INET_FORWARD);
> > - }
> > + hooks = (1 << NF_INET_PRE_ROUTING) |
> > + (1 << NF_INET_LOCAL_IN) |
> > + (1 << NF_INET_FORWARD);
> > break;
> > case NFT_FIB_RESULT_ADDRTYPE:
> > if (priv->flags & NFTA_FIB_F_IIF)
> > --
> > 2.43.0
> >
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector
2024-05-17 15:38 [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector Eric Garver
2024-05-17 15:44 ` Eric Garver
@ 2024-05-20 9:36 ` Pablo Neira Ayuso
2024-05-20 13:33 ` Eric Garver
1 sibling, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-05-20 9:36 UTC (permalink / raw)
To: Eric Garver; +Cc: netfilter-devel, Florian Westphal
BTW, one more comment below.
On Fri, May 17, 2024 at 11:38:06AM -0400, Eric Garver wrote:
> This removes the restriction of needing iif selector in the
> forward/input hooks for fib lookups when requested result is
> oif/oifname.
>
> Removing this restriction allows "loose" lookups from the forward hooks.
>
> Signed-off-by: Eric Garver <eric@garver.life>
> ---
> net/ipv4/netfilter/nft_fib_ipv4.c | 3 +--
> net/ipv6/netfilter/nft_fib_ipv6.c | 3 +--
> net/netfilter/nft_fib.c | 8 +++-----
> 3 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
> index 9eee535c64dd..975a4a809058 100644
> --- a/net/ipv4/netfilter/nft_fib_ipv4.c
> +++ b/net/ipv4/netfilter/nft_fib_ipv4.c
> @@ -116,8 +116,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
> fl4.daddr = iph->daddr;
> fl4.saddr = get_saddr(iph->saddr);
> } else {
> - if (nft_hook(pkt) == NF_INET_FORWARD &&
> - priv->flags & NFTA_FIB_F_IIF)
> + if (nft_hook(pkt) == NF_INET_FORWARD)
> fl4.flowi4_iif = nft_out(pkt)->ifindex;
is it intentional to remove for the priv->flags & NFTA_FIB_F_IIF here?
Maybe only the last chunk below is required?
> fl4.daddr = iph->saddr;
> diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
> index 36dc14b34388..f95e39e235d3 100644
> --- a/net/ipv6/netfilter/nft_fib_ipv6.c
> +++ b/net/ipv6/netfilter/nft_fib_ipv6.c
> @@ -30,8 +30,7 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
> fl6->daddr = iph->daddr;
> fl6->saddr = iph->saddr;
> } else {
> - if (nft_hook(pkt) == NF_INET_FORWARD &&
> - priv->flags & NFTA_FIB_F_IIF)
> + if (nft_hook(pkt) == NF_INET_FORWARD)
> fl6->flowi6_iif = nft_out(pkt)->ifindex;
>
> fl6->daddr = iph->saddr;
> diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
> index 37cfe6dd712d..b58f62195ff3 100644
> --- a/net/netfilter/nft_fib.c
> +++ b/net/netfilter/nft_fib.c
> @@ -35,11 +35,9 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
> switch (priv->result) {
> case NFT_FIB_RESULT_OIF:
> case NFT_FIB_RESULT_OIFNAME:
> - hooks = (1 << NF_INET_PRE_ROUTING);
> - if (priv->flags & NFTA_FIB_F_IIF) {
> - hooks |= (1 << NF_INET_LOCAL_IN) |
> - (1 << NF_INET_FORWARD);
> - }
> + hooks = (1 << NF_INET_PRE_ROUTING) |
> + (1 << NF_INET_LOCAL_IN) |
> + (1 << NF_INET_FORWARD);
I mean: This chunk alone to remove the hook restriction should be good?
Thanks.
> break;
> case NFT_FIB_RESULT_ADDRTYPE:
> if (priv->flags & NFTA_FIB_F_IIF)
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector
2024-05-20 9:36 ` Pablo Neira Ayuso
@ 2024-05-20 13:33 ` Eric Garver
0 siblings, 0 replies; 5+ messages in thread
From: Eric Garver @ 2024-05-20 13:33 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, Florian Westphal
On Mon, May 20, 2024 at 11:36:35AM +0200, Pablo Neira Ayuso wrote:
> BTW, one more comment below.
>
> On Fri, May 17, 2024 at 11:38:06AM -0400, Eric Garver wrote:
> > This removes the restriction of needing iif selector in the
> > forward/input hooks for fib lookups when requested result is
> > oif/oifname.
> >
> > Removing this restriction allows "loose" lookups from the forward hooks.
> >
> > Signed-off-by: Eric Garver <eric@garver.life>
> > ---
> > net/ipv4/netfilter/nft_fib_ipv4.c | 3 +--
> > net/ipv6/netfilter/nft_fib_ipv6.c | 3 +--
> > net/netfilter/nft_fib.c | 8 +++-----
> > 3 files changed, 5 insertions(+), 9 deletions(-)
> >
> > diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
> > index 9eee535c64dd..975a4a809058 100644
> > --- a/net/ipv4/netfilter/nft_fib_ipv4.c
> > +++ b/net/ipv4/netfilter/nft_fib_ipv4.c
> > @@ -116,8 +116,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
> > fl4.daddr = iph->daddr;
> > fl4.saddr = get_saddr(iph->saddr);
> > } else {
> > - if (nft_hook(pkt) == NF_INET_FORWARD &&
> > - priv->flags & NFTA_FIB_F_IIF)
> > + if (nft_hook(pkt) == NF_INET_FORWARD)
> > fl4.flowi4_iif = nft_out(pkt)->ifindex;
>
> is it intentional to remove for the priv->flags & NFTA_FIB_F_IIF here?
>
> Maybe only the last chunk below is required?
>
> > fl4.daddr = iph->saddr;
> > diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
> > index 36dc14b34388..f95e39e235d3 100644
> > --- a/net/ipv6/netfilter/nft_fib_ipv6.c
> > +++ b/net/ipv6/netfilter/nft_fib_ipv6.c
> > @@ -30,8 +30,7 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
> > fl6->daddr = iph->daddr;
> > fl6->saddr = iph->saddr;
> > } else {
> > - if (nft_hook(pkt) == NF_INET_FORWARD &&
> > - priv->flags & NFTA_FIB_F_IIF)
> > + if (nft_hook(pkt) == NF_INET_FORWARD)
> > fl6->flowi6_iif = nft_out(pkt)->ifindex;
> >
> > fl6->daddr = iph->saddr;
> > diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
> > index 37cfe6dd712d..b58f62195ff3 100644
> > --- a/net/netfilter/nft_fib.c
> > +++ b/net/netfilter/nft_fib.c
> > @@ -35,11 +35,9 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
> > switch (priv->result) {
> > case NFT_FIB_RESULT_OIF:
> > case NFT_FIB_RESULT_OIFNAME:
> > - hooks = (1 << NF_INET_PRE_ROUTING);
> > - if (priv->flags & NFTA_FIB_F_IIF) {
> > - hooks |= (1 << NF_INET_LOCAL_IN) |
> > - (1 << NF_INET_FORWARD);
> > - }
> > + hooks = (1 << NF_INET_PRE_ROUTING) |
> > + (1 << NF_INET_LOCAL_IN) |
> > + (1 << NF_INET_FORWARD);
>
> I mean: This chunk alone to remove the hook restriction should be good?
ACK. I'll retest and post a v2.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-20 13:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 15:38 [PATCH net-next] netfilter: nft_fib: allow from forward/input without iif selector Eric Garver
2024-05-17 15:44 ` Eric Garver
2024-05-20 9:31 ` Pablo Neira Ayuso
2024-05-20 9:36 ` Pablo Neira Ayuso
2024-05-20 13:33 ` Eric Garver
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).