*/
#include <zebra.h>
-#include "zebra/rib.h"
#include "log.h"
#include "prefix.h"
#include "pim_zlookup.h"
static struct zclient *zlookup = NULL;
+struct thread *zlookup_read;
static void zclient_lookup_sched(struct zclient *zlookup, int delay);
+static int zclient_lookup_read_pipe(struct thread *thread);
/* Connect to zebra for nexthop lookup. */
static int zclient_lookup_connect(struct thread *t)
return -1;
}
+ thread_add_timer(router->master, zclient_lookup_read_pipe, zlookup, 60,
+ &zlookup_read);
return 0;
}
/* 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",
/* 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",
void zclient_lookup_free(void)
{
+ thread_cancel(zlookup_read);
zclient_stop(zlookup);
zclient_free(zlookup);
zlookup = NULL;
void zclient_lookup_new(void)
{
- zlookup = zclient_new_notify(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__);
+ __PRETTY_FUNCTION__);
return;
}
&version, &vrf_id, &command);
if (err < 0) {
flog_err(EC_LIB_ZAPI_MISSMATCH,
- "%s: zclient_read_header() failed",
- __PRETTY_FUNCTION__);
+ "%s: zclient_read_header() failed",
+ __PRETTY_FUNCTION__);
zclient_lookup_failed(zlookup);
return -1;
}
}
for (i = 0; i < nexthop_num; ++i) {
+ vrf_id_t nexthop_vrf_id;
enum nexthop_types_t nexthop_type;
struct pim_neighbor *nbr;
struct prefix p;
+ nexthop_vrf_id = stream_getl(s);
nexthop_type = stream_getc(s);
if (num_ifindex >= tab_size) {
char addr_str[INET_ADDRSTRLEN];
}
nexthop_tab[num_ifindex].protocol_distance = distance;
nexthop_tab[num_ifindex].route_metric = metric;
+ nexthop_tab[num_ifindex].vrf_id = nexthop_vrf_id;
switch (nexthop_type) {
case NEXTHOP_TYPE_IFINDEX:
nexthop_tab[num_ifindex].ifindex = stream_getl(s);
if_lookup_by_index(
nexthop_tab[num_ifindex]
.ifindex,
- vrf_id),
+ nexthop_vrf_id),
&p);
else
nbr = pim_neighbor_find_if(if_lookup_by_index(
nexthop_tab[num_ifindex].ifindex,
- vrf_id));
+ nexthop_vrf_id));
if (nbr) {
nexthop_tab[num_ifindex].nexthop_addr.family =
AF_INET;
/* Check socket. */
if (zlookup->sock < 0) {
flog_err(EC_LIB_ZAPI_SOCKET,
- "%s: zclient lookup socket is not connected",
- __PRETTY_FUNCTION__);
+ "%s: zclient lookup socket is not connected",
+ __PRETTY_FUNCTION__);
zclient_lookup_failed(zlookup);
return -1;
}
return zclient_read_nexthop(pim, zlookup, nexthop_tab, tab_size, addr);
}
+int zclient_lookup_read_pipe(struct thread *thread)
+{
+ struct zclient *zlookup = THREAD_ARG(thread);
+ struct pim_instance *pim = pim_get_pim_instance(VRF_DEFAULT);
+ struct pim_zlookup_nexthop nexthop_tab[10];
+ struct in_addr l = {.s_addr = INADDR_ANY};
+
+ zclient_lookup_nexthop_once(pim, nexthop_tab, 10, l);
+ thread_add_timer(router->master, zclient_lookup_read_pipe, zlookup, 60,
+ &zlookup_read);
+
+ return 1;
+}
+
int zclient_lookup_nexthop(struct pim_instance *pim,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size, struct in_addr addr,
more.src = c_oil->oil.mfcc_origin;
more.grp = c_oil->oil.mfcc_mcastgrp;
zlog_debug(
- "Sending Request for New Channel Oil Information(%s) VIIF %d(%s)",
+ "Sending Request for New Channel Oil Information%s VIIF %d(%s)",
pim_str_sg_dump(&more), c_oil->oil.mfcc_parent,
c_oil->pim->vrf->name);
}
&version, &vrf_id, &command);
if (err < 0) {
flog_err(EC_LIB_ZAPI_MISSMATCH,
- "%s: zclient_read_header() failed",
- __PRETTY_FUNCTION__);
+ "%s: zclient_read_header() failed",
+ __PRETTY_FUNCTION__);
zclient_lookup_failed(zlookup);
return -1;
}