rules: process rules after the local table to ensure that local access still works
authorFelix Fietkau <nbd@openwrt.org>
Fri, 5 Feb 2016 15:43:53 +0000 (16:43 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 5 Feb 2016 15:54:27 +0000 (16:54 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
route.c

diff --git a/route.c b/route.c
index df933b152176583ab75b1d08af1ba217edaa13ff..6cea299e1a6aabb7457456c1fc68fcca5cb12add 100644 (file)
--- a/route.c
+++ b/route.c
@@ -66,6 +66,10 @@ rtnl_rule_request(struct relayd_interface *rif, int flags)
                        struct rtattr rta;
                        int table;
                } __packed table;
+               struct {
+                       struct rtattr rta;
+                       int prio;
+               } __packed prio;
                struct {
                        struct rtattr rta;
                        char ifname[IFNAMSIZ + 1];
@@ -77,6 +81,11 @@ rtnl_rule_request(struct relayd_interface *rif, int flags)
                        .rtm_scope = RT_SCOPE_UNIVERSE,
                        .rtm_protocol = RTPROT_BOOT,
                },
+               .prio = {
+                       .rta.rta_type = FRA_PRIORITY,
+                       .rta.rta_len = sizeof(req.prio),
+                       .prio = 2,
+               },
                .table.rta = {
                        .rta_type = FRA_TABLE,
                        .rta_len = sizeof(req.table),
@@ -94,11 +103,8 @@ rtnl_rule_request(struct relayd_interface *rif, int flags)
                strcpy(req.dev.ifname, ifname);
                req.dev.rta.rta_len = sizeof(req.dev.rta) + strlen(ifname) + 1;
        } else {
-               uint32_t val = 1;
-               req.dev.rta.rta_type = FRA_PRIORITY;
-               req.dev.rta.rta_len = sizeof(req.dev.rta) + sizeof(uint32_t);
-               padding -= sizeof(uint32_t);
-               memcpy(&req.dev.ifname, &val, sizeof(val));
+               padding = sizeof(req.dev);
+               req.prio.prio--;
        }
        req.table.table = get_route_table(rif);
        req.nl.nlmsg_len = sizeof(req) - padding;