#include "memory.h"
#include "log.h"
+#include "vrf.h"
+
+#include "zebra/zserv.h"
+#include "zebra/rt.h"
+#include "zebra/kernel_socket.h"
/* Kernel routing table read up by sysctl function. */
-int
-route_read ()
+void
+route_read (struct zebra_ns *zns)
{
caddr_t buf, end, ref;
size_t bufsiz;
struct rt_msghdr *rtm;
- void rtm_read (struct rt_msghdr *);
#define MIBSIZ 6
int mib[MIBSIZ] =
NET_RT_DUMP,
0
};
-
+
+ if (zns->ns_id != NS_DEFAULT)
+ return;
+
/* Get buffer size. */
if (sysctl (mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0)
{
zlog_warn ("sysctl fail: %s", safe_strerror (errno));
- return -1;
+ return;
}
/* Allocate buffer. */
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
zlog_warn ("sysctl() fail by %s", safe_strerror (errno));
- return -1;
+ XFREE(MTYPE_TMP, ref);
+ return;
}
for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen)
{
rtm = (struct rt_msghdr *) buf;
+ /* We must set RTF_DONE here, so rtm_read() doesn't ignore the message. */
+ SET_FLAG (rtm->rtm_flags, RTF_DONE);
rtm_read (rtm);
}
/* Free buffer. */
XFREE (MTYPE_TMP, ref);
- return 0;
+ return;
}