Skip to content

Commit eeb5168

Browse files
IPv6 route metrics update (#1912)
Reverts changes made in commit 0a18231 Added metric to aro route. Added ROUTE_ARO to probe table. Changed ll address to destination registered address. Added new flag to probe avoided routers.
1 parent 1debcca commit eeb5168

File tree

6 files changed

+13
-18
lines changed

6 files changed

+13
-18
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ void protocol_6lowpan_configure_core(protocol_interface_info_entry_t *cur)
373373
cur->ipv6_neighbour_cache.link_mtu = LOWPAN_MTU;
374374
#ifdef HAVE_6LOWPAN_ND
375375
cur->ipv6_neighbour_cache.send_nud_probes = nd_params.send_nud_probes;
376+
cur->ipv6_neighbour_cache.probe_avoided_routers = nd_params.send_nud_probes;
376377
cur->iids_map_to_mac = nd_params.iids_map_to_mac;
377378
#endif
378379
cur->ip_multicast_as_mac_unicast_to_parent = false;

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -839,20 +839,13 @@ buffer_t *nd_dar_parse(buffer_t *buf, protocol_interface_info_entry_t *cur_inter
839839
#ifdef HAVE_6LOWPAN_ROUTER
840840
static void nd_update_registration(protocol_interface_info_entry_t *cur_interface, ipv6_neighbour_t *neigh, const aro_t *aro)
841841
{
842-
uint8_t ll64[16];
843-
844-
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
845-
memcpy(&ll64[8], aro->eui64, 8);
846-
ll64[8] ^= 2;
847-
848-
849842
/* We are about to send an ARO response - update our Neighbour Cache accordingly */
850843
if (aro->status == ARO_SUCCESS && aro->lifetime != 0) {
851844
neigh->type = IP_NEIGHBOUR_REGISTERED;
852845
neigh->lifetime = aro->lifetime * UINT32_C(60);
853846
ipv6_neighbour_set_state(&cur_interface->ipv6_neighbour_cache, neigh, IP_NEIGHBOUR_STALE);
854847
/* Register with 2 seconds off the lifetime - don't want the NCE to expire before the route */
855-
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, ll64, ROUTE_ARO, neigh->lifetime - 2, 0);
848+
ipv6_route_add_metric(neigh->ip_address, 128, cur_interface->id, neigh->ip_address, ROUTE_ARO, NULL, 0, neigh->lifetime - 2, 32);
856849

857850
/* We need to know peer is a host before publishing - this needs MLE. Not yet established
858851
* what to do without MLE - might need special external/non-external prioritisation at root.
@@ -871,24 +864,19 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
871864
neigh->type = IP_NEIGHBOUR_TENTATIVE;
872865
neigh->lifetime = 2;
873866
ipv6_neighbour_set_state(&cur_interface->ipv6_neighbour_cache, neigh, IP_NEIGHBOUR_STALE);
874-
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, ll64, ROUTE_ARO, 4, 0);
867+
ipv6_route_add_metric(neigh->ip_address, 128, cur_interface->id, neigh->ip_address, ROUTE_ARO, NULL, 0, 4, 32);
875868
rpl_control_unpublish_address(protocol_6lowpan_rpl_domain, neigh->ip_address);
876869
}
877870
}
878871

879872
void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address)
880873
{
881-
uint8_t ll64[16];
882-
883-
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
884-
885874
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list) {
886875
if ((cur->type == IP_NEIGHBOUR_REGISTERED
887876
|| cur->type == IP_NEIGHBOUR_TENTATIVE)
888877
&& ipv6_neighbour_ll_addr_match(cur, ll_type, ll_address)) {
889-
memcpy(&ll64[8], ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, cur), 8);
890-
ll64[8] ^= 2;
891-
ipv6_route_delete(cur->ip_address, 128, cur_interface->id,ll64,
878+
879+
ipv6_route_delete(cur->ip_address, 128, cur_interface->id, cur->ip_address,
892880
ROUTE_ARO);
893881
ipv6_neighbour_entry_remove(&cur_interface->ipv6_neighbour_cache,
894882
cur);

source/6LoWPAN/Thread/thread_bootstrap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ void thread_interface_init(protocol_interface_info_entry_t *cur)
902902
cur->if_snoop = thread_nd_snoop;
903903
cur->if_icmp_handler = thread_nd_icmp_handler;
904904
cur->ipv6_neighbour_cache.send_nud_probes = false;
905+
cur->ipv6_neighbour_cache.probe_avoided_routers = false;
905906
cur->ipv6_neighbour_cache.recv_addr_reg = true;
906907
cur->send_mld = false;
907908
cur->ip_multicast_as_mac_unicast_to_parent = true;
@@ -1514,6 +1515,7 @@ int thread_bootstrap_reset(protocol_interface_info_entry_t *cur)
15141515
cur->thread_info->thread_attached_state = THREAD_STATE_NETWORK_DISCOVER;
15151516
}
15161517
cur->ipv6_neighbour_cache.send_nud_probes = false; //Disable NUD probing
1518+
cur->ipv6_neighbour_cache.probe_avoided_routers = false;
15171519
cur->ip_multicast_as_mac_unicast_to_parent = true;
15181520
//Define Default Contexts
15191521
if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
638638
cur->ipv6_neighbour_cache.omit_aro_success = true;
639639
/* Disable NUD Probes */
640640
cur->ipv6_neighbour_cache.send_nud_probes = false;
641+
cur->ipv6_neighbour_cache.probe_avoided_routers = true;
641642
dhcp_client_init(cur->id);
642643

643644
ws_nud_table_reset(cur);

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ void ipv6_neighbour_cache_init(ipv6_neighbour_cache_t *cache, int8_t interface_i
172172
cache->recv_addr_reg = false;
173173
cache->send_addr_reg = false;
174174
cache->send_nud_probes = true;
175+
cache->probe_avoided_routers = true;
175176
cache->recv_na_aro = false;
176177
cache->recv_ns_aro = false;
177178
cache->route_if_info.metric = 0;
@@ -1099,6 +1100,7 @@ static const char *route_src_names[] = {
10991100
/* (Others are assumed to be always reachable) */
11001101
static const bool ipv6_route_probing[ROUTE_MAX] = {
11011102
[ROUTE_RADV] = true,
1103+
[ROUTE_ARO] = true,
11021104
[ROUTE_RPL_DAO] = true,
11031105
[ROUTE_RPL_DIO] = true,
11041106
[ROUTE_RPL_ROOT] = true,
@@ -1225,7 +1227,7 @@ static bool ipv6_route_same_router(const ipv6_route_t *a, const ipv6_route_t *b)
12251227
static void ipv6_route_probe(ipv6_route_t *route)
12261228
{
12271229
ipv6_neighbour_cache_t *ncache = ipv6_neighbour_cache_by_interface_id(route->info.interface_id);
1228-
if (!ncache || !ncache->send_nud_probes || route->probe_timer) {
1230+
if (!ncache || !ncache->probe_avoided_routers || route->probe_timer) {
12291231
return;
12301232
}
12311233

@@ -1378,7 +1380,7 @@ ipv6_route_t *ipv6_route_choose_next_hop(const uint8_t *dest, int8_t interface_i
13781380
continue;
13791381
}
13801382

1381-
if (ncache->send_nud_probes && ipv6_route_probing[route->info.source]) {
1383+
if (ncache->probe_avoided_routers && ipv6_route_probing[route->info.source]) {
13821384
/* Going via a router - check reachability, as per RFC 4191.
13831385
* This only applies for certain routes (currently those from RAs) */
13841386
reachable = ipv6_neighbour_addr_is_probably_reachable(ncache, route->info.next_hop_addr);

source/ipv6_stack/ipv6_routing_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ typedef struct ipv6_neighbour_cache {
119119
bool send_addr_reg : 1;
120120
bool recv_addr_reg : 1;
121121
bool send_nud_probes : 1;
122+
bool probe_avoided_routers : 1;
122123
bool recv_ns_aro : 1;
123124
bool recv_na_aro : 1;
124125
bool use_eui64_as_slla_in_aro : 1;

0 commit comments

Comments
 (0)