diff options
| author | Russ White <russ@riw.us> | 2024-03-05 11:41:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 11:41:35 -0500 |
| commit | ac34badf7109e9da1c31a32a3388197aa3a2e40d (patch) | |
| tree | 93478d2ac544cfe77cc9a0769b0df53da16b16b9 | |
| parent | cf4d838e69b19fd5066da85e0c44b7c569af4e66 (diff) | |
| parent | af8c6b5b566cfa7feb7c7225e3e7ef638c83e5c9 (diff) | |
Merge pull request #15397 from idryzhov/zebra-oper
zebra: oper data additions
| -rw-r--r-- | tests/topotests/mgmt_oper/simple-results/result-intf-eth0-exact.json | 3 | ||||
| -rw-r--r-- | tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json | 3 | ||||
| -rw-r--r-- | yang/frr-zebra.yang | 12 | ||||
| -rw-r--r-- | zebra/zebra_nb.c | 6 | ||||
| -rw-r--r-- | zebra/zebra_nb.h | 1 | ||||
| -rw-r--r-- | zebra/zebra_nb_state.c | 64 |
6 files changed, 79 insertions, 10 deletions
diff --git a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-exact.json b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-exact.json index f04e3a55e1..04591b6e29 100644 --- a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-exact.json +++ b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-exact.json @@ -14,7 +14,8 @@ "frr-zebra:zebra": { "state": { "up-count": 0, - "down-count": 0 + "down-count": 0, + "zif-type": "zif-veth" } } } diff --git a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json index 84ad82c058..c770db49b1 100644 --- a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json +++ b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json @@ -25,7 +25,8 @@ }, "state": { "up-count": 0, - "down-count": 0 + "down-count": 0, + "zif-type": "zif-veth" } } } diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index c338a23af0..f1a69068c3 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -145,12 +145,6 @@ module frr-zebra { "Zebra interface type bond."; } - identity zif-bond-slave { - base zebra-interface-type; - description - "Zebra interface type bond slave."; - } - identity zif-macvlan { base zebra-interface-type; description @@ -2733,6 +2727,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 e1ca5ec19b..eee9323082 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -803,6 +803,12 @@ const struct frr_yang_module_info frr_zebra_info = { } }, { + .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 = { .modify = lib_vrf_zebra_router_id_modify, diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index d7cf5f4040..b40ed68229 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -285,6 +285,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..464c0be707 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -49,8 +49,46 @@ lib_interface_zebra_state_down_count_get_elem(struct nb_cb_get_elem_args *args) struct yang_data * lib_interface_zebra_state_zif_type_get_elem(struct nb_cb_get_elem_args *args) { - /* TODO: implement me. */ - return NULL; + const struct interface *ifp = args->list_entry; + struct zebra_if *zebra_if; + const char *type = NULL; + + zebra_if = ifp->info; + + switch (zebra_if->zif_type) { + case ZEBRA_IF_OTHER: + type = "frr-zebra:zif-other"; + break; + case ZEBRA_IF_VXLAN: + type = "frr-zebra:zif-vxlan"; + break; + case ZEBRA_IF_VRF: + type = "frr-zebra:zif-vrf"; + break; + case ZEBRA_IF_BRIDGE: + type = "frr-zebra:zif-bridge"; + break; + case ZEBRA_IF_VLAN: + type = "frr-zebra:zif-vlan"; + break; + case ZEBRA_IF_MACVLAN: + type = "frr-zebra:zif-macvlan"; + break; + case ZEBRA_IF_VETH: + type = "frr-zebra:zif-veth"; + break; + case ZEBRA_IF_BOND: + type = "frr-zebra:zif-bond"; + break; + case ZEBRA_IF_GRE: + type = "frr-zebra:zif-gre"; + break; + } + + if (!type) + return NULL; + + return yang_data_new_string(args->xpath, type); } /* @@ -145,6 +183,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; |
