Add a fake SVC parameter "_lifetime=" which allows explicit configuration of
the maximum time in seconds over which a given ADN announcement is valid. In
particular, this allows announcing ADNs which should no longer be used (zero
lifetime, see rfc9463, §6.1).
In the absence of an explicit lifetime, the previous logic is kept (i.e. the
lifetime is set to 3 * MaxRtrAdvInterval, as per §6.1 of RFC9463).
Signed-off-by: David Härdeman <david@hardeman.nu>
svc_key = strtok_r(svc_tok, "=", &saveptr2);
svc_val = strtok_r(NULL, "=", &saveptr2);
+ if (!strcmp(svc_key, "_lifetime")) {
+ uint32_t lifetime;
+
+ if (!svc_val || sscanf(svc_val, "%" SCNu32, &lifetime) != 1) {
+ syslog(LOG_ERR, "Invalid value '%s' for _lifetime", svc_val ? svc_val : "");
+ goto err;
+ }
+
+ dnr.lifetime = lifetime;
+ dnr.lifetime_set = true;
+ continue;
+ }
+
for (svc_id = 0; svc_id < DNR_SVC_MAX; svc_id++)
if (!strcmp(svc_key, svc_param_key_names[svc_id]))
break;
struct dnr_options {
uint16_t priority;
+ uint32_t lifetime;
+ bool lifetime_set;
+
uint8_t *adn;
uint16_t adn_len;
dnr->type = ND_OPT_DNR;
dnr->len = dnr_sz[i] / 8;
dnr->priority = htons(iface->dnr[i].priority);
- dnr->lifetime = htonl(lifetime);
+ if (iface->dnr[i].lifetime_set)
+ dnr->lifetime = htonl(iface->dnr[i].lifetime);
+ else
+ dnr->lifetime = htonl(lifetime);
dnr->adn_len = htons(iface->dnr[i].adn_len);
memcpy(tmp, iface->dnr[i].adn, iface->dnr[i].adn_len);