From owner-p4-projects@FreeBSD.ORG Wed Sep 24 18:11:36 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0636816A4C0; Wed, 24 Sep 2003 18:11:36 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B873116A4B3 for ; Wed, 24 Sep 2003 18:11:35 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 164CE44014 for ; Wed, 24 Sep 2003 18:11:34 -0700 (PDT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h8P1BXXJ035638 for ; Wed, 24 Sep 2003 18:11:33 -0700 (PDT) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h8P1BXSN035635 for perforce@freebsd.org; Wed, 24 Sep 2003 18:11:33 -0700 (PDT) (envelope-from sam@freebsd.org) Date: Wed, 24 Sep 2003 18:11:33 -0700 (PDT) Message-Id: <200309250111.h8P1BXSN035635@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 38551 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Sep 2003 01:11:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=38551 Change 38551 by sam@sam_ebb on 2003/09/24 18:10:56 Try yet again to deal with timing out nodes. We cannot hold the node lock while sending a management frame as this will potentially result in a LOR with a driver lock. This doesn't happen for the Atheros driver but does for the wi driver. Use a generation number to help process each node once when scanning the node table and drop the node lock if we need to timeout a node and send a frame. Affected files ... .. //depot/projects/netperf/sys/net80211/ieee80211_node.c#9 edit .. //depot/projects/netperf/sys/net80211/ieee80211_node.h#6 edit .. //depot/projects/netperf/sys/net80211/ieee80211_var.h#6 edit Differences ... ==== //depot/projects/netperf/sys/net80211/ieee80211_node.c#9 (text+ko) ==== @@ -92,6 +92,7 @@ ic->ic_node_free = ieee80211_node_free; ic->ic_node_copy = ieee80211_node_copy; ic->ic_node_getrssi = ieee80211_node_getrssi; + ic->ic_scangen = 1; } void @@ -544,30 +545,48 @@ mtx_unlock(&ic->ic_nodelock); } +/* + * Timeout inactive nodes. Note that we cannot hold the node + * lock while sending a frame as this would lead to a LOR. + * Instead we use a generation number to mark nodes that we've + * scanned and drop the lock and restart a scan if we have to + * time out a node. Since we are single-threaded by virtue of + * controlling the inactivity timer we can be sure this will + * process each node only once. + */ void ieee80211_timeout_nodes(struct ieee80211com *ic) { - struct ieee80211_node *ni, *nextbs; + struct ieee80211_node *ni; + u_int gen = ic->ic_scangen++; /* NB: ok 'cuz single-threaded*/ +restart: mtx_lock(&ic->ic_nodelock); - for (ni = TAILQ_FIRST(&ic->ic_node); ni != NULL;) { + TAILQ_FOREACH(ni, &ic->ic_node, ni_list) { + if (ni->ni_scangen == gen) /* previously handled */ + continue; + ni->ni_scangen = gen; if (++ni->ni_inact > IEEE80211_INACT_MAX) { IEEE80211_DPRINTF(("station %s timed out " "due to inactivity (%u secs)\n", ether_sprintf(ni->ni_macaddr), ni->ni_inact)); - nextbs = TAILQ_NEXT(ni, ni_list); /* * Send a deauthenticate frame. + * + * Drop the node lock before sending the + * deauthentication frame in case the driver takes + * a lock, as this will result in a LOR between the + * node lock and the driver lock. */ + mtx_unlock(&ic->ic_nodelock); IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH, IEEE80211_REASON_AUTH_EXPIRE); ieee80211_free_node(ic, ni); ic->ic_stats.is_node_timeout++; - ni = nextbs; - } else - ni = TAILQ_NEXT(ni, ni_list); + goto restart; + } } if (!TAILQ_EMPTY(&ic->ic_node)) ic->ic_inact_timer = IEEE80211_INACT_WAIT; ==== //depot/projects/netperf/sys/net80211/ieee80211_node.h#6 (text+ko) ==== @@ -62,6 +62,7 @@ TAILQ_ENTRY(ieee80211_node) ni_list; LIST_ENTRY(ieee80211_node) ni_hash; u_int ni_refcnt; + u_int ni_scangen; /* gen# for timeout scan */ /* hardware */ u_int32_t ni_rstamp; /* recv timestamp */ ==== //depot/projects/netperf/sys/net80211/ieee80211_var.h#6 (text+ko) ==== @@ -166,6 +166,7 @@ u_int16_t ic_rtsthreshold; u_int16_t ic_fragthreshold; struct mtx ic_nodelock; /* on node table */ + u_int ic_scangen; /* gen# for timeout scan */ struct ieee80211_node *(*ic_node_alloc)(struct ieee80211com *); void (*ic_node_free)(struct ieee80211com *, struct ieee80211_node *);