From 34fd50d1b8de43ba94565f7ff61ba9451505535a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 21 Aug 2023 19:07:27 +0200 Subject: [PATCH] confd: add deviation for if:type limiting it to supported types This patch adds a new infix-interface-type, derived from the IANA base type, allowing us to limit the list of supported native interface types. Basing on IANA interface type ensure compatibility with other models, e.g., standard/ieee/published/802.3/ieee802-ethernet-interface.yang, which attaches itself to all interfaces of type ianaift:ethernetCsmacd. Tested with yanglint and in Infix using ieee802-ethernet-interface.yang, the 'ethernet' container was properly attached to interfaces of type infixift:ethernet. Tab completion in the CLI now lists only the supported types. Signed-off-by: Joachim Wiberg --- .../rootfs/lib/infix/factory/gen-interfaces | 4 +- src/confd/src/confd/ietf-interfaces.c | 24 +++---- src/confd/sysrepo-bootstrap.sh | 4 +- src/confd/yang/infix-if-type@2023-06-09.yang | 27 ------- src/confd/yang/infix-if-type@2023-08-21.yang | 71 +++++++++++++++++++ ....yang => infix-interfaces@2023-08-21.yang} | 17 +++++ src/statd/statd.c | 18 ++--- 7 files changed, 113 insertions(+), 52 deletions(-) delete mode 100644 src/confd/yang/infix-if-type@2023-06-09.yang create mode 100644 src/confd/yang/infix-if-type@2023-08-21.yang rename src/confd/yang/{infix-interfaces@2023-06-05.yang => infix-interfaces@2023-08-21.yang} (66%) diff --git a/board/netconf/rootfs/lib/infix/factory/gen-interfaces b/board/netconf/rootfs/lib/infix/factory/gen-interfaces index d2f6e688..24e7ffb6 100755 --- a/board/netconf/rootfs/lib/infix/factory/gen-interfaces +++ b/board/netconf/rootfs/lib/infix/factory/gen-interfaces @@ -7,7 +7,7 @@ gen_interface() cat <."; + reference "internal"; + } + revision 2023-06-05 { description "Initial revision."; reference "internal"; @@ -31,6 +40,14 @@ module infix-interfaces { } } + deviation "/if:interfaces/if:interface/if:type" { + deviate replace { + type identityref { + base infixift:infix-interface-type; + } + } + } + deviation "/if:interfaces-state" { deviate not-supported; } diff --git a/src/statd/statd.c b/src/statd/statd.c index df725eff..4a46cca0 100644 --- a/src/statd/statd.c +++ b/src/statd/statd.c @@ -267,24 +267,24 @@ static const char *get_yang_link_type(char *xpath, json_t *iface) j_val = json_object_get(iface, "linkinfo"); if (!j_val) - return "iana-if-type:ethernetCsmacd"; + return "infix-if-type:ethernet"; j_val = json_object_get(j_val, "info_kind"); if (!j_val) - return "iana-if-type:ethernetCsmacd"; + return "infix-if-type:ethernet"; if (!json_is_string(j_val)) { ERROR("Expected a JSON string for 'info_kind'"); - return "iana-if-type:other"; + return "infix-if-type:other"; } kind = json_string_value(j_val); if (strcmp(kind, "veth") == 0) return "infix-if-type:veth"; if (strcmp(kind, "vlan") == 0) - return "iana-if-type:l2vlan"; + return "infix-if-type:vlan"; if (strcmp(kind, "bridge") == 0) - return "iana-if-type:bridge"; + return "infix-if-type:bridge"; /** * We could return ethernetCsmacd here, but it might hide some @@ -292,15 +292,15 @@ static const char *get_yang_link_type(char *xpath, json_t *iface) */ ERROR("Unable to determine info_kind for \"%s\"", xpath); - return "iana-if-type:other"; + return "infix-if-type:other"; } if (strcmp(type, "loopback") == 0) - return "iana-if-type:softwareLoopback"; + return "infix-if-type:loopback"; - ERROR("Unable to determine iana-if-type for \"%s\"", xpath); + ERROR("Unable to determine infix-if-type for \"%s\"", xpath); - return "iana-if-type:other"; + return "infix-if-type:other"; } static int ly_add_ip_link_data(const struct ly_ctx *ctx, struct lyd_node **parent,