All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6: fix 'disable_policy' for fwd packets
@ 2021-07-06  9:13 Nicolas Dichtel
  2021-07-06 22:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dichtel @ 2021-07-06  9:13 UTC (permalink / raw)
  To: davem, kuba; +Cc: steffen.klassert, netdev, dforster, Nicolas Dichtel

The goal of commit df789fe75206 ("ipv6: Provide ipv6 version of
"disable_policy" sysctl") was to have the disable_policy from ipv4
available on ipv6.
However, it's not exactly the same mechanism. On IPv4, all packets coming
from an interface, which has disable_policy set, bypass the policy check.
For ipv6, this is done only for local packets, ie for packets destinated to
an address configured on the incoming interface.

Let's align ipv6 with ipv4 so that the 'disable_policy' sysctl has the same
effect for both protocols.

My first approach was to create a new kind of route cache entries, to be
able to set DST_NOPOLICY without modifying routes. This would have added a
lot of code. Because the local delivery path is already handled, I choose
to focus on the forwarding path to minimize code churn.

Fixes: df789fe75206 ("ipv6: Provide ipv6 version of "disable_policy" sysctl")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/ip6_output.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 984050f35c61..d4ee2169afd8 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -479,7 +479,9 @@ int ip6_forward(struct sk_buff *skb)
 	if (skb_warn_if_lro(skb))
 		goto drop;
 
-	if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) {
+	if (!net->ipv6.devconf_all->disable_policy &&
+	    !idev->cnf.disable_policy &&
+	    !xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) {
 		__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
 		goto drop;
 	}
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ipv6: fix 'disable_policy' for fwd packets
  2021-07-06  9:13 [PATCH net] ipv6: fix 'disable_policy' for fwd packets Nicolas Dichtel
@ 2021-07-06 22:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-06 22:30 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, kuba, steffen.klassert, netdev, dforster

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue,  6 Jul 2021 11:13:35 +0200 you wrote:
> The goal of commit df789fe75206 ("ipv6: Provide ipv6 version of
> "disable_policy" sysctl") was to have the disable_policy from ipv4
> available on ipv6.
> However, it's not exactly the same mechanism. On IPv4, all packets coming
> from an interface, which has disable_policy set, bypass the policy check.
> For ipv6, this is done only for local packets, ie for packets destinated to
> an address configured on the incoming interface.
> 
> [...]

Here is the summary with links:
  - [net] ipv6: fix 'disable_policy' for fwd packets
    https://git.kernel.org/netdev/net/c/ccd27f05ae7b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-06 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06  9:13 [PATCH net] ipv6: fix 'disable_policy' for fwd packets Nicolas Dichtel
2021-07-06 22:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.