diff options
author | Tom Herbert <therbert@google.com> | 2014-07-02 00:32:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-08 00:14:21 -0400 |
commit | 535fb8d006bc6a96d59558181a9a6f267be382c5 (patch) | |
tree | 044ec047776bdbc14bdcf93ae2b9068d349bdeef | |
parent | b8f1a55639e6a76cfd274cc7de76eafac9a15ca9 (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>
-rw-r--r-- | drivers/net/vxlan.c | 26 | ||||
-rw-r--r-- | include/net/vxlan.h | 2 | ||||
-rw-r--r-- | net/openvswitch/vport-vxlan.c | 5 |
3 files changed, 3 insertions, 30 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 | } | ||
1590 | EXPORT_SYMBOL_GPL(vxlan_src_port); | ||
1591 | |||
1592 | static inline struct sk_buff *vxlan_handle_offloads(struct sk_buff *skb, | 1573 | static 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; |
diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 12196ce661d9..d5f59f3fc35d 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h | |||
@@ -45,8 +45,6 @@ int vxlan_xmit_skb(struct vxlan_sock *vs, | |||
45 | __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, | 45 | __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, |
46 | __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); | 46 | __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); |
47 | 47 | ||
48 | __be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb); | ||
49 | |||
50 | /* IP header + UDP + VXLAN + Ethernet header */ | 48 | /* IP header + UDP + VXLAN + Ethernet header */ |
51 | #define VXLAN_HEADROOM (20 + 8 + 8 + 14) | 49 | #define VXLAN_HEADROOM (20 + 8 + 8 + 14) |
52 | /* IPv6 header + UDP + VXLAN + Ethernet header */ | 50 | /* IPv6 header + UDP + VXLAN + Ethernet header */ |
diff --git a/net/openvswitch/vport-vxlan.c b/net/openvswitch/vport-vxlan.c index 0edbd95c60e7..d8b7e247bebf 100644 --- a/net/openvswitch/vport-vxlan.c +++ b/net/openvswitch/vport-vxlan.c | |||
@@ -143,8 +143,6 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb) | |||
143 | struct rtable *rt; | 143 | struct rtable *rt; |
144 | struct flowi4 fl; | 144 | struct flowi4 fl; |
145 | __be16 src_port; | 145 | __be16 src_port; |
146 | int port_min; | ||
147 | int port_max; | ||
148 | __be16 df; | 146 | __be16 df; |
149 | int err; | 147 | int err; |
150 | 148 | ||
@@ -172,8 +170,7 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb) | |||
172 | 170 | ||
173 | skb->ignore_df = 1; | 171 | skb->ignore_df = 1; |
174 | 172 | ||
175 | inet_get_local_port_range(net, &port_min, &port_max); | 173 | src_port = udp_flow_src_port(net, skb, 0, 0, true); |
176 | src_port = vxlan_src_port(port_min, port_max, skb); | ||
177 | 174 | ||
178 | err = vxlan_xmit_skb(vxlan_port->vs, rt, skb, | 175 | err = vxlan_xmit_skb(vxlan_port->vs, rt, skb, |
179 | fl.saddr, OVS_CB(skb)->tun_key->ipv4_dst, | 176 | fl.saddr, OVS_CB(skb)->tun_key->ipv4_dst, |