diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index ec11dbb0bbc..f737b3993bd 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -536,9 +536,9 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, unsigned int timeout); ****************************************************************************/ #ifdef CONFIG_NET_ICMPv6_AUTOCONF -void icmpv6_rnotify(FAR struct net_driver_s *dev); +void icmpv6_rnotify(FAR struct net_driver_s *dev, int result); #else -# define icmpv6_rnotify(d) (0) +# define icmpv6_rnotify(d,r) (0) #endif /**************************************************************************** diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 79339b3e3af..a9ff098261f 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -441,20 +441,22 @@ void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen) FAR struct icmpv6_prefixinfo_s *prefixopt = (FAR struct icmpv6_prefixinfo_s *)opt; - /* Is the "A" flag set? */ + /* if "M" flag isn't set, and the "A" flag is set. + * Set the new network addresses. + */ - if ((prefixopt->flags & ICMPv6_PRFX_FLAG_A) != 0) + if ((adv->flags & ICMPv6_RADV_FLAG_M) == 0 && + (prefixopt->flags & ICMPv6_PRFX_FLAG_A) != 0) { - /* Yes.. Set the new network addresses. */ - - icmpv6_setaddresses(dev, ipv6->srcipaddr, + icmpv6_setaddresses(dev, ipv6->srcipaddr, prefixopt->prefix, prefixopt->preflen); - - /* Notify any waiting threads */ - - icmpv6_rnotify(dev); - prefix = true; } + + /* Notify any waiting threads */ + + icmpv6_rnotify(dev, (adv->flags & ICMPv6_RADV_FLAG_M) ? + -EADDRNOTAVAIL : OK); + prefix = true; } break; diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c index 24516da857b..4376c22e799 100644 --- a/net/icmpv6/icmpv6_rnotify.c +++ b/net/icmpv6/icmpv6_rnotify.c @@ -289,7 +289,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, unsigned int timeout) * ****************************************************************************/ -void icmpv6_rnotify(FAR struct net_driver_s *dev) +void icmpv6_rnotify(FAR struct net_driver_s *dev, int result) { FAR struct icmpv6_rnotify_s *curr; @@ -309,7 +309,7 @@ void icmpv6_rnotify(FAR struct net_driver_s *dev) { /* And signal the waiting, returning success */ - curr->rn_result = OK; + curr->rn_result = result; nxsem_post(&curr->rn_sem); break; }