Skip to content

Commit 3e8b4ce

Browse files
author
Tero Heinonen
authored
Multicast registration time fix (#1631)
Fix for multicast registration timeouts.
1 parent f5530b1 commit 3e8b4ce

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

source/6LoWPAN/Thread/thread_constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164

165165
#define THREAD_ENTERPRISE_NUMBER 44970
166166

167-
#define THREAD_ADDR_REG_TIMEOUT_BASE 300
167+
#define THREAD_ADDR_REG_RETRY_INTERVAL 300
168168
#define THREAD_PROACTIVE_AN_INTERVAL 3600
169169

170170
// Router defines

source/6LoWPAN/Thread/thread_extension.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ int thread_extension_primary_bbr_get(struct protocol_interface_info_entry *cur,
271271
}
272272
if (mlr_timer_ptr) {
273273
*mlr_timer_ptr = common_read_32_bit(&found_tlv[7]);
274+
if (*mlr_timer_ptr < THREAD_DEFAULT_MIN_MLR_TIMEOUT) {
275+
*mlr_timer_ptr = THREAD_DEFAULT_MIN_MLR_TIMEOUT;
276+
}
274277
}
275278
return 0;
276279
}
@@ -496,14 +499,16 @@ void thread_extension_mcast_subscrition_change(protocol_interface_info_entry_t *
496499
if (addr_ipv6_multicast_scope(group->group) < IPV6_SCOPE_ADMIN_LOCAL) {
497500
return;
498501
}
499-
// Default timer added.
500-
group->mld_timer = added ? THREAD_ADDR_REG_TIMEOUT_BASE + randLIB_get_random_in_range(1, 30) : 0;
501502

502-
if (0 !=thread_extension_primary_bbr_get(interface, br_ml_addr, NULL, &mlr_timer, NULL )) {
503+
if (0 != thread_extension_primary_bbr_get(interface, br_ml_addr, NULL, &mlr_timer, NULL )) {
504+
// No BBR, try again later if adding address.
505+
group->mld_timer = added ? THREAD_ADDR_REG_RETRY_INTERVAL + randLIB_get_random_in_range(1, 30) : 0;
503506
return;
504507
}
505-
// follow the Primary BBR set timeout + Small jitter added
506-
group->mld_timer = added ? mlr_timer: 0;
508+
509+
// follow the Primary BBR set timeout.
510+
group->mld_timer = added ? (mlr_timer - randLIB_get_random_in_range(30, 40)) : 0;
511+
507512
// MLR is sent only for primary BBR for now, but this might change
508513
thread_extension_mlr_req_send(interface, br_ml_addr, group->group);
509514

source/6LoWPAN/Thread/thread_extension_bbr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ typedef struct {
9898
static NS_LIST_DEFINE(pbbr_instance_list, thread_pbbr_t, link);
9999
static NS_LIST_DEFINE(duplicate_dua_tr_list, duplicate_dua_tr_t, link);
100100

101-
102-
#define THREAD_BBR_MLR_REGISTRATION_TIMEOUT 120
101+
#define THREAD_BBR_MLR_REGISTRATION_TIMEOUT 600 //<* Default MLR timeout in seconds
103102
#define THREAD_BBR_DUA_REGISTRATION_TIMEOUT 3600
104-
#define THREAD_BBR_DUA_REGISTRATION_DELAY 5000 // 5 seconds in ms
105-
#define THREAD_BBR_BACKBONE_PORT 5683 //<* Backbone border router
103+
#define THREAD_BBR_DUA_REGISTRATION_DELAY 5000 // 5 seconds in ms
104+
#define THREAD_BBR_BACKBONE_PORT 5683 //<* Backbone border router
106105

107106
/*
108107
0 – Successful registration
@@ -608,8 +607,9 @@ static int thread_extension_bbr_mlr_cb(int8_t service_id, uint8_t source_address
608607
bbr_status = THREAD_BBR_STATUS_NOT_PRIMARY_BBR;
609608
goto send_response;
610609
}
610+
611+
//check if commissioner
611612
if (2 <= thread_meshcop_tlv_data_get_uint16(request_ptr->payload_ptr, request_ptr->payload_len, MESHCOP_TLV_COMMISSIONER_SESSION_ID, &session_id)) {
612-
//check if commissioner
613613
// Session id present must be valid
614614
tr_info("message from commissioner");
615615
if (cur->thread_info->registered_commissioner.session_id != session_id) {
@@ -630,8 +630,10 @@ static int thread_extension_bbr_mlr_cb(int8_t service_id, uint8_t source_address
630630
response_code = COAP_MSG_CODE_RESPONSE_BAD_REQUEST;
631631
goto send_response;
632632
}
633+
633634
int16_t remaining = addr_len;
634635
uint8_t *addr_ptr = addr_data_ptr;
636+
635637
while (remaining > 0) {
636638
//Go through all addresses
637639
if (timeout_value == 0) {

source/6LoWPAN/Thread/thread_extension_constants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ typedef struct discovery_additional_info {
3838
bool ccm_supported:1;
3939
}discovery_additional_info_t;
4040

41+
/**
42+
* Minimum specified MLR timeout in seconds
43+
*/
44+
#define THREAD_DEFAULT_MIN_MLR_TIMEOUT 300
45+
4146
/**
4247
* Default Autonomous enrollment port.
4348
*/

0 commit comments

Comments
 (0)