gobble

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	NDAUnspec uint16 = iota
	NDADst
	NDALLAddr
	NDACacheInfo
	NDAProbes
	NDAVLAN
	NDAPort
	NDAVNI
	NDAIfIndex
	NDAMaster
	NDALinkNetnsID
	NDASrcVNI
)

attribute types

View Source
const (
	NTFUse        = 0x01
	NTFSelf       = 0x02
	NTFMaster     = 0x04
	NTFProxy      = 0x08
	NTFExtLearned = 0x10
	NTFOffloaded  = 0x20
	NTFRouter     = 0x80
)

neighbor cache entry flags

View Source
const (
	NUDIncomplete = 0x01
	NUDReachable  = 0x02
	NUDStale      = 0x04
	NUDDelay      = 0x08
	NUDProbe      = 0x10
	NUDFailed     = 0x20
	NUDNoarp      = 0x40
	NUDPermanent  = 0x80
	NUDNone       = 0x00
)

neighbor cache entry states

View Source
const (
	IFLAInfoUnspec uint16 = iota
	IFLAInfoKind
	IFLAInfoData
)

interface link address attribute types

View Source
const (
	IFLAVXLANUnspec uint16 = iota
	IFLAVXLANID
)

vxlan attribute types

Variables

This section is empty.

Functions

func AddNeighbors added in v0.1.2

func AddNeighbors(ns []Neighbor) error

AddNeighbors adds the provided set of neighbors to the Linux kernel

func AddRoutes added in v0.1.2

func AddRoutes(rs []Route) error

AddRoutes adds the supplied set of routes to the Linux routing tables

func Ensure

func Ensure(bgpState *BgpState, baselayerState *BaselayerState)

Ensure that the baselayer satisfies bgp's view of the world

func EnsureTableRules

func EnsureTableRules()

EnsureTableRules ensures that the IP routing policy rules are set up for the routing table Gobble presides over.

func RemoveNeighbors added in v0.1.2

func RemoveNeighbors(ns []Neighbor) error

RemoveNeighbors removes the provided set of neighbors from the Linux kernel

func RemoveRoutes added in v0.1.2

func RemoveRoutes(rs []Route) error

RemoveRoutes removes the supplied set of routes from the Linux routing tables

Types

type BaselayerState

type BaselayerState struct {
	DestRT       map[string]Route // Destination keyed routing table
	Fib          []Neighbor
	Neighborhood []Neighbor
	Links        map[uint32]*Link
}

BaselayerState keeps track of state in the Linux packet layer

func ReadBaselayer

func ReadBaselayer() (*BaselayerState, error)

ReadBaselayer reads the underlying routing, neighbor and forwarding tables from the Linux kernel.

func (*BaselayerState) GetPeerMac

func (b *BaselayerState) GetPeerMac() (net.HardwareAddr, error)

GetPeerMac finds the MAC address of our link level peer router. TODO Right now we assume there is only 1.

func (*BaselayerState) GetPeerOif

func (b *BaselayerState) GetPeerOif() uint32

GetPeerOif finds the interface our link level peer router is on. TODO right now assume there is only 1.

func (BaselayerState) IsLocalIP

func (b BaselayerState) IsLocalIP(ip string) bool

IsLocalIP determines whether or not an IP address is local to the machine Gobble is running on.

type BgpState

type BgpState struct {
	Type2Routes []Type2EvpnRoute
	Type3Routes []Type3EvpnRoute
}

BgpState collects Type2Routes and Type3Routes in one place

func ReadBgp

func ReadBgp() (*BgpState, error)

reach out to gobgpd through grpc to get the global routing information base (rib)

type Config added in v0.1.3

type Config struct {
	Oif        uint32 `yaml:"oif"`
	Quantum    int    `yaml:"quantum"`
	GobgpdPort int    `yaml:"gobgpd_port"`
	PeerIfx    string `yaml:"peer_ifx"`
	PeerGw     string `yaml:"peer_gw"`
	BgpSubnet  string `yaml:"bgp_subnet"`
	Trace      bool   `yaml:"trace"`
	Table      uint   `yaml:"table"`
}

Config contains all the configuration information needed for Gobble to run.

var Cfg Config

Cfg is the global gobble config

type Link struct {
	Name    string
	Index   uint32
	Vni     uint32
	IPAddrs []net.IP
}

Link encapsulates information about links that is important to Gobble

func (*Link) Unmarshal

func (lnk *Link) Unmarshal(attrs []byte) error

Unmarshal a link from attributes, extracting Gobble-salient properties.

type NbrMsg

type NbrMsg struct {
	Msg           NdMsg
	RawAttributes []netlink.Attribute

	Neighbor
}

NbrMsg encapsulates a netlink NdMsg, providing Marshal/Unmarshal support and Gobble-salient property extraction.

func (NbrMsg) Marshal

func (n NbrMsg) Marshal() ([]byte, error)

Marshal a neighbor message to bytes

func (*NbrMsg) Unmarshal

func (n *NbrMsg) Unmarshal(bs []byte) error

Unmarshal a neighbor message and its attributes from bytes

type NdMsg

type NdMsg struct {
	Family  uint8
	Ifindex uint32
	State   uint16
	Flags   uint8
	Type    uint8
}

NdMsg is a Netlink message for communicating with the kernel about neighbors. The unix library does not have this one

type Neighbor

type Neighbor struct {
	Mac    net.HardwareAddr
	Vlan   uint32
	Port   uint32
	Master uint32
	If     uint32
	Ifx    string
	Dst    net.IP
	Vni    uint32
	SrcVni uint32
	Router bool
	Family uint8
	Nsid   uint32
}

Neighbor encapsulates information about neighbors that is important to Gobble

func (Neighbor) Key

func (f Neighbor) Key() string

Key is an indexing function for neighbors. This function is used to determine the uniqueness of a neighbor relative to Gobble operations.

type Route

type Route struct {
	Dest     net.IP
	Src      net.IP
	Gateway  net.IP
	PrefSrc  net.IP
	Oif      uint32
	Iif      uint32
	Priority uint32
	Metrics  uint32
	Family   uint8
}

Route encapsulates information about a route that is important to Gobble

func (Route) Key

func (r Route) Key() string

Key is an indexing function for routes. This function is used to determine the uniqueness of a route relative to Gobble operations.

type RtMsg

type RtMsg struct {
	Msg           unix.RtMsg
	RawAttributes []netlink.Attribute

	// extracted attribures
	Route
}

RtMsg encapsulates a unix.RtMsg providing marshal/unmarshal operations and Gobble-salient property extraction.

func (RtMsg) Marshal

func (rtm RtMsg) Marshal() ([]byte, error)

Marshal a route message to bytes

func (*RtMsg) Unmarshal

func (rtm *RtMsg) Unmarshal(bs []byte) error

Unmarshal an route message and its attributes from bytes

type Type2EvpnRoute

type Type2EvpnRoute struct {
	Route    *api.EVPNMACIPAdvertisementRoute
	NextHops []string
}

Type2EvpnRoute encapsulates a MAC advertisement route with a set of next-hops

type Type3EvpnRoute

type Type3EvpnRoute struct {
	Route               *api.EVPNInclusiveMulticastEthernetTagRoute
	CommunityLocalAdmin uint32
}

Type3EvpnRoute encapsulates a multicast Ethernet tag route with a community local admin tag

Jump to

Keyboard shortcuts

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