Commit 6c76f3d2 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 12395d06 2090714e
...@@ -523,7 +523,8 @@ static struct rtable *gre_get_rt(struct sk_buff *skb, ...@@ -523,7 +523,8 @@ static struct rtable *gre_get_rt(struct sk_buff *skb,
return ip_route_output_key(net, fl); return ip_route_output_key(net, fl);
} }
static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
__be16 proto)
{ {
struct ip_tunnel_info *tun_info; struct ip_tunnel_info *tun_info;
const struct ip_tunnel_key *key; const struct ip_tunnel_key *key;
...@@ -575,7 +576,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -575,7 +576,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev)
} }
flags = tun_info->key.tun_flags & (TUNNEL_CSUM | TUNNEL_KEY); flags = tun_info->key.tun_flags & (TUNNEL_CSUM | TUNNEL_KEY);
build_header(skb, tunnel_hlen, flags, htons(ETH_P_TEB), build_header(skb, tunnel_hlen, flags, proto,
tunnel_id_to_key(tun_info->key.tun_id), 0); tunnel_id_to_key(tun_info->key.tun_id), 0);
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; 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,7 +617,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
const struct iphdr *tnl_params; const struct iphdr *tnl_params;
if (tunnel->collect_md) { if (tunnel->collect_md) {
gre_fb_xmit(skb, dev); gre_fb_xmit(skb, dev, skb->protocol);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -660,7 +661,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb, ...@@ -660,7 +661,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
if (tunnel->collect_md) { if (tunnel->collect_md) {
gre_fb_xmit(skb, dev); gre_fb_xmit(skb, dev, htons(ETH_P_TEB));
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -893,7 +894,7 @@ static int ipgre_tunnel_init(struct net_device *dev) ...@@ -893,7 +894,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
netif_keep_dst(dev); netif_keep_dst(dev);
dev->addr_len = 4; dev->addr_len = 4;
if (iph->daddr) { if (iph->daddr && !tunnel->collect_md) {
#ifdef CONFIG_NET_IPGRE_BROADCAST #ifdef CONFIG_NET_IPGRE_BROADCAST
if (ipv4_is_multicast(iph->daddr)) { if (ipv4_is_multicast(iph->daddr)) {
if (!iph->saddr) if (!iph->saddr)
...@@ -902,8 +903,9 @@ static int ipgre_tunnel_init(struct net_device *dev) ...@@ -902,8 +903,9 @@ static int ipgre_tunnel_init(struct net_device *dev)
dev->header_ops = &ipgre_header_ops; dev->header_ops = &ipgre_header_ops;
} }
#endif #endif
} else } else if (!tunnel->collect_md) {
dev->header_ops = &ipgre_header_ops; dev->header_ops = &ipgre_header_ops;
}
return ip_tunnel_init(dev); return ip_tunnel_init(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment