Skip to content

Conversation

@aurel32
Copy link
Contributor

@aurel32 aurel32 commented Nov 24, 2025

This PR fixes various issues I've found in the MQTT-SN code when trying to get it working with IPv6. I can't split in in smaller chunks if needed

errno returns a positive value, while the API specifies that a negative
value is returned in case of error. Therefore replaces "return errno" by
"return -errno".

Signed-off-by: Aurelien Jarno <[email protected]>
@aurel32 aurel32 force-pushed the mqtt-sn-ipv6-fixes branch 2 times, most recently from 0a4c656 to fcb046d Compare November 24, 2025 22:22
Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can ignore the Sonar warning, the tp_udp_init() looks ok to me.

The current allocated buffer for storing the IP address is not always
large enough to hold an IPv6 address.  Instead of using a hard-coded
value, use NET_INET6_ADDRSTRLEN, which covers all cases, including
possible mapped IPv4 addresses.

Signed-off-by: Aurelien Jarno <[email protected]>
On IPv6, the host is subscribed to a few multicast addresses by default.
Reusing such an address for MQTT-SN leads to an EALREADY error. Ignore
this error instead of returning. Do the same for IPv4 for consistency,
and because it could happen if the multicast address has already been
added manually from another part of the code, although this is really a
corner case.

Signed-off-by: Aurelien Jarno <[email protected]>
On IPv6, IPPROTO_IPV6 needs to be replaced by IPPROTO_IP and
IP_MULTICAST_TTL by IPV6_MULTICAST_HOPS.

Signed-off-by: Aurelien Jarno <[email protected]>
rlubos
rlubos previously approved these changes Nov 26, 2025
@sonarqubecloud
Copy link

@kartben kartben merged commit 5f5db5b into zephyrproject-rtos:main Nov 27, 2025
27 checks passed
@aurel32 aurel32 deleted the mqtt-sn-ipv6-fixes branch November 27, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants