Skip to content

Commit

Permalink
Merge pull request #12174 from FRRouting/mergify/bp/stable/8.3/pr-12155
Browse files Browse the repository at this point in the history
OSPF: allow for zero length opaque LSAs (backport #12155)
  • Loading branch information
ton31337 committed Oct 23, 2022
2 parents b9cb689 + 8c9c227 commit 5e8977d
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 9 deletions.
6 changes: 6 additions & 0 deletions ospfclient/ospfclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ async def async_main(args):
for action in args.actions:
_s = action.split(",")
what = _s.pop(False)
if what.casefold() == "wait":
stime = int(_s.pop(False))
logging.info("waiting %s seconds", stime)
await asyncio.sleep(stime)
logging.info("wait complete: %s seconds", stime)
continue
ltype = int(_s.pop(False))
if ltype == 11:
addr = ip(0)
Expand Down
2 changes: 1 addition & 1 deletion ospfd/ospf_opaque.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

#define OPAQUE_TYPE_RANGE_RESERVED(type) (127 < (type) && (type) <= 255)

#define OSPF_OPAQUE_LSA_MIN_SIZE 4U
#define OSPF_OPAQUE_LSA_MIN_SIZE 0 /* RFC5250 imposes no minimum */

#define VALID_OPAQUE_INFO_LEN(lsahdr) \
((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \
Expand Down
237 changes: 229 additions & 8 deletions tests/topotests/ospfapi/test_ospf_clientapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,28 +419,249 @@ def _test_opaque_add_del(tgen, apibin):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
p = r1.popen([apibin, "-v", "add,11,232,3,ebadf00d"])
p = r1.popen(
[
apibin,
"-v",
"add,9,10.0.1.1,230,2,00000202",
"add,10,1.2.3.4,231,1,00010101",
"wait,1",
"add,10,1.2.3.4,231,2",
"add,11,232,3,ebadf00d",
"wait,20",
"del,10,1.2.3.4,231,1",
"del,10,1.2.3.4,231,2",
]
)

add_input_dict = {
"areas": {
"1.2.3.4": {
"linkLocalOpaqueLsa": [
{
"lsId": "230.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "8142",
}
],
"areaLocalOpaqueLsa": [
{
"lsId": "231.0.0.1",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "695a",
},
{
"lsId": "231.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "4881",
},
],
}
},
"asExternalOpaqueLsa": [
{
"lsId": "232.0.0.3",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "c666",
}
],
}

step("reachable: check for add LSAs")
json_cmd = "show ip ospf da json"
assert verify_ospf_database(tgen, r1, add_input_dict, json_cmd) is None
assert verify_ospf_database(tgen, r2, add_input_dict, json_cmd) is None

numcs = 3
json_cmds = [
"show ip ospf da opaque-link json",
"show ip ospf da opaque-area json",
"show ip ospf da opaque-as json",
]
add_detail_input_dict = [
{
"linkLocalOpaqueLsa": {
"areas": {
"1.2.3.4": [
{
"linkStateId": "230.0.0.2",
"advertisingRouter": "192.168.0.1",
"lsaSeqNumber": "80000001",
"checksum": "8142",
"length": 24,
"opaqueId": 2,
"opaqueDataLength": 4,
}
]
}
}
},
{
"areaLocalOpaqueLsa": {
"areas": {
"1.2.3.4": [
{
"linkStateId": "231.0.0.1",
"advertisingRouter": "192.168.0.1",
"lsaSeqNumber": "80000001",
"checksum": "695a",
"length": 24,
"opaqueDataLength": 4,
},
{
"linkStateId": "231.0.0.2",
"advertisingRouter": "192.168.0.1",
"lsaSeqNumber": "80000001",
"checksum": "4881",
"length": 20,
"opaqueDataLength": 0,
},
]
}
}
},
{
"asExternalOpaqueLsa": [
{
"linkStateId": "232.0.0.3",
"advertisingRouter": "192.168.0.1",
"lsaSeqNumber": "80000001",
"checksum": "c666",
"length": 24,
"opaqueDataLength": 4,
}
]
},
]
i = 0
while i < numcs:
step("reachable: check for add LSA details: %s" % json_cmds[i])
assert (
verify_ospf_database(tgen, r1, add_detail_input_dict[i], json_cmds[i])
is None
)
assert (
verify_ospf_database(tgen, r2, add_detail_input_dict[i], json_cmds[i])
is None
)
i += 1

# Wait for add notification
# RECV: LSA update msg for LSA 232.0.0.3 in area 0.0.0.0 seq 0x80000001 len 24 age 9

ls_id = "232.0.0.3"
waitfor = "RECV:.*update msg.*LSA {}.*age ([0-9]+)".format(ls_id)
_ = _wait_output(pread, waitfor)
step("reachable: check for API add notifications")
ls_ids = ["230.0.0.2", "231.0.0.1", "231.0.0.2", "232.0.0.3"]
for ls_id in ls_ids:
waitfor = "RECV:.*update msg.*LSA {}.*age ([0-9]+)".format(ls_id)
_ = _wait_output(pread, waitfor)

del_input_dict = {
"areas": {
"1.2.3.4": {
"linkLocalOpaqueLsa": [
{
"lsId": "230.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "8142",
}
],
"areaLocalOpaqueLsa": [
{
"lsaAge": 3600,
"lsId": "231.0.0.1",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "695a",
},
{
"lsaAge": 3600,
"lsId": "231.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "4881",
},
],
}
},
"asExternalOpaqueLsa": [
{
"lsId": "232.0.0.3",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "c666",
}
],
}

step("reachable: check for explicit withdrawal LSAs")
json_cmd = "show ip ospf da json"
assert verify_ospf_database(tgen, r1, del_input_dict, json_cmd) is None
assert verify_ospf_database(tgen, r2, del_input_dict, json_cmd) is None

p.terminate()
if p.wait():
comm_error(p)
del_input_dict = {
"areas": {
"1.2.3.4": {
"linkLocalOpaqueLsa": [
{
"lsaAge": 3600,
"lsId": "230.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "8142",
}
],
"areaLocalOpaqueLsa": [
{
"lsaAge": 3600,
"lsId": "231.0.0.1",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "695a",
},
{
"lsaAge": 3600,
"lsId": "231.0.0.2",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "4881",
},
],
}
},
"asExternalOpaqueLsa": [
{
"lsaAge": 3600,
"lsId": "232.0.0.3",
"advertisedRouter": "192.168.0.1",
"sequenceNumber": "80000001",
"checksum": "c666",
}
],
}

step("reachable: check for implicit withdrawal LSAs")
json_cmd = "show ip ospf da json"
assert verify_ospf_database(tgen, r1, del_input_dict, json_cmd) is None
assert verify_ospf_database(tgen, r2, del_input_dict, json_cmd) is None

# step("reachable: check for flush/age out")
# # Wait for max age notification
# waitfor = "RECV:.*update msg.*LSA {}.*age 3600".format(ls_id)
# _wait_output(pread, waitfor)

step("reachable: check for delete")
# Wait for delete notification
waitfor = "RECV:.*delete msg.*LSA {}.*".format(ls_id)
_wait_output(pread, waitfor)
step("reachable: check for API delete notifications")
ls_ids = ["231.0.0.1", "231.0.0.2", "230.0.0.2", "232.0.0.3"]
for ls_id in ls_ids:
waitfor = "RECV:.*delete msg.*LSA {}.*".format(ls_id)
_ = _wait_output(pread, waitfor)
except Exception:
if p:
p.terminate()
Expand Down

0 comments on commit 5e8977d

Please sign in to comment.