Patchwork [PATCHv2,3/8] vxlan: use ip_route_output

login
register
mail settings
Submitter stephen hemminger
Date Oct. 10, 2012, 6:35 a.m.
Message ID <20121010063623.533119759@vyatta.com>
Download mbox | patch
Permalink /patch/190557/
State Accepted
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Oct. 10, 2012, 6:35 a.m.
Select source address for VXLAN packet based on route destination
and don't lie to route code. VXLAN is not GRE.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 - zero flow structure



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/drivers/net/vxlan.c	2012-10-09 18:08:32.630456072 -0700
+++ b/drivers/net/vxlan.c	2012-10-09 18:08:33.466447793 -0700
@@ -680,9 +680,13 @@  static netdev_tx_t vxlan_xmit(struct sk_
 
 	hash = skb_get_rxhash(skb);
 
-	rt = ip_route_output_gre(dev_net(dev), &fl4, dst,
-				 vxlan->saddr, vxlan->vni,
-				 RT_TOS(tos), vxlan->link);
+	memset(&fl4, 0, sizeof(fl4));
+	fl4.flowi4_oif = vxlan->link;
+	fl4.flowi4_tos = RT_TOS(tos);
+	fl4.daddr = dst;
+	fl4.saddr = vxlan->saddr;
+
+	rt = ip_route_output_key(dev_net(dev), &fl4);
 	if (IS_ERR(rt)) {
 		netdev_dbg(dev, "no route to %pI4\n", &dst);
 		dev->stats.tx_carrier_errors++;
@@ -724,7 +728,7 @@  static netdev_tx_t vxlan_xmit(struct sk_
 	iph->frag_off	= df;
 	iph->protocol	= IPPROTO_UDP;
 	iph->tos	= vxlan_ecn_encap(tos, old_iph, skb);
-	iph->daddr	= fl4.daddr;
+	iph->daddr	= dst;
 	iph->saddr	= fl4.saddr;
 	iph->ttl	= ttl ? : ip4_dst_hoplimit(&rt->dst);