From patchwork Fri Jun 7 13:36:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kici?ski X-Patchwork-Id: 2686971 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 E8175DFB78 for ; Fri, 7 Jun 2013 13:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753358Ab3FGNgY (ORCPT ); Fri, 7 Jun 2013 09:36:24 -0400 Received: from mx4.wp.pl ([212.77.101.8]:32447 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777Ab3FGNgW (ORCPT ); Fri, 7 Jun 2013 09:36:22 -0400 Received: (wp-smtpd smtp.wp.pl 13060 invoked from network); 7 Jun 2013 15:36:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1370612181; bh=uooZ6vpiLsTP8B8FCdhXli7+4b2qfdt/ETchJvKPFN4=; h=From:To:Cc:Subject; b=ogFavk7SLzYK+limlej/Rok8SOoWQpYo26eRcV6z26KxkFmQOQCNAZVgbCEDRjHYz wKIXX0biIqBCmD+ExsdUWVHXx3aOEvdVijXxItDrjliHCCXItn1lMShvT2GX6IwZ6+ +9H5JuHKmrAq6J9VTsc04o1Um+tO3Y/PAqHfafLI= Received: from 89-71-197-70.dynamic.chello.pl (HELO localhost.localdomain) (moorray3@[89.71.197.70]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with SMTP for ; 7 Jun 2013 15:36:20 +0200 From: Jakub Kicinski To: linux-wireless@vger.kernel.org Cc: Helmut Schaa , Felix Fietkau , Johannes Berg , nietrywialneprzejscie@gmail.com Subject: [RFC 3/5] mac80211: always default to address compatible with mask Date: Fri, 7 Jun 2013 15:36:17 +0200 Message-Id: <1370612179-24385-4-git-send-email-moorray3@wp.pl> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370612179-24385-1-git-send-email-moorray3@wp.pl> References: <1370612179-24385-1-git-send-email-moorray3@wp.pl> X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [gZAW] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jakub Kicinski Currently default mac address for new interfaces is set to perm_addr. It can be addr_mask-wise incompatible with other addresses if user have changed address of existing interfaces manualy. This is especially important after introduction of active monitors. We have to make sure that monitor interfaces have mac addresses that fall into addr_mask, otherwise hardware may not acknowledge frames. Signed-off-by: Jakub Kicinski --- net/mac80211/iface.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 38898b3..1f26980 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1468,17 +1468,7 @@ static void __ieee80211_assign_perm_addr(struct ieee80211_local *local, return; } - /* - * 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; - } + m = perm_addr; 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); @@ -1529,6 +1519,15 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local, mutex_lock(&local->iflist_mtx); + /* After manual mac change default addr may no longer fit into mask. */ + if (!is_zero_ether_addr(local->hw.wiphy->addr_mask) && + !list_empty(&local->interfaces)) { + sdata = list_first_entry(&local->interfaces, + struct ieee80211_sub_if_data, + list); + memcpy(perm_addr, sdata->vif.addr, ETH_ALEN); + } + switch (type) { case NL80211_IFTYPE_MONITOR: /* doesn't matter */