Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix to setup-vif-rules #953

Merged
merged 1 commit into from

6 participants

@amarao

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?

@robhoes robhoes was assigned
@jonludlam
Owner

Assigning to @robhoes for review

@Mattsface

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

@jonludlam
Owner

Thanks, @Mattsface - @robhoes , any comments?

@robhoes
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?

@amarao

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.

@robhoes
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.

@robhoes
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!

@mcclurmc

@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 ;)

George Shuklin 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
@amarao

Done, commit signed.

@robhoes
Owner

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

@robhoes robhoes merged commit 47bc0e2 into xapi-project:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 31, 2013
  1. @amarao

    Fix bridge name selection for vswitch mode in scripts/setup-vif-rules

    George Shuklin authored amarao committed
      -        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>
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 scripts/setup-vif-rules
View
7 scripts/setup-vif-rules
@@ -229,10 +229,15 @@ def create_vswitch_rules(bridge_name, port, config):
# Drop everything else.
add_flow(bridge_name, "in_port=%s,priority=4000,idle_timeout=0,action=drop" % port)
+def get_bridge_name_vswitch(vif_name):
+ '''return bridge vif belong to'''
+ (rc, stdout, stderr) = doexec([vsctl, "iface-to-br", vif_name ])
+ return stdout.readline().strip()
+
def handle_vswitch(vif_type, domid, devid, action):
if (action == "clear") or (action == "filter"):
- bridge_name = "xenbr%s" % devid
vif_name = "%s%s.%s" % (vif_type, domid, devid)
+ bridge_name = get_bridge_name_vswitch(vif_name)
ip_link_set(vif_name, "down")
port = get_vswitch_port(vif_name)
clear_vswitch_rules(bridge_name, port)
Something went wrong with that request. Please try again.