-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
I have found that a gcoap shell example request fails to send a message on the tap interface. The problem looks to be in the NIB module. I describe the problem below, and then show a workaround that hopefully will help the networking wizards understand what's amiss.
The transcript below shows a gcoap example request to the tap interface fails. I have turned on debug in nib.c.
coap get fe80::845e:22ff:fe47:a59f 5683 /time
gcoap_cli: sending msg ID 9629, 11 bytes
nib: get next hop link-layer address of fe80::845e:22ff:fe47:a59f%0
nib: fe80::845e:22ff:fe47:a59f is on-link or in NC, start address resolution
nib: host unreachable
> gcoap: timeout for msg ID 9629
I can get the request to work with two actions. First, in the shell, explicitly add the tap destination to the nib cache.
> nib neigh add 6 fe80::845e:22ff:fe47:a59f 86:5e:22:47:a5:9f
Second, update gnrc_ipv6_nib_get_next_hop_l2addr()
to retain the generic_netif_t that it finds. gcoap creates the request with the SOCK_ADDR_ANY_NETIF netif. Just below the 'on_link()' test on l.188 in nib.c, I added this:
/* just found the interface; set the netif too */
if (node != NULL && iface != 0 && netif == NULL) {
DEBUG("nib: Setting interface to %u\n", iface);
gnrc_netif_release(netif);
netif = gnrc_netif_get_by_pid(iface);
gnrc_netif_acquire(netif);
}
Now the gcoap request succeeds as shown in the transcript below.
nib neigh add 6 fe80::845e:22ff:fe47:a59f 86:5e:22:47:a5:9f
> coap get fe80::845e:22ff:fe47:a59f 5683 /time
coap get fe80::845e:22ff:fe47:a59f 5683 /time
gcoap_cli: sending msg ID 52536, 11 bytes
nib: get next hop link-layer address of fe80::845e:22ff:fe47:a59f%0
nib: fe80::845e:22ff:fe47:a59f is on-link or in NC, start address resolution
nib: Setting interface to 6
nib: resolve address fe80::845e:22ff:fe47:a59f%6 from neighbor cache
> gcoap: response Success, code 2.05, 15 bytes
Dec 04 05:38:12