From 453154497e0944e8bfbc7cdcc62931bcfa0d8b0c Mon Sep 17 00:00:00 2001 From: Donna Sharp Date: Mon, 24 Feb 2025 16:04:56 -0500 Subject: [PATCH 1/2] zebra: allow retrieval of ip forwarding state There was no ability to retrieve the ip-forwarding state of zebra. Add this to yang under the state container. Signed-off-by: Donna Sharp --- yang/frr-zebra.yang | 5 +++++ zebra/zebra_nb.c | 6 ++++++ zebra/zebra_nb.h | 1 + zebra/zebra_nb_state.c | 10 ++++++++++ 4 files changed, 22 insertions(+) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 5f1b711b97..3e005c2d35 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2968,6 +2968,11 @@ module frr-zebra { config false; description "Operational data."; + leaf ip-forwarding { + type boolean; + description + "IP forwarding status."; + } } // End of operational / state container } diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 81fe2ab6a0..83d89fa7b7 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -38,6 +38,12 @@ const struct frr_yang_module_info frr_zebra_info = { .destroy = zebra_ip_forwarding_destroy, } }, + { + .xpath = "/frr-zebra:zebra/state/ip-forwarding", + .cbs = { + .get_elem = zebra_ip_forwarding_get_elem, + } + }, { .xpath = "/frr-zebra:zebra/ipv6-forwarding", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 426ad4b7de..f742d24747 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -32,6 +32,7 @@ int get_debugs_rpc(struct nb_cb_rpc_args *args); int zebra_mcast_rpf_lookup_modify(struct nb_cb_modify_args *args); int zebra_ip_forwarding_modify(struct nb_cb_modify_args *args); int zebra_ip_forwarding_destroy(struct nb_cb_destroy_args *args); +struct yang_data *zebra_ip_forwarding_get_elem(struct nb_cb_get_elem_args *args); int zebra_ipv6_forwarding_modify(struct nb_cb_modify_args *args); int zebra_ipv6_forwarding_destroy(struct nb_cb_destroy_args *args); int zebra_workqueue_hold_timer_modify(struct nb_cb_modify_args *args); diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index a7091821b5..9b9991c182 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -14,6 +14,7 @@ #include "printfrr.h" #include "zebra/zebra_vxlan.h" #include "zebra/zebra_vxlan_if.h" +#include "zebra/ipforward.h" /* * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/up-count @@ -1166,3 +1167,12 @@ struct yang_data *zebra_max_multipath_get_elem(struct nb_cb_get_elem_args *args) { return yang_data_new_uint16(args->xpath, zrouter.multipath_num); } + +/* + * XPath: + * /frr-zebra:zebra/ip_forwarding + */ +struct yang_data *zebra_ip_forwarding_get_elem(struct nb_cb_get_elem_args *args) +{ + return yang_data_new_bool(args->xpath, ipforward()); +} From 9a073f663f800e46ca654b8841892f49f3989bbd Mon Sep 17 00:00:00 2001 From: Donna Sharp Date: Mon, 24 Feb 2025 16:30:07 -0500 Subject: [PATCH 2/2] zebra: allow retrieval of ipv6 forwarding state Allow the retrieval of ipv6 forwarding state from within the yang framework as that it was missing. Signed-off-by: Donna Sharp --- yang/frr-zebra.yang | 25 +++++++------------------ zebra/zebra_nb.c | 6 ++++++ zebra/zebra_nb.h | 1 + zebra/zebra_nb_state.c | 10 ++++++++++ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 3e005c2d35..c9fa612b75 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2859,24 +2859,8 @@ module frr-zebra { "IP forwarding status."; } leaf ipv6-forwarding { - type enumeration { - enum unknown { - value -1; - description - "Unknown state."; - } - enum off { - value 0; - description - "IPv6 forwarding disabled."; - } - enum on { - value 1; - description - "IPv6 forwarding enabled."; - } - } - description + type boolean; + description "IPv6 forwarding status."; } leaf workqueue-hold-timer { @@ -2973,6 +2957,11 @@ module frr-zebra { description "IP forwarding status."; } + leaf ipv6-forwarding { + type boolean; + description + "IPv6 forwarding status."; + } } // End of operational / state container } diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 83d89fa7b7..f45ce03956 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -51,6 +51,12 @@ const struct frr_yang_module_info frr_zebra_info = { .destroy = zebra_ipv6_forwarding_destroy, } }, + { + .xpath = "/frr-zebra:zebra/state/ipv6-forwarding", + .cbs = { + .get_elem = zebra_ipv6_forwarding_get_elem, + } + }, { .xpath = "/frr-zebra:zebra/workqueue-hold-timer", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index f742d24747..7b0205058e 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -36,6 +36,7 @@ struct yang_data *zebra_ip_forwarding_get_elem(struct nb_cb_get_elem_args *args) int zebra_ipv6_forwarding_modify(struct nb_cb_modify_args *args); int zebra_ipv6_forwarding_destroy(struct nb_cb_destroy_args *args); int zebra_workqueue_hold_timer_modify(struct nb_cb_modify_args *args); +struct yang_data *zebra_ipv6_forwarding_get_elem(struct nb_cb_get_elem_args *args); int zebra_zapi_packets_modify(struct nb_cb_modify_args *args); int zebra_import_kernel_table_table_id_modify(struct nb_cb_modify_args *args); int zebra_import_kernel_table_table_id_destroy(struct nb_cb_destroy_args *args); diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 9b9991c182..adf830042b 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -1176,3 +1176,13 @@ struct yang_data *zebra_ip_forwarding_get_elem(struct nb_cb_get_elem_args *args) { return yang_data_new_bool(args->xpath, ipforward()); } + + +/* + * XPath: + * /frr-zebra:zebra/ipv6_forwarding + */ +struct yang_data *zebra_ipv6_forwarding_get_elem(struct nb_cb_get_elem_args *args) +{ + return yang_data_new_bool(args->xpath, ipforward_ipv6()); +}