From patchwork Fri Sep 18 11:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1366842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=david-bauer.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Tv5kyRZX; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BtC793Tblz9sT5 for ; Fri, 18 Sep 2020 21:59:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=poq0WjSzhHEXbbT/BOUrBojJzrOG7AoGtGEEYkIZZ8k=; b=Tv5kyRZX3bCVYh0pa+oZ8cxtX8 za+SdHfThO+vWM8tq3N+CQyiRGo1DMpFqp5V+J2UKJO0T2qidCqZe1Qq8yqhzJQpo84Gi/iCFHQUu QMzLDe8xkl72knEZhc6Xp58THSQeEfJhMp5luWdKg5NYNqzes0Bn8ZUQDlxdpCDFeKD5qh+bCx/B1 8SlPQTe5s+6YcSlJmleejYNp16GVJpD5bL40CgLoFjcHvumRvx4qPGAWYU+l3WhbH1E9yrL4v+BF/ cS/PldRb85pUV1HRzVbm8np6thj6775GySapbSVoDWlgDOZvyGycxEVkcWzf9zeU5OeF5ScVp3/lD N40J+cPg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJF19-0007FR-AR; Fri, 18 Sep 2020 11:57:31 +0000 Received: from mars.blocktrron.ovh ([51.254.112.43] helo=mail.blocktrron.ovh) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJF15-0007EP-Ul for openwrt-devel@lists.openwrt.org; Fri, 18 Sep 2020 11:57:29 +0000 Received: from localhost.localdomain (p200300e53f113900f651031cb35f6cbe.dip0.t-ipconnect.de [IPv6:2003:e5:3f11:3900:f651:31c:b35f:6cbe]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.blocktrron.ovh (Postfix) with ESMTPSA id 1436223CC2 for ; Fri, 18 Sep 2020 13:57:23 +0200 (CEST) From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH] hostapd: send ubus event on BSS update Date: Fri, 18 Sep 2020 13:57:19 +0200 Message-Id: <20200918115719.78233-1-mail@david-bauer.net> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200918_075728_094642_54BD3DCF X-CRM114-Status: GOOD ( 13.93 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org hostapd will emit a ubus event with the eventname hostapd.. when adding, removing or reloading a BSS. This way, services which install state (for example the RMM neighbor list) can on-demand reinstall this information for the BSS without polling this state. Signed-off-by: David Bauer --- .../services/hostapd/src/src/ap/ubus.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index d27ece7366..bfce641a75 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -111,6 +111,21 @@ void hostapd_ubus_free_iface(struct hostapd_iface *iface) return; } +static void hostapd_send_ubus_event(char *bssname, char *event) +{ + char *name; + + if (!ctx) + return; + + if (asprintf(&name, "hostapd.%s.%s", bssname, event) < 0) + return; + + blob_buf_init(&b, 0); + ubus_send_event(ctx, name, b.head); + free(name); +} + static void hostapd_bss_del_ban(void *eloop_data, void *user_ctx) { @@ -155,7 +170,10 @@ hostapd_bss_reload(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *msg) { struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); - return hostapd_reload_config(hapd->iface, 1); + int ret = hostapd_reload_config(hapd->iface, 1); + + hostapd_send_ubus_event(hapd->conf->iface, "reload"); + return ret; } static int @@ -1181,6 +1199,8 @@ void hostapd_ubus_add_bss(struct hostapd_data *hapd) obj->n_methods = bss_object_type.n_methods; ret = ubus_add_object(ctx, obj); hostapd_ubus_ref_inc(); + + hostapd_send_ubus_event(hapd->conf->iface, "add"); } void hostapd_ubus_free_bss(struct hostapd_data *hapd) @@ -1191,6 +1211,8 @@ void hostapd_ubus_free_bss(struct hostapd_data *hapd) if (!ctx) return; + hostapd_send_ubus_event(hapd->conf->iface, "remove"); + if (obj->id) { ubus_remove_object(ctx, obj); hostapd_ubus_ref_dec();