Skip to content

Commit 4021b0c

Browse files
author
Juha Heiskanen
committed
LLC secure data duplicate check update and EAPOL relay duplicate fix
Store Unicast Data sequency number and drop all duplicates in 5 second period. EAPOL realay duplicate filtter use normal neighbour info when it available.
1 parent b190a97 commit 4021b0c

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

source/6LoWPAN/ws/ws_eapol_pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static void ws_eapol_pdu_mpx_data_indication(const mpx_api_t *api, const struct
310310

311311
ns_list_foreach(eapol_pdu_recv_cb_t, entry, &eapol_pdu_data->recv_cb_list) {
312312
if (entry->addr_check(eapol_pdu_data->interface_ptr, data->SrcAddr) >= 0) {
313-
if (entry->filter_requsted && !ws_llc_eapol_relay_forward_filter(eapol_pdu_data->interface_ptr, data->SrcAddr, data->DSN)) {
313+
if (entry->filter_requsted && !ws_llc_eapol_relay_forward_filter(eapol_pdu_data->interface_ptr, data->SrcAddr, data->DSN, data->timestamp)) {
314314
tr_info("EAPOL relay filter drop");
315315
return;
316316
}

source/6LoWPAN/ws/ws_llc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interf
226226

227227
void ws_llc_timer_seconds(struct protocol_interface_info_entry *interface, uint16_t seconds_update);
228228

229-
bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *interface, const uint8_t *joiner_eui64, uint8_t mac_sequency);
229+
bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *interface, const uint8_t *joiner_eui64, uint8_t mac_sequency, uint32_t rx_timestamp);
230230

231231
ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);
232232

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,11 @@ static void ws_llc_data_indication_cb(const mac_api_t *api, const mcps_data_ind_
648648
}
649649
}
650650

651+
if (!multicast && !ws_neighbor_class_neighbor_duplicate_packet_check(neighbor_info.ws_neighbor, data->DSN, data->timestamp)) {
652+
tr_info("Drop duplicate message");
653+
return;
654+
}
655+
651656
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, &ws_utt, data->timestamp);
652657
if (us_ie_inline) {
653658
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, &us_ie);
@@ -1674,7 +1679,7 @@ void ws_llc_timer_seconds(struct protocol_interface_info_entry *interface, uint1
16741679
}
16751680
}
16761681

1677-
bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *interface, const uint8_t *joiner_eui64, uint8_t mac_sequency)
1682+
bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *interface, const uint8_t *joiner_eui64, uint8_t mac_sequency, uint32_t rx_timestamp)
16781683
{
16791684
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
16801685
if (!base) {
@@ -1683,7 +1688,12 @@ bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *int
16831688

16841689
ws_neighbor_temp_class_t *neighbor = ws_llc_discover_eapol_temp_entry(base->temp_entries, joiner_eui64);
16851690
if (!neighbor) {
1686-
return false;
1691+
llc_neighbour_req_t neighbor_info;
1692+
//Discover here Normal Neighbour
1693+
if (!base->ws_neighbor_info_request_cb(interface, joiner_eui64, &neighbor_info, false)) {
1694+
return false;
1695+
}
1696+
return ws_neighbor_class_neighbor_duplicate_packet_check(neighbor_info.ws_neighbor, mac_sequency, rx_timestamp);
16871697
}
16881698

16891699
if (neighbor->eapol_temp_info.eapol_rx_relay_filter && neighbor->eapol_temp_info.last_rx_mac_sequency == mac_sequency) {

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,32 @@ void ws_neighbor_class_rsl_out_calculate(ws_neighbor_class_entry_t *ws_neighbor,
322322
return;
323323
}
324324

325+
326+
bool ws_neighbor_class_neighbor_duplicate_packet_check(ws_neighbor_class_entry_t *ws_neighbor, uint8_t mac_dsn, uint32_t rx_timestamp)
327+
{
328+
if (ws_neighbor->last_DSN != mac_dsn) {
329+
// New packet allways accepted
330+
ws_neighbor->last_DSN = mac_dsn;
331+
return true;
332+
}
333+
334+
if (!ws_neighbor->unicast_data_rx) {
335+
// No unicast info stored always accepted
336+
return true;
337+
}
338+
339+
rx_timestamp -= ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp;
340+
rx_timestamp /= 1000000; //Convert to s
341+
342+
//Compare only when last rx timestamp is less than 5 seconds
343+
if (rx_timestamp < 5) {
344+
//Packet is sent too fast filter it out
345+
return false;
346+
}
347+
348+
return true;
349+
}
350+
351+
325352
#endif /* HAVE_WS */
326353

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ typedef struct ws_neighbor_class_entry {
2828
uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/
2929
uint16_t rsl_out; /*!< RSL EWMA heard by neighbour*/
3030
uint16_t routing_cost; /*!< ETX to border Router. */
31+
uint8_t last_DSN;
3132
bool candidate_parent: 1;
3233
bool broadcast_timing_info_stored: 1;
3334
bool broadcast_shedule_info_stored: 1;
@@ -181,4 +182,6 @@ void ws_neighbor_class_rsl_in_calculate(ws_neighbor_class_entry_t *ws_neighbor,
181182
*/
182183
void ws_neighbor_class_rsl_out_calculate(ws_neighbor_class_entry_t *ws_neighbor, uint8_t rsl_reported);
183184

185+
bool ws_neighbor_class_neighbor_duplicate_packet_check(ws_neighbor_class_entry_t *ws_neighbor, uint8_t mac_dsn, uint32_t rx_timestamp);
186+
184187
#endif /* WS_NEIGHBOR_CLASS_H_ */

test/nanostack/unittest/stub/ws_neighbour_class_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ void ws_neighbor_class_rsl_out_calculate(ws_neighbor_class_entry_t *ws_neighbor,
110110

111111
}
112112

113+
bool ws_neighbor_class_neighbor_duplicate_packet_check(ws_neighbor_class_entry_t *ws_neighbor, uint8_t mac_dsn, uint32_t rx_timestamp)
114+
{
115+
return true;
116+
}
117+

0 commit comments

Comments
 (0)