Documentation ¶
Overview ¶
Package sysrib implements a system-level RIB that is populated initially using an OpenConfig configuration.
Index ¶
- Constants
- type Client
- type GUEHeaders
- type GUEPolicy
- type Interface
- type NIRIB
- type ResolvedNexthop
- type ResolvedRoute
- type Route
- type RouteKey
- type RoutePreference
- type Server
- func (s *Server) PrintProgrammedRoutes()
- func (s *Server) ProgrammedRoutes() map[RouteKey]*ResolvedRoute
- func (s *Server) ResolveAndProgramDiff(ctx context.Context) error
- func (s *Server) ResolvedRoutes() map[RouteKey]*Route
- func (s *Server) SetRoute(ctx context.Context, req *sysribpb.SetRouteRequest) (*sysribpb.SetRouteResponse, error)
- func (s *Server) Start(ctx context.Context, gClient gpb.GNMIClient, ...) error
- func (s *Server) Stop()
- type SysRIB
- func (sr *SysRIB) AddRoute(ni string, r *Route) error
- func (sr *SysRIB) DeleteGUEPolicy(prefix string) (bool, error)
- func (sr *SysRIB) DeleteRoute(ni string, r *Route) error
- func (sr *SysRIB) EgressInterface(inputNI string, ip *net.IPNet) ([]*Interface, error)
- func (s *SysRIB) PrintRIB()
- func (sr *SysRIB) SetGUEPolicy(prefix string, policy GUEPolicy) error
- type ZServer
Constants ¶
const ( AdminDistanceConnected = 0 AdminDistanceStatic = 1 AdminDistanceBGP = 20 )
AdminDistance is the admin-distance of a routing protocol. See https://docs.frrouting.org/en/latest/zebra.html#administrative-distance
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a ZAPI client.
func (*Client) HandleRequest ¶
HandleRequest handles an incoming ZAPI client connection.
func (*Client) RedistributeResolvedRoutes ¶
RedistributeResolvedRoutes sends RedistributeRouteAdd messages to the client connection for all currently-resolved routes.
type GUEHeaders ¶
type GUEHeaders struct { GUEPolicy // contains filtered or unexported fields }
GUEHeaders represents the IP and UDP headers that are to encapsulate the packet.
type GUEPolicy ¶
type GUEPolicy struct {
// contains filtered or unexported fields
}
GUEPolicy represents the static values in the IP and UDP headers that are to encapsulate the packet.
srcPort is a hash (not implemented). dstIP is the nexthop of the BGP route.
type Interface ¶
type Interface struct { Name string `json:"name"` Index int32 `json:"index"` Subinterface uint32 `json:"subinterface"` }
Interface describes an interface of a device.
type NIRIB ¶
type NIRIB struct { // IPV4 is the IPv4 RIB IPV4 *generics_tree.TreeV4[*Route] // IPV6 is the IPv6 RIB IPV6 *generics_tree.TreeV6[*Route] }
NIRIB is the RIB for a single network instance.
type ResolvedNexthop ¶
type ResolvedNexthop struct { afthelper.NextHopSummary Port Interface GUEHeaders GUEHeaders }
ResolvedNexthop contains the information required to forward an IP packet.
This type must be hashable, and uniquely identifies nexthops.
func (ResolvedNexthop) HasGUE ¶
func (nh ResolvedNexthop) HasGUE() bool
HasGUE returns a bool indicating whether the resolved nexthop contains GUE information.
type ResolvedRoute ¶
type ResolvedRoute struct { RouteKey // NOTE: The order of the nexthops should not matter when being programmed into the forwarding plane. As such, the forwarding plane should sort these nexthops before assigning the hash output for ECMP. Nexthops map[ResolvedNexthop]bool }
ResolvedRoute represents a route that is ready to be programmed into the forwarding plane.
type Route ¶
type Route struct { // Prefix is a prefix that was being stored. Prefix string `json:"prefix"` // Connected indicates that the route is directly connected. Connected *Interface `json:"connected"` // NextHops is the set of IP nexthops that the route uses if // it is not a connected route. NextHops []*afthelper.NextHopSummary `json:"nexthops"` RoutePref RoutePreference }
Route is used to store a route in the radix tree.
func NewRouteViaIF ¶
NewRoute returns a new route for the specified prefix. Note - today this doesn't actually result in a viable forwarding entry unless its a connected route :-)
type RoutePreference ¶
type RoutePreference struct { // AdminDistance is the admin distance of the protocol that added this // route. // See https://docs.frrouting.org/en/latest/zebra.html#administrative-distance AdminDistance uint8 `json:"admin-distance"` // Metric is the metric of the route. It is comparable only within // routes of the same protocol, and therefore the same admin distance. Metric uint32 `json:"metric"` }
type Server ¶
type Server struct { sysribpb.UnimplementedSysribServer // For forward-compatibility // contains filtered or unexported fields }
Server is the implementation of the Sysrib API.
API: - SetRoute - setConnectedRoute - setInterface
func New ¶
New instantiates server to handle client queries.
If dp is nil, then a connection attempt is made.
func (*Server) PrintProgrammedRoutes ¶ added in v0.2.0
func (s *Server) PrintProgrammedRoutes()
PrintProgrammedRoutes prints the programmed routes.
func (*Server) ProgrammedRoutes ¶ added in v0.3.0
func (s *Server) ProgrammedRoutes() map[RouteKey]*ResolvedRoute
ProgrammedRoutes returns the shallow copy of the programmed routes of the RIB manager.
func (*Server) ResolveAndProgramDiff ¶
ResolveAndProgramDiff walks through each prefix in the RIB, resolving it and programs the forwarding plane.
func (*Server) ResolvedRoutes ¶
ResolvedRoutes returns the shallow copy of the resolved routes of the RIB manager.
func (*Server) SetRoute ¶
func (s *Server) SetRoute(ctx context.Context, req *sysribpb.SetRouteRequest) (*sysribpb.SetRouteResponse, error)
SetRoute implements ROUTE_ADD and ROUTE_DELETE
func (*Server) Start ¶
func (s *Server) Start(ctx context.Context, gClient gpb.GNMIClient, target, zapiURL, sysribAddr string) error
Start starts the sysrib gRPC service at a unix domain socket. This should be started prior to routing services to allow them to connect to sysrib during their initialization.
- If zapiURL is not specified, then the ZAPI server will not be started.
type SysRIB ¶
type SysRIB struct { // NI is the list of network instances (aka VRFs) NI map[string]*NIRIB // GUEPolicies are the configured BGP-triggered GUE policies. // Every update to this should trigger a re-computation of the resolved // routes. GUEPoliciesV4 *generics_tree.TreeV4[GUEPolicy] GUEPoliciesV6 *generics_tree.TreeV6[GUEPolicy] // contains filtered or unexported fields }
SysRIB is a RIB data structure that can be used to resolve routing entries to their egress interfaces. Currently it supports only IPV4 entries.
func NewSysRIB ¶
NewSysRIB returns a SysRIB from an input parsed OpenConfig configuration.
- initialCfg, if specified, will be used to populate connected routes into the RIB manager. Note this is intended to be used for standalone device testing.
func NewSysRIBFromJSON ¶
NewSysRIBFromJSON returns a new SysRIB from an RFC7951 marshalled JSON OpenConfig configuration.
func (*SysRIB) DeleteGUEPolicy ¶
DeleteGUEPolicy sets a GUE Policy in the RIB. It returns true if a policy was deleted, and false if not.
func (*SysRIB) DeleteRoute ¶ added in v0.4.0
DeleteRoute deletes a route r, from network instance ni, in the sysRIB.
func (*SysRIB) EgressInterface ¶
EgressInterface looks up the IP destination address ip in the routes for network instance named inputNI. It returns a slice of the interfaces that the packet would be forwarded via.
type ZServer ¶
type ZServer struct { // ClientMutex protects the ZAPI client map. ClientMutex sync.RWMutex // ClientMap stores all connected ZAPI clients. ClientMap map[net.Conn]*Client // contains filtered or unexported fields }
ZServer is a ZAPI server.
func StartZServer ¶
func StartZServer(ctx context.Context, address string, vrfID uint32, sysrib *Server) (*ZServer, error)
StartZServer starts a ZAPI server on the given connection type and path,
e.g. - "unix", "/var/run/zapi.serv"
It also resquires the sysrib server in order to send and receive redistributed routes.
TODO: vrfID is not well-integrated with the sysrib.
func (*ZServer) ClientRegister ¶
ClientRegister creates a new ZAPI client connection.
func (*ZServer) ClientUnregister ¶
ClientUnregister deletes a ZAPI client connection.