Skip to content

Commit

Permalink
vxlan: use dev->needed_headroom instead of dev->hard_header_len
Browse files Browse the repository at this point in the history
When we mirror packets from a vxlan tunnel to other device,
the mirror device should see the same packets (that is, without
outer header). Because vxlan tunnel sets dev->hard_header_len,
tcf_mirred() resets mac header back to outer mac, the mirror device
actually sees packets with outer headers

Vxlan tunnel should set dev->needed_headroom instead of
dev->hard_header_len, like what other ip tunnels do. This fixes
the above problem.

Cc: "David S. Miller" <[email protected]>
Cc: stephen hemminger <[email protected]>
Cc: Pravin B Shelar <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang1986 authored and davem330 committed Jun 13, 2014
1 parent 56f16c7 commit 2853af6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2247,9 +2247,9 @@ static void vxlan_setup(struct net_device *dev)
eth_hw_addr_random(dev);
ether_setup(dev);
if (vxlan->default_dst.remote_ip.sa.sa_family == AF_INET6)
dev->hard_header_len = ETH_HLEN + VXLAN6_HEADROOM;
dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM;
else
dev->hard_header_len = ETH_HLEN + VXLAN_HEADROOM;
dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM;

dev->netdev_ops = &vxlan_netdev_ops;
dev->destructor = free_netdev;
Expand Down Expand Up @@ -2646,8 +2646,7 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
if (!tb[IFLA_MTU])
dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);

/* update header length based on lower device */
dev->hard_header_len = lowerdev->hard_header_len +
dev->needed_headroom = lowerdev->hard_header_len +
(use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
} else if (use_ipv6)
vxlan->flags |= VXLAN_F_IPV6;
Expand Down

0 comments on commit 2853af6

Please sign in to comment.