From patchwork Sun Jan 12 09:06:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eliad Peller X-Patchwork-Id: 3470971 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91493C02DC for ; Sun, 12 Jan 2014 09:08:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9E052015E for ; Sun, 12 Jan 2014 09:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA38C20155 for ; Sun, 12 Jan 2014 09:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751114AbaALJGu (ORCPT ); Sun, 12 Jan 2014 04:06:50 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:52961 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbaALJGn (ORCPT ); Sun, 12 Jan 2014 04:06:43 -0500 Received: by mail-ee0-f44.google.com with SMTP id b57so2639319eek.3 for ; Sun, 12 Jan 2014 01:06:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Sqrj3IEbiQzM0pYaAk4KkBI/V0Tzh6c+RAKQZooJGGA=; b=knA9MEw7v+ixnFPAKXu2myoL610s4TFUxa3fKaS/9iwRJGH5/OVPeZcimbcJ4PVIQQ ESG259arqCSpXJriqQi1e7rRaw3S4TgboUwIvi2d0A3qyKwGomf8eA9PgBxD1J7lbuJq uE2q0mPAvTBv3FSRIuMwXDcnj3AELj4P3xzHdODjGDk0KAYac7z4dVMqx8Nikq7vbThR 14nyfeMoy+vrh0kDF0wZYsALRtkgBj23KjgPgngz+jrWjnZpKeIwuG/DiB/u0SQBmPtD xspH+vu40oJqZOoLvHpwxGzuyHAf7aMe4YAjIe15a7amNd8eNunW0h/Ca72qeTyjmjiK XjFA== X-Gm-Message-State: ALoCoQnUzq3cx0NN+Q/KtHbmJa1vmIGPgzasuqMwng8KaGxoZ9EShdh2AruUcOunqSOEc6+L5oTz X-Received: by 10.15.111.6 with SMTP id ci6mr15412044eeb.59.1389517602223; Sun, 12 Jan 2014 01:06:42 -0800 (PST) Received: from muse.amr.corp.intel.com (93-173-177-113.bb.netvision.net.il. [93.173.177.113]) by mx.google.com with ESMTPSA id v7sm29386612eel.2.2014.01.12.01.06.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 01:06:41 -0800 (PST) From: Eliad Peller To: Johannes Berg Cc: Subject: [PATCH] mac80211: move roc cookie assignment earlier Date: Sun, 12 Jan 2014 11:06:37 +0200 Message-Id: <1389517597-3865-1-git-send-email-eliad@wizery.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466.dirty Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ieee80211_start_roc_work() might add a new roc to existing roc, and tell cfg80211 it has already started. However, this might happen before the roc cookie was set, resulting in REMAIN_ON_CHANNEL (started) event with null cookie. Consequently, it can make wpa_supplicant go out of sync. Fix it by setting the roc cookie earlier. Signed-off-by: Eliad Peller --- net/mac80211/cfg.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index f9ae9b8..94b4acb 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2638,6 +2638,24 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local, INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work); INIT_LIST_HEAD(&roc->dependents); + /* + * cookie is either the roc cookie (for normal roc) + * or the SKB (for mgmt TX) + */ + if (!txskb) { + /* local->mtx protects this */ + local->roc_cookie_counter++; + roc->cookie = local->roc_cookie_counter; + /* wow, you wrapped 64 bits ... more likely a bug */ + if (WARN_ON(roc->cookie == 0)) { + roc->cookie = 1; + local->roc_cookie_counter++; + } + *cookie = roc->cookie; + } else { + *cookie = (unsigned long)txskb; + } + /* if there's one pending or we're scanning, queue this one */ if (!list_empty(&local->roc_list) || local->scanning || local->radar_detect_enabled) @@ -2772,24 +2790,6 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local, if (!queued) list_add_tail(&roc->list, &local->roc_list); - /* - * cookie is either the roc cookie (for normal roc) - * or the SKB (for mgmt TX) - */ - if (!txskb) { - /* local->mtx protects this */ - local->roc_cookie_counter++; - roc->cookie = local->roc_cookie_counter; - /* wow, you wrapped 64 bits ... more likely a bug */ - if (WARN_ON(roc->cookie == 0)) { - roc->cookie = 1; - local->roc_cookie_counter++; - } - *cookie = roc->cookie; - } else { - *cookie = (unsigned long)txskb; - } - return 0; }