]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_zlookup.c
Merge pull request #5430 from taruta811/build-docker-centos
[mirror_frr.git] / pimd / pim_zlookup.c
index 6e703521043b823bd1d6c1eb5e143d024f04a8c8..77526281d18c1c8a2a479c4fc766bb03d864faa2 100644 (file)
 #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)
@@ -65,13 +67,15 @@ 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",
@@ -81,7 +85,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",
@@ -113,6 +117,7 @@ static void zclient_lookup_failed(struct zclient *zlookup)
 
 void zclient_lookup_free(void)
 {
+       thread_cancel(zlookup_read);
        zclient_stop(zlookup);
        zclient_free(zlookup);
        zlookup = NULL;
@@ -120,7 +125,7 @@ void zclient_lookup_free(void)
 
 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__);
@@ -202,10 +207,12 @@ static int zclient_read_nexthop(struct pim_instance *pim,
        }
 
        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];
@@ -219,6 +226,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                }
                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);
@@ -265,12 +273,12 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                                        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;
@@ -354,6 +362,20 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
        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,
@@ -496,7 +518,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
                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);
        }