for (size_t i = 0; i < addrlen; ++i) {
struct in6_addr addr;
- uint32_t preferred_lt, valid;
+ uint32_t preferred_lt, valid_lt;
int prefix = c->managed ? addrs[i].prefix : c->length;
if (!valid_addr(&addrs[i], now))
addr = addrs[i].addr.in6;
preferred_lt = addrs[i].preferred_lt;
- valid = addrs[i].valid;
+ valid_lt = addrs[i].valid_lt;
if (c->flags & OAF_DHCPV6_NA) {
if (!ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs))
if (preferred_lt != UINT32_MAX)
preferred_lt -= now;
- if (valid > (uint32_t)c->valid_until)
- valid = c->valid_until;
+ if (valid_lt > (uint32_t)c->valid_until)
+ valid_lt = c->valid_until;
- if (valid != UINT32_MAX)
- valid -= now;
+ if (valid_lt != UINT32_MAX)
+ valid_lt -= now;
- func(&addr, prefix, preferred_lt, valid, arg);
+ func(&addr, prefix, preferred_lt, valid_lt, arg);
}
}
};
static void dhcpv6_write_ia_addrhosts(struct in6_addr *addr, int prefix, _unused uint32_t pref_lt,
- _unused uint32_t valid, void *arg)
+ _unused uint32_t valid_lt, void *arg)
{
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
char ipbuf[INET6_ADDRSTRLEN];
}
static void dhcpv6_write_ia_addr(struct in6_addr *addr, int prefix, _unused uint32_t pref_lt,
- _unused uint32_t valid, void *arg)
+ _unused uint32_t valid_lt, void *arg)
{
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
char ipbuf[INET6_ADDRSTRLEN];
continue;
x = strtok_r(NULL, ",", &saveptr2);
- if (sscanf(x, "%u", &n->valid) < 1)
+ if (sscanf(x, "%u", &n->valid_lt) < 1)
continue;
- if (n->preferred_lt > n->valid)
+ if (n->preferred_lt > n->valid_lt)
continue;
if (UINT32_MAX - now < n->preferred_lt)
else
n->preferred_lt += now;
- if (UINT32_MAX - now < n->valid)
- n->valid = UINT32_MAX;
+ if (UINT32_MAX - now < n->valid_lt)
+ n->valid_lt = UINT32_MAX;
else
- n->valid += now;
+ n->valid_lt += now;
n->dprefix = 0;
preferred_lt = iface->preferred_lifetime;
}
- uint32_t valid = leasetime;
+ uint32_t valid_lt = leasetime;
struct odhcpd_ipaddr *addrs = (a->managed) ? a->managed : iface->addr6;
size_t addrlen = (a->managed) ? (size_t)a->managed_size : iface->addr6_len;
size_t m = get_preferred_addr(addrs, addrlen);
for (size_t i = 0; i < addrlen; ++i) {
- uint32_t prefix_preferred_lt, prefix_valid;
+ uint32_t prefix_preferred_lt, prefix_valid_lt;
if (!valid_addr(&addrs[i], now))
continue;
}
prefix_preferred_lt = addrs[i].preferred_lt;
- prefix_valid = addrs[i].valid;
+ prefix_valid_lt = addrs[i].valid_lt;
if (prefix_preferred_lt != UINT32_MAX)
prefix_preferred_lt -= now;
if (prefix_preferred_lt > preferred_lt)
prefix_preferred_lt = preferred_lt;
- if (prefix_valid != UINT32_MAX)
- prefix_valid -= now;
+ if (prefix_valid_lt != UINT32_MAX)
+ prefix_valid_lt -= now;
- if (prefix_valid > leasetime)
- prefix_valid = leasetime;
+ if (prefix_valid_lt > leasetime)
+ prefix_valid_lt = leasetime;
- if (prefix_preferred_lt > prefix_valid)
- prefix_preferred_lt = prefix_valid;
+ if (prefix_preferred_lt > prefix_valid_lt)
+ prefix_preferred_lt = prefix_valid_lt;
if (a->flags & OAF_DHCPV6_PD) {
struct dhcpv6_ia_prefix o_ia_p = {
.type = htons(DHCPV6_OPT_IA_PREFIX),
.len = htons(sizeof(o_ia_p) - 4),
.preferred_lt = htonl(prefix_preferred_lt),
- .valid = htonl(prefix_valid),
+ .valid_lt = htonl(prefix_valid_lt),
.prefix = (a->managed_size) ? addrs[i].prefix : a->length,
.addr = addrs[i].addr.in6,
};
.len = htons(sizeof(o_ia_a) - 4),
.addr = addrs[i].addr.in6,
.preferred_lt = htonl(prefix_preferred_lt),
- .valid = htonl(prefix_valid)
+ .valid_lt = htonl(prefix_valid_lt)
};
o_ia_a.addr.s6_addr32[2] = htonl(a->assigned_host_id >> 32);
if (prefix_preferred_lt < preferred_lt)
preferred_lt = prefix_preferred_lt;
- if (prefix_valid < valid)
- valid = prefix_valid;
+ if (prefix_valid_lt < valid_lt)
+ valid_lt = prefix_valid_lt;
}
}
if (!INFINITE_VALID(a->valid_until))
/* UINT32_MAX is considered as infinite leasetime */
- a->valid_until = (valid == UINT32_MAX) ? 0 : valid + now;
+ a->valid_until = (valid_lt == UINT32_MAX) ? 0 : valid_lt + now;
if (!INFINITE_VALID(a->preferred_until))
/* UINT32_MAX is considered as infinite leasetime */
.type = htons(DHCPV6_OPT_IA_PREFIX),
.len = htons(sizeof(o_ia_p) - 4),
.preferred_lt = 0,
- .valid = 0,
+ .valid_lt = 0,
.prefix = ia_p->prefix,
.addr = ia_p->addr,
};
.len = htons(sizeof(o_ia_a) - 4),
.addr = ia_a->addr,
.preferred_lt = 0,
- .valid = 0,
+ .valid_lt = 0,
};
if (buflen < ia_len + sizeof(o_ia_a))
};
static void dhcpv6_log_ia_addr(struct in6_addr *addr, int prefix, _unused uint32_t pref_lt,
- _unused uint32_t valid, void *arg)
+ _unused uint32_t valid_lt, void *arg)
{
struct log_ctxt *ctxt = (struct log_ctxt *)arg;
char addrbuf[INET6_ADDRSTRLEN];
if (!IN6_ARE_ADDR_EQUAL(&addr[i].addr.in6, &iface->addr6[i].addr.in6) ||
addr[i].prefix != iface->addr6[i].prefix ||
(addr[i].preferred_lt > (uint32_t)now) != (iface->addr6[i].preferred_lt > (uint32_t)now) ||
- addr[i].valid < iface->addr6[i].valid || addr[i].preferred_lt < iface->addr6[i].preferred_lt)
+ addr[i].valid_lt < iface->addr6[i].valid_lt || addr[i].preferred_lt < iface->addr6[i].preferred_lt)
change = true;
}
for (size_t i = 0; i < iface->addr6_len; ++i) {
bool removed = true;
- if (iface->addr6[i].valid <= (uint32_t)now)
+ if (iface->addr6[i].valid_lt <= (uint32_t)now)
continue;
for (ssize_t j = 0; removed && j < len; ++j) {
iface->invalid_addr6 = new_invalid_addr6;
iface->invalid_addr6_len++;
memcpy(&iface->invalid_addr6[pos], &iface->addr6[i], sizeof(*iface->invalid_addr6));
- iface->invalid_addr6[pos].valid = iface->invalid_addr6[pos].preferred_lt = (uint32_t)now;
+ iface->invalid_addr6[pos].valid_lt = iface->invalid_addr6[pos].preferred_lt = (uint32_t)now;
if (iface->invalid_addr6[pos].prefix < 64)
iface->invalid_addr6[pos].prefix = 64;
struct ifa_cacheinfo *ifc = nla_data(nla[IFA_CACHEINFO]);
addrs[ctxt->ret].preferred_lt = ifc->ifa_prefered;
- addrs[ctxt->ret].valid = ifc->ifa_valid;
+ addrs[ctxt->ret].valid_lt = ifc->ifa_valid;
}
if (ifa->ifa_flags & IFA_F_DEPRECATED)
if (addr[i].preferred_lt < UINT32_MAX - now)
addr[i].preferred_lt += now;
- if (addr[i].valid < UINT32_MAX - now)
- addr[i].valid += now;
+ if (addr[i].valid_lt < UINT32_MAX - now)
+ addr[i].valid_lt += now;
}
free:
cinfo.ifa_prefered = preferred_lt;
}
- if (addr->valid) {
- int64_t valid = addr->valid - now;
- if (valid <= 0) {
+ if (addr->valid_lt) {
+ int64_t valid_lt = addr->valid_lt - now;
+ if (valid_lt <= 0) {
nlmsg_free(msg);
return -1;
}
- else if (valid > UINT32_MAX)
- valid = UINT32_MAX;
+ else if (valid_lt > UINT32_MAX)
+ valid_lt = UINT32_MAX;
- cinfo.ifa_valid = valid;
+ cinfo.ifa_valid = valid_lt;
}
nla_put(msg, IFA_CACHEINFO, sizeof(cinfo), &cinfo);
static bool parse_routes(struct odhcpd_ipaddr *n, ssize_t len)
{
struct odhcpd_ipaddr p = { .addr.in6 = IN6ADDR_ANY_INIT, .prefix = 0,
- .dprefix = 0, .preferred_lt = 0, .valid = 0};
+ .dprefix = 0, .preferred_lt = 0, .valid_lt = 0};
bool found_default = false;
char line[512], ifname[16];
struct odhcpd_ipaddr *addr = &addrs[i];
struct nd_opt_prefix_info *p = NULL;
uint32_t preferred_lt = 0;
- uint32_t valid = 0;
+ uint32_t valid_lt = 0;
- if (addr->prefix > 96 || (i < valid_addr_cnt && addr->valid <= (uint32_t)now)) {
- syslog(LOG_INFO, "Address %s (prefix %d, valid %u) not suitable as RA prefix on %s",
+ if (addr->prefix > 96 || (i < valid_addr_cnt && addr->valid_lt <= (uint32_t)now)) {
+ syslog(LOG_INFO, "Address %s (prefix %d, valid-lifetime %u) not suitable as RA prefix on %s",
inet_ntop(AF_INET6, &addr->addr.in6, buf, sizeof(buf)), addr->prefix,
- addr->valid, iface->name);
+ addr->valid_lt, iface->name);
continue;
}
preferred_lt = iface->preferred_lifetime;
}
- if (addr->valid > (uint32_t)now) {
- valid = TIME_LEFT(addr->valid, now);
+ if (addr->valid_lt > (uint32_t)now) {
+ valid_lt = TIME_LEFT(addr->valid_lt, now);
- if (iface->ra_useleasetime && valid > iface->dhcp_leasetime)
- valid = iface->dhcp_leasetime;
+ if (iface->ra_useleasetime && valid_lt > iface->dhcp_leasetime)
+ valid_lt = iface->dhcp_leasetime;
}
- if (minvalid > valid)
- minvalid = valid;
+ if (minvalid > valid_lt)
+ minvalid = valid_lt;
- if ((!IN6_IS_ADDR_ULA(&addr->addr.in6) || iface->default_router) && valid)
+ if ((!IN6_IS_ADDR_ULA(&addr->addr.in6) || iface->default_router) && valid_lt)
valid_prefix = true;
odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr.in6,
if (iface->ra_advrouter)
p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_RADDR;
p->nd_opt_pi_preferred_time = htonl(preferred_lt);
- p->nd_opt_pi_valid_time = htonl(valid);
+ p->nd_opt_pi_valid_time = htonl(valid_lt);
}
iov[IOV_RA_PFXS].iov_base = (char *)pfxs;
for (ssize_t i = 0; i < valid_addr_cnt; ++i) {
struct odhcpd_ipaddr *addr = &addrs[i];
struct nd_opt_route_info *tmp;
- uint32_t valid;
+ uint32_t valid_lt;
- if (addr->dprefix >= 64 || addr->dprefix == 0 || addr->valid <= (uint32_t)now) {
- syslog(LOG_INFO, "Address %s (dprefix %d, valid %u) not suitable as RA route on %s",
+ if (addr->dprefix >= 64 || addr->dprefix == 0 || addr->valid_lt <= (uint32_t)now) {
+ syslog(LOG_INFO, "Address %s (dprefix %d, valid-lifetime %u) not suitable as RA route on %s",
inet_ntop(AF_INET6, &addr->addr.in6, buf, sizeof(buf)),
- addr->dprefix, addr->valid, iface->name);
+ addr->dprefix, addr->valid_lt, iface->name);
continue; /* Address not suitable */
}
else if (iface->route_preference > 0)
routes[routes_cnt].flags |= ND_RA_PREF_HIGH;
- valid = TIME_LEFT(addr->valid, now);
- routes[routes_cnt].lifetime = htonl(valid < lifetime ? valid : lifetime);
+ valid_lt = TIME_LEFT(addr->valid_lt, now);
+ routes[routes_cnt].lifetime = htonl(valid_lt < lifetime ? valid_lt : lifetime);
routes[routes_cnt].addr[0] = addr->addr.in6.s6_addr32[0];
routes[routes_cnt].addr[1] = addr->addr.in6.s6_addr32[1];
routes[routes_cnt].addr[2] = 0;