Skip to content

Commit

Permalink
ovs-vtep: Handle tunnel key configuration in any order.
Browse files Browse the repository at this point in the history
Presently, ovs-vtep expects the datapath tunnel key to be available
in the VTEP DB at startup. This may not be the case which is also
observed as interrmittent unit test failures. This patch allows
for the tunnel key to later appear in the VTEP database.

Signed-off-by: Darrell Ball <[email protected]>
Acked-by: Russell Bryant <[email protected]>
Acked-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
darball1 authored and ddiproietto committed Jul 15, 2016
1 parent 35cfa38 commit 2a21ee2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions vtep/ovs-vtep
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,13 @@ class Logical_Switch(object):
self.local_macs = set()
self.remote_macs = {}
self.unknown_dsts = set()
self.tunnel_key = 0
self.setup_ls()
self.replication_mode = "service_node"

def __del__(self):
vlog.info("destroying lswitch %s" % self.name)

def setup_ls(self):
column = vtep_ctl("--columns=tunnel_key find logical_switch "
"name=%s" % self.name)
tunnel_key = column.partition(":")[2].strip()
if tunnel_key and isinstance(eval(tunnel_key), six.integer_types):
self.tunnel_key = tunnel_key
vlog.info("using tunnel key %s in %s"
% (self.tunnel_key, self.name))
else:
self.tunnel_key = 0
vlog.warn("invalid tunnel key for %s, using 0" % self.name)

if ps_type:
ovs_vsctl("--may-exist add-br %s -- set Bridge %s datapath_type=%s"
Expand Down Expand Up @@ -175,7 +164,7 @@ class Logical_Switch(object):
del self.ports[lbinding]
self.update_flood()

def add_tunnel(self, tunnel):
def add_tunnel(self, tunnel, tunnel_key):
global tun_id
vlog.info("adding tunnel %s" % tunnel)
encap, ip = tunnel.split("/")
Expand All @@ -189,7 +178,7 @@ class Logical_Switch(object):

ovs_vsctl("add-port %s %s -- set Interface %s type=vxlan "
"options:key=%s options:remote_ip=%s"
% (self.short_name, tun_name, tun_name, self.tunnel_key, ip))
% (self.short_name, tun_name, tun_name, tunnel_key, ip))

for i in range(10):
port_no = ovs_vsctl("get Interface %s ofport" % tun_name)
Expand Down Expand Up @@ -259,6 +248,17 @@ class Logical_Switch(object):
tunnels = set()
parse_ucast = True

column = vtep_ctl("--columns=tunnel_key find logical_switch "
"name=%s" % self.name)
tunnel_key = column.partition(":")[2].strip()
if tunnel_key and isinstance(eval(tunnel_key), six.integer_types):
vlog.info("update_remote_macs: using tunnel key %s in %s"
% (tunnel_key, self.name))
else:
vlog.info("Invalid tunnel key %s in %s post VTEP DB requery"
% (tunnel_key, self.name))
return

mac_list = vtep_ctl("list-remote-macs %s" % self.name).splitlines()
for line in mac_list:
if (line.find("mcast-mac-remote") != -1):
Expand All @@ -282,7 +282,7 @@ class Logical_Switch(object):
old_tunnels = set(self.tunnels.keys())

for tunnel in tunnels.difference(old_tunnels):
self.add_tunnel(tunnel)
self.add_tunnel(tunnel, tunnel_key)

for tunnel in old_tunnels.difference(tunnels):
self.del_tunnel(tunnel)
Expand Down

0 comments on commit 2a21ee2

Please sign in to comment.