Skip to content

Commit

Permalink
libnetwork: support mode option for bridge
Browse files Browse the repository at this point in the history
L2 will be used to allow using existing bridges which netavark will
neither create nor delete.

Signed-off-by: Michael Zimmermann <[email protected]>
  • Loading branch information
M1cha committed Nov 25, 2024
1 parent ceceb40 commit 9954a5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libnetwork/netavark/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func (n *netavarkNetwork) networkCreate(newNetwork *types.Network, defaultNet bo
if len(value) == 0 {
return nil, errors.New("invalid vrf name")
}
case types.ModeOption:
if !slices.Contains(types.ValidBridgeModes, value) {
return nil, fmt.Errorf("unknown bridge mode %q", value)
}
default:
return nil, fmt.Errorf("unsupported bridge network option %s", key)
}
Expand Down
6 changes: 6 additions & 0 deletions libnetwork/types/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
// DefaultSubnet is the subnet that will be used for the default CNI network.
DefaultSubnet = "10.88.0.0/16"

BridgeModeManaged = "managed"
BridgeModeUnmanaged = "unmanaged"

// valid macvlan driver mode values
MacVLANModeBridge = "bridge"
MacVLANModePrivate = "private"
Expand Down Expand Up @@ -53,6 +56,9 @@ const (
Netavark NetworkBackend = "netavark"
)

// ValidBridgeModes is the list of valid mode options for the bridge driver
var ValidBridgeModes = []string{BridgeModeManaged, BridgeModeUnmanaged}

// ValidMacVLANModes is the list of valid mode options for the macvlan driver
var ValidMacVLANModes = []string{MacVLANModeBridge, MacVLANModePrivate, MacVLANModeVepa, MacVLANModePassthru}

Expand Down

0 comments on commit 9954a5c

Please sign in to comment.