Skip to content

Commit

Permalink
lib: convert affinity-map to mgmtd
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
  • Loading branch information
idryzhov committed Jan 28, 2024
1 parent fe76036 commit dc6ff4c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 38 deletions.
4 changes: 1 addition & 3 deletions lib/affinitymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct affinity_maps {
DECLARE_QOBJ_TYPE(affinity_maps);

extern const struct frr_yang_module_info frr_affinity_map_info;
extern const struct frr_yang_module_info frr_affinity_map_cli_info;

void affinity_map_set(const char *name, int pos);
void affinity_map_unset(const char *name);
Expand All @@ -69,9 +70,6 @@ void affinity_map_set_update_hook(void (*func)(const char *affmap_name,
uint16_t old_pos,
uint16_t new_pos));

void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults);

void affinity_map_init(void);


Expand Down
40 changes: 15 additions & 25 deletions lib/affinitymap_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@
#include "lib/affinitymap.h"
#include "lib/affinitymap_cli_clippy.c"

/* Route map node structure. */
static int affinity_map_config_write(struct vty *vty);
static struct cmd_node affinitymap_node = {
.name = "affinity-map",
.node = AFFMAP_NODE,
.prompt = "",
.config_write = affinity_map_config_write,
};

/* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */
DEFPY_YANG_NOSH(affinity_map, affinity_map_cmd,
"affinity-map NAME$name bit-position (0-1023)$position",
Expand Down Expand Up @@ -75,33 +66,32 @@ DEFPY_YANG_NOSH(no_affinity_map, no_affinity_map_cmd,
return nb_cli_apply_changes(vty, NULL);
}

static int affinity_map_config_write(struct vty *vty)
{
const struct lyd_node *dnode;
int written = 0;

dnode = yang_dnode_get(running_config->dnode, "/frr-affinity-map:lib");
if (dnode) {
nb_cli_show_dnode_cmds(vty, dnode, false);
written = 1;
}

return written;
}

void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
static void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults __attribute__((__unused__)))
{
vty_out(vty, "affinity-map %s bit-position %u\n",
yang_dnode_get_string(dnode, "name"),
yang_dnode_get_uint16(dnode, "value"));
}

const struct frr_yang_module_info frr_affinity_map_cli_info = {
.name = "frr-affinity-map",
.ignore_cfg_cbs = true,
.nodes = {
{
.xpath = "/frr-affinity-map:lib/affinity-maps/affinity-map",
.cbs.cli_show = cli_show_affinity_map,
},
{
.xpath = NULL,
},
}
};

/* Initialization of affinity map vector. */
void affinity_map_init(void)
{
/* CLI commands. */
install_node(&affinitymap_node);
install_element(CONFIG_NODE, &affinity_map_cmd);
install_element(CONFIG_NODE, &no_affinity_map_cmd);
}
1 change: 0 additions & 1 deletion lib/affinitymap_northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const struct frr_yang_module_info frr_affinity_map_info = {
.cbs = {
.create = lib_affinity_map_create,
.destroy = lib_affinity_map_destroy,
.cli_show = cli_show_affinity_map,
}
},
{
Expand Down
10 changes: 2 additions & 8 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "ripd/rip_nb.h"
#include "ripngd/ripng_nb.h"
#include "routing_nb.h"

#include "affinitymap.h"

/* mgmt options, we use GNU getopt library. */
static const struct option longopts[] = {
Expand Down Expand Up @@ -169,12 +169,6 @@ const struct frr_yang_module_info zebra_info = {
.nodes = { { .xpath = NULL } },
};

const struct frr_yang_module_info affinity_map_info = {
.name = "frr-affinity-map",
.ignore_cfg_cbs = true,
.nodes = { { .xpath = NULL } },
};

const struct frr_yang_module_info zebra_route_map_info = {
.name = "frr-zebra-route-map",
.ignore_cfg_cbs = true,
Expand All @@ -191,13 +185,13 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
&frr_route_map_cli_info,
&frr_routing_info,
&frr_vrf_info,
&frr_affinity_map_cli_info,

/*
* YANG module info used by backend clients get added here.
*/

&zebra_info,
&affinity_map_info,
&zebra_route_map_info,

#ifdef HAVE_RIPD
Expand Down
2 changes: 2 additions & 0 deletions mgmtd/mgmt_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <zebra.h>

#include "affinitymap.h"
#include "command.h"
#include "filter.h"
#include "json.h"
Expand Down Expand Up @@ -570,6 +571,7 @@ void mgmt_vty_init(void)
*/
filter_cli_init();
route_map_cli_init();
affinity_map_init();

/*
* Initialize command handling from VTYSH connection.
Expand Down
1 change: 1 addition & 0 deletions mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ lib_LTLIBRARIES += mgmtd/libmgmt_be_nb.la
mgmtd_libmgmt_be_nb_la_SOURCES = \
# end
nodist_mgmtd_libmgmt_be_nb_la_SOURCES = \
lib/affinitymap_cli.c \
# end
mgmtd_libmgmt_be_nb_la_CFLAGS = $(AM_CFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY
mgmtd_libmgmt_be_nb_la_CPPFLAGS = $(AM_CPPFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY
Expand Down
2 changes: 1 addition & 1 deletion vtysh/vtysh.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern struct event_loop *master;
VTYSH_OSPFD | VTYSH_PBRD | VTYSH_PIMD | VTYSH_PIM6D | \
VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_VRRPD | VTYSH_ZEBRA

#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD
#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD | VTYSH_MGMTD
#define VTYSH_RMAP_CONFIG \
VTYSH_ZEBRA | VTYSH_OSPFD | VTYSH_OSPF6D | VTYSH_BGPD | VTYSH_ISISD | \
VTYSH_PIMD | VTYSH_EIGRPD | VTYSH_FABRICD | VTYSH_MGMTD
Expand Down

0 comments on commit dc6ff4c

Please sign in to comment.