summaryrefslogtreecommitdiffstats
path: root/tests/topotests/ospfapi
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:31 +0000
commitacb594b1d825c6e12369cebb941968ec08c840ce (patch)
treed544788908e7353a4f117e2991f15f4236a0c963 /tests/topotests/ospfapi
parentAdding upstream version 9.1. (diff)
downloadfrr-acb594b1d825c6e12369cebb941968ec08c840ce.tar.xz
frr-acb594b1d825c6e12369cebb941968ec08c840ce.zip
Adding upstream version 10.0.upstream/10.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/ospfapi')
-rw-r--r--tests/topotests/ospfapi/test_ospf_clientapi.py251
1 files changed, 199 insertions, 52 deletions
diff --git a/tests/topotests/ospfapi/test_ospf_clientapi.py b/tests/topotests/ospfapi/test_ospf_clientapi.py
index 7a7ea85..49dd34d 100644
--- a/tests/topotests/ospfapi/test_ospf_clientapi.py
+++ b/tests/topotests/ospfapi/test_ospf_clientapi.py
@@ -277,7 +277,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "230.0.0.2",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "00000202",
+ "opaqueValues": {
+ "opaqueData": "00000202"
+ }
},
],
}
@@ -327,7 +329,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "231.0.0.1",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "00010101",
+ "opaqueValues": {
+ "opaqueData": "00010101",
+ }
},
],
}
@@ -376,7 +380,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "232.0.0.3",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "deadbeaf01234567",
+ "opaqueValues": {
+ "opaqueData": "deadbeaf01234567",
+ }
},
]
}
@@ -427,7 +433,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "232.0.0.3",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000002",
- "opaqueData": "ebadf00d",
+ "opaqueValues": {
+ "opaqueData": "ebadf00d",
+ }
},
]
}
@@ -574,7 +582,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -583,7 +591,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -599,7 +607,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "231.0.0.2",
@@ -607,7 +615,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "7690",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -621,7 +629,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -629,7 +637,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -734,7 +742,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -744,7 +752,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -760,7 +768,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"lsaAge": 3600,
@@ -770,7 +778,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "4fe2",
# data removed
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
],
},
@@ -785,7 +793,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -793,7 +801,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -827,7 +835,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -837,7 +845,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -854,7 +862,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"lsaAge": 3600,
@@ -864,7 +872,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "4fe2",
# data removed
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
],
},
@@ -879,7 +887,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -888,7 +896,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -1044,7 +1052,7 @@ def _test_opaque_add_restart_add(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "b07a",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -1100,7 +1108,7 @@ def _test_opaque_add_restart_add(tgen, apibin):
"lsaSeqNumber": "80000003",
"checksum": "cb27",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -1205,7 +1213,10 @@ def _test_opaque_interface_disable(tgen, apibin):
}
}
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf interface json", r1_interface_without_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf interface json",
+ r1_interface_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF interface doesn't have opaque capability disabled"
@@ -1232,7 +1243,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 4 in test_ospf_opaque_interface_disable and STEP 59 in CI tests
step("Verify that the r1 neighbor options don't include opaque")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf neighbor detail json", r1_neighbor_without_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf neighbor detail json",
+ r1_neighbor_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF neighbor has opaque option in optionsList"
@@ -1241,7 +1255,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 5 in test_ospf_opaque_interface_disable and STEP 60 in CI tests
step("Verify that the r1 neighbor options don't include opaque")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf neighbor detail json", r2_neighbor_without_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf neighbor detail json",
+ r2_neighbor_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF neighbor has opaque option in optionsList"
@@ -1282,7 +1299,10 @@ def _test_opaque_interface_disable(tgen, apibin):
}
}
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf interface json", r2_interface_with_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf interface json",
+ r2_interface_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF interface has opaque capability disabled"
@@ -1338,19 +1358,17 @@ def _test_opaque_interface_disable(tgen, apibin):
"asExternalOpaqueLsaCount": 1,
}
opaque_area_empty_database = {
- "routerId":"2.0.0.0",
- "areaLocalOpaqueLsa":{
- "areas":{
- "1.2.3.4":[
- ]
- }
- }
+ "routerId": "2.0.0.0",
+ "areaLocalOpaqueLsa": {"areas": {"1.2.3.4": []}},
}
# STEP 9 in test_ospf_opaque_interface_disable and STEP 64 in CI tests
step("Check that LSAs are added on r1")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf database json", opaque_LSAs_in_database
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf database json",
+ opaque_LSAs_in_database,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF database doesn't contain opaque LSAs"
@@ -1359,8 +1377,11 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 10 in test_ospf_opaque_interface_disable and STEP 65 in CI tests
step("Check that LSAs are not added on r2")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf database opaque-area json",
- opaque_area_empty_database, True
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf database opaque-area json",
+ opaque_area_empty_database,
+ True,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF area database contains opaque LSAs"
@@ -1382,7 +1403,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 13 in test_ospf_opaque_interface_disable and STEP 68 in CI tests
step("Verify the ospf opaque option is applied to the r1 interface")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf interface json", r1_interface_with_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf interface json",
+ r1_interface_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF interface doesn't have opaque capability disabled"
@@ -1409,7 +1433,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 14 in test_ospf_opaque_interface_disable and STEP 69 in CI tests
step("Verify that the r1 neighbor options include opaque")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf neighbor detail json", r1_neighbor_with_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf neighbor detail json",
+ r1_neighbor_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF neighbor doesn't have opaque option in optionsList"
@@ -1418,7 +1445,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 15 in test_ospf_opaque_interface_disable and STEP 70 in CI tests
step("Verify that the r2 neighbor options include opaque")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf neighbor detail json", r2_neighbor_with_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf neighbor detail json",
+ r2_neighbor_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF neighbor doesn't have opaque option in optionsList"
@@ -1427,7 +1457,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 16 in test_ospf_opaque_interface_disable and STEP 71 in CI tests
step("Check that LSAs are now added to r2")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf database json", opaque_LSAs_in_database
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf database json",
+ opaque_LSAs_in_database,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF database doesn't contains opaque LSAs"
@@ -1463,7 +1496,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 20 in test_ospf_opaque_interface_disable and STEP 75 in CI tests
step("Verify the ospf opaque option is not applied to the r2 interface")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf interface json", r2_interface_without_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf interface json",
+ r2_interface_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF interface doesn't have opaque capability disabled"
@@ -1472,7 +1508,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 21 in test_ospf_opaque_interface_disable and STEP 76 in CI tests
step("Verify that the r1 neighbor options don't include opaque")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf neighbor detail json", r1_neighbor_without_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf neighbor detail json",
+ r1_neighbor_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF neighbor has opaque option in optionsList"
@@ -1481,7 +1520,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 22 in test_ospf_opaque_interface_disable and STEP 77 in CI tests
step("Verify that the r2 neighbor options don't include opaque")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf neighbor detail json", r2_neighbor_without_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf neighbor detail json",
+ r2_neighbor_without_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF neighbor has opaque option in optionsList"
@@ -1490,7 +1532,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 23 in test_ospf_opaque_interface_disable and STEP 78 in CI tests
step("Verify that r1 still has the opaque LSAs")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf database json", opaque_LSAs_in_database
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf database json",
+ opaque_LSAs_in_database,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF database doesn't contain opaque LSAs"
@@ -1499,8 +1544,11 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 24 in test_ospf_opaque_interface_disable and STEP 79 in CI tests
step("Verify that r2 doesn't have the opaque LSAs")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf database opaque-area json",
- opaque_area_empty_database, True
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf database opaque-area json",
+ opaque_area_empty_database,
+ True,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF area database contains opaque LSAs"
@@ -1524,7 +1572,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 27 in test_ospf_opaque_interface_disable and STEP 82 in CI tests
step("Verify the ospf opaque option is applied to the r2 interface")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf interface json", r2_interface_with_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf interface json",
+ r2_interface_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF interface doesn't have opaque capability disabled"
@@ -1533,7 +1584,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 28 in test_ospf_opaque_interface_disable and STEP 83 in CI tests
step("Verify that the r2 neighbor options include opaque")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf neighbor detail json", r2_neighbor_with_opaque
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf neighbor detail json",
+ r2_neighbor_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF neighbor doesn't have opaque option in optionsList"
@@ -1542,7 +1596,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 29 in test_ospf_opaque_interface_disable and STEP 84 in CI tests
step("Verify that the r1 neighbor options include opaque")
test_func = partial(
- topotest.router_json_cmp, r1, "show ip ospf neighbor detail json", r1_neighbor_with_opaque
+ topotest.router_json_cmp,
+ r1,
+ "show ip ospf neighbor detail json",
+ r1_neighbor_with_opaque,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r1 OSPF neighbor doesn't have opaque option in optionsList"
@@ -1551,7 +1608,10 @@ def _test_opaque_interface_disable(tgen, apibin):
# STEP 30 in test_ospf_opaque_interface_disable and STEP 85 in CLI tests
step("Verify that r2 now has the opaque LSAs")
test_func = partial(
- topotest.router_json_cmp, r2, "show ip ospf database json", opaque_LSAs_in_database
+ topotest.router_json_cmp,
+ r2,
+ "show ip ospf database json",
+ opaque_LSAs_in_database,
)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
assertmsg = "r2 OSPF database doesn't contain opaque LSAs"
@@ -1581,6 +1641,93 @@ def test_ospf_opaque_interface_disable(tgen):
_test_opaque_interface_disable(tgen, apibin)
+def _test_opaque_link_local_lsa_crash(tgen, apibin):
+ "Test disabling opaque capability on an interface"
+
+ r1 = tgen.gears["r1"]
+ r2 = tgen.gears["r2"]
+ tc_name = "opaque_interface_disable"
+
+ p = None
+ # Log to our stdin, stderr
+ pout = open(os.path.join(r1.net.logdir, "r1/intf-disable.log"), "a+")
+ try:
+ step("Add a link-local opaque LSA for r1-eth0")
+ pread = r1.popen([apibin, "-v", "add,9,10.0.1.1,230,1,feedaceedeadbeef"])
+
+ input_dict = {
+ "linkLocalOpaqueLsa": {
+ "areas": {
+ "1.2.3.4": [
+ {
+ "linkStateId": "230.0.0.1",
+ "advertisingRouter": "1.0.0.0",
+ "lsaSeqNumber": "80000001",
+ "opaqueValues": {
+ "opaqueData": "feedaceedeadbeef",
+ }
+ },
+ ],
+ }
+ },
+ }
+
+ # verify content
+ json_cmd = "show ip ospf da opaque-link json"
+ assert verify_ospf_database(tgen, r1, input_dict, json_cmd) is None
+
+ step("Shut down r1-eth0 and verify there is no crash")
+ r1.vtysh_multicmd("conf t\ninterface r1-eth0\nshut")
+ time.sleep(2)
+
+ step("Bring r1-eth0 back up and verify there is no crash")
+ r1.vtysh_multicmd("conf t\ninterface r1-eth0\nno shut")
+
+ step("Add another link-local opaque LSA for r1-eth0")
+ pread = r1.popen([apibin, "-v", "add,9,10.0.1.1,230,1,feedaceecafebeef"])
+
+ input_dict = {
+ "linkLocalOpaqueLsa": {
+ "areas": {
+ "1.2.3.4": [
+ {
+ "linkStateId": "230.0.0.1",
+ "advertisingRouter": "1.0.0.0",
+ "lsaSeqNumber": "80000001",
+ "opaqueValues": {
+ "opaqueData": "feedaceecafebeef",
+ }
+ },
+ ],
+ }
+ },
+ }
+ # verify content
+ json_cmd = "show ip ospf da opaque-link json"
+ assert verify_ospf_database(tgen, r1, input_dict, json_cmd) is None
+
+ except Exception:
+ if p:
+ p.terminate()
+ if p.wait():
+ comm_error(p)
+ p = None
+ raise
+ finally:
+ if p:
+ p.terminate()
+ p.wait()
+ p = None
+
+
+@pytest.mark.parametrize("tgen", [2], indirect=True)
+def test_ospf_opaque_link_local_lsa_crash(tgen):
+ apibin = os.path.join(CLIENTDIR, "ospfclient.py")
+ rc, o, e = tgen.gears["r2"].net.cmd_status([apibin, "--help"])
+ logging.debug("%s --help: rc: %s stdout: '%s' stderr: '%s'", apibin, rc, o, e)
+ _test_opaque_link_local_lsa_crash(tgen, apibin)
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))