aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorstephen hemminger <stephen@networkplumber.org>2013-04-27 07:31:56 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-29 11:53:12 -0400
commit7d836a7679a85f75bbc96d631b4007a78396b190 (patch)
treeee61331a1aa62a91aef8af609fce1e5f28a5cf86 /drivers/net/vxlan.c
parent5d174dd80ce94b7ed0950e31fc9a0122c689523b (diff)
vxlan: compute source port in network byte order
Rather than computing source port and returning it in host order then swapping later, go ahead and compute it in network order to start with. Cleaner and less error prone. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index d8de8a1303eb..66fd7bef0a4d 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -896,7 +896,7 @@ static void vxlan_set_owner(struct net_device *dev, struct sk_buff *skb)
896 * better and maybe available from hardware 896 * better and maybe available from hardware
897 * secondary choice is to use jhash on the Ethernet header 897 * secondary choice is to use jhash on the Ethernet header
898 */ 898 */
899static u16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb) 899static __be16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
900{ 900{
901 unsigned int range = (vxlan->port_max - vxlan->port_min) + 1; 901 unsigned int range = (vxlan->port_max - vxlan->port_min) + 1;
902 u32 hash; 902 u32 hash;
@@ -906,7 +906,7 @@ static u16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
906 hash = jhash(skb->data, 2 * ETH_ALEN, 906 hash = jhash(skb->data, 2 * ETH_ALEN,
907 (__force u32) skb->protocol); 907 (__force u32) skb->protocol);
908 908
909 return (((u64) hash * range) >> 32) + vxlan->port_min; 909 return htons((((u64) hash * range) >> 32) + vxlan->port_min);
910} 910}
911 911
912static int handle_offloads(struct sk_buff *skb) 912static int handle_offloads(struct sk_buff *skb)
@@ -965,8 +965,7 @@ static netdev_tx_t vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
965 struct udphdr *uh; 965 struct udphdr *uh;
966 struct flowi4 fl4; 966 struct flowi4 fl4;
967 __be32 dst; 967 __be32 dst;
968 __u16 src_port; 968 __be16 src_port, dst_port;
969 __be16 dst_port;
970 u32 vni; 969 u32 vni;
971 __be16 df = 0; 970 __be16 df = 0;
972 __u8 tos, ttl; 971 __u8 tos, ttl;
@@ -1053,7 +1052,7 @@ static netdev_tx_t vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1053 uh = udp_hdr(skb); 1052 uh = udp_hdr(skb);
1054 1053
1055 uh->dest = dst_port; 1054 uh->dest = dst_port;
1056 uh->source = htons(src_port); 1055 uh->source = src_port;
1057 1056
1058 uh->len = htons(skb->len); 1057 uh->len = htons(skb->len);
1059 uh->check = 0; 1058 uh->check = 0;