Skip to content

Commit f5a00a0

Browse files
author
Juha Heiskanen
committed
Fixed DHCPv6 prefix update case
Border router remove client same time than server -> fix address missing at Wi-sun border router. RPL prefix update will deprecate old address at case when RPL start advertisment a new Prefix. Fix case when same time old prefix deleted and new activated. Change-Id: Icc22f7f7631ac315617a64707524cfda6fb4ee70
1 parent e06c8b2 commit f5a00a0

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
3838
#include "6LoWPAN/ws/ws_pae_controller.h"
3939
#include "DHCPv6_Server/DHCPv6_server_service.h"
40+
#include "DHCPv6_client/dhcpv6_client_api.h"
4041

4142
#include "ws_bbr_api.h"
4243

@@ -285,8 +286,13 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
285286
}
286287
static void ws_bbr_dhcp_server_stop(protocol_interface_info_entry_t *cur, uint8_t *global_id)
287288
{
288-
tr_debug("DHCP server deactivate %s", trace_ipv6(global_id));
289+
uint8_t temp_address[16];
290+
memcpy(temp_address, global_id, 8);
291+
memset(temp_address + 8, 0, 8);
292+
tr_debug("DHCP server deactivate %s", trace_ipv6(temp_address));
289293
DHCPv6_server_service_delete(cur->id, global_id, false);
294+
//Delete Client
295+
dhcp_client_global_address_delete(cur->id, NULL, temp_address);
290296

291297
}
292298

source/DHCPv6_client/dhcpv6_client_service.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,28 @@ int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16
235235
//Already Created to same interface
236236
if (dhcp_client.one_instance_interface && prefix) {
237237
if (srv_data_ptr->iaNonTemporalStructValid) {
238-
if (memcmp(srv_data_ptr->iaNontemporalAddress.addressPrefix, prefix, 8)) {
239-
//Request new address direct from Server if prefix is new
240-
srv_data_ptr->iaNonTemporalStructValid = false;
241-
dhcpv6_renew(protocol_stack_interface_info_get_by_id(interface), NULL, ADDR_CALLBACK_TIMER);
238+
if (memcmp(srv_data_ptr->iaNontemporalAddress.addressPrefix, prefix, 8) == 0) {
239+
return 0;
242240
}
243-
return 0;
241+
242+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface);
243+
if (!cur) {
244+
return -1;
245+
}
246+
247+
dhcp_service_req_remove_all(srv_data_ptr);// remove all pending retransmissions
248+
addr_deprecate(cur, srv_data_ptr->iaNontemporalAddress.addressPrefix);
249+
srv_data_ptr->iaNonTemporalStructValid = false;
250+
memcpy(srv_data_ptr->iaNontemporalAddress.addressPrefix, prefix, 8);
251+
goto dhcp_address_get;
252+
244253
} else if (dhcp_client_server_address_update(interface, prefix, dhcp_addr) == 0) {
245254
//DHCP server address OK
246255
return 0;
247256
}
248257
}
249258
return -1;
259+
250260
}
251261
} else if (dhcp_client_server_address_update(interface, prefix, dhcp_addr) == 0) {
252262
//No need for allocate new
@@ -260,7 +270,7 @@ int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16
260270
tr_error("OOM srv_data_ptr");
261271
return -1;
262272
}
263-
273+
dhcp_address_get:
264274

265275
if (!prefix || dhcp_client.no_address_hint) {
266276
add_prefix = false;

0 commit comments

Comments
 (0)