summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-08-02 15:39:38 +0200
committerGitHub <noreply@github.com>2017-08-02 15:39:38 +0200
commit0ecfe5bf38cd803aef891fb9bedb5633949b39bc (patch)
tree561b08b2612329f757b8d32be91a5abb7109f45b /zebra
parentpimd: Add `ip pim rp keep-alive-time X` (diff)
parentMerge pull request #893 from opensourcerouting/minor-issues (diff)
downloadfrr-0ecfe5bf38cd803aef891fb9bedb5633949b39bc.tar.xz
frr-0ecfe5bf38cd803aef891fb9bedb5633949b39bc.zip
Merge branch 'master' into PIM_VRF
Diffstat (limited to 'zebra')
-rw-r--r--zebra/.gitignore3
-rw-r--r--zebra/Makefile10
-rw-r--r--zebra/Makefile.am94
-rw-r--r--zebra/debug.c135
-rw-r--r--zebra/if_ioctl.c4
-rw-r--r--zebra/if_ioctl_solaris.c4
-rw-r--r--zebra/if_netlink.c4
-rw-r--r--zebra/if_sysctl.c4
-rw-r--r--zebra/ioctl.c4
-rw-r--r--zebra/ioctl_solaris.c4
-rw-r--r--zebra/ipforward_proc.c4
-rw-r--r--zebra/ipforward_solaris.c5
-rw-r--r--zebra/ipforward_sysctl.c5
-rw-r--r--zebra/kernel_netlink.c4
-rw-r--r--zebra/kernel_socket.c5
-rw-r--r--zebra/rt_netlink.c5
-rw-r--r--zebra/rt_socket.c5
-rw-r--r--zebra/rtread_getmsg.c4
-rw-r--r--zebra/rtread_netlink.c4
-rw-r--r--zebra/rtread_sysctl.c4
-rw-r--r--zebra/subdir.am131
-rw-r--r--zebra/zebra_fpm_netlink.c4
-rw-r--r--zebra/zebra_mpls_netlink.c5
-rw-r--r--zebra/zebra_mpls_null.c4
-rw-r--r--zebra/zebra_mpls_openbsd.c5
-rw-r--r--zebra/zebra_mpls_vty.c599
-rw-r--r--zebra/zebra_static.c27
-rw-r--r--zebra/zebra_static.h18
-rw-r--r--zebra/zebra_vty.c996
29 files changed, 452 insertions, 1648 deletions
diff --git a/zebra/.gitignore b/zebra/.gitignore
index 145df0568..7a1321e54 100644
--- a/zebra/.gitignore
+++ b/zebra/.gitignore
@@ -1,4 +1,4 @@
-Makefile
+!Makefile
Makefile.in
*.o
zebra
@@ -13,3 +13,4 @@ TAGS
.arch-ids
*~
*.loT
+zebra_vty_clippy.c
diff --git a/zebra/Makefile b/zebra/Makefile
new file mode 100644
index 000000000..625a7168e
--- /dev/null
+++ b/zebra/Makefile
@@ -0,0 +1,10 @@
+all: ALWAYS
+ @$(MAKE) -s -C .. zebra/zebra
+%: ALWAYS
+ @$(MAKE) -s -C .. zebra/$@
+
+Makefile:
+ #nothing
+ALWAYS:
+.PHONY: ALWAYS makefiles
+.SUFFIXES:
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
deleted file mode 100644
index 46ecad5e4..000000000
--- a/zebra/Makefile.am
+++ /dev/null
@@ -1,94 +0,0 @@
-include ../common.am
-
-## Process this file with automake to produce Makefile.in.
-
-AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
-DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
-INSTALL_SDATA=@INSTALL@ -m 600
-
-LIBCAP = @LIBCAP@
-
-ipforward = @IPFORWARD@
-if_method = @IF_METHOD@
-rt_method = @RT_METHOD@
-rtread_method = @RTREAD_METHOD@
-kernel_method = @KERNEL_METHOD@
-ioctl_method = @IOCTL_METHOD@
-mpls_method = @MPLS_METHOD@
-
-otherobj = $(ioctl_method) $(ipforward) $(if_method) \
- $(rt_method) $(rtread_method) $(kernel_method) $(mpls_method)
-
-AM_CFLAGS = $(WERROR)
-
-sbin_PROGRAMS = zebra
-module_LTLIBRARIES =
-
-zebra_SOURCES = \
- zebra_memory.c \
- zserv.c main.c interface.c connected.c zebra_rib.c zebra_routemap.c \
- redistribute.c debug.c rtadv.c zebra_vty.c \
- irdp_main.c irdp_interface.c irdp_packet.c router-id.c \
- zebra_ptm.c zebra_rnh.c zebra_ptm_redistribute.c \
- zebra_ns.c zebra_vrf.c zebra_static.c zebra_mpls.c zebra_mpls_vty.c \
- zebra_mroute.c \
- label_manager.c \
- zebra_l2.c \
- zebra_vxlan.c \
- # end
-
-noinst_HEADERS = \
- zebra_memory.h \
- connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
- interface.h ipforward.h irdp.h router-id.h kernel_socket.h \
- rt_netlink.h zebra_fpm_private.h zebra_rnh.h \
- zebra_ptm_redistribute.h zebra_ptm.h zebra_routemap.h \
- zebra_ns.h zebra_vrf.h ioctl_solaris.h zebra_static.h zebra_mpls.h \
- kernel_netlink.h if_netlink.h zebra_mroute.h label_manager.h \
- zebra_l2.h zebra_vxlan_private.h zebra_vxlan.h
-
-zebra_LDADD = $(otherobj) ../lib/libfrr.la $(LIBCAP)
-
-zebra_DEPENDENCIES = $(otherobj)
-
-if SNMP
-module_LTLIBRARIES += zebra_snmp.la
-endif
-zebra_snmp_la_SOURCES = zebra_snmp.c
-zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS)
-zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-zebra_snmp_la_LIBADD = ../lib/libfrrsnmp.la
-
-if FPM
-module_LTLIBRARIES += zebra_fpm.la
-endif
-zebra_fpm_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
-zebra_fpm_la_LIBADD = $(Q_FPM_PB_CLIENT_LDOPTS)
-zebra_fpm_la_SOURCES = zebra_fpm.c
-if HAVE_NETLINK
-zebra_fpm_la_SOURCES += zebra_fpm_netlink.c
-endif
-if HAVE_PROTOBUF
-zebra_fpm_la_SOURCES += zebra_fpm_protobuf.c
-if DEV_BUILD
-zebra_fpm_la_SOURCES += zebra_fpm_dt.c
-endif
-endif
-
-
-EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c \
- if_sysctl.c ipforward_proc.c \
- ipforward_solaris.c ipforward_sysctl.c rt_netlink.c \
- rt_socket.c rtread_netlink.c rtread_sysctl.c \
- rtread_getmsg.c kernel_socket.c kernel_netlink.c \
- ioctl.c ioctl_solaris.c \
- zebra_mpls_netlink.c zebra_mpls_openbsd.c zebra_mpls_null.c \
- GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB
-
-client : client_main.o ../lib/libfrr.la
- $(CC) -g -o client client_main.o ../liblzebra.la $(LIBS) $(LIB_IPV6)
-
-frrconfdir = $(sysconfdir)
-
-examplesdir = $(exampledir)
-dist_examples_DATA = zebra.conf.sample
diff --git a/zebra/debug.c b/zebra/debug.c
index dfee6b74c..6aedea1e3 100644
--- a/zebra/debug.c
+++ b/zebra/debug.c
@@ -71,10 +71,10 @@ DEFUN (show_debugging_zebra,
" Zebra kernel netlink message dumps (recv) are on\n");
/* Check here using flags as the 'macro' does an OR */
- if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
- vty_out(vty, " Zebra RIB debugging is on\n");
if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
vty_out(vty, " Zebra RIB detailed debugging is on\n");
+ else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
+ vty_out(vty, " Zebra RIB debugging is on\n");
if (IS_ZEBRA_DEBUG_FPM)
vty_out(vty, " Zebra FPM debugging is on\n");
@@ -145,17 +145,16 @@ DEFUN (debug_zebra_packet,
if (argv_find(argv, argc, "send", &idx))
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
- idx = 0;
- if (argv_find(argv, argc, "recv", &idx))
+ else if (argv_find(argv, argc, "recv", &idx))
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
- idx = 0;
- if (argv_find(argv, argc, "detail", &idx))
- SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
-
- if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV)) {
+ else {
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
}
+
+ if (argv_find(argv, argc, "detail", &idx))
+ SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
+
return CMD_SUCCESS;
}
@@ -167,6 +166,13 @@ DEFUN (debug_zebra_kernel,
"Debug option set for zebra between kernel interface\n")
{
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
return CMD_SUCCESS;
}
@@ -181,34 +187,41 @@ DEFUN (debug_zebra_kernel_msgdump,
"Dump raw netlink messages sent\n")
{
int idx = 0;
- if (argc == 4 || argv_find(argv, argc, "recv", &idx))
+
+ if (argv_find(argv, argc, "recv", &idx)) {
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
- if (argc == 4 || argv_find(argv, argc, "send", &idx))
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
+ } else if (argv_find(argv, argc, "send", &idx)) {
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+
+ } else {
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+ }
+
return CMD_SUCCESS;
}
DEFUN (debug_zebra_rib,
debug_zebra_rib_cmd,
- "debug zebra rib",
- DEBUG_STR
- "Zebra configuration\n"
- "Debug RIB events\n")
-{
- SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
- return CMD_SUCCESS;
-}
-
-DEFUN (debug_zebra_rib_detailed,
- debug_zebra_rib_detailed_cmd,
- "debug zebra rib detailed",
+ "debug zebra rib [detailed]",
DEBUG_STR
"Zebra configuration\n"
"Debug RIB events\n"
"Detailed debugs\n")
{
- SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+ int idx = 0;
+ SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
+
+ if (argv_find(argv, argc, "detailed", &idx))
+ SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+
return CMD_SUCCESS;
}
@@ -273,19 +286,16 @@ DEFUN (no_debug_zebra_vxlan,
DEFUN (no_debug_zebra_packet,
no_debug_zebra_packet_cmd,
- "no debug zebra packet [<recv|send>]",
+ "no debug zebra packet [<recv|send>] [detail]",
NO_STR
DEBUG_STR
"Zebra configuration\n"
"Debug option set for zebra packet\n"
"Debug option set for receive packet\n"
- "Debug option set for send packet\n")
+ "Debug option set for send packet\n"
+ "Debug option set for detailed info\n")
{
- int idx = 0;
- if (argc == 4 || argv_find(argv, argc, "send", &idx))
- UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
- if (argc == 4 || argv_find(argv, argc, "recv", &idx))
- UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
+ zebra_debug_packet = 0;
return CMD_SUCCESS;
}
@@ -297,7 +307,7 @@ DEFUN (no_debug_zebra_kernel,
"Zebra configuration\n"
"Debug option set for zebra between kernel interface\n")
{
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+ zebra_debug_kernel = 0;
return CMD_SUCCESS;
}
@@ -312,37 +322,20 @@ DEFUN (no_debug_zebra_kernel_msgdump,
"Dump raw netlink messages received\n"
"Dump raw netlink messages sent\n")
{
- int idx = 0;
- if (argc == 5 || argv_find(argv, argc, "recv", &idx))
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
- if (argc == 5 || argv_find(argv, argc, "send", &idx))
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
-
+ zebra_debug_kernel = 0;
return CMD_SUCCESS;
}
DEFUN (no_debug_zebra_rib,
no_debug_zebra_rib_cmd,
- "no debug zebra rib",
- NO_STR
- DEBUG_STR
- "Zebra configuration\n"
- "Debug zebra RIB\n")
-{
- zebra_debug_rib = 0;
- return CMD_SUCCESS;
-}
-
-DEFUN (no_debug_zebra_rib_detailed,
- no_debug_zebra_rib_detailed_cmd,
- "no debug zebra rib detailed",
+ "no debug zebra rib [detailed]",
NO_STR
DEBUG_STR
"Zebra configuration\n"
"Debug zebra RIB\n"
"Detailed debugs\n")
{
- UNSET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+ zebra_debug_rib = 0;
return CMD_SUCCESS;
}
@@ -385,27 +378,31 @@ static int config_write_debug(struct vty *vty)
write++;
}
}
+
if (IS_ZEBRA_DEBUG_KERNEL) {
- vty_out(vty, "debug zebra kernel\n");
- write++;
- }
- if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
- vty_out(vty, "debug zebra kernel msgdump recv\n");
- write++;
- }
- if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
- vty_out(vty, "debug zebra kernel msgdump send\n");
- write++;
- }
- /* Check here using flags as the 'macro' does an OR */
- if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
- vty_out(vty, "debug zebra rib\n");
- write++;
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
+ vty_out(vty, "debug zebra kernel msgdump\n");
+ write++;
+ } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
+ vty_out(vty, "debug zebra kernel msgdump recv\n");
+ write++;
+ } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
+ vty_out(vty, "debug zebra kernel msgdump send\n");
+ write++;
+ } else {
+ vty_out(vty, "debug zebra kernel\n");
+ write++;
+ }
}
+
if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
vty_out(vty, "debug zebra rib detailed\n");
write++;
+ } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
+ vty_out(vty, "debug zebra rib\n");
+ write++;
}
+
if (IS_ZEBRA_DEBUG_FPM) {
vty_out(vty, "debug zebra fpm\n");
write++;
@@ -447,7 +444,6 @@ void zebra_debug_init(void)
install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
- install_element(ENABLE_NODE, &debug_zebra_rib_detailed_cmd);
install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_events_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_nht_cmd);
@@ -457,7 +453,6 @@ void zebra_debug_init(void)
install_element(ENABLE_NODE, &no_debug_zebra_kernel_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
- install_element(ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
install_element(CONFIG_NODE, &debug_zebra_events_cmd);
@@ -468,7 +463,6 @@ void zebra_debug_init(void)
install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
- install_element(CONFIG_NODE, &debug_zebra_rib_detailed_cmd);
install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_events_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_nht_cmd);
@@ -478,6 +472,5 @@ void zebra_debug_init(void)
install_element(CONFIG_NODE, &no_debug_zebra_kernel_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
- install_element(CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
}
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 2d5d604a8..a65fcb2b8 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef OPEN_BSD
+
#include "if.h"
#include "sockunion.h"
#include "prefix.h"
@@ -328,3 +330,5 @@ void interface_list(struct zebra_ns *zns)
ifaddr_proc_ipv6();
#endif /* HAVE_PROC_NET_IF_INET6 */
}
+
+#endif /* OPEN_BSD */
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index fce36ebc1..3d5319459 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef SUNOS_5
+
#include "if.h"
#include "sockunion.h"
#include "prefix.h"
@@ -358,3 +360,5 @@ struct connected *if_lookup_linklocal(struct interface *ifp)
return NULL;
}
+
+#endif /* SUNOS_5 */
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index bd7673d6c..a46657dd2 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef GNU_LINUX
+
/* The following definition is to workaround an issue in the Linux kernel
* header files with redefinition of 'struct in6_addr' in both
* netinet/in.h and linux/in6.h.
@@ -1245,3 +1247,5 @@ void interface_list(struct zebra_ns *zns)
{
interface_lookup_netlink(zns);
}
+
+#endif /* GNU_LINUX */
diff --git a/zebra/if_sysctl.c b/zebra/if_sysctl.c
index 99b0f9d94..39b7204e8 100644
--- a/zebra/if_sysctl.c
+++ b/zebra/if_sysctl.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#if !defined(GNU_LINUX) && !defined(OPEN_BSD) && !defined(SUNOS_5)
+
#include "if.h"
#include "sockunion.h"
#include "prefix.h"
@@ -134,3 +136,5 @@ void interface_list(struct zebra_ns *zns)
/* Free sysctl buffer. */
XFREE(MTYPE_TMP, ref);
}
+
+#endif /* !defined(GNU_LINUX) && !defined(OPEN_BSD) && !defined(SUNOS_5) */
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 72d98943e..835f1f493 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -33,6 +33,8 @@
#include "zebra/rt.h"
#include "zebra/interface.h"
+#ifndef SUNOS_5
+
#ifdef HAVE_BSD_LINK_DETECT
#include <net/if_media.h>
#endif /* HAVE_BSD_LINK_DETECT*/
@@ -563,3 +565,5 @@ int if_prefix_delete_ipv6(struct interface *ifp, struct connected *ifc)
#endif /* HAVE_STRUCT_IN6_ALIASREQ */
#endif /* LINUX_IPV6 */
+
+#endif /* !SUNOS_5 */
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index df1554ae6..e8b65925f 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef SUNOS_5
+
#include "linklist.h"
#include "if.h"
#include "prefix.h"
@@ -398,3 +400,5 @@ int if_prefix_delete_ipv6(struct interface *ifp, struct connected *ifc)
return 0;
}
+
+#endif /* SUNOS_5 */
diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c
index c3dcdda55..2834eeeb9 100644
--- a/zebra/ipforward_proc.c
+++ b/zebra/ipforward_proc.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef GNU_LINUX
+
#include "log.h"
#include "privs.h"
@@ -193,3 +195,5 @@ int ipforward_ipv6_off(void)
return ipforward_ipv6();
}
+
+#endif /* GNU_LINUX */
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index 0d6b7dac0..123cf1bd0 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -20,6 +20,9 @@
*/
#include <zebra.h>
+
+#ifdef SUNOS_5
+
#include "log.h"
#include "prefix.h"
@@ -153,3 +156,5 @@ int ipforward_ipv6_off(void)
(void)solaris_nd_set("ip6_forwarding", 0);
return ipforward_ipv6();
}
+
+#endif /* SUNOS_5 */
diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c
index 00be92bb6..36212a013 100644
--- a/zebra/ipforward_sysctl.c
+++ b/zebra/ipforward_sysctl.c
@@ -19,6 +19,9 @@
*/
#include <zebra.h>
+
+#if !defined(GNU_LINUX) && !defined(SUNOS_5)
+
#include "privs.h"
#include "zebra/ipforward.h"
@@ -147,3 +150,5 @@ int ipforward_ipv6_off(void)
zlog_err("Can't lower privileges");
return ip6forwarding;
}
+
+#endif /* !defined(GNU_LINUX) && !defined(SUNOS_5) */
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 7fc2d6133..dfc3f6211 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -20,6 +20,8 @@
#include <zebra.h>
+#ifdef HAVE_NETLINK
+
#include "linklist.h"
#include "if.h"
#include "log.h"
@@ -826,3 +828,5 @@ void kernel_terminate(struct zebra_ns *zns)
zns->netlink_cmd.sock = -1;
}
}
+
+#endif /* HAVE_NETLINK */
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 4b63a3eb0..5df57b253 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -19,6 +19,9 @@
*/
#include <zebra.h>
+
+#ifndef HAVE_NETLINK
+
#include <net/if_types.h>
#ifdef __OpenBSD__
#include <netmpls/mpls.h>
@@ -1376,3 +1379,5 @@ void kernel_terminate(struct zebra_ns *zns)
{
return;
}
+
+#endif /* !HAVE_NETLINK */
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 3640769f8..9b31e467c 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -19,6 +19,9 @@
*/
#include <zebra.h>
+
+#ifdef HAVE_NETLINK
+
#include <net/if_arp.h>
/* Hack for GNU libc version 2. */
@@ -2453,3 +2456,5 @@ void clear_nhlfe_installed(zebra_lsp_t *lsp)
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
}
}
+
+#endif /* HAVE_NETLINK */
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index 699fe6eb2..4e4d726b4 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -20,6 +20,9 @@
*/
#include <zebra.h>
+
+#ifndef HAVE_NETLINK
+
#ifdef __OpenBSD__
#include <netmpls/mpls.h>
#endif
@@ -449,3 +452,5 @@ extern int kernel_interface_set_master(struct interface *master,
{
return 0;
}
+
+#endif /* !HAVE_NETLINK */
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index 5384231f8..1bba003a0 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef SUNOS_5
+
#include "prefix.h"
#include "log.h"
#include "if.h"
@@ -258,3 +260,5 @@ void neigh_read(struct zebra_ns *zns)
void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
{
}
+
+#endif /* SUNOS_5 */
diff --git a/zebra/rtread_netlink.c b/zebra/rtread_netlink.c
index 304f44136..f38cba65e 100644
--- a/zebra/rtread_netlink.c
+++ b/zebra/rtread_netlink.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#ifdef GNU_LINUX
+
#include "vty.h"
#include "zebra/zserv.h"
#include "zebra/rt_netlink.h"
@@ -50,3 +52,5 @@ void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
{
netlink_neigh_read_for_vlan(zns, vlan_if);
}
+
+#endif /* GNU_LINUX */
diff --git a/zebra/rtread_sysctl.c b/zebra/rtread_sysctl.c
index d3e2eb6fa..53ed0e790 100644
--- a/zebra/rtread_sysctl.c
+++ b/zebra/rtread_sysctl.c
@@ -21,6 +21,8 @@
#include <zebra.h>
+#if !defined(GNU_LINUX) && !defined(SUNOS_5)
+
#include "memory.h"
#include "zebra_memory.h"
#include "log.h"
@@ -90,3 +92,5 @@ void neigh_read(struct zebra_ns *zns)
void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
{
}
+
+#endif /* !defined(GNU_LINUX) && !defined(SUNOS_5) */
diff --git a/zebra/subdir.am b/zebra/subdir.am
new file mode 100644
index 000000000..ceffa863e
--- /dev/null
+++ b/zebra/subdir.am
@@ -0,0 +1,131 @@
+#
+# zebra
+#
+
+if ZEBRA
+sbin_PROGRAMS += zebra/zebra
+dist_examples_DATA += zebra/zebra.conf.sample
+
+if SNMP
+module_LTLIBRARIES += zebra/zebra_snmp.la
+endif
+if FPM
+module_LTLIBRARIES += zebra/zebra_fpm.la
+endif
+
+## endif ZEBRA
+endif
+
+zebra_zebra_LDADD = lib/libfrr.la $(LIBCAP)
+zebra_zebra_SOURCES = \
+ zebra/connected.c \
+ zebra/debug.c \
+ zebra/if_ioctl.c \
+ zebra/if_ioctl_solaris.c \
+ zebra/if_netlink.c \
+ zebra/if_sysctl.c \
+ zebra/interface.c \
+ zebra/ioctl.c \
+ zebra/ioctl_solaris.c \
+ zebra/ipforward_proc.c \
+ zebra/ipforward_solaris.c \
+ zebra/ipforward_sysctl.c \
+ zebra/irdp_interface.c \
+ zebra/irdp_main.c \
+ zebra/irdp_packet.c \
+ zebra/kernel_netlink.c \
+ zebra/kernel_socket.c \
+ zebra/label_manager.c \
+ zebra/main.c \
+ zebra/redistribute.c \
+ zebra/router-id.c \
+ zebra/rt_netlink.c \
+ zebra/rt_socket.c \
+ zebra/rtadv.c \
+ zebra/rtread_getmsg.c \
+ zebra/rtread_netlink.c \
+ zebra/rtread_sysctl.c \
+ zebra/zebra_l2.c \
+ zebra/zebra_memory.c \
+ zebra/zebra_mpls.c \
+ zebra/zebra_mpls_netlink.c \
+ zebra/zebra_mpls_openbsd.c \
+ zebra/zebra_mpls_null.c \
+ zebra/zebra_mpls_vty.c \
+ zebra/zebra_mroute.c \
+ zebra/zebra_ns.c \
+ zebra/zebra_ptm.c \
+ zebra/zebra_ptm_redistribute.c \
+ zebra/zebra_rib.c \
+ zebra/zebra_rnh.c \
+ zebra/zebra_routemap.c \
+ zebra/zebra_static.c \
+ zebra/zebra_vrf.c \
+ zebra/zebra_vty.c \
+ zebra/zebra_vxlan.c \
+ zebra/zserv.c \
+ # end
+
+zebra/zebra_vty_clippy.c: $(CLIPPY_DEPS)
+zebra/zebra_vty.$(OBJEXT): zebra/zebra_vty_clippy.c
+
+noinst_HEADERS += \
+ zebra/connected.h \
+ zebra/debug.h \
+ zebra/if_netlink.h \
+ zebra/interface.h \
+ zebra/ioctl.h \
+ zebra/ioctl_solaris.h \
+ zebra/ipforward.h \
+ zebra/irdp.h \
+ zebra/kernel_netlink.h \
+ zebra/kernel_socket.h \
+ zebra/label_manager.h \
+ zebra/redistribute.h \
+ zebra/rib.h \
+ zebra/router-id.h \
+ zebra/rt.h \
+ zebra/rt_netlink.h \
+ zebra/rtadv.h \
+ zebra/zebra_fpm_private.h \
+ zebra/zebra_l2.h \
+ zebra/zebra_memory.h \
+ zebra/zebra_mpls.h \
+ zebra/zebra_mroute.h \
+ zebra/zebra_ns.h \
+ zebra/zebra_ptm.h \
+ zebra/zebra_ptm_redistribute.h \
+ zebra/zebra_rnh.h \
+ zebra/zebra_routemap.h \
+ zebra/zebra_static.h \
+ zebra/zebra_vrf.h \
+ zebra/zebra_vxlan.h \
+ zebra/zebra_vxlan_private.h \
+ zebra/zserv.h \
+ # end
+
+zebra_zebra_snmp_la_SOURCES = zebra/zebra_snmp.c
+zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS)
+zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
+zebra_zebra_snmp_la_LIBADD = lib/libfrrsnmp.la
+
+zebra_zebra_fpm_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
+zebra_zebra_fpm_la_LIBADD = $(Q_FPM_PB_CLIENT_LDOPTS)
+zebra_zebra_fpm_la_SOURCES = zebra/zebra_fpm.c
+zebra_zebra_fpm_la_SOURCES += zebra/zebra_fpm_netlink.c
+if HAVE_PROTOBUF
+zebra_zebra_fpm_la_SOURCES += zebra/zebra_fpm_protobuf.c
+if DEV_BUILD
+zebra_zebra_fpm_la_SOURCES += zebra/zebra_fpm_dt.c
+endif
+endif
+
+EXTRA_DIST += \
+ zebra/GNOME-SMI \
+ zebra/GNOME-PRODUCT-ZEBRA-MIB \
+ # end
+
+# -- unmaintained --
+# noinst_PROGRAMS += zebra/client
+# zebra_client_SOURCES = zebra/client_main.c
+# zebra_client_LDADD = lib/libfrr.la
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index 862049cb8..28f795663 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -24,6 +24,8 @@
#include <zebra.h>
+#ifdef HAVE_NETLINK
+
#include "log.h"
#include "rib.h"
#include "vty.h"
@@ -457,3 +459,5 @@ int zfpm_netlink_encode_route(int cmd, rib_dest_t *dest, struct route_entry *re,
return netlink_route_info_encode(ri, in_buf, in_buf_len);
}
+
+#endif /* HAVE_NETLINK */
diff --git a/zebra/zebra_mpls_netlink.c b/zebra/zebra_mpls_netlink.c
index c5053563b..8b30783a9 100644
--- a/zebra/zebra_mpls_netlink.c
+++ b/zebra/zebra_mpls_netlink.c
@@ -19,6 +19,9 @@
*/
#include <zebra.h>
+
+#ifdef HAVE_NETLINK
+
#include "zebra/rt.h"
#include "zebra/rt_netlink.h"
#include "zebra/zebra_mpls.h"
@@ -105,3 +108,5 @@ int mpls_kernel_init(void)
return 0;
};
+
+#endif /* HAVE_NETLINK */
diff --git a/zebra/zebra_mpls_null.c b/zebra/zebra_mpls_null.c
index a9da5c29c..e4dc570fd 100644
--- a/zebra/zebra_mpls_null.c
+++ b/zebra/zebra_mpls_null.c
@@ -22,6 +22,8 @@
#include "zebra/rt.h"
#include "zebra/zebra_mpls.h"
+#if !defined(HAVE_NETLINK) && !defined(OPEN_BSD)
+
int kernel_add_lsp(zebra_lsp_t *lsp)
{
return 0;
@@ -38,3 +40,5 @@ int mpls_kernel_init(void)
{
return -1;
};
+
+#endif /* !defined(HAVE_NETLINK) && !defined(OPEN_BSD) */
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index fc1df9227..c3d09aedb 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -19,6 +19,9 @@
*/
#include <zebra.h>
+
+#ifdef OPEN_BSD
+
#include <netmpls/mpls.h>
#include "zebra/rt.h"
#include "zebra/zebra_mpls.h"
@@ -358,3 +361,5 @@ int mpls_kernel_init(void)
return 0;
}
+
+#endif /* OPEN_BSD */
diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c
index ed34831f8..9d100bb7d 100644
--- a/zebra/zebra_mpls_vty.c
+++ b/zebra/zebra_mpls_vty.c
@@ -283,570 +283,6 @@ DEFUN (no_mpls_label_bind,
return zebra_mpls_bind(vty, 0, argv[4]->arg, NULL);
}
-/* Static route configuration. */
-DEFUN (ip_route_label,
- ip_route_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, NULL, NULL, NULL,
- argv[5]->arg);
-}
-
-DEFUN (ip_route_tag_label,
- ip_route_tag_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, argv[5]->arg, NULL, NULL,
- argv[7]->arg);
-}
-
-/* Mask as A.B.C.D format. */
-DEFUN (ip_route_mask_label,
- ip_route_mask_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, NULL, NULL,
- NULL, argv[6]->arg);
-}
-
-DEFUN (ip_route_mask_tag_label,
- ip_route_mask_tag_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
- NULL, NULL, argv[8]->arg);
-}
-
-/* Distance option value. */
-DEFUN (ip_route_distance_label,
- ip_route_distance_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, NULL, argv[4]->arg, NULL,
- argv[6]->arg);
-}
-
-DEFUN (ip_route_tag_distance_label,
- ip_route_tag_distance_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, argv[5]->arg, argv[6]->arg,
- NULL, argv[8]->arg);
-}
-
-DEFUN (ip_route_mask_distance_label,
- ip_route_mask_distance_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, NULL,
- argv[5]->arg, NULL, argv[7]->arg);
-}
-
-DEFUN (ip_route_mask_tag_distance_label,
- ip_route_mask_tag_distance_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
- argv[7]->arg, NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_label,
- no_ip_route_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, NULL, NULL, NULL,
- argv[6]->arg);
-}
-
-DEFUN (no_ip_route_tag_label,
- no_ip_route_tag_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
- argv[8]->arg);
-}
-
-DEFUN (no_ip_route_mask_label,
- no_ip_route_mask_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, NULL, NULL,
- NULL, argv[7]->arg);
-}
-
-DEFUN (no_ip_route_mask_tag_label,
- no_ip_route_mask_tag_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
- NULL, NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_distance_label,
- no_ip_route_distance_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
- argv[7]->arg);
-}
-
-DEFUN (no_ip_route_tag_distance_label,
- no_ip_route_tag_distance_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
- NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_mask_distance_label,
- no_ip_route_mask_distance_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, NULL,
- argv[6]->arg, NULL, argv[8]->arg);
-}
-
-DEFUN (no_ip_route_mask_tag_distance_label,
- no_ip_route_mask_tag_distance_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
- argv[8]->arg, NULL, argv[10]->arg);
-}
-
-DEFUN (ipv6_route_label,
- ipv6_route_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, NULL, NULL, NULL, argv[5]->arg);
-}
-
-DEFUN (ipv6_route_tag_label,
- ipv6_route_tag_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, argv[5]->arg, NULL, NULL, argv[7]->arg);
-}
-
-DEFUN (ipv6_route_ifname_label,
- ipv6_route_ifname_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, NULL, NULL, NULL,
- argv[6]->arg);
-}
-DEFUN (ipv6_route_ifname_tag_label,
- ipv6_route_ifname_tag_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
- argv[8]->arg);
-}
-
-DEFUN (ipv6_route_pref_label,
- ipv6_route_pref_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, NULL, argv[4]->arg, NULL, argv[6]->arg);
-}
-
-DEFUN (ipv6_route_pref_tag_label,
- ipv6_route_pref_tag_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, argv[5]->arg, argv[6]->arg, NULL,
- argv[8]->arg);
-}
-
-DEFUN (ipv6_route_ifname_pref_label,
- ipv6_route_ifname_pref_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
- argv[7]->arg);
-}
-
-DEFUN (ipv6_route_ifname_pref_tag_label,
- ipv6_route_ifname_pref_tag_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
- NULL, argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_label,
- no_ipv6_route_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, NULL, NULL, NULL, argv[6]->arg);
-}
-
-DEFUN (no_ipv6_route_tag_label,
- no_ipv6_route_tag_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, argv[6]->arg, NULL, NULL, argv[8]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_label,
- no_ipv6_route_ifname_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, NULL, NULL, NULL,
- argv[7]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_tag_label,
- no_ipv6_route_ifname_tag_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, argv[7]->arg, NULL, NULL,
- argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_pref_label,
- no_ipv6_route_pref_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, NULL, argv[5]->arg, NULL, argv[7]->arg);
-}
-
-DEFUN (no_ipv6_route_pref_tag_label,
- no_ipv6_route_pref_tag_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, argv[6]->arg, argv[7]->arg, NULL,
- argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_pref_label,
- no_ipv6_route_ifname_pref_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, NULL, argv[6]->arg, NULL,
- argv[8]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_pref_tag_label,
- no_ipv6_route_ifname_pref_tag_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg,
- NULL, argv[10]->arg);
-}
-
/* MPLS LSP configuration write function. */
static int zebra_mpls_config(struct vty *vty)
{
@@ -1024,44 +460,11 @@ void zebra_mpls_vty_init(void)
install_node(&mpls_node, zebra_mpls_config);
- install_element(CONFIG_NODE, &ip_route_label_cmd);
- install_element(CONFIG_NODE, &ip_route_tag_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_tag_label_cmd);
- install_element(CONFIG_NODE, &ip_route_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_tag_distance_label_cmd);
-
- install_element(CONFIG_NODE, &ipv6_route_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_pref_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_pref_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_pref_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_label_cmd);
-
install_element(CONFIG_NODE, &mpls_transit_lsp_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_all_cmd);
+
install_element(CONFIG_NODE, &mpls_label_bind_cmd);
install_element(CONFIG_NODE, &no_mpls_label_bind_cmd);
diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c
index ae3239516..6cebae997 100644
--- a/zebra/zebra_static.c
+++ b/zebra/zebra_static.c
@@ -81,6 +81,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ nexthop = route_entry_nexthop_ipv4_ifindex_add(
+ re, &si->addr.ipv4, NULL, si->ifindex);
+ break;
case STATIC_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add(re,
si->ifindex);
@@ -152,6 +156,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ nexthop = route_entry_nexthop_ipv4_ifindex_add(
+ re, &si->addr.ipv4, NULL, si->ifindex);
+ break;
case STATIC_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add(re,
si->ifindex);
@@ -216,6 +224,11 @@ static int static_nexthop_same(struct nexthop *nexthop, struct static_route *si)
&& si->type == STATIC_IPV4_GATEWAY
&& IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4))
return 1;
+ else if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
+ && si->type == STATIC_IPV4_GATEWAY_IFINDEX
+ && IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4)
+ && nexthop->ifindex == si->ifindex)
+ return 1;
else if (nexthop->type == NEXTHOP_TYPE_IFINDEX
&& si->type == STATIC_IFINDEX
&& nexthop->ifindex == si->ifindex)
@@ -361,12 +374,17 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
if (!stable)
return -1;
- if (!gate && (type == STATIC_IPV4_GATEWAY || type == STATIC_IPV6_GATEWAY
- || type == STATIC_IPV6_GATEWAY_IFINDEX))
+ if (!gate
+ && (type == STATIC_IPV4_GATEWAY
+ || type == STATIC_IPV4_GATEWAY_IFINDEX
+ || type == STATIC_IPV6_GATEWAY
+ || type == STATIC_IPV6_GATEWAY_IFINDEX))
return -1;
if (!ifindex
- && (type == STATIC_IFINDEX || type == STATIC_IPV6_GATEWAY_IFINDEX))
+ && (type == STATIC_IFINDEX
+ || type == STATIC_IPV4_GATEWAY_IFINDEX
+ || type == STATIC_IPV6_GATEWAY_IFINDEX))
return -1;
/* Lookup static route prefix. */
@@ -411,11 +429,10 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
switch (type) {
case STATIC_IPV4_GATEWAY:
+ case STATIC_IPV4_GATEWAY_IFINDEX:
si->addr.ipv4 = gate->ipv4;
break;
case STATIC_IPV6_GATEWAY:
- si->addr.ipv6 = gate->ipv6;
- break;
case STATIC_IPV6_GATEWAY_IFINDEX:
si->addr.ipv6 = gate->ipv6;
break;
diff --git a/zebra/zebra_static.h b/zebra/zebra_static.h
index 91ac0a33c..885774895 100644
--- a/zebra/zebra_static.h
+++ b/zebra/zebra_static.h
@@ -32,6 +32,7 @@ struct static_nh_label {
typedef enum {
STATIC_IFINDEX,
STATIC_IPV4_GATEWAY,
+ STATIC_IPV4_GATEWAY_IFINDEX,
STATIC_BLACKHOLE,
STATIC_IPV6_GATEWAY,
STATIC_IPV6_GATEWAY_IFINDEX,
@@ -57,11 +58,6 @@ struct static_route {
/*
* Nexthop value.
- *
- * Under IPv4 addr and ifindex are
- * used independentyly.
- * STATIC_IPV4_GATEWAY uses addr
- * STATIC_IFINDEX uses ifindex
*/
union g_addr addr;
ifindex_t ifindex;
@@ -100,16 +96,4 @@ extern int static_delete_route(afi_t, safi_t safi, u_char type,
struct zebra_vrf *zvrf,
struct static_nh_label *snh_label);
-int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
- const char *dest_str, const char *mask_str,
- const char *gate_str, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str);
-
-int static_ipv6_func(struct vty *vty, int add_cmd, const char *dest_str,
- const char *src_str, const char *gate_str,
- const char *ifname, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str);
-
#endif
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 3978664db..e8b82ecf9 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -43,6 +43,7 @@
#include "zebra/zebra_static.h"
#include "lib/json.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_vty_clippy.c"
extern int allow_delete;
@@ -61,40 +62,59 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
#define CMD_VNI_RANGE "(1-16777215)"
/* General function for static route. */
-int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
- const char *dest_str, const char *mask_str,
- const char *gate_str, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str)
+static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
+ const char *negate, const char *dest_str,
+ const char *mask_str, const char *src_str,
+ const char *gate_str, const char *ifname,
+ const char *flag_str, const char *tag_str,
+ const char *distance_str, const char *vrf_id_str,
+ const char *label_str)
{
int ret;
u_char distance;
- struct prefix p;
- struct in_addr gate;
+ struct prefix p, src;
+ struct prefix_ipv6 *src_p = NULL;
+ union g_addr gate;
+ union g_addr *gatep = NULL;
struct in_addr mask;
u_char flag = 0;
route_tag_t tag = 0;
- struct zebra_vrf *zvrf = NULL;
+ struct zebra_vrf *zvrf;
unsigned int ifindex = 0;
- const char *ifname = NULL;
- u_char type = STATIC_BLACKHOLE;
+ u_char type;
struct static_nh_label snh_label;
- memset(&snh_label, 0, sizeof(struct static_nh_label));
ret = str2prefix(dest_str, &p);
if (ret <= 0) {
vty_out(vty, "%% Malformed address\n");
return CMD_WARNING_CONFIG_FAILED;
}
- /* Cisco like mask notation. */
- if (mask_str) {
- ret = inet_aton(mask_str, &mask);
- if (ret == 0) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
+ switch (afi) {
+ case AFI_IP:
+ /* Cisco like mask notation. */
+ if (mask_str) {
+ ret = inet_aton(mask_str, &mask);
+ if (ret == 0) {
+ vty_out(vty, "%% Malformed address\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ p.prefixlen = ip_masklen(mask);
+ }
+ break;
+ case AFI_IP6:
+ /* srcdest routing */
+ if (src_str) {
+ ret = str2prefix(src_str, &src);
+ if (ret <= 0 || src.family != AF_INET6) {
+ vty_out(vty, "%% Malformed source address\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ src_p = (struct prefix_ipv6 *)&src;
}
- p.prefixlen = ip_masklen(mask);
+ break;
+ default:
+ break;
}
/* Apply mask for given prefix. */
@@ -119,6 +139,7 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
/* Labels */
+ memset(&snh_label, 0, sizeof(struct static_nh_label));
if (label_str) {
if (!mpls_enabled) {
vty_out(vty,
@@ -149,22 +170,15 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
/* Null0 static route. */
- if ((gate_str != NULL)
- && (strncasecmp(gate_str, "Null0", strlen(gate_str)) == 0)) {
+ if ((ifname != NULL)
+ && (strncasecmp(ifname, "Null0", strlen(ifname)) == 0)) {
if (flag_str) {
vty_out(vty, "%% can not have flag %s with Null0\n",
flag_str);
return CMD_WARNING_CONFIG_FAILED;
}
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, ifname, ZEBRA_FLAG_BLACKHOLE,
- tag, distance, zvrf, &snh_label);
- else
- static_delete_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, tag, distance, zvrf,
- &snh_label);
- return CMD_SUCCESS;
+ SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
+ ifname = NULL;
}
/* Route flags */
@@ -184,70 +198,56 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
}
- if (gate_str == NULL) {
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, ifname, flag, tag, distance,
- zvrf, &snh_label);
- else
- static_delete_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, tag, distance, zvrf,
- &snh_label);
-
- return CMD_SUCCESS;
+ if (gate_str) {
+ if (inet_pton(afi2family(afi), gate_str, &gate) != 1) {
+ vty_out(vty, "%% Malformed nexthop address %s\n",
+ gate_str);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ gatep = &gate;
}
- /* When gateway is A.B.C.D format, gate is treated as nexthop
- address other case gate is treated as interface name. */
- ret = inet_aton(gate_str, &gate);
- if (!ret) {
- struct interface *ifp =
- if_lookup_by_name(gate_str, zvrf_id(zvrf));
+ if (ifname) {
+ struct interface *ifp;
+ ifp = if_lookup_by_name(ifname, zvrf_id(zvrf));
if (!ifp) {
- vty_out(vty, "%% Unknown interface: %s\n", gate_str);
+ vty_out(vty, "%% Malformed Interface name %s\n",
+ ifname);
ifindex = IFINDEX_DELETED;
} else
ifindex = ifp->ifindex;
- ifname = gate_str;
+ }
+
+ if (gate_str == NULL && ifname == NULL)
+ type = STATIC_BLACKHOLE;
+ else if (gate_str && ifname) {
+ if (afi == AFI_IP)
+ type = STATIC_IPV4_GATEWAY_IFINDEX;
+ else
+ type = STATIC_IPV6_GATEWAY_IFINDEX;
+ } else if (ifname)
type = STATIC_IFINDEX;
- } else
- type = STATIC_IPV4_GATEWAY;
+ else {
+ if (afi == AFI_IP)
+ type = STATIC_IPV4_GATEWAY;
+ else
+ type = STATIC_IPV6_GATEWAY;
+ }
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL,
- ifindex ? NULL : (union g_addr *)&gate,
- ifindex, ifname, flag, tag, distance, zvrf,
- &snh_label);
+ if (!negate)
+ static_add_route(afi, safi, type, &p, src_p, gatep, ifindex,
+ ifname, flag, tag, distance, zvrf, &snh_label);
else
- static_delete_route(AFI_IP, safi, type, &p, NULL,
- ifindex ? NULL : (union g_addr *)&gate,
- ifindex, tag, distance, zvrf, &snh_label);
+ static_delete_route(afi, safi, type, &p, src_p, gatep, ifindex,
+ tag, distance, zvrf, &snh_label);
return CMD_SUCCESS;
}
/* Static unicast routes for multicast RPF lookup. */
-DEFUN (ip_mroute_dist,
+DEFPY (ip_mroute_dist,
ip_mroute_dist_cmd,
- "ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
- IP_STR
- "Configure static unicast route into MRIB for multicast RPF lookup\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Nexthop address\n"
- "Nexthop interface name\n"
- "Distance\n")
-{
- char *destprefix = argv[2]->arg;
- char *nexthop = argv[3]->arg;
- char *distance = (argc == 5) ? argv[4]->arg : NULL;
-
- return zebra_static_ipv4(vty, SAFI_MULTICAST, 1, destprefix, NULL,
- nexthop, NULL, NULL, distance, NULL, NULL);
-}
-
-DEFUN (no_ip_mroute_dist,
- no_ip_mroute_dist_cmd,
- "no ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
+ "[no] ip mroute A.B.C.D/M$prefix <A.B.C.D$gate|INTERFACE$ifname> [(1-255)$distance]",
NO_STR
IP_STR
"Configure static unicast route into MRIB for multicast RPF lookup\n"
@@ -256,12 +256,9 @@ DEFUN (no_ip_mroute_dist,
"Nexthop interface name\n"
"Distance\n")
{
- char *destprefix = argv[3]->arg;
- char *nexthop = argv[4]->arg;
- char *distance = (argc == 6) ? argv[5]->arg : NULL;
-
- return zebra_static_ipv4(vty, SAFI_MULTICAST, 0, destprefix, NULL,
- nexthop, NULL, NULL, distance, NULL, NULL);
+ return zebra_static_route(vty, AFI_IP, SAFI_MULTICAST, no, prefix_str,
+ NULL, NULL, gate_str, ifname, NULL, NULL,
+ distance_str, NULL, NULL);
}
DEFUN (ip_multicast_mode,
@@ -357,270 +354,43 @@ DEFUN (show_ip_rpf_addr,
return CMD_SUCCESS;
}
-static void zebra_vty_ip_route_tdv_helper(int argc, struct cmd_token *argv[],
- int idx_curr, char **tag,
- char **distance, char **vrf,
- char **labels)
-{
- *distance = NULL;
- while (idx_curr < argc) {
- if (strmatch(argv[idx_curr]->text, "tag")) {
- if (tag)
- *tag = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else if (strmatch(argv[idx_curr]->text, "vrf")) {
- if (vrf)
- *vrf = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else if (strmatch(argv[idx_curr]->text, "label")) {
- if (labels)
- *labels = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else {
- if (distance)
- *distance = argv[idx_curr]->arg;
- idx_curr++;
- }
- }
-
- return;
-}
-
/* Static route configuration. */
-DEFUN (ip_route,
+DEFPY (ip_route,
ip_route_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 2;
- int idx_ipv4_ifname_null = 3;
- int idx_curr = 4;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1,
- argv[idx_ipv4_prefixlen]->arg, NULL,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ip_route_flags,
- ip_route_flags_cmd,
- "ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 2;
- int idx_reject_blackhole = 3;
- int idx_curr = 4;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(
- vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance, vrf, NULL);
-}
-
-/* Mask as A.B.C.D format. */
-DEFUN (ip_route_mask,
- ip_route_mask_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 2;
- int idx_ipv4_2 = 3;
- int idx_ipv4_ifname_null = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ip_route_mask_flags,
- ip_route_mask_flags_cmd,
- "ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 2;
- int idx_ipv4_2 = 3;
- int idx_reject_blackhole = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ip_route,
- no_ip_route_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
+ "[no] ip route\
+ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask>\
+ <\
+ {A.B.C.D$gate|INTERFACE$ifname}\
+ |null0$ifname\
+ |<reject|blackhole>$flag\
+ >\
+ [{\
+ tag (1-4294967295)\
+ |(1-255)$distance\
+ |vrf NAME\
+ |label WORD\
+ }]",
NO_STR
IP_STR
"Establish static routes\n"
"IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 3;
- int idx_ipv4_ifname_null = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0,
- argv[idx_ipv4_prefixlen]->arg, NULL,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_flags,
- no_ip_route_flags_cmd,
- "no ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 3;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0,
- argv[idx_ipv4_prefixlen]->arg, NULL, NULL,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_mask,
- no_ip_route_mask_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
"IP destination prefix\n"
"IP destination prefix mask\n"
"IP gateway address\n"
"IP gateway interface name\n"
"Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 3;
- int idx_ipv4_2 = 4;
- int idx_ipv4_ifname_null = 5;
- int idx_curr = 6;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_mask_flags,
- no_ip_route_mask_flags_cmd,
- "no ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n"
- "Tag of this route\n"
+ "Set tag for this route\n"
"Tag value\n"
"Distance value for this route\n"
- VRF_CMD_HELP_STR)
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
- int idx_ipv4 = 3;
- int idx_ipv4_2 = 4;
- int idx_curr = 6;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
+ return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
+ mask_str, NULL, gate_str, ifname, flag,
+ tag_str, distance_str, vrf, label);
+ return 0;
}
/* New RIB. Detailed information for IPv4 route. */
@@ -1937,8 +1707,20 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
case STATIC_IFINDEX:
vty_out(vty, " %s", si->ifname);
break;
+ /* blackhole and Null0 mean the same thing */
case STATIC_BLACKHOLE:
- vty_out(vty, " Null0");
+ if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
+ vty_out(vty, " reject");
+ else
+ vty_out(vty, " Null0");
+ break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ vty_out(vty, " %s %s",
+ inet_ntop(AF_INET,
+ &si->addr.ipv4, buf,
+ sizeof buf),
+ ifindex2ifname(si->ifindex,
+ si->vrf_id));
break;
case STATIC_IPV6_GATEWAY_IFINDEX:
vty_out(vty, " %s %s",
@@ -1992,360 +1774,22 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
return write;
}
-/* General fucntion for IPv6 static route. */
-int static_ipv6_func(struct vty *vty, int add_cmd, const char *dest_str,
- const char *src_str, const char *gate_str,
- const char *ifname, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str)
-{
- int ret;
- u_char distance;
- struct prefix p, src;
- struct prefix_ipv6 *src_p = NULL;
- struct in6_addr *gate = NULL;
- struct in6_addr gate_addr;
- u_char type = STATIC_BLACKHOLE;
- u_char flag = 0;
- route_tag_t tag = 0;
- unsigned int ifindex = 0;
- struct interface *ifp = NULL;
- struct zebra_vrf *zvrf;
- struct static_nh_label snh_label;
-
- ret = str2prefix(dest_str, &p);
- if (ret <= 0) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- if (src_str) {
- ret = str2prefix(src_str, &src);
- if (ret <= 0 || src.family != AF_INET6) {
- vty_out(vty, "%% Malformed source address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- src_p = (struct prefix_ipv6 *)&src;
- }
-
- /* Apply mask for given prefix. */
- apply_mask(&p);
-
- /* Administrative distance. */
- if (distance_str)
- distance = atoi(distance_str);
- else
- distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
-
- /* tag */
- if (tag_str)
- tag = strtoul(tag_str, NULL, 10);
-
- /* When gateway is valid IPv6 addrees, then gate is treated as
- nexthop address other case gate is treated as interface name. */
- ret = inet_pton(AF_INET6, gate_str, &gate_addr);
-
- /* VRF id */
- zvrf = zebra_vrf_lookup_by_name(vrf_id_str);
-
- if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n", vrf_id_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /* Labels */
- memset(&snh_label, 0, sizeof(struct static_nh_label));
- if (label_str) {
- if (!mpls_enabled) {
- vty_out(vty,
- "%% MPLS not turned on in kernel, ignoring command\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- int rc = mpls_str2label(label_str, &snh_label.num_labels,
- snh_label.label);
- if (rc < 0) {
- switch (rc) {
- case -1:
- vty_out(vty, "%% Malformed label(s)\n");
- break;
- case -2:
- vty_out(vty,
- "%% Cannot use reserved label(s) (%d-%d)\n",
- MPLS_MIN_RESERVED_LABEL,
- MPLS_MAX_RESERVED_LABEL);
- break;
- case -3:
- vty_out(vty,
- "%% Too many labels. Enter %d or fewer\n",
- MPLS_MAX_LABELS);
- break;
- }
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- /* Null0 static route. */
- if ((gate_str != NULL)
- && (strncasecmp(gate_str, "Null0", strlen(gate_str)) == 0)) {
- if (flag_str) {
- vty_out(vty, "%% can not have flag %s with Null0\n",
- flag_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
- if (add_cmd)
- static_add_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- NULL, ifindex, ifname,
- ZEBRA_FLAG_BLACKHOLE, tag, distance,
- zvrf, &snh_label);
- else
- static_delete_route(AFI_IP6, SAFI_UNICAST, type, &p,
- src_p, NULL, ifindex, tag, distance,
- zvrf, &snh_label);
- return CMD_SUCCESS;
- }
-
- /* Route flags */
- if (flag_str) {
- switch (flag_str[0]) {
- case 'r':
- case 'R': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_REJECT);
- break;
- case 'b':
- case 'B': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
- break;
- default:
- vty_out(vty, "%% Malformed flag %s \n", flag_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- if (ifname) {
- /* When ifname is specified. It must be come with gateway
- address. */
- if (ret != 1) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- type = STATIC_IPV6_GATEWAY_IFINDEX;
- gate = &gate_addr;
- ifp = if_lookup_by_name(ifname, zvrf_id(zvrf));
- if (!ifp) {
- vty_out(vty, "%% Malformed Interface name %s\n",
- ifname);
- return CMD_WARNING_CONFIG_FAILED;
- }
- ifindex = ifp->ifindex;
- } else {
- if (ret == 1) {
- type = STATIC_IPV6_GATEWAY;
- gate = &gate_addr;
- } else {
- type = STATIC_IFINDEX;
- ifp = if_lookup_by_name(gate_str, zvrf_id(zvrf));
- if (!ifp) {
- vty_out(vty, "%% Malformed Interface name %s\n",
- gate_str);
- ifindex = IFINDEX_DELETED;
- } else
- ifindex = ifp->ifindex;
- ifname = gate_str;
- }
- }
-
- if (add_cmd)
- static_add_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- (union g_addr *)gate, ifindex, ifname, flag,
- tag, distance, zvrf, &snh_label);
- else
- static_delete_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- (union g_addr *)gate, ifindex, tag,
- distance, zvrf, &snh_label);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ipv6_route,
+DEFPY (ipv6_route,
ipv6_route_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6_ifname;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6_ifname = 5;
- idx_curr = 6;
- } else {
- src = NULL;
- idx_ipv6_ifname = 3;
- idx_curr = 4;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ipv6_route_flags,
- ipv6_route_flags_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6_ifname;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6_ifname = 5;
- idx_reject_blackhole = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6_ifname = 3;
- idx_reject_blackhole = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (ipv6_route_ifname,
- ipv6_route_ifname_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6 = 3;
- int idx_interface = 4;
- int idx_curr = 5;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6 = 5;
- idx_interface = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6 = 3;
- idx_interface = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (ipv6_route_ifname_flags,
- ipv6_route_ifname_flags_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6;
- int idx_interface;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6 = 5;
- idx_interface = 6;
- idx_reject_blackhole = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6 = 3;
- idx_interface = 4;
- idx_reject_blackhole = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ipv6_route,
- no_ipv6_route_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
+ "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M]\
+ <\
+ {X:X::X:X$gate|INTERFACE$ifname}\
+ |null0$ifname\
+ |<reject|blackhole>$flag\
+ >\
+ [{\
+ tag (1-4294967295)\
+ |(1-255)$distance\
+ |vrf NAME\
+ |label WORD\
+ }]",
NO_STR
- IP_STR
+ IPV6_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 source-dest route\n"
@@ -2353,171 +1797,17 @@ DEFUN (no_ipv6_route,
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
"Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6_ifname;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6_ifname = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6_ifname = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_flags,
- no_ipv6_route_flags_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6_ifname;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6_ifname = 6;
- idx_reject_blackhole = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6_ifname = 4;
- idx_reject_blackhole = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_ifname,
- no_ipv6_route_ifname_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6;
- int idx_interface;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6 = 6;
- idx_interface = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6 = 4;
- idx_interface = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_ifname_flags,
- no_ipv6_route_ifname_flags_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n"
"Set tag for this route\n"
"Tag value\n"
"Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6;
- int idx_interface;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6 = 6;
- idx_interface = 7;
- idx_reject_blackhole = 8;
- idx_curr = 9;
- } else {
- src = NULL;
- idx_ipv6 = 4;
- idx_interface = 5;
- idx_reject_blackhole = 6;
- idx_curr = 7;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
+ return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
+ NULL, from_str, gate_str, ifname, flag,
+ tag_str, distance_str, vrf, label);
}
DEFUN (show_ipv6_route,
@@ -3370,15 +2660,9 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &allow_external_route_update_cmd);
install_element(CONFIG_NODE, &no_allow_external_route_update_cmd);
install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
- install_element(CONFIG_NODE, &no_ip_mroute_dist_cmd);
install_element(CONFIG_NODE, &ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &ip_route_cmd);
- install_element(CONFIG_NODE, &ip_route_flags_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_flags_cmd);
- install_element(CONFIG_NODE, &no_ip_route_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_cmd);
install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd);
@@ -3396,24 +2680,12 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_ip_rpf_cmd);
install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);
- /* Commands for VRF */
-
- install_element(CONFIG_NODE, &no_ip_route_flags_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_flags_cmd);
-
install_element(VIEW_NODE, &show_ip_route_vrf_all_addr_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_prefix_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
install_element(CONFIG_NODE, &ipv6_route_cmd);
- install_element(CONFIG_NODE, &ipv6_route_flags_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_flags_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
install_element(CONFIG_NODE, &ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &ipv6_nht_default_route_cmd);