return 0;
}
-static int ndisc_router_process_prefix(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_prefix(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
uint8_t flags, prefixlen;
struct in6_addr a;
int r;
assert(link->network);
assert(rt);
+ usec_t lifetime_usec;
+ r = sd_ndisc_router_prefix_get_valid_lifetime(rt, &lifetime_usec);
+ if (r < 0)
+ return log_link_warning_errno(link, r, "Failed to get prefix lifetime: %m");
+
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
r = sd_ndisc_router_prefix_get_address(rt, &a);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get prefix address: %m");
return 0;
}
-static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
_cleanup_(route_unrefp) Route *route = NULL;
uint8_t preference, prefixlen;
struct in6_addr gateway, dst;
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get route lifetime from RA: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
r = sd_ndisc_router_route_get_address(rt, &dst);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get route destination address: %m");
ndisc_rdnss_compare_func,
free);
-static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
usec_t lifetime_usec;
const struct in6_addr *a;
struct in6_addr router;
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get RDNSS lifetime: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
n = sd_ndisc_router_rdnss_get_addresses(rt, &a);
if (n < 0)
return log_link_warning_errno(link, n, "Failed to get RDNSS addresses: %m");
ndisc_dnssl_compare_func,
free);
-static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
char **l;
usec_t lifetime_usec;
struct in6_addr router;
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get DNSSL lifetime: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
r = sd_ndisc_router_dnssl_get_domains(rt, &l);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get DNSSL addresses: %m");
ndisc_captive_portal_compare_func,
ndisc_captive_portal_free);
-static int ndisc_router_process_captive_portal(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_captive_portal(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
_cleanup_(ndisc_captive_portal_freep) NDiscCaptivePortal *new_entry = NULL;
_cleanup_free_ char *captive_portal = NULL;
const char *uri;
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get lifetime of RA message: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
r = sd_ndisc_router_get_captive_portal(rt, &uri);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get captive portal from RA: %m");
ndisc_pref64_compare_func,
mfree);
-static int ndisc_router_process_pref64(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_pref64(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
_cleanup_free_ NDiscPREF64 *new_entry = NULL;
usec_t lifetime_usec;
struct in6_addr a, router;
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get pref64 prefix lifetime: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
if (lifetime_usec == 0) {
free(set_remove(link->ndisc_pref64,
&(NDiscPREF64) {
return 0;
}
-static int ndisc_router_process_encrypted_dns(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_encrypted_dns(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
int r;
assert(link);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get lifetime of RA message: %m");
+ if ((lifetime_usec == 0) != zero_lifetime)
+ return 0;
+
r = sd_ndisc_router_encrypted_dns_get_resolver(rt, &res);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get encrypted dns resolvers: %m");
return 0;
}
-static int ndisc_router_process_options(Link *link, sd_ndisc_router *rt) {
+static int ndisc_router_process_options(Link *link, sd_ndisc_router *rt, bool zero_lifetime) {
size_t n_captive_portal = 0;
int r;
switch (type) {
case SD_NDISC_OPTION_PREFIX_INFORMATION:
- r = ndisc_router_process_prefix(link, rt);
+ r = ndisc_router_process_prefix(link, rt, zero_lifetime);
break;
case SD_NDISC_OPTION_ROUTE_INFORMATION:
- r = ndisc_router_process_route(link, rt);
+ r = ndisc_router_process_route(link, rt, zero_lifetime);
break;
case SD_NDISC_OPTION_RDNSS:
- r = ndisc_router_process_rdnss(link, rt);
+ r = ndisc_router_process_rdnss(link, rt, zero_lifetime);
break;
case SD_NDISC_OPTION_DNSSL:
- r = ndisc_router_process_dnssl(link, rt);
+ r = ndisc_router_process_dnssl(link, rt, zero_lifetime);
break;
case SD_NDISC_OPTION_CAPTIVE_PORTAL:
if (n_captive_portal > 0) {
n_captive_portal++;
continue;
}
- r = ndisc_router_process_captive_portal(link, rt);
+ r = ndisc_router_process_captive_portal(link, rt, zero_lifetime);
if (r > 0)
n_captive_portal++;
break;
case SD_NDISC_OPTION_PREF64:
- r = ndisc_router_process_pref64(link, rt);
+ r = ndisc_router_process_pref64(link, rt, zero_lifetime);
break;
case SD_NDISC_OPTION_ENCRYPTED_DNS:
- r = ndisc_router_process_encrypted_dns(link, rt);
+ r = ndisc_router_process_encrypted_dns(link, rt, zero_lifetime);
break;
}
if (r < 0 && r != -EBADMSG)
if (r < 0)
return r;
- r = ndisc_router_process_default(link, rt);
- if (r < 0)
- return r;
-
r = ndisc_router_process_reachable_time(link, rt);
if (r < 0)
return r;
if (r < 0)
return r;
- r = ndisc_router_process_options(link, rt);
+ r = ndisc_router_process_options(link, rt, /* zero_lifetime = */ true);
+ if (r < 0)
+ return r;
+
+ r = ndisc_router_process_default(link, rt);
+ if (r < 0)
+ return r;
+
+ r = ndisc_router_process_options(link, rt, /* zero_lifetime = */ false);
if (r < 0)
return r;