aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-07-02 00:32:49 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 00:14:21 -0400
commit535fb8d006bc6a96d59558181a9a6f267be382c5 (patch)
tree044ec047776bdbc14bdcf93ae2b9068d349bdeef /drivers/net/vxlan.c
parentb8f1a55639e6a76cfd274cc7de76eafac9a15ca9 (diff)
vxlan: Call udp_flow_src_port
In vxlan and OVS vport-vxlan call common function to get source port for a UDP tunnel. Removed vxlan_src_port since the functionality is now in udp_flow_src_port. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ade33ef82823..c2d360150804 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1570,25 +1570,6 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
1570 return false; 1570 return false;
1571} 1571}
1572 1572
1573/* Compute source port for outgoing packet
1574 * first choice to use L4 flow hash since it will spread
1575 * better and maybe available from hardware
1576 * secondary choice is to use jhash on the Ethernet header
1577 */
1578__be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb)
1579{
1580 unsigned int range = (port_max - port_min) + 1;
1581 u32 hash;
1582
1583 hash = skb_get_hash(skb);
1584 if (!hash)
1585 hash = jhash(skb->data, 2 * ETH_ALEN,
1586 (__force u32) skb->protocol);
1587
1588 return htons((((u64) hash * range) >> 32) + port_min);
1589}
1590EXPORT_SYMBOL_GPL(vxlan_src_port);
1591
1592static inline struct sk_buff *vxlan_handle_offloads(struct sk_buff *skb, 1573static inline struct sk_buff *vxlan_handle_offloads(struct sk_buff *skb,
1593 bool udp_csum) 1574 bool udp_csum)
1594{ 1575{
@@ -1807,7 +1788,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1807 if (tos == 1) 1788 if (tos == 1)
1808 tos = ip_tunnel_get_dsfield(old_iph, skb); 1789 tos = ip_tunnel_get_dsfield(old_iph, skb);
1809 1790
1810 src_port = vxlan_src_port(vxlan->port_min, vxlan->port_max, skb); 1791 src_port = udp_flow_src_port(dev_net(dev), skb, vxlan->port_min,
1792 vxlan->port_max, true);
1811 1793
1812 if (dst->sa.sa_family == AF_INET) { 1794 if (dst->sa.sa_family == AF_INET) {
1813 memset(&fl4, 0, sizeof(fl4)); 1795 memset(&fl4, 0, sizeof(fl4));
@@ -2235,7 +2217,6 @@ static void vxlan_setup(struct net_device *dev)
2235{ 2217{
2236 struct vxlan_dev *vxlan = netdev_priv(dev); 2218 struct vxlan_dev *vxlan = netdev_priv(dev);
2237 unsigned int h; 2219 unsigned int h;
2238 int low, high;
2239 2220
2240 eth_hw_addr_random(dev); 2221 eth_hw_addr_random(dev);
2241 ether_setup(dev); 2222 ether_setup(dev);
@@ -2272,9 +2253,6 @@ static void vxlan_setup(struct net_device *dev)
2272 vxlan->age_timer.function = vxlan_cleanup; 2253 vxlan->age_timer.function = vxlan_cleanup;
2273 vxlan->age_timer.data = (unsigned long) vxlan; 2254 vxlan->age_timer.data = (unsigned long) vxlan;
2274 2255
2275 inet_get_local_port_range(dev_net(dev), &low, &high);
2276 vxlan->port_min = low;
2277 vxlan->port_max = high;
2278 vxlan->dst_port = htons(vxlan_port); 2256 vxlan->dst_port = htons(vxlan_port);
2279 2257
2280 vxlan->dev = dev; 2258 vxlan->dev = dev;