diff mbox series

[PATCHv2,net] ipvlan: fix bound dev checking for IPv6 l3s mode

Message ID 20230609091502.3048339-1-liuhangbin@gmail.com (mailing list archive)
State Accepted
Commit ce57adc222aba32431c42632b396e9213d0eb0b8
Delegated to: Netdev Maintainers
Headers show
Series [PATCHv2,net] ipvlan: fix bound dev checking for IPv6 l3s mode | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 2 blamed authors not CCed: fw@strlen.de davem@davemloft.net; 6 maintainers not CCed: kuba@kernel.org fw@strlen.de davem@davemloft.net jiri@resnulli.us wujianguo@chinatelecom.cn edumazet@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hangbin Liu June 9, 2023, 9:15 a.m. UTC
The commit 59a0b022aa24 ("ipvlan: Make skb->skb_iif track skb->dev for l3s
mode") fixed ipvlan bonded dev checking by updating skb skb_iif. This fix
works for IPv4, as in raw_v4_input() the dif is from inet_iif(skb), which
is skb->skb_iif when there is no route.

But for IPv6, the fix is not enough, because in ipv6_raw_deliver() ->
raw_v6_match(), the dif is inet6_iif(skb), which is returns IP6CB(skb)->iif
instead of skb->skb_iif if it's not a l3_slave. To fix the IPv6 part
issue. Let's set IP6CB(skb)->iif to correct ifindex.

BTW, ipvlan handles NS/NA specifically. Since it works fine, I will not
reset IP6CB(skb)->iif when addr->atype is IPVL_ICMPV6.

Fixes: c675e06a98a4 ("ipvlan: decouple l3s mode dependencies from other modes")
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2196710
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
v2: set IP6CB(skb)->iif instead of setting IP6SKB_L3SLAVE flag
---
 drivers/net/ipvlan/ipvlan_l3s.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Larysa Zaremba June 9, 2023, 3:40 p.m. UTC | #1
On Fri, Jun 09, 2023 at 05:15:02PM +0800, Hangbin Liu wrote:
> The commit 59a0b022aa24 ("ipvlan: Make skb->skb_iif track skb->dev for l3s
> mode") fixed ipvlan bonded dev checking by updating skb skb_iif. This fix
> works for IPv4, as in raw_v4_input() the dif is from inet_iif(skb), which
> is skb->skb_iif when there is no route.
> 
> But for IPv6, the fix is not enough, because in ipv6_raw_deliver() ->
> raw_v6_match(), the dif is inet6_iif(skb), which is returns IP6CB(skb)->iif
> instead of skb->skb_iif if it's not a l3_slave. To fix the IPv6 part
> issue. Let's set IP6CB(skb)->iif to correct ifindex.
> 
> BTW, ipvlan handles NS/NA specifically. Since it works fine, I will not
> reset IP6CB(skb)->iif when addr->atype is IPVL_ICMPV6.
> 
> Fixes: c675e06a98a4 ("ipvlan: decouple l3s mode dependencies from other modes")
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2196710
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Despite broken prefix, unlike v1, this fix looks good.

Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>

> ---
> v2: set IP6CB(skb)->iif instead of setting IP6SKB_L3SLAVE flag
> ---
>  drivers/net/ipvlan/ipvlan_l3s.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ipvlan/ipvlan_l3s.c b/drivers/net/ipvlan/ipvlan_l3s.c
> index 71712ea25403..d5b05e803219 100644
> --- a/drivers/net/ipvlan/ipvlan_l3s.c
> +++ b/drivers/net/ipvlan/ipvlan_l3s.c
> @@ -102,6 +102,10 @@ static unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb,
>  
>  	skb->dev = addr->master->dev;
>  	skb->skb_iif = skb->dev->ifindex;
> +#if IS_ENABLED(CONFIG_IPV6)
> +	if (addr->atype == IPVL_IPV6)
> +		IP6CB(skb)->iif = skb->dev->ifindex;
> +#endif
>  	len = skb->len + ETH_HLEN;
>  	ipvlan_count_rx(addr->master, len, true, false);
>  out:
> -- 
> 2.38.1
> 
>
patchwork-bot+netdevbpf@kernel.org June 12, 2023, 8:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri,  9 Jun 2023 17:15:02 +0800 you wrote:
> The commit 59a0b022aa24 ("ipvlan: Make skb->skb_iif track skb->dev for l3s
> mode") fixed ipvlan bonded dev checking by updating skb skb_iif. This fix
> works for IPv4, as in raw_v4_input() the dif is from inet_iif(skb), which
> is skb->skb_iif when there is no route.
> 
> But for IPv6, the fix is not enough, because in ipv6_raw_deliver() ->
> raw_v6_match(), the dif is inet6_iif(skb), which is returns IP6CB(skb)->iif
> instead of skb->skb_iif if it's not a l3_slave. To fix the IPv6 part
> issue. Let's set IP6CB(skb)->iif to correct ifindex.
> 
> [...]

Here is the summary with links:
  - [PATCHv2,net] ipvlan: fix bound dev checking for IPv6 l3s mode
    https://git.kernel.org/netdev/net/c/ce57adc222ab

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ipvlan/ipvlan_l3s.c b/drivers/net/ipvlan/ipvlan_l3s.c
index 71712ea25403..d5b05e803219 100644
--- a/drivers/net/ipvlan/ipvlan_l3s.c
+++ b/drivers/net/ipvlan/ipvlan_l3s.c
@@ -102,6 +102,10 @@  static unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb,
 
 	skb->dev = addr->master->dev;
 	skb->skb_iif = skb->dev->ifindex;
+#if IS_ENABLED(CONFIG_IPV6)
+	if (addr->atype == IPVL_IPV6)
+		IP6CB(skb)->iif = skb->dev->ifindex;
+#endif
 	len = skb->len + ETH_HLEN;
 	ipvlan_count_rx(addr->master, len, true, false);
 out: