Merge pull request #711 ("Coverity munging")

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-06-15 16:22:42 +02:00
commit f43cd318b2
20 changed files with 61 additions and 848 deletions

View File

@ -2151,13 +2151,18 @@ route_set_aggregator_as_compile (const char *arg)
struct aggregator *aggregator;
char as[10];
char address[20];
int ret;
aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
sscanf (arg, "%s %s", as, address);
aggregator->as = strtoul (as, NULL, 10);
inet_aton (address, &aggregator->address);
ret = inet_aton (address, &aggregator->address);
if (ret == 0)
{
XFREE (MTYPE_ROUTE_MAP_COMPILED, aggregator);
return NULL;
}
return aggregator;
}

View File

@ -473,7 +473,7 @@ eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest)
for (ALL_LIST_ELEMENTS_RO(dest->entries, node, entry))
{
if ((entry->distance <= (uint64_t)(dest->distance*eigrp->variance)) &&
if (((uint64_t)entry->distance <= (uint64_t)(dest->distance*eigrp->variance)) &&
entry->distance != EIGRP_MAX_METRIC) // is successor
{
entry->flags |= EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG;

View File

@ -186,7 +186,7 @@ eigrp_new (const char *AS)
eigrp->topology_table = eigrp_topology_new();
eigrp->neighbor_self = eigrp_nbr_new(NULL);
inet_aton("0.0.0.0", &eigrp->neighbor_self->src);
eigrp->neighbor_self->src.s_addr = INADDR_ANY;
eigrp->variance = EIGRP_VARIANCE_DEFAULT;
eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;

View File

@ -183,6 +183,7 @@ ospf_apiclient_connect (char *host, int syncport)
fd1 = socket (AF_INET, SOCK_STREAM, 0);
if (fd1 < 0)
{
close (async_server_sock);
fprintf (stderr,
"ospf_apiclient_connect: creating sync socket failed\n");
return NULL;
@ -196,6 +197,7 @@ ospf_apiclient_connect (char *host, int syncport)
{
fprintf (stderr, "ospf_apiclient_connect: SO_REUSEADDR failed\n");
close (fd1);
close (async_server_sock);
return NULL;
}
@ -206,6 +208,7 @@ ospf_apiclient_connect (char *host, int syncport)
{
fprintf (stderr, "ospf_apiclient_connect: SO_REUSEPORT failed\n");
close (fd1);
close (async_server_sock);
return NULL;
}
#endif /* SO_REUSEPORT */
@ -227,6 +230,7 @@ ospf_apiclient_connect (char *host, int syncport)
{
fprintf (stderr, "ospf_apiclient_connect: bind sync socket failed\n");
close (fd1);
close (async_server_sock);
return NULL;
}
@ -260,6 +264,7 @@ ospf_apiclient_connect (char *host, int syncport)
fprintf (stderr, "ospf_apiclient_connect: accept async failed\n");
close (async_server_sock);
close (fd1);
close (fd2);
return NULL;
}

View File

@ -94,7 +94,12 @@ lsa_delete (struct thread *t)
oclient = THREAD_ARG (t);
inet_aton (args[6], &area_id);
rc = inet_aton (args[6], &area_id);
if (rc <= 0)
{
printf("Address Specified: %s is invalid\n", args[6]);
return rc;
}
printf ("Deleting LSA... ");
rc = ospf_apiclient_lsa_delete (oclient,
@ -123,8 +128,19 @@ lsa_inject (struct thread *t)
cl = THREAD_ARG (t);
inet_aton (args[5], &ifaddr);
inet_aton (args[6], &area_id);
rc = inet_aton (args[5], &ifaddr);
if (rc <= 0)
{
printf ("Ifaddr specified %s is invalid\n", args[5]);
return rc;
}
rc = inet_aton (args[6], &area_id);
if (rc <= 0)
{
printf( "Area ID specified %s is invalid\n", args[6]);
return rc;
}
lsa_type = atoi (args[2]);
opaque_type = atoi (args[3]);
opaque_id = atoi (args[4]);

View File

@ -1192,7 +1192,12 @@ DEFUN (router_info,
/* Check and get Area value if present */
if (area)
{
inet_aton (area, &OspfRI.area_id);
if (!inet_aton (area, &OspfRI.area_id))
{
vty_out (vty, "%% specified Area ID %s is invalid%s",
area, VTY_NEWLINE);
return CMD_WARNING;
}
scope = OSPF_OPAQUE_AREA_LSA;
}
else

View File

@ -4411,9 +4411,8 @@ DEFUN (interface_no_ip_igmp,
IFACE_IGMP_STR)
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@ -4663,13 +4662,11 @@ DEFUN (interface_ip_igmp_query_interval,
"Query interval in seconds\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
int query_interval;
int query_interval_dsec;
int ret;
pim_ifp = ifp->info;
if (!pim_ifp) {
ret = pim_cmd_igmp_start(vty, ifp);
if (ret != CMD_SUCCESS)
@ -4721,11 +4718,9 @@ DEFUN (interface_no_ip_igmp_query_interval,
IFACE_IGMP_QUERY_INTERVAL_STR)
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
int default_query_interval_dsec;
pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@ -4753,12 +4748,10 @@ DEFUN (interface_ip_igmp_version,
"IGMP version number\n")
{
VTY_DECLVAR_CONTEXT(interface,ifp);
struct pim_interface *pim_ifp = NULL;
struct pim_interface *pim_ifp = ifp->info;
int igmp_version, old_version = 0;
int ret;
pim_ifp = ifp->info;
if (!pim_ifp)
{
ret = pim_cmd_igmp_start(vty, ifp);
@ -4797,9 +4790,7 @@ DEFUN (interface_no_ip_igmp_version,
"IGMP version number\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@ -4821,12 +4812,10 @@ DEFUN (interface_ip_igmp_query_max_response_time,
"Query response value in deci-seconds\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
int query_max_response_time;
int ret;
pim_ifp = ifp->info;
if (!pim_ifp) {
ret = pim_cmd_igmp_start(vty, ifp);
if (ret != CMD_SUCCESS)
@ -4859,9 +4848,7 @@ DEFUN (interface_no_ip_igmp_query_max_response_time,
"Time for response in deci-seconds\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@ -4883,13 +4870,11 @@ DEFUN_HIDDEN (interface_ip_igmp_query_max_response_time_dsec,
"Query response value in deciseconds\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
int query_max_response_time_dsec;
int default_query_interval_dsec;
int ret;
pim_ifp = ifp->info;
if (!pim_ifp) {
ret = pim_cmd_igmp_start(vty, ifp);
if (ret != CMD_SUCCESS)
@ -4923,9 +4908,7 @@ DEFUN_HIDDEN (interface_no_ip_igmp_query_max_response_time_dsec,
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@ -4945,11 +4928,9 @@ DEFUN (interface_ip_pim_drprio,
{
VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct pim_interface *pim_ifp;
struct pim_interface *pim_ifp = ifp->info;
uint32_t old_dr_prio;
pim_ifp = ifp->info;
if (!pim_ifp) {
vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE);
return CMD_WARNING;
@ -4977,9 +4958,7 @@ DEFUN (interface_no_ip_pim_drprio,
"Old Value of the Priority\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp) {
vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
@ -5319,9 +5298,7 @@ DEFUN (interface_ip_pim_hello,
VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_time = 3;
int idx_hold = 4;
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
{
@ -5354,9 +5331,7 @@ DEFUN (interface_no_ip_pim_hello,
IFACE_PIM_HELLO_HOLD_STR)
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp) {
vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
@ -5943,12 +5918,9 @@ DEFUN (ip_pim_bfd,
"Enables BFD support\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp = NULL;
struct pim_interface *pim_ifp = ifp->info;
struct bfd_info *bfd_info = NULL;
if (!ifp)
return CMD_SUCCESS;
pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
bfd_info = pim_ifp->bfd_info;
@ -5969,11 +5941,8 @@ DEFUN (no_ip_pim_bfd,
"Disables BFD support\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp = NULL;
struct pim_interface *pim_ifp = ifp->info;
assert (ifp);
pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;

1
zebra/.gitignore vendored
View File

@ -4,7 +4,6 @@ Makefile.in
zebra
zebra.conf
client
testzebra
tags
TAGS
.deps

View File

@ -22,7 +22,6 @@ otherobj = $(ioctl_method) $(ipforward) $(if_method) \
AM_CFLAGS = $(WERROR)
sbin_PROGRAMS = zebra
noinst_PROGRAMS = testzebra
module_LTLIBRARIES =
zebra_SOURCES = \
@ -36,12 +35,6 @@ zebra_SOURCES = \
label_manager.c \
# end
testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \
zebra_vty.c zebra_ptm.c zebra_routemap.c zebra_ns.c zebra_vrf.c \
kernel_null.c redistribute_null.c ioctl_null.c misc_null.c zebra_rnh_null.c \
zebra_ptm_null.c rtadv_null.c if_null.c zserv_null.c zebra_static.c \
zebra_memory.c zebra_mpls.c zebra_mpls_vty.c zebra_mpls_null.c
noinst_HEADERS = \
zebra_memory.h \
connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
@ -53,8 +46,6 @@ noinst_HEADERS = \
zebra_LDADD = $(otherobj) ../lib/libfrr.la $(LIBCAP)
testzebra_LDADD = ../lib/libfrr.la $(LIBCAP)
zebra_DEPENDENCIES = $(otherobj)
if SNMP
@ -88,7 +79,7 @@ EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_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_netlink.c zebra_mpls_openbsd.c zebra_mpls_null.c \
GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB
client : client_main.o ../lib/libfrr.la

View File

@ -48,7 +48,12 @@ zebra_test_ipv4 (int command, int type, char *prefix, char *gateway,
struct in_addr *gpnt;
str2prefix_ipv4 (prefix, &p);
inet_aton (gateway, &gate);
if (!inet_aton (gateway, &gate))
{
printf("Gateway specified: %s is illegal\n", gateway);
return;
}
gpnt = &gate;
api.vrf_id = VRF_DEFAULT;

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2015 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <vrf.h>
#include <prefix.h>
#include <rtadv.h>
#include <zebra_ns.h>
void interface_list (struct zebra_ns *zns)
{ return; }

View File

@ -1,62 +0,0 @@
/*
* Copyright (C) 2006 Sun Microsystems, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "zebra/rib.h"
#include "zebra/rt.h"
#include "zebra/ioctl.h"
void ifreq_set_name (struct ifreq *a, struct interface *b) { return; }
int if_set_prefix (struct interface *a, struct connected *b)
{
kernel_address_add_ipv4 (a, b);
return 0;
}
int if_unset_prefix (struct interface *a, struct connected *b)
{
kernel_address_delete_ipv4 (a, b);
return 0;
}
int if_prefix_add_ipv6 (struct interface *a, struct connected *b) { return 0; }
int if_prefix_delete_ipv6 (struct interface *a, struct connected *b) { return 0; }
int if_ioctl (u_long a, caddr_t b) { return 0; }
int if_set_flags (struct interface *a, uint64_t b) { return 0; }
int if_unset_flags (struct interface *a, uint64_t b) { return 0; }
void if_get_flags (struct interface *a) { return; }
#ifdef SOLARIS_IPV6
#pragma weak if_ioctl_ipv6 = if_ioctl
struct connected *if_lookup_linklocal(struct interface *a) { return 0; }
#define AF_IOCTL(af, request, buffer) \
((af) == AF_INET? if_ioctl(request, buffer) : \
if_ioctl_ipv6(request, buffer))
#else /* SOLARIS_IPV6 */
#define AF_IOCTL(af, request, buffer) if_ioctl(request, buffer)
#endif /* SOLARIS_IPV6 */

View File

@ -1,63 +0,0 @@
/*
* NULL kernel methods for testing.
* Copyright (C) 2006 Sun Microsystems, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <log.h>
#include "vty.h"
#include "zebra/zserv.h"
#include "zebra/rt.h"
#include "zebra/redistribute.h"
#include "zebra/connected.h"
#include "zebra/rt_netlink.h"
#include "zebra/rib.h"
int kernel_route_rib (struct prefix *a, struct prefix *b,
struct route_entry *old, struct route_entry *new) { return 0; }
int kernel_address_add_ipv4 (struct interface *a, struct connected *b)
{
zlog_debug ("%s", __func__);
SET_FLAG (b->conf, ZEBRA_IFC_REAL);
connected_add_ipv4 (a, 0, &b->address->u.prefix4, b->address->prefixlen,
(b->destination ? &b->destination->u.prefix4 : NULL),
NULL);
return 0;
}
int kernel_address_delete_ipv4 (struct interface *a, struct connected *b)
{
zlog_debug ("%s", __func__);
connected_delete_ipv4 (a, 0, &b->address->u.prefix4, b->address->prefixlen,
(b->destination ? &b->destination->u.prefix4 : NULL));
return 0;
}
int kernel_neigh_update (int a, int b, uint32_t c, char *d, int e)
{
return 0;
}
void kernel_init (struct zebra_ns *zns) { return; }
void kernel_terminate (struct zebra_ns *zns) { return; }
void route_read (struct zebra_ns *zns) { return; }
int kernel_get_ipmr_sg_stats (void *m) { return 0; }

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2006 Sun Microsystems, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "prefix.h"
#include "zebra/rtadv.h"
#include "zebra/irdp.h"
#include "zebra/interface.h"
#if defined (HAVE_RTADV)
void rtadv_config_write (struct vty *vty, struct interface *ifp) { return; }
#endif
void irdp_config_write (struct vty *vty, struct interface *ifp) { return; }
#ifdef HAVE_PROC_NET_DEV
void ifstat_update_proc (void) { return; }
#endif
#ifdef HAVE_NET_RT_IFLIST
void ifstat_update_sysctl (void) { return; }
#endif

View File

@ -1,91 +0,0 @@
/*
* Copyright (C) 2006 Sun Microsystems, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "vty.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
void zebra_redistribute_add (int a, struct zserv *b, int c,
struct zebra_vrf *zvrf)
{ return; }
void zebra_redistribute_delete (int a, struct zserv *b, int c,
struct zebra_vrf *zvrf)
{ return; }
void zebra_redistribute_default_add (int a, struct zserv *b, int c,
struct zebra_vrf *zvrf)
{ return; }
void zebra_redistribute_default_delete (int a, struct zserv *b, int c,
struct zebra_vrf *zvrf)
{ return; }
void redistribute_update (struct prefix *a, struct prefix *b,
struct route_entry *c, struct route_entry *d)
{ return; }
void redistribute_delete (struct prefix *a, struct prefix *b, struct route_entry *c)
{ return; }
void zebra_interface_up_update (struct interface *a)
{ return; }
void zebra_interface_down_update (struct interface *a)
{ return; }
void zebra_interface_add_update (struct interface *a)
{ return; }
void zebra_interface_delete_update (struct interface *a)
{ return; }
void zebra_interface_address_add_update (struct interface *a,
struct connected *b)
{ return; }
void zebra_interface_address_delete_update (struct interface *a,
struct connected *b)
{ return; }
/* Interface parameters update */
void zebra_interface_parameters_update (struct interface *ifp)
{ return; };
void zebra_interface_vrf_update_del (struct interface *a, vrf_id_t new_vrf_id)
{ return; }
void zebra_interface_vrf_update_add (struct interface *a, vrf_id_t old_vrf_id)
{ return; }
int zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance,
const char *rmap_name, int add)
{ return 0; }
int zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, const char *rmap_name)
{ return 0; }
int zebra_del_import_table_entry (struct route_node *rn, struct route_entry *re)
{ return 0; }
int is_zebra_import_table_enabled(afi_t afi, u_int32_t table_id)
{ return 0; }
int zebra_import_table_config(struct vty *vty)
{ return 0; }
void zebra_import_table_rm_update()
{ return; }

View File

@ -1,34 +0,0 @@
/*
* Copyright (C) 2015 Cumulus Networks, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <lib/prefix.h>
#include <rtadv.h>
#include <zebra_ns.h>
void zebra_interface_radv_set (struct zserv *client, int sock, u_short length,
struct zebra_vrf *zvrf, int enable)
{ return; }
void rtadv_init (struct zebra_ns *zns)
{ return; }
void rtadv_terminate (struct zebra_ns *zns)
{ return; }

View File

@ -1,339 +0,0 @@
/* main routine.
* Copyright (C) 1997, 98 Kunihiro Ishiguro
*
* 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <lib/version.h>
#include "getopt.h"
#include "command.h"
#include "thread.h"
#include "filter.h"
#include "memory.h"
#include "zebra_memory.h"
#include "memory_vty.h"
#include "prefix.h"
#include "log.h"
#include "privs.h"
#include "sigevent.h"
#include "vrf.h"
#include "zebra/rib.h"
#include "zebra/zebra_ns.h"
#include "zebra/zserv.h"
#include "zebra/zebra_vrf.h"
#include "zebra/debug.h"
#include "zebra/router-id.h"
#include "zebra/interface.h"
/* Zebra instance */
struct zebra_t zebrad =
{
.rtm_table_default = 0,
};
/* 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;
/* Pacify zclient.o in libfrr, which expects this variable. */
struct thread_master *master;
/* Command line options. */
struct option longopts[] =
{
{ "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 }
};
zebra_capabilities_t _caps_p [] =
{
ZCAP_NET_ADMIN,
ZCAP_SYS_ADMIN,
ZCAP_NET_RAW,
};
/* Default configuration file path. */
char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE;
/* Process ID saved for use by init system */
const char *pid_file = "testzebra.pid";
/* Help information display. */
static void
usage (char *progname, int status)
{
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
else
{
printf ("Usage : %s [OPTION...]\n\n"\
"Daemon which manages kernel routing table management and "\
"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 zebra 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"\
"-r, --rib_hold Set rib-queue hold time\n"\
"-v, --version Print program version\n"\
"-h, --help Display this help and exit\n"\
"\n"\
"Report bugs to %s\n", progname, FRR_BUG_ADDRESS);
}
exit (status);
}
static ifindex_t test_ifindex = 0;
/* testrib commands */
DEFUN (test_interface_state,
test_interface_state_cmd,
"state <up|down>",
"configure interface\n"
"up\n"
"down\n")
{
int idx_up_down = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
if (ifp->ifindex == IFINDEX_INTERNAL)
{
ifp->ifindex = ++test_ifindex;
ifp->mtu = 1500;
ifp->flags = IFF_BROADCAST|IFF_MULTICAST;
}
switch (argv[idx_up_down]->arg[0])
{
case 'u':
SET_FLAG (ifp->flags, IFF_UP);
if_add_update (ifp);
printf ("up\n");
break;
case 'd':
UNSET_FLAG (ifp->flags, IFF_UP);
if_delete_update (ifp);
printf ("down\n");
break;
default:
return CMD_WARNING;
}
return CMD_SUCCESS;
}
static void
test_cmd_init (void)
{
install_element (INTERFACE_NODE, &test_interface_state_cmd);
}
/* SIGHUP handler. */
static void
sighup (void)
{
zlog_info ("SIGHUP received");
/* Reload of config file. */
;
}
/* SIGINT handler. */
static void
sigint (void)
{
zlog_notice ("Terminating on signal");
exit (0);
}
/* SIGUSR1 handler. */
static void
sigusr1 (void)
{
zlog_rotate();
}
struct quagga_signal_t zebra_signals[] =
{
{
.signal = SIGHUP,
.handler = &sighup,
},
{
.signal = SIGUSR1,
.handler = &sigusr1,
},
{
.signal = SIGINT,
.handler = &sigint,
},
{
.signal = SIGTERM,
.handler = &sigint,
},
};
/* Main startup routine. */
int
main (int argc, char **argv)
{
char *p;
char *vty_addr = NULL;
int vty_port = 0;
int batch_mode = 0;
int daemon_mode = 0;
char *config_file = NULL;
char *progname;
struct thread thread;
/* Set umask before anything for security */
umask (0027);
/* preserve my name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
openzlog(progname, "ZEBRA", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
while (1)
{
int opt;
opt = getopt_long (argc, argv, "bdaf:hA:P:r:v", longopts, 0);
if (opt == EOF)
break;
switch (opt)
{
case 0:
break;
case 'b':
batch_mode = 1;
case 'd':
daemon_mode = 1;
break;
case 'a':
allow_delete =1;
break;
case 'f':
config_file = optarg;
break;
case 'A':
vty_addr = optarg;
break;
case 'P':
/* Deal with atoi() returning 0 on failure, and zebra not
listening on zebra port... */
if (strcmp(optarg, "0") == 0)
{
vty_port = 0;
break;
}
vty_port = atoi (optarg);
break;
case 'r':
rib_process_hold_time = atoi(optarg);
break;
case 'v':
print_version (progname);
exit (0);
break;
case 'h':
usage (progname, 0);
break;
default:
usage (progname, 1);
break;
}
}
/* port and conf file mandatory */
if (!vty_port || !config_file)
{
fprintf (stderr, "Error: --vty_port and --config_file arguments"
" are both required\n");
usage (progname, 1);
}
/* Make master thread emulator. */
zebrad.master = thread_master_create ();
/* Vty related initialize. */
signal_init (zebrad.master, array_size(zebra_signals), zebra_signals);
cmd_init (1);
vty_config_lockless ();
vty_init (zebrad.master);
memory_init ();
zebra_debug_init ();
zebra_if_init ();
test_cmd_init ();
/* Zebra related initialize. */
rib_init ();
access_list_init ();
/* Make kernel routing socket. */
zebra_vrf_init ();
zebra_vty_init();
/* Configuration file read*/
vty_read_config (config_file, config_default);
/* Clean up rib. */
rib_weed_tables ();
/* Exit when zebra is working in batch mode. */
if (batch_mode)
exit (0);
/* Daemonize. */
if (daemon_mode && daemon (0, 0) < 0)
{
perror("daemon start failed");
exit (1);
}
/* Needed for BSD routing socket. */
pid = getpid ();
/* Make vty server socket. */
vty_serv_sock (vty_addr, vty_port, "/tmp/test_zebra");
/* Print banner. */
zlog_notice ("Zebra %s starting: vty@%d", FRR_VERSION, vty_port);
while (thread_fetch (zebrad.master, &thread))
thread_call (&thread);
/* Not reached... */
return 0;
}

View File

@ -1,30 +0,0 @@
/**
* @copyright 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "prefix.h"
#include "if.h"
#include "zebra_ptm_redistribute.h"
void zebra_interface_bfd_update (struct interface *a, struct prefix *dp,
struct prefix *sp, int status, vrf_id_t vrf_id)
{ return; }
void zebra_bfd_peer_replay_req (void)
{ return; }

View File

@ -1,49 +0,0 @@
/* Zebra next hop tracking code
* Copyright (C) 2013 Cumulus Networks, Inc.
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "vty.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "zebra/zebra_rnh.h"
int zebra_rnh_ip_default_route = 0;
int zebra_rnh_ipv6_default_route = 0;
void
zebra_free_rnh (struct rnh *rnh)
{}
void zebra_evaluate_rnh (vrf_id_t vrfid, int family, int force, rnh_type_t type,
struct prefix *p)
{}
void zebra_print_rnh_table (vrf_id_t vrfid, int family, struct vty *vty,
rnh_type_t type)
{}
void zebra_register_rnh_static_nh(vrf_id_t vrfid, struct prefix *p, struct route_node *rn)
{}
void zebra_deregister_rnh_static_nh(vrf_id_t vrfid, struct prefix *p, struct route_node *rn)
{}
void zebra_deregister_rnh_static_nexthops (vrf_id_t vrfid, struct nexthop *nexthop,
struct route_node *rn)
{}

View File

@ -1,46 +0,0 @@
/*
* Copyright (C) 2015 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of Quagga.
*
* Quagga 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.
*
* Quagga 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <vrf.h>
#include <vty.h>
#include <zserv.h>
#include <zebra_ns.h>
#include <zebra_vrf.h>
#include <router-id.h>
int
zebra_server_send_message(struct zserv *client)
{ return 0; }
void zserv_create_header (struct stream *s, uint16_t cmd, vrf_id_t vrf_id)
{ return; }
int zsend_vrf_delete (struct zserv *zserv, struct zebra_vrf *zvrf)
{ return 0; }
int zsend_vrf_add (struct zserv *zserv, struct zebra_vrf *zvrf)
{ return 0; }
void router_id_init (struct zebra_vrf *zvrf)
{ return; }