KEMBAR78
SONiC Static Route Code Changes Overview | PDF | Command Line Interface | Software
0% found this document useful (0 votes)
27 views9 pages

SONiC Static Route Code Changes Overview

The document outlines the updates made to support static routes in SONiC, including the creation of a new YANG model for the STATIC_ROUTE table and enhancements to CLI, REST, and gNMI interfaces. It details the integration with FRR through frrcfgd, which listens for changes in the STATIC_ROUTE table and applies them to the FRR configuration. Additionally, it covers unit testing and automation for adding, deleting, and validating static routes across various methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views9 pages

SONiC Static Route Code Changes Overview

The document outlines the updates made to support static routes in SONiC, including the creation of a new YANG model for the STATIC_ROUTE table and enhancements to CLI, REST, and gNMI interfaces. It details the integration with FRR through frrcfgd, which listens for changes in the STATIC_ROUTE table and applies them to the FRR configuration. Additionally, it covers unit testing and automation for adding, deleting, and validating static routes across various methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

🔧 SONiC Static Route

Code Changes Overview


This section explains all the components updated/created to support
static routes using STATIC_ROUTE table in CONFIG_DB, with support
via CLI, REST, and gNMI, and integration with FRR using frrcfgd.
1. CONFIG_DB Table Definition
File Modified: sonic-utilities/sonic-yang-models/yang-models/sonic-static-route.yang

Change:

New YANG model sonic-static-route.yang defines STATIC_ROUTE table format.

Fields Introduced:

+--rw STATIC_ROUTE_LIST* [vrf-name prefix]+--rw vrf-name string+--rw prefix inet:ip-prefix+--rw nexthop string+--
rw ifname string+--rw distance string+--rw nexthop-vrf string+--rw blackhole string
2. Transformer Changes (REST, gNMI)
Files Modified:

rest_server/sonic_static_route_trans.py (new or updated transformer script)

Change:

Maps YANG model fields ↔ STATIC_ROUTE DB entries. Handles splitting/joining comma-separated list fields for multiple
nexthops.

Key Logic:

• Build key: STATIC_ROUTE||


• Align all list fields by index (e.g., nexthop[0], ifname[0], etc.)
• Use default values (0.0.0.0, "", "false", etc.) to complete sets.
3. CLI Command Support
Files Modified:

sonic-utilities/config/main.py sonic-utilities/show/main.py

Change:

Support added for: ip route, ipv6 route no ip route, no ipv6 route show ip route static, show ipv6 route static

Logic Added:

• Construct comma-separated fields in STATIC_ROUTE based on CLI arguments.


• Apply/remove DB entry via config_db.set_entry() and config_db.set().
4. FRR Integration via frrcfgd
Files Modified/Created:

frrcfgd/frrcfgd.py frrcfgd/static_route_handler.py (new or updated)

Change:

frrcfgd subscribes to changes in STATIC_ROUTE table. On change, builds and applies vtysh CLI equivalent:

ip route [blackhole] [distance] [nexthop-vrf]

Logic Added:

• Loop over all next-hop sets


• Resolve defaults and map to correct vtysh syntax
• Use vtysh shell to update FRR configuration in runtime
5. RESTCONF / gNMI Support
Files Modified:

rest_server/rest_routes.py rest_server/data_model.py gnmi_server/translator/translator_static_route.py (if applicable)

Changes:

Add routes for static route endpoints:

/restconf/data/openconfig-network-instance:network-instances/network-instance={vrf}/...

Supported Methods:

GET, POST, PATCH, DELETE for: Entire static-routes Specific prefix Specific next-hop[index]

Note:

• Must convert openconfig keys into internal formats: index → derived from nexthop + ifname + nexthop-vrf (or DROP)
• Translate blackhole as a next-hop entry
6. Application DB Integration
Files:

orchagent/routeorch.cpp orchagent/neighresolveorch.cpp syncd and SAI – No changes

Change:

orchagent writes unresolved next-hops to NEIGH_RESOLVE_TABLE nbrmgrd listens to NEIGH_RESOLVE_TABLE and performs
resolution
7. Unit Testing & Automation
Files Modified:

sonic-swss/tests/test_route.py spytest/testcases/test_static_route.py (if added)

Tests Added:

• Positive test cases: add/delete static routes using all methods (CLI/REST/gNMI)
• Negative test cases: wrong distance, invalid VRF, mismatched AF
• Configuration reload tests (via config reload or warm boot)
8. Template for Configuration Reload
Files Added/Modified:

frrcfgd/templates/staticd.conf.j2

Change:

Uses Jinja2 template to generate FRR staticd.conf file Loaded on system/config reload to persist static routes

🧩 Summary of Integration Component Change Type Details

CONFIG_DB Schema + YANG STATIC_ROUTE + sonic-static-route.yang

CLI Command Logic ip route, ipv6 route, delete, show

Transformer REST/gNMI Bridge Converts YANG ↔ DB fields

frrcfgd Sync to FRR Listens to DB, sends to vtysh

REST API Interface Support GET/POST/PATCH/DELETE for static routes

Orchestration Neighbor Resolve NEIGH_RESOLVE_TABLE

Unit Test Automation spytest, FRR config check, CLI validation

Reload Persistence Generates staticd.conf from configDB

You might also like