This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 00cf3e559d367f16d93511ce272c0963285684c0 Author: luojun1 <luoj...@xiaomi.com> AuthorDate: Fri Jul 29 19:22:27 2022 +0800 update IPv6 NIC parameters unconditionally when ICMPv6 RA is received Signed-off-by: luojun1 <luoj...@xiaomi.com> Signed-off-by: chao.an <anc...@xiaomi.com> --- net/icmpv6/icmpv6.h | 25 ++++++++++++++++++++----- net/icmpv6/icmpv6_input.c | 8 ++++++-- net/icmpv6/icmpv6_rnotify.c | 24 +++++++----------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 1e3fbbe2e0..5b1b498afb 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -424,6 +424,24 @@ void icmpv6_notify(net_ipv6addr_t ipaddr); int icmpv6_autoconfig(FAR struct net_driver_s *dev); #endif +/**************************************************************************** + * Name: icmpv6_setaddresses + * + * Description: + * We successfully obtained the Router Advertisement. Set the new IPv6 + * addresses in the driver structure. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ICMPv6_AUTOCONF +void icmpv6_setaddresses(FAR struct net_driver_s *dev, + const net_ipv6addr_t draddr, + const net_ipv6addr_t prefix, + unsigned int preflen); +#else +# define icmpv6_setaddresses(d,d,p,p) (0) +#endif + /**************************************************************************** * Name: icmpv6_rwait_setup * @@ -502,12 +520,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, - const net_ipv6addr_t draddr, - const net_ipv6addr_t prefix, - unsigned int preflen); +void icmpv6_rnotify(FAR struct net_driver_s *dev); #else -# define icmpv6_rnotify(d,p,l) +# define icmpv6_rnotify(d) (0) #endif /**************************************************************************** diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 4684eb0f49..1408f1d82a 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -391,10 +391,14 @@ void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen) if ((prefixopt->flags & ICMPv6_PRFX_FLAG_A) != 0) { - /* Notify any waiting threads */ + /* Yes.. Set the new network addresses. */ - icmpv6_rnotify(dev, ipv6->srcipaddr, + icmpv6_setaddresses(dev, ipv6->srcipaddr, prefixopt->prefix, prefixopt->preflen); + + /* Notify any waiting threads */ + + icmpv6_rnotify(dev); prefix = true; } } diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c index 5c5c563a0b..392b83883f 100644 --- a/net/icmpv6/icmpv6_rnotify.c +++ b/net/icmpv6/icmpv6_rnotify.c @@ -58,22 +58,22 @@ static struct icmpv6_rnotify_s *g_icmpv6_rwaiters; /**************************************************************************** - * Private Functions + * Public Functions ****************************************************************************/ /**************************************************************************** * Name: icmpv6_setaddresses * * Description: - * We successfully obtained the Router Advertisement. See the new IPv6 + * We successfully obtained the Router Advertisement. Set the new IPv6 * addresses in the driver structure. * ****************************************************************************/ -static void icmpv6_setaddresses(FAR struct net_driver_s *dev, - const net_ipv6addr_t draddr, - const net_ipv6addr_t prefix, - unsigned int preflen) +void icmpv6_setaddresses(FAR struct net_driver_s *dev, + const net_ipv6addr_t draddr, + const net_ipv6addr_t prefix, + unsigned int preflen) { unsigned int i; @@ -139,10 +139,6 @@ static void icmpv6_setaddresses(FAR struct net_driver_s *dev, net_unlock(); } -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * Name: icmpv6_rwait_setup * @@ -287,9 +283,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, unsigned int timeout) * ****************************************************************************/ -void icmpv6_rnotify(FAR struct net_driver_s *dev, - const net_ipv6addr_t draddr, const net_ipv6addr_t prefix, - unsigned int preflen) +void icmpv6_rnotify(FAR struct net_driver_s *dev) { FAR struct icmpv6_rnotify_s *curr; @@ -307,10 +301,6 @@ void icmpv6_rnotify(FAR struct net_driver_s *dev, if (curr->rn_result != OK && strncmp(curr->rn_ifname, dev->d_ifname, IFNAMSIZ) == 0) { - /* Yes.. Set the new network addresses. */ - - icmpv6_setaddresses(dev, draddr, prefix, preflen); - /* And signal the waiting, returning success */ curr->rn_result = OK;