Skip to content

Commit eddf91b

Browse files
author
Juha Heiskanen
committed
Wi-sun neighbor generate limitation
RPL control added API for request parent list size. Avoid multicast neighbour generation after bootstarp. Multicast will be dropped at Border router allwayd for genrating new neighbours. Node drop multicast if neighbour candidate is 4 or bigger or selected parent size is 2 or gigger. Data accepted if it is multicast but only accepted is multicast RPL DIS. NS probe is only done 1 for unicast neighbour and multiple time only for parent. Change-Id: I08761b3dc296a938b3a2a1ab10895643f8da69da
1 parent 4d6abb3 commit eddf91b

File tree

10 files changed

+167
-41
lines changed

10 files changed

+167
-41
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
8181
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
8282
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data);
8383

84-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new);
84+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast);
8585
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur);
8686
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur);
8787
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur);
@@ -104,6 +104,13 @@ typedef enum {
104104
WS_EAPOL_PARENT_SYNCH, /**< Broadcast synch with EAPOL parent*/
105105
} ws_parent_synch_e;
106106

107+
static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *mac64)
108+
{
109+
memcpy(ll_address, ADDR_LINK_LOCAL_PREFIX, 8);
110+
memcpy(ll_address + 8, mac64, 8);
111+
ll_address[8] ^= 2;
112+
}
113+
107114
mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
108115

109116
{
@@ -312,9 +319,7 @@ static bool ws_nud_message_build(protocol_interface_info_entry_t *cur, mac_neigh
312319
{
313320
//Send NS
314321
uint8_t ll_target[16];
315-
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
316-
memcpy(ll_target + 8, neighbor->mac64, 8);
317-
ll_target[8] ^= 2;
322+
ws_bootsrap_create_ll_address(ll_target, neighbor->mac64);
318323
tr_info("NUD generate NS %u", neighbor->index);
319324
buffer_t *buffer = icmpv6_build_ns(cur, ll_target, NULL, true, false, NULL);
320325
if (buffer) {
@@ -923,7 +928,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
923928
// Save route cost for all neighbours
924929
llc_neighbour_req_t neighbor_info;
925930
neighbor_info.neighbor = NULL;
926-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
931+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
927932
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
928933
}
929934

@@ -1073,7 +1078,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10731078
return;
10741079
}
10751080
llc_neighbour_req_t neighbor_info;
1076-
if (!ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true)) {
1081+
if (!ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true, true)) {
10771082
return;
10781083
}
10791084

@@ -1156,7 +1161,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
11561161
*/
11571162

11581163
llc_neighbour_req_t neighbor_info;
1159-
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
1164+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false, false)) {
11601165
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
11611166
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp);
11621167
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
@@ -1347,7 +1352,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13471352
memcpy(ll_target + 8, cur->mac64, 8);
13481353
ll_target[8] ^= 2;
13491354

1350-
if (rpl_control_is_dodag_parent(interface, ll_target)) {
1355+
if (rpl_control_is_dodag_parent(interface, ll_target, true)) {
13511356
// Possible parent is limited to 3 by default?
13521357
continue;
13531358
}
@@ -1365,7 +1370,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13651370
link_min_timeout = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT;
13661371
}
13671372

1368-
if (time_from_last_unicast_shedule > link_min_timeout) {
1373+
if (time_from_last_unicast_shedule > link_min_timeout || !ws_neighbor->unicast_data_rx) {
13691374
//Accept only Enough Old Device
13701375
if (!neighbor_entry_ptr) {
13711376
//Accept first compare
@@ -1386,7 +1391,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13861391

13871392
}
13881393

1389-
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new)
1394+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast)
13901395
{
13911396
neighbor_buffer->neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), mac_64, ADDR_802_15_4_LONG);
13921397
if (neighbor_buffer->neighbor) {
@@ -1399,15 +1404,34 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
13991404
if (!request_new) {
14001405
return false;
14011406
}
1402-
uint8_t ll_target[16];
1403-
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
1404-
memcpy(ll_target + 8, mac_64, 8);
1405-
ll_target[8] ^= 2;
14061407

1408+
if (!multicast) {
1409+
uint8_t ll_target[16];
1410+
ws_bootsrap_create_ll_address(ll_target, mac_64);
14071411

1408-
if (blacklist_reject(ll_target)) {
1409-
// Rejected by blacklist
1410-
return false;
1412+
if (blacklist_reject(ll_target)) {
1413+
// Rejected by blacklist
1414+
return false;
1415+
}
1416+
} else {
1417+
1418+
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
1419+
//Border router never allocate neighbors by multicast
1420+
return false;
1421+
}
1422+
1423+
uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size(interface, false);
1424+
1425+
//if we have enough candidates at list do not accept new multicast neighbours
1426+
if (parent_candidate_size >= 4) {
1427+
return false;
1428+
}
1429+
1430+
parent_candidate_size = rpl_control_parent_candidate_list_size(interface, true);
1431+
//If we have already enough parent selected Candidates count is bigger tahn 4
1432+
if (parent_candidate_size >= 2) {
1433+
return false;
1434+
}
14111435
}
14121436

14131437
ws_bootstrap_neighbor_table_clean(interface);
@@ -1483,6 +1507,21 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
14831507
//Accept quick Probe for init ETX
14841508
activate_nud = true;
14851509
} else {
1510+
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
1511+
if (etx_entry->etx_samples || !ws_neighbor->unicast_data_rx) {
1512+
//Border router just need 1 sample for ETX
1513+
return false;
1514+
}
1515+
} else {
1516+
uint8_t ll_address[16];
1517+
ws_bootsrap_create_ll_address(ll_address, entry_ptr->mac64);
1518+
if (!rpl_control_is_dodag_parent(cur, ll_address, false)) {
1519+
if (etx_entry->etx_samples || !ws_neighbor->unicast_data_rx) {
1520+
return 0;
1521+
}
1522+
}
1523+
}
1524+
14861525
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
14871526
uint32_t time_block = 1 << etx_entry->etx_samples;
14881527
if (time_from_start >= probe_period) {
@@ -2471,7 +2510,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
24712510

24722511
// Add EAPOL neighbour
24732512
llc_neighbour_req_t neighbor_info;
2474-
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true)) {
2513+
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true, false)) {
24752514
return;
24762515
}
24772516

@@ -2664,9 +2703,7 @@ void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_ne
26642703
neighbor_info.ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
26652704
ws_bootstrap_primary_parent_set(interface, &neighbor_info, WS_PARENT_HARD_SYNCH);
26662705
uint8_t link_local_address[16];
2667-
memcpy(link_local_address, ADDR_LINK_LOCAL_PREFIX, 8);
2668-
memcpy(link_local_address + 8, neighbor->mac64, 8);
2669-
link_local_address[8] ^= 2;
2706+
ws_bootsrap_create_ll_address(link_local_address, neighbor->mac64);
26702707
dhcp_client_server_address_update(interface->id, NULL, link_local_address);
26712708

26722709
ws_secondary_parent_update(interface);

source/6LoWPAN/ws/ws_llc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ typedef void ws_asynch_confirm(struct protocol_interface_info_entry *interface,
9999
* @param mac_64 Neighbor 64-bit address
100100
* @param neighbor_buffer Buffer where neighbor infor is buffered
101101
* @param request_new true if is possible to allocate new entry
102+
* @param multicast true if packet is multicast
102103
*
103104
* @return true when neighbor info is available
104105
* @return false when no neighbor info
105106
*/
106-
typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new);
107+
typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast);
107108

108109
/**
109110
* @brief ws_llc_create ws LLC module create

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *
395395
success = true;
396396
}
397397

398-
if (message->dst_address_type == MAC_ADDR_MODE_64_BIT && base->ws_neighbor_info_request_cb(interface, message->dst_address, &neighbor_info, false)) {
398+
if (message->dst_address_type == MAC_ADDR_MODE_64_BIT && base->ws_neighbor_info_request_cb(interface, message->dst_address, &neighbor_info, false, false)) {
399399
etx_transm_attempts_update(interface->id, 1 + data->tx_retries, success, neighbor_info.neighbor->index);
400400
//TODO discover RSL from Enchanced ACK Header IE elements
401401
ws_utt_ie_t ws_utt;
@@ -493,6 +493,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
493493
return;
494494
}
495495

496+
mpx_user_t *user_cb;
496497
mac_payload_IE_t mpx_ie;
497498
mpx_ie.id = MAC_PAYLOAD_MPX_IE_GROUP_ID;
498499
if (mac_ie_payload_discover(ie_ext->payloadIeList, ie_ext->payloadIeListLength, &mpx_ie) < 1) {
@@ -521,12 +522,24 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
521522
}
522523

523524
llc_neighbour_req_t neighbor_info;
525+
bool multicast;
526+
if (data->DstAddrMode == ADDR_802_15_4_LONG) {
527+
multicast = false;
528+
} else {
529+
multicast = true;
530+
}
524531

525-
if (!base->ws_neighbor_info_request_cb(interface, data->SrcAddr, &neighbor_info, us_ie_inline)) {
526-
tr_debug("Drop message no neighbor");
527-
return;
532+
if (!base->ws_neighbor_info_request_cb(interface, data->SrcAddr, &neighbor_info, us_ie_inline, multicast)) {
533+
if (!multicast || ws_utt.message_type == WS_FT_EAPOL) {
534+
tr_debug("Drop message no neighbor");
535+
return;
536+
} else {
537+
goto mpx_data_ind;
538+
}
528539
}
529540

541+
multicast = false;
542+
530543
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, &ws_utt, data->timestamp);
531544
if (us_ie_inline) {
532545
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, &us_ie);
@@ -558,6 +571,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
558571

559572
//Refresh Neighbor ETX if unicast
560573
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode == ADDR_802_15_4_LONG) {
574+
neighbor_info.ws_neighbor->unicast_data_rx = true;
561575
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
562576
}
563577
if (ws_utt.message_type == WS_FT_DATA) {
@@ -570,10 +584,15 @@ static void ws_llc_mac_indication_cb(const mac_api_t *api, const mcps_data_ind_t
570584
}
571585
}
572586

587+
588+
mpx_data_ind:
573589
// Discover MPX
574-
mpx_user_t *user_cb = ws_llc_mpx_user_discover(&base->mpx_data_base, mpx_frame.multiplex_id);
590+
user_cb = ws_llc_mpx_user_discover(&base->mpx_data_base, mpx_frame.multiplex_id);
575591
if (user_cb && user_cb->data_ind) {
576592
mcps_data_ind_t data_ind = *data;
593+
if (multicast) {
594+
data_ind.Key.SecurityLevel = 0; //Mark unknow device
595+
}
577596
data_ind.msdu_ptr = mpx_frame.frame_ptr;
578597
data_ind.msduLength = mpx_frame.frame_length;
579598
user_cb->data_ind(&base->mpx_data_base.mpx_api, &data_ind);

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef struct ws_neighbor_class_entry {
3434
bool synch_done : 1;
3535
bool accelerated_etx_probe : 1;
3636
bool negative_aro_send : 1;
37+
bool unicast_data_rx : 1;
3738
} ws_neighbor_class_entry_t;
3839

3940
/**

source/Common_Protocols/icmpv6.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,7 @@ buffer_t *icmpv6_up(buffer_t *buf)
10371037

10381038
cur = buf->interface;
10391039

1040-
if (buf->options.ll_security_bypass_rx) {
1041-
tr_debug("ICMP: Drop by EP");
1042-
goto drop;
1043-
}
1040+
10441041

10451042
if (data_len < 4) {
10461043
//tr_debug("Ic1");
@@ -1051,6 +1048,13 @@ buffer_t *icmpv6_up(buffer_t *buf)
10511048
buf->options.type = *dptr++;
10521049
buf->options.code = *dptr++;
10531050

1051+
if (buf->options.ll_security_bypass_rx) {
1052+
if (!ws_info(buf->interface) || !(buf->options.type == ICMPV6_TYPE_INFO_RPL_CONTROL && buf->options.code == ICMPV6_CODE_RPL_DIS)) {
1053+
//tr_debug("ICMP: Drop by EP");
1054+
goto drop;
1055+
}
1056+
}
1057+
10541058
/* Check FCS first */
10551059
if (buffer_ipv6_fcf(buf, IPV6_NH_ICMPV6)) {
10561060
tr_warn("ICMP cksum error!");

source/RPL/rpl_control.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ void rpl_control_register_address(protocol_interface_info_entry_t *interface, co
189189

190190
void rpl_control_address_register_done(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16], uint8_t status)
191191
{
192+
if (!interface->rpl_domain) {
193+
return;
194+
}
192195
if (!rpl_policy_parent_confirmation_requested()) {
193196
return;
194197
}
@@ -201,19 +204,44 @@ void rpl_control_address_register_done(protocol_interface_info_entry_t *interfac
201204
}
202205
}
203206

204-
bool rpl_control_is_dodag_parent(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16])
207+
bool rpl_control_is_dodag_parent(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16], bool selected)
205208
{
209+
if (!interface->rpl_domain) {
210+
return false;
211+
}
206212
// go through instances and parents and check if they match the address.
207213
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
208-
if (rpl_instance_address_is_parent(instance, ll_addr)) {
214+
if (rpl_instance_address_is_parent(instance, ll_addr, selected)) {
209215
return true;
210216
}
211217
}
212218
return false;
213219
}
214220

221+
uint16_t rpl_control_parent_candidate_list_size(protocol_interface_info_entry_t *interface, bool parent_list)
222+
{
223+
if (!interface->rpl_domain) {
224+
return 0;
225+
}
226+
227+
uint16_t parent_list_size = 0;
228+
229+
// go through instances and parents and check if they match the address.
230+
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
231+
uint16_t current_size = rpl_instance_address_candidate_count(instance, parent_list);
232+
if (current_size > parent_list_size) {
233+
parent_list_size = current_size;
234+
}
235+
}
236+
return parent_list_size;
237+
}
238+
239+
215240
void rpl_control_neighbor_delete(protocol_interface_info_entry_t *interface, const uint8_t ll_addr[16])
216241
{
242+
if (!interface->rpl_domain) {
243+
return;
244+
}
217245
// go through instances and delete address.
218246
ns_list_foreach(struct rpl_instance, instance, &interface->rpl_domain->instances) {
219247

source/RPL/rpl_control.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ void rpl_control_set_callback(rpl_domain_t *domain, rpl_domain_callback_t callba
147147
/* Target publishing */
148148
void rpl_control_publish_host_address(rpl_domain_t *domain, const uint8_t addr[16], uint32_t lifetime);
149149
void rpl_control_unpublish_address(rpl_domain_t *domain, const uint8_t addr[16]);
150-
bool rpl_control_is_dodag_parent(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]);
150+
bool rpl_control_is_dodag_parent(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16], bool selected);
151+
uint16_t rpl_control_parent_candidate_list_size(struct protocol_interface_info_entry *interface, bool parent_list);
151152
void rpl_control_neighbor_delete(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]);
152153
/* Parent link confirmation API extension */
153154
void rpl_control_request_parent_link_confirmation(bool requested);

0 commit comments

Comments
 (0)