vxlan: port related patches
Subsystems (2)
cover vxlan: port related patches
Looking at VxLan issues around destination port found some cleanups, a bug, and an enhancement to allow configuring per device.
PATCH 1/6 vxlan: update mail address and copyright date
drivers/net/vxlan.c +2 -2
@@ -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 <[email protected]>" ); +MODULE_AUTHOR ("Stephen Hemminger <[email protected]>" );MODULE_ALIAS_RTNL_LINK ("vxlan" );
PATCH 2/6 vxlan: document UDP default port
In reply to Stephen HemmingerThe default port for VXLAN is not same as IANA value. Document this.
drivers/net/vxlan.c +4 -2
@@ -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" );
PATCH 3/6 vxlan: fix byte order issues with NDA_PORT
In reply to Stephen HemmingerThe 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.
drivers/net/vxlan.c +15 -13
@@ -192,7 +192,7 @@ static int vxlan_fdb_info(struct sk_buffif (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(voreturn 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 vxlanstatic 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 *nstruct 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(structstruct 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(structskb_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);
Re: [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT
[email protected] wrote on 04/27/2013 05:31:54 PM:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The
NDA_PORTattribute 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.
Quoted 81 lines
Signed-off-by Stephen Hemminger <[email protected]>drivers/net/vxlan.c 2013-04-27 13:56:54.050412049 -0700 renamed from drivers/net/vxlan.c 2013-04-27 13:38:57.232338603 -0700 +11
-10@@ -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;
drivers/net/vxlan.c 2013-04-27 13:56:54.050412049 -0700 static netdev_tx_t vxlan_xmit_one(struct · line 974
Quoted 10 lines
drivers/net/vxlan.c 2013-04-27 13:56:54.050412049 -0700 renamed from drivers/net/vxlan.c 2013-04-27 13:38:57.232338603 -0700 +3
-2__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);
Quoted 19 lines
drivers/net/vxlan.c 2013-04-27 13:56:54.050412049 -0700 renamed from drivers/net/vxlan.c 2013-04-27 13:38:57.232338603 -0700 +1
-2vni = 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 3/6] vxlan: fix byte order issues with NDA_PORT
Quoted 8 lines · On Mon, 29 Apr 2013 11:47:26 -0400 David Stevens <[email protected]> wrote:
They were all in host order until your patch (though it looks like
I may have used__be16instead of__u32and 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.
PATCH 4/6 vxlan: source compatiablity with IFLA_VXLAN_GROUP (v2)
In reply to Stephen HemmingerSource compatiability for build iproute2 was broken by:
commit c7995c43facc6e5dea4de63fa9d283a337aabeb1
Author: Atzm Watanabe <[email protected]>
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.
include/uapi/linux/if_link.h +1 -1
@@ -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 ,
drivers/net/vxlan.c +5 -5
@@ -1324,7 +1324,7 @@ static void vxlan_setup(struct net_devicstatic 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_bufif (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))
PATCH 5/6 vxlan: compute source port in network byte order
In reply to Stephen HemmingerRather 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.
drivers/net/vxlan.c +4 -5
@@ -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(structstruct 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 ;
PATCH 6/6 vxlan: allow choosing destination port per vxlan
In reply to Stephen HemmingerAllow 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.
drivers/net/vxlan.c +13 -5
@@ -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_buffif (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 *nreturn -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_devicinet_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 strucnla_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_bufnla_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))
include/uapi/linux/if_link.h +2 -1
@@ -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)
PATCH 1/1 iproute2: add vxlan dstport option
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.
include/linux/if_link.h +2 -1
@@ -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)
ip/iplink_vxlan.c +16 -5
@@ -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);
Re: [PATCH iproute2] iproute2: add vxlan dstport option
Quoted 8 lines · Stephen Hemminger
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 <[email protected]>
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
From: Stephen Hemminger <[email protected]>
Date: Sat, 27 Apr 2013 14:31:51 -0700
Quoted 2 lines
Looking at VxLan issues around destination port found some cleanups, a bug, and an enhancement to allow configuring per device.
Applied, thanks Stephen.