Skip to content

Commit

Permalink
Merge pull request FRRouting#9820 from idryzhov/if-nb-config
Browse files Browse the repository at this point in the history
*: fix interface config write in NB-converted daemons
  • Loading branch information
Mark Stapp authored Oct 26, 2021
2 parents a2b52cb + 104fd76 commit 6972571
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 135 deletions.
26 changes: 1 addition & 25 deletions eigrpd/eigrp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,30 +869,6 @@ static int eigrp_config_write(struct vty *vty)
return written;
}

static int eigrp_write_interface(struct vty *vty)
{
const struct lyd_node *dnode;
struct interface *ifp;
struct vrf *vrf;
int written = 0;

RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
FOR_ALL_INTERFACES(vrf, ifp) {
dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
if (dnode == NULL)
continue;

written = 1;
nb_cli_show_dnode_cmds(vty, dnode, false);
}
}

return written;
}

void
eigrp_cli_init(void)
{
Expand All @@ -919,7 +895,7 @@ eigrp_cli_init(void)

vrf_cmd_init(NULL);

if_cmd_init(eigrp_write_interface);
if_cmd_init_default();

install_element(INTERFACE_NODE, &eigrp_if_delay_cmd);
install_element(INTERFACE_NODE, &no_eigrp_if_delay_cmd);
Expand Down
28 changes: 4 additions & 24 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,30 +1295,6 @@ static int isis_interface_config_write(struct vty *vty)

return write;
}
#else
static int isis_interface_config_write(struct vty *vty)
{
struct vrf *vrf = NULL;
int write = 0;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
struct interface *ifp;

FOR_ALL_INTERFACES (vrf, ifp) {
struct lyd_node *dnode;
dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
if (dnode == NULL)
continue;

write++;
nb_cli_show_dnode_cmds(vty, dnode, false);
}
}
return write;
}
#endif /* ifdef FABRICD */

void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router,
Expand Down Expand Up @@ -1529,7 +1505,11 @@ void isis_circuit_init(void)
hook_register_prio(if_del, 0, isis_if_delete_hook);

/* Install interface node */
#ifdef FABRICD
if_cmd_init(isis_interface_config_write);
#else
if_cmd_init_default();
#endif
if_zapi_callbacks(isis_ifp_create, isis_ifp_up,
isis_ifp_down, isis_ifp_destroy);
}
19 changes: 19 additions & 0 deletions lib/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,20 @@ static struct cmd_node interface_node = {
.prompt = "%s(config-if)# ",
};

static int if_config_write_single(const struct lyd_node *dnode, void *arg)
{
nb_cli_show_dnode_cmds(arg, dnode, false);

return YANG_ITER_CONTINUE;
}

static int if_nb_config_write(struct vty *vty)
{
yang_dnode_iterate(if_config_write_single, vty, running_config->dnode,
"/frr-interface:lib/interface");
return 1;
}

void if_cmd_init(int (*config_write)(struct vty *))
{
cmd_variable_handler_register(if_var_handlers);
Expand All @@ -1356,6 +1370,11 @@ void if_cmd_init(int (*config_write)(struct vty *))
install_element(INTERFACE_NODE, &no_interface_desc_cmd);
}

void if_cmd_init_default(void)
{
if_cmd_init(if_nb_config_write);
}

void if_zapi_callbacks(int (*create)(struct interface *ifp),
int (*up)(struct interface *ifp),
int (*down)(struct interface *ifp),
Expand Down
1 change: 1 addition & 0 deletions lib/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ void if_link_params_free(struct interface *);
/* Northbound. */
struct vty;
extern void if_cmd_init(int (*config_write)(struct vty *));
extern void if_cmd_init_default(void);
extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
int (*up)(struct interface *ifp),
int (*down)(struct interface *ifp),
Expand Down
29 changes: 1 addition & 28 deletions ripd/rip_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,33 +1103,6 @@ void rip_passive_nondefault_clean(struct rip *rip)
rip_passive_interface_apply_all(rip);
}

/* Write rip configuration of each interface. */
static int rip_interface_config_write(struct vty *vty)
{
struct vrf *vrf;
int write = 0;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
struct interface *ifp;

FOR_ALL_INTERFACES (vrf, ifp) {
struct lyd_node *dnode;

dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
if (dnode == NULL)
continue;

write = 1;
nb_cli_show_dnode_cmds(vty, dnode, false);
}
}

return write;
}

int rip_show_network_config(struct vty *vty, struct rip *rip)
{
unsigned int i;
Expand Down Expand Up @@ -1194,7 +1167,7 @@ void rip_if_init(void)
hook_register_prio(if_del, 0, rip_interface_delete_hook);

/* Install interface node. */
if_cmd_init(rip_interface_config_write);
if_cmd_init_default();
if_zapi_callbacks(rip_ifp_create, rip_ifp_up,
rip_ifp_down, rip_ifp_destroy);
}
29 changes: 1 addition & 28 deletions ripngd/ripng_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,33 +923,6 @@ static int ripng_if_delete_hook(struct interface *ifp)
return 0;
}

/* Configuration write function for ripngd. */
static int interface_config_write(struct vty *vty)
{
struct vrf *vrf;
int write = 0;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
struct interface *ifp;

FOR_ALL_INTERFACES (vrf, ifp) {
struct lyd_node *dnode;

dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
if (dnode == NULL)
continue;

write = 1;
nb_cli_show_dnode_cmds(vty, dnode, false);
}
}

return write;
}

/* Initialization of interface. */
void ripng_if_init(void)
{
Expand All @@ -958,7 +931,7 @@ void ripng_if_init(void)
hook_register_prio(if_del, 0, ripng_if_delete_hook);

/* Install interface node. */
if_cmd_init(interface_config_write);
if_cmd_init_default();
if_zapi_callbacks(ripng_ifp_create, ripng_ifp_up,
ripng_ifp_down, ripng_ifp_destroy);
}
31 changes: 1 addition & 30 deletions vrrpd/vrrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,35 +715,6 @@ DEFUN_NOSH (show_debugging_vrrp,

/* clang-format on */

/*
* Write per interface VRRP config.
*/
static int vrrp_config_write_interface(struct vty *vty)
{
struct vrf *vrf;
int write = 0;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
struct interface *ifp;

FOR_ALL_INTERFACES (vrf, ifp) {
const struct lyd_node *dnode;

dnode = yang_dnode_getf(
running_config->dnode,
"/frr-interface:lib/interface[name='%s'][vrf='%s']",
ifp->name, vrf->name);
if (dnode == NULL)
continue;

write = 1;
nb_cli_show_dnode_cmds(vty, dnode, false);
}
}

return write;
}

static struct cmd_node debug_node = {
.name = "debug",
.node = DEBUG_NODE,
Expand All @@ -763,7 +734,7 @@ void vrrp_vty_init(void)
install_node(&debug_node);
install_node(&vrrp_node);
vrf_cmd_init(NULL);
if_cmd_init(vrrp_config_write_interface);
if_cmd_init_default();

install_element(VIEW_NODE, &vrrp_vrid_show_cmd);
install_element(VIEW_NODE, &vrrp_vrid_show_summary_cmd);
Expand Down

0 comments on commit 6972571

Please sign in to comment.