Merge pull request #2532 from donaldsharp/various_stuff

Redistribution and some extra developer debug code
This commit is contained in:
Jafar Al-Gharaibeh 2018-06-29 12:41:02 -05:00 committed by GitHub
commit 20e5fd7ab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 28 deletions

View File

@ -1109,6 +1109,10 @@ struct stream_fifo *stream_fifo_new(void)
/* Add new stream to fifo. */
void stream_fifo_push(struct stream_fifo *fifo, struct stream *s)
{
#if defined DEV_BUILD
size_t max, curmax;
#endif
if (fifo->tail)
fifo->tail->next = s;
else
@ -1116,8 +1120,15 @@ void stream_fifo_push(struct stream_fifo *fifo, struct stream *s)
fifo->tail = s;
fifo->tail->next = NULL;
#if !defined DEV_BUILD
atomic_fetch_add_explicit(&fifo->count, 1, memory_order_release);
#else
max = atomic_fetch_add_explicit(&fifo->count, 1, memory_order_release);
curmax = atomic_load_explicit(&fifo->max_count, memory_order_relaxed);
if (max > curmax)
atomic_store_explicit(&fifo->max_count, max,
memory_order_relaxed);
#endif
}
void stream_fifo_push_safe(struct stream_fifo *fifo, struct stream *s)

View File

@ -115,6 +115,9 @@ struct stream_fifo {
/* number of streams in this fifo */
_Atomic size_t count;
#if defined DEV_BUILD
_Atomic size_t max_count;
#endif
struct stream *head;
struct stream *tail;

View File

@ -737,8 +737,6 @@ static void pim_zebra_connected(struct zclient *zclient)
void pim_zebra_init(void)
{
int i;
/* Socket for receiving updates from Zebra daemon */
zclient = zclient_new_notify(master, &zclient_options_default);
@ -754,31 +752,7 @@ void pim_zebra_init(void)
zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);
if (PIM_DEBUG_PIM_TRACE) {
zlog_info("zclient_init cleared redistribution request");
}
/* Request all redistribution */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
if (i == zclient->redist_default)
continue;
vrf_bitmap_set(zclient->redist[AFI_IP][i], pimg->vrf_id);
;
if (PIM_DEBUG_PIM_TRACE) {
zlog_debug("%s: requesting redistribution for %s (%i)",
__PRETTY_FUNCTION__, zebra_route_string(i),
i);
}
}
/* Request default information */
zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient,
pimg->vrf_id);
if (PIM_DEBUG_PIM_TRACE) {
zlog_info("%s: requesting default information redistribution",
__PRETTY_FUNCTION__);
zlog_notice("%s: zclient update socket initialized",
zlog_notice("%s: zclient socket initialized",
__PRETTY_FUNCTION__);
}

View File

@ -521,6 +521,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
struct zapi_nexthop *api_nh;
struct nexthop *nexthop;
int count = 0;
afi_t afi;
memset(&api, 0, sizeof(api));
api.vrf_id = re->vrf_id;
@ -528,6 +529,24 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
api.instance = re->instance;
api.flags = re->flags;
afi = family2afi(p->family);
switch (afi) {
case AFI_IP:
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
client->redist_v4_add_cnt++;
else
client->redist_v4_del_cnt++;
break;
case AFI_IP6:
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
client->redist_v6_add_cnt++;
else
client->redist_v6_del_cnt++;
break;
default:
break;
}
/* Prefix. */
api.prefix = *p;
if (src_p) {

View File

@ -939,6 +939,11 @@ static void zebra_show_client_detail(struct vty *vty, struct zserv *client)
vty_out(vty, "MAC-IP add notifications: %d\n", client->macipadd_cnt);
vty_out(vty, "MAC-IP delete notifications: %d\n", client->macipdel_cnt);
#if defined DEV_BUILD
vty_out(vty, "Input Fifo: %zu:%zu Output Fifo: %zu:%zu\n",
client->ibuf_fifo->count, client->ibuf_fifo->max_count,
client->obuf_fifo->count, client->obuf_fifo->max_count);
#endif
vty_out(vty, "\n");
return;
}