summaryrefslogtreecommitdiff
path: root/lib/vrf.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-28 22:32:07 -0200
committerRenato Westphal <renato@opensourcerouting.org>2016-11-28 16:18:35 -0200
commitf30c50b99223be343b7fe1ae9e374602ec0d93d5 (patch)
treeb56a33113f07c0657711844df53483bd153a3971 /lib/vrf.c
parent1fbe3e585ddb0a1c16a870b8112b145732549f45 (diff)
zebra/lib: move some code around
* move netlink code from zebra_nc.c to kernel_netlink.c; * move vrf CLI commands from if.c/interface.c to vrf.c/zebra_vrf.c; * move declaration of the 'ns' structure to a header file. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/vrf.c')
-rw-r--r--lib/vrf.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index 63adea4aec..d87e38ebe8 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -740,6 +740,60 @@ vrf_socket (int domain, int type, int protocol, vrf_id_t vrf_id)
return ret;
}
+/* vrf CLI commands */
+DEFUN (vrf,
+ vrf_cmd,
+ "vrf NAME",
+ "Select a VRF to configure\n"
+ "VRF's name\n")
+{
+ struct vrf *vrfp;
+ size_t sl;
+
+ if ((sl = strlen(argv[0])) > VRF_NAMSIZ)
+ {
+ vty_out (vty, "%% VRF name %s is invalid: length exceeds "
+ "%d characters%s",
+ argv[0], VRF_NAMSIZ, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ vrfp = vrf_get (VRF_UNKNOWN, argv[0]);
+
+ VTY_PUSH_CONTEXT_COMPAT (VRF_NODE, vrfp);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN_NOSH (no_vrf,
+ no_vrf_cmd,
+ "no vrf NAME",
+ NO_STR
+ "Delete a pseudo VRF's configuration\n"
+ "VRF's name\n")
+{
+ struct vrf *vrfp;
+
+ vrfp = vrf_list_lookup_by_name (argv[0]);
+
+ if (vrfp == NULL)
+ {
+ vty_out (vty, "%% VRF %s does not exist%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (CHECK_FLAG (vrfp->status, VRF_ACTIVE))
+ {
+ vty_out (vty, "%% Only inactive VRFs can be deleted%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ vrf_delete(vrfp);
+
+ return CMD_SUCCESS;
+}
+
/*
* Debug CLI for vrf's
*/