core/dev: do not ignore dmac in dev_forward_skb()
Subsystems (3)
PATCH v2 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
Fix order of eth_type_trans() and skb_scrub_packet() in dev_forward_skb() and in ip_tunnel_rcv()
---
v2: fixing order in ip_tunnel_rcv() as suggested by Nicolas Isaku's test still works fine.
not touching ipv6 since I don't have testbed for it
net/core/dev.c | 6 +----- net/ipv4/ip_tunnel.c | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-)
net/core/dev.c +1 -5
@@ -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); }
net/ipv4/ip_tunnel.c +2 -2
@@ -454,6 +454,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, tstats->rx_bytes += skb->len;u64_stats_update_end (&tstats->syncp); +skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (tunnel->dev))); +if (tunnel->dev->type ==ARPHRD_ETHER ) { skb->protocol =eth_type_trans (skb, tunnel->dev);skb_postpull_rcsum (skb,eth_hdr (skb),ETH_HLEN );
@@ -461,8 +463,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, skb->dev = tunnel->dev; } -skb_scrub_packet (skb, !net_eq (tunnel->net,dev_net (tunnel->dev))); -gro_cells_receive (&tunnel->gro_cells, skb);return 0 ;
Signature · 1 line
1.7.9.5
David Miller
maintainerFrom: Alexei Starovoitov <[email protected]>
Date: Tue, 12 Nov 2013 14:39:13 -0800
Quoted 10 lines
commit
06a23fe31ca3
("core/dev: setpkt_typeaftereth_type_trans()indev_forward_skb()") and refactoring64261f230a91
("dev: moveskb_scrub_packet()aftereth_type_trans()")are forcing
pkt_typeto bePACKET_HOSTwhen skb traverses veth.which means that ip forwarding will kick in inside netns even if
skb->eth->h_dest!=dev->dev_addr
Quoted 8 lines
Fix order of
eth_type_trans()andskb_scrub_packet()indev_forward_skb()and inip_tunnel_rcv()Fixes 06a23fe31ca3 ("core/dev: set pkt_type after eth_type_trans() in dev_forward_skb()")CC Isaku Yamahata <[email protected]>CC Maciej Zenczykowski <[email protected]>CC Nicolas Dichtel <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>
Applied and queued up for -stable, thanks.