Skip to content

Commit 535fb8d

Browse files
Tom Herbertdavem330
authored andcommitted
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>
1 parent b8f1a55 commit 535fb8d

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

drivers/net/vxlan.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,25 +1570,6 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
15701570
return false;
15711571
}
15721572

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-
15921573
static inline struct sk_buff *vxlan_handle_offloads(struct sk_buff *skb,
15931574
bool udp_csum)
15941575
{
@@ -1807,7 +1788,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
18071788
if (tos == 1)
18081789
tos = ip_tunnel_get_dsfield(old_iph, skb);
18091790

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);
18111793

18121794
if (dst->sa.sa_family == AF_INET) {
18131795
memset(&fl4, 0, sizeof(fl4));
@@ -2235,7 +2217,6 @@ static void vxlan_setup(struct net_device *dev)
22352217
{
22362218
struct vxlan_dev *vxlan = netdev_priv(dev);
22372219
unsigned int h;
2238-
int low, high;
22392220

22402221
eth_hw_addr_random(dev);
22412222
ether_setup(dev);
@@ -2272,9 +2253,6 @@ static void vxlan_setup(struct net_device *dev)
22722253
vxlan->age_timer.function = vxlan_cleanup;
22732254
vxlan->age_timer.data = (unsigned long) vxlan;
22742255

2275-
inet_get_local_port_range(dev_net(dev), &low, &high);
2276-
vxlan->port_min = low;
2277-
vxlan->port_max = high;
22782256
vxlan->dst_port = htons(vxlan_port);
22792257

22802258
vxlan->dev = dev;

include/net/vxlan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
4545
__be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
4646
__be16 src_port, __be16 dst_port, __be32 vni, bool xnet);
4747

48-
__be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb);
49-
5048
/* IP header + UDP + VXLAN + Ethernet header */
5149
#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
5250
/* IPv6 header + UDP + VXLAN + Ethernet header */

net/openvswitch/vport-vxlan.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
143143
struct rtable *rt;
144144
struct flowi4 fl;
145145
__be16 src_port;
146-
int port_min;
147-
int port_max;
148146
__be16 df;
149147
int err;
150148

@@ -172,8 +170,7 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
172170

173171
skb->ignore_df = 1;
174172

175-
inet_get_local_port_range(net, &port_min, &port_max);
176-
src_port = vxlan_src_port(port_min, port_max, skb);
173+
src_port = udp_flow_src_port(net, skb, 0, 0, true);
177174

178175
err = vxlan_xmit_skb(vxlan_port->vs, rt, skb,
179176
fl.saddr, OVS_CB(skb)->tun_key->ipv4_dst,

0 commit comments

Comments
 (0)