[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1447873400-15337-1-git-send-email-dsa@cumulusnetworks.com>
Date: Wed, 18 Nov 2015 11:03:20 -0800
From: David Ahern <dsa@...ulusnetworks.com>
To: stephen@...workplumber.org, netdev@...r.kernel.org
Cc: David Ahern <dsa@...ulusnetworks.com>
Subject: [PATCH iproute2] Add support for rt_tables.d
Add support for reading table id/name mappings from rt_tables.d
directory.
Signed-off-by: David Ahern <dsa@...ulusnetworks.com>
---
lib/rt_names.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/lib/rt_names.c b/lib/rt_names.c
index e87c65dad39e..d835ff9c7ee0 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <sys/time.h>
#include <sys/socket.h>
+#include <dirent.h>
#include <asm/types.h>
#include <linux/rtnetlink.h>
@@ -339,6 +340,8 @@ static int rtnl_rttable_init;
static void rtnl_rttable_initialize(void)
{
+ struct dirent *de;
+ DIR *d;
int i;
rtnl_rttable_init = 1;
@@ -348,6 +351,21 @@ static void rtnl_rttable_initialize(void)
}
rtnl_hash_initialize(CONFDIR "/rt_tables",
rtnl_rttable_hash, 256);
+
+ d = opendir(CONFDIR "/rt_tables.d");
+ if (!d)
+ return;
+
+ while ((de = readdir(d)) != NULL) {
+ char path[PATH_MAX];
+
+ if (*de->d_name == '.')
+ continue;
+
+ snprintf(path, sizeof(path), CONFDIR "/rt_tables.d/%s", de->d_name);
+ rtnl_hash_initialize(path, rtnl_rttable_hash, 256);
+ }
+ closedir(d);
}
const char * rtnl_rttable_n2a(__u32 id, char *buf, int len)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists