Skip to content

sock_udp_send() reports success even though the message was never sent #11551

@benpicco

Description

@benpicco

Description

When sending the first message to a host with sock_udp_send(), the function will report the number of byes sent, 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(): no link-layer address or interface for next hop to de71:c105::1.

The Address is subsequently resolved:

ipv6: waiting for incoming message.
ipv6: GNRC_NETAPI_MSG_TYPE_RCV received
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 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

Metadata

Metadata

Labels

Area: networkArea: NetworkingType: new featureThe issue requests / The PR implemements a new feature for RIOT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions