netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] vxlan: port related patches
@ 2013-04-27 21:31 Stephen Hemminger
  2013-04-27 21:31 ` [PATCH net-next 1/6] vxlan: update mail address and copyright date Stephen Hemminger
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev

Looking at VxLan issues around destination port found some cleanups,
a bug, and an enhancement to allow configuring per device.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 1/6] vxlan: update mail address and copyright date
  2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
@ 2013-04-27 21:31 ` Stephen Hemminger
  2013-04-27 21:31 ` [PATCH net-next 2/6] vxlan: document UDP default port Stephen Hemminger
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

[-- Attachment #1: vxlan-fix-mail.patch --]
[-- Type: text/plain, Size: 758 bytes --]

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/drivers/net/vxlan.c	2013-04-27 13:36:18.118396437 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 13:38:54.124378801 -0700
@@ -1,7 +1,7 @@
 /*
  * VXLAN: Virtual eXtensible Local Area Network
  *
- * Copyright (c) 2012 Vyatta Inc.
+ * Copyright (c) 2012-2013 Vyatta Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -1663,5 +1663,5 @@ module_exit(vxlan_cleanup_module);
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(VXLAN_VERSION);
-MODULE_AUTHOR("Stephen Hemminger <shemminger@vyatta.com>");
+MODULE_AUTHOR("Stephen Hemminger <stephen@networkplumber.org>");
 MODULE_ALIAS_RTNL_LINK("vxlan");

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 2/6] vxlan: document UDP default port
  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 ` Stephen Hemminger
  2013-04-27 21:31 ` [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT Stephen Hemminger
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

[-- Attachment #1: vxlan-port-comprimise.patch --]
[-- Type: text/plain, Size: 815 bytes --]

The default port for VXLAN is not same as IANA value.
Document this.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/drivers/net/vxlan.c	2013-04-27 13:38:54.124378801 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 13:38:57.232338603 -0700
@@ -8,7 +8,6 @@
  * published by the Free Software Foundation.
  *
  * TODO
- *  - use IANA UDP port number (when defined)
  *  - IPv6 (not in RFC)
  */
 
@@ -65,7 +64,10 @@ struct vxlanhdr {
 	__be32 vx_vni;
 };
 
-/* UDP port for VXLAN traffic. */
+/* UDP port for VXLAN traffic.
+ * The IANA assigned port is 4789, but the Linux default is 8472
+ * for compatability with early adopters.
+ */
 static unsigned int vxlan_port __read_mostly = 8472;
 module_param_named(udp_port, vxlan_port, uint, 0444);
 MODULE_PARM_DESC(udp_port, "Destination UDP port");

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT
  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 ` Stephen Hemminger
  2013-04-29 15:47   ` David Stevens
  2013-04-27 21:31 ` [PATCH net-next 4/6] vxlan: source compatiablity with IFLA_VXLAN_GROUP (v2) Stephen Hemminger
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

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

The NDA_PORT attribute was added, but the author wasn't careful
about width (port is 16 bits), or byte order.  The attribute was
being dumped as 16 bits, but only 32 bit value would be accepted
when setting up a device. Also, the remote port is in network
byte order and was being compared with default port in host byte
order.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/drivers/net/vxlan.c	2013-04-27 13:38:57.232338603 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 13:56:54.050412049 -0700
@@ -192,7 +192,7 @@ static int vxlan_fdb_info(struct sk_buff
 	if (send_ip && nla_put_be32(skb, NDA_DST, rdst->remote_ip))
 		goto nla_put_failure;
 
-	if (rdst->remote_port && rdst->remote_port != vxlan_port &&
+	if (rdst->remote_port && rdst->remote_port != htons(vxlan_port) &&
 	    nla_put_be16(skb, NDA_PORT, rdst->remote_port))
 		goto nla_put_failure;
 	if (rdst->remote_vni != vxlan->default_dst.remote_vni &&
@@ -222,7 +222,7 @@ static inline size_t vxlan_nlmsg_size(vo
 	return NLMSG_ALIGN(sizeof(struct ndmsg))
 		+ nla_total_size(ETH_ALEN) /* NDA_LLADDR */
 		+ nla_total_size(sizeof(__be32)) /* NDA_DST */
-		+ nla_total_size(sizeof(__be32)) /* NDA_PORT */
+		+ nla_total_size(sizeof(__be16)) /* NDA_PORT */
 		+ nla_total_size(sizeof(__be32)) /* NDA_VNI */
 		+ nla_total_size(sizeof(__u32)) /* NDA_IFINDEX */
 		+ nla_total_size(sizeof(struct nda_cacheinfo));
@@ -317,7 +317,7 @@ static struct vxlan_fdb *vxlan_find_mac(
 
 /* Add/update destinations for multicast */
 static int vxlan_fdb_append(struct vxlan_fdb *f,
-			    __be32 ip, __u32 port, __u32 vni, __u32 ifindex)
+			    __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
 {
 	struct vxlan_rdst *rd_prev, *rd;
 
@@ -346,7 +346,7 @@ static int vxlan_fdb_append(struct vxlan
 static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 			    const u8 *mac, __be32 ip,
 			    __u16 state, __u16 flags,
-			    __u32 port, __u32 vni, __u32 ifindex,
+			    __be16 port, __u32 vni, __u32 ifindex,
 			    __u8 ndm_flags)
 {
 	struct vxlan_fdb *f;
@@ -444,7 +444,8 @@ static int vxlan_fdb_add(struct ndmsg *n
 	struct vxlan_dev *vxlan = netdev_priv(dev);
 	struct net *net = dev_net(vxlan->dev);
 	__be32 ip;
-	u32 port, vni, ifindex;
+	__be16 port;
+	u32 vni, ifindex;
 	int err;
 
 	if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_REACHABLE))) {
@@ -462,11 +463,11 @@ static int vxlan_fdb_add(struct ndmsg *n
 	ip = nla_get_be32(tb[NDA_DST]);
 
 	if (tb[NDA_PORT]) {
-		if (nla_len(tb[NDA_PORT]) != sizeof(u32))
+		if (nla_len(tb[NDA_PORT]) != sizeof(__be16))
 			return -EINVAL;
-		port = nla_get_u32(tb[NDA_PORT]);
+		port = nla_get_be16(tb[NDA_PORT]);
 	} else
-		port = vxlan_port;
+		port = htons(vxlan_port);
 
 	if (tb[NDA_VNI]) {
 		if (nla_len(tb[NDA_VNI]) != sizeof(u32))
@@ -489,8 +490,8 @@ static int vxlan_fdb_add(struct ndmsg *n
 		ifindex = 0;
 
 	spin_lock_bh(&vxlan->hash_lock);
-	err = vxlan_fdb_create(vxlan, addr, ip, ndm->ndm_state, flags, port,
-		vni, ifindex, ndm->ndm_flags);
+	err = vxlan_fdb_create(vxlan, addr, ip, ndm->ndm_state, flags,
+			       port, vni, ifindex, ndm->ndm_flags);
 	spin_unlock_bh(&vxlan->hash_lock);
 
 	return err;
@@ -964,12 +965,13 @@ static netdev_tx_t vxlan_xmit_one(struct
 	struct udphdr *uh;
 	struct flowi4 fl4;
 	__be32 dst;
-	__u16 src_port, dst_port;
+	__u16 src_port;
+	__be16 dst_port;
         u32 vni;
 	__be16 df = 0;
 	__u8 tos, ttl;
 
-	dst_port = rdst->remote_port ? rdst->remote_port : vxlan_port;
+	dst_port = rdst->remote_port ? rdst->remote_port : htons(vxlan_port);
 	vni = rdst->remote_vni;
 	dst = rdst->remote_ip;
 
@@ -1050,7 +1052,7 @@ static netdev_tx_t vxlan_xmit_one(struct
 	skb_reset_transport_header(skb);
 	uh = udp_hdr(skb);
 
-	uh->dest = htons(dst_port);
+	uh->dest = dst_port;
 	uh->source = htons(src_port);
 
 	uh->len = htons(skb->len);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 4/6] vxlan: source compatiablity with IFLA_VXLAN_GROUP (v2)
  2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
                   ` (2 preceding siblings ...)
  2013-04-27 21:31 ` [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT Stephen Hemminger
@ 2013-04-27 21:31 ` Stephen Hemminger
  2013-04-27 21:31 ` [PATCH net-next 5/6] vxlan: compute source port in network byte order Stephen Hemminger
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

[-- Attachment #1: vxlan-header-compat.patch --]
[-- Type: text/plain, Size: 2586 bytes --]

Source compatiability for build iproute2 was broken by:
  commit c7995c43facc6e5dea4de63fa9d283a337aabeb1
  Author: Atzm Watanabe <atzm@stratosphere.co.jp>
    vxlan: Allow setting destination to unicast address.

Since this commit has not made it upstream (still net-next),
and better to avoid gratitious changes to exported API's;
go back to original definition, and add a comment.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/include/uapi/linux/if_link.h	2013-04-27 13:55:37.311404520 -0700
+++ b/include/uapi/linux/if_link.h	2013-04-27 13:59:41.036252411 -0700
@@ -297,7 +297,7 @@ enum macvlan_mode {
 enum {
 	IFLA_VXLAN_UNSPEC,
 	IFLA_VXLAN_ID,
-	IFLA_VXLAN_REMOTE,
+	IFLA_VXLAN_GROUP,	/* group or remote address */
 	IFLA_VXLAN_LINK,
 	IFLA_VXLAN_LOCAL,
 	IFLA_VXLAN_TTL,
--- a/drivers/net/vxlan.c	2013-04-27 13:56:54.050412049 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 13:59:41.040252358 -0700
@@ -1324,7 +1324,7 @@ static void vxlan_setup(struct net_devic
 
 static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
 	[IFLA_VXLAN_ID]		= { .type = NLA_U32 },
-	[IFLA_VXLAN_REMOTE]	= { .len = FIELD_SIZEOF(struct iphdr, daddr) },
+	[IFLA_VXLAN_GROUP]	= { .len = FIELD_SIZEOF(struct iphdr, daddr) },
 	[IFLA_VXLAN_LINK]	= { .type = NLA_U32 },
 	[IFLA_VXLAN_LOCAL]	= { .len = FIELD_SIZEOF(struct iphdr, saddr) },
 	[IFLA_VXLAN_TOS]	= { .type = NLA_U8 },
@@ -1406,8 +1406,8 @@ static int vxlan_newlink(struct net *net
 	}
 	dst->remote_vni = vni;
 
-	if (data[IFLA_VXLAN_REMOTE])
-		dst->remote_ip = nla_get_be32(data[IFLA_VXLAN_REMOTE]);
+	if (data[IFLA_VXLAN_GROUP])
+		dst->remote_ip = nla_get_be32(data[IFLA_VXLAN_GROUP]);
 
 	if (data[IFLA_VXLAN_LOCAL])
 		vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]);
@@ -1488,7 +1488,7 @@ static size_t vxlan_get_size(const struc
 {
 
 	return nla_total_size(sizeof(__u32)) +	/* IFLA_VXLAN_ID */
-		nla_total_size(sizeof(__be32)) +/* IFLA_VXLAN_REMOTE */
+		nla_total_size(sizeof(__be32)) +/* IFLA_VXLAN_GROUP */
 		nla_total_size(sizeof(__u32)) +	/* IFLA_VXLAN_LINK */
 		nla_total_size(sizeof(__be32))+	/* IFLA_VXLAN_LOCAL */
 		nla_total_size(sizeof(__u8)) +	/* IFLA_VXLAN_TTL */
@@ -1516,7 +1516,7 @@ static int vxlan_fill_info(struct sk_buf
 	if (nla_put_u32(skb, IFLA_VXLAN_ID, dst->remote_vni))
 		goto nla_put_failure;
 
-	if (dst->remote_ip && nla_put_be32(skb, IFLA_VXLAN_REMOTE, dst->remote_ip))
+	if (dst->remote_ip && nla_put_be32(skb, IFLA_VXLAN_GROUP, dst->remote_ip))
 		goto nla_put_failure;
 
 	if (dst->remote_ifindex && nla_put_u32(skb, IFLA_VXLAN_LINK, dst->remote_ifindex))

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 5/6] vxlan: compute source port in network byte order
  2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
                   ` (3 preceding siblings ...)
  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
  2013-04-27 21:31 ` [PATCH net-next 6/6] vxlan: allow choosing destination port per vxlan Stephen Hemminger
  2013-04-29 16:07 ` [PATCH net-next 0/6] vxlan: port related patches David Miller
  6 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

[-- 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;

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next 6/6] vxlan: allow choosing destination port per vxlan
  2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
                   ` (4 preceding siblings ...)
  2013-04-27 21:31 ` [PATCH net-next 5/6] vxlan: compute source port in network byte order Stephen Hemminger
@ 2013-04-27 21:31 ` Stephen Hemminger
  2013-04-27 21:47   ` [PATCH iproute2] iproute2: add vxlan dstport option Stephen Hemminger
  2013-04-29 16:07 ` [PATCH net-next 0/6] vxlan: port related patches David Miller
  6 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

[-- Attachment #1: vxlan-dst-udp-port.patch --]
[-- Type: text/plain, Size: 4035 bytes --]

Allow configuring the default destination port on a per-device basis.
Adds new netlink paramater IFLA_VXLAN_PORT to allow setting destination
port when creating new vxlan.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/drivers/net/vxlan.c	2013-04-27 14:04:28.776531047 -0700
+++ b/drivers/net/vxlan.c	2013-04-27 14:27:23.495911755 -0700
@@ -110,6 +110,7 @@ struct vxlan_dev {
 	struct net_device *dev;
 	struct vxlan_rdst default_dst;	/* default destination */
 	__be32		  saddr;	/* source address */
+	__be16		  dst_port;
 	__u16		  port_min;	/* source port range */
 	__u16		  port_max;
 	__u8		  tos;		/* TOS override */
@@ -192,7 +193,7 @@ static int vxlan_fdb_info(struct sk_buff
 	if (send_ip && nla_put_be32(skb, NDA_DST, rdst->remote_ip))
 		goto nla_put_failure;
 
-	if (rdst->remote_port && rdst->remote_port != htons(vxlan_port) &&
+	if (rdst->remote_port && rdst->remote_port != vxlan->dst_port &&
 	    nla_put_be16(skb, NDA_PORT, rdst->remote_port))
 		goto nla_put_failure;
 	if (rdst->remote_vni != vxlan->default_dst.remote_vni &&
@@ -467,7 +468,7 @@ static int vxlan_fdb_add(struct ndmsg *n
 			return -EINVAL;
 		port = nla_get_be16(tb[NDA_PORT]);
 	} else
-		port = htons(vxlan_port);
+		port = vxlan->dst_port;
 
 	if (tb[NDA_VNI]) {
 		if (nla_len(tb[NDA_VNI]) != sizeof(u32))
@@ -579,7 +580,7 @@ static void vxlan_snoop(struct net_devic
 		err = vxlan_fdb_create(vxlan, src_mac, src_ip,
 				       NUD_REACHABLE,
 				       NLM_F_EXCL|NLM_F_CREATE,
-				       vxlan_port,
+				       vxlan->dst_port,
 				       vxlan->default_dst.remote_vni,
 				       0, NTF_SELF);
 		spin_unlock(&vxlan->hash_lock);
@@ -970,7 +971,7 @@ static netdev_tx_t vxlan_xmit_one(struct
 	__be16 df = 0;
 	__u8 tos, ttl;
 
-	dst_port = rdst->remote_port ? rdst->remote_port : htons(vxlan_port);
+	dst_port = rdst->remote_port ? rdst->remote_port : vxlan->dst_port;
 	vni = rdst->remote_vni;
 	dst = rdst->remote_ip;
 
@@ -1314,6 +1315,7 @@ static void vxlan_setup(struct net_devic
 	inet_get_local_port_range(&low, &high);
 	vxlan->port_min = low;
 	vxlan->port_max = high;
+	vxlan->dst_port = htons(vxlan_port);
 
 	vxlan->dev = dev;
 
@@ -1336,6 +1338,7 @@ static const struct nla_policy vxlan_pol
 	[IFLA_VXLAN_RSC]	= { .type = NLA_U8 },
 	[IFLA_VXLAN_L2MISS]	= { .type = NLA_U8 },
 	[IFLA_VXLAN_L3MISS]	= { .type = NLA_U8 },
+	[IFLA_VXLAN_PORT]	= { .type = NLA_U16 },
 };
 
 static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -1465,6 +1468,9 @@ static int vxlan_newlink(struct net *net
 		vxlan->port_max = ntohs(p->high);
 	}
 
+	if (data[IFLA_VXLAN_PORT])
+		vxlan->dst_port = nla_get_be16(data[IFLA_VXLAN_PORT]);
+
 	SET_ETHTOOL_OPS(dev, &vxlan_ethtool_ops);
 
 	err = register_netdevice(dev);
@@ -1500,6 +1506,7 @@ static size_t vxlan_get_size(const struc
 		nla_total_size(sizeof(__u32)) +	/* IFLA_VXLAN_AGEING */
 		nla_total_size(sizeof(__u32)) +	/* IFLA_VXLAN_LIMIT */
 		nla_total_size(sizeof(struct ifla_vxlan_port_range)) +
+		nla_total_size(sizeof(__be16))+ /* IFLA_VXLAN_PORT */
 		0;
 }
 
@@ -1536,7 +1543,8 @@ static int vxlan_fill_info(struct sk_buf
 	    nla_put_u8(skb, IFLA_VXLAN_L3MISS,
 			!!(vxlan->flags & VXLAN_F_L3MISS)) ||
 	    nla_put_u32(skb, IFLA_VXLAN_AGEING, vxlan->age_interval) ||
-	    nla_put_u32(skb, IFLA_VXLAN_LIMIT, vxlan->addrmax))
+	    nla_put_u32(skb, IFLA_VXLAN_LIMIT, vxlan->addrmax) ||
+	    nla_put_be16(skb, IFLA_VXLAN_PORT, vxlan->dst_port))
 		goto nla_put_failure;
 
 	if (nla_put(skb, IFLA_VXLAN_PORT_RANGE, sizeof(ports), &ports))
--- a/include/uapi/linux/if_link.h	2013-04-27 13:59:41.000000000 -0700
+++ b/include/uapi/linux/if_link.h	2013-04-27 14:04:52.752220968 -0700
@@ -305,11 +305,12 @@ enum {
 	IFLA_VXLAN_LEARNING,
 	IFLA_VXLAN_AGEING,
 	IFLA_VXLAN_LIMIT,
-	IFLA_VXLAN_PORT_RANGE,
+	IFLA_VXLAN_PORT_RANGE,	/* source port */
 	IFLA_VXLAN_PROXY,
 	IFLA_VXLAN_RSC,
 	IFLA_VXLAN_L2MISS,
 	IFLA_VXLAN_L3MISS,
+	IFLA_VXLAN_PORT,	/* destination port */
 	__IFLA_VXLAN_MAX
 };
 #define IFLA_VXLAN_MAX	(__IFLA_VXLAN_MAX - 1)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH iproute2] iproute2: add vxlan dstport option
  2013-04-27 21:31 ` [PATCH net-next 6/6] vxlan: allow choosing destination port per vxlan Stephen Hemminger
@ 2013-04-27 21:47   ` Stephen Hemminger
  2013-05-10 22:12     ` Sridhar Samudrala
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-27 21:47 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: davem, netdev

Add ability to set UDP destination port on a per device basis.
If no port is assigned, the default IANA assigned port will be used.
If you want the kernel default value, then use port 0.

Source port range option is now called 'srcport', to avoid
confusion. The old option syntax is accepted for compatiablity.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 40167af..e708e86 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -301,11 +301,12 @@ enum {
 	IFLA_VXLAN_LEARNING,
 	IFLA_VXLAN_AGEING,
 	IFLA_VXLAN_LIMIT,
-	IFLA_VXLAN_PORT_RANGE,
+	IFLA_VXLAN_PORT_RANGE,	/* source port */
 	IFLA_VXLAN_PROXY,
 	IFLA_VXLAN_RSC,
 	IFLA_VXLAN_L2MISS,
 	IFLA_VXLAN_L3MISS,
+	IFLA_VXLAN_PORT,	/* destination port */
 	__IFLA_VXLAN_MAX
 };
 #define IFLA_VXLAN_MAX	(__IFLA_VXLAN_MAX - 1)
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 1025326..2d93ee2 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -25,8 +25,8 @@ static void explain(void)
 {
 	fprintf(stderr, "Usage: ... vxlan id VNI [ group ADDR ] [ local ADDR ]\n");
 	fprintf(stderr, "                 [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n");
-	fprintf(stderr, "                 [ port MIN MAX ] [ [no]learning ]\n");
-	fprintf(stderr, "                 [ [no]proxy ] [ [no]rsc ]\n");
+	fprintf(stderr, "                 [ dstport PORT ] [ srcport MIN MAX ]\n");
+	fprintf(stderr, "                 [ [no]learning ] [ [no]proxy ] [ [no]rsc ]\n");
 	fprintf(stderr, "                 [ [no]l2miss ] [ [no]l3miss ]\n");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Where: VNI := 0-16777215\n");
@@ -53,6 +53,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	__u8 noage = 0;
 	__u32 age = 0;
 	__u32 maxaddr = 0;
+	__u16 dstport = 4789;
 	struct ifla_vxlan_port_range range = { 0, 0 };
 
 	while (argc > 0) {
@@ -115,7 +116,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 				maxaddr = 0;
 			else if (get_u32(&maxaddr, *argv, 0))
 				invarg("max addresses", *argv);
-		} else if (!matches(*argv, "port")) {
+		} else if (!matches(*argv, "port") ||
+			   !matches(*argv, "srcport")) {
 			__u16 minport, maxport;
 			NEXT_ARG();
 			if (get_u16(&minport, *argv, 0))
@@ -125,6 +127,10 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 				invarg("max port", *argv);
 			range.low = htons(minport);
 			range.high = htons(maxport);
+		} else if (!matches(*argv, "dstport")){
+			NEXT_ARG();
+			if (get_u16(&dstport, *argv, 0))
+				invarg("dst port", *argv);
 		} else if (!matches(*argv, "nolearning")) {
 			learning = 0;
 		} else if (!matches(*argv, "learning")) {
@@ -155,7 +161,6 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 		}
 		argc--, argv++;
 	}
-
 	if (!vni_set) {
 		fprintf(stderr, "vxlan: missing virtual network identifier\n");
 		return -1;
@@ -183,6 +188,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	if (range.low || range.high)
 		addattr_l(n, 1024, IFLA_VXLAN_PORT_RANGE,
 			  &range, sizeof(range));
+	if (dstport)
+		addattr16(n, 1024, IFLA_VXLAN_PORT, htons(dstport));
 
 	return 0;
 }
@@ -233,9 +240,13 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	if (tb[IFLA_VXLAN_PORT_RANGE]) {
 		const struct ifla_vxlan_port_range *r
 			= RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]);
-		fprintf(f, "port %u %u ", ntohs(r->low), ntohs(r->high));
+		fprintf(f, "srcport %u %u ", ntohs(r->low), ntohs(r->high));
 	}
 
+	if (tb[IFLA_VXLAN_PORT])
+		fprintf(f, "dstport %u ",
+			ntohs(rta_getattr_u16(tb[IFLA_VXLAN_PORT])));
+
 	if (tb[IFLA_VXLAN_LEARNING] &&
 	    !rta_getattr_u8(tb[IFLA_VXLAN_LEARNING]))
 		fputs("nolearning ", f);

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT
  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
  0 siblings, 1 reply; 12+ messages in thread
From: David Stevens @ 2013-04-29 15:47 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: davem, netdev, netdev-owner, Stephen Hemminger

netdev-owner@vger.kernel.org wrote on 04/27/2013 05:31:54 PM:

> From: Stephen Hemminger <stephen@networkplumber.org>

> The NDA_PORT attribute was added, but the author wasn't careful
> about width (port is 16 bits), or byte order.  The attribute was
> being dumped as 16 bits, but only 32 bit value would be accepted
> when setting up a device. Also, the remote port is in network
> byte order and was being compared with default port in host byte
> order.

        They were all in host order until your patch (though it looks like
I may have used __be16 instead of __u32 and it "worked" despite the
type error. I left it as 32 bits for netlink to be int-sized and not
have unintended promotions, not to mention because "vxlan_port" is 32bit,
and still is. I'm ok with switching them to network order and 16 bit,
but I think you should make "vxlan_port" the same byte
order and size as "remote_port" so the comparisons below don't require
byte-swapping at run-time, as the original code did not.

So my suggestion is you make vxlan_port be __be16 as part of this
patch, too.

> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> 
> --- a/drivers/net/vxlan.c   2013-04-27 13:38:57.232338603 -0700
> +++ b/drivers/net/vxlan.c   2013-04-27 13:56:54.050412049 -0700
> @@ -192,7 +192,7 @@ static int vxlan_fdb_info(struct sk_buff
>     if (send_ip && nla_put_be32(skb, NDA_DST, rdst->remote_ip))
>        goto nla_put_failure;
> 
> -   if (rdst->remote_port && rdst->remote_port != vxlan_port &&
> +   if (rdst->remote_port && rdst->remote_port != htons(vxlan_port) &&
>         nla_put_be16(skb, NDA_PORT, rdst->remote_port))
>        goto nla_put_failure;
>     if (rdst->remote_vni != vxlan->default_dst.remote_vni &&
> @@ -222,7 +222,7 @@ static inline size_t vxlan_nlmsg_size(vo
>     return NLMSG_ALIGN(sizeof(struct ndmsg))
>        + nla_total_size(ETH_ALEN) /* NDA_LLADDR */
>        + nla_total_size(sizeof(__be32)) /* NDA_DST */
> -      + nla_total_size(sizeof(__be32)) /* NDA_PORT */
> +      + nla_total_size(sizeof(__be16)) /* NDA_PORT */
>        + nla_total_size(sizeof(__be32)) /* NDA_VNI */
>        + nla_total_size(sizeof(__u32)) /* NDA_IFINDEX */
>        + nla_total_size(sizeof(struct nda_cacheinfo));
> @@ -317,7 +317,7 @@ static struct vxlan_fdb *vxlan_find_mac(
> 
>  /* Add/update destinations for multicast */
>  static int vxlan_fdb_append(struct vxlan_fdb *f,
> -             __be32 ip, __u32 port, __u32 vni, __u32 ifindex)
> +             __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
>  {
>     struct vxlan_rdst *rd_prev, *rd;
> 
> @@ -346,7 +346,7 @@ static int vxlan_fdb_append(struct vxlan
>  static int vxlan_fdb_create(struct vxlan_dev *vxlan,
>               const u8 *mac, __be32 ip,
>               __u16 state, __u16 flags,
> -             __u32 port, __u32 vni, __u32 ifindex,
> +             __be16 port, __u32 vni, __u32 ifindex,
>               __u8 ndm_flags)
>  {
>     struct vxlan_fdb *f;
> @@ -444,7 +444,8 @@ static int vxlan_fdb_add(struct ndmsg *n
>     struct vxlan_dev *vxlan = netdev_priv(dev);
>     struct net *net = dev_net(vxlan->dev);
>     __be32 ip;
> -   u32 port, vni, ifindex;
> +   __be16 port;
> +   u32 vni, ifindex;
>     int err;
> 
>     if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_REACHABLE))) {
> @@ -462,11 +463,11 @@ static int vxlan_fdb_add(struct ndmsg *n
>     ip = nla_get_be32(tb[NDA_DST]);
> 
>     if (tb[NDA_PORT]) {
> -      if (nla_len(tb[NDA_PORT]) != sizeof(u32))
> +      if (nla_len(tb[NDA_PORT]) != sizeof(__be16))
>           return -EINVAL;
> -      port = nla_get_u32(tb[NDA_PORT]);
> +      port = nla_get_be16(tb[NDA_PORT]);
>     } else
> -      port = vxlan_port;
> +      port = htons(vxlan_port);
> 
>     if (tb[NDA_VNI]) {
>        if (nla_len(tb[NDA_VNI]) != sizeof(u32))
> @@ -489,8 +490,8 @@ static int vxlan_fdb_add(struct ndmsg *n
>        ifindex = 0;
> 
>     spin_lock_bh(&vxlan->hash_lock);
> -   err = vxlan_fdb_create(vxlan, addr, ip, ndm->ndm_state, flags, port,
> -      vni, ifindex, ndm->ndm_flags);
> +   err = vxlan_fdb_create(vxlan, addr, ip, ndm->ndm_state, flags,
> +                port, vni, ifindex, ndm->ndm_flags);
>     spin_unlock_bh(&vxlan->hash_lock);
> 
>     return err;
> @@ -964,12 +965,13 @@ static netdev_tx_t vxlan_xmit_one(struct
>     struct udphdr *uh;
>     struct flowi4 fl4;
>     __be32 dst;
> -   __u16 src_port, dst_port;
> +   __u16 src_port;
> +   __be16 dst_port;
>          u32 vni;
>     __be16 df = 0;
>     __u8 tos, ttl;
> 
> -   dst_port = rdst->remote_port ? rdst->remote_port : vxlan_port;
> +   dst_port = rdst->remote_port ? rdst->remote_port : 
htons(vxlan_port);
>     vni = rdst->remote_vni;
>     dst = rdst->remote_ip;
> 
> @@ -1050,7 +1052,7 @@ static netdev_tx_t vxlan_xmit_one(struct
>     skb_reset_transport_header(skb);
>     uh = udp_hdr(skb);
> 
> -   uh->dest = htons(dst_port);
> +   uh->dest = dst_port;
>     uh->source = htons(src_port);
> 
>     uh->len = htons(skb->len);
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next 0/6] vxlan: port related patches
  2013-04-27 21:31 [PATCH net-next 0/6] vxlan: port related patches Stephen Hemminger
                   ` (5 preceding siblings ...)
  2013-04-27 21:31 ` [PATCH net-next 6/6] vxlan: allow choosing destination port per vxlan Stephen Hemminger
@ 2013-04-29 16:07 ` David Miller
  6 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2013-04-29 16:07 UTC (permalink / raw)
  To: stephen; +Cc: netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sat, 27 Apr 2013 14:31:51 -0700

> Looking at VxLan issues around destination port found some cleanups,
> a bug, and an enhancement to allow configuring per device.

Applied, thanks Stephen.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT
  2013-04-29 15:47   ` David Stevens
@ 2013-04-29 23:40     ` Stephen Hemminger
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2013-04-29 23:40 UTC (permalink / raw)
  To: David Stevens; +Cc: davem, netdev, netdev-owner

On Mon, 29 Apr 2013 11:47:26 -0400
David Stevens <dlstevens@us.ibm.com> wrote:

>         They were all in host order until your patch (though it looks like
> I may have used __be16 instead of __u32 and it "worked" despite the
> type error. I left it as 32 bits for netlink to be int-sized and not
> have unintended promotions, not to mention because "vxlan_port" is 32bit,
> and still is. I'm ok with switching them to network order and 16 bit,
> but I think you should make "vxlan_port" the same byte
> order and size as "remote_port" so the comparisons below don't require
> byte-swapping at run-time, as the original code did not.

Module parameters need to be host order, and there isn't really a good
way to type them as 16 bit.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2] iproute2: add vxlan dstport option
  2013-04-27 21:47   ` [PATCH iproute2] iproute2: add vxlan dstport option Stephen Hemminger
@ 2013-05-10 22:12     ` Sridhar Samudrala
  0 siblings, 0 replies; 12+ messages in thread
From: Sridhar Samudrala @ 2013-05-10 22:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: davem, netdev, David L Stevens

On 4/27/2013 2:47 PM, Stephen Hemminger wrote:
> Add ability to set UDP destination port on a per device basis.
> If no port is assigned, the default IANA assigned port will be used.
> If you want the kernel default value, then use port 0.
>
> Source port range option is now called 'srcport', to avoid
> confusion. The old option syntax is accepted for compatiablity.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

I updated iproute2 to the upstream git tree and i noticed that vxlan
connectivity is lost in my setup as this patch is causing vxlan packets 
to be
sent to the new IANA port 4789, but the kernel default is 8472 and the
receiver is listening on that port.

If we are going to keep 8472 as the kernel default for listening port, i 
think iproute2
also should keep the same default for dst_port.

Thanks
Sridhar

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-05-10 22:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH net-next 5/6] vxlan: compute source port in network byte order Stephen Hemminger
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).