Tuesday, 1 September 2026

SONiC Deep Dive: BGP Peer Configuration - BGP Unnumbered

 

After enabling IPv6 on the Ethernet0 interface, we can configure BGP peering. Instead of statically defining a peer IP address and AS number, the BGP neighbor is defined at the interface level. This tells BGP to expect a neighbor and initialize the BGP peering over Ethernet0. Because our intent is to transport IPv4 traffic over the IPv6 network, we activate both the IPv4 and IPv6 address families. We also configure the peer as an external BGP (eBGP) neighbor by using a command remote-as external. This tells BGP that the peer must use an AS number different from the local AS number.

Because the network uses IPv6 as the transport for IPv4 traffic, IPv4 Network Layer Reachability Information (NLRI) exchanged through BGP use IPv6 next-hop addresses. BGP therefore needs the Extended Next Hop Encoding capability to support IPv4 routes with IPv6 next hops. In this configuration, the capability is explicitly enabled with the capability extended-nexthop command.

In FRRouting, the v6only option controls which IP version is used for interface-based BGP Unnumbered peering. Without v6only, FRR uses the interface's IPv6 link-local address for peering only when no suitable IPv4 address is configured on the interface. With v6only, FRR skips searching for an IPv4 address on the interface and establishes the BGP Unnumbered peering using the interface's IPv6 link-local address.

Example below shows the complete BGP configuration on Leraf-101.

router bgp 65101

 router-id 1.1.1.101

 log-neighbor-changes

 timers 60 180

 !

 neighbor interface Ethernet0

  v6only

  remote-as external

  capability extended-nexthop

  !

  address-family ipv4 unicast

   activate

  !

  address-family ipv6 unicast

   activate

Example 6-2: BGP Configuration Script on Leaf-101.

 

Note: Traditionally, the remote AS number is configured explicitly, which provides control over which AS is allowed to establish a BGP session. This is particularly important at network edges, where BGP sessions commonly exist between different administrative organizations. In a datacenter network, AS numbers are used only for BGP loop prevention.

Figure 6-8 shows the BGP configuration on Leaf-101. We use a multi-ASN
design in which the Spine switches share the same ASN, while each Leaf
switch has a unique ASN. The BGP neighbor is configured as an IPv6-only
unnumbered neighbor over Ethernet0.

BGP Configuration in CONFIG_DB

The BGP configuration is stored in the Redis CONFIG_DB. SONiC separates the configuration into three tables according to its scope: global BGP parameters, neighbor-specific parameters, and address-family-specific parameters.

 

BGP_GLOBALS in CONFIG_DB

 

Global BGP parameters that apply to the BGP instance are stored in the BGP_GLOBALS table. On Leaf-101, these parameters are stored in the BGP_GLOBALS|default entry. BGP configuration in SONiC is organized per VRF. The default component in BGP_GLOBALS|default identifies the default VRF.

 

The configuration hierarchy can be represented as follows:

BGP Globals:

 BGP Instance

  Local ASN: 65101

  Router ID: 1.1.1.101

  Hold time: 180 seconds

  Keepalive interval: 60 seconds

  Other global BGP parameters

 

These values identify the BGP instance running on Leaf-101.

 

BGP_NEIGHBOR

Parameters that apply to a specific BGP neighbor are stored in the BGP_NEIGHBOR table. For the BGP Unnumbered peer connected through Ethernet0, the configuration is stored in:

BGP_NEIGHBOR|default|Ethernet0.

The default component identifies the VRF, while Ethernet0 identifies the BGP neighbor interface.

The configuration hierarchy is:

 

BGP Neighbor:

 Ethernet0

  Administrative status: true

  Peer type: external

  Extended next-hop capability: true

  IPv6-only transport: true

The important parameters for BGP Unnumbered are v6only and extended_nexthop capability. The v6only setting allows the BGP session to use the IPv6 link-local address of Ethernet0 without requiring a numbered IPv4 or IPv6 address. The extended next-hop capability allows IPv4 routes to use IPv6 next hops.

BGP_NEIGHBOR_AF

Address-family-specific parameters are stored separately in the BGP_NEIGHBOR_AF table. SONiC creates a separate entry for each address family enabled for a neighbor.

On Leaf-101, Ethernet0 has two address families enabled:

BGP_NEIGHBOR_AF|default|Ethernet0|ipv4_unicast

BGP_NEIGHBOR_AF|default|Ethernet0|ipv6_unicast

 

BGP Neighbor Address Families:

  Ethernet0 / IPv4 Unicast

     Administrative status: true

  Ethernet0 / IPv6 Unicast

    Administrative status: true

 

Activating both address families is required because IPv6 provides the transport for the BGP session, while IPv4 allows IPv4 routes to be exchanged over that IPv6-based BGP session.

The configuration in CONFIG_DB describes what BGP should be configured to do. It does not contain the complete operational state of the BGP session, such as whether the neighbor is currently in the Established state or how many routes have been received. This operational state is maintained by FRR after the configuration has been applied.

Applying BGP Configuration to FRR

The frrcfgd daemon running in the BGP container monitors BGP-related configuration changes in CONFIG_DB. When BGP configuration is written to CONFIG_DB, Redis notifies frrcfgd about the changed entries. Frrcfgd reads the updated configuration and translates it into FRR configuration commands, which are applied to the running FRR routing stack.

FRR (FRRouting) is a routing software suite that consists of several routing daemons. The bgpd daemon is responsible for BGP, while other daemons, such as zebra, provide common routing functions and maintain the system routing table. Therefore, frrcfgd does not directly configure a SONiC database consumer bgpd. Instead, it provides the BGP configuration to the running FRR software, where bgpd processes the BGP-specific configuration.

After the configuration is applied, bgpd creates the BGP instance and initializes the required neighbor and routing structures. It then starts the peer initialization process and attempts to establish the BGP session with the configured neighbor.

Figure 6-8: BGP Configuration Pipeline.

 

BGP Neighbor Initialization Pipeline

 

The following packet capture, taken on Spine-11’s Ethernet0 interface, shows the beginning of the BGP neighbor initialization, including the TCP three-way handshake and the first BGP OPEN message.

TCP three-way handshake

The TCP three-way handshake consists of a SYN (Flags [S]), a SYN-ACK (Flags [S.]), and an ACK (Flags [.]) packet. Immediately after the connection is established, Spine-11 sends the BGP OPEN message in a TCP packet with the PSH and ACK flags (Flags [P.]). The PSH flag instructs the receiving TCP stack to deliver the BGP payload immediately to the bgpd process.

BGP Capabilities

The BGP OPEN message contains several capabilities. The Multiprotocol Extensions capability advertises support for both IPv4 Unicast (AFI 1, SAFI 1) and IPv6 Unicast (AFI 2, SAFI 1). This allows the BGP session, although transported over IPv6, to negotiate the exchange of both IPv4 and IPv6 unicast routes.

The Extended Next Hop Encoding capability is also advertised. This capability is important for our IPv4-over-IPv6 routing design because it allows IPv4 routes to use IPv6 next-hop addresses. The capture shows Capability Code 5, although tcpdump does not decode the capability name and therefore reports no decoder for Capability 5.

The remaining capabilities include Route Refresh, Enhanced Route Refresh, 32-bit AS Numbers, Multipath, Graceful Restart, and Long-Lived Graceful Restart. These capabilities are not specific to BGP Unnumbered and are omitted from the tcpdump output shown here.

 

admin@Spine-11:~$ sudo tcpdump -i Ethernet0 -nn -s 0 -vv 'tcp port 179'

 

tcpdump: listening on Ethernet0, link-type EN10MB (Ethernet), snapshot length 262144 bytes

 

10:41:28.303725 IP6 (class 0xc0, flowlabel 0x421d8, hlim 1, next-header TCP (6) payload length: 40) fe80::e22:34ff:feb6:a.47296 > fe80::ecb:81ff:fe19:a.179: Flags [S], cksum 0x0234 (correct), seq 3251084010, win 63280, options [mss 9040,sackOK,TS val 174604957 ecr 0,nop,wscale 9], length 0

 

10:41:28.308179 IP6 (class 0xc0, flowlabel 0x41bc9, hlim 255, next-header TCP (6) payload length: 40) fe80::ecb:81ff:fe19:a.179 > fe80::e22:34ff:feb6:a.47296: Flags [S.], cksum 0xf542 (correct), seq 3128045848, ack 3251084011, win 63196, options [mss 9040,sackOK,TS val 1700510797 ecr 174604957,nop,wscale 9], length 0

 

10:41:28.308237 IP6 (class 0xc0, flowlabel 0x421d8, hlim 1, next-header TCP (6) payload length: 32) fe80::e22:34ff:feb6:a.47296 > fe80::ecb:81ff:fe19:a.179: Flags [.], cksum 0x380a (correct), seq 1, ack 1, win 124, options [nop,nop,TS val 174604961 ecr 1700510797], length 0

 

10:41:28.309421 IP6 (class 0xc0, flowlabel 0x421d8, hlim 1, next-header TCP (6) payload length: 161) fe80::e22:34ff:feb6:a.47296 > fe80::ecb:81ff:fe19:a.179: Flags [P.], cksum 0x7f3a (correct), seq 1:130, ack 1, win 124, options [nop,nop,TS val 174604962 ecr 1700510797], length 129: BGP

        Open Message (1), length: 129

          Version 4, my AS 65011, Holdtime 180s, ID 1.1.1.11

          Optional parameters, length: 100

            Option Capabilities Advertisement (2), length: 6

              Multiprotocol Extensions (1), length: 4

                AFI IPv4 (1), SAFI Unicast (1)

                0x0000:  0001 0001

            Option Capabilities Advertisement (2), length: 8

              Extended Next Hop Encoding (5), length: 6

                no decoder for Capability 5

                0x0000:  0001 0001 0002

            Option Capabilities Advertisement (2), length: 6

              Multiprotocol Extensions (1), length: 4

                AFI IPv6 (2), SAFI Unicast (1)

                0x0000:  0002 0001

            <snipped>           

Example 6-3: BGP Neighbor Session Initialization.

Verification

 

Figure 6-9 shows the basic BGP peering verification commands. The first command, show bgp ipv4 unicast, shows that instead of a peer IP address, the peer is identified by the connected interface name. The second command, show bgp ipv4 unicast neighbors interface Ethernet 0, verifies that the BGP session is established using IPv6 link-local addresses.

Note that both commands are executed for the IPv4 address family, even though the BGP session itself uses IPv6 as the transport. The same BGP session can therefore carry IPv4 and IPv6 address families. The output is the same for both address families, except for the timestamp, confirming that both address families are active on the BGP session.

Figure 6-9: BGP Peering Verification.

BGP Configuration Pipeline from sonic-cli to bgpd

To better understand how BGP configuration is passed from SONiC to FRRouting, we can examine the Python source code of the frrcfgd daemon. The following command locates the source file used by the running frrcfgd process and searches it for terms related to Redis, CONFIG_DB, VTY, bgpd, FRR, and sockets:

root@Leaf-101:/# grep -nEi 'redis|config_db|vty|bgpd|frr|FRR|socket' \

$(python3 -c "import frrcfgd.frrcfgd; print(frrcfgd.frrcfgd.__file__)")

Example 6-4: Locating the frrcfgd source code and searching for relevant terms..

The Python expression returns the exact path of the frrcfgd source file installed on the switch. Using this path as input to grep allows us to examine how frrcfgd accesses CONFIG_DB and communicates with FRRouting.

 

The first example shows that frrcfgd associates specific CONFIG_DB tables with the FRR daemons that process their configuration. Several BGP-related tables are assigned to bgpd:

87:  'DEVICE_METADATA': ['bgpd'],

88:  'BGP_GLOBALS': ['bgpd'],

89:  'BGP_GLOBALS_AF': ['bgpd'],

96:  'BGP_PEER_GROUP': ['bgpd'],

97:  'BGP_NEIGHBOR': ['bgpd'],

98:  'BGP_PEER_GROUP_AF': ['bgpd'],

99:  'BGP_NEIGHBOR_AF': ['bgpd'],

Example 6-5: CONFIG_DB tables Associated with frrcfgd.

This shows that frrcfgd knows which FRR daemon is responsible for each configuration table. For example, the global BGP configuration in BGP_GLOBALS and the neighbor configuration in BGP_NEIGHBOR are handled by bgpd.

The next example shows that frrcfgd directly accesses these tables through its CONFIG_DB connector:

2719: self.config_db = ExtConfigDBConnector(...)

2724: db_entry = self.config_db.get_entry('DEVICE_METADATA', 'localhost')

2742: glb_table = self.config_db.get_table('BGP_GLOBALS')

2750: global_af_table = self.config_db.get_table('BGP_GLOBALS_AF')

2759: nbr_table = self.config_db.get_table('BGP_NEIGHBOR')

2760: pg_table = self.config_db.get_table('BGP_PEER_GROUP')

Example 6-6: CONFIG_DB Connector.

The configuration is not only read when frrcfgd starts. The daemon also subscribes to configuration-table changes:

2993: table_list = self.config_db.get_table(table)

3009: self.config_db.subscribe(table, hdlr)

Example 6-7: CONFIG_DB Subscriber.

 

This allows frrcfgd to react when the BGP configuration in CONFIG_DB changes. A corresponding handler processes the change and prepares the configuration that must be applied to FRRouting.

The next part of the source code shows how frrcfgd translates the SONiC configuration into FRRouting commands. For example, the code constructs a command that enters BGP configuration mode and activates an address family:

3488: command = "vtysh -c 'configure terminal' \

-c 'router bgp {} vrf {}' \

-c 'address-family ipv4 unicast' -c '{}'"

Example 6-8: Command Translation.

Therefore, frrcfgd acts as the SONiC-to-FRR configuration translator. When a BGP configuration is created or changed through sonic-cli, the configuration is stored in CONFIG_DB. frrcfgd detects the change, reads the relevant CONFIG_DB entry, and generates the corresponding FRRouting configuration commands.

The generated commands are then passed to the FRR VTY interface. The source code shows that frrcfgd uses UNIX domain sockets to communicate with the FRR daemons:

205: sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

209: serv_addr = '/run/frr/%s.vty' % daemon

Example 6-9.1: Unix Domain Socket.

For bgpd, this results in communication through its VTY socket:

/run/frr/bgpd.vty

Example 6-9.2: VTY Socket for bgpd.

The complete configuration pipeline can therefore be summarized as:

Sonic-cli  CONFIG_DB  frrcfgd  FRR VTY interface  bgpd

In the BGP Unnumbered configuration used in this chapter, the same pipeline is used to configure the BGP process, the interface-based neighbor, and the required address families. After bgpd receives the configuration, it establishes and manages the BGP session, including establishing the TCP connection using the IPv6 link-local address associated with the unnumbered interface.



Monday, 24 August 2026

SONiC Deep Dive: BGP Unnumbered for IPv4

 

Chapter 6: BGP Unnumbered for IPv4

 

Introduction

 

This chapter explains how an IPv6-only transport network can provide connectivity between IPv4 networks by using IPv6 link-local addresses as next-hop addresses for IPv4 routes.

The first part of the chapter starts by showing how to configure interfaces to enable IPv6 and automatically generate IPv6 link-local addresses. These addresses can then be advertised to IPv6 peers using Router Advertisement (RA) messages defined by the IPv6 Neighbor Discovery Protocol (NDP). This provides the IPv6 link-local addressing required to establish BGP Unnumbered peering. Because the focus of the book is SONiC NOS, this section also shows how locally configured, interface-specific IPv6 information, as well as information received from neighboring devices, is represented in the SONiC Redis databases.

The second part of the chapter introduces how to configure external BGP peering using IPv6 link-local addresses without explicitly specifying the neighbor's IPv6 address or ASN. This simplifies automation by reducing the number of switch-specific configuration parameters. As in the first part, we examine the relevant Redis database tables after configuration and verification.

Figure 6-1 depicts the example topology used in this chapter. The physical topology is based on two-tiers Clos topology, with a single BGP ASN for the spine switches and a switch-specific ASN for each leaf switch. All inter-switch links are IPv6-only.


Figure 6-1: Two-Tier, Three-Stages Clos Topology.

 

IPv6 Link-Local Address Advertisement

 

A traditional way of configuring BGP peering is to define the neighbor's IPv4 or IPv6 address and peer ASN. After the configuration is complete, the BGP speaker establishes a TCP connection with the configured peer and then begins BGP session negotiation. With BGP Unnumbered, the peer's IPv6 address does not need to be explicitly configured because the directly connected peer can be identified through the interface and its IPv6 link-local address. Instead, the BGP session can use IPv6 link-local addresses associated with the directly connected interfaces. IPv6 Neighbor Discovery (ND) provides the mechanisms used to discover and communicate with the directly connected IPv6 peer.

Figure 6-2 shows the configuration used to enable IPv6 on Ethernet 0. We first bring the interface up using the SONiC command sudo config interface startup Ethernet 0 and then enable the interface with the no shutdown command in sonic-cli. We then enable IPv6 on Ethernet 0 with the ipv6 enable command.

When IPv6 is enabled, the interface is assigned an IPv6 link-local address. In this example, the link-local address is generated from the interface's link-layer address 0c:cb:81:19:00:0a using the modified EUI-64 format.

To construct the modified EUI-64 interface identifier, the MAC address is first divided into two 24-bit halves:

0c:cb:81 + 19:00:0a

The value ff:fe is inserted between the two halves:

0c:cb:81:ff:fe:19:00:0a

The Universal/Local (U/L) bit in the first byte is then inverted. The first byte 0c is 00001100 in binary. Flipping the U/L bit changes it to 00001110, which is 0e in hexadecimal. The resulting modified EUI-64 interface identifier is therefore:

0e:cb:81:ff:fe:19:00:0a

The IPv6 link-local prefix fe80::/64 is then combined with this interface identifier, producing:

fe80:0000:0000:0000:0ecb:81ff:fe19:000a

or, in compressed IPv6 notation:

fe80::ecb:81ff:fe19:a

After the interface has been enabled and assigned its link-local address, we enable Router Advertisement (RA) messages with the no ipv6 nd suppress-ra command. In this example, the RA interval is also configured to five seconds. The RA messages allow the router to advertise IPv6 information on the local link, including its link-local address.

After the configuration is applied on both switches shown in Figure 6-2, each switch periodically sends ICMPv6 Router Advertisement messages. The RA is sent from the interface's link-local IPv6 address to the IPv6 all-nodes multicast address ff02::1. The corresponding Ethernet destination MAC address is 33:33:00:00:00:01. IPv6 multicast addresses are mapped to Ethernet multicast addresses by prepending the 33:33 prefix to the lower 32 bits of the IPv6 multicast address. The lower 32 bits of ff02::1 are 00:00:00:01, resulting in 33:33:00:00:00:01. The Ethernet source MAC address is the MAC address of the transmitting interface.

Within the ICMPv6 Router Advertisement message, the Source Link-Layer Address option can contain the interface MAC address. This allows a receiving IPv6 node to associate the router's advertised link-local address with its link-layer address. The receiver can learn both the router's IPv6 link-local address and the corresponding link-layer address from the RA.

The IPv6 link-local address and Neighbor Discovery information established through this process provide the IPv6 connectivity required by the BGP Unnumbered configuration described in the next section.

Example 6-1, after the figure 6-2, shows a partial packet capture showing ICMPv6 Router Advertisements messages sent and received by Leaf-101.



Figure 6-2: Topology.

 

tcpdump: listening on Ethernet0, link-type EN10MB (Ethernet), snapshot length 262144 bytes

 

07:52:37.640210 IP6 (flowlabel 0x0c9b5, hlim 255, next-header ICMPv6 (58) payload length: 24) fe80::e22:34ff:feb6:a > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 24

        hop limit 64, Flags [none], pref medium, router lifetime 15s, reachable time 0ms, retrans timer 0ms

          source link-address option (1), length 8 (1): 0c:22:34:b6:00:0a

            0x0000:  0c22 34b6 000a

 

07:52:40.874181 IP6 (flowlabel 0x8b676, hlim 255, next-header ICMPv6 (58) payload length: 24) fe80::ecb:81ff:fe19:a > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 24

        hop limit 64, Flags [none], pref medium, router lifetime 15s, reachable time 0ms, retrans timer 0ms

          source link-address option (1), length 8 (1): 0c:cb:81:19:00:0a

            0x0000:  0ccb 8119 000a

Example 6-1: Packet Capture: Router Advertisement Messages.

Verification

The two examples shown in the upper part of Figure 6-3, obtained from sonic-cli and the Linux Bash shell, show the IPv6 addressing information for Leaf-101. The show ipv6 interface command displays the IPv6 configuration and interface state from the SONiC perspective. Ethernet 0 has the IPv6 link-local address fe80::ecb:81ff:fe19:a/64, and both its administrative and operational states are up. The ip link show Ethernet0 command displays the underlying Linux interface information, including the interface's link-layer MAC address.


Figure 6-3: Leaf-101 Link-Local and Link-Layer Address Verification.

The Linux command ip -6 neigh show dev Ethernet0 verifies that the Leaf-101 Linux kernel has a neighbor entry for Spine-11's IPv6 link-local address and its corresponding link-layer address. The neighbor entry is in the REACHABLE state, indicating that the neighbor has recently been confirmed as reachable by IPv6 Neighbor Discovery. The sonic-cli command show ipv6 neighbors interface Ethernet0 provides the same information, displaying both the IPv6 link-local address and its corresponding link-layer address. The Fwd (Forward) value in the Action field indicates that the neighbor entry is available for forwarding.

The sonic-cli command show ipv6 nd ra-interfaces Ethernet0 displays the Router Advertisement configuration for Ethernet0. The output confirms that Router Advertisements are sent every five seconds, that 12 Router Advertisements have been sent and none have been received, and that the advertised Hop Limit is 64. These values can be compared with the Router Advertisement messages captured with tcpdump in Example 6-1. The packet capture shows Router Advertisements from both Spine-11 and Leaf-101, with the advertised Hop Limit of 64 visible in each RA.

The packet capture also shows hlim 255 in the IPv6 header of each Router Advertisement. This value is different from the advertised Hop Limit of 64 contained in the RA message. The value 255 is the Hop Limit of the Router Advertisement packet itself, while the value 64 is the Hop Limit that the router advertises for hosts to use in subsequently generated IPv6 packets.



Figure 6-4: Leaf-101 IPv6 Peer Spine-11 IPv6 Link-Local and Link Layer Addressing.


CONFI_DB, APPL_DB Databases and config_db.json file

 

Figure 6-5 shows the corresponding entries in CONFIG_DB, APPL_DB, and the config_db.json file after enabling IPv6 and Router Advertisement (RA) messages on Ethernet0 of Leaf-101.

The configuration updates the CONFIG_DB INTERFACE|Ethernet0 table with the field/value pair "ipv6_use_link_local_only": "enable". This specifies that Ethernet0 uses only an IPv6 link-local address rather than a manually configured IPv6 address. The ND_CFG_MSG|Ethernet0 table contains the Neighbor Discovery configuration, showing an RA interval of 5 seconds with RA suppression disabled. Consequently, Leaf-101 is configured to advertise Router Advertisement messages on Ethernet 0.

The intfmgrd daemon, SONiC's interface manager, monitors interface configuration in CONFIG_DB and translates it into the application-level representation used by APPL_DB. In this example, APPL_DB contains an INTERFACE_TABLE:Ethernet0 entry corresponding to the interface configuration. It also contains an INTF_TABLE entry for Ethernet0 with the IPv6 prefix fe80::ecb:81ff:fe19:a/64. The entry identifies the address family as IPv6, specifies link_local_mode as auto, and indicates that the address has local scope. This represents Leaf-101's automatically assigned IPv6 link-local address.

APPL_DB also contains the NEIGH_REFRESH_TABLE:Ethernet0:fe80:: e22:34ff:feb6:a entry. Unlike the interface configuration and local IPv6 address, this entry represents dynamically learned information about the IPv6 neighbor on Ethernet0. The entry identifies the peer's IPv6 link-local address and its link-layer address, 0c:22:34:b6:00:0a. The isrouter field is set to 1, indicating that the neighbor is identified as a router.

The neighbor information originates from IPv6 Neighbor Discovery (ND) processing in the Linux kernel. When the switch receives a Router Advertisement (RA) from the peer, the Linux IPv6 ND subsystem processes the message and identifies the peer as an IPv6 router. The kernel also maintains the peer's IPv6-to-link-layer address mapping in its IPv6 neighbor table.

When the neighbor information is created or updated, the Linux kernel generates a Netlink neighbor event, such as an RTM_NEWNEIGH message [1]. The message is sent to the appropriate Netlink multicast group to which the SONiC neighsyncd daemon, running as part of SWSS, is subscribed. Neighsyncd receives the Netlink message, extracts the neighbor information, and synchronizes it with the SONiC application database. As a result, the peer's IPv6 link-local address and associated neighbor information becomes available in the NEIGH_REFRESH_TABLE in APPL_DB. This information can then be consumed by other SONiC components, such as orchagent, for further processing and programming of the forwarding plane.

Figure 6-5 also shows the corresponding entries in the config_db.json file. These entries represent persistent configuration and correspond to the configuration stored in CONFIG_DB. The dynamically learned neighbor information is not present in config_db.json because it originates from IPv6 Neighbor Discovery rather than from the configured state.




Figure 6-5: CONFIG_DB, APPL_DB Databases and Config_db.json file.

 

ASIC_DB

 

After the IPv6 neighbor information has been processed by orchagent, the corresponding SAI objects are represented in ASIC_DB. Figure 6-6 brings these objects together to show how they are related and how they contribute to forwarding an IPv6 packet toward the neighboring router, Spine-11.

The easiest way to understand these objects is to follow the forwarding relationship from the route to the egress port. The ROUTE_ENTRY identifies the destination prefix and the virtual router in which the route is installed. For the example in Figure 6-6, the destination prefix is fe80::/10, and the route belongs to virtual router oid:0x300000000003a.

The route contains the ATTR_NEXT_HOP_ID attribute, which points to the NEXT_HOP object oid:0x1000000000001. Its ATTR_PACKET_ACTION is SAI_PACKET_ACTION_FORWARD, indicating that packets matching the route are forwarded rather than dropped or trapped.

The NEXT_HOP object provides the IPv6 address of the next hop and identifies the router interface through which the packet is forwarded:

NEXT_HOP

    oid:0x1000000000001

    ATTR_IP: fe80::e22:34ff:feb6:a

    ATTR_ROUTER_INTERFACE_ID: oid:0x6000000000a48

 

The ATTR_ROUTER_INTERFACE_ID points to the ROUTER_INTERFACE object oid:0x6000000000a48. This object associates the L3 router interface with the virtual router and the physical port:

ROUTER_INTERFACE

    oid:0x6000000000a48

    ATTR_PORT_ID: oid:0x1000000000002

    ATTR_SRC_MAC_ADDRESS: 0C:CB:81:19:00:0A

    ATTR_VIRTUAL_ROUTER_ID: oid:0x300000000003a

 

The ATTR_PORT_ID points to the PORT object oid:0x1000000000002, which represents Ethernet0. Thus, the router interface ultimately identifies Ethernet0 as the egress port for the next-hop forwarding operation.

The NEXT_HOP object also identifies the IPv6 address of the neighboring router, fe80::e22:34ff:feb6:a. ASIC_DB contains a corresponding NEIGHBOR_ENTRY that associates this IPv6 address and router interface with the neighbor's destination MAC address:

NEIGHBOR_ENTRY

    IP: fe80::e22:34ff:feb6:a

    RIF: oid:0x6000000000a48

    ATTR_DST_MAC_ADDRESS: 0C:22:34:B6:00:0A

 

The orchagent log shows how the learned IPv6 neighbor information is processed. First, orchagent associates the peer's IPv6 link-local address with its MAC address on Ethernet0. It then creates a next-hop representation for the peer and maintains a MAC-to-neighbor mapping. These operations lead to the corresponding neighbor and next-hop objects being programmed into ASIC_DB.

 

:- addNeighborInternal: Created neighbor ip fe80::e22:34ff:feb6:a, 0c:22:34:b6:00:0a on Ethernet0, proto:0, nbr_tbl_add:FALSE

:- addNextHop: Created next hop fe80::e22:34ff:feb6:a|Ethernet0

:- addMactoIp: add neighbor fe80::e22:34ff:feb6:a to macToNeigh mapping, key:(Ethernet0, 0c:22:34:b6:00:0a)

These operations result in the corresponding neighbor and next-hop forwarding state being represented in ASIC_DB.

This relationship is important because the NEXT_HOP identifies the IPv6 address of the next hop, while the NEIGHBOR_ENTRY provides the link-layer destination address required to construct the Ethernet frame.


Figure 6-6: ASIC_DB Objects Mapping.

Figure 6-7 depicts the forwarding and neighbor resolution as chain:

 

Figure 6-7: Object Relationship in ASIC_DB.