From patchwork Fri Mar 10 09:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 9615697 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E89960414 for ; Fri, 10 Mar 2017 09:50:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65E3A286E7 for ; Fri, 10 Mar 2017 09:50:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A9BD2870D; Fri, 10 Mar 2017 09:50:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1D12286E7 for ; Fri, 10 Mar 2017 09:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965089AbdCJJf2 (ORCPT ); Fri, 10 Mar 2017 04:35:28 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37709 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965046AbdCJJfZ (ORCPT ); Fri, 10 Mar 2017 04:35:25 -0500 Received: by mail-wm0-f51.google.com with SMTP id n11so6232547wma.0 for ; Fri, 10 Mar 2017 01:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openmesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=na26NAhp4CWDE9mHZHWPJQVpDL9yPuSkr8EZwmL/auo=; b=Lwi4kdCNWuA6K0dhG//XgWfeQ3iDjkG9vNudMle5D7Plu1ejvhYn1+6nw0BvAH3bL7 xgHtcM1o2PIZhbEbxmWvkx0yBJS145VTHLFpVWtTN8cMiJWE8AjSPNWM8+balmsMU1nL iVZjdn1txScXHmQnd1tydgeeXr2y+/5C/fPaE6jrRhL1Hxtc2dPyRX4xvkOHfzsXJS/O eZ6KRtFErXo3pycz/6fKD7hxKrliPRG7FVo3fFDG+tkzQuWqd/ondm0ZQqA3B10WvjHY M9i4OVE66hwNsPZGu2x6byqNA9fZsXpIDzmnST9/x13b1glRxjxGO8ERjPCLagh1CMpg RIDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=na26NAhp4CWDE9mHZHWPJQVpDL9yPuSkr8EZwmL/auo=; b=cCoVy+c57znUffWar4WxXkMAzjT3Ll7b66C8JTDhn+cKV/bcFCrvAlP5RqLHFTRjVc q/ZdMRgRO6R79fQbUH0HGzZ6NagLVdSidNXvWTbY33dJQzSWG44dppBu1Opk6N8pRuUa 5ZT+btNvmCNpVYDOd6HGi/9YA+ESdGupd9dbh5YEyWnn2PFrKn2vCq1Ry5DYmOgDCIUd BNUOBdq8pLpmILVv0maU2NavrNLz5iPyWbAtW5mERVge3ns27uDYesaTwXT1ZKpr2qiL EsCk+uG3gQgeqV+tVolKKCUlxfcc3MhQux9fiDx3VugVAIGl0nO6Mj64XvYz6BahN5WF 3kUQ== X-Gm-Message-State: AFeK/H0J00g6CF6sFXDlbxvLG6a9LAZUZ30d/H+gPQd8oj8JzKv+Umc2V56rnvGwEAP9zQgn X-Received: by 10.28.182.10 with SMTP id g10mr1590796wmf.123.1489138522354; Fri, 10 Mar 2017 01:35:22 -0800 (PST) Received: from sven-desktop.home.narfation.org (p2003007C6F5694FE527B9DFFFECE2683.dip0.t-ipconnect.de. [2003:7c:6f56:94fe:527b:9dff:fece:2683]) by smtp.gmail.com with ESMTPSA id x193sm2451756wme.23.2017.03.10.01.35.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Mar 2017 01:35:21 -0800 (PST) From: Sven Eckelmann To: linux-wireless@vger.kernel.org Cc: Johannes Berg , simon.wunderlich@openmesh.com, Benjamin Berg , Sven Eckelmann Subject: [PATCH] mac80211: Allow multiple listeners for management frames. Date: Fri, 10 Mar 2017 10:34:54 +0100 Message-Id: <20170310093454.27664-1-sven.eckelmann@openmesh.com> X-Mailer: git-send-email 2.11.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Berg Previously it was not possible to have multiple listeners for management frames in userspace. This is a bit weird as multiple processes in userspace might try to request management frame reporting but only the first request was accepted. Signed-off-by: Benjamin Berg Signed-off-by: Sven Eckelmann --- It is currently unknown why Benjamin never forwarded it. I am doing this now to have a chance that this private patch doesn't have to be rebased anymore by OpenMesh. --- net/wireless/mlme.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 22b3d9990065..f8ce18dcaa61 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -467,6 +467,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); struct cfg80211_mgmt_registration *reg, *nreg; int err = 0; + int registered = 0; u16 mgmt_type; if (!wdev->wiphy->mgmt_stypes) @@ -494,6 +495,12 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, if (frame_type != le16_to_cpu(reg->frame_type)) continue; + registered = 1; + + /* Allow duplicate registrations on different ports */ + if (snd_portid != reg->nlportid) + continue; + if (memcmp(reg->match, match_data, mlen) == 0) { err = -EALREADY; break; @@ -516,7 +523,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, /* process all unregistrations to avoid driver confusion */ cfg80211_process_mlme_unregistrations(rdev); - if (rdev->ops->mgmt_frame_register) + if (rdev->ops->mgmt_frame_register && !registered) rdev_mgmt_frame_register(rdev, wdev, frame_type, true); return 0; @@ -536,6 +543,26 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) spin_lock_bh(&wdev->mgmt_registrations_lock); list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) { + struct cfg80211_mgmt_registration *inner; + int keep_registration = 0; + + /* Do not remove registration as long as there is one other + * registration for the frame type. Note that this registration + * might even be on the same nlportid with a different match. + */ + list_for_each_entry(inner, &wdev->mgmt_registrations, list) { + if (inner == reg) + continue; + + if (reg->frame_type == inner->frame_type) { + keep_registration = 1; + break; + } + } + + if (keep_registration) + continue; + if (reg->nlportid != nlportid) continue; @@ -735,7 +762,6 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, continue; result = true; - break; } spin_unlock_bh(&wdev->mgmt_registrations_lock);