From 7a7bb6bc786db44a5803d214c02541bb1394d15f Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 20 Feb 2024 17:37:25 +0200 Subject: [PATCH] zebra: add interface's bond to oper state Signed-off-by: Igor Ryzhov --- yang/frr-zebra.yang | 6 ++++++ zebra/zebra_nb.c | 6 ++++++ zebra/zebra_nb.h | 1 + zebra/zebra_nb_state.c | 22 ++++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index c338a23af0..6c2a7bde7a 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2733,6 +2733,12 @@ module frr-zebra { description "The VNI multicast group for BUM traffic."; } + + leaf bond { + type frr-interface:interface-ref; + description + "The bond interface this interface belongs to."; + } } } } diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 7e1c43c204..ab07f8d869 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -786,6 +786,12 @@ const struct frr_yang_module_info frr_zebra_info = { .get_elem = lib_interface_zebra_state_mcast_group_get_elem, } }, + { + .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/bond", + .cbs = { + .get_elem = lib_interface_zebra_state_bond_get_elem, + } + }, { .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/router-id", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 97979ef962..69cf2b786a 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -279,6 +279,7 @@ struct yang_data *lib_interface_zebra_state_remote_vtep_get_elem( struct nb_cb_get_elem_args *args); struct yang_data *lib_interface_zebra_state_mcast_group_get_elem( struct nb_cb_get_elem_args *args); +struct yang_data *lib_interface_zebra_state_bond_get_elem(struct nb_cb_get_elem_args *args); int lib_vrf_zebra_router_id_modify(struct nb_cb_modify_args *args); int lib_vrf_zebra_router_id_destroy(struct nb_cb_destroy_args *args); int lib_vrf_zebra_ipv6_router_id_modify(struct nb_cb_modify_args *args); diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 00df9bfc55..8f81abc171 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -145,6 +145,28 @@ lib_interface_zebra_state_mcast_group_get_elem(struct nb_cb_get_elem_args *args) return yang_data_new_ipv4(args->xpath, &vni->mcast_grp); } +/* + * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/bond + */ +struct yang_data * +lib_interface_zebra_state_bond_get_elem(struct nb_cb_get_elem_args *args) +{ + const struct interface *ifp = args->list_entry; + struct zebra_if *zebra_if; + struct interface *bond; + + if (!IS_ZEBRA_IF_BOND_SLAVE(ifp)) + return NULL; + + zebra_if = ifp->info; + bond = zebra_if->bondslave_info.bond_if; + + if (!bond) + return NULL; + + return yang_data_new_string(args->xpath, bond->name); +} + const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args) { struct vrf *vrf = (struct vrf *)args->parent_list_entry; -- 2.39.5