summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2015-03-19 18:13:33 +0100
committerSteven Barth <steven@midlink.org>2015-03-19 18:13:33 +0100
commit3eea8576d48d9b20cc1c6b46f54c7345a39d13aa (patch)
tree2e0e29087b544d395604b9912c1ad62bbe260b49 /system-linux.c
parent60f57b2bfb87c463fc271a9c3e8e1f97feaecdca (diff)
add prelocal table to manipulate locally destinated traffic
Signed-off-by: Steven Barth <steven@midlink.org>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c
index fb2ee29..21385fc 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -43,6 +43,10 @@
#define RTN_FAILED_POLICY 12
#endif
+#ifndef RT_TABLE_PRELOCAL
+#define RT_TABLE_PRELOCAL 128
+#endif
+
#include <string.h>
#include <fcntl.h>
#include <glob.h>
@@ -1606,6 +1610,8 @@ bool system_resolve_rt_table(const char *name, unsigned int *id)
table = RT_TABLE_MAIN;
else if (!strcmp(name, "local"))
table = RT_TABLE_LOCAL;
+ else if (!strcmp(name, "prelocal"))
+ table = RT_TABLE_PRELOCAL;
/* try to look up name in /etc/iproute2/rt_tables */
else if ((f = fopen("/etc/iproute2/rt_tables", "r")) != NULL)
@@ -1767,6 +1773,10 @@ int system_flush_iprules(void)
rule.flags = IPRULE_INET4 | IPRULE_PRIORITY | IPRULE_LOOKUP;
rule.priority = 0;
+ rule.lookup = RT_TABLE_PRELOCAL;
+ rv |= system_iprule(&rule, RTM_NEWRULE);
+
+ rule.priority = 1;
rule.lookup = RT_TABLE_LOCAL;
rv |= system_iprule(&rule, RTM_NEWRULE);
@@ -1782,6 +1792,10 @@ int system_flush_iprules(void)
rule.flags = IPRULE_INET6 | IPRULE_PRIORITY | IPRULE_LOOKUP;
rule.priority = 0;
+ rule.lookup = RT_TABLE_PRELOCAL;
+ rv |= system_iprule(&rule, RTM_NEWRULE);
+
+ rule.priority = 1;
rule.lookup = RT_TABLE_LOCAL;
rv |= system_iprule(&rule, RTM_NEWRULE);