Skip to content

Commit 424ceb1

Browse files
committed
Add support for Bridge Parameters
See https://bugs.launchpad.net/bugs/1771120 We should support parsing and passing on all of the bridge parameters that are allowed.
1 parent e4ab5bd commit 424ceb1

File tree

2 files changed

+88
-6
lines changed

2 files changed

+88
-6
lines changed

network/netplan/netplan.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,21 @@ type Wifi struct {
6363
Interface `yaml:",inline"`
6464
}
6565

66+
type BridgeParameters struct {
67+
AgeingTime *int `yaml:"ageing-time,omitempty"`
68+
ForwardDelay *int `yaml:"forward-delay,omitempty"`
69+
HelloTime *int `yaml:"hello-time,omitempty"`
70+
MaxAge *int `yaml:"max-age,omitempty"`
71+
PathCost map[string]int `yaml:"path-cost,omitempty"`
72+
PortPriority map[string]int `yaml:"port-priority,omitempty"`
73+
Priority *int `yaml:"priority,omitempty"`
74+
STP *bool `yaml:"stp,omitempty"`
75+
}
76+
6677
type Bridge struct {
6778
Interfaces []string `yaml:"interfaces,omitempty,flow"`
6879
Interface `yaml:",inline"`
69-
// TODO: parameters
80+
Parameters BridgeParameters `yaml:"parameters,omitempty"`
7081
}
7182

7283
type Route struct {
@@ -166,7 +177,7 @@ type BondParameters struct {
166177
MinLinks *int `yaml:"min-links,omitempty"`
167178
TransmitHashPolicy string `yaml:"transmit-hash-policy,omitempty"`
168179
ADSelect IntString `yaml:"ad-select,omitempty"`
169-
AllSlavesActive bool `yaml:"all-slaves-active,omitempty"`
180+
AllSlavesActive *bool `yaml:"all-slaves-active,omitempty"`
170181
ARPInterval *int `yaml:"arp-interval,omitempty"`
171182
ARPIPTargets []string `yaml:"arp-ip-targets,omitempty"`
172183
ARPValidate IntString `yaml:"arp-validate,omitempty"`

network/netplan/netplan_test.go

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ network:
164164
`)
165165
}
166166

167-
func (s *NetplanSuite) TestBondIntValues(c *gc.C) {
167+
func (s *NetplanSuite) TestBondsIntParameters(c *gc.C) {
168168
// several parameters can be specified as an integer or a string
169169
// such as 'mode: 0' is the same as 'balance-rr'
170170
checkNetplanRoundTrips(c, `
@@ -187,6 +187,7 @@ network:
187187
mode: 0
188188
lacp-rate: 1
189189
ad-select: 1
190+
all-slaves-active: true
190191
arp-validate: 0
191192
arp-all-targets: 0
192193
fail-over-mac-policy: 1
@@ -212,6 +213,7 @@ network:
212213
mode: balance-rr
213214
lacp-rate: fast
214215
ad-select: bandwidth
216+
all-slaves-active: false
215217
arp-validate: filter
216218
arp-all-targets: all
217219
fail-over-mac-policy: follow
@@ -269,6 +271,12 @@ network:
269271
match:
270272
macaddress: de:ad:be:ef:01:02
271273
set-name: id1
274+
id2:
275+
match:
276+
macaddress: de:ad:be:ef:01:03
277+
id3:
278+
match:
279+
macaddress: de:ad:be:ef:01:04
272280
bonds:
273281
bond0:
274282
interfaces: [id0, id1]
@@ -285,7 +293,7 @@ network:
285293
- 192.168.0.1
286294
- 192.168.10.20
287295
arp-validate: none
288-
arp-all-targets: boo
296+
arp-all-targets: all
289297
up-delay: 0
290298
down-delay: 0
291299
fail-over-mac-policy: follow
@@ -298,8 +306,71 @@ network:
298306
`)
299307
}
300308

301-
func (s *NetplanSuite) TestAllEthernetParams(c *gc.C) {
302-
// Make sure we can handle any fields in Ethernet stanzas
309+
func (s *NetplanSuite) TestBridgesAllParameters(c *gc.C) {
310+
// All parameters don't inherently make sense at the same time, but we should be able to parse all of them.
311+
checkNetplanRoundTrips(c, `
312+
network:
313+
version: 2
314+
renderer: NetworkManager
315+
ethernets:
316+
id0:
317+
match:
318+
macaddress: "00:11:22:33:44:55"
319+
set-name: id0
320+
id1:
321+
match:
322+
macaddress: de:ad:be:ef:01:02
323+
set-name: id1
324+
id2:
325+
match:
326+
macaddress: de:ad:be:ef:01:03
327+
set-name: id2
328+
bridges:
329+
br-id0:
330+
interfaces: [id0]
331+
accept-ra: true
332+
addresses:
333+
- 123.123.123.123/24
334+
dhcp4: false
335+
dhcp6: true
336+
dhcp-identifier: duid
337+
parameters:
338+
ageing-time: 0
339+
forward-delay: 0
340+
hello-time: 0
341+
max-age: 0
342+
path-cost:
343+
id0: 0
344+
port-priority:
345+
id0: 0
346+
priority: 0
347+
stp: false
348+
br-id1:
349+
interfaces: [id1]
350+
accept-ra: false
351+
addresses:
352+
- 2001::1/64
353+
dhcp4: true
354+
dhcp6: true
355+
dhcp-identifier: mac
356+
parameters:
357+
ageing-time: 100
358+
forward-delay: 10
359+
hello-time: 20
360+
max-age: 10
361+
path-cost:
362+
id1: 50
363+
port-priority:
364+
id1: 50
365+
priority: 20000
366+
stp: true
367+
br-id2:
368+
interfaces: [id2]
369+
br-id3:
370+
interfaces: [id2]
371+
parameters:
372+
ageing-time: 10
373+
`)
303374
}
304375

305376
func (s *NetplanSuite) TestAllRoutesParams(c *gc.C) {

0 commit comments

Comments
 (0)