Skip to content

RIB FIB HLD#2060

Open
eddieruan-alibaba wants to merge 9 commits into
sonic-net:masterfrom
eddieruan-alibaba:ribfib
Open

RIB FIB HLD#2060
eddieruan-alibaba wants to merge 9 commits into
sonic-net:masterfrom
eddieruan-alibaba:ribfib

Conversation

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@eddieruan-alibaba

Copy link
Copy Markdown
Contributor Author

@StormLiangMS

Copy link
Copy Markdown
Contributor

Could we add a knob to enable this feature selectively, based on demand? The reason I ask is that the NHG process between kernel and zebra has not been stable—we’ve had it disabled since 202405 to address a production issue (see sonic-net/sonic-buildimage#23459
). I can imagine this new design will introduce additional complexity, so until it matures and is qualified in production, it would be helpful to have a knob to control it.

@selva-nexthop selva-nexthop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one design question regarding where the NHG block is being maintained. Currently, this HLD proposes to keep the NHG block in fpmsyncd and persist it in Redis for warm restart reconciliation. While this works for the FRR-based stack, it introduces a few long-term architectural risks:

Tight Coupling to FRR:
I am not sure about other deployments of SONiC using different RIB entities. But modularization-wise, just want to understand the rationale of the placement of NHG blcok.
Maintaining NHG mapping in fpmsyncd makes the design dependent on FRR as the RIB. If in future deployments another routing entity (or alternate northbound programming mechanism) is used instead of FRR, the cache management logic would need to be duplicated in other agents

Placement of State Ownership:
Conceptually, NHG reconciliation feels closer to orchagent, since orchagent is the consumer responsible for applying NHG state into ASIC DB. Having the reconciliation state live in fpmsyncd risks splitting ownership of critical NHG state between two daemons.

Redis as Central Persistency:
Persisting the cache in Redis is fine for warm restart, but the ownership boundary still matters. If orchagent owns NHG lifecycle, it would be more consistent for it to also own the NHG cache, while Redis just acts as the persistence layer.

@eddieruan-alibaba

Copy link
Copy Markdown
Contributor Author

I have one design question regarding where the NHG block is being maintained. Currently, this HLD proposes to keep the NHG block in fpmsyncd and persist it in Redis for warm restart reconciliation. While this works for the FRR-based stack, it introduces a few long-term architectural risks:

Tight Coupling to FRR: I am not sure about other deployments of SONiC using different RIB entities. But modularization-wise, just want to understand the rationale of the placement of NHG blcok. Maintaining NHG mapping in fpmsyncd makes the design dependent on FRR as the RIB. If in future deployments another routing entity (or alternate northbound programming mechanism) is used instead of FRR, the cache management logic would need to be duplicated in other agents

EDDIE:
FPM is Forwarding Plane Manager. It is a component of FRR that provides a mechanism to export routing updates (like route additions, modifications, or deletions) from FRR’s internal Routing Information Base (RIB) to an external forwarding plane.

Once we use FPM, it is tight coupled with FRR.

Currently, I don't see any valid use cases to replace FRR to somethingelse. I would not worry about this tight couple to FRR, since it is current arch design. Any change in this arch design would need to be discussed in TSC.

Placement of State Ownership: Conceptually, NHG reconciliation feels closer to orchagent, since orchagent is the consumer responsible for applying NHG state into ASIC DB. Having the reconciliation state live in fpmsyncd risks splitting ownership of critical NHG state between two daemons.

EDDIE:
We map zebra NHG information to various SONiC APP DB objects here., SONiC NHG OBJ is just one of them. Currently, this step is handled in zebra, now we want to move fpmsyncd to provide FIB functionality.

Redis as Central Persistency: Persisting the cache in Redis is fine for warm restart, but the ownership boundary still matters. If orchagent owns NHG lifecycle, it would be more consistent for it to also own the NHG cache, while Redis just acts as the persistence layer.

EDDIE: We discussed it in WG before. Current logic, during warmreboot, fpmsyncd would check if routes information are changed or not and skip routes updating to avoid unnecessary hardware update. We want to keep this design philosophy as well.

Redis is an expensive access. We want to keep only SONIC OBJs in there. FIB would break RIB information into corresponding SONiC OBJs.

@eddieruan-alibaba

Copy link
Copy Markdown
Contributor Author

Could we add a knob to enable this feature selectively, based on demand? The reason I ask is that the NHG process between kernel and zebra has not been stable—we’ve had it disabled since 202405 to address a production issue (see sonic-net/sonic-buildimage#23459 ). I can imagine this new design will introduce additional complexity, so until it matures and is qualified in production, it would be helpful to have a knob to control it.

That is a valid ask. We don't plan to remove current code path. If NHG usage is disabled, we will use current code path. But if NHG usage is enabled, we will go with RIB/FIB path.

Comment thread doc/ribfib/ribfib.md Outdated
Comment thread doc/ribfib/ribfib.md
Comment thread doc/ribfib/ribfib.md
Comment thread doc/ribfib/ribfib.md Outdated
Comment thread doc/ribfib/ribfib.md
Comment thread doc/ribfib/ribfib.md
Comment thread doc/ribfib/ribfib.md Outdated
@pbrisset

Copy link
Copy Markdown
Contributor

Regarding the comment about FRR and FIB manager being tightly coupled, I must agree with it. FIB manager should also work for controllers taping on SONiC.

Perhaps, Requirements should be clearly stated at the beginning of this document.

@eddieruan-alibaba

eddieruan-alibaba commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Regarding the comment about FRR and FIB manager being tightly coupled, I must agree with it. FIB manager should also work for controllers taping on SONiC.

Perhaps, Requirements should be clearly stated at the beginning of this document.

I added a section at the very beginning of this document to clarify these discussions are not in the scope of this document.

https://github.com/eddieruan-alibaba/SONiC/blob/ribfib/doc/ribfib/ribfib.md#topics-not-in-the-scope

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

Comment thread doc/ribfib/ribfib.md
Comment thread doc/ribfib/ribfib.md
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
…led in fpmsyncd

Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
@rookie-who

Copy link
Copy Markdown
Contributor

Hi @eddieruan-alibaba — the 202605 branch cut is at end of May. @selva-nexthop left review comments in March. Please address them.

CC: @vaibhavhd @radha-danda (branch managers)

@eddieruan-alibaba

Copy link
Copy Markdown
Contributor Author

Hi @eddieruan-alibaba — the 202605 branch cut is at end of May. @selva-nexthop left review comments in March. Please address them.

CC: @vaibhavhd @radha-danda (branch managers)

The review comments have been addressed. Currently, I am waiting all Code PRs to be merged

prsunny pushed a commit to sonic-net/sonic-swss that referenced this pull request May 21, 2026
)

* [fpmsyncd]: add libnexthopgroup in Makefile.am to support rib/fib feature
What I did

Add libnexthopgroup in fpmsyncd Makefile.am to support RIB/FIB

Why I did it

In the RIB/FIB design, we need the libnexthopgroup compiled from sonic-fib to communicate with Zebra.
More details please refer the documents following:

RIB/FIB HLD: sonic-net/SONiC#2060
nhg mgr LLD: sonic-net/SONiC#2270
sonic-fib PR: sonic-net/SONiC#2270
RIB/FIB nhg mgr code: #4395
@rookie-who

Copy link
Copy Markdown
Contributor

This PR/feature will not be included in the SONiC 202605 release. It can be retargeted for the 202611 release.

Comment thread doc/ribfib/ribfib.md
* Each entry in the SONiC Zebra NHG table must correspond to an entry in Zebra’s NHG hash table.
* The entry stores the struct zebra_dplane_ctx as the Zebra context, which is the yellow and green parts in the following diagram.
* In addition, it maintains SONiC-specific metadata, such as the SONiC NHG ID, which is the blue part in the following diagram.
![image](images/zebra_nhg_table_entry.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the "uint32_t id" in the yellow part of the diagram?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is zebra NHG id. It is just a logic view.

Comment thread doc/ribfib/ribfib.md
This design allows the SONiC Zebra NHG table to serve as a mapping table between Zebra NHG IDs and SONiC NHG IDs.

#### NEXTHOP KEY to Zebra NHG ID mapping
This mapping table is used during warm reboot to mapping new zebra NHG ID to existing SONiC NHG ID.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add details on what constitutes a nexthop key?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to use generate term in HLD. The key would be defined in LLD, based on the features we supports.

Logically, it is the same set of fields used in zebra. But since we don't support some MPLS features, some fields would not be carried over. So it would be a trimmed version.

Comment thread doc/ribfib/ribfib.md Outdated
### SONiC NHG table
In certain scenarios, it is necessary to create a new SONIC Next Hop Group (NHG) upon receiving a zebra NHG event. In such cases, the corresponding SONiC NHG will be maintained in the SONiC NHG table.

For the SRv6 VPN use case, NHG messages from Zebra carry not only forwarding information but also additional context, such as the VPN SID or a policy SID list. To handle this, SONiC will create a gateway NHG that contains the forwarding information only. This gateway NHG is also referred to as the PIC NHG. The accompanying context information will be used to construct a PIC Context object in SONiC.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we stick with a single term..either "gateway" or "pic" NHG and use that consistently in the document. It would also be good to use that consistently in the code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you list what exactly is part of "gateway"/"pic" NHG.
In the HLD, it would be good to have lesser code and have more logical content. Or you can remove the rest and only highlight the part of the code that is pertinent (with explanations about what it is doing or what the field means).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will remove PIC NHG term, only use gateway nhg.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed PIC NHG and only use gateway NHG in eddieruan-alibaba@06b4f30

Comment thread doc/ribfib/ribfib.md
This mapping table is used during warm reboot to mapping new zebra NHG ID to existing SONiC NHG ID.

### SONiC NHG table
In certain scenarios, it is necessary to create a new SONIC Next Hop Group (NHG) upon receiving a zebra NHG event. In such cases, the corresponding SONiC NHG will be maintained in the SONiC NHG table.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is not very clear to me. Which scenarios require the creation of SONiC NHG? I thought that would get created all the time? Can you add more explanation here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PE3# show ip route vrf Vrf1 192.100.0.1 next
Routing entry for 192.100.0.1/32
Known via "bgp", distance 20, metric 0, vrf Vrf1, best
Last update 00:16:37 ago
Nexthop Group ID: 246
Received Nexthop Group ID: 244
q 2064:100::1d(vrf default) (recursive), label 16, weight 1
q fc06::2, via Ethernet12(vrf default), label 16, weight 1
q fc08::2, via Ethernet4(vrf default), label 16, weight 1
q 2064:200::1e(vrf default) (recursive), label 32, weight 1
q fc06::2, via Ethernet12(vrf default), label 32, weight 1
q fc08::2, via Ethernet4(vrf default), label 32, weight 1

PE3# show nexthop rib 244
ID: 244 (zebra)
RefCnt: 10 Flags: 0x403
Uptime: 00:16:46
VRF: default(No AFI)
Nexthop Count: 2
Valid, Installed
Depends: (238) (245)
via 2064:100::1d (vrf default) inactive, label 16, seg6 fd00:201:201:1::, weight 1
via 2064:200::1e (vrf default) inactive, label 32, seg6 fd00:202:202:2::, weight 1

For this NHG, it has 2064:100::1d and 2064:200::1e as nexthops, with corresponding VPN contexts.

This zebra NHG would create two SONIC object, SONiC NHG and SONiC PIC CONTEXT

127.0.0.1:6378> hgetall "NEXTHOP_GROUP_TABLE:4"

  1. "nexthop"
  2. "2064:100::1d,2064:200::1e"
  3. "ifname"
  4. "unknown,unknown"
  5. "weight"
  6. "1,1"
  7. "seg_src"
  8. "2064:300::1f,2064:300::1f"

127.0.0.1:6378> hgetall "PIC_CONTEXT_TABLE:3"

  1. "nexthop"
  2. "2064:200::1e,2064:100::1d"
  3. "ifname"
  4. "unknown,unknown"
  5. "weight"
  6. "1,1"
  7. "vpn_sid"
  8. "fd00:202:202:2::,fd00:201:201:1::"
  9. "seg_src"
  10. "2064:300::1f,2064:300::1f"

SONiC NHG is sharable, while SONiC PIC Context is not since it has VPN context.

Since SONiC NHG is sharable, it stores in SONiC NHG table.

Signed-off-by: Eddie Ruan <eddie.ruan@alibaba-inc.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@eddieruan-alibaba eddieruan-alibaba moved this to 🏗 In Progress in SONiC 202611 Release Jul 8, 2026
Yogapriya-cisco pushed a commit to prhoskot/sonic-swss that referenced this pull request Jul 13, 2026
…nic-net#4394)

* [fpmsyncd]: add libnexthopgroup in Makefile.am to support rib/fib feature
What I did

Add libnexthopgroup in fpmsyncd Makefile.am to support RIB/FIB

Why I did it

In the RIB/FIB design, we need the libnexthopgroup compiled from sonic-fib to communicate with Zebra.
More details please refer the documents following:

RIB/FIB HLD: sonic-net/SONiC#2060
nhg mgr LLD: sonic-net/SONiC#2270
sonic-fib PR: sonic-net/SONiC#2270
RIB/FIB nhg mgr code: sonic-net#4395

Signed-off-by: Yogapriya Mohankumar <ymohanku@cisco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress
Status: 🏗 In Progress
Status: In Progress

Development

Successfully merging this pull request may close these issues.

8 participants