All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH net-next 5/6] vxlan: compute source port in network byte order
Date: Sat, 27 Apr 2013 14:31:56 -0700	[thread overview]
Message-ID: <20130427213258.458048173@vyatta.com> (raw)
In-Reply-To: 20130427213151.255971631@vyatta.com

[-- Attachment #1: vxlan-src-port-be16.patch --]
[-- Type: text/plain, Size: 1545 bytes --]

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>


--- a/drivers/net/vxlan.c	2013-04-27 13:59:41.000000000 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 14:04:28.776531047 -0700
@@ -896,7 +896,7 @@ static void vxlan_set_owner(struct net_d
  *     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)
+static __be16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
 {
 	unsigned int range = (vxlan->port_max - vxlan->port_min) + 1;
 	u32 hash;
@@ -906,7 +906,7 @@ static u16 vxlan_src_port(const struct v
 		hash = jhash(skb->data, 2 * ETH_ALEN,
 			     (__force u32) skb->protocol);
 
-	return (((u64) hash * range) >> 32) + vxlan->port_min;
+	return htons((((u64) hash * range) >> 32) + vxlan->port_min);
 }
 
 static int handle_offloads(struct sk_buff *skb)
@@ -965,8 +965,7 @@ static netdev_tx_t vxlan_xmit_one(struct
 	struct udphdr *uh;
 	struct flowi4 fl4;
 	__be32 dst;
-	__u16 src_port;
-	__be16 dst_port;
+	__be16 src_port, dst_port;
         u32 vni;
 	__be16 df = 0;
 	__u8 tos, ttl;
@@ -1053,7 +1052,7 @@ static netdev_tx_t vxlan_xmit_one(struct
 	uh = udp_hdr(skb);
 
 	uh->dest = dst_port;
-	uh->source = htons(src_port);
+	uh->source = src_port;
 
 	uh->len = htons(skb->len);
 	uh->check = 0;

  parent reply	other threads:[~2013-04-27 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
2013-04-27 21:31 ` [PATCH net-next 1/6] vxlan: update mail address and copyright date Stephen Hemminger
2013-04-27 21:31 ` [PATCH net-next 2/6] vxlan: document UDP default port Stephen Hemminger
2013-04-27 21:31 ` [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT Stephen Hemminger
2013-04-29 15:47   ` David Stevens
2013-04-29 23:40     ` Stephen Hemminger
2013-04-27 21:31 ` [PATCH net-next 4/6] vxlan: source compatiablity with IFLA_VXLAN_GROUP (v2) Stephen Hemminger
2013-04-27 21:31 ` Stephen Hemminger [this message]
2013-04-27 21:31 ` [PATCH net-next 6/6] vxlan: allow choosing destination port per vxlan Stephen Hemminger
2013-04-27 21:47   ` [PATCH iproute2] iproute2: add vxlan dstport option Stephen Hemminger
2013-05-10 22:12     ` Sridhar Samudrala
2013-04-29 16:07 ` [PATCH net-next 0/6] vxlan: port related patches David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130427213258.458048173@vyatta.com \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.