Skip to content

Commit 9abf1c7

Browse files
committed
Merge pull request #1790 from simonjbeaumont/ca-137468
CA-137468: Wait for ofport to settle before modifying ovs rules
2 parents 3a8d3d5 + a704c6a commit 9abf1c7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/setup-vif-rules

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,13 @@ def handle_bridge(vif_type, domid, devid, action):
170170
# Creation of openflow rules in the case of openvswitch.
171171
###############################################################################
172172

173-
def get_vswitch_port(vif_name):
174-
(rc, stdout, stderr) = doexec([vsctl, "get", "interface", vif_name, "ofport"])
173+
def get_vswitch_port(vif_name, wait_for_valid):
174+
args = ["get", "interface", vif_name, "ofport"]
175+
if wait_for_valid:
176+
cmd = [vsctl, "wait-until", "interface", vif_name, "ofport!=-1", "--"] + args
177+
else:
178+
cmd = [vsctl] + args
179+
(rc, stdout, stderr) = doexec(cmd)
175180
return stdout.readline().strip()
176181

177182
def clear_vswitch_rules(bridge_name, port):
@@ -243,8 +248,9 @@ def handle_vswitch(vif_type, domid, devid, action):
243248
vif_name = "%s%s.%s" % (vif_type, domid, devid)
244249
bridge_name = get_bridge_name_vswitch(vif_name)
245250
ip_link_set(vif_name, "down")
246-
port = get_vswitch_port(vif_name)
247-
clear_vswitch_rules(bridge_name, port)
251+
port = get_vswitch_port(vif_name, action == "filter")
252+
if port != -1:
253+
clear_vswitch_rules(bridge_name, port)
248254
if action == "filter":
249255
config = get_locking_config(domid, devid)
250256
locking_mode = config["locking_mode"]

0 commit comments

Comments
 (0)