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@makrotopia.org>
This commit is contained in:
Daniel Golle 2020-12-07 13:12:46 +00:00
parent 425e392466
commit 2d305ff13a
4 changed files with 11 additions and 4 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd PKG_NAME:=hostapd
PKG_RELEASE:=22 PKG_RELEASE:=23
PKG_SOURCE_URL:=http://w1.fi/hostap.git PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git

View File

@ -1379,18 +1379,17 @@ wpa_supplicant_run() {
_wpa_supplicant_common "$ifname" _wpa_supplicant_common "$ifname"
ubus wait_for wpa_supplicant 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\", \ \"driver\": \"${_w_driver:-wext}\", \"ctrl\": \"$_rpath\", \
\"iface\": \"$ifname\", \"config\": \"$_config\" \ \"iface\": \"$ifname\", \"config\": \"$_config\" \
${network_bridge:+, \"bridge\": \"$network_bridge\"} \ ${network_bridge:+, \"bridge\": \"$network_bridge\"} \
${hostapd_ctrl:+, \"hostapd_ctrl\": \"$hostapd_ctrl\"} \ ${hostapd_ctrl:+, \"hostapd_ctrl\": \"$hostapd_ctrl\"} \
}" }" | jsonfilter -l 1 -e @.pid)
ret="$?" ret="$?"
[ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED [ "$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 wireless_add_process "$supplicant_pid" "/usr/sbin/wpa_supplicant" 1 1
return $ret return $ret

View File

@ -658,6 +658,10 @@ hostapd_config_add(struct ubus_context *ctx, struct ubus_object *obj,
if (hostapd_add_iface(interfaces, buf)) if (hostapd_add_iface(interfaces, buf))
return UBUS_STATUS_INVALID_ARGUMENT; 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; return UBUS_STATUS_OK;
} }

View File

@ -264,6 +264,10 @@ wpas_config_add(struct ubus_context *ctx, struct ubus_object *obj,
if (!wpa_supplicant_add_iface(global, iface, NULL)) if (!wpa_supplicant_add_iface(global, iface, NULL))
return UBUS_STATUS_INVALID_ARGUMENT; 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; return UBUS_STATUS_OK;
} }