]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add interface's bond to oper state
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 20 Feb 2024 15:37:25 +0000 (17:37 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 20 Feb 2024 15:37:25 +0000 (17:37 +0200)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
yang/frr-zebra.yang
zebra/zebra_nb.c
zebra/zebra_nb.h
zebra/zebra_nb_state.c

index c338a23af08ae760f642ddc6f1bcf4cd19bb2aaa..6c2a7bde7a4f6bd9532fbb0f4adc81dcf4b4756d 100644 (file)
@@ -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.";
+        }
       }
     }
   }
index 7e1c43c204d7c5245bad707a4c2dfc999bd96640..ab07f8d869c98c60717358660783a281360021c4 100644 (file)
@@ -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 = {
index 97979ef9623bede3649fc169f074b3da1bfe2135..69cf2b786a438215924b901b6f17776833b3219a 100644 (file)
@@ -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);
index 00df9bfc55c57b600aa67b6037e81e458ae1ad95..8f81abc171f3aea5b3bc1f4f334f8f8e6f789d5e 100644 (file)
@@ -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;