Subject: kern/31000: [PATCH] Fix two bugs in ral(4)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <fun@naobsd.org>
List: netbsd-bugs
Date: 08/16/2005 13:58:00
>Number:         31000
>Category:       kern
>Synopsis:       [PATCH] Fix two bugs in ral(4)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 16 13:58:00 +0000 2005
>Originator:     FUKAUMI Naoki
>Release:        NetBSD 3.99.7
>Organization:
	FUKAUMI Naoki
>Environment:
System: NetBSD turion64.naobsd.org 3.99.7 NetBSD 3.99.7 (TURION64) #2: Tue Aug 16 19:43:57 JST 2005 root@turion64.naobsd.org:/usr/obj/amd64/sys/arch/amd64/compile/TURION64 amd64
Architecture: x86_64
Machine: amd64
>Description:
	Two bugs were fixed in FreeBSD:

	remove driver-private key allocators; use the default one instead
	so wpa keys are handled properly (if_ral.c, if_ural.c rev 1.9)

	remove local mods that snuck into rev 1.6 (if_ral.c rev 1.10)

	Later seems to fix AP association problem.
>How-To-Repeat:
	See FreeBSD's source changes.
>Fix:
	This is patch for NetBSD-current.

Index: src/sys/dev/ic/ral.c
===================================================================
RCS file: /home/fun/cvsroot/NetBSD/src/sys/dev/ic/ral.c,v
retrieving revision 1.4
diff -u -p -r1.4 ral.c
--- src/sys/dev/ic/ral.c	12 Jul 2005 12:13:00 -0000	1.4
+++ src/sys/dev/ic/ral.c	16 Aug 2005 13:43:58 -0000
@@ -1,6 +1,6 @@
 /*	$NetBSD: ral.c,v 1.4 2005/07/12 12:13:00 drochner Exp $ */
 /*	$OpenBSD: ral.c,v 1.56 2005/07/02 23:14:42 brad Exp $  */
-/*	$FreeBSD: src/sys/dev/ral/if_ral.c,v 1.8 2005/07/08 19:33:42 damien Exp $	*/
+/*	$FreeBSD: /a/cvsroot/freebsd.repo/ncvs/src/sys/dev/ral/if_ral.c,v 1.10 2005/07/10 22:25:44 sam Exp $	*/
 
 /*-
  * Copyright (c) 2005
@@ -90,8 +90,6 @@ static void		ral_free_rx_ring(struct ral
 			    struct ral_rx_ring *);
 static struct		ieee80211_node *ral_node_alloc(
 			    struct ieee80211_node_table *);
-static int		ral_key_alloc(struct ieee80211com *,
-			    const struct ieee80211_key *);
 static int		ral_media_change(struct ifnet *);
 static void		ral_next_scan(void *);
 static void		ral_iter_func(void *, struct ieee80211_node *);
@@ -452,7 +450,6 @@ ral_attach(struct ral_softc *sc)
 	/* override state transition machine */
 	sc->sc_newstate = ic->ic_newstate;
 	ic->ic_newstate = ral_newstate;
-	ic->ic_crypto.cs_key_alloc = ral_key_alloc;
 	ieee80211_media_init(ic, ral_media_change, ieee80211_media_status);
 
 #if NBPFILTER > 0
@@ -814,15 +811,6 @@ ral_node_alloc(struct ieee80211_node_tab
 }
 
 static int
-ral_key_alloc(struct ieee80211com *ic, const struct ieee80211_key *k)
-{
-	if (k >= ic->ic_nw_keys && k < &ic->ic_nw_keys[IEEE80211_WEP_NKID])
-		return k - ic->ic_nw_keys;
-
-	return IEEE80211_KEYIX_NONE;
-}
-
-static int
 ral_media_change(struct ifnet *ifp)
 {
 	int error;
@@ -881,7 +869,6 @@ static int
 ral_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
 {
 	struct ral_softc *sc = ic->ic_ifp->if_softc;
-	struct ifnet *ifp = &sc->sc_if;
 	enum ieee80211_state ostate;
 	struct mbuf *m;
 	int error = 0;
@@ -918,10 +905,8 @@ ral_newstate(struct ieee80211com *ic, en
 	case IEEE80211_S_RUN:
 		ral_set_chan(sc, ic->ic_bss->ni_chan);
 
-		if (ic->ic_opmode != IEEE80211_M_MONITOR) {
+		if (ic->ic_opmode != IEEE80211_M_MONITOR)
 			ral_set_bssid(sc, ic->ic_bss->ni_bssid);
-			ral_update_slot(ifp);
-		}
 
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP ||
 		    ic->ic_opmode == IEEE80211_M_IBSS) {
Index: src/sys/dev/usb/if_ural.c
===================================================================
RCS file: /home/fun/cvsroot/NetBSD/src/sys/dev/usb/if_ural.c,v
retrieving revision 1.5
diff -u -p -r1.5 if_ural.c
--- src/sys/dev/usb/if_ural.c	12 Jul 2005 12:51:03 -0000	1.5
+++ src/sys/dev/usb/if_ural.c	16 Aug 2005 13:43:58 -0000
@@ -1,6 +1,6 @@
 /*	$NetBSD: if_ural.c,v 1.5 2005/07/12 12:51:03 drochner Exp $ */
 /*	$OpenBSD: if_ral.c,v 1.38 2005/07/07 08:33:22 jsg Exp $  */
-/*	$FreeBSD: src/sys/dev/usb/if_ural.c,v 1.9 2005/07/08 19:19:06 damien Exp $	*/
+/*	$FreeBSD: /a/cvsroot/freebsd.repo/ncvs/src/sys/dev/usb/if_ural.c,v 1.10 2005/07/10 00:17:05 sam Exp $	*/
 
 /*-
  * Copyright (c) 2005
@@ -114,8 +114,6 @@ Static int		ural_alloc_tx_list(struct ur
 Static void		ural_free_tx_list(struct ural_softc *);
 Static int		ural_alloc_rx_list(struct ural_softc *);
 Static void		ural_free_rx_list(struct ural_softc *);
-Static int		ural_key_alloc(struct ieee80211com *,
-			    const struct ieee80211_key *);
 Static int		ural_media_change(struct ifnet *);
 Static void		ural_next_scan(void *);
 Static void		ural_task(void *);
@@ -487,7 +485,6 @@ USB_ATTACH(ural)
 	/* override state transition machine */
 	sc->sc_newstate = ic->ic_newstate;
 	ic->ic_newstate = ural_newstate;
-	ic->ic_crypto.cs_key_alloc = ural_key_alloc;
 	ieee80211_media_init(ic, ural_media_change, ieee80211_media_status);
 
 #if NBPFILTER > 0
@@ -681,15 +678,6 @@ ural_free_rx_list(struct ural_softc *sc)
 }
 
 Static int
-ural_key_alloc(struct ieee80211com *ic, const struct ieee80211_key *k)
-{
-	if (k >= ic->ic_nw_keys && k < &ic->ic_nw_keys[IEEE80211_WEP_NKID])
-		return k - ic->ic_nw_keys;
-
-	return IEEE80211_KEYIX_NONE;
-}
-
-Static int
 ural_media_change(struct ifnet *ifp)
 {
 	int error;