Skip to content

Commit

Permalink
Merge pull request #1900 from zzaimeche/ovsbpdu-fix
Browse files Browse the repository at this point in the history
Allow enabling bpdu-forwarding on OVS bridges
  • Loading branch information
zzaimeche authored Nov 6, 2019
2 parents f2e69e6 + 26878c1 commit 3495e0e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chef/cookbooks/barclamp/libraries/barclamp_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Network
attr_reader :vlan, :use_vlan
attr_reader :add_bridge, :add_ovs_bridge, :bridge_name
attr_reader :conduit
attr_reader :ovs_forward_bpdu

def initialize(node, net, data)
@node = node
Expand All @@ -109,6 +110,7 @@ def initialize(node, net, data)
@add_bridge = data["add_bridge"]
@add_ovs_bridge = data["add_ovs_bridge"]
@bridge_name = data["bridge_name"]
@ovs_forward_bpdu = data["ovs_forward_bpdu"]
# let's resolve this only if needed
@interface = nil
@interface_list = nil
Expand Down
4 changes: 4 additions & 0 deletions chef/cookbooks/barclamp/libraries/nic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ def plug(slave)
::Kernel.system("ovs-vsctl add-port #{@nic} #{slave}")
end

def ovs_forward_bpdu(forward)
::Kernel.system("ovs-vsctl set Bridge #{@nic} other_config:forward-bpdu=#{forward}")
end

def self.create(nic, slaves = [])
Chef::Log.info("Creating new OVS bridge #{nic}")
if self.exists?(nic)
Expand Down
10 changes: 10 additions & 0 deletions chef/cookbooks/network/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ def kill_nic(nic)
our_iface = br
net_ifs << our_iface.name
end

unless network.ovs_forward_bpdu.nil?
Chef::Log.info("OVS BPDU forwarding set to #{network.ovs_forward_bpdu}.")
ifs[our_iface.name]["ovs_forward_bpdu"] = network.ovs_forward_bpdu
end

if network.mtu
Chef::Log.info("Using mtu #{network.mtu} for #{network.name} network on #{our_iface.name}")
ifs[our_iface.name]["mtu"] = network.mtu
Expand Down Expand Up @@ -682,15 +688,19 @@ def kill_nic(nic)
end

pre_up_script = "/etc/wicked/scripts/#{nic.name}-pre-up"
ovs_forward_bpdu = ifs[nic.name]["ovs_forward_bpdu"] || false
is_admin_nwk = if_mapping.key?("admin") && if_mapping["admin"].include?(nic.name)

nic.ovs_forward_bpdu(ovs_forward_bpdu)

template pre_up_script do
owner "root"
group "root"
mode "0755"
source "ovs-pre-up.sh.erb"
variables(
bridgename: nic.name,
ovs_forward_bpdu: ovs_forward_bpdu,
is_admin_nwk: is_admin_nwk
)
end
Expand Down
1 change: 1 addition & 0 deletions chef/cookbooks/network/templates/default/ovs-pre-up.sh.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/bash

ovs-vsctl br-exists <%= @bridgename %> || exit 0
ovs-vsctl set bridge <%= @bridgename %> other-config:forward-bpdu=<%= @ovs_forward_bpdu %>
<%
# remove the "secure" fail-mode for bridges that share an interface
# with the "admin" network, otherwise the admin network will be offline
Expand Down
1 change: 1 addition & 0 deletions chef/data_bags/crowbar/template-network.schema
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"add_bridge": { "type": "bool", "required": true },
"add_ovs_bridge": { "type": "bool", "required": false },
"bridge_name": { "type": "str", "required": false },
"ovs_forward_bpdu": { "type": "bool", "required": false },
"subnet": { "type": "str", "required": true, "name": "IpAddress" },
"netmask": { "type": "str", "required": true, "name": "IpAddress" },
"broadcast": { "type": "str", "required": true, "name": "IpAddress" },
Expand Down

0 comments on commit 3495e0e

Please sign in to comment.