[openwrt/openwrt] hostapd: return PID on config_add call
LEDE Commits
lede-commits at lists.infradead.org
Sun Jan 10 14:20:52 EST 2021
dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2d305ff13a5e24fd2bd54e7dcde89539950974a1
commit 2d305ff13a5e24fd2bd54e7dcde89539950974a1
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Mon Dec 7 13:12:46 2020 +0000
hostapd: return PID on config_add call
To simplify the way netifd acquires the PIDs of wpa_supplicant and
hostapd let the config_add method of both of them return the PID of the
called process. Use the returned PID instead of querying procd when
adding wpa_supplicant configuration.
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
package/network/services/hostapd/Makefile | 2 +-
package/network/services/hostapd/files/hostapd.sh | 5 ++---
package/network/services/hostapd/src/src/ap/ubus.c | 4 ++++
package/network/services/hostapd/src/wpa_supplicant/ubus.c | 4 ++++
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
index 8e9605fe68..f57b072974 100644
--- a/package/network/services/hostapd/Makefile
+++ b/package/network/services/hostapd/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_RELEASE:=22
+PKG_RELEASE:=23
PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 0f6741336b..7d9ee5121e 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -1379,18 +1379,17 @@ wpa_supplicant_run() {
_wpa_supplicant_common "$ifname"
ubus wait_for wpa_supplicant
- ubus call wpa_supplicant config_add "{ \
+ local supplicant_pid=$(ubus call wpa_supplicant config_add "{ \
\"driver\": \"${_w_driver:-wext}\", \"ctrl\": \"$_rpath\", \
\"iface\": \"$ifname\", \"config\": \"$_config\" \
${network_bridge:+, \"bridge\": \"$network_bridge\"} \
${hostapd_ctrl:+, \"hostapd_ctrl\": \"$hostapd_ctrl\"} \
- }"
+ }" | jsonfilter -l 1 -e @.pid)
ret="$?"
[ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
- local supplicant_pid=$(ubus call service list '{"name": "wpad"}' | jsonfilter -l 1 -e "@['wpad'].instances['supplicant'].pid")
wireless_add_process "$supplicant_pid" "/usr/sbin/wpa_supplicant" 1 1
return $ret
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index 8546d2ce69..d03b848f94 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -658,6 +658,10 @@ hostapd_config_add(struct ubus_context *ctx, struct ubus_object *obj,
if (hostapd_add_iface(interfaces, buf))
return UBUS_STATUS_INVALID_ARGUMENT;
+ blob_buf_init(&b, 0);
+ blobmsg_add_u32(&b, "pid", getpid());
+ ubus_send_reply(ctx, req, b.head);
+
return UBUS_STATUS_OK;
}
diff --git a/package/network/services/hostapd/src/wpa_supplicant/ubus.c b/package/network/services/hostapd/src/wpa_supplicant/ubus.c
index 4bb92a7b66..16a68c5073 100644
--- a/package/network/services/hostapd/src/wpa_supplicant/ubus.c
+++ b/package/network/services/hostapd/src/wpa_supplicant/ubus.c
@@ -264,6 +264,10 @@ wpas_config_add(struct ubus_context *ctx, struct ubus_object *obj,
if (!wpa_supplicant_add_iface(global, iface, NULL))
return UBUS_STATUS_INVALID_ARGUMENT;
+ blob_buf_init(&b, 0);
+ blobmsg_add_u32(&b, "pid", getpid());
+ ubus_send_reply(ctx, req, b.head);
+
return UBUS_STATUS_OK;
}
More information about the lede-commits
mailing list