/* Route retain mode flag. */
int retain_mode = 0;
+/* Allow non-quagga entities to delete quagga routes */
+int allow_delete = 0;
+
/* Don't delete kernel route. */
int keep_kernel_mode = 0;
/* Command line options. */
struct option longopts[] =
{
- { "batch", no_argument, NULL, 'b'},
- { "daemon", no_argument, NULL, 'd'},
- { "keep_kernel", no_argument, NULL, 'k'},
- { "config_file", required_argument, NULL, 'f'},
- { "pid_file", required_argument, NULL, 'i'},
- { "socket", required_argument, NULL, 'z'},
- { "help", no_argument, NULL, 'h'},
- { "vty_addr", required_argument, NULL, 'A'},
- { "vty_port", required_argument, NULL, 'P'},
- { "retain", no_argument, NULL, 'r'},
- { "dryrun", no_argument, NULL, 'C'},
+ { "batch", no_argument, NULL, 'b'},
+ { "daemon", no_argument, NULL, 'd'},
+ { "allow_delete", no_argument, NULL, 'a'},
+ { "keep_kernel", no_argument, NULL, 'k'},
+ { "config_file", required_argument, NULL, 'f'},
+ { "pid_file", required_argument, NULL, 'i'},
+ { "socket", required_argument, NULL, 'z'},
+ { "help", no_argument, NULL, 'h'},
+ { "vty_addr", required_argument, NULL, 'A'},
+ { "vty_port", required_argument, NULL, 'P'},
+ { "retain", no_argument, NULL, 'r'},
+ { "dryrun", no_argument, NULL, 'C'},
#ifdef HAVE_NETLINK
- { "nl-bufsize", required_argument, NULL, 's'},
+ { "nl-bufsize", required_argument, NULL, 's'},
#endif /* HAVE_NETLINK */
- { "user", required_argument, NULL, 'u'},
- { "group", required_argument, NULL, 'g'},
- { "version", no_argument, NULL, 'v'},
+ { "user", required_argument, NULL, 'u'},
+ { "group", required_argument, NULL, 'g'},
+ { "version", no_argument, NULL, 'v'},
{ 0 }
};
"redistribution between different routing protocols.\n\n"\
"-b, --batch Runs in batch mode\n"\
"-d, --daemon Runs in daemon mode\n"\
+ "-a, --allow_delete Allow other processes to delete Quagga Routes\n" \
"-f, --config_file Set configuration file name\n"\
"-i, --pid_file Set process identifier file name\n"\
"-z, --socket Set path of zebra socket\n"\
int opt;
#ifdef HAVE_NETLINK
- opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vs:C", longopts, 0);
+ opt = getopt_long (argc, argv, "bdakf:i:z:hA:P:ru:g:vs:C", longopts, 0);
#else
- opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vC", longopts, 0);
+ opt = getopt_long (argc, argv, "bdakf:i:z:hA:P:ru:g:vC", longopts, 0);
#endif /* HAVE_NETLINK */
if (opt == EOF)
case 'd':
daemon_mode = 1;
break;
+ case 'a':
+ allow_delete = 1;
+ break;
case 'k':
keep_kernel_mode = 1;
break;
/* process id. */
pid_t pid;
+/* Allow non-quagga entities to delete quagga routes */
+int allow_delete = 0;
+
/* zebra_rib's workqueue hold time. Private export for use by test code only */
extern int rib_process_hold_time;
/* Command line options. */
struct option longopts[] =
{
- { "batch", no_argument, NULL, 'b'},
- { "daemon", no_argument, NULL, 'd'},
- { "config_file", required_argument, NULL, 'f'},
- { "help", no_argument, NULL, 'h'},
- { "vty_addr", required_argument, NULL, 'A'},
- { "vty_port", required_argument, NULL, 'P'},
- { "version", no_argument, NULL, 'v'},
- { "rib_hold", required_argument, NULL, 'r'},
+ { "batch", no_argument, NULL, 'b'},
+ { "daemon", no_argument, NULL, 'd'},
+ { "allow_delete", no_argument, NULL, 'a'},
+ { "config_file", required_argument, NULL, 'f'},
+ { "help", no_argument, NULL, 'h'},
+ { "vty_addr", required_argument, NULL, 'A'},
+ { "vty_port", required_argument, NULL, 'P'},
+ { "version", no_argument, NULL, 'v'},
+ { "rib_hold", required_argument, NULL, 'r'},
{ 0 }
};
"redistribution between different routing protocols.\n\n"\
"-b, --batch Runs in batch mode\n"\
"-d, --daemon Runs in daemon mode\n"\
+ "-a, --allow_delete Allow other processes to delete Quagga Routes\n" \
"-f, --config_file Set configuration file name\n"\
"-A, --vty_addr Set vty's bind address\n"\
"-P, --vty_port Set vty's port number\n"\
{
int opt;
- opt = getopt_long (argc, argv, "bdf:hA:P:r:v", longopts, 0);
+ opt = getopt_long (argc, argv, "bdaf:hA:P:r:v", longopts, 0);
if (opt == EOF)
break;
case 'd':
daemon_mode = 1;
break;
+ case 'a':
+ allow_delete =1;
+ break;
case 'f':
config_file = optarg;
break;
/* Default rtm_table for all clients */
extern struct zebra_t zebrad;
+/* Should we allow non Quagga processes to delete our routes */
+extern int allow_delete;
+
/* Hold time for RIB process, should be very minimal.
* it is useful to able to set it otherwise for testing, hence exported
* as global here for test-rig code.
inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen);
}
- /* This means someone else, other than Zebra, has deleted
- * a Zebra router from the kernel. We will add it back */
- rib_install_kernel(rn, fib, 0);
+ if (allow_delete)
+ {
+ /* Unset flags. */
+ for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
+ UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+
+ UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
+ }
+ else
+ {
+ /* This means someone else, other than Zebra, has deleted
+ * a Zebra router from the kernel. We will add it back */
+ rib_install_kernel(rn, fib, 0);
+ }
}
else
{
inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen);
}
- /* This means someone else, other than Zebra, has deleted a Zebra
- * route from the kernel. We will add it back */
- rib_install_kernel(rn, fib, 0);
+ if (allow_delete)
+ {
+ /* Unset flags. */
+ for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
+ UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+
+ UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
+ }
+ else
+ {
+ /* This means someone else, other than Zebra, has deleted a Zebra
+ * route from the kernel. We will add it back */
+ rib_install_kernel(rn, fib, 0);
+ }
}
else
{
#include "zebra/zserv.h"
#include "zebra/debug.h"
#include "zebra/zebra_rnh.h"
+#include "zebra/zebra_routemap.h"
static u_int32_t zebra_rmap_update_timer = ZEBRA_RMAP_DEFAULT_UPDATE_TIMER;
static struct thread *zebra_t_rmap_update = NULL;
}
/* ip protocol configuration write function */
-static int config_write_protocol(struct vty *vty)
+void
+zebra_routemap_config_write_protocol (struct vty *vty)
{
int i;
- if (zebra_rnh_ip_default_route)
- vty_out (vty, "ip nht resolve-via-default%s", VTY_NEWLINE);
-
- if (zebra_rnh_ipv6_default_route)
- vty_out (vty, "ipv6 nht resolve-via-default%s", VTY_NEWLINE);
-
for (i=0;i<ZEBRA_ROUTE_MAX;i++)
{
if (proto_rm[AFI_IP][i])
if (zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER)
vty_out (vty, "zebra route-map delay-timer %d%s", zebra_rmap_update_timer,
VTY_NEWLINE);
- return 1;
}
-/* table node for protocol filtering */
-static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
void
zebra_route_map_init ()
{
- install_node (&protocol_node, config_write_protocol);
install_element (CONFIG_NODE, &ip_protocol_cmd);
install_element (CONFIG_NODE, &no_ip_protocol_cmd);
install_element (CONFIG_NODE, &no_ip_protocol_val_cmd);
--- /dev/null
+/*
+ * Zebra routemap header
+ * Copyright (C) 2015 Cumulus Networks, Inc.
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * GNU Zebra is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Zebra; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __ZEBRA_ROUTEMAP_H__
+#define __ZEBRA_ROUTEMAP_H__
+
+extern void zebra_routemap_config_write_protocol(struct vty *vty);
+
+#endif
#include "zebra/zserv.h"
#include "zebra/zebra_rnh.h"
#include "zebra/redistribute.h"
+#include "zebra/zebra_routemap.h"
+
+extern int allow_delete;
/* General fucntion for static route. */
static int
}
#endif /* HAVE_IPV6 */
+DEFUN (allow_external_route_update,
+ allow_external_route_update_cmd,
+ "allow-external-route-update",
+ "Allow Quagga routes to be overwritten by external processes")
+{
+ allow_delete = 1;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_allow_external_route_update,
+ no_allow_external_route_update_cmd,
+ "no allow-external-route-update",
+ "Allow Quagga routes to be overwritten by external processes")
+{
+ allow_delete = 0;
+
+ return CMD_SUCCESS;
+}
+
/* Static ip route configuration write function. */
static int
zebra_ip_config (struct vty *vty)
"kernel routing table id\n"
"distance to be used\n")
+static int
+config_write_protocol (struct vty *vty)
+{
+ if (allow_delete)
+ vty_out(vty, "allow-external-route-update%s", VTY_NEWLINE);
+
+ if (zebra_rnh_ip_default_route)
+ vty_out(vty, "ip nht resolve-via-default%s", VTY_NEWLINE);
+
+ if (zebra_rnh_ipv6_default_route)
+ vty_out(vty, "ipv6 nht resolve-via-default%s", VTY_NEWLINE);
+
+ zebra_routemap_config_write_protocol(vty);
+
+ return 1;
+}
+
/* IP node for static routes. */
static struct cmd_node ip_node = { IP_NODE, "", 1 };
+static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
/* Route VTY. */
void
zebra_vty_init (void)
{
install_node (&ip_node, zebra_ip_config);
+ install_node (&protocol_node, config_write_protocol);
+ install_element (CONFIG_NODE, &allow_external_route_update_cmd);
+ install_element (CONFIG_NODE, &no_allow_external_route_update_cmd);
install_element (CONFIG_NODE, &ip_route_cmd);
install_element (CONFIG_NODE, &ip_route_tag_cmd);
install_element (CONFIG_NODE, &ip_route_flags_cmd);