Skip to content

Commit e936a26

Browse files
Mika TervonenMika Tervonen
authored andcommitted
Reduce periodic DNS traces
Only trace when there is change in the DNS status to prevent periodic DNS Traces Added Validation to DNS server address storage
1 parent a45fe3f commit e936a26

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ static void ws_bbr_dhcp_server_dns_info_update(protocol_interface_info_entry_t *
517517
for (int n = 0; n < MAX_DNS_RESOLUTIONS; n++) {
518518
if (pre_resolved_dns_queries[n].domain_name != NULL) {
519519
ptr = net_dns_option_vendor_option_data_dns_query_write(ptr, pre_resolved_dns_queries[n].address, pre_resolved_dns_queries[n].domain_name);
520-
tr_info("set DNS query result for %s, addr: %s", pre_resolved_dns_queries[n].domain_name, tr_ipv6(pre_resolved_dns_queries[n].address));
521520
}
522521
}
523522
}
@@ -1459,6 +1458,7 @@ int ws_bbr_dns_query_result_set(int8_t interface_id, const uint8_t address[16],
14591458
if (address) {
14601459
// Update address
14611460
memcpy(pre_resolved_dns_queries[n].address, address, 16);
1461+
tr_info("Update DNS query result for %s, addr: %s", pre_resolved_dns_queries[n].domain_name, tr_ipv6(pre_resolved_dns_queries[n].address));
14621462
} else {
14631463
// delete entry
14641464
memset(pre_resolved_dns_queries[n].address, 0, 16);
@@ -1481,6 +1481,7 @@ int ws_bbr_dns_query_result_set(int8_t interface_id, const uint8_t address[16],
14811481
}
14821482
memcpy(pre_resolved_dns_queries[n].address, address, 16);
14831483
strcpy(pre_resolved_dns_queries[n].domain_name, domain_name_ptr);
1484+
tr_info("set DNS query result for %s, addr: %s", pre_resolved_dns_queries[n].domain_name, tr_ipv6(pre_resolved_dns_queries[n].address));
14841485
goto update_information;
14851486
}
14861487
}

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,8 @@ static void ws_bootstrap_dhcp_info_notify_cb(int8_t interface, dhcp_option_notif
10141014
break;
10151015

10161016
case DHCPV6_OPTION_DNS_SERVERS:
1017-
while (options->option.generic.data_length) {
1017+
while (options->option.generic.data_length && options->option.generic.data_length >= 16 && options->option.generic.data_length % 16 == 0) {
1018+
// Validate payload to have full 16 byte length addresses without any extra bytes
10181019
net_dns_server_address_set(interface, server_ll64, options->option.generic.data, server_info->life_time);
10191020
options->option.generic.data_length -= 16;
10201021
options->option.generic.data += 16;

source/libNET/src/net_dns.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ int8_t net_dns_server_address_set(int8_t interface_id, const uint8_t address[16]
112112

113113
if (!info_ptr) {
114114
info_ptr = dns_server_info_create(interface_id, address);
115+
// Trace only when new entry is created
116+
tr_info("DNS Server: %s from: %s Lifetime: %lu", trace_ipv6(dns_server_address), trace_ipv6(info_ptr->address), (unsigned long) lifetime);
115117
}
116118
info_ptr->lifetime = lifetime;
117119
memcpy(info_ptr->dns_server_address, dns_server_address, 16);
118-
tr_info("DNS Server: %s from: %s Lifetime: %lu", trace_ipv6(info_ptr->dns_server_address), trace_ipv6(info_ptr->address), (unsigned long) info_ptr->lifetime);
119120
return 0;
120121
}
121122

@@ -148,22 +149,22 @@ int8_t net_dns_server_search_list_set(int8_t interface_id, const uint8_t address
148149
if (info_ptr->dns_search_list_ptr && info_ptr->dns_search_list_len != dns_search_list_len) {
149150
ns_dyn_mem_free(info_ptr->dns_search_list_ptr);
150151
info_ptr->dns_search_list_ptr = NULL;
152+
info_ptr->dns_search_list_len = 0;
151153
}
152154

153155
if (dns_search_list_len) {
154156
if (!info_ptr->dns_search_list_ptr) {
155157
info_ptr->dns_search_list_ptr = ns_dyn_mem_alloc(dns_search_list_len);
158+
159+
tr_info("DNS Search List: %s Lifetime: %lu", trace_array(dns_search_list_ptr, dns_search_list_len), (unsigned long) info_ptr->lifetime);
156160
}
157161

158162
if (!info_ptr->dns_search_list_ptr) {
159163
return -2;
160164
}
161165
memcpy(info_ptr->dns_search_list_ptr, dns_search_list_ptr, dns_search_list_len);
166+
info_ptr->dns_search_list_len = dns_search_list_len;
162167
}
163-
164-
info_ptr->dns_search_list_len = dns_search_list_len;
165-
tr_info("DNS Search List: %s Lifetime: %lu", trace_array(info_ptr->dns_search_list_ptr, info_ptr->dns_search_list_len), (unsigned long) info_ptr->lifetime);
166-
167168
return 0;
168169
}
169170

0 commit comments

Comments
 (0)