From cbfbe24afcf1e741185295463fbbba0d551abb8e Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Wed, 13 Nov 2024 22:35:17 +0100 Subject: [PATCH] libnetwork: support `mode` option for bridge L2 will be used to allow using existing bridges which netavark will neither create nor delete. Signed-off-by: Michael Zimmermann --- libnetwork/netavark/config.go | 4 ++++ libnetwork/types/const.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/libnetwork/netavark/config.go b/libnetwork/netavark/config.go index 8b43a787e..33ef26acf 100644 --- a/libnetwork/netavark/config.go +++ b/libnetwork/netavark/config.go @@ -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) } diff --git a/libnetwork/types/const.go b/libnetwork/types/const.go index a91618200..a90e0aeeb 100644 --- a/libnetwork/types/const.go +++ b/libnetwork/types/const.go @@ -53,6 +53,9 @@ const ( Netavark NetworkBackend = "netavark" ) +// ValidBridgeModes is the list of valid mode options for the bridge driver +var ValidBridgeModes = []string{IPVLANModeL2, IPVLANModeL3} + // ValidMacVLANModes is the list of valid mode options for the macvlan driver var ValidMacVLANModes = []string{MacVLANModeBridge, MacVLANModePrivate, MacVLANModeVepa, MacVLANModePassthru}