From 6a553c226bd78bd3f615483f592c9e6f426c98bc Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 14 Apr 2021 15:53:45 +0200 Subject: [PATCH] B #: Fix PHYDEV behavior for bridge networks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit co-authored-by: Christian González (cherry picked from commit 356c654801cc4007864057b0a375f6e76af83e0e) --- src/vnm_mad/remotes/lib/no_vlan.rb | 34 ++++++++++++------------------ 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/vnm_mad/remotes/lib/no_vlan.rb b/src/vnm_mad/remotes/lib/no_vlan.rb index 6c477330e7..16c4e8fe3b 100644 --- a/src/vnm_mad/remotes/lib/no_vlan.rb +++ b/src/vnm_mad/remotes/lib/no_vlan.rb @@ -25,17 +25,10 @@ module VNMMAD super(vm, xpath_filter, deploy_id) end - def create_vlan_dev - true - end - - def delete_vlan_dev - true - end # Activate the driver and creates bridges and tags devices as needed. def activate - lock + lock @bridges = list_bridges @@ -44,6 +37,15 @@ module VNMMAD # Create the bridge. create_bridge + + # Return if vlan device is already in the bridge. + next if !nic[:phydev] || @bridges[@nic[:bridge]].include? @nic[:phydev] + + # Add phydev device to the bridge. + OpenNebula.exec_and_log("#{command(:ip)} link set " \ + "#{@nic[:phydev]} master #{@nic[:bridge]}") + + @bridges[@nic[:bridge]] << @nic[:phydev] end unlock @@ -75,8 +77,10 @@ module VNMMAD # Return if we want to keep the empty bridge next if @nic[:conf][:keep_empty_bridge] - # Return if the bridge is not empty - next unless @bridges[@nic[:bridge]].empty? + # Return if the phydev device is not the only left device in + # the bridge. + next if (@bridges[@nic[:bridge]].length > 1) || + !@bridges[@nic[:bridge]].include?(@nic[:phydev]) # Delete the bridge. OpenNebula.exec_and_log("#{command(:ip)} link delete"\ @@ -90,16 +94,6 @@ module VNMMAD 0 end - private - - def gen_vlan_dev_name - @nic[:vlan_dev] = @nic[:phydev] if @nic[:phydev] - end - - def validate_vlan_id - true - end - end end