]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: Allow zlookup socket to drain
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Jun 2019 20:23:09 +0000 (16:23 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Jun 2019 20:23:09 +0000 (16:23 -0400)
When pim is started and has nothing to talk to zebra about
over the zlookup socket and interface events are happening
then the zlookup socket is not being drained.

This eventually leads to a situation where the kernel send buffer
fills up and zebra is unable to write anything down the pipe.
At this time the zapi starts buffering data in `struct buffer`
which of course slowly fills up as pim has nothing to do.

As a bit of a hack allow the zlookup socket to wake up 1 time
a minute and ask for information about the default route
and do nothing with it.  This will cause the socket buffers
to be drained and the system will be happy.

Long term we need to get rid of this synchronous/asynchronous
duality that pim has.  This is on the radar but is not something
that could be fixed in an afternoon or a week of effort in my
opinion.  Given time constraints right now.  Let's put this
in place and then once we get pim completely async then
we can just remove the zlookup( I hope ) code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_zlookup.c

index 6d93a40b913d95c0cdd63b60f189ef0e4890f504..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,6 +67,8 @@ 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;
 }
 
@@ -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;
@@ -357,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,