Skip to content
This repository

Fix to setup-vif-rules #953

Merged
merged 1 commit into from about 1 year ago

6 participants

George Shuklin xen-git Jon Ludlam Matthew Spah Rob Hoes Mike McClurg
George Shuklin

change bridge_name = "xenbr%s" % devid
to bridge_name = get_bridge_name_vswitch(vif_name)

Devid is device number for domU (f.e. vif1.15; 15 - devid) and is definitely NOT a
xenbr number (xenbr0, xenbr1, etc).

This will fix broken Multi-Tenancy feature for xenbrX and vif1.X for X !=0.

xen-git
Owner

Can one of the admins verify this patch?

Jon Ludlam
Owner

Assigning to @robhoes for review

Matthew Spah

I just tested the patch in my lab environment. VIF level locking is working on an internal network named "xapi0".

Jon Ludlam
Owner

Thanks, @Mattsface - @robhoes , any comments?

Rob Hoes
Owner

@amarao I think the fix looks good, at least for the case where you are adding the rules/flows when a VIF is plugged. But does it also ensure that the rules/flows are removed when a VIF is unplugged or the VM is shutdown (I have seen flows being left behind even though the port was gone)? Is the bridge port for the VIF still present by the time you get into this function, so that 'ovs-vsctl iface-to-br' works, or does openvswitch remove the port as soon as the interface disappears?

George Shuklin

AFAIK, yes.

The logic is simple: when vif is unplugged (it happens if VM is shutdowned/rebooted/migrated), setup-vif-rules called with clear command. That cause call of clear_vswitch_rules. It removes all rules for port in bridge from OVS.

I checked that patch: migration, reboot, shutdown and manual domain self-shutdown (halt command from VM) clear rules from bridge.

Rob Hoes
Owner

@amarao: I finally got a chance to try this out myself, and it looks like it indeed works as you explained. Whenever the setup-vif-rules script is called, the interface still exists, and "ovs-vsctl iface-to-br" gives the right answer.

Thanks a lot of the patch and sorry for the delay from my side! I'll merge this now.

Rob Hoes
Owner

@amarao: Oops, it seems that your patch's commit message does not have a signed-off-by line. Could you add one? After that I'll merge it. Thanks!

Mike McClurg
Owner

@amarao Protip: you can automatically add a Signed-off-by line to your commit messages by doing 'git commit -s'. I can't spell 'commit' with '-s' now ;)

Fix bridge name selection for vswitch mode in scripts/setup-vif-rules
  -        bridge_name = "xenbr%s" % devid
  +        bridge_name = get_bridge_name_vswitch(vif_name)

  Devid is device number for domU (f.e. vif1.15; 15 - devid) and is definitely NOT a
  xenbr number (xenbr0, xenbr1, etc).

Signed-off-by: George Shuklin <george.shuklin@gmail.com>
06c2d0f
George Shuklin

Done, commit signed.

Rob Hoes
Owner

Awesome, thanks George. I'll merge this now.

Rob Hoes robhoes merged commit 47bc0e2 into from January 31, 2013
Rob Hoes robhoes closed this January 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 2 authors.

Jan 31, 2013
Fix bridge name selection for vswitch mode in scripts/setup-vif-rules
  -        bridge_name = "xenbr%s" % devid
  +        bridge_name = get_bridge_name_vswitch(vif_name)

  Devid is device number for domU (f.e. vif1.15; 15 - devid) and is definitely NOT a
  xenbr number (xenbr0, xenbr1, etc).

Signed-off-by: George Shuklin <george.shuklin@gmail.com>
06c2d0f
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  scripts/setup-vif-rules
7  scripts/setup-vif-rules
@@ -229,10 +229,15 @@ def create_vswitch_rules(bridge_name, port, config):
229 229
     # Drop everything else.
230 230
     add_flow(bridge_name, "in_port=%s,priority=4000,idle_timeout=0,action=drop" % port)
231 231
 
  232
+def get_bridge_name_vswitch(vif_name):
  233
+    '''return bridge vif belong to'''
  234
+    (rc, stdout, stderr) = doexec([vsctl, "iface-to-br",  vif_name ])
  235
+    return stdout.readline().strip()
  236
+
232 237
 def handle_vswitch(vif_type, domid, devid, action):
233 238
     if (action == "clear") or (action == "filter"):
234  
-        bridge_name = "xenbr%s" % devid
235 239
         vif_name = "%s%s.%s" % (vif_type, domid, devid)
  240
+        bridge_name = get_bridge_name_vswitch(vif_name) 
236 241
         ip_link_set(vif_name, "down")
237 242
         port = get_vswitch_port(vif_name)
238 243
         clear_vswitch_rules(bridge_name, port)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.