dhcpcd-discuss

Re: [RFC]Routes are stored as a linked list

Donald Sharp

Tue Mar 05 15:02:54 2019

Roy -

I could not figure out how to make debug's work so I just changed the
logdebugx to logerrx:

diff --git a/src/route.c b/src/route.c
index dbe2b5a5..6963837d 100644
--- a/src/route.c
+++ b/src/route.c
@@ -258,8 +258,8 @@ rt_dispose(struct dhcpcd_ctx *ctx)
  rt_headfree(&ctx->routes);
 #ifdef RT_FREE_ROUTE_TABLE
  rt_headfree(&ctx->froutes);
- logdebugx("free route list used %zu times", froutes);
- logdebugx("new routes from free list %zu", nroutes);
+ logerrx("free route list used %zu times", froutes);
+ logerrx("new routes from free list %zu", nroutes);
 #endif
 }


And only see this:

Mar 05 14:41:19 janelle dhcpcd[20151]: free route list used 7 times
Mar 05 14:41:19 janelle dhcpcd[20168]: dummy0: soliciting an IPv6 router
Mar 05 14:41:19 janelle dhcpcd[20151]: new routes from free list 0

On startup.  After startup when I install/remove 1 million routes I
never see the message again.

Another issue that has popped up during testing is that now that I am
looking at the syslog is that I am seeing frequent messges from dhcpd
that say this:

Mar 05 14:34:40 janelle dhcpcd[19931]: route socket overflowed -
learning interface state
Mar 05 14:34:41 janelle dhcpcd[19931]: route socket overflowed -
learning interface state

during route install/removal.

I added this bit of code:

diff --git a/src/if-linux.c b/src/if-linux.c
index b912c171..4b5dda54 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -323,12 +323,15 @@ if_opensockets_os(struct dhcpcd_ctx *ctx)
      &on, sizeof(on));
 #endif

+ int rcvbufsize = 16 * 1024 * 1024;
+ setsockopt(ctx->link_fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbufsize,
sizeof(rcvbufsize));
  if ((priv = calloc(1, sizeof(*priv))) == NULL)
  return -1;

  ctx->priv = priv;
  memset(&snl, 0, sizeof(snl));
  priv->route_fd = _open_link_socket(&snl, NETLINK_ROUTE);
+ setsockopt(priv->route_fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbufsize,
sizeof(rcvbufsize));
  if (priv->route_fd == -1)
  return -1;
  len = sizeof(snl);

and the error message has gone away.  Perhaps some cli option is
needed for linux when it is planned to be used in a large scale
routing env?

donald

On Tue, Mar 5, 2019 at 4:22 AM Roy Marples <roy@xxxxxxxxxxxx> wrote:
>
> On 05/03/2019 07:03, Roy Marples wrote:
> > If you run dhcpcd under valgrind, is there a large difference between
> > the number of mallocs made?
>
> I also added a small patch to report the number of times a route was
> placed onto the free list and the number of times a new route was taken
> from it.
>
> Could you report those numbers please? I'm surprised that memory usage
> is low, infact no different, with it enabled still compared to without.
> I'm now starding to wonder if this micro memory optimisation is worth it
> with modern allocators.
>
> Roy

Follow-Ups:
Re: [RFC]Routes are stored as a linked listRoy Marples
References:
[RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listRoy Marples
Archive administrator: postmaster@marples.name