Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp387708ybt; Wed, 17 Jun 2020 03:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhePs/W+J1bjsVq6GWubZO4MuE0k377hUxmALCGUKYweYw0D6cfqrPrqKG96niAEtLMmUw X-Received: by 2002:a17:906:7d97:: with SMTP id v23mr6611784ejo.199.1592390588818; Wed, 17 Jun 2020 03:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592390588; cv=none; d=google.com; s=arc-20160816; b=uix2AaljMhxBUsw4XRmojlId+cGLJ9ddnEC7eFajcPdeBBiMAEtQZYxu9gUVLTpHwM +hwGVMIyciQi9Dzk24LydFnwS62DEpS+0NeTHtNP30jU6SYhOL7VLmPAV8SBECk1y+lv T7f0yR+c9H1zSuOlJZCKmkBoqK1mWOdNVwphdrr6fC0EJUTCRvtLDzt2JJjsYS1CY6Ms NgqTchuD9X4oRHbfKiO36+77AECM3RXMWR5XvBFtEgT6XnAcoQp+tbbvWf5p/76EO2uj JPcJykj4WlbXzY5QAcX0JM9Jf9PIOQSgoUxuMlc0Rof5Dt0JuB65OYCyxZOyKgs1/61Z bBgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=7JJxulm2YBY2uitiJIaIit3Ylo3v/fJGMGy4jedqvCU=; b=IQljur1Q8YApsSuSk5JWEfb75wpogRqosa25q1X9QfU1ttURzBsecG2Mo9y8nVv/D9 s9tbIXniYvSQMoFWhMMZQ/fnYvBiWKY4eEZfeR3Z4gbnZU6QU7NgdWmGF9eJgIwxJmNI WXhksZcOnIPWBQuNXMh6SKwJ8rGIDm0DleSZvsDEdgipQgUU1sbK8OpEnQ54xQsgen0K GidJA9ZaK6hMGS+WysQNUlQmpdkUXsqjwglKoagGa4btoMAPD+0GqMpemNN+FejcqIup 9foib9Ne1XHnyDk7Zx8JAhAHgtr3ZKuA7VKa2W7dROuBGnxZj6OxcMlS1SSBNBQu6yr3 V+QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si13522114ejr.656.2020.06.17.03.42.44; Wed, 17 Jun 2020 03:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgFQKmQ (ORCPT + 99 others); Wed, 17 Jun 2020 06:42:16 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50634 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgFQKmN (ORCPT ); Wed, 17 Jun 2020 06:42:13 -0400 Received: from localhost.localdomain (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 010E7CECDD for ; Wed, 17 Jun 2020 12:52:02 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH 11/14] Bluetooth: Notify adv monitor removed event Date: Wed, 17 Jun 2020 12:42:02 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Miao-chen Chou This notifies management sockets on MGMT_EV_ADV_MONITOR_REMOVED event. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Miao-chen Chou Signed-off-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3268d9a00608..b194da4de2d7 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -192,6 +192,7 @@ static const u16 mgmt_untrusted_events[] = { MGMT_EV_EXT_INFO_CHANGED, MGMT_EV_EXP_FEATURE_CHANGED, MGMT_EV_ADV_MONITOR_ADDED, + MGMT_EV_ADV_MONITOR_REMOVED, }; #define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000) @@ -3988,6 +3989,16 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev, mgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk); } +static void mgmt_adv_monitor_removed(struct sock *sk, struct hci_dev *hdev, + u16 handle) +{ + struct mgmt_ev_adv_monitor_added ev; + + ev.monitor_handle = cpu_to_le16(handle); + + mgmt_event(MGMT_EV_ADV_MONITOR_REMOVED, hdev, &ev, sizeof(ev), sk); +} + static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { @@ -4140,6 +4151,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, { struct mgmt_cp_remove_adv_monitor *cp = data; struct mgmt_rp_remove_adv_monitor rp; + unsigned int prev_adv_monitors_cnt; u16 handle; int err; @@ -4148,6 +4160,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, hci_dev_lock(hdev); handle = __le16_to_cpu(cp->monitor_handle); + prev_adv_monitors_cnt = hdev->adv_monitors_cnt; err = hci_remove_adv_monitor(hdev, handle); if (err == -ENOENT) { @@ -4156,6 +4169,9 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev, goto unlock; } + if (hdev->adv_monitors_cnt < prev_adv_monitors_cnt) + mgmt_adv_monitor_removed(sk, hdev, handle); + hci_dev_unlock(hdev); rp.monitor_handle = cp->monitor_handle; -- 2.26.2