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

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package agent
     5  
     6  import (
     7  	"context"
     8  
     9  	"github.com/cilium/cilium/api/v1/models"
    10  	restapi "github.com/cilium/cilium/api/v1/server/restapi/bgp"
    11  	v2api "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
    12  	v2alpha1api "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2alpha1"
    13  )
    14  
    15  // BGPRouterManager provides a declarative API for defining
    16  // BGP peers.
    17  type BGPRouterManager interface {
    18  	// ConfigurePeers evaluates the provided CiliumBGPPeeringPolicy
    19  	// and the implementation will configure itself to apply this policy.
    20  	//
    21  	// A ControllerState structure is provided which captures Cilium's runtime
    22  	// state at the time of this method's invocation. It must remain read-only.
    23  	//
    24  	// ConfigurePeers should block until it can ensure a subsequent call
    25  	// to ConfigurePeers can occur without conflict.
    26  	//
    27  	// ConfigurePeers should not be called concurrently and expects invocations
    28  	// to be serialized contingent to the method's completion.
    29  	//
    30  	// An error is returned only when the implementation can determine a
    31  	// critical flaw with the peering policy, not when network connectivity
    32  	// is an issue.
    33  	//
    34  	// Providing a nil policy to ConfigurePeers will withdrawal all routes
    35  	// and disconnect from the peers.
    36  	ConfigurePeers(ctx context.Context, policy *v2alpha1api.CiliumBGPPeeringPolicy, ciliumNode *v2api.CiliumNode) error
    37  
    38  	// ReconcileInstances evaluates the provided CiliumBGPNodeConfig
    39  	// and the implementation will configure itself to apply this configuration.
    40  	ReconcileInstances(ctx context.Context, bgpnc *v2alpha1api.CiliumBGPNodeConfig, ciliumNode *v2api.CiliumNode) error
    41  
    42  	// GetPeers fetches BGP peering state from underlying routing daemon.
    43  	//
    44  	// List of all peers will be returned and if there are multiple instances of
    45  	// BGP daemon running locally, then peers can be differentiated based on
    46  	// local AS number.
    47  	GetPeers(ctx context.Context) ([]*models.BgpPeer, error)
    48  
    49  	// GetRoutes fetches BGP routes from underlying routing daemon's RIBs.
    50  	GetRoutes(ctx context.Context, params restapi.GetBgpRoutesParams) ([]*models.BgpRoute, error)
    51  
    52  	// GetRoutePolicies fetches BGP routing policies from underlying routing daemon.
    53  	GetRoutePolicies(ctx context.Context, params restapi.GetBgpRoutePoliciesParams) ([]*models.BgpRoutePolicy, error)
    54  
    55  	// Stop will stop all BGP instances and clean up local state.
    56  	Stop()
    57  }