|
|
964f4f |
From 1c58317f56e312576b6872440f125f794e45f991 Mon Sep 17 00:00:00 2001
|
|
|
964f4f |
Message-Id: <1c58317f56e312576b6872440f125f794e45f991.1602774933.git.davide.caratti@gmail.com>
|
|
|
964f4f |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
964f4f |
Date: Wed, 30 Sep 2020 18:34:36 +0200
|
|
|
964f4f |
Subject: [PATCH] D-Bus: Allow changing an interface bridge via D-Bus
|
|
|
964f4f |
|
|
|
964f4f |
D-Bus clients can call CreateInterface() once and use the resulting
|
|
|
964f4f |
Interface object to connect multiple times to different networks.
|
|
|
964f4f |
|
|
|
964f4f |
However, if the network interface gets added to a bridge, clients
|
|
|
964f4f |
currently have to remove the Interface object and create a new one.
|
|
|
964f4f |
|
|
|
964f4f |
Improve this by supporting the change of the BridgeIfname property of
|
|
|
964f4f |
an existing Interface object.
|
|
|
964f4f |
|
|
|
964f4f |
Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
964f4f |
---
|
|
|
964f4f |
src/rsn_supp/tdls.c | 5 +++
|
|
|
964f4f |
wpa_supplicant/dbus/dbus_new.c | 2 +-
|
|
|
964f4f |
wpa_supplicant/dbus/dbus_new_handlers.c | 37 ++++++++++++++++
|
|
|
964f4f |
wpa_supplicant/dbus/dbus_new_handlers.h | 1 +
|
|
|
964f4f |
wpa_supplicant/wpa_supplicant.c | 59 +++++++++++++++++++++++++
|
|
|
964f4f |
wpa_supplicant/wpa_supplicant_i.h | 2 +
|
|
|
964f4f |
6 files changed, 105 insertions(+), 1 deletion(-)
|
|
|
964f4f |
|
|
|
964f4f |
diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c
|
|
|
964f4f |
index 7b47e3ac5..eff8cd829 100644
|
|
|
964f4f |
--- a/src/rsn_supp/tdls.c
|
|
|
964f4f |
+++ b/src/rsn_supp/tdls.c
|
|
|
964f4f |
@@ -2807,6 +2807,11 @@ int wpa_tdls_init(struct wpa_sm *sm)
|
|
|
964f4f |
if (sm == NULL)
|
|
|
964f4f |
return -1;
|
|
|
964f4f |
|
|
|
964f4f |
+ if (sm->l2_tdls) {
|
|
|
964f4f |
+ l2_packet_deinit(sm->l2_tdls);
|
|
|
964f4f |
+ sm->l2_tdls = NULL;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+
|
|
|
964f4f |
sm->l2_tdls = l2_packet_init(sm->bridge_ifname ? sm->bridge_ifname :
|
|
|
964f4f |
sm->ifname,
|
|
|
964f4f |
sm->own_addr,
|
|
|
964f4f |
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
|
|
|
964f4f |
index 793a881ef..ab7628f87 100644
|
|
|
964f4f |
--- a/wpa_supplicant/dbus/dbus_new.c
|
|
|
964f4f |
+++ b/wpa_supplicant/dbus/dbus_new.c
|
|
|
964f4f |
@@ -3613,7 +3613,7 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
|
|
|
964f4f |
},
|
|
|
964f4f |
{ "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
964f4f |
wpas_dbus_getter_bridge_ifname,
|
|
|
964f4f |
- NULL,
|
|
|
964f4f |
+ wpas_dbus_setter_bridge_ifname,
|
|
|
964f4f |
NULL
|
|
|
964f4f |
},
|
|
|
964f4f |
{ "ConfigFile", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
|
|
|
964f4f |
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
|
|
|
964f4f |
index 34abab752..2cfc87fa8 100644
|
|
|
964f4f |
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
|
|
|
964f4f |
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
|
|
|
964f4f |
@@ -3635,6 +3635,43 @@ dbus_bool_t wpas_dbus_getter_bridge_ifname(
|
|
|
964f4f |
}
|
|
|
964f4f |
|
|
|
964f4f |
|
|
|
964f4f |
+dbus_bool_t wpas_dbus_setter_bridge_ifname(
|
|
|
964f4f |
+ const struct wpa_dbus_property_desc *property_desc,
|
|
|
964f4f |
+ DBusMessageIter *iter, DBusError *error, void *user_data)
|
|
|
964f4f |
+{
|
|
|
964f4f |
+ struct wpa_supplicant *wpa_s = user_data;
|
|
|
964f4f |
+ const char *bridge_ifname = NULL;
|
|
|
964f4f |
+ const char *msg;
|
|
|
964f4f |
+ int r;
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
|
|
|
964f4f |
+ &bridge_ifname))
|
|
|
964f4f |
+ return FALSE;
|
|
|
964f4f |
+
|
|
|
964f4f |
+ r = wpa_supplicant_update_bridge_ifname(wpa_s, bridge_ifname);
|
|
|
964f4f |
+ if (r != 0) {
|
|
|
964f4f |
+ switch (r) {
|
|
|
964f4f |
+ case -EINVAL:
|
|
|
964f4f |
+ msg = "invalid interface name";
|
|
|
964f4f |
+ break;
|
|
|
964f4f |
+ case -EBUSY:
|
|
|
964f4f |
+ msg = "interface is busy";
|
|
|
964f4f |
+ break;
|
|
|
964f4f |
+ case -EIO:
|
|
|
964f4f |
+ msg = "socket error";
|
|
|
964f4f |
+ break;
|
|
|
964f4f |
+ default:
|
|
|
964f4f |
+ msg = "unknown error";
|
|
|
964f4f |
+ break;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+ dbus_set_error_const(error, DBUS_ERROR_FAILED, msg);
|
|
|
964f4f |
+ return FALSE;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+
|
|
|
964f4f |
+ return TRUE;
|
|
|
964f4f |
+}
|
|
|
964f4f |
+
|
|
|
964f4f |
+
|
|
|
964f4f |
/**
|
|
|
964f4f |
* wpas_dbus_getter_config_file - Get interface configuration file path
|
|
|
964f4f |
* @iter: Pointer to incoming dbus message iter
|
|
|
964f4f |
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
|
|
|
964f4f |
index afa26efed..d528c0816 100644
|
|
|
964f4f |
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
|
|
|
964f4f |
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
|
|
|
964f4f |
@@ -167,6 +167,7 @@ DECLARE_ACCESSOR(wpas_dbus_setter_scan_interval);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_ifname);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_driver);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_bridge_ifname);
|
|
|
964f4f |
+DECLARE_ACCESSOR(wpas_dbus_setter_bridge_ifname);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_config_file);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_current_bss);
|
|
|
964f4f |
DECLARE_ACCESSOR(wpas_dbus_getter_current_network);
|
|
|
964f4f |
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
|
|
|
964f4f |
index 39e92fb68..a7e9e459e 100644
|
|
|
964f4f |
--- a/wpa_supplicant/wpa_supplicant.c
|
|
|
964f4f |
+++ b/wpa_supplicant/wpa_supplicant.c
|
|
|
964f4f |
@@ -4906,6 +4906,65 @@ static void wpa_supplicant_rx_eapol_bridge(void *ctx, const u8 *src_addr,
|
|
|
964f4f |
}
|
|
|
964f4f |
|
|
|
964f4f |
|
|
|
964f4f |
+int wpa_supplicant_update_bridge_ifname(struct wpa_supplicant *wpa_s,
|
|
|
964f4f |
+ const char *bridge_ifname)
|
|
|
964f4f |
+{
|
|
|
964f4f |
+ if (wpa_s->wpa_state > WPA_SCANNING)
|
|
|
964f4f |
+ return -EBUSY;
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (bridge_ifname &&
|
|
|
964f4f |
+ os_strlen(bridge_ifname) >= sizeof(wpa_s->bridge_ifname))
|
|
|
964f4f |
+ return -EINVAL;
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (!bridge_ifname)
|
|
|
964f4f |
+ bridge_ifname = "";
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (os_strcmp(wpa_s->bridge_ifname, bridge_ifname) == 0)
|
|
|
964f4f |
+ return 0;
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (wpa_s->l2_br) {
|
|
|
964f4f |
+ l2_packet_deinit(wpa_s->l2_br);
|
|
|
964f4f |
+ wpa_s->l2_br = NULL;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+
|
|
|
964f4f |
+ os_strlcpy(wpa_s->bridge_ifname, bridge_ifname,
|
|
|
964f4f |
+ sizeof(wpa_s->bridge_ifname));
|
|
|
964f4f |
+
|
|
|
964f4f |
+ if (wpa_s->bridge_ifname[0]) {
|
|
|
964f4f |
+ wpa_dbg(wpa_s, MSG_DEBUG,
|
|
|
964f4f |
+ "Receiving packets from bridge interface '%s'",
|
|
|
964f4f |
+ wpa_s->bridge_ifname);
|
|
|
964f4f |
+ wpa_s->l2_br = l2_packet_init_bridge(
|
|
|
964f4f |
+ wpa_s->bridge_ifname, wpa_s->ifname, wpa_s->own_addr,
|
|
|
964f4f |
+ ETH_P_EAPOL, wpa_supplicant_rx_eapol_bridge, wpa_s, 1);
|
|
|
964f4f |
+ if (!wpa_s->l2_br) {
|
|
|
964f4f |
+ wpa_msg(wpa_s, MSG_ERROR,
|
|
|
964f4f |
+ "Failed to open l2_packet connection for the bridge interface '%s'",
|
|
|
964f4f |
+ wpa_s->bridge_ifname);
|
|
|
964f4f |
+ goto fail;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+
|
|
|
964f4f |
+#ifdef CONFIG_TDLS
|
|
|
964f4f |
+ if (!wpa_s->p2p_mgmt && wpa_tdls_init(wpa_s->wpa))
|
|
|
964f4f |
+ goto fail;
|
|
|
964f4f |
+#endif /* CONFIG_TDLS */
|
|
|
964f4f |
+
|
|
|
964f4f |
+ return 0;
|
|
|
964f4f |
+fail:
|
|
|
964f4f |
+ wpa_s->bridge_ifname[0] = 0;
|
|
|
964f4f |
+ if (wpa_s->l2_br) {
|
|
|
964f4f |
+ l2_packet_deinit(wpa_s->l2_br);
|
|
|
964f4f |
+ wpa_s->l2_br = NULL;
|
|
|
964f4f |
+ }
|
|
|
964f4f |
+#ifdef CONFIG_TDLS
|
|
|
964f4f |
+ if (!wpa_s->p2p_mgmt)
|
|
|
964f4f |
+ wpa_tdls_init(wpa_s->wpa);
|
|
|
964f4f |
+#endif /* CONFIG_TDLS */
|
|
|
964f4f |
+ return -EIO;
|
|
|
964f4f |
+}
|
|
|
964f4f |
+
|
|
|
964f4f |
+
|
|
|
964f4f |
/**
|
|
|
964f4f |
* wpa_supplicant_driver_init - Initialize driver interface parameters
|
|
|
964f4f |
* @wpa_s: Pointer to wpa_supplicant data
|
|
|
964f4f |
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
|
|
|
964f4f |
index 31a9b7427..eac3491cc 100644
|
|
|
964f4f |
--- a/wpa_supplicant/wpa_supplicant_i.h
|
|
|
964f4f |
+++ b/wpa_supplicant/wpa_supplicant_i.h
|
|
|
964f4f |
@@ -1351,6 +1351,8 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
|
|
|
964f4f |
const char * wpa_supplicant_state_txt(enum wpa_states state);
|
|
|
964f4f |
int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
|
|
|
964f4f |
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
|
|
|
964f4f |
+int wpa_supplicant_update_bridge_ifname(struct wpa_supplicant *wpa_s,
|
|
|
964f4f |
+ const char *bridge_ifname);
|
|
|
964f4f |
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
|
|
964f4f |
struct wpa_bss *bss, struct wpa_ssid *ssid,
|
|
|
964f4f |
u8 *wpa_ie, size_t *wpa_ie_len);
|
|
|
964f4f |
--
|
|
|
964f4f |
2.26.2
|
|
|
964f4f |
|