bgp

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommunityMaxSize     = 32
	CommunityMaxPartSize = 16
)

Variables

This section is empty.

Functions

func GenerateRouterID

func GenerateRouterID(nodeIPAware utils.NodeIPAware, configRouterID string) (string, error)

GenerateRouterID will generate a router ID based upon the user's configuration (or lack there of) and the node's primary IP address if the user has not specified. If the user has configured the router ID as "generate" then we will generate a router ID based upon fnv hashing the node's primary IP address.

func ParseNextHop

func ParseNextHop(path *apiutil.Path) (net.IP, error)

ParseNextHop takes in a GoBGP Path and parses out the destination's next hop from its attributes. If it can't parse a next hop IP from the GoBGP Path, it returns an error.

func ParsePath

func ParsePath(path *apiutil.Path) (*net.IPNet, net.IP, error)

ParsePath takes in a GoBGP Path and parses out the destination subnet and the next hop from its attributes. If successful, it will return the destination of the BGP path as a subnet form and the next hop. If it can't parse the destination or the next hop IP, it returns an error.

func ValidateCommunity

func ValidateCommunity(arg string) error

ValidateCommunity takes in a string and attempts to parse a BGP community out of it in a way that is similar to gobgp (internal/pkg/table/policy.go:ParseCommunity()). If it is not able to parse the community information it returns an error.

Types

type PathBuilder added in v2.7.0

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

PathBuilder helps construct BGP paths with native GoBGP v4 types. It automatically handles IPv4 vs IPv6 differences including: - Correct Family (AFI_IP/AFI_IP6 + SAFI_UNICAST) - NextHop attribute for IPv4 - MpReachNLRI attribute for IPv6

func NewPathBuilder added in v2.7.0

func NewPathBuilder(cidr string, nextHop string) (*PathBuilder, error)

NewPathBuilder creates a new PathBuilder for the given CIDR prefix and next-hop IP. It automatically detects IPv4 vs IPv6 from the CIDR and creates the appropriate BGP path attributes.

Example:

pb, err := bgp.NewPathBuilder("10.244.1.0/24", "192.168.1.1")
pb, err := bgp.NewPathBuilder("2001:db8::/64", "2001:db8::1")

func (*PathBuilder) Build added in v2.7.0

func (pb *PathBuilder) Build() (*apiutil.Path, error)

Build creates the final apiutil.Path ready to be sent to GoBGP.

func (*PathBuilder) WithWithdrawal added in v2.7.0

func (pb *PathBuilder) WithWithdrawal() *PathBuilder

WithWithdrawal marks this path as a withdrawal. Returns the builder for method chaining.

type PeerConfig added in v2.7.0

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

func NewPeerConfig added in v2.7.0

func NewPeerConfig(remoteIPStr string, remoteASN uint32, port *uint32, b64EncodedPassword utils.Base64String,
	localIP string,
) (PeerConfig, error)

func (PeerConfig) LocalIP added in v2.7.0

func (p PeerConfig) LocalIP() string

func (PeerConfig) Password added in v2.7.0

func (p PeerConfig) Password() string

func (PeerConfig) Port added in v2.7.0

func (p PeerConfig) Port() *uint32

func (PeerConfig) RemoteASN added in v2.7.0

func (p PeerConfig) RemoteASN() uint32

func (PeerConfig) RemoteIP added in v2.7.0

func (p PeerConfig) RemoteIP() net.IP

func (PeerConfig) String added in v2.7.0

func (p PeerConfig) String() string

Custom Stringer to prevent leaking passwords when printed

func (*PeerConfig) UnmarshalYAML added in v2.7.0

func (p *PeerConfig) UnmarshalYAML(raw []byte) error

type PeerConfigs added in v2.7.0

type PeerConfigs []PeerConfig

func NewPeerConfigs added in v2.7.0

func NewPeerConfigs(
	remoteIPs []string,
	remoteASNs []uint32,
	ports []uint32,
	b64EncodedPasswords []string,
	localIPs []string,
	localAddress string,
) (PeerConfigs, error)

func (PeerConfigs) RemoteIPStrings added in v2.7.0

func (p PeerConfigs) RemoteIPStrings() []string

func (PeerConfigs) String added in v2.7.0

func (p PeerConfigs) String() string

Prints the PeerConfigs without the passwords leaking

Jump to

Keyboard shortcuts

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