mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 03:32:42 +01:00
dbus: Use native ell kdbus calls
It seems until now dbus.c would always connect to dbus-1 (unless DBUS_SESSION_BUS_ADDRESS pointed at kdbus) and passing -K only made iwd create a kdbus bus and not use it. Now use ell to actually use kdbus instead of dbus-1 with -K. Don't use the src/kdbus.c functions that duplicate ell functionality. As a side effect the connection description and the bloom sizes are now the ell defaults.
This commit is contained in:
parent
f983196d44
commit
79839dbfd6
32
src/dbus.c
32
src/dbus.c
@ -24,11 +24,16 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ell/ell.h>
|
||||
#include <ell/dbus-private.h>
|
||||
#include "src/dbus.h"
|
||||
#include "src/manager.h"
|
||||
|
||||
struct l_dbus *g_dbus = 0;
|
||||
static int kdbus_fd = -1;
|
||||
|
||||
static void do_debug(const char *str, void *user_data)
|
||||
{
|
||||
@ -204,9 +209,31 @@ struct l_dbus *dbus_get_bus(void)
|
||||
return g_dbus;
|
||||
}
|
||||
|
||||
bool dbus_init(bool enable_debug)
|
||||
bool dbus_init(bool enable_debug, bool use_kdbus)
|
||||
{
|
||||
if (!use_kdbus)
|
||||
g_dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
|
||||
else {
|
||||
char bus_name[32], bus_address[64];
|
||||
|
||||
snprintf(bus_name, sizeof(bus_name), "%u-iwd", getuid());
|
||||
|
||||
kdbus_fd = _dbus_kernel_create_bus(bus_name);
|
||||
if (kdbus_fd < 0)
|
||||
return false;
|
||||
|
||||
snprintf(bus_address, sizeof(bus_address),
|
||||
"kernel:path=/dev/kdbus/%s/bus", bus_name);
|
||||
|
||||
l_debug("Bus location: %s", bus_address);
|
||||
|
||||
g_dbus = l_dbus_new(bus_address);
|
||||
|
||||
if (!g_dbus) {
|
||||
close(kdbus_fd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable_debug)
|
||||
l_dbus_set_debug(g_dbus, do_debug, "[DBUS] ", NULL);
|
||||
@ -229,5 +256,8 @@ bool dbus_exit(void)
|
||||
l_dbus_destroy(g_dbus);
|
||||
g_dbus = NULL;
|
||||
|
||||
if (kdbus_fd >= 0)
|
||||
close(kdbus_fd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -61,5 +61,5 @@ struct l_dbus_message *dbus_error_no_agent(struct l_dbus_message *msg);
|
||||
struct l_dbus_message *dbus_error_not_connected(struct l_dbus_message *msg);
|
||||
struct l_dbus_message *dbus_error_not_implemented(struct l_dbus_message *msg);
|
||||
|
||||
bool dbus_init(bool enable_debug);
|
||||
bool dbus_init(bool enable_debug, bool use_kdbus);
|
||||
bool dbus_exit(void);
|
||||
|
34
src/main.c
34
src/main.c
@ -33,7 +33,6 @@
|
||||
|
||||
#include "src/netdev.h"
|
||||
#include "src/wiphy.h"
|
||||
#include "src/kdbus.h"
|
||||
#include "src/dbus.h"
|
||||
#include "src/agent.h"
|
||||
#include "src/network.h"
|
||||
@ -165,38 +164,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
l_info("Wireless daemon version %s", VERSION);
|
||||
|
||||
if (enable_kdbus) {
|
||||
char *bus_name;
|
||||
bool result;
|
||||
|
||||
if (!kdbus_create_bus()) {
|
||||
if (!dbus_init(enable_dbus_debug, enable_kdbus)) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
bus_name = kdbus_lookup_bus();
|
||||
if (!bus_name) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
goto fail_dbus;
|
||||
}
|
||||
|
||||
l_debug("Bus location: %s", bus_name);
|
||||
|
||||
result = kdbus_open_bus(bus_name, "net.connman.iwd", "iwd");
|
||||
|
||||
l_free(bus_name);
|
||||
|
||||
if (!result) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
goto fail_dbus;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dbus_init(enable_dbus_debug)) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
goto fail_dbus;
|
||||
}
|
||||
|
||||
genl = l_genl_new_default();
|
||||
if (!genl) {
|
||||
l_error("Failed to open generic netlink socket");
|
||||
@ -244,10 +216,6 @@ fail_netdev:
|
||||
fail_genl:
|
||||
dbus_exit();
|
||||
|
||||
fail_dbus:
|
||||
if (enable_kdbus)
|
||||
kdbus_destroy_bus();
|
||||
|
||||
done:
|
||||
l_signal_remove(signal);
|
||||
l_timeout_remove(timeout);
|
||||
|
Loading…
Reference in New Issue
Block a user