gobgp

package
v1.13.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GoBGPIPv6Family is a read-only pointer to a gobgp.Family structure
	// representing IPv6 address family.
	GoBGPIPv6Family = &gobgp.Family{
		Afi:  gobgp.Family_AFI_IP6,
		Safi: gobgp.Family_SAFI_UNICAST,
	}
	// GoBGPIPv4Family is a read-only pointer to a gobgp.Family structure
	// representing IPv4 address family.
	GoBGPIPv4Family = &gobgp.Family{
		Afi:  gobgp.Family_AFI_IP,
		Safi: gobgp.Family_SAFI_UNICAST,
	}
)

Functions

func NewBGPRouterManager added in v1.12.0

func NewBGPRouterManager(params bgpRouterManagerParams) agent.BGPRouterManager

NewBGPRouterManager constructs a GoBGP-backed BGPRouterManager.

See NewBGPRouterManager for details.

func NewExportPodCIDRReconciler added in v1.13.0

func NewExportPodCIDRReconciler() exportPodCIDRReconcilerOut

func NewLBServiceReconciler added in v1.13.0

func NewLBServiceReconciler(diffStore DiffStore[*slim_corev1.Service]) lbServiceReconcilerOut

func NewNeighborReconciler added in v1.13.0

func NewNeighborReconciler() neighborReconcilerOut

func NewPreflightReconciler added in v1.13.0

func NewPreflightReconciler() preflightReconcilerOut

Types

type Advertisement struct {
	Net  *net.IPNet
	Path *gobgp.Path
}

Advertisement is a container object which associates a net.IPNet with a gobgp.Path.

The `Net` field makes comparing this Advertisement with another IPNet encoded prefixes simple.

The `Path` field is a gobgp.Path object which can be forwarded to our server's WithdrawPath method, making withdrawing an advertised route simple.

type BGPRouterManager added in v1.12.0

type BGPRouterManager struct {
	lock.RWMutex
	Servers     LocalASNMap
	Reconcilers []ConfigReconciler
}

BGPRouterManager implements the pkg.bgpv1.agent.BGPRouterManager interface.

This BGPRouterMananger utilizes the gobgp project to implement a BGP routing plane.

Logically, this manager views each CiliumBGPVirtualRouter within a CiliumBGPPeeringPolicy as a BGP router instantiated on its host.

BGP routers are grouped and accessed by their local ASNs, thus this backend mandates that each CiliumBGPPeeringConfig have a unique local ASN and precludes a single host instantiating two routers with the same local ASN.

This manager employs two main data structures to implement its high level business logic.

A reconcilerDiff is used to establish which BgpServers must be created, and removed from the Mananger along with which servers must have their configurations reconciled.

A set of ReconcilerConfigFunc(s), which usages are wrapped by the ReconcileBGPConfig function, reconcile individual features of a CiliumBGPPeeringConfig.

Together, the high-level flow the manager takes is:

  • Instantiate a reconcilerDiff to compute which BgpServers to create, remove, and reconcile
  • Create any BgpServers necessary, run ReconcilerConfigFuncs(s) on each
  • Run each ReconcilerConfigFunc, by way of ReconcileBGPConfig, on any BgpServers marked for reconcile

BgpServers are abstracted by the ServerWithConfig structure which provides a method set for low-level BGP operations.

func (*BGPRouterManager) ConfigurePeers added in v1.12.0

ConfigurePeers is a declarative API for configuring the BGP peering topology given a desired CiliumBGPPeeringPolicy.

ConfigurePeers will evaluate BGPRouterManager's current state and the desired CiliumBGPPeeringPolicy policy then take the necessary actions to apply the provided policy. For more details see BGPRouterManager's comments.

ConfigurePeers should return only once a subsequent invocation is safe. This method is not thread safe and does not intend to be called concurrently.

func (*BGPRouterManager) GetPeers added in v1.13.2

func (m *BGPRouterManager) GetPeers(ctx context.Context) ([]*models.BgpPeer, error)

GetPeers gets peering state from previously initialized gobgp instances.

type ConfigReconciler added in v1.13.0

type ConfigReconciler interface {
	// Priority is used to determine the order in which reconcilers are called. Reconcilers are called from lowest to
	// highest.
	Priority() int
	// If the `Config` field in `sc` is nil the reconciler should unconditionally
	// perform the reconciliation actions, as no previous configuration is present.
	Reconcile(ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState) error
}

ConfigReconciler is a interface for reconciling a particular aspect of an old and new *v2alpha1api.CiliumBGPVirtualRouter

type DiffStore added in v1.13.0

type DiffStore[T k8sRuntime.Object] interface {
	resource.Store[T]

	// Diff returns a list of items that have been upserted(updated or inserted) and deleted since the last call to Diff.
	Diff() (upserted []T, deleted []resource.Key, err error)
}

DiffStore is a super set of the resource.Store. The diffStore tracks all changes made to it since the last time the user synced up. This allows a user to get a list of just the changed objects while still being able to query the full store for a full sync.

func NewDiffStore added in v1.13.0

func NewDiffStore[T k8sRuntime.Object](params diffStoreParams[T]) DiffStore[T]

type ExportPodCIDRReconciler added in v1.13.0

type ExportPodCIDRReconciler struct{}

func (*ExportPodCIDRReconciler) Priority added in v1.13.0

func (r *ExportPodCIDRReconciler) Priority() int

func (*ExportPodCIDRReconciler) Reconcile added in v1.13.0

type LBServiceReconciler added in v1.13.0

type LBServiceReconciler struct {
	// contains filtered or unexported fields
}

func (*LBServiceReconciler) Priority added in v1.13.0

func (r *LBServiceReconciler) Priority() int

func (*LBServiceReconciler) Reconcile added in v1.13.0

type LocalASNMap added in v1.12.0

type LocalASNMap map[int]*ServerWithConfig

LocalASNMap maps local ASNs to their associated BgpServers and server configuration info.

type NeighborReconciler added in v1.13.0

type NeighborReconciler struct{}

func (*NeighborReconciler) Priority added in v1.13.0

func (r *NeighborReconciler) Priority() int

func (*NeighborReconciler) Reconcile added in v1.13.0

type PreflightReconciler added in v1.13.0

type PreflightReconciler struct{}

func (*PreflightReconciler) Priority added in v1.13.0

func (r *PreflightReconciler) Priority() int

func (*PreflightReconciler) Reconcile added in v1.13.0

type ServerLogger

type ServerLogger struct {
	// contains filtered or unexported fields
}

implement github.com/osrg/gobgp/v3/pkg/log/Logger interface

func NewServerLogger

func NewServerLogger(l *logrus.Logger, asn uint32) *ServerLogger

func (*ServerLogger) Debug

func (l *ServerLogger) Debug(msg string, fields gobgpLog.Fields)

func (*ServerLogger) Error

func (l *ServerLogger) Error(msg string, fields gobgpLog.Fields)

func (*ServerLogger) Fatal

func (l *ServerLogger) Fatal(msg string, fields gobgpLog.Fields)

func (*ServerLogger) GetLevel

func (l *ServerLogger) GetLevel() gobgpLog.LogLevel

func (*ServerLogger) Info

func (l *ServerLogger) Info(msg string, fields gobgpLog.Fields)

func (*ServerLogger) Panic

func (l *ServerLogger) Panic(msg string, fields gobgpLog.Fields)

func (*ServerLogger) SetLevel

func (l *ServerLogger) SetLevel(level gobgpLog.LogLevel)

func (*ServerLogger) Warn

func (l *ServerLogger) Warn(msg string, fields gobgpLog.Fields)

type ServerWithConfig added in v1.12.0

type ServerWithConfig struct {
	// a gobgp backed BgpServer configured in accordance to the accompanying
	// CiliumBGPVirtualRouter configuration.
	Server *server.BgpServer
	// The CiliumBGPVirtualRouter configuration which drives the configuration
	// of the above BgpServer.
	//
	// If this field is nil it means the above BgpServer has had no
	// configuration applied to it.
	Config *v2alpha1api.CiliumBGPVirtualRouter
	// Holds any announced PodCIDR routes.
	PodCIDRAnnouncements []Advertisement
	// Holds any announced Service routes.
	ServiceAnnouncements map[resource.Key][]Advertisement
}

ServerWithConfig is a container for grouping a gobgp BgpServer with the Cilium's BGP control plane related configuration.

It exports a method set for manipulating the BgpServer. However, this struct is a dumb object. The calling code is required to keep the BgpServer's configuration and associated configuration fields in sync.

func NewServerWithConfig added in v1.12.0

func NewServerWithConfig(ctx context.Context, startReq *gobgp.StartBgpRequest) (*ServerWithConfig, error)

NewServerWithConfig will start an underlying BgpServer utilizing startReq for its initial configuration.

The returned ServerWithConfig has a nil CiliumBGPVirtualRouter config, and is ready to be provided to ReconcileBGPConfig.

Canceling the provided context will kill the BgpServer along with calling the underlying BgpServer's Stop() method.

func (*ServerWithConfig) AddNeighbor added in v1.12.0

AddNeighbor will add the CiliumBGPNeighbor to the gobgp.BgpServer, creating a BGP peering connection.

func (*ServerWithConfig) AdvertisePath added in v1.12.0

func (sc *ServerWithConfig) AdvertisePath(ctx context.Context, ip *net.IPNet) (Advertisement, error)

AdvertisePath will advertise the provided IP network to any existing and all subsequently added Neighbors currently peered with this BgpServer.

`ip` can be an ipv4 or ipv6 and this method will handle the differences between MP BGP and BGP.

It is an error to advertise an IPv6 path when no IPv6 address is configured on this Cilium node, selfsame for IPv4.

Nexthop of the path will always set to "0.0.0.0" in IPv4 and "::" in IPv6, so that GoBGP selects appropriate actual nexthop address and advertise it.

An Advertisement is returned which may be passed to WithdrawPath to remove this Advertisement.

func (*ServerWithConfig) GetPeerState added in v1.13.2

func (sc *ServerWithConfig) GetPeerState(ctx context.Context) ([]*models.BgpPeer, error)

GetPeerState invokes goBGP ListPeer API to get current peering state.

func (*ServerWithConfig) RemoveNeighbor added in v1.12.0

func (sc *ServerWithConfig) RemoveNeighbor(ctx context.Context, n *v2alpha1api.CiliumBGPNeighbor) error

RemoveNeighbor will remove the CiliumBGPNeighbor from the gobgp.BgpServer, disconnecting the BGP peering connection.

func (*ServerWithConfig) WithdrawPath added in v1.12.0

func (sc *ServerWithConfig) WithdrawPath(ctx context.Context, advert Advertisement) error

WithdrawPath withdraws an Advertisement produced by AdvertisePath from this BgpServer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL