IPv6: fix prefix assignment with continuous hints
[project/netifd.git] / system-linux.c
index f5c900d..4299a61 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/fib_rules.h>
 
 #include <linux/ethtool.h>
 #include <linux/fib_rules.h>
 
+#ifndef RTN_FAILED_POLICY
+#define RTN_FAILED_POLICY 12
+#endif
+
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
@@ -918,17 +922,21 @@ static int system_addr(struct device *dev, struct device_addr *addr, int cmd)
                struct ifa_cacheinfo cinfo = {0xffffffffU, 0xffffffffU, 0, 0};
 
                if (addr->preferred_until) {
                struct ifa_cacheinfo cinfo = {0xffffffffU, 0xffffffffU, 0, 0};
 
                if (addr->preferred_until) {
-                       int preferred = addr->preferred_until - now;
+                       int64_t preferred = addr->preferred_until - now;
                        if (preferred < 0)
                                preferred = 0;
                        if (preferred < 0)
                                preferred = 0;
+                       else if (preferred > UINT32_MAX)
+                               preferred = UINT32_MAX;
 
                        cinfo.ifa_prefered = preferred;
                }
 
                if (addr->valid_until) {
 
                        cinfo.ifa_prefered = preferred;
                }
 
                if (addr->valid_until) {
-                       int valid = addr->valid_until - now;
+                       int64_t valid = addr->valid_until - now;
                        if (valid <= 0)
                                return -1;
                        if (valid <= 0)
                                return -1;
+                       else if (valid > UINT32_MAX)
+                               valid = UINT32_MAX;
 
                        cinfo.ifa_valid = valid;
                }
 
                        cinfo.ifa_valid = valid;
                }
@@ -1251,6 +1259,8 @@ bool system_resolve_iprule_action(const char *action, unsigned int *id)
                n = RTN_UNICAST;
        else if (!strcmp(action, "throw"))
                n = RTN_THROW;
                n = RTN_UNICAST;
        else if (!strcmp(action, "throw"))
                n = RTN_THROW;
+       else if (!strcmp(action, "failed_policy"))
+               n = RTN_FAILED_POLICY;
        else {
                n = strtoul(action, &e, 0);
                if (!e || *e || e == action || n > 255)
        else {
                n = strtoul(action, &e, 0);
                if (!e || *e || e == action || n > 255)