From patchwork Mon Feb 23 15:33:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 5866161 X-Patchwork-Delegate: johannes@sipsolutions.net 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9D5C4BF440 for ; Mon, 23 Feb 2015 15:36:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF08820617 for ; Mon, 23 Feb 2015 15:36:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9768720614 for ; Mon, 23 Feb 2015 15:36:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbbBWPg2 (ORCPT ); Mon, 23 Feb 2015 10:36:28 -0500 Received: from mail-ie0-f182.google.com ([209.85.223.182]:43751 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbbBWPg1 (ORCPT ); Mon, 23 Feb 2015 10:36:27 -0500 Received: by iebtr6 with SMTP id tr6so24044310ieb.10 for ; Mon, 23 Feb 2015 07:36:26 -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=jGYgal1YVyPjOktv6/zy+DR5EG/09y6+rO+juFjk0jo=; b=QPK8LvWYBjL4e3OV2Etay6QRqPeSQglg08g/8xGRLvbYW3nSQ+0T7YB9r0XX1OI7xb asSIbZDxH6voIri6zoffsYcc0G+MeXjGQWEBjq9DedMN5GdgtGR4/l4u1Oti7gX+5zRM E7NazmgddZVVmy66MBOpvrZT6nMIQE9Ejrw8FVkkBBEDGDeJEsEWNCidTdR5QTOwVZh8 H18340ssL4p1D0PvqjQoZWGYyilE7oHCi6MRRoihIOx7BPRhRXRLnQ7x/NCiZtI4L1L5 klt+j2RFZXh5SQ2i5crg3supjOM505GC0AqjHlgpoPnqQWUl0kTGsFhRGqsBFyVoHdGw 3O9Q== X-Gm-Message-State: ALoCoQkb8SwXWPFscgOME5duPWlKOtJnkdBJrEoUty/OAGLPkneaBtwDvHmqcOInPnA2+S5oj5pV X-Received: by 10.107.19.89 with SMTP id b86mr14165542ioj.35.1424705786615; Mon, 23 Feb 2015 07:36:26 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by mx.google.com with ESMTPSA id k9sm6295461ige.6.2015.02.23.07.36.25 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Feb 2015 07:36:25 -0800 (PST) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.80) (envelope-from ) id 1YPv34-000460-1m; Mon, 23 Feb 2015 10:35:54 -0500 Received: from bob by glass with local (Exim 4.84) (envelope-from ) id 1YPv30-000262-PT; Mon, 23 Feb 2015 10:35:50 -0500 From: Bob Copeland To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Bob Copeland Subject: [PATCH] mac80211_hwsim: support any address in userspace Date: Mon, 23 Feb 2015 10:33:44 -0500 Message-Id: <1424705624-7964-1-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Due to the checks in get_hwsim_data_ref_from_addr, wmediumd was only able to use the second mac address (those starting with 0x42). This is confusing and needlessly limiting, so allow any configured address. While at it, use ether_addr_equal since data->addresses and the address from the netlink payload are aligned(2). Signed-off-by: Bob Copeland --- drivers/net/wireless/mac80211_hwsim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 1204853..be8bb18 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -907,8 +907,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; } - if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, - ETH_ALEN, data->addresses[1].addr)) + if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, ETH_ALEN, hdr->addr2)) goto nla_put_failure; /* We get the skb->data */ @@ -2608,14 +2607,18 @@ static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr(const u8 *addr) { struct mac80211_hwsim_data *data; bool _found = false; + int i; spin_lock_bh(&hwsim_radio_lock); list_for_each_entry(data, &hwsim_radios, list) { - if (memcmp(data->addresses[1].addr, addr, ETH_ALEN) == 0) { - _found = true; - break; + for (i = 0; i < ARRAY_SIZE(data->addresses); i++) { + if (ether_addr_equal(data->addresses[i].addr, addr)) { + _found = true; + goto end_loop; + } } } +end_loop: spin_unlock_bh(&hwsim_radio_lock); if (!_found)