bgp

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBgpPeerExists    = errors.New("bgp peer already exists")
	ErrBgpPeerNotExists = errors.New("bgp peer does not exist")
)
View Source
var (
	MetricSessionStatus = promauto.NewGauge(
		prometheus.GaugeOpts{
			Name: "doublezero_session_is_up",
			Help: "Status of session to doublezero",
		},
	)
	MetricSessionStatusDesc = `` /* 131-byte string literal not displayed */

)

Functions

This section is empty.

Types

type BgpServer

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

func NewBgpServer

func NewBgpServer(routerID net.IP, r RouteReaderWriter) (*BgpServer, error)

func (*BgpServer) AddPeer

func (b *BgpServer) AddPeer(p *PeerConfig, advertised []NLRI) error

func (*BgpServer) DeletePeer

func (b *BgpServer) DeletePeer(ip net.IP) error

func (*BgpServer) GetPeerStatus

func (b *BgpServer) GetPeerStatus(ip net.IP) Session

func (*BgpServer) GetStatusEvent

func (b *BgpServer) GetStatusEvent() <-chan SessionEvent

func (*BgpServer) Serve

func (b *BgpServer) Serve(lis []net.Listener) error

type NLRI

type NLRI struct {
	AsPath       []uint32
	NextHop      string
	Prefix       string
	PrefixLength uint8
	RouteTable   int
}

func NewNLRI

func NewNLRI(aspath []uint32, nexthop, prefix string, prefixlen uint8) (NLRI, error)

type PeerConfig

type PeerConfig struct {
	LocalAddress  net.IP
	RemoteAddress net.IP
	LocalAs       uint32
	RemoteAs      uint32
	Port          int
	RouteSrc      net.IP
	RouteTable    int
	FlushRoutes   bool
	NoInstall     bool
}

type Plugin

type Plugin struct {
	AdvertisedNLRI    []NLRI
	PeerStatusChan    chan SessionEvent
	RouteSrc          net.IP
	RouteTable        int // kernel routing table to target for writing/removing
	FlushRoutes       bool
	NoInstall         bool
	RouteReaderWriter RouteReaderWriter
}

func NewBgpPlugin

func NewBgpPlugin(
	advertised []NLRI,
	routeSrc net.IP,
	routeTable int,
	peerStatus chan SessionEvent,
	flushRoutes bool,
	noInstall bool,
	routeReaderWriter RouteReaderWriter) *Plugin

func (*Plugin) GetCapabilities

func (p *Plugin) GetCapabilities(peer corebgp.PeerConfig) []corebgp.Capability

func (*Plugin) OnClose

func (p *Plugin) OnClose(peer corebgp.PeerConfig)

func (*Plugin) OnEstablished

func (*Plugin) OnOpenMessage

func (p *Plugin) OnOpenMessage(peer corebgp.PeerConfig, routerID netip.Addr, capabilities []corebgp.Capability) *corebgp.Notification

type RouteReaderWriter

type RouteReaderWriter interface {
	RouteAdd(*routing.Route) error
	RouteDelete(*routing.Route) error
	RouteByProtocol(int) ([]*routing.Route, error)
}

type Session

type Session struct {
	SessionStatus     SessionStatus `json:"session_status"`
	LastSessionUpdate int64         `json:"last_session_update"`
}

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

type SessionEvent

type SessionEvent struct {
	PeerAddr net.IP
	Session  Session
}

type SessionStatus

type SessionStatus int
const (
	SessionStatusunknown SessionStatus = iota
	SessionStatusPending
	SessionStatusInitializing
	SessionStatusDown
	SessionStatusUp
)

func (SessionStatus) FromString

func (s SessionStatus) FromString(sessionStatus string) SessionStatus

func (SessionStatus) MarshalJSON

func (s SessionStatus) MarshalJSON() ([]byte, error)

func (SessionStatus) String

func (s SessionStatus) String() string

func (*SessionStatus) UnmarshalJSON

func (s *SessionStatus) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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