Skip to content

Commit 56831ad

Browse files
author
Juha Heiskanen
committed
Wi-sun BBR Slaac Ula support fix
SLAAC ULA was broken because it never genrate address and thats why RPL never advertisment prefix. Change-Id: Id02a6712feb60f8204b92349c4bcd80f6e825abc
1 parent add63fe commit 56831ad

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,38 @@ int ws_border_router_proxy_state_update(int8_t caller_interface_id, int8_t handl
175175
return 0;
176176
}
177177

178+
static if_address_entry_t *ws_bbr_slaac_generate(protocol_interface_info_entry_t *cur, uint8_t *ula_prefix)
179+
{
180+
if_address_entry_t *add_entry = icmpv6_slaac_address_add(cur, ula_prefix, 64, 0xffffffff, 0xffffffff, true, SLAAC_IID_FIXED);
181+
if (!add_entry) {
182+
tr_err("ula create failed");
183+
return NULL;
184+
}
185+
addr_policy_table_add_entry(ula_prefix, 64, 2, WS_NON_PREFFRED_LABEL);
186+
return add_entry;
187+
}
188+
189+
static void ws_bbr_slaac_remove(protocol_interface_info_entry_t *cur, uint8_t *ula_prefix)
190+
{
191+
icmpv6_slaac_prefix_update(cur, ula_prefix, 64, 0, 0);
192+
addr_policy_table_delete_entry(ula_prefix, 64);
193+
}
194+
195+
178196
static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
179197
{
180198
if (memcmp(current_dodag_id, ADDR_UNSPECIFIED, 16) != 0) {
181199
// address generated
182200
return 0;
183201
}
184202
// This address is only used if no other address available.
185-
if_address_entry_t *add_entry = icmpv6_slaac_address_add(cur, static_dodag_id_prefix, 64, 0xffffffff, 0xffffffff, true, SLAAC_IID_FIXED);
203+
if_address_entry_t *add_entry = ws_bbr_slaac_generate(cur, static_dodag_id_prefix);
186204
if (!add_entry) {
187205
tr_err("dodagid create failed");
188206
return -1;
189207
}
190208
memcpy(current_dodag_id, add_entry->address, 16);
191209
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));
192-
addr_policy_table_add_entry(static_dodag_id_prefix, 64, 2, WS_NON_PREFFRED_LABEL);
193210

194211
return 0;
195212
}
@@ -360,9 +377,16 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
360377
// Start static ULA prefix and routing always
361378
if (memcmp(current_local_prefix, ADDR_UNSPECIFIED, 8) != 0) {
362379
// Remove Old ULA prefix
380+
ws_bbr_slaac_remove(cur, current_local_prefix);
363381
rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, current_local_prefix, 64, PIO_A, 0, 0, true);
382+
memset(current_local_prefix, 0, 8);
364383
}
384+
365385
if (memcmp(local_prefix, ADDR_UNSPECIFIED, 8) != 0) {
386+
if (!ws_bbr_slaac_generate(cur, local_prefix)) {
387+
return;
388+
}
389+
366390
tr_info("RPL Local prefix activate %s", trace_ipv6_prefix(local_prefix, 64));
367391
rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, local_prefix, 64, PIO_A, WS_ULA_LIFETIME, WS_ULA_LIFETIME, false);
368392
memcpy(current_local_prefix, local_prefix, 8);
@@ -372,7 +396,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
372396
/*
373397
* Check if backup ULA prefix is needed
374398
*/
375-
if (memcmp(global_prefix, ADDR_UNSPECIFIED, 8) == 0) {
399+
if ((configuration & BBR_ULA_C) == 0 && memcmp(global_prefix, ADDR_UNSPECIFIED, 8) == 0) {
376400
//Global prefix not available count if backup ULA should be created
377401
global_prefix_unavailable_timer += BBR_CHECK_INTERVAL;
378402
tr_debug("Check for backup prefix %"PRIu32"", global_prefix_unavailable_timer);

0 commit comments

Comments
 (0)