connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] service: Support hot-plug of technologies by updating ipconfig index
@ 2021-11-16 15:34 Jussi Laakkonen
  2021-11-18 21:05 ` Daniel Wagner
  0 siblings, 1 reply; 2+ messages in thread
From: Jussi Laakkonen @ 2021-11-16 15:34 UTC (permalink / raw)
  To: connman

It is important to update the index of the ipconfig belonging to the
service that is to be created from network after re-inserting a
technology that supports hot-plug (e.g., an USB ethernet adapter). The
service does exist in such case but the interface index is not updated
which results in DHCP failing to start. This is because the old index
would be used.

With this change index update is always done regardless of the existing
path for the service.
---
 src/service.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index 8d3c75a5..9141b85d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -7464,8 +7464,19 @@ struct connman_service * __connman_service_create_from_network(struct connman_ne
 	if (__connman_network_get_weakness(network))
 		return service;
 
+	index = connman_network_get_index(network);
+
 	if (service->path) {
 		update_from_network(service, network);
+
+		if (service->ipconfig_ipv4)
+			__connman_ipconfig_set_index(service->ipconfig_ipv4,
+									index);
+
+		if (service->ipconfig_ipv6)
+			__connman_ipconfig_set_index(service->ipconfig_ipv6,
+									index);
+
 		__connman_connection_update_gateway();
 		return service;
 	}
@@ -7496,14 +7507,16 @@ struct connman_service * __connman_service_create_from_network(struct connman_ne
 
 	update_from_network(service, network);
 
-	index = connman_network_get_index(network);
-
 	if (!service->ipconfig_ipv4)
 		service->ipconfig_ipv4 = create_ip4config(service, index,
 				CONNMAN_IPCONFIG_METHOD_DHCP);
+	else
+		__connman_ipconfig_set_index(service->ipconfig_ipv4, index);
 
 	if (!service->ipconfig_ipv6)
 		service->ipconfig_ipv6 = create_ip6config(service, index);
+	else
+		__connman_ipconfig_set_index(service->ipconfig_ipv6, index);
 
 	service_register(service);
 	service_schedule_added(service);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] service: Support hot-plug of technologies by updating ipconfig index
  2021-11-16 15:34 [PATCH] service: Support hot-plug of technologies by updating ipconfig index Jussi Laakkonen
@ 2021-11-18 21:05 ` Daniel Wagner
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Wagner @ 2021-11-18 21:05 UTC (permalink / raw)
  To: Jussi Laakkonen; +Cc: connman

Hi Jussi,

On Tue, Nov 16, 2021 at 05:34:35PM +0200, Jussi Laakkonen wrote:
> It is important to update the index of the ipconfig belonging to the
> service that is to be created from network after re-inserting a
> technology that supports hot-plug (e.g., an USB ethernet adapter). The
> service does exist in such case but the interface index is not updated
> which results in DHCP failing to start. This is because the old index
> would be used.
> 
> With this change index update is always done regardless of the existing
> path for the service.

Patch applied.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-18 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 15:34 [PATCH] service: Support hot-plug of technologies by updating ipconfig index Jussi Laakkonen
2021-11-18 21:05 ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).