summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-03-06 21:41:35 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2024-03-06 21:41:35 +0200
commit18da7369490af6bfb88431ad3f2c3a2934865f17 (patch)
tree5debd7c718b9fbaac83c9796ae80e9b2ed2743f8 /lib/if.c
parentdfe570e988b6f4bf295452bcb8397789d3dca359 (diff)
lib: fix order of interfaces in the config
Add missing cli_cmp callback. Without it, interfaces are not sorted and printed in order they were created. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/if.c b/lib/if.c
index a344c2b865..a8ceac7243 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1340,6 +1340,15 @@ static void cli_show_interface_end(struct vty *vty,
vty_out(vty, "exit\n");
}
+static int cli_cmp_interface(const struct lyd_node *dnode1,
+ const struct lyd_node *dnode2)
+{
+ const char *ifname1 = yang_dnode_get_string(dnode1, "name");
+ const char *ifname2 = yang_dnode_get_string(dnode2, "name");
+
+ return if_cmp_name_func(ifname1, ifname2);
+}
+
void if_vty_config_start(struct vty *vty, struct interface *ifp)
{
vty_frame(vty, "!\n");
@@ -1760,6 +1769,7 @@ const struct frr_yang_module_info frr_interface_info = {
.destroy = lib_interface_destroy,
.cli_show = cli_show_interface,
.cli_show_end = cli_show_interface_end,
+ .cli_cmp = cli_cmp_interface,
.get_next = lib_interface_get_next,
.get_keys = lib_interface_get_keys,
.lookup_entry = lib_interface_lookup_entry,
@@ -1842,6 +1852,7 @@ const struct frr_yang_module_info frr_interface_cli_info = {
.cbs = {
.cli_show = cli_show_interface,
.cli_show_end = cli_show_interface_end,
+ .cli_cmp = cli_cmp_interface,
},
},
{