hostapd: return PID on config_add call
authorDaniel Golle <daniel@makrotopia.org>
Mon, 7 Dec 2020 13:12:46 +0000 (13:12 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 10 Jan 2021 19:15:51 +0000 (19:15 +0000)
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@makrotopia.org>
package/network/services/hostapd/Makefile
package/network/services/hostapd/files/hostapd.sh
package/network/services/hostapd/src/src/ap/ubus.c
package/network/services/hostapd/src/wpa_supplicant/ubus.c

index 8e9605fe68d8058714439fe827eb1dc31907e216..f57b0729748577d0cf9bb21c09f120c89fd81223 100644 (file)
@@ -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
index 0f6741336b90c2dfa52c2525499ea16fe50f243f..7d9ee5121eb538a5728e29e45506f14b46d9eb5b 100644 (file)
@@ -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
index 8546d2ce6991cb6b9cd0b7cb36b790d2b45f1c41..d03b848f94bfc763af93f15dbaf6f33b114b72bb 100644 (file)
@@ -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;
 }
 
index 4bb92a7b66f5ca1c69ba70529a28f485d36b20ba..16a68c5073171e3e13487b13970c84718b3beafd 100644 (file)
@@ -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;
 }