o 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. I 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
1. _ 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.
1. ï 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().
1. _ 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
1. 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
1. / Application DB Integration
Files:
orchagent/routeorch.cpp orchagent/neighresolveorch.cpp syncd and SAI 3 No changes
Change:
orchagent writes unresolved next-hops to NEIGH_RESOLVE_TABLE nbrmgrd listens to NEIGH_RESOLVE_TABLE and performs
resolution
1. i 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)
1. 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
h 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