Skip to contentSkip to conversation

core/dev: do not ignore dmac in dev_forward_skb()

PATCH Superseded Alexei Starovoitov 4 participants 5 messages Nov 11, 2013 – Nov 12, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 core/dev: do not ignore dmac in dev_forward_skb()

commit 06a23fe31ca3
("core/dev: set pkt_type after eth_type_trans() in dev_forward_skb()") and refactoring 64261f230a91
("dev: move skb_scrub_packet() after eth_type_trans()")

are forcing pkt_type to be PACKET_HOST when skb traverses veth.

which means that ip forwarding will kick in inside netns even if skb->eth->h_dest != dev->dev_addr

Revert offending commit

Fixes 06a23fe31ca3 ("core/dev: set pkt_type after eth_type_trans() in dev_forward_skb()")
CC Maciej Zenczykowski <[email protected]>
CC Nicolas Dichtel <[email protected]>

---

commit-06a23fe31ca3's testcase is still working,
since pkt_type is now set by ip tunnel

the diff is for 3.12
imo the bug is severe enough that worth queueing for 3.11

 net/core/dev.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/core/dev.c +1 -5
index 3430b1e..2afc521 100644
@@ -1691,13 +1691,9 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
 		kfree_skb(skb);
 		return NET_RX_DROP;
 	}
-	skb->protocol = eth_type_trans(skb, dev);
 
-	/* eth_type_trans() can set pkt_type.
-	 * call skb_scrub_packet() after it to clear pkt_type _after_ calling
-	 * eth_type_trans().
-	 */
 	skb_scrub_packet(skb, true);
+	skb->protocol = eth_type_trans(skb, dev);
 
 	return netif_rx(skb);
 }
Signature · 1 line
1.7.9.5
#1 lore raw

Ack.

I'm sure this breaks whatever the original commit was trying to 'fix', however it does so in a clearly incorrect manner by effectively disabling dst mac address filtering.

#2 lore raw
Quoted 5 lines · Maciej Żenczykowski

Ack.

I'm sure this breaks whatever the original commit was trying to 'fix', however it does so in a clearly incorrect manner by effectively disabling dst mac address filtering.

actually it doesn't break it. Isaku's testcase works for me.

#3 lore raw
Quoted 9 lines · Alexei Starovoitov
Quoted 5 lines · Maciej Żenczykowski

Ack.

I'm sure this breaks whatever the original commit was trying to 'fix', however it does so in a clearly incorrect manner by effectively disabling dst mac address filtering.

actually it doesn't break it. Isaku's testcase works for me.

The changeset of 963a88b31ddbbe99f38502239b1a46601773d217
"tunnels: harmonize cleanup done on skb on xmit path"
addresses the issue by calling skb_scrub_packet() when sending skb through tunnel. So it is safe to revert it.

thanks,

Signature · 1 line
Isaku Yamahata <[email protected]>
#4 lore raw
In reply to Alexei Starovoitov
Quoted 10 lines · Alexei Starovoitov

commit 06a23fe31ca3
("core/dev: set pkt_type after eth_type_trans() in dev_forward_skb()") and refactoring 64261f230a91
("dev: move skb_scrub_packet() after eth_type_trans()")

are forcing pkt_type to be PACKET_HOST when skb traverses veth.

which means that ip forwarding will kick in inside netns even if skb->eth->h_dest != dev->dev_addr

Quoted 6 lines

Revert offending commit

Fixes 06a23fe31ca3 ("core/dev: set pkt_type after eth_type_trans() in dev_forward_skb()")
CC Maciej Zenczykowski <[email protected]>
CC Nicolas Dichtel <[email protected]>

skb_scrub_packet() is also called after eth_type_trans() in ip_tunnel_rcv(). I do it to be consistent with dev_forward_skb(), thus it should be inverted too.