[riot-notifications] [RIOT-OS/RIOT] sock_udp_send() reports success even though the message was never sent (#11551)

benpicco notifications at github.com
Mon May 20 15:12:39 CEST 2019

#### Description
When sending a message with `sock_udp_send()`, the function will report the number of byes send, indicating success. But in reality the packet never reached the device driver - it was silently dropped by the IPv6 layer with no error being propagated. (unless you `ENABLE_DEBUG` is set in `gnrc_ipv6.c` - then a debug message is printed)

#### Steps to reproduce the issue
- configure a custom, non-link-local IP address:

    ipv6_addr_t addr;
    gnrc_netif_t *netif = gnrc_netif_iter(NULL);
    gnrc_netif_ipv6_addrs_get(netif, &addr, sizeof(addr));

    addr.u8[0] = 0xde;
    addr.u8[1] = 0x71;
    addr.u8[2] = 0xc1;
    addr.u8[3] = 0x05;

    gnrc_netif_ipv6_addr_add(netif, &addr, 64, 0);

- send a message to the remote

    sock_udp_ep_t remote = { .family = AF_INET6, .port = port };
    ipv6_addr_from_str((ipv6_addr_t *)&remote.addr, "de71:c105::1");
    int res = sock_udp_send(NULL, "Hello", 6, &remote);

#### Expected results
Either `res < 0` and the message failed to be send, or `res == 6` and the message is being sent.

#### Actual results
`res == 6`, the message is not being sent.

When tracing the packet through the network stack it becomes evident that it is dropped in [`_send_unicast()`](https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c#L401): `no link-layer address or interface for next hop to de71:c105::1`.

The Address is subsequently resolved:
ipv6: waiting for incoming message.
ipv6: Received (src = de71:c105::1, dst = de71:c105::8d1b:3202:ae20:bb66, next header = 58, length = 40)
ipv6: forward nh = 58 to other threads
ipv6: handle ICMPv6 packet (nh = 58)

However, `_send_unicast` does not return an error and the [`GNRC_NETAPI_MSG_TYPE_SND`](https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c#L191) case will not report an error to the upper layer.

My current hack around this is to send a dummy message after startup, but this is of course not a very nice solution.

#### Versions
RIOT 2019.04

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190520/0b4446b6/attachment.html>

More information about the notifications mailing list