diff options
author | David S. Miller <davem@davemloft.net> | 2016-04-28 17:02:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-28 17:02:45 -0400 |
commit | 6c76f3d2922115f4e1327a2dcce47e94453e3375 (patch) | |
tree | f8745a471e54642e31bd682dc16eadc1b09ff568 | |
parent | 12395d0647dd0e4a594e091925fc4f2705b986a1 (diff) | |
parent | 2090714e1d6e80979dd6926be22b0de9ca432273 (diff) |
Merge branch 'gre-lwt-fixes'
Jiri Benc says:
====================
gre: fix lwtunnel support
This patchset fixes a few bugs in ipgre metadata mode implementation.
As an example, in this setup:
ip a a 192.168.1.1/24 dev eth0
ip l a gre1 type gre external
ip l s gre1 up
ip a a 192.168.99.1/24 dev gre1
ip r a 192.168.99.2/32 encap ip dst 192.168.1.2 ttl 10 dev gre1
ping 192.168.99.2
the traffic does not go through before this patchset and does as expected
with it applied.
v3: Back to v1 in order not to break existing users. Dropped patch 3, will
be fixed in iproute2 instead.
v2: Rejecting invalid configuration, added patch 3, dropped patch for
ETH_P_TEB (will target net-next).
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/ip_gre.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index af5d1f38217f..f973e0a58993 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -523,7 +523,8 @@ static struct rtable *gre_get_rt(struct sk_buff *skb, | |||
523 | return ip_route_output_key(net, fl); | 523 | return ip_route_output_key(net, fl); |
524 | } | 524 | } |
525 | 525 | ||
526 | static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) | 526 | static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev, |
527 | __be16 proto) | ||
527 | { | 528 | { |
528 | struct ip_tunnel_info *tun_info; | 529 | struct ip_tunnel_info *tun_info; |
529 | const struct ip_tunnel_key *key; | 530 | const struct ip_tunnel_key *key; |
@@ -575,7 +576,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) | |||
575 | } | 576 | } |
576 | 577 | ||
577 | flags = tun_info->key.tun_flags & (TUNNEL_CSUM | TUNNEL_KEY); | 578 | flags = tun_info->key.tun_flags & (TUNNEL_CSUM | TUNNEL_KEY); |
578 | build_header(skb, tunnel_hlen, flags, htons(ETH_P_TEB), | 579 | build_header(skb, tunnel_hlen, flags, proto, |
579 | tunnel_id_to_key(tun_info->key.tun_id), 0); | 580 | tunnel_id_to_key(tun_info->key.tun_id), 0); |
580 | 581 | ||
581 | df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; | 582 | df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; |
@@ -616,7 +617,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, | |||
616 | const struct iphdr *tnl_params; | 617 | const struct iphdr *tnl_params; |
617 | 618 | ||
618 | if (tunnel->collect_md) { | 619 | if (tunnel->collect_md) { |
619 | gre_fb_xmit(skb, dev); | 620 | gre_fb_xmit(skb, dev, skb->protocol); |
620 | return NETDEV_TX_OK; | 621 | return NETDEV_TX_OK; |
621 | } | 622 | } |
622 | 623 | ||
@@ -660,7 +661,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb, | |||
660 | struct ip_tunnel *tunnel = netdev_priv(dev); | 661 | struct ip_tunnel *tunnel = netdev_priv(dev); |
661 | 662 | ||
662 | if (tunnel->collect_md) { | 663 | if (tunnel->collect_md) { |
663 | gre_fb_xmit(skb, dev); | 664 | gre_fb_xmit(skb, dev, htons(ETH_P_TEB)); |
664 | return NETDEV_TX_OK; | 665 | return NETDEV_TX_OK; |
665 | } | 666 | } |
666 | 667 | ||
@@ -893,7 +894,7 @@ static int ipgre_tunnel_init(struct net_device *dev) | |||
893 | netif_keep_dst(dev); | 894 | netif_keep_dst(dev); |
894 | dev->addr_len = 4; | 895 | dev->addr_len = 4; |
895 | 896 | ||
896 | if (iph->daddr) { | 897 | if (iph->daddr && !tunnel->collect_md) { |
897 | #ifdef CONFIG_NET_IPGRE_BROADCAST | 898 | #ifdef CONFIG_NET_IPGRE_BROADCAST |
898 | if (ipv4_is_multicast(iph->daddr)) { | 899 | if (ipv4_is_multicast(iph->daddr)) { |
899 | if (!iph->saddr) | 900 | if (!iph->saddr) |
@@ -902,8 +903,9 @@ static int ipgre_tunnel_init(struct net_device *dev) | |||
902 | dev->header_ops = &ipgre_header_ops; | 903 | dev->header_ops = &ipgre_header_ops; |
903 | } | 904 | } |
904 | #endif | 905 | #endif |
905 | } else | 906 | } else if (!tunnel->collect_md) { |
906 | dev->header_ops = &ipgre_header_ops; | 907 | dev->header_ops = &ipgre_header_ops; |
908 | } | ||
907 | 909 | ||
908 | return ip_tunnel_init(dev); | 910 | return ip_tunnel_init(dev); |
909 | } | 911 | } |