genode/repos/dde_linux/patches/wpa_supplicant.patch
Josef Söntgen d4e4b8bf60 driver/wifi: rework CTRL interface manager
This commit streamlines the interaction between the Wifi::Manager
and the wpa_supplicant's CTRL interface.

As user-facing changes it alters some default settings and introduces
new features:

* Every configured network now needs to explicitly have its
  'auto_connect' (to be considered an option for joining) attribute
  set to 'true' whereas this was previously the default value if the
  attribute was not set at all.

* The 'log_level' attribute is added and configures the supplicant's
  verbosity. Valid values correspond to levels used by the supplicant
  and are as follows 'excessive', 'msgdump', 'debug', 'info', 'warning'
  and 'error'. The default value is 'error' and configures the least
  amount of verbosity.

* The 'bgscan' attribute may be used to configure the way the
  supplicant performs background-scanning to steer or rather optimize
  roaming decision within the same network. The default value is set
  to 'simple:30:-70:600'. It can be disabled by specifying an empty
  value, e.g. 'bgscan=""'.

* The 'verbose_state' attribute was removed alltogether and similar
  functionality is now coverted by 'verbose' attribute.

Implementation-wise the internals changed significantly and are
outlined in the following paragraphs.

Formerly the interaction between the manager and the supplicant
was handled in an apparent way where the internal state of each
interaction was in plain sight. This made the flow cumbersome to
follow and therefor each interaction is now confined to its own
'Action' object that encapsulates the ping-pong of commands and
responses between the manager and the supplicant. All actions are
processed in an sequential way and thus there is no longer any
need to defer pending actions depending on the interal state of
the current interaction. Configuration changes as well as events
issued by the supplicant where new actions can be created are
handled in this fashion. Of note are both signal-handlers,
'_handle_cmds' and '_handle_events' respectively.

The state report, which provides the information about the current
state of connectivity to a given wireless network, was dealt with
in the same vein and its handling was spread across the manager
implementation. Again, to make it easier to follow, the generation
of the state report is now purely driven by the 'Join_state' object.
This object encapsulates the state of connectivity and is normally
updated by events issued from the supplicant (see '_handle_events').
It is also incorporated when handling command responses (see
'_handle_cmds').

Handling of timed-actions, like scan and signal quality
update requests, was done by setting a timeout at the Timer session
directly and thus only one timed-action could be pending at any time.
This excluded dealing with timed-actions like connected-scanning
and signal quality polling concurrently. This was changed and now
a One_shot_timeout is used to programm each concurrent timed-action.

For implementing the communication channel for the CTRL interface the
manager and supplicant use a shared memory buffer, the Msg_buffer.
Since the CTRL interface for Genode was implemented using C, some
shenanigans were performed to access the memory buffer. Now the
CTRL interface implementation uses C++ and only exports the functions
required by the supplicant as C. This simplifies the usage of the
Msg_buffer and allows for removing the global functions needed for
synchronizing the Msg_buffer access as those are now part of the
object itself via the 'Notify_interface'.

Fixes #5341.
2024-10-08 09:09:22 +02:00

148 lines
4.9 KiB
Diff

The nl80211 driver patch contains the following changes:
- Convert inline error values from Linux to libc (FreeBSD) as otherwise
wpa_supplicant might come to the wrong conclusions.
- Show RFKILL operations at INFO level (so that the always appear in the
log) and generate a interface dis-/enable event that will be handled
by the management layer.
- Remove netlink messages that rely on newer libnl versions, e.g. signed
value where introduced in 3.2.27.
- Hardcode the I/O control socket rather than calling socket because it
is not used anyway (see wpa_driver_nl80211/ioctl.cc).
--- a/src/drivers/driver_nl80211.c
+++ a/src/drivers/driver_nl80211.c
@@ -487,6 +487,8 @@
}
+extern int convert_errno_from_linux(int linux_errno);
+
int send_and_recv(struct nl80211_global *global,
struct nl_sock *nl_handle, struct nl_msg *msg,
int (*valid_handler)(struct nl_msg *, void *),
@@ -579,7 +581,7 @@
/* Always clear the message as it can potentially contain keys */
nl80211_nlmsg_clear(msg);
nlmsg_free(msg);
- return err.err;
+ return convert_errno_from_linux(err.err);
}
@@ -2088,13 +2090,13 @@
{
struct wpa_driver_nl80211_data *drv = ctx;
- wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
+ wpa_printf(MSG_INFO, "nl80211: RFKILL blocked");
/*
* rtnetlink ifdown handler will report interfaces other than the P2P
* Device interface as disabled.
*/
- if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
+ // if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED, NULL);
}
@@ -2102,7 +2104,7 @@
static void wpa_driver_nl80211_rfkill_unblocked(void *ctx)
{
struct wpa_driver_nl80211_data *drv = ctx;
- wpa_printf(MSG_DEBUG, "nl80211: RFKILL unblocked");
+ wpa_printf(MSG_INFO, "nl80211: RFKILL unblocked");
if (i802_set_iface_flags(drv->first_bss, 1)) {
wpa_printf(MSG_DEBUG, "nl80211: Could not set interface UP "
"after rfkill unblock");
@@ -2116,7 +2118,7 @@
* rtnetlink ifup handler will report interfaces other than the P2P
* Device interface as enabled.
*/
- if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
+ // if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE)
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED, NULL);
}
@@ -7826,7 +7828,7 @@
[NL80211_STA_INFO_BEACON_SIGNAL_AVG] = { .type = NLA_U8},
[NL80211_STA_INFO_RX_DURATION] = { .type = NLA_U64 },
[NL80211_STA_INFO_ACK_SIGNAL] = { .type = NLA_U8 },
- [NL80211_STA_INFO_ACK_SIGNAL_AVG] = { .type = NLA_S8 },
+ [NL80211_STA_INFO_ACK_SIGNAL_AVG] = { .type = NLA_U8 },
[NL80211_STA_INFO_RX_MPDUS] = { .type = NLA_U32 },
[NL80211_STA_INFO_FCS_ERROR_COUNT] = { .type = NLA_U32 },
[NL80211_STA_INFO_TX_DURATION] = { .type = NLA_U64 },
@@ -7930,9 +7932,9 @@
nla_get_u8(stats[NL80211_STA_INFO_ACK_SIGNAL]);
data->flags |= STA_DRV_DATA_LAST_ACK_RSSI;
}
- if (stats[NL80211_STA_INFO_ACK_SIGNAL_AVG])
- data->avg_ack_signal =
- nla_get_s8(stats[NL80211_STA_INFO_ACK_SIGNAL_AVG]);
+ // if (stats[NL80211_STA_INFO_ACK_SIGNAL_AVG])
+ // data->avg_ack_signal =
+ // nla_get_s8(stats[NL80211_STA_INFO_ACK_SIGNAL_AVG]);
if (stats[NL80211_STA_INFO_RX_MPDUS])
data->rx_mpdus = nla_get_u32(stats[NL80211_STA_INFO_RX_MPDUS]);
if (stats[NL80211_STA_INFO_FCS_ERROR_COUNT])
@@ -9939,7 +9941,7 @@
if (wpa_driver_nl80211_init_nl_global(global) < 0)
goto err;
- global->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
+ global->ioctl_sock = 12345; /* arbitrarily chosen number b/c it won't be used anyway */
if (global->ioctl_sock < 0) {
wpa_printf(MSG_ERROR, "nl80211: socket(PF_INET,SOCK_DGRAM) failed: %s",
strerror(errno));
diff --git a/src/drivers/netlink.c b/src/drivers/netlink.c
index 0e960f4..38fb26c 100644
--- a/src/drivers/netlink.c
+++ b/src/drivers/netlink.c
@@ -13,6 +13,8 @@
#include "priv_netlink.h"
#include "netlink.h"
+#define PF_NETLINK 16
+#define AF_NETLINK PF_NETLINK
struct netlink_data {
struct netlink_config *cfg;
diff --git a/src/utils/common.c b/src/utils/common.c
index 2c12751..e9047d5 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -509,12 +509,12 @@ void printf_encode(char *txt, size_t maxlen, const u8 *data, size_t len)
*txt++ = 't';
break;
default:
- if (data[i] >= 32 && data[i] <= 126) {
+ // if (data[i] >= 32 && data[i] <= 126) {
*txt++ = data[i];
- } else {
- txt += os_snprintf(txt, end - txt, "\\x%02x",
- data[i]);
- }
+ // } else {
+ // txt += os_snprintf(txt, end - txt, "\\x%02x",
+ // data[i]);
+ // }
break;
}
}
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index bcd67fc..025ec8d 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -11447,7 +11447,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
char *buf, size_t *resp_len)
{
char *reply;
- const int reply_size = 4096;
+ const int reply_size = 4096*8;
int reply_len;
if (os_strncmp(buf, WPA_CTRL_RSP, os_strlen(WPA_CTRL_RSP)) == 0 ||