if (bgp_route->inst_type == BGP_INSTANCE_TYPE_VIEW) {
SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
SET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
- } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED))
+ } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED) &&
+ !is_default_host_route(&bnc->node->p))
register_zebra_rnh(bnc, is_bgp_static_route);
+
if (pi && pi->nexthop != bnc) {
/* Unlink from existing nexthop cache, if any. This will also
* free
return CMD_WARNING_CONFIG_FAILED;
}
-#if CONFDATE > 20190402
-CPP_NOTICE("bgpd: time to remove undebug commands")
-#endif
-ALIAS_HIDDEN(no_debug_bgp_vnc,
- undebug_bgp_vnc_cmd,
- "undebug bgp vnc <rfapi-query|import-bi-attach|import-del-remote|verbose>",
- "Undebug\n"
- BGP_STR
- VNC_STR
- "rfapi query handling\n"
- "import BI atachment\n"
- "import delete remote routes\n"
- "verbose logging\n")
-
-
/***********************************************************************
* no debug bgp vnc all
***********************************************************************/
return CMD_SUCCESS;
}
-#if CONFDATE > 20190402
-CPP_NOTICE("bgpd: time to remove undebug commands")
-#endif
-ALIAS_HIDDEN (no_debug_bgp_vnc_all,
- undebug_bgp_vnc_all_cmd,
- "undebug all bgp vnc",
- "Undebug\n"
- "Disable all VNC debugging\n"
- BGP_STR
- VNC_STR)
-
/***********************************************************************
* show/save
***********************************************************************/
install_element(CONFIG_NODE, &debug_bgp_vnc_cmd);
install_element(ENABLE_NODE, &no_debug_bgp_vnc_cmd);
install_element(CONFIG_NODE, &no_debug_bgp_vnc_cmd);
- install_element(ENABLE_NODE, &undebug_bgp_vnc_cmd);
- install_element(CONFIG_NODE, &undebug_bgp_vnc_cmd);
install_element(ENABLE_NODE, &no_debug_bgp_vnc_all_cmd);
install_element(CONFIG_NODE, &no_debug_bgp_vnc_all_cmd);
- install_element(ENABLE_NODE, &undebug_bgp_vnc_all_cmd);
- install_element(CONFIG_NODE, &undebug_bgp_vnc_all_cmd);
}
DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info")
-int bfd_debug = 0;
-struct bfd_gbl bfd_gbl;
+static int bfd_debug = 0;
+static struct bfd_gbl bfd_gbl;
/*
* bfd_gbl_init - Initialize the BFD global structure
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname")
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name")
-struct list *dist_ctx_list;
+static struct list *dist_ctx_list;
static struct distribute *distribute_new(void)
{
/*
* Global shared hash table holding reference text for all defined errors.
*/
-pthread_mutex_t refs_mtx = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t refs_mtx = PTHREAD_MUTEX_INITIALIZER;
struct hash *refs;
static bool ferr_hash_cmp(const void *a, const void *b)
void init_cmdgraph(struct vty *, struct graph **);
/** shim interface commands **/
-struct graph *nodegraph = NULL, *nodegraph_free = NULL;
+static struct graph *nodegraph = NULL, *nodegraph_free = NULL;
#define check_nodegraph() \
do { \
DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket")
DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index")
-pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct list *_hashes;
struct hash *hash_create_size(unsigned int size,
DEFINE_HOOK(if_add, (struct interface * ifp), (ifp))
DEFINE_KOOH(if_del, (struct interface * ifp), (ifp))
-/* List of interfaces in only the default VRF */
-int ptm_enable = 0;
-
/* Compare interface names, returning an integer greater than, equal to, or
* less than 0, (following the strcmp convention), according to the
* relationship between ifp1 and ifp2. Interface names consist of an
DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map")
DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name")
-struct list *if_rmap_ctx_list;
+static struct list *if_rmap_ctx_list;
static struct if_rmap *if_rmap_new(void)
{
#include "queue.h"
#include "imsg.h"
-int imsg_fd_overhead = 0;
+static int imsg_fd_overhead = 0;
-int imsg_get_fd(struct imsgbuf *);
+static int imsg_get_fd(struct imsgbuf *);
#ifndef __OpenBSD__
/*
DEFINE_QOBJ_TYPE(key)
/* Master list of key chain. */
-struct list *keychain_list;
+static struct list *keychain_list;
static struct keychain *keychain_new(void)
{
bool zlog_startup_stderr = true;
/* lock protecting zlog_default for mt-safe zlog */
-pthread_mutex_t loglock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t loglock = PTHREAD_MUTEX_INITIALIZER;
const char *zlog_priority[] = {
"emergencies", "alerts", "critical", "errors", "warnings",
RB_GENERATE(nhgc_entry_head, nexthop_group_cmd, nhgc_entry,
nexthop_group_cmd_compare)
-struct nhgc_entry_head nhgc_entries;
+static struct nhgc_entry_head nhgc_entries;
static inline int
nexthop_group_cmd_compare(const struct nexthop_group_cmd *nhgc1,
return 0;
}
+static inline int is_default_host_route(struct prefix *p)
+{
+ if (p->family == AF_INET) {
+ return (p->u.prefix4.s_addr == INADDR_ANY &&
+ p->prefixlen == IPV4_MAX_BITLEN);
+ } else if (p->family == AF_INET6) {
+ return ((!memcmp(&p->u.prefix6, &in6addr_any,
+ sizeof(struct in6_addr))) &&
+ p->prefixlen == IPV6_MAX_BITLEN);
+ }
+ return 0;
+}
+
#ifdef __cplusplus
}
#endif
/* master signals descriptor struct */
-struct quagga_sigevent_master_t {
+static struct quagga_sigevent_master_t {
struct thread *t;
struct quagga_signal_t *signals;
} while (0);
/* control variable for initializer */
-pthread_once_t init_once = PTHREAD_ONCE_INIT;
+static pthread_once_t init_once = PTHREAD_ONCE_INIT;
pthread_key_t thread_current;
-pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct list *masters;
static void thread_free(struct thread_master *master, struct thread *thread);
static void vty_out_cpu_thread_history(struct vty *vty,
struct cpu_thread_history *a)
{
- vty_out(vty, "%5"PRIdFAST32" %10lu.%03lu %9"PRIuFAST32
- " %8lu %9lu %8lu %9lu", a->total_active,
- a->cpu.total / 1000, a->cpu.total % 1000, a->total_calls,
- a->cpu.total / a->total_calls, a->cpu.max,
+ vty_out(vty, "%5zu %10zu.%03lu %9zu %8zu %9zu %8lu %9lu",
+ a->total_active, a->cpu.total / 1000, a->cpu.total % 1000,
+ a->total_calls, a->cpu.total / a->total_calls, a->cpu.max,
a->real.total / a->total_calls, a->real.max);
vty_out(vty, " %c%c%c%c%c %s\n",
a->types & (1 << THREAD_READ) ? 'R' : ' ',
* Turn on/off debug code
* for vrf.
*/
-int debug_vrf = 0;
+static int debug_vrf = 0;
/* Holding VRF hooks */
struct vrf_master {
static int no_password_check = 0;
/* Integrated configuration file path */
-char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
+static char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
static int do_log_commands = 0;
#endif
/* Exported variables */
-extern char integrate_default[];
extern struct vty *vty_exclusive_lock;
/* Prototypes. */
/* Prototype for event manager. */
static void zclient_event(enum event, struct zclient *);
+struct zclient_options zclient_options_default = {.receive_notify = false};
+
struct sockaddr_storage zclient_addr;
socklen_t zclient_addr_len;
/* This file local debug flag. */
-int zclient_debug = 0;
-
-struct zclient_options zclient_options_default = {.receive_notify = false};
+static int zclient_debug;
/* Allocate zclient structure. */
struct zclient *zclient_new(struct thread_master *master,
switch (note) {
case ZAPI_RULE_FAIL_INSTALL:
pbrms->installed &= ~installed;
- DEBUGD(&pbr_dbg_zebra, "%s: Received RULE_FAIL_INSTALL: %lu",
+ DEBUGD(&pbr_dbg_zebra,
+ "%s: Received RULE_FAIL_INSTALL: %" PRIu64,
__PRETTY_FUNCTION__, pbrms->installed);
break;
case ZAPI_RULE_INSTALLED:
pbrms->installed |= installed;
- DEBUGD(&pbr_dbg_zebra, "%s: Received RULE_INSTALLED: %lu",
+ DEBUGD(&pbr_dbg_zebra, "%s: Received RULE_INSTALLED: %" PRIu64,
__PRETTY_FUNCTION__, pbrms->installed);
break;
case ZAPI_RULE_FAIL_REMOVE:
case ZAPI_RULE_REMOVED:
pbrms->installed &= ~installed;
- DEBUGD(&pbr_dbg_zebra, "%s: Received RULE REMOVED: %lu",
+ DEBUGD(&pbr_dbg_zebra, "%s: Received RULE REMOVED: %" PRIu64,
__PRETTY_FUNCTION__, pbrms->installed);
break;
}
return CMD_WARNING;
}
- if (pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) {
+ if (!pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) {
vty_out(vty,
"Failure querying RIB nexthop for unicast address %s\n",
addr_str);
return CMD_SUCCESS;
}
-#if CONFDATE > 20190402
-CPP_NOTICE("bgpd: time to remove undebug commands")
-#endif
-ALIAS_HIDDEN (no_debug_msdp,
- undebug_msdp_cmd,
- "undebug msdp",
- UNDEBUG_STR DEBUG_MSDP_STR)
-
DEFUN (debug_msdp_events,
debug_msdp_events_cmd,
"debug msdp events",
return CMD_SUCCESS;
}
-#if CONFDATE > 20190402
-CPP_NOTICE("bgpd: time to remove undebug commands")
-#endif
-ALIAS_HIDDEN (no_debug_msdp_events,
- undebug_msdp_events_cmd,
- "undebug msdp events",
- UNDEBUG_STR
- DEBUG_MSDP_STR
- DEBUG_MSDP_EVENTS_STR)
-
DEFUN (debug_msdp_packets,
debug_msdp_packets_cmd,
"debug msdp packets",
return CMD_SUCCESS;
}
-#if CONFDATE > 20190402
-CPP_NOTICE("bgpd: time to remove undebug commands")
-#endif
-ALIAS_HIDDEN (no_debug_msdp_packets,
- undebug_msdp_packets_cmd,
- "undebug msdp packets",
- UNDEBUG_STR
- DEBUG_MSDP_STR
- DEBUG_MSDP_PACKETS_STR)
-
DEFUN (debug_mtrace,
debug_mtrace_cmd,
"debug mtrace",
install_element(ENABLE_NODE, &no_debug_pim_zebra_cmd);
install_element(ENABLE_NODE, &debug_msdp_cmd);
install_element(ENABLE_NODE, &no_debug_msdp_cmd);
- install_element(ENABLE_NODE, &undebug_msdp_cmd);
install_element(ENABLE_NODE, &debug_msdp_events_cmd);
install_element(ENABLE_NODE, &no_debug_msdp_events_cmd);
- install_element(ENABLE_NODE, &undebug_msdp_events_cmd);
install_element(ENABLE_NODE, &debug_msdp_packets_cmd);
install_element(ENABLE_NODE, &no_debug_msdp_packets_cmd);
- install_element(ENABLE_NODE, &undebug_msdp_packets_cmd);
install_element(ENABLE_NODE, &debug_mtrace_cmd);
install_element(ENABLE_NODE, &no_debug_mtrace_cmd);
install_element(CONFIG_NODE, &no_debug_pim_zebra_cmd);
install_element(CONFIG_NODE, &debug_msdp_cmd);
install_element(CONFIG_NODE, &no_debug_msdp_cmd);
- install_element(CONFIG_NODE, &undebug_msdp_cmd);
install_element(CONFIG_NODE, &debug_msdp_events_cmd);
install_element(CONFIG_NODE, &no_debug_msdp_events_cmd);
- install_element(CONFIG_NODE, &undebug_msdp_events_cmd);
install_element(CONFIG_NODE, &debug_msdp_packets_cmd);
install_element(CONFIG_NODE, &no_debug_msdp_packets_cmd);
- install_element(CONFIG_NODE, &undebug_msdp_packets_cmd);
install_element(CONFIG_NODE, &debug_mtrace_cmd);
install_element(CONFIG_NODE, &no_debug_mtrace_cmd);
struct pim_nexthop nexthop;
struct interface *ifp_in;
struct in_addr nh_addr;
- int ret;
char nexthop_str[INET_ADDRSTRLEN];
nh_addr.s_addr = 0;
memset(&nexthop, 0, sizeof(nexthop));
- ret = pim_nexthop_lookup(pim, &nexthop, mtracep->src_addr, 1);
-
- if (ret != 0) {
+ if (!pim_nexthop_lookup(pim, &nexthop, mtracep->src_addr, 1)) {
if (PIM_DEBUG_MTRACE)
zlog_debug("mtrace not found neighbor");
return false;
if (interface == NULL) {
memset(&nexthop, 0, sizeof(nexthop));
- ret = pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0);
-
- if (ret != 0) {
+ if (!pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0)) {
close(fd);
if (PIM_DEBUG_MTRACE)
zlog_warn(
struct igmp_mtrace *mtracep, size_t mtrace_len)
{
struct pim_nexthop nexthop;
- int ret;
mtracep->type = PIM_IGMP_MTRACE_RESPONSE;
} else {
memset(&nexthop, 0, sizeof(nexthop));
/* TODO: should use unicast rib lookup */
- ret = pim_nexthop_lookup(pim, &nexthop, mtracep->rsp_addr, 1);
-
- if (ret != 0) {
+ if (!pim_nexthop_lookup(pim, &nexthop, mtracep->rsp_addr, 1)) {
if (PIM_DEBUG_MTRACE)
zlog_warn(
"Dropped response qid=%ud, no route to "
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
// No if channel, but upstream we are at the RP.
if (pim_nexthop_lookup(pim_ifp->pim, &source,
- up->upstream_register, 0)
- == 0) {
+ up->upstream_register, 0)) {
pim_register_stop_send(source.interface, &sg,
pim_ifp->primary_address,
up->upstream_register);
} else {
if (I_am_RP(pim_ifp->pim, up->sg.grp)) {
if (pim_nexthop_lookup(pim_ifp->pim, &source,
- up->upstream_register, 0)
- == 0)
+ up->upstream_register,
+ 0))
pim_register_stop_send(
source.interface, &sg,
pim_ifp->primary_address,
Upon PIM neighbor UP, iterate all RPs and update
nexthop cache with this neighbor.
*/
- pim_resolve_rp_nh(pim_ifp->pim);
+ pim_resolve_rp_nh(pim_ifp->pim, neigh);
pim_rp_setup(pim_ifp->pim);
}
}
-/* This API is used to traverse nexthop cache of RPF addr
- of upstream entry whose IPv4 nexthop address is in
- unresolved state and due to event like pim neighbor
- UP event if it can be resolved.
-*/
-void pim_resolve_upstream_nh(struct pim_instance *pim, struct prefix *nht_p)
-{
- struct nexthop *nh_node = NULL;
- struct pim_nexthop_cache pnc;
- struct pim_neighbor *nbr = NULL;
-
- memset(&pnc, 0, sizeof(struct pim_nexthop_cache));
- if (!pim_find_or_track_nexthop(pim, nht_p, NULL, NULL, &pnc))
- return;
-
- for (nh_node = pnc.nexthop; nh_node; nh_node = nh_node->next) {
- if (nh_node->gate.ipv4.s_addr != 0)
- continue;
-
- struct interface *ifp1 =
- if_lookup_by_index(nh_node->ifindex, pim->vrf_id);
- nbr = pim_neighbor_find_if(ifp1);
- if (!nbr)
- continue;
-
- nh_node->gate.ipv4 = nbr->source_addr;
- if (PIM_DEBUG_PIM_NHT) {
- char str[PREFIX_STRLEN];
- char str1[INET_ADDRSTRLEN];
- pim_inet4_dump("<nht_nbr?>", nbr->source_addr, str1,
- sizeof(str1));
- pim_addr_dump("<nht_addr?>", nht_p, str, sizeof(str));
- zlog_debug(
- "%s: addr %s new nexthop addr %s interface %s",
- __PRETTY_FUNCTION__, str, str1, ifp1->name);
- }
- }
-}
-
/* Update Upstream nexthop info based on Nexthop update received from Zebra.*/
static int pim_update_upstream_nh_helper(struct hash_bucket *bucket, void *arg)
{
struct prefix *grp, int neighbor_needed);
void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,
struct pim_nexthop_cache *pnc, int command);
-void pim_resolve_upstream_nh(struct pim_instance *pim, struct prefix *nht_p);
int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,
struct prefix *src, struct prefix *grp);
void pim_rp_nexthop_del(struct rp_info *rp_info);
}
}
-void pim_resolve_rp_nh(struct pim_instance *pim)
+void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
{
struct listnode *node = NULL;
struct rp_info *rp_info = NULL;
struct nexthop *nh_node = NULL;
struct prefix nht_p;
struct pim_nexthop_cache pnc;
- struct pim_neighbor *nbr = NULL;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
struct interface *ifp1 = if_lookup_by_index(
nh_node->ifindex, pim->vrf_id);
- nbr = pim_neighbor_find_if(ifp1);
- if (!nbr)
+
+ if (nbr->interface != ifp1)
continue;
nh_node->gate.ipv4 = nbr->source_addr;
void pim_rp_show_information(struct pim_instance *pim, struct vty *vty,
bool uj);
-void pim_resolve_rp_nh(struct pim_instance *pim);
+void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr);
int pim_rp_list_cmp(void *v1, void *v2);
struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
const struct prefix *group);
pim->last_route_change_time);
}
-int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
- struct in_addr addr, int neighbor_needed)
+bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
+ struct in_addr addr, int neighbor_needed)
{
struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
struct pim_neighbor *nbr = NULL;
* it will never work
*/
if (addr.s_addr == INADDR_NONE)
- return -1;
+ return false;
if ((nexthop->last_lookup.s_addr == addr.s_addr)
&& (nexthop->last_lookup_time > pim->last_route_change_time)) {
pim->last_route_change_time, nexthop_str);
}
pim->nexthop_lookups_avoided++;
- return 0;
+ return true;
} else {
if (PIM_DEBUG_TRACE) {
char addr_str[INET_ADDRSTRLEN];
zlog_warn(
"%s %s: could not find nexthop ifindex for address %s",
__FILE__, __PRETTY_FUNCTION__, addr_str);
- return -1;
+ return false;
}
while (!found && (i < num_ifindex)) {
nexthop->last_lookup = addr;
nexthop->last_lookup_time = pim_time_monotonic_usec();
nexthop->nbr = nbr;
- return 0;
+ return true;
} else
- return -1;
+ return false;
}
static int nexthop_mismatch(const struct pim_nexthop *nh1,
unsigned int pim_rpf_hash_key(void *arg);
bool pim_rpf_equal(const void *arg1, const void *arg2);
-int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
- struct in_addr addr, int neighbor_needed);
+bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
+ struct in_addr addr, int neighbor_needed);
enum pim_rpf_result pim_rpf_update(struct pim_instance *pim,
struct pim_upstream *up, struct pim_rpf *old,
uint8_t is_new);
}
if (copylen > destlen) {
- zlog_warn("%s: destination buffer too small (%lu vs %lu)",
- __func__, copylen, destlen);
+ zlog_warn(
+ "%s: destination buffer too small (%zu vs %zu)",
+ __func__, copylen, destlen);
memcpy(dest, sap, destlen);
} else
memcpy(dest, sap, copylen);
if (copylen > 0 && dest != NULL && sdl->sdl_family == AF_LINK) {
if (copylen > IFNAMSIZ) {
- zlog_warn("%s: destination buffer too small (%lu vs %d)",
- __func__, copylen, IFNAMSIZ);
+ zlog_warn(
+ "%s: destination buffer too small (%zu vs %d)",
+ __func__, copylen, IFNAMSIZ);
memcpy(dest, sdl->sdl_data, IFNAMSIZ);
dest[IFNAMSIZ] = 0;
*destlen = IFNAMSIZ;