github.com/cilium/cilium@v1.16.2/pkg/bgpv1/agent/mode/mode.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package mode
     5  
     6  import (
     7  	"github.com/cilium/cilium/pkg/lock"
     8  )
     9  
    10  // Mode defines the modes in which BGP agent can be configured.
    11  type Mode int
    12  
    13  const (
    14  	// Disabled mode, BGP control plane is not enabled
    15  	Disabled Mode = iota
    16  	// BGPv1 mode is enabled, BGP configuration of the agent will rely on matching CiliumBGPPeeringPolicy for the node.
    17  	BGPv1
    18  	// BGPv2 mode is enabled, BGP configuration of the agent will rely on CiliumBGPNodeConfig, CiliumBGPAdvertisement and CiliumBGPPeerConfig.
    19  	BGPv2
    20  )
    21  
    22  func NewConfigMode() *ConfigMode {
    23  	return &ConfigMode{}
    24  }
    25  
    26  type ConfigMode struct {
    27  	lock.RWMutex
    28  	configMode Mode
    29  }
    30  
    31  func (m *ConfigMode) Get() Mode {
    32  	m.RLock()
    33  	defer m.RUnlock()
    34  	return m.configMode
    35  }
    36  
    37  func (m *ConfigMode) Set(mode Mode) {
    38  	m.Lock()
    39  	defer m.Unlock()
    40  	m.configMode = mode
    41  }