aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2020-04-06 23:58:40 +0100
committerDaniel Golle <daniel@makrotopia.org>2020-04-14 00:22:21 +0100
commitf37d6342367b4f8393f9693edd96b12dfa016399 (patch)
tree39814f5b920a29263d3d25bd9991a4e906297b8b /package
parent35f208da3c13cc16227f229f8aea14c4f0a06928 (diff)
downloadupstream-f37d6342367b4f8393f9693edd96b12dfa016399.tar.gz
upstream-f37d6342367b4f8393f9693edd96b12dfa016399.tar.bz2
upstream-f37d6342367b4f8393f9693edd96b12dfa016399.zip
hostapd: reduce to a single instance per service
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package')
-rw-r--r--package/network/services/hostapd/Makefile4
-rw-r--r--package/network/services/hostapd/files/hostapd.hotplug46
-rw-r--r--package/network/services/hostapd/files/hostapd.sh6
-rw-r--r--package/network/services/hostapd/files/wpad.init25
-rw-r--r--package/network/services/hostapd/patches/600-ubus_support.patch66
-rw-r--r--package/network/services/hostapd/patches/700-wifi-reload.patch58
-rw-r--r--package/network/services/hostapd/src/src/ap/ubus.c14
-rw-r--r--package/network/services/hostapd/src/wpa_supplicant/ubus.c17
8 files changed, 62 insertions, 174 deletions
diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
index b7fe1d8018..aa57d2121a 100644
--- a/package/network/services/hostapd/Makefile
+++ b/package/network/services/hostapd/Makefile
@@ -526,9 +526,9 @@ define Install/supplicant
endef
define Package/hostapd-common/install
- $(INSTALL_DIR) $(1)/lib/netifd $(1)/etc/rc.button $(1)/etc/hotplug.d/ieee80211
+ $(INSTALL_DIR) $(1)/lib/netifd $(1)/etc/rc.button $(1)/etc/hotplug.d/ieee80211 $(1)/etc/init.d
$(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/netifd/hostapd.sh
- $(INSTALL_BIN) ./files/hostapd.hotplug $(1)/etc/hotplug.d/ieee80211/20-hostapd
+ $(INSTALL_BIN) ./files/wpad.init $(1)/etc/init.d/wpad
$(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps
endef
diff --git a/package/network/services/hostapd/files/hostapd.hotplug b/package/network/services/hostapd/files/hostapd.hotplug
deleted file mode 100644
index 2c936fde75..0000000000
--- a/package/network/services/hostapd/files/hostapd.hotplug
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-initscript="$0"
-
-. /lib/functions.sh
-. /lib/functions/procd.sh
-
-cd /sys/class/ieee80211
-
-procd_lock() {
- return 0
-}
-
-service_triggers() {
- return 0
-}
-
-service_data() {
- return 0
-}
-
-procd_open_service hostapd
-
-for phy in *; do
- [ -d "$phy" ] || continue
-
- mkdir -p /var/run/wpa_supplicant-$phy /var/run/hostapd-$phy
-
- if [ -x "/usr/sbin/hostapd" ]; then
- procd_open_instance hostapd-$phy
- procd_set_param command /usr/sbin/hostapd -s -n $phy -g /var/run/hostapd-${phy}/global
- procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
- procd_set_param respawn
- procd_close_instance
- fi
-
- if [ -x "/usr/sbin/wpa_supplicant" ]; then
- procd_open_instance supplicant-$phy
- procd_set_param command /usr/sbin/wpa_supplicant -s -n $phy -g /var/run/wpa_supplicant-${phy}/global
- procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
- procd_set_param respawn
- procd_close_instance
- fi
-done
-
-procd_close_service set
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 542056fe9a..637f298ad9 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -1075,8 +1075,8 @@ wpa_supplicant_run() {
_wpa_supplicant_common "$ifname"
- ubus wait_for wpa_supplicant.$phy
- ubus call wpa_supplicant.$phy config_add "{ \
+ ubus wait_for wpa_supplicant
+ ubus call wpa_supplicant config_add "{ \
\"driver\": \"${_w_driver:-wext}\", \"ctrl\": \"$_rpath\", \
\"iface\": \"$ifname\", \"config\": \"$_config\" \
${network_bridge:+, \"bridge\": \"$network_bridge\"} \
@@ -1087,7 +1087,7 @@ wpa_supplicant_run() {
[ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
- local supplicant_pid=$(ubus call service list '{"name": "hostapd"}' | jsonfilter -l 1 -e "@['hostapd'].instances['supplicant-${phy}'].pid")
+ local supplicant_pid=$(ubus call service list '{"name": "hostapd"}' | jsonfilter -l 1 -e "@['hostapd'].instances['supplicant'].pid")
wireless_add_process "$supplicant_pid" "/usr/sbin/wpa_supplicant" 1
return $ret
diff --git a/package/network/services/hostapd/files/wpad.init b/package/network/services/hostapd/files/wpad.init
new file mode 100644
index 0000000000..3198e9801f
--- /dev/null
+++ b/package/network/services/hostapd/files/wpad.init
@@ -0,0 +1,25 @@
+#!/bin/sh /etc/rc.common
+
+START=19
+STOP=21
+
+USE_PROCD=1
+NAME=wpad
+
+start_service() {
+ if [ -x "/usr/sbin/hostapd" ]; then
+ mkdir -p /var/run/hostapd
+ procd_open_instance hostapd
+ procd_set_param command /usr/sbin/hostapd -s -g /var/run/hostapd/global
+ procd_set_param respawn
+ procd_close_instance
+ fi
+
+ if [ -x "/usr/sbin/wpa_supplicant" ]; then
+ mkdir -p /var/run/wpa_supplicant
+ procd_open_instance supplicant
+ procd_set_param command /usr/sbin/wpa_supplicant -n -s -g /var/run/wpa_supplicant/global
+ procd_set_param respawn
+ procd_close_instance
+ fi
+}
diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch
index b2860780eb..cc49ae3b24 100644
--- a/package/network/services/hostapd/patches/600-ubus_support.patch
+++ b/package/network/services/hostapd/patches/600-ubus_support.patch
@@ -22,16 +22,15 @@
#define OCE_STA_CFON_ENABLED(hapd) \
((hapd->conf->oce & OCE_STA_CFON) && \
-@@ -72,6 +73,8 @@ struct hapd_interfaces {
+@@ -72,6 +73,7 @@ struct hapd_interfaces {
#ifdef CONFIG_DPP
struct dpp_global *dpp;
#endif /* CONFIG_DPP */
+ struct ubus_object ubus;
-+ char *name;
};
enum hostapd_chan_status {
-@@ -145,6 +148,7 @@ struct hostapd_data {
+@@ -145,6 +147,7 @@ struct hostapd_data {
struct hostapd_iface *iface;
struct hostapd_config *iconf;
struct hostapd_bss_config *conf;
@@ -39,7 +38,7 @@
int interface_added; /* virtual interface added for this BSS */
unsigned int started:1;
unsigned int disabled:1;
-@@ -580,6 +584,7 @@ hostapd_alloc_bss_data(struct hostapd_if
+@@ -580,6 +583,7 @@ hostapd_alloc_bss_data(struct hostapd_if
struct hostapd_bss_config *bss);
int hostapd_setup_interface(struct hostapd_iface *iface);
int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
@@ -315,16 +314,7 @@
/* Remove interface from the global list of interfaces */
prev = global->ifaces;
if (prev == wpa_s) {
-@@ -6520,6 +6524,8 @@ struct wpa_global * wpa_supplicant_init(
- if (params->override_ctrl_interface)
- global->params.override_ctrl_interface =
- os_strdup(params->override_ctrl_interface);
-+ if (params->name)
-+ global->params.name = os_strdup(params->name);
- #ifdef CONFIG_MATCH_IFACE
- global->params.match_iface_count = params->match_iface_count;
- if (params->match_iface_count) {
-@@ -6626,8 +6632,12 @@ int wpa_supplicant_run(struct wpa_global
+@@ -6626,8 +6630,12 @@ int wpa_supplicant_run(struct wpa_global
eloop_register_signal_terminate(wpa_supplicant_terminate, global);
eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
@@ -337,14 +327,6 @@
return 0;
}
-@@ -6687,6 +6697,7 @@ void wpa_supplicant_deinit(struct wpa_gl
- #ifdef CONFIG_MATCH_IFACE
- os_free(global->params.match_ifaces);
- #endif /* CONFIG_MATCH_IFACE */
-+ os_free(global->params.name);
- #ifdef CONFIG_P2P
- os_free(global->params.conf_p2p_dev);
- #endif /* CONFIG_P2P */
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -17,6 +17,7 @@
@@ -355,16 +337,7 @@
extern const char *const wpa_supplicant_version;
extern const char *const wpa_supplicant_license;
-@@ -246,6 +247,8 @@ struct wpa_params {
- */
- int match_iface_count;
- #endif /* CONFIG_MATCH_IFACE */
-+
-+ char *name;
- };
-
- struct p2p_srv_bonjour {
-@@ -306,6 +309,8 @@ struct wpa_global {
+@@ -306,6 +307,8 @@ struct wpa_global {
#endif /* CONFIG_WIFI_DISPLAY */
struct psk_list_entry *add_psk; /* From group formation */
@@ -373,7 +346,7 @@
};
-@@ -506,6 +511,7 @@ struct wpa_supplicant {
+@@ -506,6 +509,7 @@ struct wpa_supplicant {
unsigned char own_addr[ETH_ALEN];
unsigned char perm_addr[ETH_ALEN];
char ifname[100];
@@ -402,25 +375,7 @@
--- a/hostapd/main.c
+++ b/hostapd/main.c
-@@ -688,7 +688,7 @@ int main(int argc, char *argv[])
- wpa_supplicant_event = hostapd_wpa_event;
- wpa_supplicant_event_global = hostapd_wpa_event_global;
- for (;;) {
-- c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:g:G:v::");
-+ c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:g:G:n:v::");
- if (c < 0)
- break;
- switch (c) {
-@@ -763,6 +763,8 @@ int main(int argc, char *argv[])
- if (hostapd_get_interface_names(&if_names,
- &if_names_size, optarg))
- goto out;
-+ case 'n':
-+ interfaces.name = optarg;
- break;
- default:
- usage();
-@@ -894,6 +896,7 @@ int main(int argc, char *argv[])
+@@ -894,6 +894,7 @@ int main(int argc, char *argv[])
}
hostapd_global_ctrl_iface_init(&interfaces);
@@ -428,7 +383,7 @@
if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
wpa_printf(MSG_ERROR, "Failed to start eloop");
-@@ -903,6 +906,7 @@ int main(int argc, char *argv[])
+@@ -903,6 +904,7 @@ int main(int argc, char *argv[])
ret = 0;
out:
@@ -443,16 +398,15 @@
for (;;) {
c = getopt(argc, argv,
- "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuv::W");
-+ "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:n:No:O:p:P:qsTtuv::W");
++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:nNo:O:p:P:qsTtuv::W");
if (c < 0)
break;
switch (c) {
-@@ -271,6 +271,10 @@ int main(int argc, char *argv[])
+@@ -271,6 +271,9 @@ int main(int argc, char *argv[])
params.conf_p2p_dev = optarg;
break;
#endif /* CONFIG_P2P */
+ case 'n':
-+ params.name = optarg;
+ iface_count = 0;
+ break;
case 'o':
diff --git a/package/network/services/hostapd/patches/700-wifi-reload.patch b/package/network/services/hostapd/patches/700-wifi-reload.patch
index fa557b76c6..e89d21d580 100644
--- a/package/network/services/hostapd/patches/700-wifi-reload.patch
+++ b/package/network/services/hostapd/patches/700-wifi-reload.patch
@@ -1,7 +1,5 @@
-Index: hostapd-2019-08-08-ca8c2bd2/hostapd/config_file.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/hostapd/config_file.c
-+++ hostapd-2019-08-08-ca8c2bd2/hostapd/config_file.c
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
@@ -2470,6 +2470,8 @@ static int hostapd_config_fill(struct ho
bss->isolate = atoi(pos);
} else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
@@ -20,10 +18,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/hostapd/config_file.c
} else if (os_strcmp(buf, "channel") == 0) {
if (os_strcmp(pos, "acs_survey") == 0) {
#ifndef CONFIG_ACS
-Index: hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/ap/ap_config.c
-+++ hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.c
+--- a/src/ap/ap_config.c
++++ b/src/ap/ap_config.c
@@ -698,6 +698,7 @@ void hostapd_config_free_bss(struct host
os_free(conf->radius_req_attr_sqlite);
os_free(conf->rsn_preauth_interfaces);
@@ -40,10 +36,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.c
os_free(conf->bss);
os_free(conf->supported_rates);
os_free(conf->basic_rates);
-Index: hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.h
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/ap/ap_config.h
-+++ hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.h
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
@@ -829,6 +829,7 @@ struct hostapd_bss_config {
*/
u8 mka_psk_set;
@@ -60,10 +54,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/ap_config.h
};
-Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/ap/hostapd.c
-+++ hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.c
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
@@ -206,6 +206,10 @@ static int hostapd_iface_conf_changed(st
{
size_t i;
@@ -150,10 +142,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.c
if (conf)
hapd->driver = conf->driver;
hapd->ctrl_sock = -1;
-Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.h
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/ap/hostapd.h
-+++ hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.h
+--- a/src/ap/hostapd.h
++++ b/src/ap/hostapd.h
@@ -42,7 +42,7 @@ struct mesh_conf;
struct hostapd_iface;
@@ -163,7 +153,7 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.h
struct hostapd_config * (*config_read_cb)(const char *config_fname);
int (*ctrl_iface_init)(struct hostapd_data *hapd);
void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
-@@ -149,6 +149,7 @@ struct hostapd_data {
+@@ -148,6 +148,7 @@ struct hostapd_data {
struct hostapd_config *iconf;
struct hostapd_bss_config *conf;
struct hostapd_ubus_bss ubus;
@@ -171,7 +161,7 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.h
int interface_added; /* virtual interface added for this BSS */
unsigned int started:1;
unsigned int disabled:1;
-@@ -576,7 +577,7 @@ struct hostapd_iface {
+@@ -575,7 +576,7 @@ struct hostapd_iface {
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx);
@@ -180,10 +170,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/ap/hostapd.h
void hostapd_reconfig_encryption(struct hostapd_data *hapd);
struct hostapd_data *
hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
-Index: hostapd-2019-08-08-ca8c2bd2/src/drivers/driver_nl80211.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/drivers/driver_nl80211.c
-+++ hostapd-2019-08-08-ca8c2bd2/src/drivers/driver_nl80211.c
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
@@ -4295,6 +4295,9 @@ static int wpa_driver_nl80211_set_ap(voi
if (ret) {
wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
@@ -194,10 +182,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/src/drivers/driver_nl80211.c
} else {
bss->beacon_set = 1;
nl80211_set_bss(bss, params->cts_protect, params->preamble,
-Index: hostapd-2019-08-08-ca8c2bd2/hostapd/ctrl_iface.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/hostapd/ctrl_iface.c
-+++ hostapd-2019-08-08-ca8c2bd2/hostapd/ctrl_iface.c
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
@@ -182,7 +182,7 @@ static int hostapd_ctrl_iface_update(str
iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
reload_opts = txt;
@@ -207,10 +193,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/hostapd/ctrl_iface.c
iface->interfaces->config_read_cb = config_read_cb;
}
-Index: hostapd-2019-08-08-ca8c2bd2/hostapd/main.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/hostapd/main.c
-+++ hostapd-2019-08-08-ca8c2bd2/hostapd/main.c
+--- a/hostapd/main.c
++++ b/hostapd/main.c
@@ -320,7 +320,7 @@ static void handle_term(int sig, void *s
static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
@@ -220,10 +204,8 @@ Index: hostapd-2019-08-08-ca8c2bd2/hostapd/main.c
wpa_printf(MSG_WARNING, "Failed to read new configuration "
"file - continuing with old.");
}
-Index: hostapd-2019-08-08-ca8c2bd2/src/ap/wps_hostapd.c
-===================================================================
---- hostapd-2019-08-08-ca8c2bd2.orig/src/ap/wps_hostapd.c
-+++ hostapd-2019-08-08-ca8c2bd2/src/ap/wps_hostapd.c
+--- a/src/ap/wps_hostapd.c
++++ b/src/ap/wps_hostapd.c
@@ -275,7 +275,7 @@ static void wps_reload_config(void *eloo
wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index 011c32a8b1..aeea310594 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -1115,24 +1115,12 @@ static struct ubus_object_type daemon_object_type =
void hostapd_ubus_add(struct hapd_interfaces *interfaces)
{
struct ubus_object *obj = &interfaces->ubus;
- char *name;
- int name_len;
int ret;
if (!hostapd_ubus_init())
return;
- name_len = strlen("hostapd") + 1;
- if (interfaces->name)
- name_len += strlen(interfaces->name) + 1;
-
- name = malloc(name_len);
- strcpy(name, "hostapd");
- if (interfaces->name) {
- strcat(name, ".");
- strcat(name, interfaces->name);
- }
- obj->name = name;
+ obj->name = strdup("hostapd");
obj->type = &daemon_object_type;
obj->methods = daemon_object_type.methods;
diff --git a/package/network/services/hostapd/src/wpa_supplicant/ubus.c b/package/network/services/hostapd/src/wpa_supplicant/ubus.c
index 5450b24476..4bb92a7b66 100644
--- a/package/network/services/hostapd/src/wpa_supplicant/ubus.c
+++ b/package/network/services/hostapd/src/wpa_supplicant/ubus.c
@@ -322,27 +322,12 @@ static struct ubus_object_type wpas_daemon_object_type =
void wpas_ubus_add(struct wpa_global *global)
{
struct ubus_object *obj = &global->ubus_global;
- char *name;
- int name_len;
int ret;
if (!wpas_ubus_init())
return;
- name_len = strlen("wpa_supplicant") + 1;
- if (global->params.name)
- name_len += strlen(global->params.name) + 1;
-
- name = malloc(name_len);
- strcpy(name, "wpa_supplicant");
-
- if (global->params.name)
- {
- strcat(name, ".");
- strcat(name, global->params.name);
- }
-
- obj->name = name;
+ obj->name = strdup("wpa_supplicant");
obj->type = &wpas_daemon_object_type;
obj->methods = wpas_daemon_object_type.methods;