8000 Start of an OSPF YANG northbound/mgmtd conversion by choppsv1 · Pull Request #18401 · FRRouting/frr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Start of an OSPF YANG northbound/mgmtd conversion #18401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view 8000
3 changes: 3 additions & 0 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ char const *const mgmt_daemons[] = {
#ifdef HAVE_STATICD
"staticd",
#endif
#ifdef HAVE_OSPFD
"ospfd",
#endif
};
uint mgmt_daemons_count = array_size(mgmt_daemons);

Expand Down
14 changes: 14 additions & 0 deletions mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = {
[MGMTD_BE_CLIENT_ID_TESTC] = "mgmtd-testc", /* always first */
[MGMTD_BE_CLIENT_ID_ZEBRA] = "zebra",
#ifdef HAVE_OSPFD
[MGMTD_BE_CLIENT_ID_OSPFD] = "ospfd",
#endif
#ifdef HAVE_RIPD
[MGMTD_BE_CLIENT_ID_RIPD] = "ripd",
#endif
Expand Down Expand Up @@ -91,6 +94,14 @@ static const char *const mgmtd_testc_oper_xpaths[] = {
};
#endif

#if HAVE_OSPFD
static const char *const ospfd_oper_xpaths[] = {
"/frr-interface:lib/interface/state/frr-ospfd-lite:ospf/state/*",
"/frr-ospfd-lite:ospf/instance/state/*",
NULL,
};
#endif

#ifdef HAVE_RIPD
static const char *const ripd_config_xpaths[] = {
"/frr-filter:lib",
Expand Down Expand Up @@ -174,6 +185,9 @@ static const char *const *be_client_oper_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
[MGMTD_BE_CLIENT_ID_STATICD] = staticd_oper_xpaths,
#endif
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
#if HAVE_OSPFD
[MGMTD_BE_CLIENT_ID_OSPFD] = ospfd_oper_xpaths,
#endif
};

static const char *const *be_client_notif_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
Expand Down
3 changes: 3 additions & 0 deletions mgmtd/mgmt_be_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
enum mgmt_be_client_id {
MGMTD_BE_CLIENT_ID_TESTC, /* always first */
MGMTD_BE_CLIENT_ID_ZEBRA,
#ifdef HAVE_OSPFD
MGMTD_BE_CLIENT_ID_OSPFD,
#endif
#ifdef HAVE_RIPD
MGMTD_BE_CLIENT_ID_RIPD,
#endif
Expand Down
6 changes: 5 additions & 1 deletion mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "frr_pthread.h"
#include "mgmtd/mgmt.h"
#include "mgmtd/mgmt_ds.h"
#include "ospfd/ospf_nb.h"
#include "ripd/rip_nb.h"
#include "ripngd/ripng_nb.h"
#include "routing_nb.h"
Expand Down Expand Up @@ -175,6 +176,7 @@ const struct frr_yang_module_info zebra_route_map_info = {
* List of YANG modules to be loaded in the process context of
* MGMTd.
*/
/* clang-format off */
static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
&frr_filter_cli_info,
&frr_interface_cli_info,
Expand Down Expand Up @@ -205,9 +207,11 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
#ifdef HAVE_STATICD
&frr_staticd_cli_info,
#endif
#ifdef HAVE_OSPFD
&frr_ospfd_lite_cli_info
#endif
};

/* clang-format off */
FRR_DAEMON_INFO(mgmtd, MGMTD,
.vty_port = MGMTD_VTY_PORT,
.proghelp = "FRR Management Daemon.",
Expand Down
9 changes: 9 additions & 0 deletions mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ nodist_mgmtd_mgmtd_SOURCES += yang/frr-bfdd.yang.c
endif
endif

if OSPFD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-ospfd-lite.yang.c \
# end
mgmtd_libmgmt_be_nb_la_SOURCES += \
ospfd/ospf_cli.c \
# end
endif

if RIPD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-ripd.yang.c \
Expand Down
62 changes: 62 additions & 0 deletions ospfd/ospf_cli.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* March 15 2025, Christian Hopps <chopps@labn.net>
*
* Copyright (c) 2025, LabN Consulting, L.L.C.
*
*/
#include <zebra.h>
#include "ospf_nb.h"
#include "ospfd/ospf_cli_clippy.c"

/*
* XXX Add YANG based CLI config writing functions here.
*/

#if 0
static void lib_interface_ospf_interface_cli_write(struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
{
/* TODO: this cli callback is optional; the cli output may not need to be done at each node. */
}

static void ospf_instance_cli_write(struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
{
/* TODO: this cli callback is optional; the cli output may not need to be done at each node. */
}

static void ospf_instance_areas_area_cli_write(struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
{
/* TODO: this cli callback is optional; the cli output may not need to be done at each node. */
}
#endif

/* clang-format off */
const struct frr_yang_module_info frr_ospfd_lite_cli_info = {
.name = "frr-ospfd-lite",
.ignore_cfg_cbs = true,
.nodes = {
#if 0
{
.xpath = "/frr-interface:lib/interface/frr-ospfd-lite:ospf-interface",
.cbs = {
.cli_show = lib_interface_ospf_interface_cli_write,
}
},
{
.xpath = "/frr-ospfd-lite:ospf/instance",
.cbs = {
.cli_show = ospf_instance_cli_write,
}
},
{
.xpath = "/frr-ospfd-lite:ospf/instance/areas/area",
.cbs = {
.cli_show = ospf_instance_areas_area_cli_write,
}
},
#endif
{
.xpath = NULL,
},
}
};
/* clang-format on */
4 changes: 4 additions & 0 deletions ospfd/ospf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "stream.h"
#include "log.h"
#include "sockopt.h"
#include "mgmt_be_client.h"

#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
Expand Down Expand Up @@ -2112,4 +2113,7 @@ void ospf_debug_init(void)
install_element(CONFIG_NODE, &no_debug_ospf_instance_event_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_instance_nssa_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_cmd);

/* Init mgmtd backend client debug commands. */
mgmt_be_client_lib_vty_init();
}
18 changes: 11 additions & 7 deletions ospfd/ospf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "routemap.h"
#include "keychain.h"
#include "libagentx.h"
#include "mgmt_be_client.h"

#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
Expand All @@ -46,6 +47,7 @@
#include "ospfd/ospf_ldp_sync.h"
#include "ospfd/ospf_routemap_nb.h"
#include "ospfd/ospf_apiserver.h"
#include "ospfd/ospf_nb.h"

#define OSPFD_STATE_NAME "%s/ospfd.json", frr_libstatedir
#define OSPFD_INST_STATE_NAME(i) "%s/ospfd-%d.json", frr_libstatedir, i
Expand Down Expand Up @@ -92,6 +94,8 @@ const struct option longopts[] = {
/* Master of threads. */
struct event_loop *master;

struct mgmt_be_client *mgmt_be_client;

/* SIGHUP handler. */
static void sighup(void)
{
Expand All @@ -103,6 +107,7 @@ static void sigint(void)
{
zlog_notice("Terminating on signal");
bfd_protocol_integration_set_shutdown(true);
mgmt_be_client_destroy(mgmt_be_client);
ospf_terminate();

exit(0);
Expand Down Expand Up @@ -134,13 +139,10 @@ struct frr_signal_t ospf_signals[] = {
};

static const struct frr_yang_module_info *const ospfd_yang_modules[] = {
&frr_filter_info,
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
&frr_ospf_route_map_info,
&ietf_key_chain_info,
&ietf_key_chain_deviation_info,
&frr_filter_info, &frr_interface_info,
&frr_route_map_info, &frr_vrf_info,
&frr_ospf_route_map_info, &frr_ospfd_lite_info,
&ietf_key_chain_info, &ietf_key_chain_deviation_info,
};

/* actual paths filled in main() */
Expand Down Expand Up @@ -291,6 +293,8 @@ int main(int argc, char **argv)
ospf_vty_show_init();
ospf_vty_clear_init();

mgmt_be_client = mgmt_be_client_create("ospfd", NULL, 0, master);

/* OSPF BFD init */
ospf_bfd_init(master);

Expand Down
Loading
Loading
0