Each router stores information about how to forward IP and MPLS packets in a set of RIB (routing information base) and FIB (forwarding information base) tables. These tables are conventionally populated by the management plane of the router (static entries) and by control plane protocols such as BGP, OSPF, ISIS, RSVP, LDP or segment routing.
In some SDN (Software Defined Networking) use cases, it may be useful to augment the RIB/FIB state held by a router to also include forwarding entries programmed by an external controller. SR OS supports a powerful and flexible gRPC-based RIB API service for this purpose. Using gRPC between a controller (gRPC client) and a router (gRPC server) has many benefits:
To build a gRPC client that implements the RIB API service you must obtain, from Nokia, the protobuf definition file for the Nokia SR OS RIB API service. This protobuf file defines a RIB API service and its supported RPCs. The RIB API service supports one bidirectional streaming RPC called Modify and one unary RPC called GetVersion. The Modify RPC is used to add, delete or replace entries in any of the following RIB/FIB tables:
The GetVersion RPC allows the client to request the overall RIB API version and the individual RIB table versions supported by the router.
For maximum programming flexibility and speed, the entries added by the RIB-API service are not processed or stored as configuration data; they are provided directly to the control plane and modeled as though learned from a pseudo-protocol. RIB-API entries have the same persistence characteristics as protocol routes: if a router (gRPC server) detects that a gRPC client has disconnected or terminated its RPC, or if the router reboots, dependent RIB API entries are removed and must be re-programmed if persistence is required.
A gRPC client cannot delete entries it does not own, including routes from other protocols, but it can supersede routes from other sources through appropriate programming of preference values.
A gRPC client can read RIB/FIB entries programmed using the RIB API service (by any client) and obtain other state information that it needs using the gNMI management interface. gNMI is another gRPC-based service supported by the router and it supports RPCs for configuration, one-time state retrieval and telemetry state subscriptions. The same client can have active gNMI and RIB API RPCs with the same target router and at the same time using the same TCP connection.
The Modify RPC allows a gRPC client to add, modify or delete RIB/FIB entries. To accomplish this, the client sends a stream of ModifyRequest messages to the server (router) and receives, in return, a stream of ModifyResponse messages. Each ModifyRequest message can include multiple Request messages. Each Request message has a 64-bit ID (used to pair it with a Response message) and conveys one of the following instructions:
The following general points should be noted:
All states created by the RIB API service are ephemeral. In other words, when the router reboots, none of the API-programmed entries are preserved. The necessary entries must be reprogrammed by a gRPC client in the same way that BGP routes must be relearned from BGP peers after a reboot.
The persistence of a programmed RIB/FIB entry also depends on the liveness of the RPC session with the client that owns the entry, and this in turn depends on the liveness of the underlying TCP connection. If the TCP connection with a client goes down (due to link and/or router failures, client failure, or CPM switchover by the router) the router starts a purge timer for all affected clients and marks their owned RIB/FIB entries as stale. When a client's purge timer expires all of its stale entries are removed. While a purge timer is running, the associated stale entries remain valid and usable for forwarding but are less preferred than any non-stale entry. The purge timer gives an opportunity for the disconnected client or some other client to re-program the necessary RIB/FIB tables so that forwarding continues uninterrupted.
Detection of TCP connection failures by the router (gRPC server) can be assisted by enabling TCP keepalive on the gRPC TCP connections. When it is enabled, TCP keepalive messages are sent to all gRPC clients, regardless of the RPCs they support (gNMI or RIB API).
On the router, TCP keepalive is configured by specifying 3 parameters: idle-time, interval, and retries. These parameters are configured in the config>system>grpc>tcp-keepalive context. The sending of TCP keepalives starts when the connection has been idle (no TCP segments sent or received) for more than idle-time seconds. At that point the router sends a probe (TCP ACK with a sequence number = current sequence number - 1) and expects a TCP ACK. It repeats this probe every interval seconds for the configured number of retries and if no response is received to any of them the connection is immediately closed, starting the purge timer if the TCP connection is supporting a Modify RPC.
When a client is done programming all entries in a particular RIB/FIB table it can optionally send an end-of-rib request for that table in order to immediately remove all stale RIB entries associated with that table, regardless of the owner client IP.
Configuration related to the RIB/FIB API service on the router is spread across two general areas:
To enable the router to receive and process RIB API requests from a client:
To enable the router to use RIB API tunnel entries for resolving certain types of static and BGP routes, additional configuration is needed. For more information, refer to the Unicast Routing Protocols Guide.
The RIB API service proto definition requires the client to provide values for all of the parameters listed in Table 26 when performing an add or replace of an IPv4 route. When performing a delete operation, only the bolded parameters (the lookup keys) are required. Table 26 describes the meaning of each parameter and its valid range.
Parameter | Type | Description |
prefix | string | IPv4 prefix and prefix-length in CIDR format |
preferences | uint32 (0-65535) | RIB API preference, used to compare one RIB API entry to another one; the lowest preference wins |
rtm_preference | uint32 (0-255) | RTM preference, used to compare RIB API entry to other routes in RTM; the lowest preference wins |
metric | uint32 (0-16777215) | Route cost/metric |
tunnel_next_hop | string | A remote IPv4 address that must correspond to an API-programmed IPv4 tunnel |
The router's RIB API database can hold up to eight different gPRC-programmed entries per IPv4 prefix. Typically N entries would be associated with N different gRPC clients although the same client can program multiple entries for the same prefix as long as the preference values are unique.
When an IPv4 route entry is successfully added or modified in the RIB API database, the router assesses whether the entry is valid or invalid and constantly re-evaluates this status. The entry is invalid if its next hop cannot be resolved to a gRPC-programmed IPv4 tunnel that is up.
If the entry is valid, the router compares it to all other valid API-programmed entries for the same IPv4 prefix. The router chooses any non-stale entry over a stale entry, then the entry with the lowest preference value, and then if there is a tie, the lowest metric, and then if there is a still a tie, the entry from the client with the lowest 128-bit IP address (an IPv4 address is encoded in the lower 32 bits).
If the entry is valid and the best relative to other RIB API entries then it is submitted to the route table manager. This software task compares the API route to all other non-API routes it has for the same IPv4 prefix. The router chooses the entry with the lowest RTM preference value, and then if there is a tie, the lowest metric, and then if there is still a tie, the entry submitted by the protocol with the lowest default preference.
If the route table manager selects the API route as the best route it is sent to the FIB manager for programming into the data path.
The RIB API service proto definition requires the client to provide values for all of the parameters listed in Table 27 when performing an add or replace of an IPv6 route. When performing a delete operation, only the bolded parameters (the lookup keys) are required. Table 27 describes the meaning of each parameter and its valid range.
Parameter | Type | Description |
prefix | string | IPv6 prefix and prefix-length in CIDR format |
preferences | uint32 (0-65535) | RIB API preference, used to compare one RIB API entry to another one; the lowest preference wins |
rtm_preference | uint32 (0-255) | RTM preference, used to compare RIB API entry to other routes in RTM; the lowest preference wins |
metric | uint32 (0-16777215) | Route cost/metric |
tunnel_next_hop | string | A remote IPv6 address that must correspond to an API-programmed IPv6 tunnel |
The router's RIB API database can hold up to eight different gPRC-programmed entries per IPv6 prefix. Typically N entries would be associated with N different gRPC clients although the same client can program multiple entries for the same prefix as long as the preference values are unique.
When an IPv6 route entry is successfully added or modified in the RIB API database, the router assesses whether the entry is valid or invalid and constantly re-evaluates this status. The entry is invalid if its next hop cannot be resolved to a gRPC-programmed IPv6 tunnel that is up.
If the entry is valid, the router compares it to all other valid API-programmed entries for the same IPv6 prefix. The router chooses any non-stale entry over a stale entry, then the entry with the lowest preference value, and then if there is a tie, the lowest metric, and then if there is a still a tie, the entry from the client with the lowest 128-bit IP address (an IPv4 address is encoded in the lower 32 bits).
If the entry is valid and the best relative to other RIB API entries then it is submitted to the route table manager. This software task compares the API route to all other non-API routes it has for the same IPv6 prefix. The router chooses the entry with the lowest RTM preference value, and then if there is a tie, the lowest metric, and then if there is still a tie, the entry submitted by the protocol with the lowest default preference.
If the route table manager selects the API route as the best route it is sent to the FIB manager for programming into the data path.
The RIB API service proto definition requires the client to provide values for all of the parameters listed in Table 28 when performing an add or replace of an IPv4 MPLS tunnel. When performing a delete operation, only the bolded parameters (the lookup keys) are required. Table 28 describes the meaning of each parameter and its valid range.
Parameter | Type | Description |
prefix | string | IPv4 host address |
preferences | uint32 (0-65535) | RIB API preference, used to compare one RIB API entry to another one; the lowest preference wins |
ttm_preference | uint32 (0-255) | TTM preference, used in the programming of the tunnel in TTM |
metric | uint32 (0-16777215) | Route cost/metric |
next-hop-group[id] | list | A list of next-hop groups |
id | uint32 (1-32) | Unique identifier of the next-hop group. Selected by the client |
weight | uint32 | Weight assigned to the next-hop-group when weighted ECMP is desired between next-hop-groups |
primary | — | Mandatory |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address |
pushed_label_stack | list of uint32 | A list of one or more MPLS labels, up to ten MPLS labels |
backup | — | Optional |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address |
pushed_label_stack | list of uint32 | A list of up to ten MPLS labels |
egress-statistics | — | — |
enable | boolean | Indicates whether statistics collection is enabled for this entry |
The router's RIB API database can hold up to eight different gPRC-programmed entries per IPv4 tunnel endpoint. Typically N entries would be associated with N different gRPC clients although the same client can program multiple entries for the same tunnel endpoint as long as the preference values are unique
When an IPv4 tunnel endpoint entry is successfully added or modified in the RIB API database, the router assesses whether the entry is valid or invalid and constantly re-evaluates this status. The tunnel is invalid if none of its primary next hops can be resolved to an interface that is up or if MPLS programming using the RIB API is currently administratively disabled.
If the IPv4 tunnel entry is valid the router compares it to all other valid API-programmed entries for the same IPv4 endpoint address. The router chooses any non-stale entry over a stale entry, then the entry with the lowest preference value, and then if there is a tie, the lowest metric, and then if there is a still a tie, the entry from the client with the lowest 128-bit IP address (an IPv4 address is encoded in the lower 32 bits).
If the entry is valid and the best relative to other RIB API entries then it is programmed into the FIB and added to the base router IPv4 tunnel table. The tunnel entry is now active and can be used to resolve the next hops of other routes. For more information, refer to the Unicast Routing Protocols Guide.
The RIB API service proto definition requires the client to provide values for all of the parameters listed in Table 29 when performing an add or replace of an IPv6 MPLS tunnel. When performing a delete operation, only the bolded parameters (the lookup keys) are required. Table 29 describes the meaning of each parameter and its valid range.
Parameter | Type | Description |
prefix | string | IPv6 host address |
preferences | uint32 (0-65535) | RIB API preference, used to compare one RIB API entry to another one; the lowest preference wins |
ttm_preference | uint32 (0-255) | TTM preference, used in the programming of the tunnel in TTM |
metric | uint32 (0-16777215) | Route cost/metric |
next-hop-group[id] | list | A list of next-hop groups |
id | uint32 (1-32) | Unique identifier of the next-hop group; selected by the client |
weight | uint32 | Weight assigned to the next-hop-group when weighted ECMP is desired between next-hop-groups |
primary | — | Mandatory |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address. |
pushed_label_stack | list of uint32 | A list of one or more MPLS labels, up to ten MPLS labels |
backup | — | Optional |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address |
pushed_label_stack | list of uint32 | A list of up to ten MPLS labels |
egress-statistics | — | — |
enable | boolean | Indicates whether statistics collection is enabled for this entry |
The router's RIB API database can hold up to eight different gPRC-programmed entries per IPv6 tunnel endpoint. Typically N entries would be associated with N different gRPC clients although the same client can program multiple entries for the same tunnel endpoint as long as the preference values are unique.
When an IPv6 tunnel endpoint entry is successfully added or modified in the RIB API database, the router assesses whether the entry is valid or invalid and constantly re-evaluates this status. The tunnel is invalid if none of its primary next hops can be resolved to an interface that is up or if MPLS programming using the RIB API is currently administratively disabled.
If the IPv6 tunnel entry is valid the router compares it to all other valid API-programmed entries for the same IPv6 endpoint address. The router chooses any non-stale entry over a stale entry, then the entry with the lowest preference value, and then if there is a tie, the lowest metric, and then if there is a still a tie, the entry from the client with the lowest 128-bit IP address (an IPv4 address is encoded in the lower 32 bits).
If the entry is valid and the best relative to other RIB API entries then it is programmed into the FIB and added to the base router IPv6 tunnel table. The tunnel entry is now active and can be used to resolve the next hops of other routes. For more information, refer to the Unicast Routing Protocols Guide.
The RIB API service proto definition requires the client to provide values for all of the parameters listed in Table 30 when performing an add or replace of an MPLS LFIB entry. When performing a delete operation, only the bolded parameters (the lookup keys) are required. Table 30 describes the meaning of each parameter and its valid range.
Parameter | Type | Description |
prefix | string | Incoming label value |
preferences | uint32 (0-65535) | RIB API preference, used to compare one RIB API entry to another one; the lowest preference wins |
next-hop-group[id] | list | A list of next-hop groups; required for a SWAP operation; omitted when the operation is a POP |
id | uint32 (1-32) | Unique identifier of the next-hop group; selected by the client |
weight | uint32 | Weight assigned to the next-hop-group when weighted ECMP is desired between next-hop-groups |
primary | — | Mandatory |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address |
pushed_label_stack | list of uint32 | A list of zero or more MPLS labels, up to ten MPLS labels |
backup | — | Optional |
ip_address | string | IPv4 or IPv6 address on a local subnet; can be a secondary address |
pushed_label_stack | list of uint32 | A list of up to ten MPLS labels |
ingress-statistics | — | — |
enable | bool | — |
type | enum 0, 1, 2 | INVALID = 0 POP = 1 SWAP = 2 |
egress-statistics | — | — |
enable | boolean | Indicates whether statistics collection is to be enabled for this entry |
The router's RIB API database can hold up to eight different gPRC-programmed entries per MPLS label value. Typically N entries would be associated with N different gRPC clients although the same client can program multiple entries for the same label value as long as the preference values are unique.
When an MPLS label entry is successfully added or modified in the RIB API database, the router assesses whether the entry is valid or invalid and constantly re-evaluates this status. The label entry is invalid if it is a SWAP operation and none of the primary next hops can be resolved to an interface that is up or if MPLS programming using the RIB API is administratively disabled or if the requested incoming label has already been allocated to another owner sharing the same reserved label block or if the requested incoming label is outside the reserved label block range.
If the label entry is valid the router compares it to all other valid API-programmed entries for the same label value. The router chooses any non-stale entry over a stale entry, then the entry with the lowest preference value, and then if there is a tie, the entry from the client with the lowest 128-bit IP address (an IPv4 address is encoded in the lower 32 bits).
If the label entry is valid and best relative to other RIB API entries then it is programmed into the forwarding plane.
The RIB API service proto definition allows each MPLS tunnel and each MPLS label entry to have multiple next-hop-groups, each with a primary next hop and optionally one backup next hop. When a tunnel or label entry has more than one next-hop-group, this instructs the router to spray matching traffic across the next-hop-groups based on an ECMP or weighted-ECMP algorithm.
At any time, traffic hashed to a particular next-hop-group uses only the primary or backup next hop for forwarding. The selection of the active next hop within each next-hop-group is influenced by failures and by next-hop-switch Request messages made by the owner gRPC client. The specific rules are:
![]() | Note: The router returns a status of OK in response to a next-hop-switch Request as long as the key values identify a next-hop-group that exists for a tunnel or label entry owned by the gRPC client, even if the desired next hop is not activated. |
A gRPC client can use the gRPC gNMI service (Get RPC, Subscribe RPC) to retrieve state information from the router that can help it make better programming decisions. All states maintained by the router (and exposed to model-driven management interfaces) are available to the gRPC client.
RIB/FIB API also introduces additional YANG state models that are complementary to the programming actions. This new state is available through the following YANG paths:
The corresponding show commands are also provided for reference.
The state information represented by the state/router/route-fib and state/router/tunnel-fib paths, and the show router fib-telemetry route and show router fib-telemetry tunnel show commands list are not collected by default, since it requires additional processing. In order for this state to be collected you must configure the configure router fib-telemetry command. If this command is not configured then these states are not collected at all, and telemetry subscriptions are not supported for any of the following paths:
It is not possible for a single telemetry subscription to include any of these three paths in addition to other state paths outside of this tree. This is because of the potential volume of information in the tables described in this chapter.
For gNMI telemetry subscriptions, the following restrictions should be noted:
A gRPC client can make a request for traffic statistics to be collected. Both ingress and egress statistics are available but not all types of entries support both.
Traffic statistics are expressed in number of packets and in octets and are provided without forwarding-class or QoS profile distinction.
The system provides capabilities to display or show, clear, or monitor statistics.
Only RIB-API MPLS tunnel table entries support ingress statistics. The counters are attached to the ILM entry that is formed when the RIB-API entry is programmed. When different RIB-API entries use the same ILM or label, then the traffic statistics for these RIB-API entries are identical. Traffic counters are kept until the ILM entry is removed. Due to a lack of resources, the system may not be able to allocate counters (statistic indices) to an ILM. In this case, the system automatically retries until it succeeds.
Egress statistics are supported for the three RIB-API tunnel tables (IPv4, IPv6, and MPLS). The counters are attached to the NHLFE of each next hop. Counters are effectively allocated by the system at the time that the instance is programmed in the data-path. Counters are maintained even if an instance is deprogrammed and values are not reset. This means that, if an instance is reprogrammed, traffic counting resumes at the point where it last stopped. Traffic counters are released and thus traffic statistics are lost when the instance or entry is removed from the database.
No retry mechanism is available for egress statistics. The system maintains a state per next-hop and per instance identifying whether or not allocation of statistic indices is successful. If the system is not able to allocate all the desired indices on a specified instance due to a lack of resources, then the user should disable egress statistics on that instance. This action frees enough statistic indices and re-enables egress statistics on the desired entry. The selection of which other construct to release statistic indices from is beyond the scope of this document.