[ovs-dev] [PATCH 5/6] vxlan: Update tnl_set_config() to use UDP dst_port to distinguish VXLAN ports

Kyle Mestery kmestery at cisco.com
Thu Feb 14 14:37:29 UTC 2013


In tnl_set_config(), when determining if a tunnel port
already exists, make sure to also check the destination port. For VXLAN, this
can be different and allows multiple VXLAN ports in the datapath to be
created.

Signed-off-by: Kyle Mestery <kmestery at cisco.com>
---
 datapath/tunnel.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 7c2560f..6e6f18e 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -48,6 +48,7 @@
 #include "datapath.h"
 #include "tunnel.h"
 #include "vlan.h"
+#include "tunnel.h"
 #include "vport.h"
 #include "vport-internal_dev.h"
 
@@ -707,6 +708,7 @@ static int tnl_set_config(struct net *net, struct nlattr *options,
 			  struct tnl_mutable_config *mutable)
 {
 	const struct vport *old_vport;
+	const struct tnl_vport *old_tnl_vport;
 	const struct tnl_mutable_config *old_mutable;
 	struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
 	int err;
@@ -786,8 +788,20 @@ static int tnl_set_config(struct net *net, struct nlattr *options,
 
 out:
 	old_vport = port_table_lookup(&mutable->key, &old_mutable);
-	if (old_vport && old_vport != cur_vport)
-		return -EEXIST;
+	if (old_vport) {
+		old_tnl_vport = tnl_vport_priv(old_vport);
+		if (old_tnl_vport) {
+			struct tnl_mutable_config *tmutable;
+
+			tmutable = rcu_dereference_rtnl(old_tnl_vport->mutable);
+			if (old_vport == cur_vport &&
+			    mutable->dst_port == tmutable->dst_port)
+				return -EEXIST;
+		} else {
+			if (old_vport != cur_vport)
+				return -EEXIST;
+		}
+	}
 
 	return 0;
 }
-- 
1.8.1




More information about the dev mailing list