Skip to content

Commit

Permalink
DNS configuration lifetime validation
Browse files Browse the repository at this point in the history
DNS configuration lifetime needs to be at least same as the router lifetime
So it can not expire before the router is timing out.
this prevents DNS information to expire between RA messages causing inconsintent
configuration in the Wi-SUN network

"The value of Lifetime SHOULD by default be at least
3 * MaxRtrAdvInterval, where MaxRtrAdvInterval is the
maximum RA interval as defined in [RFC4861]"

Router lifetime should be
Default: 3 * MaxRtrAdvInterval
  • Loading branch information
Mika committed Oct 5, 2020
1 parent 9a3278a commit 2a465b2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/Common_Protocols/icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ static buffer_t *icmpv6_ra_handler(buffer_t *buf)
uint8_t dns_search_list_len = length - 8; // Length includes type and length
//Cut Padding
dns_search_list_len = icmpv6_dns_search_list_remove_pad(dns_search_list, dns_search_list_len);

// validate lifetime to be at least same amount as default route lifetime
if (dns_lifetime > 0 && dns_lifetime < router_lifetime) {
dns_lifetime = router_lifetime;
}
//tr_info("DNS Search List: %s Lifetime: %lu", trace_array(dns_search_list, dns_search_list_len), (unsigned long) dns_lifetime);
// Add DNS server to DNS information storage.
net_dns_server_search_list_set(cur->id, buf->src_sa.address, dns_search_list, dns_search_list_len, dns_lifetime);
Expand All @@ -899,6 +904,12 @@ static buffer_t *icmpv6_ra_handler(buffer_t *buf)
}
uint8_t dns_count = (dns_length - 1) / 2;
uint32_t dns_lifetime = common_read_32_bit(dptr + 2); // 2 x reserved

// validate lifetime to be at least same amount as default route lifetime
if (dns_lifetime > 0 && dns_lifetime < router_lifetime) {
dns_lifetime = router_lifetime;
}

for (int n = 0; n < dns_count; n++) {
uint8_t *dns_srv_addr = dptr + 6 + n * 16;
//tr_info("DNS Server: %s Lifetime: %lu", trace_ipv6(dns_srv_addr), (unsigned long) dns_lifetime);
Expand Down

0 comments on commit 2a465b2

Please sign in to comment.