}
}
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"
# 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"
# 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"
}
}
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"
"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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
# 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"
_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",
+ "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",
+ "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))