diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2019-01-04 19:08:10 -0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2019-01-18 16:15:41 -0200 |
| commit | dde7b15b83513b5883378ba1d4f2298ef451450b (patch) | |
| tree | 2130501acfc20fe071d92ee93ee4cd75eec17998 /ripngd/ripng_cli.c | |
| parent | 14f17e6362fdc36428883c8557df6c681c9bceb4 (diff) | |
ripngd: add VRF support
* Turn the "instance" YANG presence-container into a YANG list keyed
by the new "vrf" leaf. This is a backward incompatible change but
this should be ok for now.
* RIPng VRF instances can be configured even when the corresponding
VRF doesn't exist. And a RIPng VRF instance isn't deleted when
the corresponding VRF is deleted. For this to work, implement the
ripng_instance_enable() and ripng_instance_disable() functions
that are called to enable/disable RIPng routing instances when
necessary. A RIPng routing instance can be enabled only when the
corresponding VRF is enabled (this information comes from zebra
and depends on the underlying VRF backend). Routing instances are
stored in the new ripng_instances rb-tree (global variable).
* Add a vrf pointer to the ripng structure instead of storing vrf_id
only. This is much more convenient than using vrf_lookup_by_id()
every time we need to get the vrf pointer from the VRF ID. The
ripng->vrf pointer is updated whenever the VRF enable/disable hooks
are called.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd/ripng_cli.c')
| -rw-r--r-- | ripngd/ripng_cli.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index a187e80fd7..c89832d51d 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -39,31 +39,46 @@ */ DEFPY_NOSH (router_ripng, router_ripng_cmd, - "router ripng", + "router ripng [vrf NAME]", "Enable a routing process\n" - "Make RIPng instance command\n") + "Make RIPng instance command\n" + VRF_CMD_HELP_STR) { + char xpath[XPATH_MAXLEN]; int ret; - nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_CREATE, - NULL); + /* Build RIPng instance XPath. */ + if (!vrf) + vrf = VRF_DEFAULT_NAME; + snprintf(xpath, sizeof(xpath), "/frr-ripngd:ripngd/instance[vrf='%s']", + vrf); + + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); ret = nb_cli_apply_changes(vty, NULL); if (ret == CMD_SUCCESS) - VTY_PUSH_XPATH(RIPNG_NODE, "/frr-ripngd:ripngd/instance"); + VTY_PUSH_XPATH(RIPNG_NODE, xpath); return ret; } DEFPY (no_router_ripng, no_router_ripng_cmd, - "no router ripng", + "no router ripng [vrf NAME]", NO_STR "Enable a routing process\n" - "Make RIPng instance command\n") + "Make RIPng instance command\n" + VRF_CMD_HELP_STR) { - nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_DELETE, - NULL); + char xpath[XPATH_MAXLEN]; + + /* Build RIPng instance XPath. */ + if (!vrf) + vrf = VRF_DEFAULT_NAME; + snprintf(xpath, sizeof(xpath), "/frr-ripngd:ripngd/instance[vrf='%s']", + vrf); + + nb_cli_enqueue_change(vty, xpath, NB_OP_DELETE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -71,8 +86,15 @@ DEFPY (no_router_ripng, void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode, bool show_defaults) { + const char *vrf_name; + + vrf_name = yang_dnode_get_string(dnode, "./vrf"); + vty_out(vty, "!\n"); - vty_out(vty, "router ripng\n"); + vty_out(vty, "router ripng"); + if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) + vty_out(vty, " vrf %s", vrf_name); + vty_out(vty, "\n"); } /* |
