This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 97ad94e6e88f4969f70bb2ef3f390c1eaa6cd981 Author: Marco Casaroli <[email protected]> AuthorDate: Thu Nov 26 11:45:03 2026 +0100 net/icmpv6: Build the ICMPv6 stack without a link layer address. icmpv6_advertise.c, icmpv6_solicit.c, icmpv6_rsolicit.c, icmpv6_radvertise.c and icmpv6_linkipaddr.c use dev->d_mac, which exists only with Ethernet, 6LoWPAN, Bluetooth, IEEE 802.15.4 or TUN. An ICMPv6 stack without one of these link layers (sim:rpproxy with CONFIG_NET_IPv6 and CONFIG_NET_ICMPv6, for example) did not compile. Give the condition of d_mac a name, NETDEV_HAVE_LLADDR in <nuttx/net/netdev.h>, and use the address only when it exists. netdev_lladdrsize() gives 0 for the other link layers, so the copies were 0 bytes there, and icmpv6_linkipaddr() goes to its case 0. neighbor_lookup.c, which had the same condition written out, uses the name too. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- include/nuttx/net/netdev.h | 12 +++++++++--- net/icmpv6/icmpv6_advertise.c | 2 ++ net/icmpv6/icmpv6_linkipaddr.c | 2 ++ net/icmpv6/icmpv6_radvertise.c | 2 ++ net/icmpv6/icmpv6_rsolicit.c | 2 ++ net/icmpv6/icmpv6_solicit.c | 2 ++ net/neighbor/neighbor_lookup.c | 4 +--- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index c3dfbd3a67c..4177e2f0e2a 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -88,6 +88,14 @@ #define NETDEV_RX_STAMP (1 << 3) /* Netdev support hardware timestamp */ #define NETDEV_TX_STAMP (1 << 4) /* Netdev provides hardware TX timestamps */ +/* The link layers with an address: struct net_driver_s has d_mac */ + +#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN) || \ + defined(CONFIG_NET_BLUETOOTH) || defined(CONFIG_NET_IEEE802154) || \ + defined(CONFIG_NET_TUN) +# define NETDEV_HAVE_LLADDR +#endif + /* Determine the largest possible address */ #if defined(CONFIG_WIRELESS_IEEE802154) && defined(CONFIG_WIRELESS_PKTRADIO) @@ -367,9 +375,7 @@ struct net_driver_s /* Link layer address */ -#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN) || \ - defined(CONFIG_NET_BLUETOOTH) || defined(CONFIG_NET_IEEE802154) || \ - defined(CONFIG_NET_TUN) +#ifdef NETDEV_HAVE_LLADDR union { # if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_TUN) diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c index 6e30e288ae5..100cd067d2f 100644 --- a/net/icmpv6/icmpv6_advertise.c +++ b/net/icmpv6/icmpv6_advertise.c @@ -103,7 +103,9 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Copy our link layer address into the message */ +#ifdef NETDEV_HAVE_LLADDR memcpy(adv->tgtlladdr, &dev->d_mac, lladdrsize); +#endif /* Update device buffer length */ diff --git a/net/icmpv6/icmpv6_linkipaddr.c b/net/icmpv6/icmpv6_linkipaddr.c index 9630760789b..c0413f98ad4 100644 --- a/net/icmpv6/icmpv6_linkipaddr.c +++ b/net/icmpv6/icmpv6_linkipaddr.c @@ -161,6 +161,7 @@ void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr) { switch (netdev_lladdrsize(dev)) { +#ifdef NETDEV_HAVE_LLADDR case 1: icmpv6_linkipaddr_1(&dev->d_mac, ipaddr); break; @@ -176,6 +177,7 @@ void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr) case 8: icmpv6_linkipaddr_8(&dev->d_mac, ipaddr); break; +#endif default: icmpv6_linkipaddr_0(dev, ipaddr); diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c index 61b56262158..61d2721140c 100644 --- a/net/icmpv6/icmpv6_radvertise.c +++ b/net/icmpv6/icmpv6_radvertise.c @@ -221,7 +221,9 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) sizeof(struct icmpv6_router_advertise_s)); srcaddr->opttype = ICMPv6_OPT_SRCLLADDR; srcaddr->optlen = ICMPv6_OPT_OCTECTS(lladdrsize); +#ifdef NETDEV_HAVE_LLADDR memcpy(srcaddr->srclladdr, &dev->d_mac, lladdrsize); +#endif /* Set up the MTU option */ diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c index f67aa62b433..4e90be1d4c9 100644 --- a/net/icmpv6/icmpv6_rsolicit.c +++ b/net/icmpv6/icmpv6_rsolicit.c @@ -98,7 +98,9 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Copy our link layer address into the message */ +#ifdef NETDEV_HAVE_LLADDR memcpy(sol->srclladdr, &dev->d_mac, lladdrsize); +#endif /* Update device buffer length */ diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c index c1157763a34..f34a1ad706b 100644 --- a/net/icmpv6/icmpv6_solicit.c +++ b/net/icmpv6/icmpv6_solicit.c @@ -120,7 +120,9 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Copy our link layer address into the message */ +#ifdef NETDEV_HAVE_LLADDR memcpy(sol->srclladdr, &dev->d_mac, lladdrsize); +#endif /* Update device buffer length */ diff --git a/net/neighbor/neighbor_lookup.c b/net/neighbor/neighbor_lookup.c index 3a6b2b45ba2..b236ca5c78d 100644 --- a/net/neighbor/neighbor_lookup.c +++ b/net/neighbor/neighbor_lookup.c @@ -82,9 +82,7 @@ static int neighbor_match(FAR struct net_driver_s *dev, FAR void *arg) info->ni_laddr->na_lltype = dev->d_lltype; info->ni_laddr->na_llsize = netdev_lladdrsize(dev); -#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN) || \ - defined(CONFIG_NET_BLUETOOTH) || defined(CONFIG_NET_IEEE802154) || \ - defined(CONFIG_NET_TUN) +#ifdef NETDEV_HAVE_LLADDR memcpy(&info->ni_laddr->u, &dev->d_mac, info->ni_laddr->na_llsize); #endif }
