Skip to content

Commit ef2a89d

Browse files
authored
Merge pull request #3152 from stgraber/main
incusd/device/nic_physical: Fix inheritance from network
2 parents b030aad + 974eb2b commit ef2a89d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/server/device/nic_physical.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ func (d *nicPhysical) validateConfig(instConf instance.ConfigReader, partialVali
141141
// managed: no
142142
// shortdesc: The managed network to link the device to (instead of specifying the `nictype` directly)
143143
if d.config["network"] != "" {
144+
// List of properties we import from the parent network.
145+
networkFields := []string{"gvrp", "mtu", "vlan", "vlan.tagged"}
146+
144147
requiredFields = append(requiredFields, "network")
145148

146-
bannedKeys := []string{"nictype", "parent", "mtu", "vlan", "vlan.tagged", "gvrp"}
149+
bannedKeys := append([]string{"nictype", "parent"}, networkFields...)
147150
for _, bannedKey := range bannedKeys {
148151
if d.config[bannedKey] != "" {
149152
return fmt.Errorf("Cannot use %q property in conjunction with %q property", bannedKey, "network")
@@ -171,8 +174,8 @@ func (d *nicPhysical) validateConfig(instConf instance.ConfigReader, partialVali
171174
// Get actual parent device from network's parent setting.
172175
d.config["parent"] = netConfig["parent"]
173176

174-
// Copy certain keys verbatim from the network's settings.
175-
for _, field := range optionalFields {
177+
// Copy certain keys verbatim from the parent network's settings.
178+
for _, field := range networkFields {
176179
_, found := netConfig[field]
177180
if found {
178181
d.config[field] = netConfig[field]

0 commit comments

Comments
 (0)