From 4083fbf4c5622c6288b1e31565be37f59829a6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Fri, 20 Sep 2024 16:27:11 +0200 Subject: [PATCH] routing: Add a infix-routing-type to only support selected protocols Today Infix only support OSPFv2 and Static routes, this hides all other protocols in the CLI and makes it clearar about what we support in the YANG model. --- src/confd/src/ietf-routing.c | 4 +-- src/confd/yang/confd.inc | 2 +- ...-13.yang => infix-routing@2024-09-20.yang} | 36 ++++++++++++++----- src/statd/python/yanger/yanger.py | 2 +- test/case/ietf_routing/ospf_basic/test.py | 4 +-- test/case/ietf_routing/ospf_multiarea/test.py | 8 ++--- .../ospf_unnumbered_interface/test.py | 10 ++---- test/case/ietf_routing/static_routing/test.py | 4 +-- test/infamy/route.py | 2 +- 9 files changed, 42 insertions(+), 30 deletions(-) rename src/confd/yang/{infix-routing@2024-09-13.yang => infix-routing@2024-09-20.yang} (97%) diff --git a/src/confd/src/ietf-routing.c b/src/confd/src/ietf-routing.c index f7ca0fa5..de6aacfb 100644 --- a/src/confd/src/ietf-routing.c +++ b/src/confd/src/ietf-routing.c @@ -372,9 +372,9 @@ static int change_control_plane_protocols(sr_session_ctx_t *session, uint32_t su const char *type; type = lydx_get_cattr(cplane, "type"); - if (!strcmp(type, "ietf-routing:static")) { + if (!strcmp(type, "infix-routing:static")) { staticd_enabled = parse_static_routes(session, lydx_get_child(cplane, "static-routes"), fp); - } else if (!strcmp(type, "ietf-ospf:ospfv2")) { + } else if (!strcmp(type, "infix-routing:ospfv2")) { parse_ospf(session, lydx_get_child(cplane, "ospf")); } } diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index 60435761..78b17949 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -27,7 +27,7 @@ MODULES=( "ieee802-dot1q-types@2022-10-29.yang" "infix-ip@2023-09-14.yang" "infix-if-type@2024-01-29.yang" - "infix-routing@2024-09-13.yang" + "infix-routing@2024-09-20.yang" "ieee802-dot1ab-lldp@2022-03-15.yang" "infix-lldp@2023-08-23.yang" "infix-dhcp-client@2024-04-12.yang" diff --git a/src/confd/yang/infix-routing@2024-09-13.yang b/src/confd/yang/infix-routing@2024-09-20.yang similarity index 97% rename from src/confd/yang/infix-routing@2024-09-13.yang rename to src/confd/yang/infix-routing@2024-09-20.yang index 28641219..4e8ccb75 100644 --- a/src/confd/yang/infix-routing@2024-09-13.yang +++ b/src/confd/yang/infix-routing@2024-09-20.yang @@ -24,6 +24,10 @@ module infix-routing { import ietf-routing-types { prefix rt-types; } + revision 2024-09-20 { + description "Deviate to only show supported routing types"; + reference "internal"; + } revision 2024-09-13 { description "Declare deviations for non-supported OSPF RPCs and Notifications"; reference "internal"; @@ -69,10 +73,6 @@ module infix-routing { description "Kernel added route"; base infix-source-protocol; } - identity static { - description "Static added route"; - base infix-source-protocol; - } identity ospf { description "OSPF added route"; base infix-source-protocol; @@ -113,8 +113,26 @@ module infix-routing { } } - deviation "/ietf-r:routing/ietf-r:control-plane-protocols/ietf-r:control-plane-protocol/ietf-r:description" { - deviate not-supported; + identity infix-routing-type { + description "Infix routing type"; + } + identity ospfv2 { + base ospf:ospfv2; + base infix-routing-type; + description "OSPv2 (IPv4) routing protocol"; + } + identity static { + base ietf-r:static; + base infix-routing-type; + base infix-source-protocol; + description "Static route"; + } + deviation "/ietf-r:routing/ietf-r:control-plane-protocols/ietf-r:control-plane-protocol/ietf-r:type" { + deviate replace { + type identityref { + base infix-routing-type; + } + } } /* Static routes */ @@ -174,7 +192,7 @@ module infix-routing { } } } - +/* deviation "/ietf-r:routing/ietf-r:control-plane-protocols/ietf-r:control-plane-protocol/ietf-r:type" { deviate add { must "derived-from-or-self(., 'ospf:ospfv2') or "+ @@ -183,7 +201,7 @@ module infix-routing { } } } - +*/ augment "/ietf-r:routing/ietf-r:control-plane-protocols/ietf-r:control-plane-protocol/ospf:ospf" { description "ietf-ospf lack the setting to generate a default route"; container default-route-advertise { @@ -429,7 +447,7 @@ module infix-routing { deviate not-supported; } - /* OSPF RPCs */ + /* OSPF RPCs */ deviation "/ospf:clear-neighbor" { deviate not-supported; } diff --git a/src/statd/python/yanger/yanger.py b/src/statd/python/yanger/yanger.py index 7888f934..9e8afee8 100755 --- a/src/statd/python/yanger/yanger.py +++ b/src/statd/python/yanger/yanger.py @@ -354,7 +354,7 @@ def add_ospf(control_protocols): return # No OSPF data available control_protocol = {} - control_protocol["type"] = "ietf-ospf:ospfv2" + control_protocol["type"] = "infix-routing:ospfv2" control_protocol["name"] = "default" control_protocol["ietf-ospf:ospf"] = {} control_protocol["ietf-ospf:ospf"]["ietf-ospf:areas"] = {} diff --git a/test/case/ietf_routing/ospf_basic/test.py b/test/case/ietf_routing/ospf_basic/test.py index 0f090ce4..f1f2bf06 100755 --- a/test/case/ietf_routing/ospf_basic/test.py +++ b/test/case/ietf_routing/ospf_basic/test.py @@ -57,7 +57,7 @@ def config_target1(target, data, link): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "redistribute": { @@ -127,7 +127,7 @@ def config_target2(target, link): "control-plane-protocols": { "control-plane-protocol": [ { - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "redistribute": { diff --git a/test/case/ietf_routing/ospf_multiarea/test.py b/test/case/ietf_routing/ospf_multiarea/test.py index b19e02d4..7f16b9db 100755 --- a/test/case/ietf_routing/ospf_multiarea/test.py +++ b/test/case/ietf_routing/ospf_multiarea/test.py @@ -93,7 +93,7 @@ def config_target1(target, ring1, ring2, cross): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "explicit-router-id": "10.0.0.1", @@ -236,7 +236,7 @@ def config_target2(target, ring1, ring2, cross): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "explicit-router-id": "10.0.0.2", @@ -358,7 +358,7 @@ def config_target3(target, ring2, cross, link): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "areas": { @@ -459,7 +459,7 @@ def config_target4(target, ring1, cross, link): "control-plane-protocols": { "control-plane-protocol": [ { - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "redistribute": { diff --git a/test/case/ietf_routing/ospf_unnumbered_interface/test.py b/test/case/ietf_routing/ospf_unnumbered_interface/test.py index 62245095..0d725b95 100755 --- a/test/case/ietf_routing/ospf_unnumbered_interface/test.py +++ b/test/case/ietf_routing/ospf_unnumbered_interface/test.py @@ -60,7 +60,7 @@ def config_target1(target, data, link): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "areas": { @@ -121,18 +121,12 @@ def config_target2(target, link): } }) - target.put_config_dict("ietf-system", { - "system": { - "hostname": "R2" - } - }) - target.put_config_dict("ietf-routing", { "routing": { "control-plane-protocols": { "control-plane-protocol": [ { - "type": "ietf-ospf:ospfv2", + "type": "infix-routing:ospfv2", "name": "default", "ospf": { "areas": { diff --git a/test/case/ietf_routing/static_routing/test.py b/test/case/ietf_routing/static_routing/test.py index 204412ae..8f7d0661 100755 --- a/test/case/ietf_routing/static_routing/test.py +++ b/test/case/ietf_routing/static_routing/test.py @@ -91,7 +91,7 @@ def config_target1(target, data, link): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "static", + "type": "infix-routing:static", "name": "default", "static-routes": { "ipv4": { @@ -163,7 +163,7 @@ def config_target2(target, link): "routing": { "control-plane-protocols": { "control-plane-protocol": [{ - "type": "static", + "type": "infix-routing:static", "name": "default", "static-routes": { "ipv4": { diff --git a/test/infamy/route.py b/test/infamy/route.py index f8e478dc..b9d0f2cd 100644 --- a/test/infamy/route.py +++ b/test/infamy/route.py @@ -47,7 +47,7 @@ def _get_ospf_status(target): xpath="/ietf-routing:routing/control-plane-protocols" rib = target.get_data(xpath)["routing"]["control-plane-protocols"].get("control-plane-protocol", {}) for p in rib: - if p["type"] == "ietf-ospf:ospfv2": + if p["type"] == "infix-routing:ospfv2": return p.get("ospf") or p.get("ietf-ospf:ospf") def _get_ospf_status_area(target, area_id):