From patchwork Mon May 27 08:43:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 2617991 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 93CB1DF215 for ; Mon, 27 May 2013 08:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757234Ab3E0ImT (ORCPT ); Mon, 27 May 2013 04:42:19 -0400 Received: from mail-qe0-f42.google.com ([209.85.128.42]:63057 "EHLO mail-qe0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757124Ab3E0ImT (ORCPT ); Mon, 27 May 2013 04:42:19 -0400 Received: by mail-qe0-f42.google.com with SMTP id cz11so3671223qeb.1 for ; Mon, 27 May 2013 01:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=dRdEuQYjyYB545pL6gT0VkY68TL6aqWza+FJ+YCmYyk=; b=gPRD+ht3fxUnnixgeb/tMW8fvLP/WW2Oxp4CHP8fVdz49OEhwSfln+EvkOWNiKgPfh eO/g5SMTLFkNY4wF7epzgutC0tuKFvZafSZkvfrVXmLSF4/ow/PkNeA61ZWe6Ec7nYLU 6EM+0mMIUovLrQBKnBHktHDWE1AuH1Dtx1RJ/tV3fJ9LvPf7X+mpo+wRhKNbXvVCnxy9 pw3qbFzGmvUtcxD0Jwh++ghA336lwXCvlBM7Btf0LqkKdqDcd9BlVJFZ3z4+Ak7SYTlg m0+1YEdOKI53uF+zCbQnXt1J6HYNDotBuyPRtvn028LC5lZJqUJ2PBd8gTITVn2J1cT7 nNBA== X-Received: by 10.229.166.2 with SMTP id k2mr5385390qcy.107.1369644138334; Mon, 27 May 2013 01:42:18 -0700 (PDT) Received: from hschaa-desktop.site ([217.8.58.223]) by mx.google.com with ESMTPSA id d5sm23131060qel.4.2013.05.27.01.42.15 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 01:42:16 -0700 (PDT) From: Helmut Schaa To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Helmut Schaa , Jakub Kicinski , Alessandro Lannocca , Bruno Randolf Subject: [PATCHv2] mac80211: Allow single vif mac address change with addr_mask Date: Mon, 27 May 2013 10:43:09 +0200 Message-Id: <1369644189-13874-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369140893-22622-1-git-send-email-helmut.schaa@googlemail.com> References: <1369140893-22622-1-git-send-email-helmut.schaa@googlemail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When changing the MAC address of a single vif mac80211 will check if the new address fits into the address mask specified by the driver. This only needs to be done when using multiple BSSIDs. Hence, check the new address only against all other vifs. Also fix the MAC address assignment on new interfaces if the user changed the address of a vif such that perm_addr is not covered by addr_mask anymore. Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=57371 Signed-off-by: Helmut Schaa Signed-off-by: Jakub Kicinski Reported-by: Alessandro Lannocca Cc: Alessandro Lannocca Cc: Bruno Randolf --- net/mac80211/iface.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 60f1ce5..3000cda 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -159,9 +159,10 @@ static int ieee80211_change_mtu(struct net_device *dev, int new_mtu) return 0; } -static int ieee80211_verify_mac(struct ieee80211_local *local, u8 *addr) +static int ieee80211_verify_mac(struct ieee80211_sub_if_data *sdata, u8 *addr) { - struct ieee80211_sub_if_data *sdata; + struct ieee80211_local *local = sdata->local; + struct ieee80211_sub_if_data *iter; u64 new, mask, tmp; u8 *m; int ret = 0; @@ -181,11 +182,14 @@ static int ieee80211_verify_mac(struct ieee80211_local *local, u8 *addr) mutex_lock(&local->iflist_mtx); - list_for_each_entry(sdata, &local->interfaces, list) { - if (sdata->vif.type == NL80211_IFTYPE_MONITOR) + list_for_each_entry(iter, &local->interfaces, list) { + if (iter == sdata) continue; - m = sdata->vif.addr; + if (iter->vif.type == NL80211_IFTYPE_MONITOR) + continue; + + m = iter->vif.addr; tmp = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8); @@ -209,7 +213,7 @@ static int ieee80211_change_mac(struct net_device *dev, void *addr) if (ieee80211_sdata_running(sdata)) return -EBUSY; - ret = ieee80211_verify_mac(sdata->local, sa->sa_data); + ret = ieee80211_verify_mac(sdata, sa->sa_data); if (ret) return ret; @@ -1479,7 +1483,17 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local, break; } + /* + * Pick address of existing interface in case user changed + * MAC address manually, default to perm_addr. + */ m = local->hw.wiphy->perm_addr; + list_for_each_entry(sdata, &local->interfaces, list) { + if (sdata->vif.type == NL80211_IFTYPE_MONITOR) + continue; + m = sdata->vif.addr; + break; + } start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);