diff mbox series

[net-next] ipvlan: Make skb->skb_iif track skb->dev for l3s mode

Message ID 29865b1f-6db7-c07a-de89-949d3721ea30@163.com (mailing list archive)
State Accepted
Commit 59a0b022aa249e3f5735d93de0849341722c4754
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ipvlan: Make skb->skb_iif track skb->dev for 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-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 20 this patch: 20
netdev/cc_maintainers warning 3 maintainers not CCed: kuba@kernel.org wujianguo@chinatelecom.cn pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
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 fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jianguo Wu March 9, 2023, 2:03 a.m. UTC
From: Jianguo Wu <wujianguo@chinatelecom.cn>

For l3s mode, skb->dev is set to ipvlan interface in ipvlan_nf_input():
  skb->dev = addr->master->dev
but, skb->skb_iif remain unchanged, this will cause socket lookup failed
if a target socket is bound to a interface, like the following example:

  ip link add ipvlan0 link eth0 type ipvlan mode l3s
  ip addr add dev ipvlan0 192.168.124.111/24
  ip link set ipvlan0 up

  ping -c 1 -I ipvlan0 8.8.8.8
  100% packet loss

This is because there is no match sk in __raw_v4_lookup() as sk->sk_bound_dev_if != dif(skb->skb_iif).
Fix this by make skb->skb_iif track skb->dev in ipvlan_nf_input().

Fixes: c675e06a98a4 ("ipvlan: decouple l3s mode dependencies from other modes").

Signed-off-by: Jianguo Wu <wujianguo@chinatelecom.cn>
---
 drivers/net/ipvlan/ipvlan_l3s.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jiri Pirko March 9, 2023, 11:10 a.m. UTC | #1
Thu, Mar 09, 2023 at 03:03:36AM CET, wujianguo106@163.com wrote:
>From: Jianguo Wu <wujianguo@chinatelecom.cn>
>
>For l3s mode, skb->dev is set to ipvlan interface in ipvlan_nf_input():
>  skb->dev = addr->master->dev
>but, skb->skb_iif remain unchanged, this will cause socket lookup failed
>if a target socket is bound to a interface, like the following example:
>
>  ip link add ipvlan0 link eth0 type ipvlan mode l3s
>  ip addr add dev ipvlan0 192.168.124.111/24
>  ip link set ipvlan0 up
>
>  ping -c 1 -I ipvlan0 8.8.8.8
>  100% packet loss
>
>This is because there is no match sk in __raw_v4_lookup() as sk->sk_bound_dev_if != dif(skb->skb_iif).
>Fix this by make skb->skb_iif track skb->dev in ipvlan_nf_input().
>
>Fixes: c675e06a98a4 ("ipvlan: decouple l3s mode dependencies from other modes").
>
>Signed-off-by: Jianguo Wu <wujianguo@chinatelecom.cn>
>---
> drivers/net/ipvlan/ipvlan_l3s.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/net/ipvlan/ipvlan_l3s.c b/drivers/net/ipvlan/ipvlan_l3s.c
>index 943d26cbf39f..71712ea25403 100644
>--- a/drivers/net/ipvlan/ipvlan_l3s.c
>+++ b/drivers/net/ipvlan/ipvlan_l3s.c
>@@ -101,6 +101,7 @@ static unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb,
> 		goto out;
>
> 	skb->dev = addr->master->dev;
>+	skb->skb_iif = skb->dev->ifindex;

I think we should have a macro to replace skb->dev which would handle
this too. It's on multiple places.

Anyway, this patch looks fine to me.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>



> 	len = skb->len + ETH_HLEN;
> 	ipvlan_count_rx(addr->master, len, true, false);
> out:
>-- 
>1.8.3.1
>
patchwork-bot+netdevbpf@kernel.org March 11, 2023, 5:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 9 Mar 2023 10:03:36 +0800 you wrote:
> From: Jianguo Wu <wujianguo@chinatelecom.cn>
> 
> For l3s mode, skb->dev is set to ipvlan interface in ipvlan_nf_input():
>   skb->dev = addr->master->dev
> but, skb->skb_iif remain unchanged, this will cause socket lookup failed
> if a target socket is bound to a interface, like the following example:
> 
> [...]

Here is the summary with links:
  - [net-next] ipvlan: Make skb->skb_iif track skb->dev for l3s mode
    https://git.kernel.org/netdev/net/c/59a0b022aa24

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 943d26cbf39f..71712ea25403 100644
--- a/drivers/net/ipvlan/ipvlan_l3s.c
+++ b/drivers/net/ipvlan/ipvlan_l3s.c
@@ -101,6 +101,7 @@  static unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb,
 		goto out;

 	skb->dev = addr->master->dev;
+	skb->skb_iif = skb->dev->ifindex;
 	len = skb->len + ETH_HLEN;
 	ipvlan_count_rx(addr->master, len, true, false);
 out: