diff --git a/test/infamy/route.py b/test/infamy/route.py index cb3f9a35..0e713f0f 100644 --- a/test/infamy/route.py +++ b/test/infamy/route.py @@ -1,4 +1,4 @@ -def _get_routes(target,protocol): +def _get_routes(target, protocol): xpath=f"/ietf-routing:routing" rib = target.get_data(xpath)["routing"]["ribs"]["rib"] for r in rib: @@ -7,16 +7,19 @@ def _get_routes(target,protocol): return r.get("routes", {}).get("route",{}) return {} -def _exist_route(target,destination_prefix, protocol): - routes=_get_routes(target,protocol) +def _exist_route(target, prefix, nexthop, protocol): + routes = _get_routes(target, protocol) for r in routes: - if(r["destination-prefix"] == destination_prefix): - return True - + if r["destination-prefix"] != prefix: + continue + nh = r["next-hop"] + if nexthop and nh["next-hop-address"] != nexthop: + continue + return True return False -def ipv4_route_exist(target, destination_prefix): - return _exist_route(target,destination_prefix, "ipv4") +def ipv4_route_exist(target, prefix, nexthop=None): + return _exist_route(target, prefix, nexthop, "ipv4") -def ipv6_route_exist(target, destination_prefix): - return _exist_route(target,destination_prefix, "ipv6") +def ipv6_route_exist(target, prefix, nexthop=None): + return _exist_route(target, prefix, nexthop, "ipv6")