system: fix treatment of RT_TABLE_MAIN
authorSteven Barth <steven@midlink.org>
Fri, 20 Jun 2014 17:48:32 +0000 (19:48 +0200)
committerSteven Barth <steven@midlink.org>
Fri, 20 Jun 2014 17:48:32 +0000 (19:48 +0200)
Do not treat RT_TABLE_MAIN as RT_TABLE_UNSPEC in system_resolve_rt_table() in
order to allow ip rules with lookup main to work as expected.

Provide a new function system_is_default_rt_table() to allow calling code to
specifically test for RT_TABLE_MAIN, this is going to be needed for the
backwards compatible handling of the table attribute in route objects.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
system-dummy.c
system-linux.c
system.h

index f2988f2..66b3ae6 100644 (file)
@@ -205,6 +205,11 @@ bool system_resolve_rt_table(const char *name, unsigned int *id)
        return true;
 }
 
+bool system_is_default_rt_table(unsigned int id)
+{
+       return true;
+}
+
 int system_add_iprule(struct iprule *rule)
 {
        return 0;
index 8f612c9..c6f17e9 100644 (file)
@@ -1464,14 +1464,15 @@ bool system_resolve_rt_table(const char *name, unsigned int *id)
        if (table == RT_TABLE_UNSPEC)
                return false;
 
-       /* do not consider main table special */
-       if (table == RT_TABLE_MAIN)
-               table = RT_TABLE_UNSPEC;
-
        *id = table;
        return true;
 }
 
+bool system_is_default_rt_table(unsigned int id)
+{
+       return (id == RT_TABLE_MAIN);
+}
+
 static int system_iprule(struct iprule *rule, int cmd)
 {
        int alen = ((rule->flags & IPRULE_FAMILY) == IPRULE_INET4) ? 4 : 16;
index 4c80eb0..0fde7f1 100644 (file)
--- a/system.h
+++ b/system.h
@@ -130,6 +130,7 @@ int system_flush_routes(void);
 
 bool system_resolve_rt_type(const char *type, unsigned int *id);
 bool system_resolve_rt_table(const char *name, unsigned int *id);
+bool system_is_default_rt_table(unsigned int id);
 
 int system_del_ip_tunnel(const char *name);
 int system_add_ip_tunnel(const char *name, struct blob_attr *attr);