From d241bbbb2fa15f46fcb54c744c986d67edd0afc4 Mon Sep 17 00:00:00 2001 From: Liping Mao Date: Mon, 31 Oct 2016 23:47:52 +0800 Subject: [PATCH] kuryr bind port error with neutron linux bridge driver When neutron configured with linux bridge driver, kuryr will bind port error. The linux bridge name should be "brq"+network_id[0,11]. Change-Id: I07be68bbfe7b1384f4e946664aed41546ff9ddce Closes-bug: #1638041 --- kuryr/lib/binding/drivers/veth.py | 3 ++- usr/libexec/kuryr/bridge | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/kuryr/lib/binding/drivers/veth.py b/kuryr/lib/binding/drivers/veth.py index 3de55da0..c63cdc96 100644 --- a/kuryr/lib/binding/drivers/veth.py +++ b/kuryr/lib/binding/drivers/veth.py @@ -108,9 +108,10 @@ def port_unbind(endpoint_id, neutron_port): ifname, _ = utils.get_veth_pair_names(port_id) mac_address = neutron_port['mac_address'] + network_id = neutron_port['network_id'] stdout, stderr = processutils.execute( unbinding_exec_path, UNBINDING_SUBCOMMAND, port_id, ifname, - endpoint_id, mac_address, vif_details, run_as_root=True) + endpoint_id, mac_address, vif_details, network_id, run_as_root=True) try: utils.remove_device(ifname) except pyroute2.NetlinkError: diff --git a/usr/libexec/kuryr/bridge b/usr/libexec/kuryr/bridge index 8b5347a2..03016978 100755 --- a/usr/libexec/kuryr/bridge +++ b/usr/libexec/kuryr/bridge @@ -12,10 +12,15 @@ # under the License. bind_port() { - echo "plugging veth $2 (Neutron port $1)..." + PORT_ID=$1 + IFNAME=$2 + ENDPOINT_ID=$3 + MAC_ADDRESS=$4 + NET_ID=$5 + echo "plugging veth $IFNAME (Neutron port $PORT_ID)..." # create a linux bridge - br_name="br"${4:0:12} + br_name="brq"${NET_ID:0:11} ip link show $br_name if [ $? -ne 0 ]; then echo "Bridge $br_name does not exist, create it" @@ -28,17 +33,21 @@ bind_port() { fi # connect the veth outside to linux bridge - ip link set dev $2 master $br_name - ip link set $2 up + ip link set dev $IFNAME master $br_name + ip link set $IFNAME up } unbind_port() { - echo "unplugging veth $1..." - br_name="br"${3:0:12} + PORT_ID=$1 + IFNAME=$2 + ENDPOINT_ID=$3 + MAC_ADDRESS=$4 + VIF_DETAILs=$5 + NET_ID=$6 + echo "unplugging veth $IFNAME..." + br_name="brq"${NET_ID:0:11} - ip link set dev $2 nomaster - ip link set $br_name down - ip link delete $br_name type bridge + ip link set dev $IFNAME nomaster } case $1 in