Skip to contentSkip to conversation

ipvlan: Make skb->skb_iif track skb->dev for l3s mode

PATCH Applied Jianguo Wu 3 participants 3 messages Mar 9, 2023 – Mar 11, 2023

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 1/1 ipvlan: Make skb->skb_iif track skb->dev for l3s mode

From: Jianguo Wu <[email protected]>

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").
---
 drivers/net/ipvlan/ipvlan_l3s.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ipvlan/ipvlan_l3s.c +1 -0
index 943d26cbf39f..71712ea25403 100644
@@ -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:
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Thu, Mar 09, 2023 at 03:03:36AM CET, [email protected] wrote:

From: Jianguo Wu <[email protected]>

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").

---
drivers/net/ipvlan/ipvlan_l3s.c | 1 +

1 file changed, 1 insertion(+)
drivers/net/ipvlan/ipvlan_l3s.c +0 -0
index 943d26cbf39f..71712ea25403 100644

drivers/net/ipvlan/ipvlan_l3s.c static unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb, · line 104

Quoted 4 lines
drivers/net/ipvlan/ipvlan_l3s.c +1 -0
@@ -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.

Quoted 6 lines
drivers/net/ipvlan/ipvlan_l3s.c +0 -0
 	len = skb->len + ETH_HLEN;
 	ipvlan_count_rx(addr->master, len, true, false);

out:

Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Jianguo Wu
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 9 Mar 2023 10:03:36 +0800 you wrote:

From: Jianguo Wu <[email protected]>

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html