X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto.c;h=676852d8b05239cb76175e4f88857161868ac971;hp=31b36488b33d501c7d06ee683257ce2724808337;hb=587655b45085fcfc9c575792640c21c6ffb24f42;hpb=48ffedb4a2b6701eec99e32e91b8a66a0a4be950 diff --git a/proto.c b/proto.c index 31b3648..676852d 100644 --- a/proto.c +++ b/proto.c @@ -1,6 +1,7 @@ /* * netifd - network interface daemon * Copyright (C) 2012 Felix Fietkau + * Copyright (C) 2012 Steven Barth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -250,7 +251,13 @@ parse_gateway_option(struct interface *iface, struct blob_attr *attr, bool v6) route->mask = 0; route->flags = (v6 ? DEVADDR_INET6 : DEVADDR_INET4); - vlist_add(&iface->proto_ip.route, &route->node, &route->flags); + + if (v6) { + route->table = interface_ip_resolve_v6_rtable(iface->l3_dev.dev->ifindex); + route->flags |= DEVROUTE_SRCTABLE; + } + + vlist_add(&iface->proto_ip.route, &route->node, route); return true; } @@ -273,7 +280,7 @@ parse_prefix_option(struct interface *iface, const char *str, size_t len) char *prefstr = strtok_r(NULL, ",", &saveptr); char *validstr = (!prefstr) ? NULL : strtok_r(NULL, ",", &saveptr); - char *excludestr = (!validstr) ? NULL : strtok_r(NULL, ",", &saveptr); + char *addstr = (!validstr) ? NULL : strtok_r(NULL, ",", &saveptr); uint32_t pref = (!prefstr) ? 0 : strtoul(prefstr, NULL, 10); uint32_t valid = (!validstr) ? 0 : strtoul(validstr, NULL, 10); @@ -286,20 +293,31 @@ parse_prefix_option(struct interface *iface, const char *str, size_t len) if (inet_pton(AF_INET6, addrstr, &addr) < 1) return false; - if (excludestr) { - char *sep = strchr(excludestr, '/'); - if (!sep) - return false; + for (; addstr; addstr = strtok_r(NULL, ",", &saveptr)) { + char *key = NULL, *val = NULL, *addsaveptr; + if (!(key = strtok_r(addstr, "=", &addsaveptr)) || + !(val = strtok_r(NULL, ",", &addsaveptr))) + continue; - *sep = 0; - excl_length = atoi(sep + 1); + if (!strcmp(key, "excluded")) { + char *sep = strchr(val, '/'); + if (!sep) + return false; - if (inet_pton(AF_INET6, excludestr, &excluded) < 1) - return false; + *sep = 0; + excl_length = atoi(sep + 1); + + if (inet_pton(AF_INET6, val, &excluded) < 1) + return false; + + excludedp = &excluded; + } - excludedp = &excluded; } + + + time_t now = system_get_rtime(); time_t preferred_until = 0; if (prefstr && pref != 0xffffffffU)