Skip to content

Commit

Permalink
lxd/network: Support setting tag_request column when adding logical s…
Browse files Browse the repository at this point in the history
…witch ports

Signed-off-by: Mark Bolton <[email protected]>
  • Loading branch information
boltmark committed Oct 3, 2024
1 parent 0abe687 commit 4011fde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lxd/network/driver_ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,7 @@ func (n *ovn) InstanceDevicePortStart(opts *OVNInstanceNICSetupOpts, securityACL
MAC: mac,
IPs: staticIPs,
Parent: nestedPortParentName,
VLAN: nestedPortVLAN,
NestedVLAN: nestedPortVLAN,
Location: n.state.ServerName,
}, true)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions lxd/network/openvswitch/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ type OVNSwitchPortOpts struct {
DHCPv4OptsID OVNDHCPOptionsUUID // Optional, if empty, no DHCPv4 enabled on port.
DHCPv6OptsID OVNDHCPOptionsUUID // Optional, if empty, no DHCPv6 enabled on port.
Parent OVNSwitchPort // Optional, if set a nested port is created.
VLAN uint16 // Optional, use with Parent to request a specific VLAN for nested port.
NestedVLAN uint16 // Optional, use with Parent to request a specific VLAN for nested port.
Location string // Optional, use to indicate the name of the LXD server this port is bound to.
VLAN uint16 // Optional, use to indicate a specific VLAN for the port.
}

// OVNACLRule represents an ACL rule that can be added to a logical switch or port group.
Expand Down Expand Up @@ -1239,7 +1240,7 @@ func (o *OVN) LogicalSwitchPortAdd(switchName OVNSwitch, portName OVNSwitchPort,
if opts != nil {
// Created nested VLAN port if requested.
if opts.Parent != "" {
args = append(args, string(opts.Parent), fmt.Sprintf("%d", opts.VLAN))
args = append(args, string(opts.Parent), fmt.Sprintf("%d", opts.NestedVLAN))
}

ipStr := make([]string, 0, len(opts.IPs))
Expand Down Expand Up @@ -1269,6 +1270,10 @@ func (o *OVN) LogicalSwitchPortAdd(switchName OVNSwitch, portName OVNSwitchPort,
if opts.Location != "" {
args = append(args, "--", "set", "logical_switch_port", string(portName), fmt.Sprintf("external_ids:%s=%s", ovnExtIDLXDLocation, opts.Location))
}

if opts.VLAN != 0 {
args = append(args, "--", "set", "logical_switch_port", string(portName), fmt.Sprintf("tag_request=%d", opts.VLAN))
}
}

args = append(args, "--", "set", "logical_switch_port", string(portName), fmt.Sprintf("external_ids:%s=%s", ovnExtIDLXDSwitch, switchName))
Expand Down

0 comments on commit 4011fde

Please sign in to comment.