Skip to content

Commit

Permalink
Set vlan_filtering 1 at linux-bridge without ports (#172)
Browse files Browse the repository at this point in the history
This PR add vlanfiltering_flag even if there is not port configured at the
linux bridge in the desiredState.

This is necessary in case ports are added outside of nmstate (linux bridge CNI) and vlan
communicatoin and filtering is needed

Signed-off-by: Quique Llorente <[email protected]>
  • Loading branch information
qinqon authored and phoracek committed Sep 20, 2019
1 parent be1d57c commit b3f0c02
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
5 changes: 1 addition & 4 deletions pkg/helper/bridges.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ func getBridgesUp(desiredState nmstatev1alpha1.State) (map[string][]string, erro
portList = append(portList, port.String())
}

// Add only the bridge we have some outbound port to configure
if len(portList) > 0 {
foundBridgesWithPorts[bridgeUp.Get("name").String()] = portList
}
foundBridgesWithPorts[bridgeUp.Get("name").String()] = portList
}

return foundBridgesWithPorts, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/helper/bridges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ var _ = Describe("Network desired state bridge parser", func() {
BeforeEach(func() {
desiredState = bridgeWithNoPorts
})
It("should return empty map", func() {
It("should return the bridge with empty port list", func() {
Expect(err).ToNot(HaveOccurred())
Expect(obtainedBridgesAndPorts).To(BeEmpty())
Expect(obtainedBridgesAndPorts).To(HaveKeyWithValue("br1", BeEmpty()))
})
})
Context("when there are bridges up", func() {
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/simple_bridge_and_bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ var _ = Describe("NodeNetworkState", func() {
miimon: '120'
`)

br1UpNoPorts = nmstatev1alpha1.State(`interfaces:
- name: br1
type: linux-bridge
state: up
bridge:
options:
stp:
enabled: false
port: []
`)

br1Up = nmstatev1alpha1.State(`interfaces:
- name: br1
type: linux-bridge
Expand Down Expand Up @@ -94,6 +105,23 @@ var _ = Describe("NodeNetworkState", func() {
`)
)
Context("when desiredState is configured", func() {
Context("with a linux bridge up with no ports", func() {
BeforeEach(func() {
updateDesiredState(br1UpNoPorts)
})
AfterEach(func() {
updateDesiredState(br1Absent)
for _, node := range nodes {
interfacesNameForNode(node).ShouldNot(ContainElement("br1"))
}
})
It("should have the linux bridge at currentState with vlan_filtering 1", func() {
for _, node := range nodes {
interfacesNameForNode(node).Should(ContainElement("br1"))
bridgeDescription(node, "br1").Should(ContainSubstring("vlan_filtering 1"))
}
})
})
Context("with a linux bridge up", func() {
BeforeEach(func() {
updateDesiredState(br1Up)
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,9 @@ func vlansCardinality(node string, connection string) AsyncAssertion {
}, ReadTimeout, ReadInterval)

}

func bridgeDescription(node string, bridgeName string) AsyncAssertion {
return Eventually(func() (string, error) {
return run(node, "sudo", "ip", "-d", "link", "show", "type", "bridge", bridgeName)
}, ReadTimeout, ReadTimeout)
}

0 comments on commit b3f0c02

Please sign in to comment.