From owner-svn-src-head@FreeBSD.ORG Tue Jul 21 19:36:33 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FEE61065673; Tue, 21 Jul 2009 19:36:33 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D59448FC1C; Tue, 21 Jul 2009 19:36:32 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6LJaWb3020197; Tue, 21 Jul 2009 19:36:32 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6LJaWFF020194; Tue, 21 Jul 2009 19:36:32 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200907211936.n6LJaWFF020194@svn.freebsd.org> From: Sam Leffler Date: Tue, 21 Jul 2009 19:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195812 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2009 19:36:33 -0000 Author: sam Date: Tue Jul 21 19:36:32 2009 New Revision: 195812 URL: http://svn.freebsd.org/changeset/base/195812 Log: Correct handling of keys that already have a hardware/device key index: this was broken in r183248 when the check of wk_keyix was replaced by a check of IEEE80211_KEY_DEVKEY (because the flag was clobbered). Define IEEE80211_KEY_DEVICE to specify flags that are owned by net80211/driver and use this to preserve IEEE80211_KEY_DEVKEY so we don't ask the driver for another key index when we already have one. Testing by: Daniel Thiele, Wes Morgan Reviewed by: rpaulo Approved by: re (kib) Modified: head/sys/net80211/ieee80211_crypto.c head/sys/net80211/ieee80211_crypto.h Modified: head/sys/net80211/ieee80211_crypto.c ============================================================================== --- head/sys/net80211/ieee80211_crypto.c Tue Jul 21 19:25:25 2009 (r195811) +++ head/sys/net80211/ieee80211_crypto.c Tue Jul 21 19:36:32 2009 (r195812) @@ -244,11 +244,13 @@ static const char *cipher_modnames[IEEE8 [IEEE80211_CIPHER_NONE] = "wlan_none", }; +/* NB: there must be no overlap between user-supplied and device-owned flags */ +CTASSERT((IEEE80211_KEY_COMMON & IEEE80211_KEY_DEVICE) == 0); + /* * Establish a relationship between the specified key and cipher * and, if necessary, allocate a hardware index from the driver. - * Note that when a fixed key index is required it must be specified - * and we blindly assign it w/o consulting the driver (XXX). + * Note that when a fixed key index is required it must be specified. * * This must be the first call applied to a key; all the other key * routines assume wk_cipher is setup. @@ -309,6 +311,8 @@ ieee80211_crypto_newkey(struct ieee80211 oflags = key->wk_flags; flags &= IEEE80211_KEY_COMMON; + /* NB: preserve device attributes */ + flags |= (oflags & IEEE80211_KEY_DEVICE); /* * If the hardware does not support the cipher then * fallback to a host-based implementation. @@ -359,10 +363,6 @@ ieee80211_crypto_newkey(struct ieee80211 key->wk_cipher = cip; /* XXX refcnt? */ key->wk_private = keyctx; } - /* - * Commit to requested usage so driver can see the flags. - */ - key->wk_flags = flags; /* * Ask the driver for a key index if we don't have one. Modified: head/sys/net80211/ieee80211_crypto.h ============================================================================== --- head/sys/net80211/ieee80211_crypto.h Tue Jul 21 19:25:25 2009 (r195811) +++ head/sys/net80211/ieee80211_crypto.h Tue Jul 21 19:36:32 2009 (r195812) @@ -99,6 +99,8 @@ struct ieee80211_key { }; #define IEEE80211_KEY_COMMON /* common flags passed in by apps */\ (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP) +#define IEEE80211_KEY_DEVICE /* flags owned by device driver */\ + (IEEE80211_KEY_DEVKEY|IEEE80211_KEY_CIPHER0|IEEE80211_KEY_CIPHER1) #define IEEE80211_KEY_SWCRYPT \ (IEEE80211_KEY_SWENCRYPT | IEEE80211_KEY_SWDECRYPT)