Skip to content

Commit a693520

Browse files
authoredMar 6, 2025
[FRR]: Add CLI to support steering of IPv4 traffic over SRv6 SID list (sonic-net#21707)
Currently SONiC supports the steering of IPv6 traffic over SRv6 SID List. This commit adds the support to steering of IPv4 traffic over SRv6 SID list. This PR has been already merged into FRR mainline (FRRouting/frr#17988). Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
1 parent e3f3483 commit a693520

File tree

2 files changed

+436
-0
lines changed

2 files changed

+436
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,435 @@
1+
From 6f52056f70524a26e7ff72c06ca9be826763d603 Mon Sep 17 00:00:00 2001
2+
From: Carmine Scarpitta <cscarpit@cisco.com>
3+
Date: Tue, 24 Dec 2024 08:56:28 +0100
4+
Subject: [PATCH 1/6] staticd: Extend `ip_route_address_interface` to support
5+
SRv6 traffic steering
6+
7+
staticd already has a CLI to steer IPv6 traffic over a given SRv6 SID
8+
list:
9+
10+
```
11+
ipv6 route 2001:db8:1:1::/64 sr0 segments fcbb:bbbb:1:2:3:fe00::
12+
```
13+
14+
This PR extends the existing CLI `ip route` to support steering of IPv4
15+
traffic over an SRv6 SID list.
16+
17+
```
18+
ip route 10.0.0.0/24 sr0 segments fcbb:bbbb:1:2:3:fe00::
19+
```
20+
21+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
22+
---
23+
staticd/static_vty.c | 6 +++++-
24+
1 file changed, 5 insertions(+), 1 deletion(-)
25+
26+
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
27+
index ed2805d3eab9..ce414121dca3 100644
28+
--- a/staticd/static_vty.c
29+
+++ b/staticd/static_vty.c
30+
@@ -564,6 +564,7 @@ DEFPY_YANG(ip_route_address_interface,
31+
|onlink$onlink \
32+
|color (1-4294967295) \
33+
|bfd$bfd [{multi-hop$bfd_multi_hop|source A.B.C.D$bfd_source|profile BFDPROF$bfd_profile}] \
34+
+ |segments WORD \
35+
}]",
36+
NO_STR IP_STR
37+
"Establish static routes\n"
38+
@@ -589,7 +590,9 @@ DEFPY_YANG(ip_route_address_interface,
39+
BFD_INTEGRATION_SOURCE_STR
40+
BFD_INTEGRATION_SOURCEV4_STR
41+
BFD_PROFILE_STR
42+
- BFD_PROFILE_NAME_STR)
43+
+ BFD_PROFILE_NAME_STR
44+
+ "Steer this route over an SRv6 SID list\n"
45+
+ "SRv6 SID list\n")
46+
{
47+
struct static_route_args args = {
48+
.delete = !!no,
49+
@@ -611,6 +614,7 @@ DEFPY_YANG(ip_route_address_interface,
50+
.bfd_multi_hop = !!bfd_multi_hop,
51+
.bfd_source = bfd_source_str,
52+
.bfd_profile = bfd_profile,
53+
+ .segs = segments,
54+
};
55+
56+
return static_route_nb_run(vty, &args);
57+
58+
From e1e31e086983ac9d18fa973172697436b9368495 Mon Sep 17 00:00:00 2001
59+
From: Carmine Scarpitta <cscarpit@cisco.com>
60+
Date: Tue, 24 Dec 2024 08:57:28 +0100
61+
Subject: [PATCH 2/6] staticd: Extend `ip_route_address_interface_vrf` to
62+
support SRv6 traffic steering
63+
64+
staticd already has a CLI to steer IPv6 traffic over a given SRv6 SID
65+
list:
66+
67+
```
68+
vrf vrf10
69+
ipv6 route 2001:db8:1:1::/64 sr0 segments fcbb:bbbb:1:2:3:fe00::
70+
```
71+
72+
This PR extends the existing CLI `ip route` to support steering of IPv4
73+
traffic over an SRv6 SID list.
74+
75+
```
76+
vrf vrf10
77+
ip route 10.0.0.0/24 sr0 segments fcbb:bbbb:1:2:3:fe00::
78+
```
79+
80+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
81+
---
82+
staticd/static_vty.c | 6 +++++-
83+
1 file changed, 5 insertions(+), 1 deletion(-)
84+
85+
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
86+
index ce414121dca3..cabcf00b034d 100644
87+
--- a/staticd/static_vty.c
88+
+++ b/staticd/static_vty.c
89+
@@ -635,6 +635,7 @@ DEFPY_YANG(ip_route_address_interface_vrf,
90+
|onlink$onlink \
91+
|color (1-4294967295) \
92+
|bfd$bfd [{multi-hop$bfd_multi_hop|source A.B.C.D$bfd_source|profile BFDPROF$bfd_profile}] \
93+
+ |segments WORD \
94+
}]",
95+
NO_STR IP_STR
96+
"Establish static routes\n"
97+
@@ -659,7 +660,9 @@ DEFPY_YANG(ip_route_address_interface_vrf,
98+
BFD_INTEGRATION_SOURCE_STR
99+
BFD_INTEGRATION_SOURCEV4_STR
100+
BFD_PROFILE_STR
101+
- BFD_PROFILE_NAME_STR)
102+
+ BFD_PROFILE_NAME_STR
103+
+ "Steer this route over an SRv6 SID list\n"
104+
+ "SRv6 SID list\n")
105+
{
106+
struct static_route_args args = {
107+
.delete = !!no,
108+
@@ -681,6 +684,7 @@ DEFPY_YANG(ip_route_address_interface_vrf,
109+
.bfd_multi_hop = !!bfd_multi_hop,
110+
.bfd_source = bfd_source_str,
111+
.bfd_profile = bfd_profile,
112+
+ .segs = segments,
113+
};
114+
115+
return static_route_nb_run(vty, &args);
116+
117+
From 885181acb441dcb1b78bacea2c4287ac20e5d043 Mon Sep 17 00:00:00 2001
118+
From: Carmine Scarpitta <cscarpit@cisco.com>
119+
Date: Tue, 24 Dec 2024 08:58:41 +0100
120+
Subject: [PATCH 3/6] staticd: Extend `ip_route` CLI to support SRv6 traffic
121+
steering
122+
123+
staticd already has a CLI to steer IPv6 traffic over a given SRv6 SID
124+
list:
125+
126+
```
127+
ipv6 route 2001:db8:1:1::/64 sr0 segments fcbb:bbbb:1:2:3:fe00::
128+
```
129+
130+
This PR extends the existing CLI `ip route` to support steering of IPv4
131+
traffic over an SRv6 SID list.
132+
133+
```
134+
ip route 10.0.0.0/24 sr0 segments fcbb:bbbb:1:2:3:fe00::
135+
```
136+
137+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
138+
---
139+
staticd/static_vty.c | 6 +++++-
140+
1 file changed, 5 insertions(+), 1 deletion(-)
141+
142+
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
143+
index cabcf00b034d..b84e3b6a6cb9 100644
144+
--- a/staticd/static_vty.c
145+
+++ b/staticd/static_vty.c
146+
@@ -704,6 +704,7 @@ DEFPY_YANG(ip_route,
147+
|nexthop-vrf NAME \
148+
|color (1-4294967295) \
149+
|bfd$bfd [{multi-hop$bfd_multi_hop|source A.B.C.D$bfd_source|profile BFDPROF$bfd_profile}] \
150+
+ |segments WORD \
151+
}]",
152+
NO_STR IP_STR
153+
"Establish static routes\n"
154+
@@ -728,7 +729,9 @@ DEFPY_YANG(ip_route,
155+
BFD_INTEGRATION_SOURCE_STR
156+
BFD_INTEGRATION_SOURCEV4_STR
157+
BFD_PROFILE_STR
158+
- BFD_PROFILE_NAME_STR)
159+
+ BFD_PROFILE_NAME_STR
160+
+ "Steer this route over an SRv6 SID list\n"
161+
+ "SRv6 SID list\n")
162+
{
163+
struct static_route_args args = {
164+
.delete = !!no,
165+
@@ -749,6 +752,7 @@ DEFPY_YANG(ip_route,
166+
.bfd_multi_hop = !!bfd_multi_hop,
167+
.bfd_source = bfd_source_str,
168+
.bfd_profile = bfd_profile,
169+
+ .segs = segments,
170+
};
171+
172+
return static_route_nb_run(vty, &args);
173+
174+
From 39613ec8be65240f1dfd4ec623c259076062b91c Mon Sep 17 00:00:00 2001
175+
From: Carmine Scarpitta <cscarpit@cisco.com>
176+
Date: Tue, 24 Dec 2024 08:59:18 +0100
177+
Subject: [PATCH 4/6] staticd: Extend `ip_route_vrf` CLI to support SRv6
178+
traffic steering
179+
180+
staticd already has a CLI to steer IPv6 traffic over a given SRv6 SID
181+
list:
182+
183+
```
184+
vrf vrf10
185+
ipv6 route 2001:db8:1:1::/64 sr0 segments fcbb:bbbb:1:2:3:fe00::
186+
```
187+
188+
This PR extends the existing CLI `ip route` to support steering of IPv4
189+
traffic over an SRv6 SID list.
190+
191+
```
192+
vrf vrf10
193+
ip route 10.0.0.0/24 sr0 segments fcbb:bbbb:1:2:3:fe00::
194+
```
195+
196+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
197+
---
198+
staticd/static_vty.c | 6 +++++-
199+
1 file changed, 5 insertions(+), 1 deletion(-)
200+
201+
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
202+
index b84e3b6a6cb9..7c425f4a33df 100644
203+
--- a/staticd/static_vty.c
204+
+++ b/staticd/static_vty.c
205+
@@ -771,6 +771,7 @@ DEFPY_YANG(ip_route_vrf,
206+
|nexthop-vrf NAME \
207+
|color (1-4294967295) \
208+
|bfd$bfd [{multi-hop$bfd_multi_hop|source A.B.C.D$bfd_source|profile BFDPROF$bfd_profile}] \
209+
+ |segments WORD \
210+
}]",
211+
NO_STR IP_STR
212+
"Establish static routes\n"
213+
@@ -794,7 +795,9 @@ DEFPY_YANG(ip_route_vrf,
214+
BFD_INTEGRATION_SOURCE_STR
215+
BFD_INTEGRATION_SOURCEV4_STR
216+
BFD_PROFILE_STR
217+
- BFD_PROFILE_NAME_STR)
218+
+ BFD_PROFILE_NAME_STR
219+
+ "Steer this route over an SRv6 SID list\n"
220+
+ "SRv6 SID list\n")
221+
{
222+
struct static_route_args args = {
223+
.delete = !!no,
224+
@@ -815,6 +818,7 @@ DEFPY_YANG(ip_route_vrf,
225+
.bfd_multi_hop = !!bfd_multi_hop,
226+
.bfd_source = bfd_source_str,
227+
.bfd_profile = bfd_profile,
228+
+ .segs = segments,
229+
};
230+
231+
return static_route_nb_run(vty, &args);
232+
233+
From 478550efc404332cf44ed05905aecec8c9c3eaba Mon Sep 17 00:00:00 2001
234+
From: Carmine Scarpitta <cscarpit@cisco.com>
235+
Date: Tue, 24 Dec 2024 09:22:52 +0100
236+
Subject: [PATCH 5/6] doc: Add documentation for SRv6 IPv4 traffic steering
237+
238+
Add an example of how to steer IPv4 traffic over an SRv6 SID list.
239+
240+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
241+
---
242+
doc/user/static.rst | 14 ++++++++++++++
243+
1 file changed, 14 insertions(+)
244+
245+
diff --git a/doc/user/static.rst b/doc/user/static.rst
246+
index 5bf5004a66fb..0ce6e2107e7c 100644
247+
--- a/doc/user/static.rst
248+
+++ b/doc/user/static.rst
249+
@@ -177,2 +177,16 @@ multiple segments instructions.
250+
[..]
251+
S>* 2005::/64 [1/0] is directly connected, ens3, seg6 2001:db8:aaaa::7,2002::4,2002::3,2002::2, weight 1, 00:00:06
252+
+
253+
+STATIC also supports steering of IPv4 traffic over an SRv6 SID list, as shown in the example below.
254+
+
255+
+.. code-block:: frr
256+
+
257+
+ ip route A.B.C.D <A.B.C.D|nexthop> segments U:U::U:U/Y:Y::Y:Y/Z:Z::Z:Z
258+
+
259+
+::
260+
+
261+
+ router(config)# ip route 10.0.0.0/24 sr0 segments fcbb:bbbb:1:2:3:fe00::
262+
+
263+
+ router# show ip route
264+
+ [..]
265+
+ S>* 10.0.0.0/24 [1/0] is directly connected, sr0, seg6 fcbb:bbbb:1:2:3:fe00::, weight 1, 00:00:06
266+
\ No newline at end of file
267+
268+
From 1add31d129ddbe53afd8ac83717f7818c1fb228a Mon Sep 17 00:00:00 2001
269+
From: Carmine Scarpitta <cscarpit@cisco.com>
270+
Date: Tue, 24 Dec 2024 09:42:34 +0100
271+
Subject: [PATCH 6/6] tests: Add topotest for SRv6 IPv4 traffic steering
272+
273+
Add a topotest to verify the newly introduced CLI to support
274+
steering of IPv4 traffic over an SRv6 SID list.
275+
276+
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
277+
---
278+
.../srv6_static_route_ipv4/__init__.py | 0
279+
.../expected_srv6_route.json | 28 +++++++
280+
.../srv6_static_route_ipv4/r1/frr.conf | 7 ++
281+
.../srv6_static_route_ipv4/r1/setup.sh | 2 +
282+
.../srv6_static_route_ipv4/test_srv6_route.py | 82 +++++++++++++++++++
283+
5 files changed, 119 insertions(+)
284+
create mode 100644 tests/topotests/srv6_static_route_ipv4/__init__.py
285+
create mode 100644 tests/topotests/srv6_static_route_ipv4/expected_srv6_route.json
286+
create mode 100644 tests/topotests/srv6_static_route_ipv4/r1/frr.conf
287+
create mode 100644 tests/topotests/srv6_static_route_ipv4/r1/setup.sh
288+
create mode 100755 tests/topotests/srv6_static_route_ipv4/test_srv6_route.py
289+
290+
diff --git a/tests/topotests/srv6_static_route_ipv4/__init__.py b/tests/topotests/srv6_static_route_ipv4/__init__.py
291+
new file mode 100644
292+
index 000000000000..e69de29bb2d1
293+
diff --git a/tests/topotests/srv6_static_route_ipv4/expected_srv6_route.json b/tests/topotests/srv6_static_route_ipv4/expected_srv6_route.json
294+
new file mode 100644
295+
index 000000000000..57f4c4488dbd
296+
--- /dev/null
297+
+++ b/tests/topotests/srv6_static_route_ipv4/expected_srv6_route.json
298+
@@ -0,0 +1,28 @@
299+
+{
300+
+ "192.0.2.0/24": [
301+
+ {
302+
+ "prefix": "192.0.2.0/24",
303+
+ "prefixLen": 24,
304+
+ "protocol": "static",
305+
+ "selected": true,
306+
+ "destSelected": true,
307+
+ "distance": 1,
308+
+ "metric": 0,
309+
+ "installed": true,
310+
+ "nexthops": [
311+
+ {
312+
+ "directlyConnected": true,
313+
+ "active": true,
314+
+ "weight": 1,
315+
+ "seg6local": {
316+
+ "action": "unspec"
317+
+ },
318+
+ "seg6": [
319+
+ "fcbb:bbbb:1:2:3:4:5:6",
320+
+ "fcbb:bbbb:7:8:fe00::"
321+
+ ]
322+
+ }
323+
+ ]
324+
+ }
325+
+ ]
326+
+}
327+
diff --git a/tests/topotests/srv6_static_route_ipv4/r1/frr.conf b/tests/topotests/srv6_static_route_ipv4/r1/frr.conf
328+
new file mode 100644
329+
index 000000000000..8ff23ec1b886
330+
--- /dev/null
331+
+++ b/tests/topotests/srv6_static_route_ipv4/r1/frr.conf
332+
@@ -0,0 +1,7 @@
333+
+hostname r1
334+
+!
335+
+log stdout notifications
336+
+log commands
337+
+!
338+
+ipv6 route fcbb:bbbb:1::/48 sr0
339+
+ip route 192.0.2.0/24 sr0 segments fcbb:bbbb:1:2:3:4:5:6/fcbb:bbbb:7:8:fe00::
340+
diff --git a/tests/topotests/srv6_static_route_ipv4/r1/setup.sh b/tests/topotests/srv6_static_route_ipv4/r1/setup.sh
341+
new file mode 100644
342+
index 000000000000..4b6cce89f89d
343+
--- /dev/null
344+
+++ b/tests/topotests/srv6_static_route_ipv4/r1/setup.sh
345+
@@ -0,0 +1,2 @@
346+
+ip link add sr0 type dummy
347+
+ip link set sr0 up
348+
diff --git a/tests/topotests/srv6_static_route_ipv4/test_srv6_route.py b/tests/topotests/srv6_static_route_ipv4/test_srv6_route.py
349+
new file mode 100755
350+
index 000000000000..b49a9cec8928
351+
--- /dev/null
352+
+++ b/tests/topotests/srv6_static_route_ipv4/test_srv6_route.py
353+
@@ -0,0 +1,82 @@
354+
+#!/usr/bin/env python
355+
+# SPDX-License-Identifier: ISC
356+
+
357+
+#
358+
+# test_srv6_static_route_ipv4.py
359+
+#
360+
+# Copyright 2025
361+
+# Carmine Scarpitta <cscarpit.@cisco.com>
362+
+#
363+
+
364+
+"""
365+
+test_srv6_static_route_ipv4.py:
366+
+Test for SRv6 static route on zebra
367+
+"""
368+
+
369+
+import os
370+
+import sys
371+
+import json
372+
+import pytest
373+
+import functools
374+
+
375+
+CWD = os.path.dirname(os.path.realpath(__file__))
376+
+sys.path.append(os.path.join(CWD, "../"))
377+
+
378+
+# pylint: disable=C0413
379+
+from lib import topotest
380+
+from lib.topogen import Topogen, TopoRouter, get_topogen
381+
+from lib.topolog import logger
382+
+
383+
+pytestmark = [pytest.mark.staticd]
384+
+
385+
+
386+
+def open_json_file(filename):
387+
+ try:
388+
+ with open(filename, "r") as f:
389+
+ return json.load(f)
390+
+ except IOError:
391+
+ assert False, "Could not read file {}".format(filename)
392+
+
393+
+
394+
+def setup_module(mod):
395+
+ tgen = Topogen({None: "r1"}, mod.__name__)
396+
+ tgen.start_topology()
397+
+ for rname, router in tgen.routers().items():
398+
+ router.run("/bin/bash {}/{}/setup.sh".format(CWD, rname))
399+
+ router.load_frr_config("frr.conf")
400+
+ tgen.start_router()
401+
+
402+
+
403+
+def teardown_module():
404+
+ tgen = get_topogen()
405+
+ tgen.stop_topology()
406+
+
407+
+
408+
+def test_srv6_static_route():
409+
+ tgen = get_topogen()
410+
+ if tgen.routers_have_failure():
411+
+ pytest.skip(tgen.errors)
412+
+ router = tgen.gears["r1"]
413+
+
414+
+ def _check_srv6_static_route(router, expected_route_file):
415+
+ logger.info("checking zebra srv6 static route with multiple segs status")
416+
+ output = json.loads(router.vtysh_cmd("show ip route static json"))
417+
+ expected = open_json_file("{}/{}".format(CWD, expected_route_file))
418+
+ return topotest.json_cmp(output, expected)
419+
+
420+
+ def check_srv6_static_route(router, expected_file):
421+
+ func = functools.partial(_check_srv6_static_route, router, expected_file)
422+
+ _, result = topotest.run_and_expect(func, None, count=15, wait=1)
423+
+ assert result is None, "Failed"
424+
+
425+
+ # FOR DEVELOPER:
426+
+ # If you want to stop some specific line and start interactive shell,
427+
+ # please use tgen.mininet_cli() to start it.
428+
+
429+
+ logger.info("Test for srv6 route configuration")
430+
+ check_srv6_static_route(router, "expected_srv6_route.json")
431+
+
432+
+
433+
+if __name__ == "__main__":
434+
+ args = ["-s"] + sys.argv[1:]
435+
+ sys.exit(pytest.main(args))

‎src/sonic-frr/patch/series

+1
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@
6262
0079-staticd-add-support-for-srv6.patch
6363
0080-SRv6-vpn-route-and-sidlist-install.patch
6464
0082-Revert-bgpd-upon-if-event-evaluate-bnc-with-matching.patch
65+
0083-staticd-add-cli-to-support-steering-of-ipv4-traffic-over-srv6-sid-list.patch

0 commit comments

Comments
 (0)
Please sign in to comment.