public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] dbus: register interface before acquiring name
@ 2026-01-27 22:40 Ronan Pigott
  2026-01-30 15:45 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Ronan Pigott @ 2026-01-27 22:40 UTC (permalink / raw)
  To: iwd; +Cc: Ronan Pigott

If the interface isn't available by the time we acquire the well-known
name, clients can get confused when the expected interfaces are missing
during bus activation.
---
This code seems backwards to me. Presently, if IWD is not running,
calling any IWD methods will fail:

  $ busctl call net.connman.iwd /net/connman/iwd net.connman.iwd.Daemon GetInfo
  Call failed: No matching method found

only to succeed immediately after once the bus activation is complete:

  $ busctl call net.connman.iwd /net/connman/iwd net.connman.iwd.Daemon GetInfo
  a{sv} 3 "NetworkConfigurationEnabled" b false "StateDirectory" s "/var/lib/iwd" "Version" s "3.10"

With this patch, we register IWD methods before acquiring the well-known
name, and the abovve call succeeds on the first try.

 src/main.c | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/src/main.c b/src/main.c
index beaf228fb3cd..0f27488211d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -197,29 +197,8 @@ static void request_name_callback(struct l_dbus *dbus, bool success,
 {
 	if (!success) {
 		l_error("Name request failed");
-		goto fail_exit;
+		l_main_quit();
 	}
-
-	if (!l_dbus_object_manager_enable(dbus, "/"))
-		l_warn("Unable to register the ObjectManager");
-
-	if (!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
-						IWD_DAEMON_INTERFACE,
-						NULL) ||
-			!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
-						L_DBUS_INTERFACE_PROPERTIES,
-						NULL))
-		l_info("Unable to add %s and/or %s at %s",
-			IWD_DAEMON_INTERFACE, L_DBUS_INTERFACE_PROPERTIES,
-			IWD_BASE_PATH);
-
-	/* TODO: Always request nl80211 for now, ignoring auto-loading */
-	l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
-				NULL, NULL);
-	return;
-
-fail_exit:
-	l_main_quit();
 }
 
 static struct l_dbus_message *iwd_dbus_get_info(struct l_dbus *dbus,
@@ -249,12 +228,29 @@ static void dbus_ready(void *user_data)
 {
 	struct l_dbus *dbus = user_data;
 
-	l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
-				request_name_callback, NULL);
-
 	l_dbus_register_interface(dbus, IWD_DAEMON_INTERFACE,
 					iwd_setup_deamon_interface,
 					NULL, false);
+
+	if (!l_dbus_object_manager_enable(dbus, "/"))
+		l_warn("Unable to register the ObjectManager");
+
+	if (!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
+						IWD_DAEMON_INTERFACE,
+						NULL) ||
+			!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
+						L_DBUS_INTERFACE_PROPERTIES,
+						NULL))
+		l_info("Unable to add %s and/or %s at %s",
+			IWD_DAEMON_INTERFACE, L_DBUS_INTERFACE_PROPERTIES,
+			IWD_BASE_PATH);
+
+	/* TODO: Always request nl80211 for now, ignoring auto-loading */
+	l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
+				NULL, NULL);
+
+	l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
+				request_name_callback, NULL);
 }
 
 static void dbus_disconnected(void *user_data)
-- 
2.52.0


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

* Re: [PATCH] dbus: register interface before acquiring name
  2026-01-27 22:40 [PATCH] dbus: register interface before acquiring name Ronan Pigott
@ 2026-01-30 15:45 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2026-01-30 15:45 UTC (permalink / raw)
  To: Ronan Pigott, iwd

Hi Ronan,

On 1/27/26 4:40 PM, Ronan Pigott wrote:
> If the interface isn't available by the time we acquire the well-known
> name, clients can get confused when the expected interfaces are missing
> during bus activation.
> ---
> This code seems backwards to me. Presently, if IWD is not running,
> calling any IWD methods will fail:
> 
>    $ busctl call net.connman.iwd /net/connman/iwd net.connman.iwd.Daemon GetInfo
>    Call failed: No matching method found
> 
> only to succeed immediately after once the bus activation is complete:
> 
>    $ busctl call net.connman.iwd /net/connman/iwd net.connman.iwd.Daemon GetInfo
>    a{sv} 3 "NetworkConfigurationEnabled" b false "StateDirectory" s "/var/lib/iwd" "Version" s "3.10"
> 
> With this patch, we register IWD methods before acquiring the well-known
> name, and the abovve call succeeds on the first try.
> 
>   src/main.c | 46 +++++++++++++++++++++-------------------------
>   1 file changed, 21 insertions(+), 25 deletions(-)
> 

<snip>

> @@ -249,12 +228,29 @@ static void dbus_ready(void *user_data)
>   {
>   	struct l_dbus *dbus = user_data;
>   
> -	l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
> -				request_name_callback, NULL);
> -
>   	l_dbus_register_interface(dbus, IWD_DAEMON_INTERFACE,
>   					iwd_setup_deamon_interface,
>   					NULL, false);
> +
> +	if (!l_dbus_object_manager_enable(dbus, "/"))
> +		l_warn("Unable to register the ObjectManager");
> +
> +	if (!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
> +						IWD_DAEMON_INTERFACE,
> +						NULL) ||
> +			!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
> +						L_DBUS_INTERFACE_PROPERTIES,
> +						NULL))
> +		l_info("Unable to add %s and/or %s at %s",
> +			IWD_DAEMON_INTERFACE, L_DBUS_INTERFACE_PROPERTIES,
> +			IWD_BASE_PATH);
> +
> +	/* TODO: Always request nl80211 for now, ignoring auto-loading */
> +	l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
> +				NULL, NULL);

nit: I would preserve some of the original behavior and not request the NL80211 
family until we know that the DBus name request succeeded.  If we can't jump on 
the bus, we can't manage NL80211, so having the subsystem loaded, etc is wasteful.

> +
> +	l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
> +				request_name_callback, NULL);
>   }

Otherwise, looks reasonable.

>   
>   static void dbus_disconnected(void *user_data)

Regards,
-Denis

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

end of thread, other threads:[~2026-01-30 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 22:40 [PATCH] dbus: register interface before acquiring name Ronan Pigott
2026-01-30 15:45 ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox