openvswitch needs this function tunnel_src_port() to generate udp source port number for vxlan packet.
Signed-off-by: Pravin B Shelar <[email protected]> --- drivers/net/vxlan.c | 20 +------------------- include/net/ip_tunnels.h | 1 + net/ipv4/ip_tunnel.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index bcfa933..a17a7cb 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -907,24 +907,6 @@ static void vxlan_set_owner(const struct vxlan_port *port, struct sk_buff *skb) skb->destructor = vxlan_sock_free; } -/* Compute source port for outgoing packet - * first choice to use L4 flow hash since it will spread - * better and maybe available from hardware - * secondary choice is to use jhash on the Ethernet header - */ -static u16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb) -{ - unsigned int range = (vxlan->port_max - vxlan->port_min) + 1; - u32 hash; - - hash = skb_get_rxhash(skb); - if (!hash) - hash = jhash(skb->data, 2 * ETH_ALEN, - (__force u32) skb->protocol); - - return (((u64) hash * range) >> 32) + vxlan->port_min; -} - static int handle_offloads(struct sk_buff *skb) { if (skb_is_gso(skb)) { @@ -1003,7 +985,7 @@ static netdev_tx_t vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, if (tos == 1) tos = ip_tunnel_get_dsfield(old_iph, skb); - src_port = vxlan_src_port(vxlan, skb); + src_port = tunnel_src_port(vxlan->port_max, vxlan->port_min, skb); memset(&fl4, 0, sizeof(fl4)); fl4.flowi4_oif = rdst->remote_ifindex; diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 4b6f0b2..973bf68 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -119,6 +119,7 @@ int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], struct ip_tunnel_parm *p); void ip_tunnel_setup(struct net_device *dev, int net_id); +u16 tunnel_src_port(__u16 port_max, __u16 port_min, struct sk_buff *skb); /* Extract dsfield from inner protocol */ static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph, diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index e4147ec..353265b 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -1032,4 +1032,23 @@ void ip_tunnel_setup(struct net_device *dev, int net_id) } EXPORT_SYMBOL_GPL(ip_tunnel_setup); +/* Compute source port for outgoing packet + * first choice to use L4 flow hash since it will spread + * better and maybe available from hardware + * secondary choice is to use jhash on the Ethernet header + */ +u16 tunnel_src_port(__u16 port_max, __u16 port_min, struct sk_buff *skb) +{ + unsigned int range = (port_max - port_min) + 1; + u32 hash; + + hash = skb_get_rxhash(skb); + if (!hash) + hash = jhash(skb->data, 2 * ETH_ALEN, + (__force u32) skb->protocol); + + return (((u64) hash * range) >> 32) + port_min; +} +EXPORT_SYMBOL_GPL(tunnel_src_port); + MODULE_LICENSE("GPL"); -- 1.7.1 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
