zephyr: UDP over IPSP not working on nRF52840

Describe the bug UDP packets are not sent through the IPSP interface if the destination IP is a global IP. It works just fine if the destination IP is link-local. Both ICMPv6 and TCP traffic work as expected.

Although the packets do not appear on the interface between the host and the device (analyzed using Wireshark from the host), the zephyr logs seem to indicate that they are sent, no errors occur and the packet send callback returns a value greater than zero. This was tested and replicated on the IPSP sample and other samples such as the echo server.

Environment Tested on:

  • Host
    • Linux with Kernel 4.14 / 5.15 / 5.19.6
    • Several BLE USB dongles
  • Zephyr Device
    • nRF52480DK (nrf52840dk_nrf52840)
      • Zephyr RTOS versions:
        • v.3.2.0-rc2
        • v.3.1.0
        • v.2.7.1
      • Zephyr SDK versions:
        • v.15.0
        • v.14.2
        • v.14.1

The route and IP configuration were performed manually ( CONFIG_NET_CONFIG_MY_IPV6_ADDR and CONFIG_NET_CONFIG_PEER_IPV6_ADDR) and also tested with a remote configuration via Router Advertisement with RADVD service in the host (configuration shown below).

radvd.conf

interface bt0
{
AdvSendAdvert on;
AdvDefaultPreference high;
prefix 2001:db8::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};

	route 2001:db8::/64
	{
		AdvRoutePreference high;
	        AdvRouteLifetime 3600;
	};


};

To Reproduce Steps to reproduce the behavior:

  1. Compile and flash the sample/bluetooth/ipsp sample
  2. Connect to the board from the host.
 modprobe bluetooth_6lowpan
 echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
 echo "connect  <nRF MAC> <type>" > /sys/kernel/debug/bluetooth/6lowpan_control
 ip address add 2001:db8::2/64 dev bt0 # only needed on manual IP configuration

3.a. send a UDP packet from the host to the board IP with port 4242. (for example, using Netcat) nc -6 -u <nRF IP> 4242

3.b. Alternatively, the Zephyr shell command can be used to replicate the same behavior net udp send <host IP> <host port> <Payload>

When using a global IP as destination, the board never replies and starts to send a Neighbor Solicitation request to the host IP every time it should send a UDP packet, even if there is a valid neighbor entry on net nbr or a valid route installed on the board.

Additionally, the following settings have been added to the sample’s prj_dbg.conf to try to identify the problem.

CONFIG_NET_BUF_LOG_LEVEL_DBG=y
CONFIG_NET_IF_LOG_LEVEL_DBG=y
CONFIG_NET_6LO_LOG_LEVEL_DBG=y
CONFIG_NET_IPV6_LOG_LEVEL_DBG=y
CONFIG_NET_UDP_LOG_LEVEL_DBG=y
CONFIG_NET_CORE_LOG_LEVEL_DBG=y
CONFIG_NET_ROUTE_LOG_LEVEL_DBG=y

Logs and console output In this case, the IPs will be: PC(Host)

 Link Local: fe80::8c88:2bff:fe20:39d8 with prefix length 64
Global: 2001:db8::8c88:2bff:fe20:39d8 with prefix length 64

nRf52840

 Link Local: fe80::c4b2:5bff:fe9b:d45a with prefix length 64
Global:  2001:db8::c4b2:5bff:fe9b:d45a with prefix length 64
  • Net logs from zephyr
uart:~$ net iface

Interface 0x200018f4 (Bluetooth) [1]
====================================
Link addr : C4:B2:5B:9B:D4:5A
MTU       : 1280
Flags     : NO_AUTO_START,IPv6
IPv6 unicast addresses (max 3):
        fe80::c4b2:5bff:fe9b:d45a autoconf preferred infinite
        2001:db8::c4b2:5bff:fe9b:d45a autoconf preferred
IPv6 multicast addresses (max 4):
        ff02::1
        ff02::1:ff9b:d45a
IPv6 prefixes (max 2):
        2001:db8::/64
IPv6 default router :
        fe80::8c88:2bff:fe20:39d8
IPv6 hop limit           : 64
IPv6 base reachable time : 30000
IPv6 reachable time      : 41009
IPv6 retransmit timer    : 0
uart:~$ net route

IPv6 routes for interface 1 (0x200018f4) (Bluetooth)
==================================================
IPv6 prefix : 2001:db8::/64
        neighbor : 0x20000ab8   addr : 8C:88:2B:20:39:D8        lifetime : 3596 sec
uart:~$ net ipv6
IPv6 support                              : enabled
IPv6 fragmentation support                : disabled
Multicast Listener Discovery support      : enabled
Neighbor cache support                    : enabled
Neighbor discovery support                : enabled
Duplicate address detection (DAD) support : enabled
Router advertisement RDNSS option support : enabled
6lo header compression support            : enabled
Max number of IPv6 network interfaces in the system          : 1
Max number of unicast IPv6 addresses per network interface   : 3
Max number of multicast IPv6 addresses per network interface : 4
Max number of IPv6 prefixes per network interface            : 2

IPv6 addresses for interface 1 (0x200018f4) (Bluetooth)
=====================================================
Type            State           Lifetime (sec)  Address
autoconf        preferred       infinite        fe80::c4b2:5bff:fe9b:d45a/128
autoconf        preferred       2152792         2001:db8::c4b2:5bff:fe9b:d45a/64

  • Console Log for a TCP packet send operation with the zephyr shell command(working for global and link local)
uart:~$ net tcp send "test"
Message sent
[00:06:37.625,885] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor lookup 0x20000b0c (0) iface 0x200018f4/1 addr 2001:db8::e
[00:06:37.625,915] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor 0x20000b0c addr 8C:88:2B:20:39:D8
[00:06:37.625,946] <dbg> net_if: net_if_tx: (shell_uart): Processing (pkt 0x200106f0, prio 1) network packet iface 0x200018f4/1
[00:06:37.626,007] <dbg> net_6lo: compress_hoplimit: (shell_uart): HLIM compressed (64)
[00:06:37.626,007] <dbg> net_6lo: compress_tfl: (shell_uart): Traffic class and Flow label elided
[00:06:37.719,757] <dbg> net_core: net_recv_data: (BT RX): prio 0 iface 0x200018f4 pkt 0x20010a98 len 58
[00:06:37.719,940] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x20010a98 len 58
[00:06:37.719,970] <dbg> net_6lo: get_ihpc_inlined_size: (rx_q[0]): Size of inlined IP HDR data: 36
[00:06:37.720,001] <dbg> net_6lo: uncompress_IPHC_header: (rx_q[0]): Enough tailroom. Uncompress inplace
[00:06:37.720,031] <dbg> net_6lo: uncompress_tfl: (rx_q[0]): ECN + 2-bit Pad + Flow Label, DSCP is elided
[00:06:37.720,031] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAC_0
[00:06:37.720,092] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAM_00 full src addr inlined
[00:06:37.720,123] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAC_0
[00:06:37.720,184] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAM_00 full dst addr inlined
  • Console Log for a UDP packet send operation with the zephyr shell command

  • To link-local IP (working)

uart:~$ net udp send  fe80::8c88:2bff:fe20:39d8 4242 "test"
[00:12:47.342,956] <dbg> net_ipv6: check_route: (shell_uart): Router 0x20005b90 nexthop fe80::8c88:2bff:fe20:39d8
[00:12:47.343,048] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor lookup 0x20000ab8 (0) iface 0x200018f4/1 addr fe80::8c88:2bff:fe20:39d8 state static
[00:12:47.343,078] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor 0x20000ab8 addr 8C:88:2B:20:39:D8
[00:12:47.343,109] <dbg> net_if: net_if_tx: (shell_uart): Processing (pkt 0x20010810, prio 1) network packet iface 0x200018f4/1
[00:12:47.343,139] <dbg> net_6lo: compress_nh_udp: (shell_uart): Can not compress ports, ports are inlined
[00:12:47.343,170] <dbg> net_6lo: compress_da: (shell_uart): DAM_11 dst addr fully elided
[00:12:47.343,200] <dbg> net_6lo: compress_sa: (shell_uart): SAM_11 src address is fully elided
[00:12:47.343,231] <dbg> net_6lo: compress_hoplimit: (shell_uart): HLIM compressed (64)
[00:12:47.343,261] <dbg> net_6lo: compress_tfl: (shell_uart): Traffic class and Flow label elided
[00:12:47.343,383] <dbg> net_if: net_if_tx: (shell_uart): Calling context send cb 0x20005d64 status 13
[00:12:47.416,717] <dbg> net_core: net_recv_data: (BT RX): prio 0 iface 0x200018f4 pkt 0x20010ae0 len 66
[00:12:47.416,900] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x20010ae0 len 66
[00:12:47.416,931] <dbg> net_6lo: get_ihpc_inlined_size: (rx_q[0]): Size of inlined IP HDR data: 4
[00:12:47.416,961] <dbg> net_6lo: uncompress_IPHC_header: (rx_q[0]): Enough tailroom. Uncompress inplace
[00:12:47.416,992] <dbg> net_6lo: uncompress_tfl: (rx_q[0]): ECN + 2-bit Pad + Flow Label, DSCP is elided
[00:12:47.417,022] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAC_0
[00:12:47.417,053] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAM_11 generate src addr from ll
[00:12:47.417,083] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAC_0
[00:12:47.417,114] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAM_11 generate dst addr from ll
  • To global IP (not working)
uart:~$ net udp send  2001:db8::8c88:2bff:fe20:39d8 4242 "test"
[00:14:00.579,254] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor lookup 0x20000b0c (0) iface 0x200018f4/1 addr 2001:db8::8c88:2bff:fe20:39d8 state reachable
[00:14:00.579,315] <dbg> net_ipv6: net_ipv6_prepare_for_send: (shell_uart): Neighbor 0x20000b0c addr 8C:88:2B:20:39:D8
[00:14:00.579,345] <dbg> net_if: net_if_tx: (shell_uart): Processing (pkt 0x20010810, prio 1) network packet iface 0x200018f4/1
[00:14:00.579,376] <dbg> net_6lo: compress_nh_udp: (shell_uart): Can not compress ports, ports are inlined
[00:14:00.579,406] <dbg> net_6lo: compress_hoplimit: (shell_uart): HLIM compressed (64)
[00:14:00.579,437] <dbg> net_6lo: compress_tfl: (shell_uart): Traffic class and Flow label elided
[00:14:00.579,711] <dbg> net_if: net_if_tx: (shell_uart): Calling context send cb 0x20005d64 status 45
[00:14:01.530,700] <dbg> net_core: net_recv_data: (BT RX): prio 0 iface 0x200018f4 pkt 0x20010ae0 len 51
[00:14:01.530,883] <dbg> net_core: net_rx: (rx_q[0]): Received pkt 0x20010ae0 len 51
[00:14:01.530,914] <dbg> net_6lo: get_ihpc_inlined_size: (rx_q[0]): Size of inlined IP HDR data: 17
[00:14:01.530,944] <dbg> net_6lo: uncompress_IPHC_header: (rx_q[0]): Enough tailroom. Uncompress inplace
[00:14:01.530,975] <dbg> net_6lo: uncompress_tfl: (rx_q[0]): Tcl and Flow label elided
[00:14:01.531,005] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAC_0
[00:14:01.531,036] <dbg> net_6lo: uncompress_sa: (rx_q[0]): SAM_11 generate src addr from ll
[00:14:01.531,066] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAC_0
[00:14:01.531,097] <dbg> net_6lo: uncompress_da: (rx_q[0]): DAM_00 full dst addr inlined
[00:14:01.531,188] <dbg> net_ipv6: net_ipv6_input: (rx_q[0]): IPv6 packet len 72 received from fe80::8c88:2bff:fe20:39d8 to 2001:db8::c4b2:5bff:fe9b:d45a
[00:14:01.531,341] <dbg> net_ipv6: handle_ns_input: (rx_q[0]): Received Neighbor Solicitation from fe80::8c88:2bff:fe20:39d8 to 2001:db8::c4b2:5bff:fe9b:d45a, target 2001:db8::c4b2:5bff:fe9b:d45a iface 0x200018f4/1
[00:14:01.531,463] <dbg> net_ipv6: net_ipv6_nbr_add: (rx_q[0]): [0] nbr 0x20000ab8 state 0 router 0 IPv6 fe80::8c88:2bff:fe20:39d8 ll 8C:88:2B:20:39:D8 iface 0x200018f4/1
[00:14:01.531,707] <dbg> net_ipv6: net_ipv6_send_na: (rx_q[0]): Sent Neighbor Advertisement from 2001:db8::c4b2:5bff:fe9b:d45a to fe80::8c88:2bff:fe20:39d8, target 2001:db8::c4b2:5bff:fe9b:d45a iface 0x200018f4/1
[00:14:01.531,799] <dbg> net_ipv6: check_route: (rx_q[0]): Router 0x20005b90 nexthop fe80::8c88:2bff:fe20:39d8
[00:14:01.531,860] <dbg> net_ipv6: net_ipv6_prepare_for_send: (rx_q[0]): Neighbor lookup 0x20000ab8 (0) iface 0x200018f4/1 addr fe80::8c88:2bff:fe20:39d8 state static
[00:14:01.531,921] <dbg> net_ipv6: net_ipv6_prepare_for_send: (rx_q[0]): Neighbor 0x20000ab8 addr 8C:88:2B:20:39:D8
[00:14:01.531,951] <dbg> net_if: net_if_tx: (rx_q[0]): Processing (pkt 0x20010810, prio 1) network packet iface 0x200018f4/1
[00:14:01.531,982] <dbg> net_6lo: compress_da: (rx_q[0]): DAM_11 dst addr fully elided
[00:14:01.531,982] <dbg> net_6lo: compress_hoplimit: (rx_q[0]): HLIM compressed (255)
[00:14:01.532,012] <dbg> net_6lo: compress_tfl: (rx_q[0]): Traffic class and Flow label elided
[00:14:01.532,135] <dbg> net_core: processing_data: (rx_q[0]): Consumed pkt 0x20010ae0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

@jori-nordic Thank you for your answer, as I have a special interest in this technology I will be trying to correct that behavior even though there is no maintainer in this feature. As far as I can I will try to contribute to the development of this feature.

@carlescufi After some more debugging, I think that the problem may be a problem with the Bluetooth layer 2 code, specifically in the send function ( bt_l2cap_chan_send). For the same payload, (The same case as above, TCP/UDP packet with the string “test” ) the return value for UDP with a destination link-local IP it returns 13, with TCP it returns a 17 and with UDP and global IP as destination IP it returns 45. Which, It is a bit odd that fluctuates that differences in bytes between the global UDP send and the link local, when the difference in the packet should only be the IP fields. If I’m able to figure out a fix, I will Pull Request it.