-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12261 from cscarpitta/srv6-encap-src-addr
zebra: Add the support of the Source Addr param of the SRv6 Encapsulation
- Loading branch information
Showing
25 changed files
with
979 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
9 changes: 9 additions & 0 deletions
9
tests/topotests/srv6_encap_src_addr/r1/expected_srv6_encap_src_addr.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parameters": { | ||
"encapsulation":{ | ||
"sourceAddress": { | ||
"configured": "fc00:0:1::1" | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/topotests/srv6_encap_src_addr/r1/expected_srv6_encap_src_addr_set.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parameters": { | ||
"encapsulation":{ | ||
"sourceAddress": { | ||
"configured": "fc00:0:1::1" | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/topotests/srv6_encap_src_addr/r1/expected_srv6_encap_src_addr_unset.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parameters": { | ||
"encapsulation":{ | ||
"sourceAddress": { | ||
"configured": "::" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ip link add dummy0 type dummy | ||
ip link set dummy0 up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
hostname r1 | ||
! | ||
! debug zebra events | ||
! debug zebra rib detailed | ||
! | ||
log stdout notifications | ||
log monitor notifications | ||
log commands | ||
log file zebra.log debugging | ||
! | ||
segment-routing | ||
srv6 | ||
encapsulation | ||
source-address fc00:0:1::1 | ||
! | ||
! | ||
! |
142 changes: 142 additions & 0 deletions
142
tests/topotests/srv6_encap_src_addr/test_srv6_encap_src_addr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/usr/bin/env python | ||
# SPDX-License-Identifier: ISC | ||
|
||
# | ||
# test_srv6_encap_src_addr.py | ||
# Part of NetDEF Topology Tests | ||
# | ||
# Copyright (c) 2022 by | ||
# University of Rome Tor Vergata, Carmine Scarpitta <[email protected]> | ||
# | ||
|
||
""" | ||
test_srv6_encap_src_addr.py: | ||
Test for SRv6 encap source address on zebra | ||
""" | ||
|
||
import os | ||
import sys | ||
import json | ||
import pytest | ||
import functools | ||
|
||
CWD = os.path.dirname(os.path.realpath(__file__)) | ||
sys.path.append(os.path.join(CWD, "../")) | ||
|
||
# pylint: disable=C0413 | ||
from lib import topotest | ||
from lib.topogen import Topogen, TopoRouter, get_topogen | ||
from lib.topolog import logger | ||
|
||
pytestmark = [pytest.mark.bgpd, pytest.mark.sharpd] | ||
|
||
|
||
def open_json_file(filename): | ||
try: | ||
with open(filename, "r") as f: | ||
return json.load(f) | ||
except IOError: | ||
assert False, "Could not read file {}".format(filename) | ||
|
||
|
||
def setup_module(mod): | ||
tgen = Topogen({None: "r1"}, mod.__name__) | ||
tgen.start_topology() | ||
for rname, router in tgen.routers().items(): | ||
router.run("/bin/bash {}/{}/setup.sh".format(CWD, rname)) | ||
router.load_config( | ||
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) | ||
) | ||
router.load_config( | ||
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) | ||
) | ||
router.load_config( | ||
TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname)) | ||
) | ||
tgen.start_router() | ||
|
||
|
||
def teardown_module(mod): | ||
tgen = get_topogen() | ||
tgen.stop_topology() | ||
|
||
|
||
def test_zebra_srv6_encap_src_addr(tgen): | ||
"Test SRv6 encapsulation source address." | ||
logger.info( | ||
"Test SRv6 encapsulation source address." | ||
) | ||
r1 = tgen.gears["r1"] | ||
|
||
# Generate expected results | ||
json_file = "{}/r1/expected_srv6_encap_src_addr.json".format(CWD) | ||
expected = json.loads(open(json_file).read()) | ||
|
||
ok = topotest.router_json_cmp_retry(r1, "show segment-routing srv6 manager json", expected) | ||
assert ok, '"r1" JSON output mismatches' | ||
|
||
output = r1.cmd("ip sr tunsrc show") | ||
assert output == "tunsrc addr fc00:0:1::1\n" | ||
|
||
|
||
def test_zebra_srv6_encap_src_addr_unset(tgen): | ||
"Test SRv6 encapsulation source address unset." | ||
logger.info( | ||
"Test SRv6 encapsulation source address unset." | ||
) | ||
r1 = tgen.gears["r1"] | ||
|
||
# Unset SRv6 encapsulation source address | ||
r1.vtysh_cmd( | ||
""" | ||
configure terminal | ||
segment-routing | ||
srv6 | ||
encapsulation | ||
no source-address | ||
""" | ||
) | ||
|
||
# Generate expected results | ||
json_file = "{}/r1/expected_srv6_encap_src_addr_unset.json".format(CWD) | ||
expected = json.loads(open(json_file).read()) | ||
|
||
ok = topotest.router_json_cmp_retry(r1, "show segment-routing srv6 manager json", expected) | ||
assert ok, '"r1" JSON output mismatches' | ||
|
||
output = r1.cmd("ip sr tunsrc show") | ||
assert output == "tunsrc addr ::\n" | ||
|
||
|
||
def test_zebra_srv6_encap_src_addr_set(tgen): | ||
"Test SRv6 encapsulation source address set." | ||
logger.info( | ||
"Test SRv6 encapsulation source address set." | ||
) | ||
r1 = tgen.gears["r1"] | ||
|
||
# Set SRv6 encapsulation source address | ||
r1.vtysh_cmd( | ||
""" | ||
configure terminal | ||
segment-routing | ||
srv6 | ||
encapsulation | ||
source-address fc00:0:1::1 | ||
""" | ||
) | ||
|
||
# Generate expected results | ||
json_file = "{}/r1/expected_srv6_encap_src_addr_set.json".format(CWD) | ||
expected = json.loads(open(json_file).read()) | ||
|
||
ok = topotest.router_json_cmp_retry(r1, "show segment-routing srv6 manager json", expected) | ||
assert ok, '"r1" JSON output mismatches' | ||
|
||
output = r1.cmd("ip sr tunsrc show") | ||
assert output == "tunsrc addr fc00:0:1::1\n" | ||
|
||
|
||
if __name__ == "__main__": | ||
args = ["-s"] + sys.argv[1:] | ||
sys.exit(pytest.main(args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.