1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

gnrc_ipv6_nib_nc: error on non-link-local address without ARSM

This commit is contained in:
Martine S. Lenders 2020-09-01 10:15:46 +02:00
parent 14efa3185b
commit 3b7bab1108
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
3 changed files with 11 additions and 2 deletions

View File

@ -222,10 +222,13 @@ static inline unsigned gnrc_ipv6_nib_nc_get_ar_state(const gnrc_ipv6_nib_nc_t *e
* If an entry pointing to the same IPv6 address as @p ipv6 exists already it
* will be overwritten and marked as unmanaged.
*
* If @ref CONFIG_GNRC_IPV6_NIB_ARSM != 0 @p l2addr and @p l2addr_len won't be set.
* If @ref CONFIG_GNRC_IPV6_NIB_ARSM == 0 @p l2addr and @p l2addr_len won't be
* set and @p ipv6 must be a link-local address.
*
* @return 0 on success.
* @return -ENOMEM, if no space is left in neighbor cache.
* @return -EINVAL, if @p ipv6 is invalid (i.e.
* @ref CONFIG_GNRC_IPV6_NIB_ARSM == 0 and @p ipv6 is not link-local).
*/
int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface,
const uint8_t *l2addr, size_t l2addr_len);

View File

@ -46,6 +46,9 @@ int gnrc_ipv6_nib_nc_set(const ipv6_addr_t *ipv6, unsigned iface,
#else
(void)l2addr;
(void)l2addr_len;
if (!ipv6_addr_is_link_local(ipv6)) {
return -EINVAL;
}
#endif
node->info &= ~(GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK |
GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK);

View File

@ -136,7 +136,10 @@ static int _nib_neigh(int argc, char **argv)
_usage_nib_neigh(argv);
return 1;
}
gnrc_ipv6_nib_nc_set(&ipv6_addr, iface, l2addr, l2addr_len);
if (gnrc_ipv6_nib_nc_set(&ipv6_addr, iface, l2addr, l2addr_len) < 0) {
printf("Unable to add %s%%%u to neighbor cache\n",
argv[4], iface);
}
}
else if ((argc > 3) && (strcmp(argv[2], "del") == 0)) {
ipv6_addr_t ipv6_addr;