diff mbox series

[v2,6/6] net: update net_ip6 from link_local address when eth device is changed

Message ID 20230510165959.2228978-6-dimorinny@google.com
State Superseded
Delegated to: Ramon Fried
Headers show
Series [v2,1/6] net: split IP_TCP header into separate IP/IP6 and TCP headers | expand

Commit Message

Dmitrii Merkurev May 10, 2023, 4:59 p.m. UTC
Current active eth device may be changed (due to ethprime), so make
sure current net_ip6 is updated as a reaction.

Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
Cc: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Сс: Joe Hershberger <joe.hershberger@ni.com>
Сс: Ramon Fried <rfried.dev@gmail.com>
---
 net/net.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Simon Glass July 23, 2023, 3:48 a.m. UTC | #1
On Wed, 10 May 2023 at 11:00, Dmitrii Merkurev <dimorinny@google.com> wrote:
>
> Current active eth device may be changed (due to ethprime), so make
> sure current net_ip6 is updated as a reaction.
>
> Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
> Cc: Simon Glass <sjg@chromium.org>
> Сс: Joe Hershberger <joe.hershberger@ni.com>
> Сс: Ramon Fried <rfried.dev@gmail.com>
> ---
>  net/net.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/net/net.c b/net/net.c
index 9ef290dc41..0f14f29de8 100644
--- a/net/net.c
+++ b/net/net.c
@@ -359,10 +359,10 @@  static int net_init_loop(void)
 
 		if (IS_ENABLED(CONFIG_IPV6)) {
 			ip6_make_lladdr(&net_link_local_ip6, net_ethaddr);
-			if (!memcmp(&net_ip6, &net_null_addr_ip6,
-				    sizeof(struct in6_addr)))
-				memcpy(&net_ip6, &net_link_local_ip6,
-				       sizeof(struct in6_addr));
+			if (memcmp(&net_link_local_ip6, &net_null_addr_ip6,
+				   sizeof(struct in6_addr))) {
+				net_copy_ip6(&net_ip6, &net_link_local_ip6);
+			}
 		}
 	}
 	else