Merge pull request #3529 from donaldsharp/some_integration

Cleanup of some PIM, very early start of MLAG integration info zebra
This commit is contained in:
Jafar Al-Gharaibeh 2019-01-04 14:20:22 -05:00 committed by GitHub
commit e4587bc559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 472 additions and 213 deletions

41
lib/mlag.c Normal file
View File

@ -0,0 +1,41 @@
/* mlag generic code.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR 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.
*
* FRR 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 FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <zebra.h>
#include <mlag.h>
char *mlag_role2str(enum mlag_role role, char *buf, size_t size)
{
switch (role) {
case MLAG_ROLE_NONE:
snprintf(buf, size, "NONE");
break;
case MLAG_ROLE_PRIMARY:
snprintf(buf, size, "PRIMARY");
break;
case MLAG_ROLE_SECONDARY:
snprintf(buf, size, "SECONDARY");
break;
}
return buf;
}

32
lib/mlag.h Normal file
View File

@ -0,0 +1,32 @@
/* mlag header.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR 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.
*
* FRR 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 FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __MLAG_H__
#define __MLAG_H__
enum mlag_role {
MLAG_ROLE_NONE,
MLAG_ROLE_PRIMARY,
MLAG_ROLE_SECONDARY
};
extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size);
#endif

View File

@ -44,6 +44,7 @@ lib_libfrr_la_SOURCES = \
lib/md5.c \
lib/memory.c \
lib/memory_vty.c \
lib/mlag.c \
lib/module.c \
lib/mpls.c \
lib/network.c \
@ -134,6 +135,7 @@ pkginclude_HEADERS += \
lib/bitfield.h \
lib/buffer.h \
lib/checksum.h \
lib/mlag.h \
lib/command.h \
lib/command_graph.h \
lib/command_match.h \

View File

@ -2355,6 +2355,7 @@ static void zclient_capability_decode(int command, struct zclient *zclient,
STREAM_GETC(s, mpls_enabled);
cap.mpls_enabled = !!mpls_enabled;
STREAM_GETL(s, cap.ecmp);
STREAM_GETC(s, cap.role);
if (zclient->zebra_capabilities)
(*zclient->zebra_capabilities)(&cap);

View File

@ -36,6 +36,8 @@
/* For union pw_protocol_fields */
#include "pw.h"
#include "mlag.h"
/* For input/output buffer to zebra. */
#define ZEBRA_MAX_PACKET_SIZ 16384
@ -171,6 +173,7 @@ struct redist_proto {
struct zclient_capabilities {
uint32_t ecmp;
bool mpls_enabled;
enum mlag_role role;
};
/* Structure for the zebra client. */

View File

@ -569,7 +569,7 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch, int interval)
ch->interface->name);
}
thread_add_timer(master, on_assert_timer, ch, interval,
thread_add_timer(router->master, on_assert_timer, ch, interval,
&ch->t_ifassert_timer);
}

View File

@ -2646,7 +2646,7 @@ static void show_rpf_refresh_stats(struct vty *vty, struct pim_instance *pim,
if (json) {
json_object_int_add(json, "rpfCacheRefreshDelayMsecs",
qpim_rpf_cache_refresh_delay_msec);
router->rpf_cache_refresh_delay_msec);
json_object_int_add(
json, "rpfCacheRefreshTimer",
pim_time_timer_remain_msec(pim->rpf_cache_refresher));
@ -2669,7 +2669,7 @@ static void show_rpf_refresh_stats(struct vty *vty, struct pim_instance *pim,
"RPF Cache Refresh Last: %s\n"
"Nexthop Lookups: %lld\n"
"Nexthop Lookups Avoided: %lld\n",
qpim_rpf_cache_refresh_delay_msec,
router->rpf_cache_refresh_delay_msec,
pim_time_timer_remain_msec(pim->rpf_cache_refresher),
(long long)pim->rpf_cache_refresh_requests,
(long long)pim->rpf_cache_refresh_events,
@ -4408,9 +4408,12 @@ static void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
struct vrf *vrf = pim->vrf;
time_t now = pim_time_monotonic_sec();
char uptime[10];
char mlag_role[80];
pim = vrf->info;
vty_out(vty, "Router MLAG Role: %s\n",
mlag_role2str(router->role, mlag_role, sizeof(mlag_role)));
vty_out(vty, "Mroute socket descriptor:");
vty_out(vty, " %d(%s)\n", pim->mroute_socket, vrf->name);
@ -4428,7 +4431,7 @@ static void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
vty_out(vty, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS);
vty_out(vty, "\n");
vty_out(vty, "Upstream Join Timer: %d secs\n", qpim_t_periodic);
vty_out(vty, "Upstream Join Timer: %d secs\n", router->t_periodic);
vty_out(vty, "Join/Prune Holdtime: %d secs\n", PIM_JP_HOLDTIME);
vty_out(vty, "PIM ECMP: %s\n", pim->ecmp_enable ? "Enable" : "Disable");
vty_out(vty, "PIM ECMP Rebalance: %s\n",
@ -5229,7 +5232,7 @@ DEFUN (ip_pim_joinprune_time,
"Seconds\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_t_periodic = atoi(argv[3]->arg);
router->t_periodic = atoi(argv[3]->arg);
return CMD_SUCCESS;
}
@ -5243,7 +5246,7 @@ DEFUN (no_ip_pim_joinprune_time,
"Seconds\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_t_periodic = PIM_DEFAULT_T_PERIODIC;
router->t_periodic = PIM_DEFAULT_T_PERIODIC;
return CMD_SUCCESS;
}
@ -5256,7 +5259,7 @@ DEFUN (ip_pim_register_suppress,
"Seconds\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_register_suppress_time = atoi(argv[3]->arg);
router->register_suppress_time = atoi(argv[3]->arg);
return CMD_SUCCESS;
}
@ -5270,7 +5273,7 @@ DEFUN (no_ip_pim_register_suppress,
"Seconds\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
router->register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
return CMD_SUCCESS;
}
@ -5339,7 +5342,7 @@ DEFUN (ip_pim_packets,
"Number of packets\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_packet_process = atoi(argv[3]->arg);
router->packet_process = atoi(argv[3]->arg);
return CMD_SUCCESS;
}
@ -5353,7 +5356,7 @@ DEFUN (no_ip_pim_packets,
"Number of packets\n")
{
PIM_DECLVAR_CONTEXT(vrf, pim);
qpim_packet_process = PIM_DEFAULT_PACKET_PROCESS;
router->packet_process = PIM_DEFAULT_PACKET_PROCESS;
return CMD_SUCCESS;
}

View File

@ -1157,7 +1157,7 @@ long pim_if_t_suppressed_msec(struct interface *ifp)
/* t_suppressed = t_periodic * rand(1.1, 1.4) */
ramount = 1100 + (random() % (1400 - 1100 + 1));
t_suppressed_msec = qpim_t_periodic * ramount;
t_suppressed_msec = router->t_periodic * ramount;
return t_suppressed_msec;
}

View File

@ -415,7 +415,7 @@ void reset_ifassert_state(struct pim_ifchannel *ch)
THREAD_OFF(ch->t_ifassert_timer);
pim_ifassert_winner_set(ch, PIM_IFASSERT_NOINFO, any,
qpim_infinite_assert_metric);
router->infinite_assert_metric);
}
struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
@ -889,8 +889,8 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,
}
if (holdtime != 0xFFFF) {
thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
&ch->t_ifjoin_expiry_timer);
thread_add_timer(router->master, on_ifjoin_expiry_timer, ch,
holdtime, &ch->t_ifjoin_expiry_timer);
}
}
@ -945,11 +945,12 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream,
THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
THREAD_OFF(ch->t_ifjoin_expiry_timer);
thread_add_timer_msec(
master, on_ifjoin_prune_pending_timer, ch,
jp_override_interval_msec,
router->master, on_ifjoin_prune_pending_timer,
ch, jp_override_interval_msec,
&ch->t_ifjoin_prune_pending_timer);
thread_add_timer(master, on_ifjoin_expiry_timer, ch,
holdtime, &ch->t_ifjoin_expiry_timer);
thread_add_timer(router->master, on_ifjoin_expiry_timer,
ch, holdtime,
&ch->t_ifjoin_expiry_timer);
pim_upstream_update_join_desired(pim_ifp->pim,
ch->upstream);
}
@ -973,31 +974,35 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream,
be taken not to use "ch" afterwards since it would be
deleted. */
THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
thread_add_timer_msec(master, on_ifjoin_prune_pending_timer, ch,
thread_add_timer_msec(router->master,
on_ifjoin_prune_pending_timer, ch,
jp_override_interval_msec,
&ch->t_ifjoin_prune_pending_timer);
break;
case PIM_IFJOIN_PRUNE:
if (source_flags & PIM_ENCODE_RPT_BIT) {
THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
thread_add_timer(master, on_ifjoin_expiry_timer, ch,
holdtime, &ch->t_ifjoin_expiry_timer);
thread_add_timer(router->master, on_ifjoin_expiry_timer,
ch, holdtime,
&ch->t_ifjoin_expiry_timer);
}
break;
case PIM_IFJOIN_PRUNE_TMP:
if (source_flags & PIM_ENCODE_RPT_BIT) {
ch->ifjoin_state = PIM_IFJOIN_PRUNE;
THREAD_OFF(ch->t_ifjoin_expiry_timer);
thread_add_timer(master, on_ifjoin_expiry_timer, ch,
holdtime, &ch->t_ifjoin_expiry_timer);
thread_add_timer(router->master, on_ifjoin_expiry_timer,
ch, holdtime,
&ch->t_ifjoin_expiry_timer);
}
break;
case PIM_IFJOIN_PRUNE_PENDING_TMP:
if (source_flags & PIM_ENCODE_RPT_BIT) {
ch->ifjoin_state = PIM_IFJOIN_PRUNE_PENDING;
THREAD_OFF(ch->t_ifjoin_expiry_timer);
thread_add_timer(master, on_ifjoin_expiry_timer, ch,
holdtime, &ch->t_ifjoin_expiry_timer);
thread_add_timer(router->master, on_ifjoin_expiry_timer,
ch, holdtime,
&ch->t_ifjoin_expiry_timer);
}
break;
}

View File

@ -250,8 +250,8 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
other_querier_present_interval_msec % 1000);
}
thread_add_timer_msec(master, pim_igmp_other_querier_expire, igmp,
other_querier_present_interval_msec,
thread_add_timer_msec(router->master, pim_igmp_other_querier_expire,
igmp, other_querier_present_interval_msec,
&igmp->t_other_querier_timer);
}
@ -603,8 +603,8 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
startup_mode ? "startup" : "non-startup", igmp->fd);
}
igmp->t_igmp_query_timer = NULL;
thread_add_timer(master, pim_igmp_general_query, igmp, query_interval,
&igmp->t_igmp_query_timer);
thread_add_timer(router->master, pim_igmp_general_query, igmp,
query_interval, &igmp->t_igmp_query_timer);
}
void pim_igmp_general_query_off(struct igmp_sock *igmp)
@ -940,7 +940,7 @@ static void igmp_read_on(struct igmp_sock *igmp)
igmp->fd);
}
igmp->t_igmp_read = NULL;
thread_add_read(master, pim_igmp_read, igmp, igmp->fd,
thread_add_read(router->master, pim_igmp_read, igmp, igmp->fd,
&igmp->t_igmp_read);
}
@ -1067,8 +1067,8 @@ void igmp_group_timer_on(struct igmp_group *group, long interval_msec,
*/
zassert(group->group_filtermode_isexcl);
thread_add_timer_msec(master, igmp_group_timer, group, interval_msec,
&group->t_group_timer);
thread_add_timer_msec(router->master, igmp_group_timer, group,
interval_msec, &group->t_group_timer);
}
struct igmp_group *find_group_by_addr(struct igmp_sock *igmp,

View File

@ -214,8 +214,8 @@ static void igmp_source_timer_on(struct igmp_group *group,
source_str, group->group_igmp_sock->interface->name);
}
thread_add_timer_msec(master, igmp_source_timer, source, interval_msec,
&source->t_source_timer);
thread_add_timer_msec(router->master, igmp_source_timer, source,
interval_msec, &source->t_source_timer);
/*
RFC 3376: 6.3. IGMPv3 Source-Specific Forwarding Rules
@ -1294,7 +1294,8 @@ static void group_retransmit_timer_on(struct igmp_group *group)
igmp->interface->name);
}
thread_add_timer_msec(master, igmp_group_retransmit, group, lmqi_msec,
thread_add_timer_msec(router->master, igmp_group_retransmit, group,
lmqi_msec,
&group->t_group_query_retransmit_timer);
}

View File

@ -85,7 +85,7 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
pim->spt.switchover = PIM_SPT_IMMEDIATE;
pim->spt.plist = NULL;
pim_msdp_init(pim, master);
pim_msdp_init(pim, router->master);
snprintf(hash_name, 64, "PIM %s RPF Hash", vrf->name);
pim->rpf_hash = hash_create_size(256, pim_rpf_hash_key, pim_rpf_equal,
@ -101,9 +101,6 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
pim->send_v6_secondary = 1;
if (vrf->vrf_id == VRF_DEFAULT)
pimg = pim;
pim_rp_init(pim);
pim_oil_init(pim);
@ -132,9 +129,6 @@ static int pim_vrf_new(struct vrf *vrf)
vrf->info = (void *)pim;
if (vrf->vrf_id == VRF_DEFAULT)
pimg = pim;
pim_ssmpingd_init(pim);
return 0;
}

View File

@ -21,8 +21,11 @@
#ifndef __PIM_INSTANCE_H__
#define __PIM_INSTANCE_H__
#include <mlag.h>
#include "pim_str.h"
#include "pim_msdp.h"
#include "pim_assert.h"
#if defined(HAVE_LINUX_MROUTE_H)
#include <linux/mroute.h>
@ -35,13 +38,32 @@
#define MAXVIFS (256)
#endif
#endif
extern struct pim_instance *pimg; // Pim Global Instance
enum pim_spt_switchover {
PIM_SPT_IMMEDIATE,
PIM_SPT_INFINITY,
};
struct pim_router {
struct thread_master *master;
uint32_t debugs;
int t_periodic;
struct pim_assert_metric infinite_assert_metric;
long rpf_cache_refresh_delay_msec;
int32_t register_suppress_time;
int packet_process;
int32_t register_probe_time;
/*
* What is the default vrf that we work in
*/
vrf_id_t vrf_id;
enum mlag_role role;
};
/* Per VRF PIM DB */
struct pim_instance {
vrf_id_t vrf_id;

View File

@ -295,7 +295,7 @@ pim_macro_ch_my_assert_metric_eval(const struct pim_ifchannel *ch)
}
}
return qpim_infinite_assert_metric;
return router->infinite_assert_metric;
}
/*

View File

@ -109,7 +109,7 @@ int main(int argc, char **argv, char **envp)
}
}
master = frr_init();
pim_router_init();
/*
* Initializations
@ -157,7 +157,7 @@ int main(int argc, char **argv, char **envp)
"PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
#endif
frr_run(master);
frr_run(router->master);
/* never reached */
return 0;

View File

@ -708,7 +708,7 @@ static int mroute_read(struct thread *t)
result = pim_mroute_msg(pim, buf, rd, ifindex);
count++;
if (count % qpim_packet_process == 0)
if (count % router->packet_process == 0)
cont = 0;
}
/* Keep reading */
@ -720,7 +720,7 @@ done:
static void mroute_read_on(struct pim_instance *pim)
{
thread_add_read(master, mroute_read, pim, pim->mroute_socket,
thread_add_read(router->master, mroute_read, pim, pim->mroute_socket,
&pim->thread);
}

View File

@ -1523,8 +1523,8 @@ enum pim_msdp_err pim_msdp_mg_src_add(struct pim_instance *pim,
}
/*********************** MSDP feature APIs *********************************/
int pim_msdp_config_write_helper(struct pim_instance *pim, struct vty *vty,
const char *spaces)
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
const char *spaces)
{
struct listnode *mbrnode;
struct pim_msdp_mg_mbr *mbr;
@ -1553,11 +1553,6 @@ int pim_msdp_config_write_helper(struct pim_instance *pim, struct vty *vty,
return count;
}
int pim_msdp_config_write(struct vty *vty)
{
return pim_msdp_config_write_helper(pimg, vty, "");
}
/* Enable feature including active/periodic timers etc. on the first peer
* config. Till then MSDP should just stay quiet. */
static void pim_msdp_enable(struct pim_instance *pim)

View File

@ -232,9 +232,8 @@ void pim_msdp_peer_reset_tcp_conn(struct pim_msdp_peer *mp, const char *rc_str);
int pim_msdp_write(struct thread *thread);
char *pim_msdp_peer_key_dump(struct pim_msdp_peer *mp, char *buf, int buf_size,
bool long_format);
int pim_msdp_config_write(struct vty *vty);
int pim_msdp_config_write_helper(struct pim_instance *pim, struct vty *vty,
const char *spaces);
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
const char *spaces);
void pim_msdp_peer_pkt_txed(struct pim_msdp_peer *mp);
void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp,
struct prefix_sg *sg, struct in_addr rp);

View File

@ -79,7 +79,7 @@ static int pim_msdp_sock_accept(struct thread *thread)
return -1;
}
pim->msdp.listener.thread = NULL;
thread_add_read(master, pim_msdp_sock_accept, pim, accept_sock,
thread_add_read(router->master, pim_msdp_sock_accept, pim, accept_sock,
&pim->msdp.listener.thread);
/* accept client connection. */

View File

@ -255,8 +255,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)
neigh->interface->name);
}
thread_add_timer(master, on_neighbor_timer, neigh, neigh->holdtime,
&neigh->t_expire_timer);
thread_add_timer(router->master, on_neighbor_timer, neigh,
neigh->holdtime, &neigh->t_expire_timer);
}
static int on_neighbor_jp_timer(struct thread *t)
@ -277,8 +277,8 @@ static int on_neighbor_jp_timer(struct thread *t)
rpf.rpf_addr.u.prefix4 = neigh->source_addr;
pim_joinprune_send(&rpf, neigh->upstream_jp_agg);
thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
&neigh->jp_timer);
thread_add_timer(router->master, on_neighbor_jp_timer, neigh,
router->t_periodic, &neigh->jp_timer);
return 0;
}
@ -286,8 +286,8 @@ static int on_neighbor_jp_timer(struct thread *t)
static void pim_neighbor_start_jp_timer(struct pim_neighbor *neigh)
{
THREAD_TIMER_OFF(neigh->jp_timer);
thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
&neigh->jp_timer);
thread_add_timer(router->master, on_neighbor_jp_timer, neigh,
router->t_periodic, &neigh->jp_timer);
}
static struct pim_neighbor *

View File

@ -346,7 +346,7 @@ static int pim_sock_read(struct thread *t)
}
count++;
if (count % qpim_packet_process == 0)
if (count % router->packet_process == 0)
cont = 0;
}
@ -376,8 +376,8 @@ static void pim_sock_read_on(struct interface *ifp)
pim_ifp->pim_sock_fd);
}
pim_ifp->t_pim_sock_read = NULL;
thread_add_read(master, pim_sock_read, ifp, pim_ifp->pim_sock_fd,
&pim_ifp->t_pim_sock_read);
thread_add_read(router->master, pim_sock_read, ifp,
pim_ifp->pim_sock_fd, &pim_ifp->t_pim_sock_read);
}
static int pim_sock_open(struct interface *ifp)
@ -683,7 +683,7 @@ static void hello_resched(struct interface *ifp)
pim_ifp->pim_hello_period, ifp->name);
}
THREAD_OFF(pim_ifp->t_pim_hello_timer);
thread_add_timer(master, on_pim_hello_send, ifp,
thread_add_timer(router->master, on_pim_hello_send, ifp,
pim_ifp->pim_hello_period,
&pim_ifp->t_pim_hello_timer);
}
@ -796,8 +796,8 @@ void pim_hello_restart_triggered(struct interface *ifp)
random_msec, ifp->name);
}
thread_add_timer_msec(master, on_pim_hello_send, ifp, random_msec,
&pim_ifp->t_pim_hello_timer);
thread_add_timer_msec(router->master, on_pim_hello_send, ifp,
random_msec, &pim_ifp->t_pim_hello_timer);
}
int pim_sock_add(struct interface *ifp)

View File

@ -339,7 +339,7 @@ static int ssmpingd_sock_read(struct thread *t)
static void ssmpingd_read_on(struct ssmpingd_sock *ss)
{
thread_add_read(master, ssmpingd_sock_read, ss, ss->sock_fd,
thread_add_read(router->master, ssmpingd_sock_read, ss, ss->sock_fd,
&ss->t_sock_read);
}

View File

@ -308,7 +308,7 @@ void join_timer_start(struct pim_upstream *up)
if (PIM_DEBUG_PIM_EVENTS) {
zlog_debug(
"%s: starting %d sec timer for upstream (S,G)=%s",
__PRETTY_FUNCTION__, qpim_t_periodic,
__PRETTY_FUNCTION__, router->t_periodic,
up->sg_str);
}
}
@ -317,8 +317,8 @@ void join_timer_start(struct pim_upstream *up)
pim_jp_agg_add_group(nbr->upstream_jp_agg, up, 1);
else {
THREAD_OFF(up->t_join_timer);
thread_add_timer(master, on_join_timer, up, qpim_t_periodic,
&up->t_join_timer);
thread_add_timer(router->master, on_join_timer, up,
router->t_periodic, &up->t_join_timer);
}
pim_jp_agg_upstream_verification(up, true);
}
@ -346,7 +346,7 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up,
}
THREAD_OFF(up->t_join_timer);
thread_add_timer_msec(master, on_join_timer, up, interval_msec,
thread_add_timer_msec(router->master, on_join_timer, up, interval_msec,
&up->t_join_timer);
}
@ -647,9 +647,9 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,
up->rpf.source_nexthop.mrib_nexthop_addr.u.prefix4.s_addr =
PIM_NET_INADDR_ANY;
up->rpf.source_nexthop.mrib_metric_preference =
qpim_infinite_assert_metric.metric_preference;
router->infinite_assert_metric.metric_preference;
up->rpf.source_nexthop.mrib_route_metric =
qpim_infinite_assert_metric.route_metric;
router->infinite_assert_metric.route_metric;
up->rpf.rpf_addr.family = AF_INET;
up->rpf.rpf_addr.u.prefix4.s_addr = PIM_NET_INADDR_ANY;
@ -1124,8 +1124,8 @@ void pim_upstream_keep_alive_timer_start(struct pim_upstream *up, uint32_t time)
up->sg_str);
}
THREAD_OFF(up->t_ka_timer);
thread_add_timer(master, pim_upstream_keep_alive_timer, up, time,
&up->t_ka_timer);
thread_add_timer(router->master, pim_upstream_keep_alive_timer, up,
time, &up->t_ka_timer);
/* any time keepalive is started against a SG we will have to
* re-evaluate our active source database */
@ -1145,7 +1145,7 @@ static int pim_upstream_msdp_reg_timer(struct thread *t)
void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
{
THREAD_OFF(up->t_msdp_reg_timer);
thread_add_timer(master, pim_upstream_msdp_reg_timer, up,
thread_add_timer(router->master, pim_upstream_msdp_reg_timer, up,
PIM_MSDP_REG_RXED_PERIOD, &up->t_msdp_reg_timer);
pim_msdp_sa_local_update(up);
@ -1406,8 +1406,8 @@ void pim_upstream_start_register_stop_timer(struct pim_upstream *up,
"%s: (S,G)=%s Starting upstream register stop timer %d",
__PRETTY_FUNCTION__, up->sg_str, time);
}
thread_add_timer(master, pim_upstream_register_stop_timer, up, time,
&up->t_rs_timer);
thread_add_timer(router->master, pim_upstream_register_stop_timer, up,
time, &up->t_rs_timer);
}
int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
@ -1768,7 +1768,7 @@ void pim_upstream_init(struct pim_instance *pim)
snprintf(name, 64, "PIM %s Timer Wheel",
pim->vrf->name);
pim->upstream_sg_wheel =
wheel_init(master, 31000, 100, pim_upstream_hash_key,
wheel_init(router->master, 31000, 100, pim_upstream_hash_key,
pim_upstream_sg_running, name);
snprintf(name, 64, "PIM %s Upstream Hash",

View File

@ -126,13 +126,14 @@ struct pim_upstream {
*/
struct thread *t_ka_timer;
#define PIM_KEEPALIVE_PERIOD (210)
#define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
#define PIM_RP_KEEPALIVE_PERIOD \
(3 * router->register_suppress_time + router->register_probe_time)
/* on the RP we restart a timer to indicate if registers are being rxed
* for
* SG. This is needed by MSDP to determine its local SA cache */
struct thread *t_msdp_reg_timer;
#define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * qpim_register_suppress_time))
#define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * router->register_suppress_time))
int64_t state_transition; /* Record current state uptime */
};

View File

@ -163,7 +163,7 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
else
sprintf(spaces, "%s", " ");
writes += pim_msdp_config_write_helper(pim, vty, spaces);
writes += pim_msdp_config_write(pim, vty, spaces);
if (!pim->send_v6_secondary) {
vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
@ -172,15 +172,15 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
writes += pim_rp_config_write(pim, vty, spaces);
if (qpim_register_suppress_time
if (router->register_suppress_time
!= PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
vty_out(vty, "%sip pim register-suppress-time %d\n", spaces,
qpim_register_suppress_time);
router->register_suppress_time);
++writes;
}
if (qpim_t_periodic != PIM_DEFAULT_T_PERIODIC) {
if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
vty_out(vty, "%sip pim join-prune-interval %d\n", spaces,
qpim_t_periodic);
router->t_periodic);
++writes;
}
if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
@ -193,9 +193,9 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
pim->rp_keep_alive_time);
++writes;
}
if (qpim_packet_process != PIM_DEFAULT_PACKET_PROCESS) {
if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
vty_out(vty, "%sip pim packets %d\n", spaces,
qpim_packet_process);
router->packet_process);
++writes;
}
if (ssm->plist_name) {

View File

@ -727,11 +727,11 @@ void sched_rpf_cache_refresh(struct pim_instance *pim)
if (PIM_DEBUG_ZEBRA) {
zlog_debug("%s: triggering %ld msec timer", __PRETTY_FUNCTION__,
qpim_rpf_cache_refresh_delay_msec);
router->rpf_cache_refresh_delay_msec);
}
thread_add_timer_msec(master, on_rpf_cache_refresh, pim,
qpim_rpf_cache_refresh_delay_msec,
thread_add_timer_msec(router->master, on_rpf_cache_refresh, pim,
router->rpf_cache_refresh_delay_msec,
&pim->rpf_cache_refresher);
}
@ -740,14 +740,20 @@ static void pim_zebra_connected(struct zclient *zclient)
/* Send the client registration */
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
zclient_send_reg_requests(zclient, pimg->vrf_id);
zclient_send_reg_requests(zclient, router->vrf_id);
}
static void pim_zebra_capabilities(struct zclient_capabilities *cap)
{
router->role = cap->role;
}
void pim_zebra_init(void)
{
/* Socket for receiving updates from Zebra daemon */
zclient = zclient_new(master, &zclient_options_default);
zclient = zclient_new(router->master, &zclient_options_default);
zclient->zebra_capabilities = pim_zebra_capabilities;
zclient->zebra_connected = pim_zebra_connected;
zclient->router_id_update = pim_router_id_update_zebra;
zclient->interface_add = pim_zebra_if_add;

View File

@ -71,7 +71,7 @@ static int zclient_lookup_connect(struct thread *t)
/* Schedule connection with delay. */
static void zclient_lookup_sched(struct zclient *zlookup, int delay)
{
thread_add_timer(master, zclient_lookup_connect, zlookup, delay,
thread_add_timer(router->master, zclient_lookup_connect, zlookup, delay,
&zlookup->t_connect);
zlog_notice("%s: zclient lookup connection scheduled for %d seconds",
@ -81,7 +81,7 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay)
/* Schedule connection for now. */
static void zclient_lookup_sched_now(struct zclient *zlookup)
{
thread_add_event(master, zclient_lookup_connect, zlookup, 0,
thread_add_event(router->master, zclient_lookup_connect, zlookup, 0,
&zlookup->t_connect);
zlog_notice("%s: zclient lookup immediate connection scheduled",
@ -120,7 +120,7 @@ void zclient_lookup_free(void)
void zclient_lookup_new(void)
{
zlookup = zclient_new(master, &zclient_options_default);
zlookup = zclient_new(router->master, &zclient_options_default);
if (!zlookup) {
flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_new() failure",
__PRETTY_FUNCTION__);

View File

@ -47,17 +47,9 @@ const char *const PIM_ALL_ROUTERS = MCAST_ALL_ROUTERS;
const char *const PIM_ALL_PIM_ROUTERS = MCAST_ALL_PIM_ROUTERS;
const char *const PIM_ALL_IGMP_ROUTERS = MCAST_ALL_IGMP_ROUTERS;
struct thread_master *master = NULL;
uint32_t qpim_debugs = 0;
int qpim_t_periodic =
PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
struct pim_assert_metric qpim_infinite_assert_metric;
long qpim_rpf_cache_refresh_delay_msec = 50;
int qpim_packet_process = PIM_DEFAULT_PACKET_PROCESS;
struct pim_instance *pimg = NULL;
DEFINE_MTYPE_STATIC(PIMD, ROUTER, "PIM Router information");
int32_t qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
int32_t qpim_register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
struct pim_router *router = NULL;
void pim_prefix_list_update(struct prefix_list *plist)
{
@ -82,7 +74,41 @@ static void pim_free()
zclient_lookup_free();
}
void pim_init()
void pim_router_init(void)
{
router = XCALLOC(MTYPE_ROUTER, sizeof(*router));
router->debugs = 0;
router->master = frr_init();
router->t_periodic = PIM_DEFAULT_T_PERIODIC;
/*
RFC 4601: 4.6.3. Assert Metrics
assert_metric
infinite_assert_metric() {
return {1,infinity,infinity,0}
}
*/
router->infinite_assert_metric.rpt_bit_flag = 1;
router->infinite_assert_metric.metric_preference =
PIM_ASSERT_METRIC_PREFERENCE_MAX;
router->infinite_assert_metric.route_metric =
PIM_ASSERT_ROUTE_METRIC_MAX;
router->infinite_assert_metric.ip_address.s_addr = INADDR_ANY;
router->rpf_cache_refresh_delay_msec = 50;
router->register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
router->packet_process = PIM_DEFAULT_PACKET_PROCESS;
router->register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
router->vrf_id = VRF_DEFAULT;
}
void pim_router_terminate(void)
{
XFREE(MTYPE_ROUTER, router);
}
void pim_init(void)
{
if (!inet_aton(PIM_ALL_PIM_ROUTERS, &qpim_all_pim_routers_addr)) {
flog_err(
@ -94,20 +120,6 @@ void pim_init()
return;
}
/*
RFC 4601: 4.6.3. Assert Metrics
assert_metric
infinite_assert_metric() {
return {1,infinity,infinity,0}
}
*/
qpim_infinite_assert_metric.rpt_bit_flag = 1;
qpim_infinite_assert_metric.metric_preference =
PIM_ASSERT_METRIC_PREFERENCE_MAX;
qpim_infinite_assert_metric.route_metric = PIM_ASSERT_ROUTE_METRIC_MAX;
qpim_infinite_assert_metric.ip_address.s_addr = INADDR_ANY;
pim_cmd_init();
}
@ -130,5 +142,6 @@ void pim_terminate()
zclient_free(zclient);
}
pim_router_terminate();
frr_fini();
}

View File

@ -132,110 +132,125 @@ const char *const PIM_ALL_ROUTERS;
const char *const PIM_ALL_PIM_ROUTERS;
const char *const PIM_ALL_IGMP_ROUTERS;
extern struct thread_master *master;
extern struct pim_router *router;
extern struct zebra_privs_t pimd_privs;
uint32_t qpim_debugs;
struct in_addr qpim_all_pim_routers_addr;
int qpim_t_periodic; /* Period between Join/Prune Messages */
struct pim_assert_metric qpim_infinite_assert_metric;
long qpim_rpf_cache_refresh_delay_msec;
extern int qpim_packet_process;
extern uint8_t qpim_ecmp_enable;
extern uint8_t qpim_ecmp_rebalance_enable;
#define PIM_DEFAULT_PACKET_PROCESS 3
#define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2)
#define PIM_JP_HOLDTIME (router->t_periodic * 7 / 2)
/*
* Register-Stop Timer (RST(S,G))
* Default values
*/
extern int32_t qpim_register_suppress_time;
extern int32_t qpim_register_probe_time;
#define PIM_REGISTER_SUPPRESSION_TIME_DEFAULT (60)
#define PIM_REGISTER_PROBE_TIME_DEFAULT (5)
#define PIM_DEBUG_PIM_EVENTS (qpim_debugs & PIM_MASK_PIM_EVENTS)
#define PIM_DEBUG_PIM_EVENTS_DETAIL (qpim_debugs & PIM_MASK_PIM_EVENTS_DETAIL)
#define PIM_DEBUG_PIM_PACKETS (qpim_debugs & PIM_MASK_PIM_PACKETS)
#define PIM_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DEBUG_PIM_TRACE (qpim_debugs & PIM_MASK_PIM_TRACE)
#define PIM_DEBUG_PIM_TRACE_DETAIL (qpim_debugs & PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DEBUG_IGMP_EVENTS (qpim_debugs & PIM_MASK_IGMP_EVENTS)
#define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS)
#define PIM_DEBUG_IGMP_TRACE (qpim_debugs & PIM_MASK_IGMP_TRACE)
#define PIM_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs & PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DEBUG_ZEBRA (qpim_debugs & PIM_MASK_ZEBRA)
#define PIM_DEBUG_SSMPINGD (qpim_debugs & PIM_MASK_SSMPINGD)
#define PIM_DEBUG_MROUTE (qpim_debugs & PIM_MASK_MROUTE)
#define PIM_DEBUG_MROUTE_DETAIL (qpim_debugs & PIM_MASK_MROUTE_DETAIL)
#define PIM_DEBUG_PIM_HELLO (qpim_debugs & PIM_MASK_PIM_HELLO)
#define PIM_DEBUG_PIM_J_P (qpim_debugs & PIM_MASK_PIM_J_P)
#define PIM_DEBUG_PIM_REG (qpim_debugs & PIM_MASK_PIM_REG)
#define PIM_DEBUG_STATIC (qpim_debugs & PIM_MASK_STATIC)
#define PIM_DEBUG_MSDP_EVENTS (qpim_debugs & PIM_MASK_MSDP_EVENTS)
#define PIM_DEBUG_MSDP_PACKETS (qpim_debugs & PIM_MASK_MSDP_PACKETS)
#define PIM_DEBUG_MSDP_INTERNAL (qpim_debugs & PIM_MASK_MSDP_INTERNAL)
#define PIM_DEBUG_PIM_NHT (qpim_debugs & PIM_MASK_PIM_NHT)
#define PIM_DEBUG_PIM_NHT_DETAIL (qpim_debugs & PIM_MASK_PIM_NHT_DETAIL)
#define PIM_DEBUG_PIM_NHT_RP (qpim_debugs & PIM_MASK_PIM_NHT_RP)
#define PIM_DEBUG_MTRACE (qpim_debugs & PIM_MASK_MTRACE)
#define PIM_DEBUG_PIM_EVENTS (router->debugs & PIM_MASK_PIM_EVENTS)
#define PIM_DEBUG_PIM_EVENTS_DETAIL \
(router->debugs & PIM_MASK_PIM_EVENTS_DETAIL)
#define PIM_DEBUG_PIM_PACKETS (router->debugs & PIM_MASK_PIM_PACKETS)
#define PIM_DEBUG_PIM_PACKETDUMP_SEND \
(router->debugs & PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DEBUG_PIM_PACKETDUMP_RECV \
(router->debugs & PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DEBUG_PIM_TRACE (router->debugs & PIM_MASK_PIM_TRACE)
#define PIM_DEBUG_PIM_TRACE_DETAIL (router->debugs & PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DEBUG_IGMP_EVENTS (router->debugs & PIM_MASK_IGMP_EVENTS)
#define PIM_DEBUG_IGMP_PACKETS (router->debugs & PIM_MASK_IGMP_PACKETS)
#define PIM_DEBUG_IGMP_TRACE (router->debugs & PIM_MASK_IGMP_TRACE)
#define PIM_DEBUG_IGMP_TRACE_DETAIL \
(router->debugs & PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DEBUG_ZEBRA (router->debugs & PIM_MASK_ZEBRA)
#define PIM_DEBUG_SSMPINGD (router->debugs & PIM_MASK_SSMPINGD)
#define PIM_DEBUG_MROUTE (router->debugs & PIM_MASK_MROUTE)
#define PIM_DEBUG_MROUTE_DETAIL (router->debugs & PIM_MASK_MROUTE_DETAIL)
#define PIM_DEBUG_PIM_HELLO (router->debugs & PIM_MASK_PIM_HELLO)
#define PIM_DEBUG_PIM_J_P (router->debugs & PIM_MASK_PIM_J_P)
#define PIM_DEBUG_PIM_REG (router->debugs & PIM_MASK_PIM_REG)
#define PIM_DEBUG_STATIC (router->debugs & PIM_MASK_STATIC)
#define PIM_DEBUG_MSDP_EVENTS (router->debugs & PIM_MASK_MSDP_EVENTS)
#define PIM_DEBUG_MSDP_PACKETS (router->debugs & PIM_MASK_MSDP_PACKETS)
#define PIM_DEBUG_MSDP_INTERNAL (router->debugs & PIM_MASK_MSDP_INTERNAL)
#define PIM_DEBUG_PIM_NHT (router->debugs & PIM_MASK_PIM_NHT)
#define PIM_DEBUG_PIM_NHT_DETAIL (router->debugs & PIM_MASK_PIM_NHT_DETAIL)
#define PIM_DEBUG_PIM_NHT_RP (router->debugs & PIM_MASK_PIM_NHT_RP)
#define PIM_DEBUG_MTRACE (router->debugs & PIM_MASK_MTRACE)
#define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS | PIM_MASK_MSDP_EVENTS))
#define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS | PIM_MASK_MSDP_PACKETS))
#define PIM_DEBUG_TRACE (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))
#define PIM_DEBUG_EVENTS \
(router->debugs \
& (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS \
| PIM_MASK_MSDP_EVENTS))
#define PIM_DEBUG_PACKETS \
(router->debugs \
& (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS \
| PIM_MASK_MSDP_PACKETS))
#define PIM_DEBUG_TRACE \
(router->debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))
#define PIM_DO_DEBUG_PIM_EVENTS (qpim_debugs |= PIM_MASK_PIM_EVENTS)
#define PIM_DO_DEBUG_PIM_PACKETS (qpim_debugs |= PIM_MASK_PIM_PACKETS)
#define PIM_DO_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DO_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DO_DEBUG_PIM_TRACE (qpim_debugs |= PIM_MASK_PIM_TRACE)
#define PIM_DO_DEBUG_PIM_TRACE_DETAIL (qpim_debugs |= PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DO_DEBUG_IGMP_EVENTS (qpim_debugs |= PIM_MASK_IGMP_EVENTS)
#define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS)
#define PIM_DO_DEBUG_IGMP_TRACE (qpim_debugs |= PIM_MASK_IGMP_TRACE)
#define PIM_DO_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs |= PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DO_DEBUG_ZEBRA (qpim_debugs |= PIM_MASK_ZEBRA)
#define PIM_DO_DEBUG_SSMPINGD (qpim_debugs |= PIM_MASK_SSMPINGD)
#define PIM_DO_DEBUG_MROUTE (qpim_debugs |= PIM_MASK_MROUTE)
#define PIM_DO_DEBUG_MROUTE_DETAIL (qpim_debugs |= PIM_MASK_MROUTE_DETAIL)
#define PIM_DO_DEBUG_PIM_HELLO (qpim_debugs |= PIM_MASK_PIM_HELLO)
#define PIM_DO_DEBUG_PIM_J_P (qpim_debugs |= PIM_MASK_PIM_J_P)
#define PIM_DO_DEBUG_PIM_REG (qpim_debugs |= PIM_MASK_PIM_REG)
#define PIM_DO_DEBUG_STATIC (qpim_debugs |= PIM_MASK_STATIC)
#define PIM_DO_DEBUG_MSDP_EVENTS (qpim_debugs |= PIM_MASK_MSDP_EVENTS)
#define PIM_DO_DEBUG_MSDP_PACKETS (qpim_debugs |= PIM_MASK_MSDP_PACKETS)
#define PIM_DO_DEBUG_MSDP_INTERNAL (qpim_debugs |= PIM_MASK_MSDP_INTERNAL)
#define PIM_DO_DEBUG_PIM_NHT (qpim_debugs |= PIM_MASK_PIM_NHT)
#define PIM_DO_DEBUG_PIM_NHT_RP (qpim_debugs |= PIM_MASK_PIM_NHT_RP)
#define PIM_DO_DEBUG_MTRACE (qpim_debugs |= PIM_MASK_MTRACE)
#define PIM_DO_DEBUG_PIM_EVENTS (router->debugs |= PIM_MASK_PIM_EVENTS)
#define PIM_DO_DEBUG_PIM_PACKETS (router->debugs |= PIM_MASK_PIM_PACKETS)
#define PIM_DO_DEBUG_PIM_PACKETDUMP_SEND \
(router->debugs |= PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DO_DEBUG_PIM_PACKETDUMP_RECV \
(router->debugs |= PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DO_DEBUG_PIM_TRACE (router->debugs |= PIM_MASK_PIM_TRACE)
#define PIM_DO_DEBUG_PIM_TRACE_DETAIL \
(router->debugs |= PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DO_DEBUG_IGMP_EVENTS (router->debugs |= PIM_MASK_IGMP_EVENTS)
#define PIM_DO_DEBUG_IGMP_PACKETS (router->debugs |= PIM_MASK_IGMP_PACKETS)
#define PIM_DO_DEBUG_IGMP_TRACE (router->debugs |= PIM_MASK_IGMP_TRACE)
#define PIM_DO_DEBUG_IGMP_TRACE_DETAIL \
(router->debugs |= PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DO_DEBUG_ZEBRA (router->debugs |= PIM_MASK_ZEBRA)
#define PIM_DO_DEBUG_SSMPINGD (router->debugs |= PIM_MASK_SSMPINGD)
#define PIM_DO_DEBUG_MROUTE (router->debugs |= PIM_MASK_MROUTE)
#define PIM_DO_DEBUG_MROUTE_DETAIL (router->debugs |= PIM_MASK_MROUTE_DETAIL)
#define PIM_DO_DEBUG_PIM_HELLO (router->debugs |= PIM_MASK_PIM_HELLO)
#define PIM_DO_DEBUG_PIM_J_P (router->debugs |= PIM_MASK_PIM_J_P)
#define PIM_DO_DEBUG_PIM_REG (router->debugs |= PIM_MASK_PIM_REG)
#define PIM_DO_DEBUG_STATIC (router->debugs |= PIM_MASK_STATIC)
#define PIM_DO_DEBUG_MSDP_EVENTS (router->debugs |= PIM_MASK_MSDP_EVENTS)
#define PIM_DO_DEBUG_MSDP_PACKETS (router->debugs |= PIM_MASK_MSDP_PACKETS)
#define PIM_DO_DEBUG_MSDP_INTERNAL (router->debugs |= PIM_MASK_MSDP_INTERNAL)
#define PIM_DO_DEBUG_PIM_NHT (router->debugs |= PIM_MASK_PIM_NHT)
#define PIM_DO_DEBUG_PIM_NHT_RP (router->debugs |= PIM_MASK_PIM_NHT_RP)
#define PIM_DO_DEBUG_MTRACE (router->debugs |= PIM_MASK_MTRACE)
#define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
#define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS)
#define PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DONT_DEBUG_PIM_TRACE (qpim_debugs &= ~PIM_MASK_PIM_TRACE)
#define PIM_DONT_DEBUG_PIM_TRACE_DETAIL (qpim_debugs &= ~PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DONT_DEBUG_IGMP_EVENTS (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS)
#define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS)
#define PIM_DONT_DEBUG_IGMP_TRACE (qpim_debugs &= ~PIM_MASK_IGMP_TRACE)
#define PIM_DONT_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs &= ~PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DONT_DEBUG_ZEBRA (qpim_debugs &= ~PIM_MASK_ZEBRA)
#define PIM_DONT_DEBUG_SSMPINGD (qpim_debugs &= ~PIM_MASK_SSMPINGD)
#define PIM_DONT_DEBUG_MROUTE (qpim_debugs &= ~PIM_MASK_MROUTE)
#define PIM_DONT_DEBUG_MROUTE_DETAIL (qpim_debugs &= ~PIM_MASK_MROUTE_DETAIL)
#define PIM_DONT_DEBUG_PIM_HELLO (qpim_debugs &= ~PIM_MASK_PIM_HELLO)
#define PIM_DONT_DEBUG_PIM_J_P (qpim_debugs &= ~PIM_MASK_PIM_J_P)
#define PIM_DONT_DEBUG_PIM_REG (qpim_debugs &= ~PIM_MASK_PIM_REG)
#define PIM_DONT_DEBUG_STATIC (qpim_debugs &= ~PIM_MASK_STATIC)
#define PIM_DONT_DEBUG_MSDP_EVENTS (qpim_debugs &= ~PIM_MASK_MSDP_EVENTS)
#define PIM_DONT_DEBUG_MSDP_PACKETS (qpim_debugs &= ~PIM_MASK_MSDP_PACKETS)
#define PIM_DONT_DEBUG_MSDP_INTERNAL (qpim_debugs &= ~PIM_MASK_MSDP_INTERNAL)
#define PIM_DONT_DEBUG_PIM_NHT (qpim_debugs &= ~PIM_MASK_PIM_NHT)
#define PIM_DONT_DEBUG_PIM_NHT_RP (qpim_debugs &= ~PIM_MASK_PIM_NHT_RP)
#define PIM_DONT_DEBUG_MTRACE (qpim_debugs &= ~PIM_MASK_MTRACE)
#define PIM_DONT_DEBUG_PIM_EVENTS (router->debugs &= ~PIM_MASK_PIM_EVENTS)
#define PIM_DONT_DEBUG_PIM_PACKETS (router->debugs &= ~PIM_MASK_PIM_PACKETS)
#define PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND \
(router->debugs &= ~PIM_MASK_PIM_PACKETDUMP_SEND)
#define PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV \
(router->debugs &= ~PIM_MASK_PIM_PACKETDUMP_RECV)
#define PIM_DONT_DEBUG_PIM_TRACE (router->debugs &= ~PIM_MASK_PIM_TRACE)
#define PIM_DONT_DEBUG_PIM_TRACE_DETAIL \
(router->debugs &= ~PIM_MASK_PIM_TRACE_DETAIL)
#define PIM_DONT_DEBUG_IGMP_EVENTS (router->debugs &= ~PIM_MASK_IGMP_EVENTS)
#define PIM_DONT_DEBUG_IGMP_PACKETS (router->debugs &= ~PIM_MASK_IGMP_PACKETS)
#define PIM_DONT_DEBUG_IGMP_TRACE (router->debugs &= ~PIM_MASK_IGMP_TRACE)
#define PIM_DONT_DEBUG_IGMP_TRACE_DETAIL \
(router->debugs &= ~PIM_MASK_IGMP_TRACE_DETAIL)
#define PIM_DONT_DEBUG_ZEBRA (router->debugs &= ~PIM_MASK_ZEBRA)
#define PIM_DONT_DEBUG_SSMPINGD (router->debugs &= ~PIM_MASK_SSMPINGD)
#define PIM_DONT_DEBUG_MROUTE (router->debugs &= ~PIM_MASK_MROUTE)
#define PIM_DONT_DEBUG_MROUTE_DETAIL (router->debugs &= ~PIM_MASK_MROUTE_DETAIL)
#define PIM_DONT_DEBUG_PIM_HELLO (router->debugs &= ~PIM_MASK_PIM_HELLO)
#define PIM_DONT_DEBUG_PIM_J_P (router->debugs &= ~PIM_MASK_PIM_J_P)
#define PIM_DONT_DEBUG_PIM_REG (router->debugs &= ~PIM_MASK_PIM_REG)
#define PIM_DONT_DEBUG_STATIC (router->debugs &= ~PIM_MASK_STATIC)
#define PIM_DONT_DEBUG_MSDP_EVENTS (router->debugs &= ~PIM_MASK_MSDP_EVENTS)
#define PIM_DONT_DEBUG_MSDP_PACKETS (router->debugs &= ~PIM_MASK_MSDP_PACKETS)
#define PIM_DONT_DEBUG_MSDP_INTERNAL (router->debugs &= ~PIM_MASK_MSDP_INTERNAL)
#define PIM_DONT_DEBUG_PIM_NHT (router->debugs &= ~PIM_MASK_PIM_NHT)
#define PIM_DONT_DEBUG_PIM_NHT_RP (router->debugs &= ~PIM_MASK_PIM_NHT_RP)
#define PIM_DONT_DEBUG_MTRACE (router->debugs &= ~PIM_MASK_MTRACE)
void pim_router_init(void);
void pim_router_terminate(void);
void pim_init(void);
void pim_terminate(void);

View File

@ -10,6 +10,7 @@ vtysh_scan += \
$(top_srcdir)/zebra/interface.c \
$(top_srcdir)/zebra/router-id.c \
$(top_srcdir)/zebra/rtadv.c \
$(top_srcdir)/zebra/zebra_mlag.c \
$(top_srcdir)/zebra/zebra_mpls_vty.c \
$(top_srcdir)/zebra/zebra_ptm.c \
$(top_srcdir)/zebra/zebra_pw.c \
@ -64,6 +65,7 @@ zebra_zebra_SOURCES = \
zebra/rtread_sysctl.c \
zebra/rule_netlink.c \
zebra/rule_socket.c \
zebra/zebra_mlag.c \
zebra/zebra_l2.c \
zebra/zebra_memory.c \
zebra/zebra_dplane.c \
@ -93,10 +95,12 @@ zebra_zebra_SOURCES = \
zebra/zebra_errors.c \
# end
zebra/zebra_mlag_clippy.c: $(CLIPPY_DEPS)
zebra/zebra_mlag.$(OBJEXT): zebra/zebra_mlag_clippy.c
zebra/zebra_vty_clippy.c: $(CLIPPY_DEPS)
zebra/zebra_vty.$(OBJEXT): zebra/zebra_vty_clippy.c
zebra/zebra_routemap_clippy.c: $(CLIPPY_DEPS)
zebra/zebra_routemap.$(OBJEXT): zebra/zebra_routemap_clippy.c
@ -119,6 +123,7 @@ noinst_HEADERS += \
zebra/rt_netlink.h \
zebra/rtadv.h \
zebra/rule_netlink.h \
zebra/zebra_mlag.h \
zebra/zebra_fpm_private.h \
zebra/zebra_l2.h \
zebra/zebra_dplane.h \

View File

@ -63,6 +63,7 @@
#include "zebra/table_manager.h"
#include "zebra/zapi_msg.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_mlag.h"
/* Encoding helpers -------------------------------------------------------- */
@ -1657,6 +1658,7 @@ static void zsend_capabilities(struct zserv *client, struct zebra_vrf *zvrf)
zclient_create_header(s, ZEBRA_CAPABILITIES, zvrf->vrf->vrf_id);
stream_putc(s, mpls_enabled);
stream_putl(s, multipath_num);
stream_putc(s, zebra_mlag_get_role());
stream_putw_at(s, 0, stream_get_endp(s));
zserv_send_message(client, s);

83
zebra/zebra_mlag.c Normal file
View File

@ -0,0 +1,83 @@
/* Zebra Mlag Code.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR 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.
*
* FRR 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 FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include "zebra.h"
#include "command.h"
#include "hook.h"
#include "zebra/zebra_mlag.h"
#ifndef VTYSH_EXTRACT_PL
#include "zebra/zebra_mlag_clippy.c"
#endif
enum mlag_role role = MLAG_ROLE_NONE;
enum mlag_role zebra_mlag_get_role(void)
{
return role;
}
DEFUN_HIDDEN (show_mlag,
show_mlag_cmd,
"show zebra mlag",
SHOW_STR
ZEBRA_STR
"The mlag role on this machine\n")
{
char buf[80];
vty_out(vty, "MLag is configured to: %s\n",
mlag_role2str(role, buf, sizeof(buf)));
return CMD_SUCCESS;
}
DEFPY_HIDDEN (test_mlag,
test_mlag_cmd,
"test zebra mlag <none$none|primary$primary|secondary$secondary>",
"Test code\n"
ZEBRA_STR
"Modify the Mlag state\n"
"Mlag is not setup on the machine\n"
"Mlag is setup to be primary\n"
"Mlag is setup to be the secondary\n")
{
if (none)
role = MLAG_ROLE_NONE;
if (primary)
role = MLAG_ROLE_PRIMARY;
if (secondary)
role = MLAG_ROLE_SECONDARY;
return CMD_SUCCESS;
}
void zebra_mlag_init(void)
{
install_element(VIEW_NODE, &show_mlag_cmd);
install_element(ENABLE_NODE, &test_mlag_cmd);
}
void zebra_mlag_terminate(void)
{
}

31
zebra/zebra_mlag.h Normal file
View File

@ -0,0 +1,31 @@
/* Zebra mlag header.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR 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.
*
* FRR 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 FRR; 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_MLAG_H__
#define __ZEBRA_MLAG_H__
#include "mlag.h"
void zebra_mlag_init(void);
void zebra_mlag_terminate(void);
enum mlag_role zebra_mlag_get_role(void);
#endif

View File

@ -25,6 +25,7 @@
#include "zebra_memory.h"
#include "zebra_pbr.h"
#include "zebra_vxlan.h"
#include "zebra_mlag.h"
struct zebra_router zrouter;
@ -159,6 +160,8 @@ void zebra_router_terminate(void)
}
zebra_vxlan_disable();
zebra_mlag_terminate();
hash_clean(zrouter.rules_hash, zebra_pbr_rules_free);
hash_free(zrouter.rules_hash);
@ -173,6 +176,8 @@ void zebra_router_terminate(void)
void zebra_router_init(void)
{
zebra_vxlan_init();
zebra_mlag_init();
zrouter.rules_hash = hash_create_size(8, zebra_pbr_rules_hash_key,
zebra_pbr_rules_hash_equal,
"Rules Hash");