From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:07:55 2008 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 ABC211065699; Sun, 26 Oct 2008 00:07:55 +0000 (UTC) (envelope-from olli@fromme.com) Received: from haluter.fromme.com (haluter.fromme.com [212.17.241.231]) by mx1.freebsd.org (Postfix) with ESMTP id 0C46C8FC12; Sun, 26 Oct 2008 00:07:54 +0000 (UTC) (envelope-from olli@fromme.com) Received: from haluter.fromme.com (irc_sucks@localhost [127.0.0.1]) by haluter.fromme.com (8.14.3/8.14.3) with ESMTP id m9Q07qBD053067; Sun, 26 Oct 2008 02:07:53 +0200 (CEST) (envelope-from olli@fromme.com) Received: (from olli@localhost) by haluter.fromme.com (8.14.3/8.14.3/Submit) id m9Q07q9Z053065; Sun, 26 Oct 2008 02:07:52 +0200 (CEST) (envelope-from olli) From: Oliver Fromme Message-Id: <200810260007.m9Q07q9Z053065@haluter.fromme.com> To: maxim@macomnet.ru (Maxim Konovalov) Date: Sun, 26 Oct 2008 02:07:52 +0200 (CEST) In-Reply-To: <20081025234159.G17979@mp2.macomnet.net> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (haluter.fromme.com [127.0.0.1]); Sun, 26 Oct 2008 02:07:53 +0200 (CEST) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, Ceri Davies , Ed Schouten , src-committers@FreeBSD.org Subject: Re: svn commit: r184265 - head/etc/periodic/security 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: Sun, 26 Oct 2008 00:07:55 -0000 Maxim Konovalov wrote: > On Sat, 25 Oct 2008, 20:16+0100, Ceri Davies wrote: > > On Sat, Oct 25, 2008 at 06:45:40PM +0000, Ed Schouten wrote: > > > Author: ed > > > Date: Sat Oct 25 18:45:40 2008 > > > New Revision: 184265 > > > URL: http://svn.freebsd.org/changeset/base/184265 > > > > > > Log: > > > Sort `mount -p' output by name before checking for any differences. > > > > > > I noticed on a system at home that restarting named(8) causes the > > > /var/named/dev mount to be moved to the bottom of the mount list, > > > because it gets remounted. When I received the daily security email this > > > morning, I was quite amazed to see that the security report listed the > > > differences, while it was nothing out of the ordinary. > > > > > > If we just throw the `mount -p' output through sort(1), we'll only > > > receive notifications about changes to mounts if something has really > > > changed. > > > > Hmm. I've always found it useful to know that the mount list has > > changed, so that I can work out if I did anything to cause it to > > happen or not - if not, I have something to worry about. I want to > > see this every time. But you didn't see it every time. See below. > Seconded. From the sysadmin point of view it's better to be on the > safe side. You should be aware that you were *not* on the safe side before that change. You only saw modifications if they happened to change the order in the mount output. If someone changed the last mount (or mounts) in the list, there would be no difference in the output. So this was completely unreliable anyway. Therefore I think Ed's change is good, because it makes the behaviour of the script more deterministic. If you *really* want to see all changes, then the script must record the device IDs of all mounts and compare them, i.e. something like this: $ mount -p | awk '{print $2}' | xargs stat -f '%N %d' | sort Then you will reliably notice if any of the file systems was umounted/remounted, even if the order in the "mount" output didn't change. Best regards Oliver -- Oliver Fromme, Bunsenstr. 13, 81735 Muenchen, Germany ``We are all but compressed light'' (Albert Einstein) From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:32:03 2008 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 4BCDD106567C; Sun, 26 Oct 2008 00:32:03 +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 3B5E88FC0A; Sun, 26 Oct 2008 00:32:03 +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 m9Q0W3BR063691; Sun, 26 Oct 2008 00:32:03 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0W3eY063690; Sun, 26 Oct 2008 00:32:03 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260032.m9Q0W3eY063690@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:32:03 +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: r184281 - 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: Sun, 26 Oct 2008 00:32:03 -0000 Author: sam Date: Sun Oct 26 00:32:02 2008 New Revision: 184281 URL: http://svn.freebsd.org/changeset/base/184281 Log: fix old merge botch that causes gaps in the tx seq# space for QoS frames Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sat Oct 25 23:58:59 2008 (r184280) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:32:02 2008 (r184281) @@ -1083,7 +1083,6 @@ ieee80211_encap(struct ieee80211_node *n htole16(ni->ni_txseqs[tid] << IEEE80211_SEQ_SEQ_SHIFT); ni->ni_txseqs[tid]++; } - ni->ni_txseqs[tid]++; } else { *(uint16_t *)wh->i_seq = htole16(ni->ni_txseqs[IEEE80211_NONQOS_TID] << IEEE80211_SEQ_SEQ_SHIFT); From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:43:11 2008 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 CB4D2106566B; Sun, 26 Oct 2008 00:43:11 +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 B9FDA8FC14; Sun, 26 Oct 2008 00:43:11 +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 m9Q0hB3P064689; Sun, 26 Oct 2008 00:43:11 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0hBYd064685; Sun, 26 Oct 2008 00:43:11 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260043.m9Q0hBYd064685@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:43:11 +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: r184282 - 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: Sun, 26 Oct 2008 00:43:12 -0000 Author: sam Date: Sun Oct 26 00:43:11 2008 New Revision: 184282 URL: http://svn.freebsd.org/changeset/base/184282 Log: o change ieee80211_mgmt_output to take a raw xmit parameters block so the net80211 layer has complete control over the handling of mgt frames (in particular, the ac, tx rate, and retry count); this also allows us to purge the M_LINK0 flag that was attached to mbufs to mark them as needing encryption for shared key auth o change ieee80211_send_setup to take a tid parameter so it can be used to setup QoS frames Modified: head/sys/net80211/ieee80211_freebsd.h head/sys/net80211/ieee80211_ht.c head/sys/net80211/ieee80211_output.c head/sys/net80211/ieee80211_proto.h Modified: head/sys/net80211/ieee80211_freebsd.h ============================================================================== --- head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 00:32:02 2008 (r184281) +++ head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 00:43:11 2008 (r184282) @@ -239,7 +239,6 @@ void ieee80211_vap_destroy(struct ieee80 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen); /* tx path usage */ -#define M_LINK0 M_PROTO1 /* WEP requested */ #define M_WDS M_PROTO2 /* WDS frame */ #define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */ #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ @@ -248,7 +247,7 @@ struct mbuf *ieee80211_getmgtframe(uint8 #define M_TXCB M_PROTO7 /* do tx complete callback */ #define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */ #define M_80211_TX \ - (M_LINK0|M_WDS|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU) + (M_WDS|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU) /* rx path usage */ #define M_AMPDU M_PROTO1 /* A-MPDU subframe */ Modified: head/sys/net80211/ieee80211_ht.c ============================================================================== --- head/sys/net80211/ieee80211_ht.c Sun Oct 26 00:32:02 2008 (r184281) +++ head/sys/net80211/ieee80211_ht.c Sun Oct 26 00:43:11 2008 (r184282) @@ -2104,6 +2104,7 @@ ieee80211_send_action(struct ieee80211_n } while (0) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + struct ieee80211_bpf_params params; struct mbuf *m; uint8_t *frm; uint16_t baparamset; @@ -2207,7 +2208,14 @@ ieee80211_send_action(struct ieee80211_n } m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); - return ieee80211_mgmt_output(ni, m, IEEE80211_FC0_SUBTYPE_ACTION); + memset(¶ms, 0, sizeof(params)); + params.ibp_pri = WME_AC_VO; + params.ibp_rate0 = ni->ni_txparms->mgmtrate; + /* NB: we know all frames are unicast */ + params.ibp_try0 = ni->ni_txparms->maxretry; + params.ibp_power = ni->ni_txpower; + return ieee80211_mgmt_output(ni, m, IEEE80211_FC0_SUBTYPE_ACTION, + ¶ms); bad: ieee80211_free_node(ni); if (m != NULL) Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 00:32:02 2008 (r184281) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:43:11 2008 (r184282) @@ -409,7 +409,7 @@ static void ieee80211_send_setup( struct ieee80211_node *ni, struct ieee80211_frame *wh, - int type, + int type, int tid, const uint8_t sa[IEEE80211_ADDR_LEN], const uint8_t da[IEEE80211_ADDR_LEN], const uint8_t bssid[IEEE80211_ADDR_LEN]) @@ -457,11 +457,9 @@ ieee80211_send_setup( IEEE80211_ADDR_COPY(wh->i_addr3, bssid); } *(uint16_t *)&wh->i_dur[0] = 0; - /* XXX probe response use per-vap seq#? */ - /* NB: use non-QoS tid */ *(uint16_t *)&wh->i_seq[0] = - htole16(ni->ni_txseqs[IEEE80211_NONQOS_TID] << IEEE80211_SEQ_SEQ_SHIFT); - ni->ni_txseqs[IEEE80211_NONQOS_TID]++; + htole16(ni->ni_txseqs[tid] << IEEE80211_SEQ_SEQ_SHIFT); + ni->ni_txseqs[tid]++; #undef WH4 } @@ -474,7 +472,8 @@ ieee80211_send_setup( * otherwise deal with reclaiming any reference (on error). */ int -ieee80211_mgmt_output(struct ieee80211_node *ni, struct mbuf *m, int type) +ieee80211_mgmt_output(struct ieee80211_node *ni, struct mbuf *m, int type, + struct ieee80211_bpf_params *params) { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; @@ -501,20 +500,18 @@ ieee80211_mgmt_output(struct ieee80211_n } wh = mtod(m, struct ieee80211_frame *); - ieee80211_send_setup(ni, wh, - IEEE80211_FC0_TYPE_MGT | type, - vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); - if ((m->m_flags & M_LINK0) != 0 && ni->ni_challenge != NULL) { - m->m_flags &= ~M_LINK0; + ieee80211_send_setup(ni, wh, + IEEE80211_FC0_TYPE_MGT | type, IEEE80211_NONQOS_TID, + vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); + if (params->ibp_flags & IEEE80211_BPF_CRYPTO) { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr1, "encrypting frame (%s)", __func__); wh->i_fc[1] |= IEEE80211_FC1_WEP; } - if (type != IEEE80211_FC0_SUBTYPE_PROBE_RESP) { - /* NB: force non-ProbeResp frames to the highest queue */ - M_WME_SETAC(m, WME_AC_VO); - } else - M_WME_SETAC(m, WME_AC_BE); + + KASSERT(type != IEEE80211_FC0_SUBTYPE_PROBE_RESP, ("probe response?")); + M_WME_SETAC(m, params->ibp_pri); + #ifdef IEEE80211_DEBUG /* avoid printing too many frames */ if ((ieee80211_msg_debug(vap) && doprint(vap, type)) || @@ -529,7 +526,7 @@ ieee80211_mgmt_output(struct ieee80211_n #endif IEEE80211_NODE_STAT(ni, tx_mgmt); - return ic->ic_raw_xmit(ni, m, NULL); + return ic->ic_raw_xmit(ni, m, params); } /* @@ -569,8 +566,9 @@ ieee80211_send_nulldata(struct ieee80211 wh = mtod(m, struct ieee80211_frame *); ieee80211_send_setup(ni, wh, - IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA, - vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); + IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA, + IEEE80211_NONQOS_TID, + vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); if (vap->iv_opmode != IEEE80211_M_WDS) { /* NB: power management bit is never sent by an AP */ if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && @@ -1726,8 +1724,8 @@ ieee80211_send_probereq(struct ieee80211 wh = mtod(m, struct ieee80211_frame *); ieee80211_send_setup(ni, wh, - IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_REQ, - sa, da, bssid); + IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_REQ, + IEEE80211_NONQOS_TID, sa, da, bssid); /* XXX power management? */ M_WME_SETAC(m, WME_AC_BE); @@ -1785,6 +1783,7 @@ ieee80211_send_mgmt(struct ieee80211_nod struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; struct ieee80211_node *bss = vap->iv_bss; + struct ieee80211_bpf_params params; struct mbuf *m; uint8_t *frm; uint16_t capinfo; @@ -1804,6 +1803,7 @@ ieee80211_send_mgmt(struct ieee80211_nod ieee80211_node_refcnt(ni)+1); ieee80211_ref_node(ni); + memset(¶ms, 0, sizeof(params)); switch (type) { case IEEE80211_FC0_SUBTYPE_AUTH: @@ -1826,7 +1826,7 @@ ieee80211_send_mgmt(struct ieee80211_nod bss->ni_authmode == IEEE80211_AUTH_SHARED); m = ieee80211_getmgtframe(&frm, - ic->ic_headroom + sizeof(struct ieee80211_frame), + ic->ic_headroom + sizeof(struct ieee80211_frame), 3 * sizeof(uint16_t) + (has_challenge && status == IEEE80211_STATUS_SUCCESS ? sizeof(uint16_t)+IEEE80211_CHALLENGE_LEN : 0) @@ -1851,7 +1851,8 @@ ieee80211_send_mgmt(struct ieee80211_nod if (arg == IEEE80211_AUTH_SHARED_RESPONSE) { IEEE80211_NOTE(vap, IEEE80211_MSG_AUTH, ni, "request encrypt frame (%s)", __func__); - m->m_flags |= M_LINK0; /* WEP-encrypt, please */ + /* mark frame for encryption */ + params.ibp_flags |= IEEE80211_BPF_CRYPTO; } } else m->m_pkthdr.len = m->m_len = 3 * sizeof(uint16_t); @@ -2092,7 +2093,13 @@ ieee80211_send_mgmt(struct ieee80211_nod /* NOTREACHED */ } - return ieee80211_mgmt_output(ni, m, type); + /* NB: force non-ProbeResp frames to the highest queue */ + params.ibp_pri = WME_AC_VO; + params.ibp_rate0 = bss->ni_txparms->mgmtrate; + /* NB: we know all frames are unicast */ + params.ibp_try0 = bss->ni_txparms->maxretry; + params.ibp_power = bss->ni_txpower; + return ieee80211_mgmt_output(ni, m, type, ¶ms); bad: ieee80211_free_node(ni); return ret; @@ -2296,8 +2303,8 @@ ieee80211_send_proberesp(struct ieee8021 wh = mtod(m, struct ieee80211_frame *); ieee80211_send_setup(bss, wh, - IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP, - vap->iv_myaddr, da, bss->ni_bssid); + IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP, + IEEE80211_NONQOS_TID, vap->iv_myaddr, da, bss->ni_bssid); /* XXX power management? */ M_WME_SETAC(m, WME_AC_BE); Modified: head/sys/net80211/ieee80211_proto.h ============================================================================== --- head/sys/net80211/ieee80211_proto.h Sun Oct 26 00:32:02 2008 (r184281) +++ head/sys/net80211/ieee80211_proto.h Sun Oct 26 00:43:11 2008 (r184282) @@ -64,7 +64,8 @@ void ieee80211_syncflag_ext(struct ieee8 ((ni)->ni_vap->iv_input(ni, m, rssi, noise, rstamp)) int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int, uint32_t); -int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int); +int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, + struct ieee80211_bpf_params *); struct ieee80211_bpf_params; int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:46:17 2008 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 A560B106567E; Sun, 26 Oct 2008 00:46:17 +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 947238FC1A; Sun, 26 Oct 2008 00:46:17 +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 m9Q0kH7k064996; Sun, 26 Oct 2008 00:46:17 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0kHqZ064995; Sun, 26 Oct 2008 00:46:17 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260046.m9Q0kHqZ064995@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:46:17 +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: r184283 - 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: Sun, 26 Oct 2008 00:46:17 -0000 Author: sam Date: Sun Oct 26 00:46:17 2008 New Revision: 184283 URL: http://svn.freebsd.org/changeset/base/184283 Log: change ieee80211_send_nulldata to send a QoS Null Data frame to a QoS-enabled station; this makes inactivity handling follow the spec as previously it would probe inactive stations w/ a Null Data (no QoS) data frame Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 00:43:11 2008 (r184282) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:46:17 2008 (r184283) @@ -530,7 +530,9 @@ ieee80211_mgmt_output(struct ieee80211_n } /* - * Send a null data frame to the specified node. + * Send a null data frame to the specified node. If the station + * is setup for QoS then a QoS Null Data frame is constructed. + * If this is a WDS station then a 4-address frame is constructed. * * NB: the caller is assumed to have setup a node reference * for use; this is necessary to deal with a race condition @@ -546,6 +548,8 @@ ieee80211_send_nulldata(struct ieee80211 struct ieee80211com *ic = ni->ni_ic; struct mbuf *m; struct ieee80211_frame *wh; + int hdrlen; + uint8_t *frm; if (vap->iv_state == IEEE80211_S_CAC) { IEEE80211_NOTE(vap, IEEE80211_MSG_OUTPUT | IEEE80211_MSG_DOTH, @@ -555,37 +559,70 @@ ieee80211_send_nulldata(struct ieee80211 return EIO; /* XXX */ } - m = m_gethdr(M_NOWAIT, MT_HEADER); + if (ni->ni_flags & (IEEE80211_NODE_QOS|IEEE80211_NODE_HT)) + hdrlen = sizeof(struct ieee80211_qosframe); + else + hdrlen = sizeof(struct ieee80211_frame); + /* NB: only WDS vap's get 4-address frames */ + if (vap->iv_opmode == IEEE80211_M_WDS) + hdrlen += IEEE80211_ADDR_LEN; + if (ic->ic_flags & IEEE80211_F_DATAPAD) + hdrlen = roundup(hdrlen, sizeof(uint32_t)); + + m = ieee80211_getmgtframe(&frm, ic->ic_headroom + hdrlen, 0); if (m == NULL) { /* XXX debug msg */ ieee80211_unref_node(&ni); vap->iv_stats.is_tx_nobuf++; return ENOMEM; } - MH_ALIGN(m, sizeof(struct ieee80211_frame)); + KASSERT(M_LEADINGSPACE(m) >= hdrlen, + ("leading space %zd", M_LEADINGSPACE(m))); + M_PREPEND(m, hdrlen, M_DONTWAIT); + if (m == NULL) { + /* NB: cannot happen */ + ieee80211_free_node(ni); + return ENOMEM; + } - wh = mtod(m, struct ieee80211_frame *); - ieee80211_send_setup(ni, wh, - IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA, - IEEE80211_NONQOS_TID, - vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); + wh = mtod(m, struct ieee80211_frame *); /* NB: a little lie */ + if (ni->ni_flags & IEEE80211_NODE_QOS) { + const int tid = WME_AC_TO_TID(WME_AC_BE); + uint8_t *qos; + + ieee80211_send_setup(ni, wh, + IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS_NULL, + tid, vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); + + if (vap->iv_opmode == IEEE80211_M_WDS) + qos = ((struct ieee80211_qosframe_addr4 *) wh)->i_qos; + else + qos = ((struct ieee80211_qosframe *) wh)->i_qos; + qos[0] = tid & IEEE80211_QOS_TID; + if (ic->ic_wme.wme_wmeChanParams.cap_wmeParams[WME_AC_BE].wmep_noackPolicy) + qos[0] |= IEEE80211_QOS_ACKPOLICY_NOACK; + qos[1] = 0; + } else { + ieee80211_send_setup(ni, wh, + IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA, + IEEE80211_NONQOS_TID, + vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); + } if (vap->iv_opmode != IEEE80211_M_WDS) { /* NB: power management bit is never sent by an AP */ if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && vap->iv_opmode != IEEE80211_M_HOSTAP) wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT; - m->m_len = m->m_pkthdr.len = sizeof(struct ieee80211_frame); - } else { - /* NB: 4-address frame */ - m->m_len = m->m_pkthdr.len = - sizeof(struct ieee80211_frame_addr4); } + m->m_len = m->m_pkthdr.len = hdrlen; + M_WME_SETAC(m, WME_AC_BE); IEEE80211_NODE_STAT(ni, tx_data); IEEE80211_NOTE(vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_DUMPPKTS, ni, - "send null data frame on channel %u, pwr mgt %s", + "send %snull data frame on channel %u, pwr mgt %s", + ni->ni_flags & IEEE80211_NODE_QOS ? "QoS " : "", ieee80211_chan2ieee(ic, ic->ic_curchan), wh->i_fc[1] & IEEE80211_FC1_PWR_MGT ? "ena" : "dis"); From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:48:20 2008 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 AF6BA10656A2; Sun, 26 Oct 2008 00:48:20 +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 9EE288FC12; Sun, 26 Oct 2008 00:48:20 +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 m9Q0mK53065204; Sun, 26 Oct 2008 00:48:20 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0mKOt065203; Sun, 26 Oct 2008 00:48:20 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260048.m9Q0mKOt065203@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:48:20 +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: r184284 - 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: Sun, 26 Oct 2008 00:48:20 -0000 Author: sam Date: Sun Oct 26 00:48:20 2008 New Revision: 184284 URL: http://svn.freebsd.org/changeset/base/184284 Log: change ieee80211_send_probereq to supply raw xmit parameters so it can control how frames are handled by the driver Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 00:46:17 2008 (r184283) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:48:20 2008 (r184284) @@ -1688,6 +1688,8 @@ ieee80211_send_probereq(struct ieee80211 { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + const struct ieee80211_txparam *tp; + struct ieee80211_bpf_params params; struct ieee80211_frame *wh; const struct ieee80211_rateset *rs; struct mbuf *m; @@ -1755,9 +1757,14 @@ ieee80211_send_probereq(struct ieee80211 frm = add_appie(frm, vap->iv_appie_probereq); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); + KASSERT(M_LEADINGSPACE(m) >= sizeof(struct ieee80211_frame), + ("leading space %zd", M_LEADINGSPACE(m))); M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT); - if (m == NULL) + if (m == NULL) { + /* NB: cannot happen */ + ieee80211_free_node(ni); return ENOMEM; + } wh = mtod(m, struct ieee80211_frame *); ieee80211_send_setup(ni, wh, @@ -1775,7 +1782,17 @@ ieee80211_send_probereq(struct ieee80211 ieee80211_chan2ieee(ic, ic->ic_curchan), ether_sprintf(bssid), ssidlen, ssid); - return ic->ic_raw_xmit(ni, m, NULL); + memset(¶ms, 0, sizeof(params)); + params.ibp_pri = M_WME_GETAC(m); + tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; + params.ibp_rate0 = tp->mgmtrate; + if (IEEE80211_IS_MULTICAST(da)) { + params.ibp_flags |= IEEE80211_BPF_NOACK; + params.ibp_try0 = 1; + } else + params.ibp_try0 = tp->maxretry; + params.ibp_power = ni->ni_txpower; + return ic->ic_raw_xmit(ni, m, ¶ms); } /* From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:52:27 2008 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 39E781065671; Sun, 26 Oct 2008 00:52:27 +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 293DE8FC08; Sun, 26 Oct 2008 00:52:27 +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 m9Q0qQh2065575; Sun, 26 Oct 2008 00:52:26 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0qQh4065574; Sun, 26 Oct 2008 00:52:26 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260052.m9Q0qQh4065574@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:52:26 +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: r184285 - 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: Sun, 26 Oct 2008 00:52:27 -0000 Author: sam Date: Sun Oct 26 00:52:26 2008 New Revision: 184285 URL: http://svn.freebsd.org/changeset/base/184285 Log: fix comment that belonged w/ previous commit Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 00:48:20 2008 (r184284) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:52:26 2008 (r184285) @@ -401,9 +401,8 @@ bad: /* * Set the direction field and address fields of an outgoing - * non-QoS frame. Note this should be called early on in - * constructing a frame as it sets i_fc[1]; other bits can - * then be or'd in. + * frame. Note this should be called early on in constructing + * a frame as it sets i_fc[1]; other bits can then be or'd in. */ static void ieee80211_send_setup( From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 00:55:39 2008 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 1378C1065672; Sun, 26 Oct 2008 00:55:39 +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 0217A8FC0C; Sun, 26 Oct 2008 00:55:39 +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 m9Q0tcBN065890; Sun, 26 Oct 2008 00:55:38 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q0tcpY065888; Sun, 26 Oct 2008 00:55:38 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260055.m9Q0tcpY065888@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 00:55:38 +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: r184286 - 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: Sun, 26 Oct 2008 00:55:39 -0000 Author: sam Date: Sun Oct 26 00:55:38 2008 New Revision: 184286 URL: http://svn.freebsd.org/changeset/base/184286 Log: introduce M_ENCAP flag to mark packets encapsulated w/ an 802.11 header Modified: head/sys/net80211/ieee80211_freebsd.h head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_freebsd.h ============================================================================== --- head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 00:52:26 2008 (r184285) +++ head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 00:55:38 2008 (r184286) @@ -239,6 +239,7 @@ void ieee80211_vap_destroy(struct ieee80 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen); /* tx path usage */ +#define M_ENCAP M_PROTO1 /* 802.11 encap done */ #define M_WDS M_PROTO2 /* WDS frame */ #define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */ #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ @@ -247,7 +248,7 @@ struct mbuf *ieee80211_getmgtframe(uint8 #define M_TXCB M_PROTO7 /* do tx complete callback */ #define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */ #define M_80211_TX \ - (M_WDS|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU) + (M_ENCAP|M_WDS|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU) /* rx path usage */ #define M_AMPDU M_PROTO1 /* A-MPDU subframe */ Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 00:52:26 2008 (r184285) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 00:55:38 2008 (r184286) @@ -507,6 +507,7 @@ ieee80211_mgmt_output(struct ieee80211_n "encrypting frame (%s)", __func__); wh->i_fc[1] |= IEEE80211_FC1_WEP; } + m->m_flags |= M_ENCAP; /* mark encapsulated */ KASSERT(type != IEEE80211_FC0_SUBTYPE_PROBE_RESP, ("probe response?")); M_WME_SETAC(m, params->ibp_pri); @@ -614,6 +615,7 @@ ieee80211_send_nulldata(struct ieee80211 wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT; } m->m_len = m->m_pkthdr.len = hdrlen; + m->m_flags |= M_ENCAP; /* mark encapsulated */ M_WME_SETAC(m, WME_AC_BE); @@ -1151,6 +1153,8 @@ ieee80211_encap(struct ieee80211_node *n key != NULL ? key->wk_cipher->ic_header : 0, vap->iv_fragthreshold)) goto bad; + m->m_flags |= M_ENCAP; /* mark encapsulated */ + IEEE80211_NODE_STAT(ni, tx_data); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) IEEE80211_NODE_STAT(ni, tx_mcast); @@ -1770,6 +1774,7 @@ ieee80211_send_probereq(struct ieee80211 IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_REQ, IEEE80211_NONQOS_TID, sa, da, bssid); /* XXX power management? */ + m->m_flags |= M_ENCAP; /* mark encapsulated */ M_WME_SETAC(m, WME_AC_BE); @@ -2359,6 +2364,7 @@ ieee80211_send_proberesp(struct ieee8021 IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP, IEEE80211_NONQOS_TID, vap->iv_myaddr, da, bss->ni_bssid); /* XXX power management? */ + m->m_flags |= M_ENCAP; /* mark encapsulated */ M_WME_SETAC(m, WME_AC_BE); From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 01:01:01 2008 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 688D51065673; Sun, 26 Oct 2008 01:01:01 +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 5871D8FC12; Sun, 26 Oct 2008 01:01:01 +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 m9Q111tj066381; Sun, 26 Oct 2008 01:01:01 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q1115T066379; Sun, 26 Oct 2008 01:01:01 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260101.m9Q1115T066379@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 01:01:01 +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: r184287 - 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: Sun, 26 Oct 2008 01:01:01 -0000 Author: sam Date: Sun Oct 26 01:01:01 2008 New Revision: 184287 URL: http://svn.freebsd.org/changeset/base/184287 Log: move decl up before first use Modified: head/sys/net80211/ieee80211_proto.h Modified: head/sys/net80211/ieee80211_proto.h ============================================================================== --- head/sys/net80211/ieee80211_proto.h Sun Oct 26 00:55:38 2008 (r184286) +++ head/sys/net80211/ieee80211_proto.h Sun Oct 26 01:01:01 2008 (r184287) @@ -64,9 +64,9 @@ void ieee80211_syncflag_ext(struct ieee8 ((ni)->ni_vap->iv_input(ni, m, rssi, noise, rstamp)) int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int, uint32_t); +struct ieee80211_bpf_params; int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, struct ieee80211_bpf_params *); -struct ieee80211_bpf_params; int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); int ieee80211_output(struct ifnet *, struct mbuf *, From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 01:04:46 2008 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 96D3410656AE; Sun, 26 Oct 2008 01:04:46 +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 857BB8FC0A; Sun, 26 Oct 2008 01:04:46 +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 m9Q14kXo066734; Sun, 26 Oct 2008 01:04:46 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9Q14krS066726; Sun, 26 Oct 2008 01:04:46 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810260104.m9Q14krS066726@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 01:04:46 +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: r184288 - 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: Sun, 26 Oct 2008 01:04:46 -0000 Author: sam Date: Sun Oct 26 01:04:46 2008 New Revision: 184288 URL: http://svn.freebsd.org/changeset/base/184288 Log: New ap-side power save implementation; the main change is to allow drivers to queue frames previously encapsulated on a separate high priority list that is dispatched before the unencapsulated frames (to preserve order). Modified: head/sys/net80211/ieee80211_freebsd.h head/sys/net80211/ieee80211_hostap.c head/sys/net80211/ieee80211_node.c head/sys/net80211/ieee80211_node.h head/sys/net80211/ieee80211_output.c head/sys/net80211/ieee80211_power.c head/sys/net80211/ieee80211_power.h head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211_freebsd.h ============================================================================== --- head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_freebsd.h Sun Oct 26 01:04:46 2008 (r184288) @@ -112,41 +112,14 @@ typedef struct { } while (0) /* - * Per-node power-save queue definitions. + * Power-save queue definitions. */ -#define IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do { \ - mtx_init(&(_ni)->ni_savedq.ifq_mtx, _name, "802.11 ps queue", MTX_DEF);\ - (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE; \ -} while (0) -#define IEEE80211_NODE_SAVEQ_DESTROY(_ni) \ - mtx_destroy(&(_ni)->ni_savedq.ifq_mtx) -#define IEEE80211_NODE_SAVEQ_QLEN(_ni) \ - _IF_QLEN(&(_ni)->ni_savedq) -#define IEEE80211_NODE_SAVEQ_LOCK(_ni) do { \ - IF_LOCK(&(_ni)->ni_savedq); \ -} while (0) -#define IEEE80211_NODE_SAVEQ_UNLOCK(_ni) do { \ - IF_UNLOCK(&(_ni)->ni_savedq); \ -} while (0) -#define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do { \ - IEEE80211_NODE_SAVEQ_LOCK(_ni); \ - _IF_DEQUEUE(&(_ni)->ni_savedq, _m); \ - (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ - IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ -} while (0) -#define IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do { \ - IEEE80211_NODE_SAVEQ_LOCK(_ni); \ - (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni); \ - _IF_DRAIN(&(_ni)->ni_savedq); \ - IEEE80211_NODE_SAVEQ_UNLOCK(_ni); \ -} while (0) -/* XXX could be optimized */ -#define _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do { \ - _IF_DEQUEUE(&(_ni)->ni_savedq, m); \ -} while (0) -#define _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\ - _AGEQ_ENQUEUE(&ni->ni_savedq, _m, _qlen, _age); \ -} while (0) +typedef struct mtx ieee80211_psq_lock_t; +#define IEEE80211_PSQ_INIT(_psq, _name) \ + mtx_init(&(_psq)->psq_lock, _name, "802.11 ps q", MTX_DEF); +#define IEEE80211_PSQ_DESTROY(_psq) mtx_destroy(&(_psq)->psq_lock) +#define IEEE80211_PSQ_LOCK(_psq) mtx_lock(&(_psq)->psq_lock) +#define IEEE80211_PSQ_UNLOCK(_psq) mtx_unlock(&(_psq)->psq_lock) #ifndef IF_PREPEND_LIST #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do { \ Modified: head/sys/net80211/ieee80211_hostap.c ============================================================================== --- head/sys/net80211/ieee80211_hostap.c Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_hostap.c Sun Oct 26 01:04:46 2008 (r184288) @@ -2171,7 +2171,7 @@ hostap_recv_pspoll(struct ieee80211_node { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211_frame_min *wh; - struct ifnet *ifp = vap->iv_ifp; + struct ifnet *ifp; struct mbuf *m; uint16_t aid; int qlen; @@ -2208,7 +2208,7 @@ hostap_recv_pspoll(struct ieee80211_node } /* Okay, take the first queued packet and put it out... */ - IEEE80211_NODE_SAVEQ_DEQUEUE(ni, m, qlen); + m = ieee80211_node_psq_dequeue(ni, &qlen); if (m == NULL) { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2, "%s", "recv ps-poll, but queue empty"); @@ -2234,6 +2234,11 @@ hostap_recv_pspoll(struct ieee80211_node vap->iv_set_tim(ni, 0); } m->m_flags |= M_PWR_SAV; /* bypass PS handling */ + + if (m->m_flags & M_ENCAP) + ifp = vap->iv_ic->ic_ifp; + else + ifp = vap->iv_ifp; IF_ENQUEUE(&ifp->if_snd, m); if_start(ifp); } Modified: head/sys/net80211/ieee80211_node.c ============================================================================== --- head/sys/net80211/ieee80211_node.c Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_node.c Sun Oct 26 01:04:46 2008 (r184288) @@ -904,7 +904,7 @@ node_cleanup(struct ieee80211_node *ni) /* * Drain power save queue and, if needed, clear TIM. */ - if (ieee80211_node_saveq_drain(ni) != 0 && vap->iv_set_tim != NULL) + if (ieee80211_node_psq_drain(ni) != 0 && vap->iv_set_tim != NULL) vap->iv_set_tim(ni, 0); ni->ni_associd = 0; @@ -943,7 +943,7 @@ node_free(struct ieee80211_node *ni) ic->ic_node_cleanup(ni); ieee80211_ies_cleanup(&ni->ni_ies); - IEEE80211_NODE_SAVEQ_DESTROY(ni); + ieee80211_psq_cleanup(&ni->ni_psq); IEEE80211_NODE_WDSQ_DESTROY(ni); FREE(ni, M_80211_NODE); } @@ -958,9 +958,8 @@ node_age(struct ieee80211_node *ni) /* * Age frames on the power save queue. */ - if (ieee80211_node_saveq_age(ni) != 0 && - IEEE80211_NODE_SAVEQ_QLEN(ni) == 0 && - vap->iv_set_tim != NULL) + if (ieee80211_node_psq_age(ni) != 0 && + ni->ni_psq.psq_len == 0 && vap->iv_set_tim != NULL) vap->iv_set_tim(ni, 0); /* * Age frames on the wds pending queue. @@ -1031,7 +1030,7 @@ ieee80211_alloc_node(struct ieee80211_no ni->ni_inact_reload = nt->nt_inact_init; ni->ni_inact = ni->ni_inact_reload; ni->ni_ath_defkeyix = 0x7fff; - IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); + ieee80211_psq_init(&ni->ni_psq, "unknown"); IEEE80211_NODE_WDSQ_INIT(ni, "unknown"); IEEE80211_NODE_LOCK(nt); @@ -1081,7 +1080,7 @@ ieee80211_tmp_node(struct ieee80211vap * IEEE80211_KEYIX_NONE); ni->ni_txpower = bss->ni_txpower; /* XXX optimize away */ - IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); + ieee80211_psq_init(&ni->ni_psq, "unknown"); IEEE80211_NODE_WDSQ_INIT(ni, "unknown"); } else { /* XXX msg */ Modified: head/sys/net80211/ieee80211_node.h ============================================================================== --- head/sys/net80211/ieee80211_node.h Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_node.h Sun Oct 26 01:04:46 2008 (r184288) @@ -185,7 +185,7 @@ struct ieee80211_node { short ni_inact; /* inactivity mark count */ short ni_inact_reload;/* inactivity reload value */ int ni_txrate; /* legacy rate/MCS */ - struct ifqueue ni_savedq; /* ps-poll queue */ + struct ieee80211_psq ni_psq; /* power save queue */ struct ieee80211_nodestats ni_stats; /* per-node statistics */ struct ieee80211vap *ni_wdsvap; /* associated WDS vap */ Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_output.c Sun Oct 26 01:04:46 2008 (r184288) @@ -225,7 +225,7 @@ ieee80211_start(struct ifnet *ifp) * the frame back when the time is right. * XXX lose WDS vap linkage? */ - ieee80211_pwrsave(ni, m); + (void) ieee80211_pwrsave(ni, m); ieee80211_free_node(ni); continue; } Modified: head/sys/net80211/ieee80211_power.c ============================================================================== --- head/sys/net80211/ieee80211_power.c Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_power.c Sun Oct 26 01:04:46 2008 (r184288) @@ -99,24 +99,115 @@ ieee80211_power_vdetach(struct ieee80211 } } +void +ieee80211_psq_init(struct ieee80211_psq *psq, const char *name) +{ + memset(psq, 0, sizeof(psq)); + psq->psq_maxlen = IEEE80211_PS_MAX_QUEUE; + IEEE80211_PSQ_INIT(psq, name); /* OS-dependent setup */ +} + +void +ieee80211_psq_cleanup(struct ieee80211_psq *psq) +{ +#if 0 + psq_drain(psq); /* XXX should not be needed? */ +#else + KASSERT(psq->psq_len == 0, ("%d frames on ps q", psq->psq_len)); +#endif + IEEE80211_PSQ_DESTROY(psq); /* OS-dependent cleanup */ +} + +/* + * Return the highest priority frame in the ps queue. + */ +struct mbuf * +ieee80211_node_psq_dequeue(struct ieee80211_node *ni, int *qlen) +{ + struct ieee80211_psq *psq = &ni->ni_psq; + struct ieee80211_psq_head *qhead; + struct mbuf *m; + + IEEE80211_PSQ_LOCK(psq); + qhead = &psq->psq_head[0]; +again: + if ((m = qhead->head) != NULL) { + if ((qhead->head = m->m_nextpkt) == NULL) + qhead->tail = NULL; + KASSERT(qhead->len > 0, ("qhead len %d", qhead->len)); + qhead->len--; + KASSERT(psq->psq_len > 0, ("psq len %d", psq->psq_len)); + psq->psq_len--; + m->m_nextpkt = NULL; + } + if (m == NULL && qhead == &psq->psq_head[0]) { + /* Algol-68 style for loop */ + qhead = &psq->psq_head[1]; + goto again; + } + if (qlen != NULL) + *qlen = psq->psq_len; + IEEE80211_PSQ_UNLOCK(psq); + return m; +} + +/* + * Reclaim an mbuf from the ps q. If marked with M_ENCAP + * we assume there is a node reference that must be relcaimed. + */ +static void +psq_mfree(struct mbuf *m) +{ + if (m->m_flags & M_ENCAP) { + struct ieee80211_node *ni = (void *) m->m_pkthdr.rcvif; + ieee80211_free_node(ni); + } + m->m_nextpkt = NULL; + m_freem(m); +} + /* - * Clear any frames queued on a node's power save queue. + * Clear any frames queued in the power save queue. * The number of frames that were present is returned. */ -int -ieee80211_node_saveq_drain(struct ieee80211_node *ni) +static int +psq_drain(struct ieee80211_psq *psq) { + struct ieee80211_psq_head *qhead; + struct mbuf *m; int qlen; - IEEE80211_NODE_SAVEQ_LOCK(ni); - qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); - _IF_DRAIN(&ni->ni_savedq); - IEEE80211_NODE_SAVEQ_UNLOCK(ni); + IEEE80211_PSQ_LOCK(psq); + qlen = psq->psq_len; + qhead = &psq->psq_head[0]; +again: + while ((m = qhead->head) != NULL) { + qhead->head = m->m_nextpkt; + psq_mfree(m); + } + qhead->tail = NULL; + qhead->len = 0; + if (qhead == &psq->psq_head[0]) { /* Algol-68 style for loop */ + qhead = &psq->psq_head[1]; + goto again; + } + psq->psq_len = 0; + IEEE80211_PSQ_UNLOCK(psq); return qlen; } /* + * Clear any frames queued in the power save queue. + * The number of frames that were present is returned. + */ +int +ieee80211_node_psq_drain(struct ieee80211_node *ni) +{ + return psq_drain(&ni->ni_psq); +} + +/* * Age frames on the power save queue. The aging interval is * 4 times the listen interval specified by the station. This * number is factored into the age calculations when the frame @@ -127,28 +218,41 @@ ieee80211_node_saveq_drain(struct ieee80 * can check if it needs to adjust the tim. */ int -ieee80211_node_saveq_age(struct ieee80211_node *ni) +ieee80211_node_psq_age(struct ieee80211_node *ni) { + struct ieee80211_psq *psq = &ni->ni_psq; int discard = 0; - if (IEEE80211_NODE_SAVEQ_QLEN(ni) != 0) { + if (psq->psq_len != 0) { #ifdef IEEE80211_DEBUG struct ieee80211vap *vap = ni->ni_vap; #endif + struct ieee80211_psq_head *qhead; struct mbuf *m; - IEEE80211_NODE_SAVEQ_LOCK(ni); - while (IF_POLL(&ni->ni_savedq, m) != NULL && - M_AGE_GET(m) < IEEE80211_INACT_WAIT) { + IEEE80211_PSQ_LOCK(psq); + qhead = &psq->psq_head[0]; + again: + while ((m = qhead->head) != NULL && + M_AGE_GET(m) < IEEE80211_INACT_WAIT) { IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, "discard frame, age %u", M_AGE_GET(m)); - _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(ni, m); - m_freem(m); + if ((qhead->head = m->m_nextpkt) == NULL) + qhead->tail = NULL; + KASSERT(qhead->len > 0, ("qhead len %d", qhead->len)); + qhead->len--; + KASSERT(psq->psq_len > 0, ("psq len %d", psq->psq_len)); + psq->psq_len--; + psq_mfree(m); discard++; } + if (qhead == &psq->psq_head[0]) { /* Algol-68 style for loop */ + qhead = &psq->psq_head[1]; + goto again; + } if (m != NULL) M_AGE_SUB(m, IEEE80211_INACT_WAIT); - IEEE80211_NODE_SAVEQ_UNLOCK(ni); + IEEE80211_PSQ_UNLOCK(psq); IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, "discard %u frames for age", discard); @@ -211,82 +315,143 @@ ieee80211_set_tim(struct ieee80211_node * The new packet is placed on the node's saved queue, and the TIM * is changed, if necessary. */ -void +int ieee80211_pwrsave(struct ieee80211_node *ni, struct mbuf *m) { + struct ieee80211_psq *psq = &ni->ni_psq; struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + struct ieee80211_psq_head *qhead; int qlen, age; - IEEE80211_NODE_SAVEQ_LOCK(ni); - if (_IF_QFULL(&ni->ni_savedq)) { - _IF_DROP(&ni->ni_savedq); - IEEE80211_NODE_SAVEQ_UNLOCK(ni); + IEEE80211_PSQ_LOCK(psq); + if (psq->psq_len >= psq->psq_maxlen) { + psq->psq_drops++; + IEEE80211_PSQ_UNLOCK(psq); IEEE80211_NOTE(vap, IEEE80211_MSG_ANY, ni, "pwr save q overflow, drops %d (size %d)", - ni->ni_savedq.ifq_drops, IEEE80211_PS_MAX_QUEUE); + psq->psq_drops, psq->psq_len); #ifdef IEEE80211_DEBUG if (ieee80211_msg_dumppkts(vap)) ieee80211_dump_pkt(ni->ni_ic, mtod(m, caddr_t), m->m_len, -1, -1); #endif - m_freem(m); - return; + psq_mfree(m); + return ENOSPC; } /* - * Tag the frame with it's expiry time and insert - * it in the queue. The aging interval is 4 times - * the listen interval specified by the station. - * Frames that sit around too long are reclaimed - * using this information. + * Tag the frame with it's expiry time and insert it in + * the appropriate queue. The aging interval is 4 times + * the listen interval specified by the station. Frames + * that sit around too long are reclaimed using this + * information. */ /* TU -> secs. XXX handle overflow? */ age = IEEE80211_TU_TO_MS((ni->ni_intval * ic->ic_bintval) << 2) / 1000; - _IEEE80211_NODE_SAVEQ_ENQUEUE(ni, m, qlen, age); - IEEE80211_NODE_SAVEQ_UNLOCK(ni); + /* + * Encapsulated frames go on the high priority queue, + * other stuff goes on the low priority queue. We use + * this to order frames returned out of the driver + * ahead of frames we collect in ieee80211_start. + */ + if (m->m_flags & M_ENCAP) + qhead = &psq->psq_head[0]; + else + qhead = &psq->psq_head[1]; + if (qhead->tail == NULL) { + struct mbuf *mh; + + qhead->head = m; + /* + * Take care to adjust age when inserting the first + * frame of a queue and the other queue already has + * frames. We need to preserve the age difference + * relationship so ieee80211_node_psq_age works. + */ + if (qhead == &psq->psq_head[1]) { + mh = psq->psq_head[0].head; + if (mh != NULL) + age-= M_AGE_GET(mh); + } else { + mh = psq->psq_head[1].head; + if (mh != NULL) { + int nage = M_AGE_GET(mh) - age; + /* XXX is clamping to zero good 'nuf? */ + M_AGE_SET(mh, nage < 0 ? 0 : nage); + } + } + } else { + qhead->tail->m_nextpkt = m; + age -= M_AGE_GET(qhead->head); + } + KASSERT(age >= 0, ("age %d", age)); + M_AGE_SET(m, age); + m->m_nextpkt = NULL; + qhead->tail = m; + qhead->len++; + qlen = ++(psq->psq_len); + IEEE80211_PSQ_UNLOCK(psq); IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, "save frame with age %d, %u now queued", age, qlen); if (qlen == 1 && vap->iv_set_tim != NULL) vap->iv_set_tim(ni, 1); + + return 0; } /* - * Unload the frames from the ps q but don't send them - * to the driver yet. We do this in two stages to minimize - * locking but also because there's no easy way to preserve - * ordering given the existing ifnet access mechanisms. - * XXX could be optimized + * Move frames from the ps q to the vap's send queue + * and/or the driver's send queue; and kick the start + * method for each, as appropriate. Note we're careful + * to preserve packet ordering here. */ static void pwrsave_flushq(struct ieee80211_node *ni) { - struct mbuf *m, *mhead, *mtail; - int mcount; + struct ieee80211_psq *psq = &ni->ni_psq; + struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_psq_head *qhead; + struct ifnet *parent, *ifp; - IEEE80211_NODE_SAVEQ_LOCK(ni); - mcount = IEEE80211_NODE_SAVEQ_QLEN(ni); - mhead = mtail = NULL; - for (;;) { - _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(ni, m); - if (m == NULL) - break; - if (mhead == NULL) { - mhead = m; - m->m_nextpkt = NULL; - } else - mtail->m_nextpkt = m; - mtail = m; - } - IEEE80211_NODE_SAVEQ_UNLOCK(ni); - if (mhead != NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, + "flush ps queue, %u packets queued", psq->psq_len); + + IEEE80211_PSQ_LOCK(psq); + qhead = &psq->psq_head[0]; /* 802.11 frames */ + if (qhead->head != NULL) { + /* XXX could dispatch through vap and check M_ENCAP */ + parent = vap->iv_ic->ic_ifp; /* XXX need different driver interface */ /* XXX bypasses q max and OACTIVE */ - struct ifnet *ifp = ni->ni_vap->iv_ifp; - IF_PREPEND_LIST(&ifp->if_snd, mhead, mtail, mcount); + IF_PREPEND_LIST(&parent->if_snd, qhead->head, qhead->tail, + qhead->len); + qhead->head = qhead->tail = NULL; + qhead->len = 0; + } else + parent = NULL; + + qhead = &psq->psq_head[1]; /* 802.3 frames */ + if (qhead->head != NULL) { + ifp = vap->iv_ifp; + /* XXX need different driver interface */ + /* XXX bypasses q max and OACTIVE */ + IF_PREPEND_LIST(&ifp->if_snd, qhead->head, qhead->tail, + qhead->len); + qhead->head = qhead->tail = NULL; + qhead->len = 0; + } else + ifp = NULL; + psq->psq_len = 0; + IEEE80211_PSQ_UNLOCK(psq); + + /* NB: do this outside the psq lock */ + /* XXX packets might get reordered if parent is OACTIVE */ + if (parent != NULL) + if_start(parent); + if (ifp != NULL) if_start(ifp); - } } /* @@ -326,7 +491,8 @@ ieee80211_node_pwrsave(struct ieee80211_ /* NB if no sta's in ps, driver should flush mc q */ vap->iv_update_ps(vap, vap->iv_ps_sta); } - pwrsave_flushq(ni); + if (ni->ni_psq.psq_len != 0) + pwrsave_flushq(ni); } } @@ -337,7 +503,6 @@ void ieee80211_sta_pwrsave(struct ieee80211vap *vap, int enable) { struct ieee80211_node *ni = vap->iv_bss; - int qlen; if (!((enable != 0) ^ ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) != 0))) return; @@ -353,12 +518,8 @@ ieee80211_sta_pwrsave(struct ieee80211va * data frame we send the ap. * XXX can we use a data frame to take us out of ps? */ - qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); - if (qlen != 0) { - IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, - "flush ps queue, %u packets queued", qlen); + if (ni->ni_psq.psq_len != 0) pwrsave_flushq(ni); - } } else { ni->ni_flags |= IEEE80211_NODE_PWR_MGT; ieee80211_send_nulldata(ieee80211_ref_node(ni)); Modified: head/sys/net80211/ieee80211_power.h ============================================================================== --- head/sys/net80211/ieee80211_power.h Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_power.h Sun Oct 26 01:04:46 2008 (r184288) @@ -28,6 +28,39 @@ #define _NET80211_IEEE80211_POWER_H_ struct ieee80211com; +struct ieee80211vap; +struct ieee80211_node; +struct mbuf; + +/* + * Power save packet queues. There are two queues, one + * for frames coming from the net80211 layer and the other + * for frames that come from the driver. Frames from the + * driver are expected to have M_ENCAP marked to indicate + * they have already been encapsulated and are treated as + * higher priority: they are sent first when flushing the + * queue on a power save state change or in response to a + * ps-poll frame. + * + * Note that frames sent from the high priority queue are + * fed directly to the driver without going through + * ieee80211_start again; drivers that send up encap'd + * frames are required to handle them when they come back. + */ +struct ieee80211_psq { + ieee80211_psq_lock_t psq_lock; + int psq_len; + int psq_maxlen; + int psq_drops; + struct ieee80211_psq_head { + struct mbuf *head; + struct mbuf *tail; + int len; + } psq_head[2]; /* 2 priorities */ +}; + +void ieee80211_psq_init(struct ieee80211_psq *, const char *); +void ieee80211_psq_cleanup(struct ieee80211_psq *); void ieee80211_power_attach(struct ieee80211com *); void ieee80211_power_detach(struct ieee80211com *); @@ -35,9 +68,10 @@ void ieee80211_power_vattach(struct ieee void ieee80211_power_vdetach(struct ieee80211vap *); void ieee80211_power_latevattach(struct ieee80211vap *); -int ieee80211_node_saveq_drain(struct ieee80211_node *); -int ieee80211_node_saveq_age(struct ieee80211_node *); -void ieee80211_pwrsave(struct ieee80211_node *, struct mbuf *); +struct mbuf *ieee80211_node_psq_dequeue(struct ieee80211_node *ni, int *qlen); +int ieee80211_node_psq_drain(struct ieee80211_node *); +int ieee80211_node_psq_age(struct ieee80211_node *); +int ieee80211_pwrsave(struct ieee80211_node *, struct mbuf *); void ieee80211_node_pwrsave(struct ieee80211_node *, int enable); void ieee80211_sta_pwrsave(struct ieee80211vap *, int enable); Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Sun Oct 26 01:01:01 2008 (r184287) +++ head/sys/net80211/ieee80211_var.h Sun Oct 26 01:04:46 2008 (r184288) @@ -47,8 +47,8 @@ #include #include #include /* for ieee80211_stats */ -#include #include +#include #include #include From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 02:22:44 2008 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 954ED1065675; Sun, 26 Oct 2008 02:22:44 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 3E38B8FC13; Sun, 26 Oct 2008 02:22:44 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m9Q2KvPd034144; Sat, 25 Oct 2008 20:20:57 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 25 Oct 2008 20:20:57 -0600 (MDT) Message-Id: <20081025.202057.74716595.imp@bsdimp.com> To: bms@FreeBSD.org From: Warner Losh In-Reply-To: <4902DE9E.2090004@FreeBSD.org> References: <200810250618.m9P6ICWl023370@svn.freebsd.org> <4902DE9E.2090004@FreeBSD.org> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, marcel@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys 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: Sun, 26 Oct 2008 02:22:44 -0000 > Thanks for bringing this code in. Hopefully it shouldn't be too hard to > add MTD-like support on top, and/or port it to other parts. What, exactly, do you mean here? The partitioning stuff, the flash erase stuff, moving all things through the /dev/mt* or something else? Warner From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 17:20:37 2008 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 AFA75106569D; Sun, 26 Oct 2008 17:20:37 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CD208FC1D; Sun, 26 Oct 2008 17:20:37 +0000 (UTC) (envelope-from lulf@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 m9QHKbCd089686; Sun, 26 Oct 2008 17:20:37 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QHKbEu089676; Sun, 26 Oct 2008 17:20:37 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200810261720.m9QHKbEu089676@svn.freebsd.org> From: Ulf Lilleengen Date: Sun, 26 Oct 2008 17:20:37 +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: r184292 - head/sys/geom/vinum 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: Sun, 26 Oct 2008 17:20:37 -0000 Author: lulf Date: Sun Oct 26 17:20:37 2008 New Revision: 184292 URL: http://svn.freebsd.org/changeset/base/184292 Log: - Import macros used in gmirror for printing gvinum debug messages and making the output more standardized. - Add a sysctl to set the verbosity of the debug messages. - While there, fixup typos and wording in the messages. Modified: head/sys/geom/vinum/geom_vinum.c head/sys/geom/vinum/geom_vinum.h head/sys/geom/vinum/geom_vinum_drive.c head/sys/geom/vinum/geom_vinum_init.c head/sys/geom/vinum/geom_vinum_plex.c head/sys/geom/vinum/geom_vinum_raid5.c head/sys/geom/vinum/geom_vinum_rm.c head/sys/geom/vinum/geom_vinum_state.c head/sys/geom/vinum/geom_vinum_subr.c head/sys/geom/vinum/geom_vinum_volume.c Modified: head/sys/geom/vinum/geom_vinum.c ============================================================================== --- head/sys/geom/vinum/geom_vinum.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum.c Sun Oct 26 17:20:37 2008 (r184292) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -42,12 +43,12 @@ __FBSDID("$FreeBSD$"); #include #include -#if 0 SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, vinum, CTLFLAG_RW, 0, "GEOM_VINUM stuff"); -SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RW, &gv_debug, 0, +u_int g_vinum_debug = 0; +TUNABLE_INT("kern.geom.vinum.debug", &g_vinum_debug); +SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RW, &g_vinum_debug, 0, "Debug level"); -#endif int gv_create(struct g_geom *, struct gctl_req *); @@ -363,7 +364,7 @@ gv_create(struct g_geom *gp, struct gctl */ pp = g_provider_by_name(d->device); if (pp == NULL) { - printf("geom_vinum: %s: drive disapeared?\n", + G_VINUM_DEBUG(0, "%s: drive disappeared?", d->device); continue; } Modified: head/sys/geom/vinum/geom_vinum.h ============================================================================== --- head/sys/geom/vinum/geom_vinum.h Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum.h Sun Oct 26 17:20:37 2008 (r184292) @@ -96,4 +96,30 @@ void gv_update_vol_size(struct gv_volume off_t gv_vol_size(struct gv_volume *); off_t gv_plex_size(struct gv_plex *); +extern u_int g_vinum_debug; + +#define G_VINUM_DEBUG(lvl, ...) do { \ + if (g_vinum_debug >= (lvl)) { \ + printf("GEOM_VINUM"); \ + if (g_vinum_debug > 0) \ + printf("[%u]", lvl); \ + printf(": "); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ +} while (0) + +#define G_VINUM_LOGREQ(lvl, bp, ...) do { \ + if (g_vinum_debug >= (lvl)) { \ + printf("GEOM_VINUM"); \ + if (g_vinum_debug > 0) \ + printf("[%u]", lvl); \ + printf(": "); \ + printf(__VA_ARGS__); \ + printf(" "); \ + g_print_bio(bp); \ + printf("\n"); \ + } \ +} while (0) + #endif /* !_GEOM_VINUM_H_ */ Modified: head/sys/geom/vinum/geom_vinum_drive.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_drive.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_drive.c Sun Oct 26 17:20:37 2008 (r184292) @@ -172,7 +172,7 @@ gv_read_header(struct g_consumer *cp, st g_free(d_hdr); return (-1); } else if (gv_legacy_header_type(d_hdr, be) == GV_LEGACY_SPARC64) { - printf("VINUM: detected legacy sparc64 header\n"); + G_VINUM_DEBUG(1, "detected legacy sparc64 header"); m_hdr->magic = GV_MAGIC; /* Legacy sparc64 on-disk header */ m_hdr->config_length = GV_GET64(be); @@ -186,7 +186,7 @@ gv_read_header(struct g_consumer *cp, st m_hdr->label.last_update.tv_usec = GV_GET64(be); m_hdr->label.drive_size = GV_GET64(be); } else if (gv_legacy_header_type(d_hdr, be) == GV_LEGACY_POWERPC) { - printf("VINUM: detected legacy PowerPC header\n"); + G_VINUM_DEBUG(1, "detected legacy PowerPC header"); m_hdr->magic = GV_MAGIC; /* legacy 32-bit big endian on-disk header */ m_hdr->config_length = GV_GET32(be); @@ -200,7 +200,7 @@ gv_read_header(struct g_consumer *cp, st m_hdr->label.last_update.tv_usec = GV_GET32(be); m_hdr->label.drive_size = GV_GET64(be); } else if (gv_legacy_header_type(d_hdr, be) == GV_LEGACY_I386) { - printf("VINUM: detected legacy i386 header\n"); + G_VINUM_DEBUG(1, "detected legacy i386 header"); m_hdr->magic = GV_MAGIC; /* legacy i386 on-disk header */ m_hdr->config_length = GV_GET32(le); @@ -214,7 +214,7 @@ gv_read_header(struct g_consumer *cp, st m_hdr->label.last_update.tv_usec = GV_GET32(le); m_hdr->label.drive_size = GV_GET64(le); } else { - printf("VINUM: detected legacy amd64 header\n"); + G_VINUM_DEBUG(1, "detected legacy amd64 header"); m_hdr->magic = GV_MAGIC; /* legacy amd64 on-disk header */ m_hdr->config_length = GV_GET64(le); @@ -354,7 +354,7 @@ gv_save_config(struct g_consumer *cp, st hdr = d->hdr; if (hdr == NULL) { - printf("GEOM_VINUM: drive %s has NULL hdr\n", d->name); + G_VINUM_DEBUG(0, "drive %s has NULL hdr", d->name); g_free(vhdr); return; } @@ -367,7 +367,7 @@ gv_save_config(struct g_consumer *cp, st error = g_access(cp2, 0, 1, 0); if (error) { - printf("GEOM_VINUM: g_access failed on drive %s, errno %d\n", + G_VINUM_DEBUG(0, "g_access failed on drive %s, errno %d", d->name, error); sbuf_delete(sb); g_free(vhdr); @@ -378,7 +378,7 @@ gv_save_config(struct g_consumer *cp, st do { error = gv_write_header(cp2, vhdr); if (error) { - printf("GEOM_VINUM: writing vhdr failed on drive %s, " + G_VINUM_DEBUG(0, "writing vhdr failed on drive %s, " "errno %d", d->name, error); break; } @@ -386,7 +386,7 @@ gv_save_config(struct g_consumer *cp, st error = g_write_data(cp2, GV_CFG_OFFSET, sbuf_data(sb), GV_CFG_LEN); if (error) { - printf("GEOM_VINUM: writing first config copy failed " + G_VINUM_DEBUG(0, "writing first config copy failed " "on drive %s, errno %d", d->name, error); break; } @@ -394,7 +394,7 @@ gv_save_config(struct g_consumer *cp, st error = g_write_data(cp2, GV_CFG_OFFSET + GV_CFG_LEN, sbuf_data(sb), GV_CFG_LEN); if (error) - printf("GEOM_VINUM: writing second config copy failed " + G_VINUM_DEBUG(0, "writing second config copy failed " "on drive %s, errno %d", d->name, error); } while (0); @@ -836,8 +836,8 @@ gv_drive_dead(void *arg, int flag) LIST_FOREACH(cp, &gp->consumer, consumer) { if (cp->nstart != cp->nend) { - printf("GEOM_VINUM: dead drive '%s' has still " - "active requests, can't detach consumer\n", + G_VINUM_DEBUG(0, "dead drive '%s' still has " + "active requests, cannot detach consumer", d->name); g_post_event(gv_drive_dead, d, M_WAITOK, d, NULL); @@ -847,7 +847,7 @@ gv_drive_dead(void *arg, int flag) g_access(cp, -cp->acr, -cp->acw, -cp->ace); } - printf("GEOM_VINUM: lost drive '%s'\n", d->name); + G_VINUM_DEBUG(1, "lost drive '%s'", d->name); d->geom = NULL; LIST_FOREACH(s, &d->subdisks, from_drive) { s->provider = NULL; Modified: head/sys/geom/vinum/geom_vinum_init.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_init.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_init.c Sun Oct 26 17:20:37 2008 (r184292) @@ -420,15 +420,15 @@ gv_rebuild_td(void *arg) error = g_access(cp, 1, 1, 0); if (error) { g_topology_unlock(); - printf("GEOM_VINUM: rebuild of %s failed to access consumer: " - "%d\n", p->name, error); + G_VINUM_DEBUG(0, "rebuild of %s failed to access consumer: " + "%d", p->name, error); kproc_exit(error); } g_topology_unlock(); buf = g_malloc(sync->syncsize, M_WAITOK); - printf("GEOM_VINUM: rebuild of %s started\n", p->name); + G_VINUM_DEBUG(1, "rebuild of %s started", p->name); i = 0; for (i = 0; i < p->size; i += (p->stripesize * (p->sdcount - 1))) { /* @@ -437,8 +437,8 @@ gv_rebuild_td(void *arg) */ bp = g_new_bio(); if (bp == NULL) { - printf("GEOM_VINUM: rebuild of %s failed creating bio: " - "out of memory\n", p->name); + G_VINUM_DEBUG(0, "rebuild of %s failed creating bio: " + "out of memory", p->name); break; } bp->bio_cmd = BIO_WRITE; @@ -454,8 +454,8 @@ gv_rebuild_td(void *arg) /* ... and wait for the result. */ error = biowait(bp, "gwrite"); if (error) { - printf("GEOM_VINUM: rebuild of %s failed at offset %jd " - "errno: %d\n", p->name, i, error); + G_VINUM_DEBUG(0, "rebuild of %s failed at offset %jd " + "errno: %d", p->name, i, error); break; } g_destroy_bio(bp); @@ -477,7 +477,7 @@ gv_rebuild_td(void *arg) /* Successful initialization. */ if (!error) - printf("GEOM_VINUM: rebuild of %s finished\n", p->name); + G_VINUM_DEBUG(1, "rebuild of %s finished", p->name); g_free(sync); kproc_exit(error); @@ -508,8 +508,8 @@ gv_sync_td(void *arg) error = g_access(from, 1, 0, 0); if (error) { g_topology_unlock(); - printf("GEOM_VINUM: sync from '%s' failed to access " - "consumer: %d\n", sync->from->name, error); + G_VINUM_DEBUG(0, "sync from '%s' failed to access " + "consumer: %d", sync->from->name, error); g_free(sync); kproc_exit(error); } @@ -517,21 +517,21 @@ gv_sync_td(void *arg) if (error) { g_access(from, -1, 0, 0); g_topology_unlock(); - printf("GEOM_VINUM: sync to '%s' failed to access " - "consumer: %d\n", p->name, error); + G_VINUM_DEBUG(0, "sync to '%s' failed to access " + "consumer: %d", p->name, error); g_free(sync); kproc_exit(error); } g_topology_unlock(); - printf("GEOM_VINUM: plex sync %s -> %s started\n", sync->from->name, + G_VINUM_DEBUG(1, "plex sync %s -> %s started", sync->from->name, sync->to->name); for (i = 0; i < p->size; i+= sync->syncsize) { /* Read some bits from the good plex. */ buf = g_read_data(from, i, sync->syncsize, &error); if (buf == NULL) { - printf("GEOM_VINUM: sync read from '%s' failed at " - "offset %jd; errno: %d\n", sync->from->name, i, + G_VINUM_DEBUG(0, "sync read from '%s' failed at " + "offset %jd; errno: %d", sync->from->name, i, error); break; } @@ -544,8 +544,8 @@ gv_sync_td(void *arg) */ bp = g_new_bio(); if (bp == NULL) { - printf("GEOM_VINUM: sync write to '%s' failed at " - "offset %jd; out of memory\n", p->name, i); + G_VINUM_DEBUG(0, "sync write to '%s' failed at " + "offset %jd; out of memory", p->name, i); g_free(buf); break; } @@ -569,7 +569,7 @@ gv_sync_td(void *arg) g_destroy_bio(bp); g_free(buf); if (error) { - printf("GEOM_VINUM: sync write to '%s' failed at " + G_VINUM_DEBUG(0, "sync write to '%s' failed at " "offset %jd; errno: %d\n", p->name, i, error); break; } @@ -586,7 +586,7 @@ gv_sync_td(void *arg) /* Successful initialization. */ if (!error) - printf("GEOM_VINUM: plex sync %s -> %s finished\n", + G_VINUM_DEBUG(1, "plex sync %s -> %s finished", sync->from->name, sync->to->name); p->flags &= ~GV_PLEX_SYNCING; @@ -630,8 +630,8 @@ gv_init_td(void *arg) if (error) { s->init_error = error; g_topology_unlock(); - printf("GEOM_VINUM: subdisk '%s' init: failed to access " - "consumer; error: %d\n", s->name, error); + G_VINUM_DEBUG(0, "subdisk '%s' init: failed to access " + "consumer; error: %d", s->name, error); kproc_exit(error); } g_topology_unlock(); @@ -639,8 +639,8 @@ gv_init_td(void *arg) for (i = start; i < offset + length; i += init_size) { error = g_write_data(cp, i, buf, init_size); if (error) { - printf("GEOM_VINUM: subdisk '%s' init: write failed" - " at offset %jd (drive offset %jd); error %d\n", + G_VINUM_DEBUG(0, "subdisk '%s' init: write failed" + " at offset %jd (drive offset %jd); error %d", s->name, (intmax_t)s->initialized, (intmax_t)i, error); break; @@ -664,7 +664,7 @@ gv_init_td(void *arg) gv_set_sd_state(s, GV_SD_UP, GV_SETSTATE_CONFIG); g_topology_unlock(); s->initialized = 0; - printf("GEOM_VINUM: subdisk '%s' init: finished successfully\n", + G_VINUM_DEBUG(1, "subdisk '%s' init: finished successfully", s->name); } kproc_exit(error); Modified: head/sys/geom/vinum/geom_vinum_plex.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_plex.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_plex.c Sun Oct 26 17:20:37 2008 (r184292) @@ -189,7 +189,7 @@ gv_plexbuffer(struct gv_plex *p, struct if (!(bp->bio_cflags & GV_BIO_SYNCREQ)) return (ENXIO); - printf("GEOM_VINUM: sd %s is initializing\n", s->name); + G_VINUM_DEBUG(1, "sd %s is initializing", s->name); gv_set_sd_state(s, GV_SD_INITIALIZING, GV_SETSTATE_FORCE); break; @@ -558,9 +558,7 @@ gv_plex_normal_request(struct gv_plex *p * clean up a lot. */ if (err) { - printf("GEOM_VINUM: plex request failed for "); - g_print_bio(bp); - printf("\n"); + G_VINUM_LOGREQ(0, bp, "plex request failed."); TAILQ_FOREACH_SAFE(bq, &wp->bits, queue, bq2) { TAILQ_REMOVE(&wp->bits, bq, queue); g_free(bq); @@ -620,9 +618,7 @@ gv_plex_normal_request(struct gv_plex *p /* Building the sub-request failed. */ if (err) { - printf("GEOM_VINUM: plex request failed for "); - g_print_bio(bp); - printf("\n"); + G_VINUM_LOGREQ(0, bp, "plex request failed."); cbp = bp->bio_driver1; while (cbp != NULL) { pbp = cbp->bio_caller1; @@ -719,7 +715,7 @@ gv_plex_taste(struct g_class *mp, struct /* Now find the correct plex where this subdisk belongs to. */ p = gv_find_plex(sc, s->plex); if (p == NULL) { - printf("gv_plex_taste: NULL p for '%s'\n", s->name); + G_VINUM_DEBUG(0, "%s: NULL p for '%s'", __func__, s->name); return (NULL); } @@ -740,7 +736,7 @@ gv_plex_taste(struct g_class *mp, struct cp = g_new_consumer(gp); error = g_attach(cp, pp); if (error) { - printf("geom_vinum: couldn't attach consumer to %s\n", + G_VINUM_DEBUG(0, "unable to attach consumer to %s", pp->name); g_destroy_consumer(cp); return (NULL); @@ -749,8 +745,8 @@ gv_plex_taste(struct g_class *mp, struct if ((cp2 != NULL) && (cp2->acr || cp2->acw || cp2->ace)) { error = g_access(cp, cp2->acr, cp2->acw, cp2->ace); if (error) { - printf("geom_vinum: couldn't set access counts" - " for consumer on %s\n", pp->name); + G_VINUM_DEBUG(0, "unable to set access counts" + " for consumer on %s", pp->name); g_detach(cp); g_destroy_consumer(cp); return (NULL); Modified: head/sys/geom/vinum/geom_vinum_raid5.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_raid5.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_raid5.c Sun Oct 26 17:20:37 2008 (r184292) @@ -208,7 +208,7 @@ gv_rebuild_raid5(struct gv_plex *p, stru if (!(bp->bio_cflags & GV_BIO_REBUILD)) return (ENXIO); - printf("GEOM_VINUM: sd %s is reviving\n", broken->name); + G_VINUM_DEBUG(1, "sd %s is reviving", broken->name); gv_set_sd_state(broken, GV_SD_REVIVING, GV_SETSTATE_FORCE); break; Modified: head/sys/geom/vinum/geom_vinum_rm.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_rm.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_rm.c Sun Oct 26 17:20:37 2008 (r184292) @@ -351,8 +351,8 @@ gv_rm_drive(struct gv_softc *sc, struct cp = LIST_FIRST(&gp->consumer); err = g_access(cp, 0, 1, 0); if (err) { - printf("GEOM_VINUM: gv_rm_drive: couldn't access '%s', errno: " - "%d\n", cp->provider->name, err); + G_VINUM_DEBUG(0, "%s: unable to access '%s', errno: " + "%d", __func__, cp->provider->name, err); return (err); } @@ -361,8 +361,8 @@ gv_rm_drive(struct gv_softc *sc, struct g_topology_unlock(); err = gv_write_header(cp, d->hdr); if (err) { - printf("GEOM_VINUM: gv_rm_drive: couldn't write header to '%s'" - ", errno: %d\n", cp->provider->name, err); + G_VINUM_DEBUG(0, "%s: unable to write header to '%s'" + ", errno: %d", __func__, cp->provider->name, err); d->hdr->magic = GV_MAGIC; } g_topology_lock(); Modified: head/sys/geom/vinum/geom_vinum_state.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_state.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_state.c Sun Oct 26 17:20:37 2008 (r184292) @@ -280,8 +280,8 @@ gv_update_sd_state(struct gv_sd *s) s->state = GV_SD_UP; if (s->state != oldstate) - printf("GEOM_VINUM: subdisk %s state change: %s -> %s\n", - s->name, gv_sdstate(oldstate), gv_sdstate(s->state)); + G_VINUM_DEBUG(1, "subdisk %s state change: %s -> %s", s->name, + gv_sdstate(oldstate), gv_sdstate(s->state)); /* Update the plex, if we have one. */ if (s->plex_sc != NULL) @@ -324,7 +324,7 @@ gv_update_plex_state(struct gv_plex *p) p->state = GV_PLEX_DOWN; if (p->state != oldstate) - printf("GEOM_VINUM: plex %s state change: %s -> %s\n", p->name, + G_VINUM_DEBUG(1, "plex %s state change: %s -> %s", p->name, gv_plexstate(oldstate), gv_plexstate(p->state)); /* Update our volume, if we have one. */ Modified: head/sys/geom/vinum/geom_vinum_subr.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_subr.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_subr.c Sun Oct 26 17:20:37 2008 (r184292) @@ -113,7 +113,7 @@ gv_parse_config(struct gv_softc *sc, u_c if (!strcmp(token[0], "volume")) { v = gv_new_volume(tokens, token); if (v == NULL) { - printf("geom_vinum: failed volume\n"); + G_VINUM_DEBUG(0, "failed volume"); break; } @@ -132,7 +132,7 @@ gv_parse_config(struct gv_softc *sc, u_c } else if (!strcmp(token[0], "plex")) { p = gv_new_plex(tokens, token); if (p == NULL) { - printf("geom_vinum: failed plex\n"); + G_VINUM_DEBUG(0, "failed plex"); break; } @@ -152,7 +152,7 @@ gv_parse_config(struct gv_softc *sc, u_c s = gv_new_sd(tokens, token); if (s == NULL) { - printf("geom_vinum: failed subdisk\n"); + G_VINUM_DEBUG(0, "failed subdisk"); break; } @@ -265,8 +265,8 @@ gv_sd_to_plex(struct gv_plex *p, struct /* Check correct size of this subdisk. */ s2 = LIST_FIRST(&p->subdisks); if (s2 != NULL && gv_is_striped(p) && (s2->size != s->size)) { - printf("GEOM_VINUM: need equal sized subdisks for " - "this plex organisation - %s (%jd) <-> %s (%jd)\n", + G_VINUM_DEBUG(0, "need equal sized subdisks for " + "this plex organisation - %s (%jd) <-> %s (%jd)", s2->name, s2->size, s->name, s->size); return (-1); } @@ -439,8 +439,8 @@ gv_update_plex_config(struct gv_plex *p) s = LIST_FIRST(&p->subdisks); LIST_FOREACH(s2, &p->subdisks, in_plex) { if (s->size != s2->size) { - printf("geom_vinum: subdisk size mismatch " - "%s (%jd) <> %s (%jd)\n", s->name, s->size, + G_VINUM_DEBUG(0, "subdisk size mismatch %s" + "(%jd) <> %s (%jd)", s->name, s->size, s2->name, s2->size); state = GV_PLEX_DOWN; } @@ -450,10 +450,9 @@ gv_update_plex_config(struct gv_plex *p) LIST_FOREACH(s, &p->subdisks, in_plex) { remainder = s->size % p->stripesize; if (remainder) { - printf("gvinum: size of sd %s is not a " + G_VINUM_DEBUG(1, "size of sd %s is not a " "multiple of plex stripesize, taking off " - "%jd bytes\n", s->name, - (intmax_t)remainder); + "%jd bytes", s->name, (intmax_t)remainder); gv_adjust_freespace(s, remainder); } } @@ -544,7 +543,7 @@ gv_sd_to_drive(struct gv_softc *sc, stru /* No good slot found? */ if (s->size == -1) { - snprintf(errstr, errlen, "couldn't autosize '%s' on " + snprintf(errstr, errlen, "could not autosize '%s' on " "'%s'", s->name, d->name); return (-1); } Modified: head/sys/geom/vinum/geom_vinum_volume.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_volume.c Sun Oct 26 17:03:51 2008 (r184291) +++ head/sys/geom/vinum/geom_vinum_volume.c Sun Oct 26 17:20:37 2008 (r184292) @@ -385,8 +385,8 @@ gv_volume_taste(struct g_class *mp, stru if ((ocp != NULL) && (ocp->acr > 0 || ocp->acw > 0 || ocp->ace > 0)) { error = g_access(cp, ocp->acr, ocp->acw, ocp->ace); if (error) { - printf("GEOM_VINUM: failed g_access %s -> %s; " - "errno %d\n", v->name, p->name, error); + G_VINUM_DEBUG(0, "failed g_access %s -> %s; " + "errno %d", v->name, p->name, error); g_detach(cp); g_destroy_consumer(cp); if (first) From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 18:58:04 2008 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 B4817106566B; Sun, 26 Oct 2008 18:58:04 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1F888FC19; Sun, 26 Oct 2008 18:58:04 +0000 (UTC) (envelope-from sobomax@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 m9QIw4Lw091895; Sun, 26 Oct 2008 18:58:04 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QIw4YV091893; Sun, 26 Oct 2008 18:58:04 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810261858.m9QIw4YV091893@svn.freebsd.org> From: Maxim Sobolev Date: Sun, 26 Oct 2008 18:58:04 +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: r184293 - in head/sys: amd64/amd64 i386/i386 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: Sun, 26 Oct 2008 18:58:04 -0000 Author: sobomax Date: Sun Oct 26 18:58:04 2008 New Revision: 184293 URL: http://svn.freebsd.org/changeset/base/184293 Log: Fix division by zero panic if kern.hz less than 32. MFC after: 1 day Modified: head/sys/amd64/amd64/local_apic.c head/sys/i386/i386/local_apic.c Modified: head/sys/amd64/amd64/local_apic.c ============================================================================== --- head/sys/amd64/amd64/local_apic.c Sun Oct 26 17:20:37 2008 (r184292) +++ head/sys/amd64/amd64/local_apic.c Sun Oct 26 18:58:04 2008 (r184293) @@ -401,7 +401,11 @@ lapic_setup_clock(void) lapic_timer_hz = hz * 2; else lapic_timer_hz = hz * 4; - stathz = lapic_timer_hz / (lapic_timer_hz / 128); + if (lapic_timer_hz < 128) { + stathz = 128; + } else { + stathz = lapic_timer_hz / (lapic_timer_hz / 128); + } profhz = lapic_timer_hz; lapic_timer_period = value / lapic_timer_hz; Modified: head/sys/i386/i386/local_apic.c ============================================================================== --- head/sys/i386/i386/local_apic.c Sun Oct 26 17:20:37 2008 (r184292) +++ head/sys/i386/i386/local_apic.c Sun Oct 26 18:58:04 2008 (r184293) @@ -403,7 +403,11 @@ lapic_setup_clock(void) lapic_timer_hz = hz * 2; else lapic_timer_hz = hz * 4; - stathz = lapic_timer_hz / (lapic_timer_hz / 128); + if (lapic_timer_hz < 128) { + stathz = 128; + } else { + stathz = lapic_timer_hz / (lapic_timer_hz / 128); + } profhz = lapic_timer_hz; lapic_timer_period = value / lapic_timer_hz; From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 19:17:25 2008 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 915E41065675; Sun, 26 Oct 2008 19:17:25 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7E92B8FC16; Sun, 26 Oct 2008 19:17:25 +0000 (UTC) (envelope-from bz@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 m9QJHPY5092418; Sun, 26 Oct 2008 19:17:25 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QJHPIE092417; Sun, 26 Oct 2008 19:17:25 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200810261917.m9QJHPIE092417@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 26 Oct 2008 19:17:25 +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: r184295 - head/sys/netinet 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: Sun, 26 Oct 2008 19:17:25 -0000 Author: bz Date: Sun Oct 26 19:17:25 2008 New Revision: 184295 URL: http://svn.freebsd.org/changeset/base/184295 Log: Style changes only: - Consistently add parentheses to return statements. - Use NULL instead of 0 when comparing pointers, also avoiding unnecessary casts. - Do not use pointers as booleans. Reviewed by: rwatson (earlier version) MFC after: 2 months Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Sun Oct 26 19:14:50 2008 (r184294) +++ head/sys/netinet/in.c Sun Oct 26 19:17:25 2008 (r184295) @@ -115,9 +115,9 @@ in_localip(struct in_addr in) LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash) { if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr) - return 1; + return (1); } - return 0; + return (0); } /* @@ -177,7 +177,7 @@ in_mask2len(mask) break; } } - return x * 8 + y; + return (x * 8 + y); } static void @@ -205,7 +205,7 @@ in_control(struct socket *so, u_long cmd { INIT_VNET_INET(curvnet); /* both so and ifp can be NULL here! */ register struct ifreq *ifr = (struct ifreq *)data; - register struct in_ifaddr *ia = 0, *iap; + register struct in_ifaddr *ia, *iap; register struct ifaddr *ifa; struct in_addr allhosts_addr; struct in_addr dst; @@ -215,6 +215,7 @@ in_control(struct socket *so, u_long cmd int error, hostIsNew, iaIsNew, maskIsNew, s; int iaIsFirst; + ia = NULL; iaIsFirst = 0; iaIsNew = 0; allhosts_addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP); @@ -226,8 +227,8 @@ in_control(struct socket *so, u_long cmd if (error) return (error); } - if (!ifp) - return EINVAL; + if (ifp == NULL) + return (EINVAL); return in_lifaddr_ioctl(so, cmd, data, ifp, td); case SIOCDLIFADDR: @@ -236,13 +237,13 @@ in_control(struct socket *so, u_long cmd if (error) return (error); } - if (!ifp) - return EINVAL; + if (ifp == NULL) + return (EINVAL); return in_lifaddr_ioctl(so, cmd, data, ifp, td); case SIOCGLIFADDR: - if (!ifp) - return EINVAL; + if (ifp == NULL) + return (EINVAL); return in_lifaddr_ioctl(so, cmd, data, ifp, td); } @@ -252,7 +253,7 @@ in_control(struct socket *so, u_long cmd * If an alias address was specified, find that one instead of * the first one on the interface, if possible. */ - if (ifp) { + if (ifp != NULL) { dst = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr; LIST_FOREACH(iap, INADDR_HASH(dst.s_addr), ia_hash) if (iap->ia_ifp == ifp && @@ -276,7 +277,7 @@ in_control(struct socket *so, u_long cmd case SIOCAIFADDR: case SIOCDIFADDR: - if (ifp == 0) + if (ifp == NULL) return (EADDRNOTAVAIL); if (ifra->ifra_addr.sin_family == AF_INET) { for (oia = ia; ia; ia = TAILQ_NEXT(ia, ia_link)) { @@ -289,10 +290,10 @@ in_control(struct socket *so, u_long cmd && (cmd == SIOCAIFADDR) && (ifra->ifra_dstaddr.sin_addr.s_addr == INADDR_ANY)) { - return EDESTADDRREQ; + return (EDESTADDRREQ); } } - if (cmd == SIOCDIFADDR && ia == 0) + if (cmd == SIOCDIFADDR && ia == NULL) return (EADDRNOTAVAIL); /* FALLTHROUGH */ case SIOCSIFADDR: @@ -305,12 +306,12 @@ in_control(struct socket *so, u_long cmd return (error); } - if (ifp == 0) + if (ifp == NULL) return (EADDRNOTAVAIL); - if (ia == (struct in_ifaddr *)0) { + if (ia == NULL) { ia = (struct in_ifaddr *) malloc(sizeof *ia, M_IFADDR, M_WAITOK | M_ZERO); - if (ia == (struct in_ifaddr *)NULL) + if (ia == NULL) return (ENOBUFS); /* * Protect from ipintr() traversing address list @@ -351,7 +352,7 @@ in_control(struct socket *so, u_long cmd case SIOCGIFNETMASK: case SIOCGIFDSTADDR: case SIOCGIFBRDADDR: - if (ia == (struct in_ifaddr *)0) + if (ia == NULL) return (EADDRNOTAVAIL); break; } @@ -382,7 +383,7 @@ in_control(struct socket *so, u_long cmd return (EINVAL); oldaddr = ia->ia_dstaddr; ia->ia_dstaddr = *(struct sockaddr_in *)&ifr->ifr_dstaddr; - if (ifp->if_ioctl) { + if (ifp->if_ioctl != NULL) { IFF_LOCKGIANT(ifp); error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, (caddr_t)ia); @@ -483,7 +484,7 @@ in_control(struct socket *so, u_long cmd break; default: - if (ifp == 0 || ifp->if_ioctl == 0) + if (ifp == NULL || ifp->if_ioctl == NULL) return (EOPNOTSUPP); IFF_LOCKGIANT(ifp); error = (*ifp->if_ioctl)(ifp, cmd, data); @@ -549,7 +550,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo struct ifaddr *ifa; /* sanity checks */ - if (!data || !ifp) { + if (data == NULL || ifp == NULL) { panic("invalid argument to in_lifaddr_ioctl"); /*NOTRECHED*/ } @@ -564,22 +565,22 @@ in_lifaddr_ioctl(struct socket *so, u_lo case SIOCDLIFADDR: /* address must be specified on ADD and DELETE */ if (iflr->addr.ss_family != AF_INET) - return EINVAL; + return (EINVAL); if (iflr->addr.ss_len != sizeof(struct sockaddr_in)) - return EINVAL; + return (EINVAL); /* XXX need improvement */ if (iflr->dstaddr.ss_family && iflr->dstaddr.ss_family != AF_INET) - return EINVAL; + return (EINVAL); if (iflr->dstaddr.ss_family && iflr->dstaddr.ss_len != sizeof(struct sockaddr_in)) - return EINVAL; + return (EINVAL); break; default: /*shouldn't happen*/ - return EOPNOTSUPP; + return (EOPNOTSUPP); } if (sizeof(struct in_addr) * 8 < iflr->prefixlen) - return EINVAL; + return (EINVAL); switch (cmd) { case SIOCALIFADDR: @@ -587,7 +588,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo struct in_aliasreq ifra; if (iflr->flags & IFLR_PREFIX) - return EINVAL; + return (EINVAL); /* copy args to in_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */ bzero(&ifra, sizeof(ifra)); @@ -605,7 +606,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo ifra.ifra_mask.sin_len = sizeof(struct sockaddr_in); in_len2mask(&ifra.ifra_mask.sin_addr, iflr->prefixlen); - return in_control(so, SIOCAIFADDR, (caddr_t)&ifra, ifp, td); + return (in_control(so, SIOCAIFADDR, (caddr_t)&ifra, ifp, td)); } case SIOCGLIFADDR: case SIOCDLIFADDR: @@ -626,7 +627,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo /* if you set extra bits, that's wrong */ if (match.s_addr != sin->sin_addr.s_addr) - return EINVAL; + return (EINVAL); } else { /* on getting an address, take the 1st match */ @@ -648,8 +649,8 @@ in_lifaddr_ioctl(struct socket *so, u_lo if (candidate.s_addr == match.s_addr) break; } - if (!ifa) - return EADDRNOTAVAIL; + if (ifa == NULL) + return (EADDRNOTAVAIL); ia = (struct in_ifaddr *)ifa; if (cmd == SIOCGLIFADDR) { @@ -667,7 +668,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo iflr->flags = 0; /*XXX*/ - return 0; + return (0); } else { struct in_aliasreq ifra; @@ -685,13 +686,13 @@ in_lifaddr_ioctl(struct socket *so, u_lo bcopy(&ia->ia_sockmask, &ifra.ifra_dstaddr, ia->ia_sockmask.sin_len); - return in_control(so, SIOCDIFADDR, (caddr_t)&ifra, - ifp, td); + return (in_control(so, SIOCDIFADDR, (caddr_t)&ifra, + ifp, td)); } } } - return EOPNOTSUPP; /*just for safety*/ + return (EOPNOTSUPP); /*just for safety*/ } /* @@ -729,7 +730,7 @@ in_ifinit(struct ifnet *ifp, struct in_i * if this is its first address, * and to validate the address if necessary. */ - if (ifp->if_ioctl) { + if (ifp->if_ioctl != NULL) { IFF_LOCKGIANT(ifp); error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); IFF_UNLOCKGIANT(ifp); @@ -865,7 +866,7 @@ in_addprefix(struct in_ifaddr *target, i error = rtinit(&target->ia_ifa, (int)RTM_ADD, flags); if (!error) target->ia_flags |= IFA_ROUTE; - return error; + return (error); } /* @@ -882,7 +883,7 @@ in_scrubprefix(struct in_ifaddr *target) int error; if ((target->ia_flags & IFA_ROUTE) == 0) - return 0; + return (0); if (rtinitflags(target)) prefix = target->ia_dstaddr.sin_addr; @@ -923,7 +924,7 @@ in_scrubprefix(struct in_ifaddr *target) rtinitflags(ia) | RTF_UP); if (error == 0) ia->ia_flags |= IFA_ROUTE; - return error; + return (error); } } @@ -932,7 +933,7 @@ in_scrubprefix(struct in_ifaddr *target) */ rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target)); target->ia_flags &= ~IFA_ROUTE; - return 0; + return (0); } #undef rtinitflags @@ -948,9 +949,9 @@ in_broadcast(struct in_addr in, struct i if (in.s_addr == INADDR_BROADCAST || in.s_addr == INADDR_ANY) - return 1; + return (1); if ((ifp->if_flags & IFF_BROADCAST) == 0) - return 0; + return (0); t = ntohl(in.s_addr); /* * Look through the list of addresses for a match @@ -971,7 +972,7 @@ in_broadcast(struct in_addr in, struct i * address. */ ia->ia_subnetmask != (u_long)0xffffffff) - return 1; + return (1); return (0); #undef ia } From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 19:33:22 2008 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 E3926106567A; Sun, 26 Oct 2008 19:33:22 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D111F8FC1D; Sun, 26 Oct 2008 19:33:22 +0000 (UTC) (envelope-from rwatson@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 m9QJXMFQ093050; Sun, 26 Oct 2008 19:33:22 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QJXMUW093047; Sun, 26 Oct 2008 19:33:22 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810261933.m9QJXMUW093047@svn.freebsd.org> From: Robert Watson Date: Sun, 26 Oct 2008 19:33:22 +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: r184298 - head/sys/netinet 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: Sun, 26 Oct 2008 19:33:23 -0000 Author: rwatson Date: Sun Oct 26 19:33:22 2008 New Revision: 184298 URL: http://svn.freebsd.org/changeset/base/184298 Log: Remove endearing but syntactically unnecessary "return;" statements directly before the final closeing brackets of some TCP functions. MFC after: 3 days Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_sack.c head/sys/netinet/tcp_syncache.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Sun Oct 26 19:28:04 2008 (r184297) +++ head/sys/netinet/tcp_input.c Sun Oct 26 19:33:22 2008 (r184298) @@ -925,7 +925,6 @@ drop: free(s, M_TCPLOG); if (m != NULL) m_freem(m); - return; } static void @@ -2529,7 +2528,6 @@ drop: if (headlocked) INP_INFO_WUNLOCK(&V_tcbinfo); m_freem(m); - return; } /* @@ -2588,7 +2586,6 @@ tcp_dropwithreset(struct mbuf *m, struct return; drop: m_freem(m); - return; } /* Modified: head/sys/netinet/tcp_sack.c ============================================================================== --- head/sys/netinet/tcp_sack.c Sun Oct 26 19:28:04 2008 (r184297) +++ head/sys/netinet/tcp_sack.c Sun Oct 26 19:33:22 2008 (r184298) @@ -680,5 +680,4 @@ tcp_sack_adjust(struct tcpcb *tp) if (SEQ_LT(tp->snd_nxt, cur->end)) return; tp->snd_nxt = tp->snd_fack; - return; } Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Sun Oct 26 19:28:04 2008 (r184297) +++ head/sys/netinet/tcp_syncache.c Sun Oct 26 19:33:22 2008 (r184298) @@ -1243,7 +1243,6 @@ done: *lsop = NULL; m_freem(m); } - return; } static int @@ -1576,7 +1575,6 @@ syncookie_generate(struct syncache_head } V_tcpstat.tcps_sc_sendcookie++; - return; } static struct syncache * From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 19:37:39 2008 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 3B3D41065675; Sun, 26 Oct 2008 19:37:39 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26A498FC08; Sun, 26 Oct 2008 19:37:39 +0000 (UTC) (envelope-from nwhitehorn@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 m9QJbd5p093209; Sun, 26 Oct 2008 19:37:39 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QJbc2O093202; Sun, 26 Oct 2008 19:37:38 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200810261937.m9QJbc2O093202@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 26 Oct 2008 19:37:38 +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: r184299 - in head/sys: conf dev/adb powerpc/conf powerpc/powermac 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: Sun, 26 Oct 2008 19:37:39 -0000 Author: nwhitehorn Date: Sun Oct 26 19:37:38 2008 New Revision: 184299 URL: http://svn.freebsd.org/changeset/base/184299 Log: Add ADB support. This provides support for the external ADB bus on the PowerMac G3 as well as the internal ADB keyboard and mice in PowerBooks and iBooks. This also brings in Mac GPIO support, for which we should eventually have a better interface. Obtained from: NetBSD (CUDA and PMU drivers) Added: head/sys/dev/adb/ head/sys/dev/adb/adb.h (contents, props changed) head/sys/dev/adb/adb_bus.c (contents, props changed) head/sys/dev/adb/adb_hb_if.m (contents, props changed) head/sys/dev/adb/adb_if.m (contents, props changed) head/sys/dev/adb/adb_kbd.c (contents, props changed) head/sys/dev/adb/adb_mouse.c (contents, props changed) head/sys/dev/adb/adbvar.h (contents, props changed) head/sys/powerpc/powermac/cuda.c (contents, props changed) head/sys/powerpc/powermac/cudavar.h (contents, props changed) head/sys/powerpc/powermac/macgpio.c (contents, props changed) head/sys/powerpc/powermac/macgpiovar.h (contents, props changed) head/sys/powerpc/powermac/pmu.c (contents, props changed) head/sys/powerpc/powermac/pmuvar.h (contents, props changed) head/sys/powerpc/powermac/viareg.h (contents, props changed) Modified: head/sys/conf/files.powerpc head/sys/powerpc/conf/GENERIC head/sys/powerpc/powermac/macio.c Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Sun Oct 26 19:33:22 2008 (r184298) +++ head/sys/conf/files.powerpc Sun Oct 26 19:37:38 2008 (r184299) @@ -28,6 +28,11 @@ opt_ah.h optional ath_hal \ crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/bm/if_bm.c optional bm powermac +dev/adb/adb_bus.c optional adb +dev/adb/adb_kbd.c optional adb +dev/adb/adb_mouse.c optional adb +dev/adb/adb_hb_if.m optional adb +dev/adb/adb_if.m optional adb dev/cfi/cfi_bus_lbc.c optional cfi dev/fb/fb.c optional sc dev/hwpmc/hwpmc_powerpc.c optional hwpmc @@ -119,6 +124,9 @@ powerpc/powermac/macio.c optional powerm powerpc/powermac/openpic_macio.c optional powermac pci powerpc/powermac/pswitch.c optional powermac pswitch powerpc/powermac/uninorth.c optional powermac pci +powerpc/powermac/cuda.c optional powermac cuda +powerpc/powermac/pmu.c optional powermac pmu +powerpc/powermac/macgpio.c optional powermac pci powerpc/powerpc/atomic.S standard powerpc/powerpc/autoconf.c standard powerpc/powerpc/bcopy.c standard Added: head/sys/dev/adb/adb.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/adb/adb.h Sun Oct 26 19:37:38 2008 (r184299) @@ -0,0 +1,78 @@ +/*- + * Copyright (C) 2008 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _POWERPC_ADB_H_ +#define _POWERPC_ADB_H_ + +#include "adb_hb_if.h" +#include "adb_if.h" + +enum { + ADB_COMMAND_FLUSH = 0, + ADB_COMMAND_LISTEN = 2, + ADB_COMMAND_TALK = 3, +}; + +enum { + ADB_DEVICE_DONGLE = 0x01, + ADB_DEVICE_KEYBOARD = 0x02, + ADB_DEVICE_MOUSE = 0x03, + ADB_DEVICE_TABLET = 0x04, + ADB_DEVICE_MODEM = 0x05, + + ADB_DEVICE_MISC = 0x07 +}; + +struct adb_devinfo { + uint8_t address; + uint8_t default_address; + uint8_t handler_id; + + uint16_t register3; +}; + +/* Pass packets down through the bus manager */ +u_int adb_send_packet(device_t dev, u_char command, u_char reg, int len, + u_char *data); +u_int adb_set_autopoll(device_t dev, u_char enable); + +/* Pass packets up from the interface */ +u_int adb_receive_raw_packet(device_t dev, u_char status, u_char command, + int len, u_char *data); + +uint8_t adb_get_device_type(device_t dev); +uint8_t adb_get_device_handler(device_t dev); +uint8_t adb_set_device_handler(device_t dev, uint8_t newhandler); + +uint8_t adb_read_register(device_t dev, u_char reg, size_t *len, void *data); + +/* Bits for implementing ADB host bus adapters */ +extern devclass_t adb_devclass; +extern driver_t adb_driver; + +#endif + Added: head/sys/dev/adb/adb_bus.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/adb/adb_bus.c Sun Oct 26 19:37:38 2008 (r184299) @@ -0,0 +1,384 @@ +/*- + * Copyright (C) 2008 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "adb.h" +#include "adbvar.h" + +static int adb_bus_probe(device_t dev); +static int adb_bus_attach(device_t dev); +static int adb_bus_detach(device_t dev); +static void adb_probe_nomatch(device_t dev, device_t child); +static int adb_print_child(device_t dev, device_t child); + +static int adb_send_raw_packet_sync(device_t dev, uint8_t to, uint8_t command, uint8_t reg, int len, u_char *data); + +static char *adb_device_string[] = { + "HOST", "dongle", "keyboard", "mouse", "tablet", "modem", "RESERVED", "misc" +}; + +static device_method_t adb_bus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, adb_bus_probe), + DEVMETHOD(device_attach, adb_bus_attach), + DEVMETHOD(device_detach, adb_bus_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus Interface */ + DEVMETHOD(bus_probe_nomatch, adb_probe_nomatch), + DEVMETHOD(bus_print_child, adb_print_child), + + { 0, 0 }, +}; + +driver_t adb_driver = { + "adb", + adb_bus_methods, + sizeof(struct adb_softc), +}; + +devclass_t adb_devclass; + +static int +adb_bus_probe(device_t dev) +{ + device_set_desc(dev, "Apple Desktop Bus"); + return (0); +} + +static int +adb_bus_attach(device_t dev) +{ + struct adb_softc *sc = device_get_softc(dev); + uint8_t i, next_free; + uint16_t r3; + + sc->sc_dev = dev; + sc->parent = device_get_parent(dev); + + sc->packet_reply = 0; + sc->autopoll_mask = 0; + + mtx_init(&sc->sc_sync_mtx,"adbsyn",NULL,MTX_DEF | MTX_RECURSE); + + /* Initialize devinfo */ + for (i = 0; i < 16; i++) { + sc->devinfo[i].address = i; + sc->devinfo[i].default_address = 0; + } + + /* Reset ADB bus */ + adb_send_raw_packet_sync(dev,0,ADB_COMMAND_BUS_RESET,0,0,NULL); + DELAY(1500); + + /* Enumerate bus */ + next_free = 8; + + for (i = 1; i < 7; i++) { + int8_t first_relocated = -1; + int reply = 0; + + do { + reply = adb_send_raw_packet_sync(dev,i, + ADB_COMMAND_TALK,3,0,NULL); + + if (reply) { + /* If we got a response, relocate to next_free */ + r3 = sc->devinfo[i].register3; + r3 &= 0xf000; + r3 |= ((uint16_t)(next_free) & 0x000f) << 8; + r3 |= 0x00fe; + + adb_send_raw_packet_sync(dev,i, ADB_COMMAND_LISTEN,3, + sizeof(uint16_t),(u_char *)(&r3)); + + adb_send_raw_packet_sync(dev,next_free, + ADB_COMMAND_TALK,3,0,NULL); + + sc->devinfo[next_free].default_address = i; + if (first_relocated < 0) + first_relocated = next_free; + + next_free++; + } else if (first_relocated > 0) { + /* Collisions removed, relocate first device back */ + + r3 = sc->devinfo[i].register3; + r3 &= 0xf000; + r3 |= ((uint16_t)(i) & 0x000f) << 8; + + adb_send_raw_packet_sync(dev,first_relocated, + ADB_COMMAND_LISTEN,3, + sizeof(uint16_t),(u_char *)(&r3)); + adb_send_raw_packet_sync(dev,i, + ADB_COMMAND_TALK,3,0,NULL); + + sc->devinfo[i].default_address = i; + sc->devinfo[(int)(first_relocated)].default_address = 0; + break; + } + } while (reply); + } + + for (i = 0; i < 16; i++) { + if (sc->devinfo[i].default_address) { + sc->children[i] = device_add_child(dev, NULL, -1); + device_set_ivars(sc->children[i], &sc->devinfo[i]); + } + } + + return (bus_generic_attach(dev)); +} + +static int adb_bus_detach(device_t dev) +{ + struct adb_softc *sc = device_get_softc(dev); + + mtx_destroy(&sc->sc_sync_mtx); + + return (bus_generic_detach(dev)); +} + + +static void +adb_probe_nomatch(device_t dev, device_t child) +{ + struct adb_devinfo *dinfo; + + if (bootverbose) { + dinfo = device_get_ivars(child); + + device_printf(dev,"ADB %s at device %d (no driver attached)\n", + adb_device_string[dinfo->default_address],dinfo->address); + } +} + +u_int +adb_receive_raw_packet(device_t dev, u_char status, u_char command, int len, + u_char *data) +{ + struct adb_softc *sc = device_get_softc(dev); + u_char addr = command >> 4; + + if (len > 0 && (command & 0x0f) == ((ADB_COMMAND_TALK << 2) | 3)) { + memcpy(&sc->devinfo[addr].register3,data,2); + sc->devinfo[addr].handler_id = data[1]; + } + + if (sc->sync_packet == command) { + memcpy(sc->syncreg,data,(len > 8) ? 8 : len); + atomic_store_rel_int(&sc->packet_reply,len + 1); + } + + if (sc->children[addr] != NULL) { + ADB_RECEIVE_PACKET(sc->children[addr],status, + (command & 0x0f) >> 2,command & 0x03,len,data); + } + + return (0); +} + +static int +adb_print_child(device_t dev, device_t child) +{ + struct adb_devinfo *dinfo; + int retval = 0; + + dinfo = device_get_ivars(child); + + retval += bus_print_child_header(dev,child); + printf(" at device %d",dinfo->address); + retval += bus_print_child_footer(dev, child); + + return (retval); +} + +u_int +adb_send_packet(device_t dev, u_char command, u_char reg, int len, u_char *data) +{ + u_char command_byte = 0; + struct adb_devinfo *dinfo; + struct adb_softc *sc; + + sc = device_get_softc(device_get_parent(dev)); + dinfo = device_get_ivars(dev); + + command_byte |= dinfo->address << 4; + command_byte |= command << 2; + command_byte |= reg; + + ADB_HB_SEND_RAW_PACKET(sc->parent, command_byte, len, data, 1); + + return (0); +} + +u_int +adb_set_autopoll(device_t dev, u_char enable) +{ + struct adb_devinfo *dinfo; + struct adb_softc *sc; + uint16_t mod = 0; + + sc = device_get_softc(device_get_parent(dev)); + dinfo = device_get_ivars(dev); + + mod = enable << dinfo->address; + if (enable) { + sc->autopoll_mask |= mod; + } else { + mod = ~mod; + sc->autopoll_mask &= mod; + } + + ADB_HB_SET_AUTOPOLL_MASK(sc->parent,sc->autopoll_mask); + + return (0); +} + +uint8_t +adb_get_device_type(device_t dev) +{ + struct adb_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->default_address); +} + +uint8_t +adb_get_device_handler(device_t dev) +{ + struct adb_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->handler_id); +} + +static int +adb_send_raw_packet_sync(device_t dev, uint8_t to, uint8_t command, + uint8_t reg, int len, u_char *data) +{ + u_char command_byte = 0; + struct adb_softc *sc; + int result = -1; + int i = 0; + + sc = device_get_softc(dev); + + command_byte |= to << 4; + command_byte |= command << 2; + command_byte |= reg; + + /* Wait if someone else has a synchronous request pending */ + mtx_lock(&sc->sc_sync_mtx); + + sc->packet_reply = 0; + sc->sync_packet = command_byte; + + ADB_HB_SEND_RAW_PACKET(sc->parent, command_byte, len, data, 1); + + while (!atomic_fetchadd_int(&sc->packet_reply,0)) { + /* Sometimes CUDA controllers hang up during cold boots. + Try poking them. */ + if (i > 10) + ADB_HB_CONTROLLER_POLL(sc->parent); + + DELAY(100); + i++; + } + + result = sc->packet_reply - 1; + + /* Clear packet sync */ + sc->packet_reply = 0; + sc->sync_packet = 0xffff; /* We can't match a 16 bit value */ + + mtx_unlock(&sc->sc_sync_mtx); + + return (result); +} + +uint8_t +adb_set_device_handler(device_t dev, uint8_t newhandler) +{ + struct adb_softc *sc; + struct adb_devinfo *dinfo; + uint16_t newr3; + + dinfo = device_get_ivars(dev); + sc = device_get_softc(device_get_parent(dev)); + + newr3 = dinfo->register3 & 0xff00; + newr3 |= (uint16_t)(newhandler); + + adb_send_raw_packet_sync(sc->sc_dev,dinfo->address, + ADB_COMMAND_LISTEN, 3, sizeof(uint16_t), (u_char *)(&newr3)); + adb_send_raw_packet_sync(sc->sc_dev,dinfo->address, + ADB_COMMAND_TALK, 3, 0, NULL); + + return (dinfo->handler_id); +} + +uint8_t +adb_read_register(device_t dev, u_char reg, + size_t *len, void *data) +{ + struct adb_softc *sc; + struct adb_devinfo *dinfo; + size_t orig_len; + + dinfo = device_get_ivars(dev); + sc = device_get_softc(device_get_parent(dev)); + + orig_len = *len; + + mtx_lock(&sc->sc_sync_mtx); + + *len = adb_send_raw_packet_sync(sc->sc_dev,dinfo->address, + ADB_COMMAND_TALK, reg, 0, NULL); + + if (*len > 0) + memcpy(data,sc->syncreg,*len); + + mtx_unlock(&sc->sc_sync_mtx); + + return ((*len > 0) ? 0 : -1); +} + Added: head/sys/dev/adb/adb_hb_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/adb/adb_hb_if.m Sun Oct 26 19:37:38 2008 (r184299) @@ -0,0 +1,58 @@ +#- +# Copyright (c) 2008 Nathan Whitehorn +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +#include + +#include + +INTERFACE adb_hb; + +# +# Bus level operations. These are used by the ADB bus manager, and are +# required to inplement an ADB interface. +# + +METHOD u_int send_raw_packet { + device_t dev; + u_char command_byte; + + int len; + u_char *data; + u_char poll; +}; + +METHOD u_int controller_poll { + device_t dev; +}; + +METHOD u_int set_autopoll_mask { + device_t dev; + + uint16_t mask; +}; + Added: head/sys/dev/adb/adb_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/adb/adb_if.m Sun Oct 26 19:37:38 2008 (r184299) @@ -0,0 +1,49 @@ +#- +# Copyright (c) 2008 Nathan Whitehorn +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +#include + +#include + +INTERFACE adb; + +# +# Driver level operations +# + +METHOD u_int receive_packet { + device_t dev; + + u_char status; + u_char command; + u_char reg; + + int len; + u_char *data; +}; + Added: head/sys/dev/adb/adb_kbd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/adb/adb_kbd.c Sun Oct 26 19:37:38 2008 (r184299) @@ -0,0 +1,692 @@ +/*- + * Copyright (C) 2008 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "opt_kbd.h" +#include +#include + +#include +#include + +#include "adb.h" + +#define KBD_DRIVER_NAME "akbd" + +#define AKBD_EMULATE_ATKBD 1 + +static int adb_kbd_probe(device_t dev); +static int adb_kbd_attach(device_t dev); +static int adb_kbd_detach(device_t dev); +static void akbd_repeat(void *xsc); + +static u_int adb_kbd_receive_packet(device_t dev, u_char status, + u_char command, u_char reg, int len, u_char *data); + +struct adb_kbd_softc { + keyboard_t sc_kbd; + + device_t sc_dev; + struct mtx sc_mutex; + struct cv sc_cv; + + int sc_mode; + int sc_state; + + int have_led_control; + + uint8_t buffer[8]; + volatile int buffers; + + struct callout sc_repeater; + int sc_repeatstart; + int sc_repeatcontinue; + uint8_t last_press; +}; + +static device_method_t adb_kbd_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, adb_kbd_probe), + DEVMETHOD(device_attach, adb_kbd_attach), + DEVMETHOD(device_detach, adb_kbd_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* ADB interface */ + DEVMETHOD(adb_receive_packet, adb_kbd_receive_packet), + + { 0, 0 } +}; + +static driver_t adb_kbd_driver = { + "akbd", + adb_kbd_methods, + sizeof(struct adb_kbd_softc), +}; + +static devclass_t adb_kbd_devclass; + +DRIVER_MODULE(akbd, adb, adb_kbd_driver, adb_kbd_devclass, 0, 0); + +static const uint8_t adb_to_at_scancode_map[128] = { 30, 31, 32, 33, 35, 34, + 44, 45, 46, 47, 0, 48, 16, 17, 18, 19, 21, 20, 2, 3, 4, 5, 7, 6, 13, + 10, 8, 12, 9, 11, 27, 24, 22, 26, 23, 25, 28, 38, 36, 40, 37, 39, 43, + 51, 53, 49, 50, 52, 15, 57, 41, 14, 0, 1, 29, 0, 42, 58, 56, 97, 98, + 100, 95, 0, 0, 83, 0, 55, 0, 78, 0, 69, 0, 0, 0, 91, 89, 0, 74, 13, 0, + 0, 82, 79, 80, 81, 75, 76, 77, 71, 0, 72, 73, 0, 0, 0, 63, 64, 65, 61, + 66, 67, 0, 87, 0, 105, 0, 70, 0, 68, 0, 88, 0, 107, 102, 94, 96, 103, + 62, 99, 60, 101, 59, 54, 93, 90, 0, 0 }; + +/* keyboard driver declaration */ +static int akbd_configure(int flags); +static kbd_probe_t akbd_probe; +static kbd_init_t akbd_init; +static kbd_term_t akbd_term; +static kbd_intr_t akbd_interrupt; +static kbd_test_if_t akbd_test_if; +static kbd_enable_t akbd_enable; +static kbd_disable_t akbd_disable; +static kbd_read_t akbd_read; +static kbd_check_t akbd_check; +static kbd_read_char_t akbd_read_char; +static kbd_check_char_t akbd_check_char; +static kbd_ioctl_t akbd_ioctl; +static kbd_lock_t akbd_lock; +static kbd_clear_state_t akbd_clear_state; +static kbd_get_state_t akbd_get_state; +static kbd_set_state_t akbd_set_state; +static kbd_poll_mode_t akbd_poll; + +keyboard_switch_t akbdsw = { + akbd_probe, + akbd_init, + akbd_term, + akbd_interrupt, + akbd_test_if, + akbd_enable, + akbd_disable, + akbd_read, + akbd_check, + akbd_read_char, + akbd_check_char, + akbd_ioctl, + akbd_lock, + akbd_clear_state, + akbd_get_state, + akbd_set_state, + genkbd_get_fkeystr, + akbd_poll, + genkbd_diag, +}; + +KEYBOARD_DRIVER(akbd, akbdsw, akbd_configure); + +static int +adb_kbd_probe(device_t dev) +{ + uint8_t type; + + type = adb_get_device_type(dev); + + if (type != ADB_DEVICE_KEYBOARD) + return (ENXIO); + + switch(adb_get_device_handler(dev)) { + case 1: + device_set_desc(dev,"Apple Standard Keyboard"); + break; + case 2: + device_set_desc(dev,"Apple Extended Keyboard"); + break; + case 4: + device_set_desc(dev,"Apple ISO Keyboard"); + break; + case 5: + device_set_desc(dev,"Apple Extended ISO Keyboard"); + break; + case 8: + device_set_desc(dev,"Apple Keyboard II"); + break; + case 9: + device_set_desc(dev,"Apple ISO Keyboard II"); + break; + case 12: + device_set_desc(dev,"PowerBook Keyboard"); + break; + case 13: + device_set_desc(dev,"PowerBook ISO Keyboard"); + break; + case 24: + device_set_desc(dev,"PowerBook Extended Keyboard"); + break; + case 27: + device_set_desc(dev,"Apple Design Keyboard"); + break; + case 195: + device_set_desc(dev,"PowerBook G3 Keyboard"); + break; + case 196: + device_set_desc(dev,"iBook Keyboard"); + break; + default: + device_set_desc(dev,"ADB Keyboard"); + break; + } + + return (0); +} + +static int +ms_to_ticks(int ms) +{ + if (hz > 1000) + return ms*(hz/1000); + + return ms/(1000/hz); +} + +static int +adb_kbd_attach(device_t dev) +{ + struct adb_kbd_softc *sc; + keyboard_switch_t *sw; + + sw = kbd_get_switch(KBD_DRIVER_NAME); + if (sw == NULL) { + return ENXIO; + } + + sc = device_get_softc(dev); + sc->sc_dev = dev; + sc->sc_mode = K_RAW; + sc->sc_state = 0; + sc->have_led_control = 0; + sc->buffers = 0; + + /* Try stepping forward to the extended keyboard protocol */ + adb_set_device_handler(dev,3); + + mtx_init(&sc->sc_mutex,KBD_DRIVER_NAME,MTX_DEF,0); + cv_init(&sc->sc_cv,KBD_DRIVER_NAME); + callout_init(&sc->sc_repeater, 0); + +#ifdef AKBD_EMULATE_ATKBD + kbd_init_struct(&sc->sc_kbd, KBD_DRIVER_NAME, KB_101, 0, 0, 0, 0); + kbd_set_maps(&sc->sc_kbd, &key_map, &accent_map, fkey_tab, + sizeof(fkey_tab) / sizeof(fkey_tab[0])); +#else + #error ADB raw mode not implemented +#endif + + KBD_FOUND_DEVICE(&sc->sc_kbd); + KBD_PROBE_DONE(&sc->sc_kbd); + KBD_INIT_DONE(&sc->sc_kbd); + KBD_CONFIG_DONE(&sc->sc_kbd); + + (*sw->enable)(&sc->sc_kbd); + + kbd_register(&sc->sc_kbd); + +#ifdef KBD_INSTALL_CDEV + if (kbd_attach(&sc->sc_kbd)) { + adb_kbd_detach(dev); + return ENXIO; + } +#endif + + adb_set_autopoll(dev,1); + + /* Check (asynchronously) if we can read out the LED state from + this keyboard by reading the key state register */ + adb_send_packet(dev,ADB_COMMAND_TALK,2,0,NULL); + + return (0); +} + +static int +adb_kbd_detach(device_t dev) +{ + struct adb_kbd_softc *sc; + keyboard_t *kbd; + + sc = device_get_softc(dev); + + adb_set_autopoll(dev,0); + callout_stop(&sc->sc_repeater); + + mtx_lock(&sc->sc_mutex); + + kbd = kbd_get_keyboard(kbd_find_keyboard(KBD_DRIVER_NAME, + device_get_unit(dev))); + + kbdd_disable(kbd); + +#ifdef KBD_INSTALL_CDEV + kbd_detach(kbd); +#endif + + kbdd_term(kbd); + + mtx_unlock(&sc->sc_mutex); + + mtx_destroy(&sc->sc_mutex); + cv_destroy(&sc->sc_cv); + + return (0); +} + +static u_int +adb_kbd_receive_packet(device_t dev, u_char status, + u_char command, u_char reg, int len, u_char *data) +{ + struct adb_kbd_softc *sc; + + sc = device_get_softc(dev); + + if (command != ADB_COMMAND_TALK) + return 0; + + if (reg == 2 && len == 2) { + sc->have_led_control = 1; + return 0; + } + + if (reg != 0 || len != 2) + return (0); + + mtx_lock(&sc->sc_mutex); + if ((data[0] & 0x7f) == 57 && sc->buffers < 7) { + /* Fake the down/up cycle for caps lock */ + sc->buffer[sc->buffers++] = data[0] & 0x7f; + sc->buffer[sc->buffers++] = (data[0] & 0x7f) | (1 << 7); + } else { + sc->buffer[sc->buffers++] = data[0]; + } + + if (sc->buffer[sc->buffers-1] < 0xff) + sc->last_press = sc->buffer[sc->buffers-1]; + + if ((data[1] & 0x7f) == 57 && sc->buffers < 7) { + /* Fake the down/up cycle for caps lock */ + sc->buffer[sc->buffers++] = data[1] & 0x7f; + sc->buffer[sc->buffers++] = (data[1] & 0x7f) | (1 << 7); + } else { + sc->buffer[sc->buffers++] = data[1]; + } + + if (sc->buffer[sc->buffers-1] < 0xff) + sc->last_press = sc->buffer[sc->buffers-1]; + + /* Stop any existing key repeating */ + callout_stop(&sc->sc_repeater); + + /* Schedule a repeat callback on keydown */ + if (!(sc->last_press & (1 << 7))) { + callout_reset(&sc->sc_repeater, + ms_to_ticks(sc->sc_kbd.kb_delay1), akbd_repeat, sc); + } + mtx_unlock(&sc->sc_mutex); + + cv_broadcast(&sc->sc_cv); + + if (KBD_IS_ACTIVE(&sc->sc_kbd) && KBD_IS_BUSY(&sc->sc_kbd)) { + sc->sc_kbd.kb_callback.kc_func(&sc->sc_kbd, + KBDIO_KEYINPUT, sc->sc_kbd.kb_callback.kc_arg); + } + + return (0); +} + +static void +akbd_repeat(void *xsc) { + struct adb_kbd_softc *sc = xsc; + int notify_kbd = 0; + + /* Fake an up/down key repeat so long as we have the + free buffers */ + mtx_lock(&sc->sc_mutex); + if (sc->buffers < 7) { + sc->buffer[sc->buffers++] = sc->last_press | (1 << 7); + sc->buffer[sc->buffers++] = sc->last_press; + + notify_kbd = 1; + } + mtx_unlock(&sc->sc_mutex); + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 20:01:11 2008 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 32436106567E; Sun, 26 Oct 2008 20:01:11 +0000 (UTC) (envelope-from rink@rink.nu) Received: from mx1.rink.nu (gloom.rink.nu [213.34.49.2]) by mx1.freebsd.org (Postfix) with ESMTP id E45A18FC0A; Sun, 26 Oct 2008 20:01:10 +0000 (UTC) (envelope-from rink@rink.nu) Received: from localhost (localhost [127.0.0.1]) by mx1.rink.nu (Postfix) with ESMTP id ACFBC6D42B; Sun, 26 Oct 2008 20:41:57 +0100 (CET) X-Virus-Scanned: amavisd-new at rink.nu Received: from mx1.rink.nu ([213.34.49.2]) by localhost (gloom.rink.nu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xjm4wAcxXFC8; Sun, 26 Oct 2008 20:41:54 +0100 (CET) Received: by mx1.rink.nu (Postfix, from userid 1000) id B921B6D423; Sun, 26 Oct 2008 20:41:54 +0100 (CET) Date: Sun, 26 Oct 2008 20:41:54 +0100 From: Rink Springer To: Nathan Whitehorn Message-ID: <20081026194154.GA64709@rink.nu> References: <200810261937.m9QJbc2O093202@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200810261937.m9QJbc2O093202@svn.freebsd.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184299 - in head/sys: conf dev/adb powerpc/conf powerpc/powermac 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: Sun, 26 Oct 2008 20:01:11 -0000 On Sun, Oct 26, 2008 at 07:37:38PM +0000, Nathan Whitehorn wrote: > Log: > Add ADB support. This provides support for the external ADB bus on the PowerMac > G3 as well as the internal ADB keyboard and mice in PowerBooks and iBooks. This > also brings in Mac GPIO support, for which we should eventually have a better > interface. > > Obtained from: NetBSD (CUDA and PMU drivers) Thank you! I was looking into this myself, but it seems you've already got it sorted out. Great work! -- Rink P.W. Springer - http://rink.nu "Anyway boys, this is America. Just because you get more votes doesn't mean you win." - Fox Mulder From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 20:45:29 2008 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 2B8C51065675; Sun, 26 Oct 2008 20:45:29 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 0EF988FC12; Sun, 26 Oct 2008 20:45:28 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 301F51CCA0; Sun, 26 Oct 2008 21:45:26 +0100 (CET) Date: Sun, 26 Oct 2008 21:45:26 +0100 From: Ed Schouten To: Nathan Whitehorn Message-ID: <20081026204526.GK6808@hoeg.nl> References: <200810261937.m9QJbc2O093202@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pN9MePJoZbRKbUk1" Content-Disposition: inline In-Reply-To: <200810261937.m9QJbc2O093202@svn.freebsd.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184299 - in head/sys: conf dev/adb powerpc/conf powerpc/powermac 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: Sun, 26 Oct 2008 20:45:29 -0000 --pN9MePJoZbRKbUk1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Sun Oct 26 19:37:38 2008 > New Revision: 184299 > URL: http://svn.freebsd.org/changeset/base/184299 >=20 > Log: > Add ADB support. This provides support for the external ADB bus on > the PowerMac G3 as well as the internal ADB keyboard and mice in > PowerBooks and iBooks. This also brings in Mac GPIO support, for > which we should eventually have a better interface. > =20 > Obtained from: NetBSD (CUDA and PMU drivers) I, for one, welcome our kernel hacking overlord! Thanks a lot! This means I can finally try FreeBSD/powerpc on my old rusty PowerBook. --=20 Ed Schouten WWW: http://80386.nl/ --pN9MePJoZbRKbUk1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkkE1uYACgkQ52SDGA2eCwVrTwCfVmUHGCj3AY/qCThsgX5Bn9D4 Q5IAn0MOu8hp85SInFu8T+fhVszG7hcx =c7zN -----END PGP SIGNATURE----- --pN9MePJoZbRKbUk1-- From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 21:56:27 2008 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 6535B106566C; Sun, 26 Oct 2008 21:56:27 +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 5315B8FC18; Sun, 26 Oct 2008 21:56:27 +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 m9QLuRxw097075; Sun, 26 Oct 2008 21:56:27 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QLuRZN097074; Sun, 26 Oct 2008 21:56:27 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810262156.m9QLuRZN097074@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 21:56:27 +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: r184302 - 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: Sun, 26 Oct 2008 21:56:27 -0000 Author: sam Date: Sun Oct 26 21:56:27 2008 New Revision: 184302 URL: http://svn.freebsd.org/changeset/base/184302 Log: Fix joining an 11b BSS: scanning is normally done using 11g channels (unless explicitly locked to mode 11b) so when we join the bss the channel attached to the scan cache entry may need to be demoted. o demote to 11b if the ap is advertising 11b rates o skip the ap if it's 11b but we're locked to 11g (could consider this advisory but for now treat it as mandatory) o handle an odd edge case, if there is a fixed transmit rate for 11g then the rate check against the 11b ap will fail, try to demote to 11b and retry the rate check Reviewed by: sephe, thompsa Modified: head/sys/net80211/ieee80211_scan_sta.c Modified: head/sys/net80211/ieee80211_scan_sta.c ============================================================================== --- head/sys/net80211/ieee80211_scan_sta.c Sun Oct 26 21:56:06 2008 (r184301) +++ head/sys/net80211/ieee80211_scan_sta.c Sun Oct 26 21:56:27 2008 (r184302) @@ -73,8 +73,7 @@ struct sta_entry { uint8_t se_seen; /* seen during current scan */ uint8_t se_notseen; /* not seen in previous scans */ uint8_t se_flags; -#define STA_SSID_MATCH 0x01 -#define STA_BSSID_MATCH 0x02 +#define STA_DEMOTE11B 0x01 /* match w/ demoted 11b chan */ uint32_t se_avgrssi; /* LPF rssi state */ unsigned long se_lastupdate; /* time of last update */ unsigned long se_lastfail; /* time of last failure */ @@ -107,16 +106,16 @@ static void sta_flush_table(struct sta_t * contents explains why. The following flags are or'd to to this * mask and can be used to figure out why the entry was rejected. */ -#define MATCH_CHANNEL 0x001 /* channel mismatch */ -#define MATCH_CAPINFO 0x002 /* capabilities mismatch, e.g. no ess */ -#define MATCH_PRIVACY 0x004 /* privacy mismatch */ -#define MATCH_RATE 0x008 /* rate set mismatch */ -#define MATCH_SSID 0x010 /* ssid mismatch */ -#define MATCH_BSSID 0x020 /* bssid mismatch */ -#define MATCH_FAILS 0x040 /* too many failed auth attempts */ -#define MATCH_NOTSEEN 0x080 /* not seen in recent scans */ -#define MATCH_RSSI 0x100 /* rssi deemed too low to use */ -#define MATCH_CC 0x200 /* country code mismatch */ +#define MATCH_CHANNEL 0x0001 /* channel mismatch */ +#define MATCH_CAPINFO 0x0002 /* capabilities mismatch, e.g. no ess */ +#define MATCH_PRIVACY 0x0004 /* privacy mismatch */ +#define MATCH_RATE 0x0008 /* rate set mismatch */ +#define MATCH_SSID 0x0010 /* ssid mismatch */ +#define MATCH_BSSID 0x0020 /* bssid mismatch */ +#define MATCH_FAILS 0x0040 /* too many failed auth attempts */ +#define MATCH_NOTSEEN 0x0080 /* not seen in recent scans */ +#define MATCH_RSSI 0x0100 /* rssi deemed too low to use */ +#define MATCH_CC 0x0200 /* country code mismatch */ static int match_bss(struct ieee80211vap *, const struct ieee80211_scan_state *, struct sta_entry *, int); static void adhoc_age(struct ieee80211_scan_state *); @@ -675,6 +674,26 @@ sta_cancel(struct ieee80211_scan_state * ((uint16_t) \ ((((const uint8_t *)(p))[0] ) | \ (((const uint8_t *)(p))[1] << 8))) + +/* + * Demote any supplied 11g channel to 11b. There should + * always be an 11b channel but we check anyway... + */ +static struct ieee80211_channel * +demote11b(struct ieee80211vap *vap, struct ieee80211_channel *chan) +{ + struct ieee80211_channel *c; + + if (IEEE80211_IS_CHAN_ANYG(chan) && + vap->iv_des_mode == IEEE80211_MODE_AUTO) { + c = ieee80211_find_channel(vap->iv_ic, chan->ic_freq, + (chan->ic_flags &~ (IEEE80211_CHAN_PUREG | IEEE80211_CHAN_G)) | + IEEE80211_CHAN_B); + if (c != NULL) + chan = c; + } + return chan; +} static int maxrate(const struct ieee80211_scan_entry *se) @@ -774,7 +793,8 @@ sta_compare(const struct sta_entry *a, c * XXX inspect MCS for HT */ static int -check_rate(struct ieee80211vap *vap, const struct ieee80211_scan_entry *se) +check_rate(struct ieee80211vap *vap, const struct ieee80211_channel *chan, + const struct ieee80211_scan_entry *se) { #define RV(v) ((v) & IEEE80211_RATE_VAL) const struct ieee80211_rateset *srs; @@ -783,11 +803,11 @@ check_rate(struct ieee80211vap *vap, con okrate = badrate = 0; - srs = ieee80211_get_suprates(vap->iv_ic, se->se_chan); + srs = ieee80211_get_suprates(vap->iv_ic, chan); nrs = se->se_rates[1]; rs = se->se_rates+2; /* XXX MCS */ - ucastrate = vap->iv_txparms[ieee80211_chan2mode(se->se_chan)].ucastrate; + ucastrate = vap->iv_txparms[ieee80211_chan2mode(chan)].ucastrate; fixedrate = IEEE80211_FIXED_RATE_NONE; again: for (i = 0; i < nrs; i++) { @@ -903,9 +923,38 @@ match_bss(struct ieee80211vap *vap, if (se->se_capinfo & IEEE80211_CAPINFO_PRIVACY) fail |= MATCH_PRIVACY; } - rate = check_rate(vap, se); - if (rate & IEEE80211_RATE_BASIC) + se0->se_flags &= ~STA_DEMOTE11B; + rate = check_rate(vap, se->se_chan, se); + if (rate & IEEE80211_RATE_BASIC) { fail |= MATCH_RATE; + /* + * An 11b-only ap will give a rate mismatch if there is an + * OFDM fixed tx rate for 11g. Try downgrading the channel + * in the scan list to 11b and retry the rate check. + */ + if (IEEE80211_IS_CHAN_ANYG(se->se_chan)) { + rate = check_rate(vap, demote11b(vap, se->se_chan), se); + if ((rate & IEEE80211_RATE_BASIC) == 0) { + fail &= ~MATCH_RATE; + se0->se_flags |= STA_DEMOTE11B; + } + } + } else if (rate < 2*24) { + /* + * This is an 11b-only ap. Check the desired mode in + * case that needs to be honored (mode 11g filters out + * 11b-only ap's). Otherwise force any 11g channel used + * in scanning to be demoted. + * + * NB: we cheat a bit here by looking at the max rate; + * we could/should check the rates. + */ + if (!(vap->iv_des_mode == IEEE80211_MODE_AUTO || + vap->iv_des_mode == IEEE80211_MODE_11B)) + fail |= MATCH_RATE; + else + se0->se_flags |= STA_DEMOTE11B; + } if (ss->ss_nssid != 0 && !match_ssid(se->se_ssid, ss->ss_nssid, ss->ss_ssid)) fail |= MATCH_SSID; @@ -1060,6 +1109,8 @@ notfound: if (selbs == NULL) goto notfound; chan = selbs->base.se_chan; + if (selbs->se_flags & STA_DEMOTE11B) + chan = demote11b(vap, chan); if (!ieee80211_sta_join(vap, chan, &selbs->base)) goto notfound; return 1; /* terminate scan */ @@ -1151,6 +1202,8 @@ sta_roam_check(struct ieee80211_scan_sta curRate, roamRate, curRssi, roamRssi); chan = selbs->base.se_chan; + if (selbs->se_flags & STA_DEMOTE11B) + chan = demote11b(vap, chan); (void) ieee80211_sta_join(vap, chan, &selbs->base); } } @@ -1430,6 +1483,8 @@ notfound: if (selbs == NULL) goto notfound; chan = selbs->base.se_chan; + if (selbs->se_flags & STA_DEMOTE11B) + chan = demote11b(vap, chan); if (!ieee80211_sta_join(vap, chan, &selbs->base)) goto notfound; return 1; /* terminate scan */ From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 21:59:07 2008 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 8A4401065676; Sun, 26 Oct 2008 21:59:07 +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 78C9A8FC12; Sun, 26 Oct 2008 21:59:07 +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 m9QLx7a8097163; Sun, 26 Oct 2008 21:59:07 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QLx7J3097162; Sun, 26 Oct 2008 21:59:07 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810262159.m9QLx7J3097162@svn.freebsd.org> From: Sam Leffler Date: Sun, 26 Oct 2008 21:59:07 +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: r184303 - 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: Sun, 26 Oct 2008 21:59:07 -0000 Author: sam Date: Sun Oct 26 21:59:07 2008 New Revision: 184303 URL: http://svn.freebsd.org/changeset/base/184303 Log: o re-enable a lock assert o while here reformat a comment to sync w/ other repot's Modified: head/sys/net80211/ieee80211_node.c Modified: head/sys/net80211/ieee80211_node.c ============================================================================== --- head/sys/net80211/ieee80211_node.c Sun Oct 26 21:56:27 2008 (r184302) +++ head/sys/net80211/ieee80211_node.c Sun Oct 26 21:59:07 2008 (r184303) @@ -598,8 +598,8 @@ gethtadjustflags(struct ieee80211com *ic /* * Check if the current channel needs to change based on whether - * any vap's are using HT20/HT40. This is used sync the state of - * ic_curchan after a channel width change on a running vap. + * any vap's are using HT20/HT40. This is used to sync the state + * of ic_curchan after a channel width change on a running vap. */ void ieee80211_sync_curchan(struct ieee80211com *ic) @@ -952,9 +952,9 @@ static void node_age(struct ieee80211_node *ni) { struct ieee80211vap *vap = ni->ni_vap; -#if 0 - IEEE80211_NODE_LOCK_ASSERT(&ic->ic_sta); -#endif + + IEEE80211_NODE_LOCK_ASSERT(&vap->iv_ic->ic_sta); + /* * Age frames on the power save queue. */ From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 22:03:52 2008 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 E9BA9106567A; Sun, 26 Oct 2008 22:03:52 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D761B8FC14; Sun, 26 Oct 2008 22:03:52 +0000 (UTC) (envelope-from rwatson@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 m9QM3qOE097360; Sun, 26 Oct 2008 22:03:52 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QM3q9m097359; Sun, 26 Oct 2008 22:03:52 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810262203.m9QM3q9m097359@svn.freebsd.org> From: Robert Watson Date: Sun, 26 Oct 2008 22:03:52 +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: r184304 - head/sys/netinet 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: Sun, 26 Oct 2008 22:03:53 -0000 Author: rwatson Date: Sun Oct 26 22:03:52 2008 New Revision: 184304 URL: http://svn.freebsd.org/changeset/base/184304 Log: In both dropwithreset paths in tcp_input.c, drop the tcbinfo lock sooner to decomplicate locking and eliminate the need for a rather chatty comment about why we have to handle the global lock in a special way for the benefit of ipfw and pf cred rules. MFC after: 3 days Modified: head/sys/netinet/tcp_input.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Sun Oct 26 21:59:07 2008 (r184303) +++ head/sys/netinet/tcp_input.c Sun Oct 26 22:03:52 2008 (r184304) @@ -896,19 +896,12 @@ findpcb: dropwithreset: INP_INFO_WLOCK_ASSERT(&V_tcbinfo); + INP_INFO_WUNLOCK(&V_tcbinfo); - /* - * If inp is non-NULL, we call tcp_dropwithreset() holding both inpcb - * and global locks. However, if NULL, we must hold neither as - * firewalls may acquire the global lock in order to look for a - * matching inpcb. - */ if (inp != NULL) { tcp_dropwithreset(m, th, tp, tlen, rstreason); INP_WUNLOCK(inp); - } - INP_INFO_WUNLOCK(&V_tcbinfo); - if (inp == NULL) + } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); m = NULL; /* mbuf chain got consumed. */ goto drop; @@ -2498,19 +2491,12 @@ dropafterack: dropwithreset: KASSERT(headlocked, ("%s: dropwithreset: head not locked", __func__)); + INP_INFO_WUNLOCK(&V_tcbinfo); - /* - * If tp is non-NULL, we call tcp_dropwithreset() holding both inpcb - * and global locks. However, if NULL, we must hold neither as - * firewalls may acquire the global lock in order to look for a - * matching inpcb. - */ if (tp != NULL) { tcp_dropwithreset(m, th, tp, tlen, rstreason); INP_WUNLOCK(tp->t_inpcb); - } - INP_INFO_WUNLOCK(&V_tcbinfo); - if (tp == NULL) + } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); return; From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 22:45:18 2008 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 99E461065672; Sun, 26 Oct 2008 22:45:18 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 862F58FC0C; Sun, 26 Oct 2008 22:45:18 +0000 (UTC) (envelope-from rwatson@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 m9QMjIW0099569; Sun, 26 Oct 2008 22:45:18 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QMjITE099564; Sun, 26 Oct 2008 22:45:18 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810262245.m9QMjITE099564@svn.freebsd.org> From: Robert Watson Date: Sun, 26 Oct 2008 22:45:18 +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: r184307 - in head/sys: netinet6 security/mac 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: Sun, 26 Oct 2008 22:45:18 -0000 Author: rwatson Date: Sun Oct 26 22:45:18 2008 New Revision: 184307 URL: http://svn.freebsd.org/changeset/base/184307 Log: Add a MAC label, MAC Framework, and MAC policy entry points for IPv6 fragment reassembly queues. This allows policies to label reassembly queues, perform access control checks when matching fragments to a queue, update a queue label when fragments are matched, and label the resulting reassembled datagram. Obtained from: TrustedBSD Project Modified: head/sys/netinet6/frag6.c head/sys/netinet6/ip6_var.h head/sys/security/mac/mac_framework.h head/sys/security/mac/mac_inet6.c head/sys/security/mac/mac_policy.h Modified: head/sys/netinet6/frag6.c ============================================================================== --- head/sys/netinet6/frag6.c Sun Oct 26 22:11:31 2008 (r184306) +++ head/sys/netinet6/frag6.c Sun Oct 26 22:45:18 2008 (r184307) @@ -32,6 +32,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_mac.h" + #include #include #include @@ -56,6 +58,8 @@ __FBSDID("$FreeBSD$"); #include /* for ECN definitions */ #include /* for ECN definitions */ +#include + /* * Define it to get a correct behavior on per-interface statistics. * You will need to perform an extra routing table lookup, per fragment, @@ -228,7 +232,11 @@ frag6_input(struct mbuf **mp, int *offp, for (q6 = V_ip6q.ip6q_next; q6 != &V_ip6q; q6 = q6->ip6q_next) if (ip6f->ip6f_ident == q6->ip6q_ident && IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) && - IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &q6->ip6q_dst)) + IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &q6->ip6q_dst) +#ifdef MAC + && mac_ip6q_match(m, q6) +#endif + ) break; if (q6 == &V_ip6q) { @@ -254,7 +262,13 @@ frag6_input(struct mbuf **mp, int *offp, if (q6 == NULL) goto dropfrag; bzero(q6, sizeof(*q6)); - +#ifdef MAC + if (mac_ip6q_init(q6, M_NOWAIT) != 0) { + free(q6, M_FTABLE); + goto dropfrag; + } + mac_ip6q_create(m, q6); +#endif frag6_insque(q6, &V_ip6q); /* ip6q_nxt will be filled afterwards, from 1st fragment */ @@ -461,6 +475,10 @@ frag6_input(struct mbuf **mp, int *offp, #endif insert: +#ifdef MAC + if (!first_frag) + mac_ip6q_update(m, q6); +#endif /* * Stick new segment in its place; @@ -533,6 +551,9 @@ insert: if ((t = m_split(m, offset, M_DONTWAIT)) == NULL) { frag6_remque(q6); V_frag6_nfrags -= q6->ip6q_nfrag; +#ifdef MAC + mac_ip6q_destroy(q6); +#endif free(q6, M_FTABLE); V_frag6_nfragpackets--; goto dropfrag; @@ -551,6 +572,10 @@ insert: frag6_remque(q6); V_frag6_nfrags -= q6->ip6q_nfrag; +#ifdef MAC + mac_ip6q_reassemble(q6, m); + mac_ip6q_destroy(q6); +#endif free(q6, M_FTABLE); V_frag6_nfragpackets--; @@ -623,6 +648,9 @@ frag6_freef(struct ip6q *q6) } frag6_remque(q6); V_frag6_nfrags -= q6->ip6q_nfrag; +#ifdef MAC + mac_ip6q_destroy(q6); +#endif free(q6, M_FTABLE); V_frag6_nfragpackets--; } Modified: head/sys/netinet6/ip6_var.h ============================================================================== --- head/sys/netinet6/ip6_var.h Sun Oct 26 22:11:31 2008 (r184306) +++ head/sys/netinet6/ip6_var.h Sun Oct 26 22:45:18 2008 (r184307) @@ -83,6 +83,7 @@ struct ip6q { u_char *ip6q_nxtp; #endif int ip6q_nfrag; /* # of fragments */ + struct label *ip6q_label; }; struct ip6asfrag { Modified: head/sys/security/mac/mac_framework.h ============================================================================== --- head/sys/security/mac/mac_framework.h Sun Oct 26 22:11:31 2008 (r184306) +++ head/sys/security/mac/mac_framework.h Sun Oct 26 22:45:18 2008 (r184307) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. * Copyright (c) 2005-2006 SPARTA, Inc. * All rights reserved. @@ -60,6 +60,7 @@ struct ifnet; struct ifreq; struct image_params; struct inpcb; +struct ip6q; struct ipq; struct ksem; struct label; @@ -138,6 +139,13 @@ void mac_inpcb_destroy(struct inpcb *); int mac_inpcb_init(struct inpcb *, int); void mac_inpcb_sosetlabel(struct socket *so, struct inpcb *inp); +void mac_ip6q_create(struct mbuf *m, struct ip6q *q6); +void mac_ip6q_destroy(struct ip6q *q6); +int mac_ip6q_init(struct ip6q *q6, int); +int mac_ip6q_match(struct mbuf *m, struct ip6q *q6); +void mac_ip6q_reassemble(struct ip6q *q6, struct mbuf *m); +void mac_ip6q_update(struct mbuf *m, struct ip6q *q6); + void mac_ipq_create(struct mbuf *m, struct ipq *q); void mac_ipq_destroy(struct ipq *q); int mac_ipq_init(struct ipq *q, int); Modified: head/sys/security/mac/mac_inet6.c ============================================================================== --- head/sys/security/mac/mac_inet6.c Sun Oct 26 22:11:31 2008 (r184306) +++ head/sys/security/mac/mac_inet6.c Sun Oct 26 22:45:18 2008 (r184307) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2007 Robert N. M. Watson + * Copyright (c) 2007-2008 Robert N. M. Watson * All rights reserved. * * This software was developed by Robert Watson for the TrustedBSD Project. @@ -49,10 +49,108 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include +static struct label * +mac_ip6q_label_alloc(int flag) +{ + struct label *label; + int error; + + label = mac_labelzone_alloc(flag); + if (label == NULL) + return (NULL); + + MAC_CHECK(ip6q_init_label, label, flag); + if (error) { + MAC_PERFORM(ip6q_destroy_label, label); + mac_labelzone_free(label); + return (NULL); + } + return (label); +} + +int +mac_ip6q_init(struct ip6q *q6, int flag) +{ + + if (mac_labeled & MPC_OBJECT_IPQ) { + q6->ip6q_label = mac_ip6q_label_alloc(flag); + if (q6->ip6q_label == NULL) + return (ENOMEM); + } else + q6->ip6q_label = NULL; + return (0); +} + +static void +mac_ip6q_label_free(struct label *label) +{ + + MAC_PERFORM(ip6q_destroy_label, label); + mac_labelzone_free(label); +} + +void +mac_ip6q_destroy(struct ip6q *q6) +{ + + if (q6->ip6q_label != NULL) { + mac_ip6q_label_free(q6->ip6q_label); + q6->ip6q_label = NULL; + } +} + +void +mac_ip6q_reassemble(struct ip6q *q6, struct mbuf *m) +{ + struct label *label; + + label = mac_mbuf_to_label(m); + + MAC_PERFORM(ip6q_reassemble, q6, q6->ip6q_label, m, label); +} + +void +mac_ip6q_create(struct mbuf *m, struct ip6q *q6) +{ + struct label *label; + + label = mac_mbuf_to_label(m); + + MAC_PERFORM(ip6q_create, m, label, q6, q6->ip6q_label); +} + +int +mac_ip6q_match(struct mbuf *m, struct ip6q *q6) +{ + struct label *label; + int result; + + label = mac_mbuf_to_label(m); + + result = 1; + MAC_BOOLEAN(ip6q_match, &&, m, label, q6, q6->ip6q_label); + + return (result); +} + +void +mac_ip6q_update(struct mbuf *m, struct ip6q *q6) +{ + struct label *label; + + label = mac_mbuf_to_label(m); + + MAC_PERFORM(ip6q_update, m, label, q6, q6->ip6q_label); +} + void mac_netinet6_nd6_send(struct ifnet *ifp, struct mbuf *m) { Modified: head/sys/security/mac/mac_policy.h ============================================================================== --- head/sys/security/mac/mac_policy.h Sun Oct 26 22:11:31 2008 (r184306) +++ head/sys/security/mac/mac_policy.h Sun Oct 26 22:45:18 2008 (r184307) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. * Copyright (c) 2005-2006 SPARTA, Inc. * Copyright (c) 2008 Apple Inc. @@ -72,6 +72,7 @@ struct devfs_dirent; struct ifnet; struct image_params; struct inpcb; +struct ip6q; struct ipq; struct ksem; struct label; @@ -201,6 +202,17 @@ typedef void (*mpo_inpcb_sosetlabel_t)(s struct label *label, struct inpcb *inp, struct label *inplabel); +typedef void (*mpo_ip6q_create_t)(struct mbuf *m, struct label *mlabel, + struct ip6q *q6, struct label *q6label); +typedef void (*mpo_ip6q_destroy_label_t)(struct label *label); +typedef int (*mpo_ip6q_init_label_t)(struct label *label, int flag); +typedef int (*mpo_ip6q_match_t)(struct mbuf *m, struct label *mlabel, + struct ip6q *q6, struct label *q6label); +typedef void (*mpo_ip6q_reassemble)(struct ip6q *q6, struct label *q6label, + struct mbuf *m, struct label *mlabel); +typedef void (*mpo_ip6q_update_t)(struct mbuf *m, struct label *mlabel, + struct ip6q *q6, struct label *q6label); + typedef void (*mpo_ipq_create_t)(struct mbuf *m, struct label *mlabel, struct ipq *q, struct label *qlabel); typedef void (*mpo_ipq_destroy_label_t)(struct label *label); @@ -698,6 +710,13 @@ struct mac_policy_ops { mpo_inpcb_init_label_t mpo_inpcb_init_label; mpo_inpcb_sosetlabel_t mpo_inpcb_sosetlabel; + mpo_ip6q_create_t mpo_ip6q_create; + mpo_ip6q_destroy_label_t mpo_ip6q_destroy_label; + mpo_ip6q_init_label_t mpo_ip6q_init_label; + mpo_ip6q_match_t mpo_ip6q_match; + mpo_ip6q_reassemble mpo_ip6q_reassemble; + mpo_ip6q_update_t mpo_ip6q_update; + mpo_ipq_create_t mpo_ipq_create; mpo_ipq_destroy_label_t mpo_ipq_destroy_label; mpo_ipq_init_label_t mpo_ipq_init_label; @@ -970,6 +989,7 @@ struct mac_policy_conf { #define MPC_OBJECT_SYSVSEM 0x0000000000010000 #define MPC_OBJECT_SYSVSHM 0x0000000000020000 #define MPC_OBJECT_SYNCACHE 0x0000000000040000 +#define MPC_OBJECT_IP6Q 0x0000000000080000 /*- * The TrustedBSD MAC Framework has a major version number, MAC_VERSION, From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 22:46:38 2008 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 5DDBD106567E; Sun, 26 Oct 2008 22:46:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23B4D8FC0A; Sun, 26 Oct 2008 22:46:38 +0000 (UTC) (envelope-from rwatson@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 m9QMkc2L099637; Sun, 26 Oct 2008 22:46:38 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QMkbxk099632; Sun, 26 Oct 2008 22:46:37 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810262246.m9QMkbxk099632@svn.freebsd.org> From: Robert Watson Date: Sun, 26 Oct 2008 22:46:37 +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: r184308 - in head/sys/security: mac_biba mac_lomac mac_mls mac_stub mac_test 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: Sun, 26 Oct 2008 22:46:38 -0000 Author: rwatson Date: Sun Oct 26 22:46:37 2008 New Revision: 184308 URL: http://svn.freebsd.org/changeset/base/184308 Log: Implement MAC policy support for IPv6 fragment reassembly queues, modeled on IPv4 fragment reassembly queue support. Obtained from: TrustedBSD Project Modified: head/sys/security/mac_biba/mac_biba.c head/sys/security/mac_lomac/mac_lomac.c head/sys/security/mac_mls/mac_mls.c head/sys/security/mac_stub/mac_stub.c head/sys/security/mac_test/mac_test.c Modified: head/sys/security/mac_biba/mac_biba.c ============================================================================== --- head/sys/security/mac_biba/mac_biba.c Sun Oct 26 22:45:18 2008 (r184307) +++ head/sys/security/mac_biba/mac_biba.c Sun Oct 26 22:46:37 2008 (r184308) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 McAfee, Inc. * Copyright (c) 2006 SPARTA, Inc. * All rights reserved. @@ -1170,6 +1170,51 @@ biba_inpcb_sosetlabel(struct socket *so, } static void +biba_ip6q_create(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_biba *source, *dest; + + source = SLOT(mlabel); + dest = SLOT(q6label); + + biba_copy_effective(source, dest); +} + +static int +biba_ip6q_match(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_biba *a, *b; + + a = SLOT(q6label); + b = SLOT(mlabel); + + return (biba_equal_effective(a, b)); +} + +static void +biba_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, + struct label *mlabel) +{ + struct mac_biba *source, *dest; + + source = SLOT(q6label); + dest = SLOT(mlabel); + + /* Just use the head, since we require them all to match. */ + biba_copy_effective(source, dest); +} + +static void +biba_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + + /* NOOP: we only accept matching labels, so no need to update */ +} + +static void biba_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *q, struct label *qlabel) { @@ -3325,6 +3370,13 @@ static struct mac_policy_ops mac_biba_op .mpo_inpcb_init_label = biba_init_label_waitcheck, .mpo_inpcb_sosetlabel = biba_inpcb_sosetlabel, + .mpo_ip6q_create = biba_ip6q_create, + .mpo_ip6q_destroy_label = biba_destroy_label, + .mpo_ip6q_init_label = biba_init_label_waitcheck, + .mpo_ip6q_match = biba_ip6q_match, + .mpo_ip6q_reassemble = biba_ip6q_reassemble, + .mpo_ip6q_update = biba_ip6q_update, + .mpo_ipq_create = biba_ipq_create, .mpo_ipq_destroy_label = biba_destroy_label, .mpo_ipq_init_label = biba_init_label_waitcheck, Modified: head/sys/security/mac_lomac/mac_lomac.c ============================================================================== --- head/sys/security/mac_lomac/mac_lomac.c Sun Oct 26 22:45:18 2008 (r184307) +++ head/sys/security/mac_lomac/mac_lomac.c Sun Oct 26 22:46:37 2008 (r184308) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. * Copyright (c) 2006 SPARTA, Inc. * All rights reserved. @@ -1299,6 +1299,51 @@ lomac_inpcb_sosetlabel(struct socket *so } static void +lomac_ip6q_create(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_lomac *source, *dest; + + source = SLOT(mlabel); + dest = SLOT(q6label); + + lomac_copy_single(source, dest); +} + +static int +lomac_ip6q_match(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_lomac *a, *b; + + a = SLOT(q6label); + b = SLOT(mlabel); + + return (lomac_equal_single(a, b)); +} + +static void +lomac_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, + struct label *mlabel) +{ + struct mac_lomac *source, *dest; + + source = SLOT(q6label); + dest = SLOT(mlabel); + + /* Just use the head, since we require them all to match. */ + lomac_copy_single(source, dest); +} + +static void +lomac_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + + /* NOOP: we only accept matching labels, so no need to update */ +} + +static void lomac_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *q, struct label *qlabel) { @@ -2886,6 +2931,13 @@ static struct mac_policy_ops lomac_ops = .mpo_inpcb_init_label = lomac_init_label_waitcheck, .mpo_inpcb_sosetlabel = lomac_inpcb_sosetlabel, + .mpo_ip6q_create = lomac_ip6q_create, + .mpo_ip6q_destroy_label = lomac_destroy_label, + .mpo_ip6q_init_label = lomac_init_label_waitcheck, + .mpo_ip6q_match = lomac_ip6q_match, + .mpo_ip6q_reassemble = lomac_ip6q_reassemble, + .mpo_ip6q_update = lomac_ip6q_update, + .mpo_ipq_create = lomac_ipq_create, .mpo_ipq_destroy_label = lomac_destroy_label, .mpo_ipq_init_label = lomac_init_label_waitcheck, Modified: head/sys/security/mac_mls/mac_mls.c ============================================================================== --- head/sys/security/mac_mls/mac_mls.c Sun Oct 26 22:45:18 2008 (r184307) +++ head/sys/security/mac_mls/mac_mls.c Sun Oct 26 22:46:37 2008 (r184308) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 McAfee, Inc. * Copyright (c) 2006 SPARTA, Inc. * All rights reserved. @@ -1088,6 +1088,51 @@ mls_inpcb_sosetlabel(struct socket *so, } static void +mls_ip6q_create(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_mls *source, *dest; + + source = SLOT(mlabel); + dest = SLOT(q6label); + + mls_copy_effective(source, dest); +} + +static int +mls_ip6q_match(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + struct mac_mls *a, *b; + + a = SLOT(q6label); + b = SLOT(mlabel); + + return (mls_equal_effective(a, b)); +} + +static void +mls_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, + struct label *mlabel) +{ + struct mac_mls *source, *dest; + + source = SLOT(q6label); + dest = SLOT(mlabel); + + /* Just use the head, since we require them all to match. */ + mls_copy_effective(source, dest); +} + +static void +mls_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + + /* NOOP: we only accept matching labels, so no need to update */ +} + +static void mls_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *q, struct label *qlabel) { @@ -2948,6 +2993,13 @@ static struct mac_policy_ops mls_ops = .mpo_inpcb_init_label = mls_init_label_waitcheck, .mpo_inpcb_sosetlabel = mls_inpcb_sosetlabel, + .mpo_ip6q_create = mls_ip6q_create, + .mpo_ip6q_destroy_label = mls_destroy_label, + .mpo_ip6q_init_label = mls_init_label_waitcheck, + .mpo_ip6q_match = mls_ip6q_match, + .mpo_ip6q_reassemble = mls_ip6q_reassemble, + .mpo_ip6q_update = mls_ip6q_update, + .mpo_ipq_create = mls_ipq_create, .mpo_ipq_destroy_label = mls_destroy_label, .mpo_ipq_init_label = mls_init_label_waitcheck, Modified: head/sys/security/mac_stub/mac_stub.c ============================================================================== --- head/sys/security/mac_stub/mac_stub.c Sun Oct 26 22:45:18 2008 (r184307) +++ head/sys/security/mac_stub/mac_stub.c Sun Oct 26 22:46:37 2008 (r184308) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 McAfee, Inc. * Copyright (c) 2005-2006 SPARTA, Inc. * Copyright (c) 2008 Apple Inc. @@ -308,6 +308,35 @@ stub_inpcb_sosetlabel(struct socket *so, } static void +stub_ip6q_create(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + +} + +static int +stub_ip6q_match(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + + return (1); +} + +static void +stub_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, + struct label *mlabel) +{ + +} + +static void +stub_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + +} + +static void stub_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *q, struct label *qlabel) { @@ -1546,6 +1575,13 @@ static struct mac_policy_ops stub_ops = .mpo_inpcb_init_label = stub_init_label_waitcheck, .mpo_inpcb_sosetlabel = stub_inpcb_sosetlabel, + .mpo_ip6q_create = stub_ip6q_create, + .mpo_ip6q_destroy_label = stub_destroy_label, + .mpo_ip6q_init_label = stub_init_label_waitcheck, + .mpo_ip6q_match = stub_ip6q_match, + .mpo_ip6q_update = stub_ip6q_update, + .mpo_ip6q_reassemble = stub_ip6q_reassemble, + .mpo_ipq_create = stub_ipq_create, .mpo_ipq_destroy_label = stub_destroy_label, .mpo_ipq_init_label = stub_init_label_waitcheck, Modified: head/sys/security/mac_test/mac_test.c ============================================================================== --- head/sys/security/mac_test/mac_test.c Sun Oct 26 22:45:18 2008 (r184307) +++ head/sys/security/mac_test/mac_test.c Sun Oct 26 22:46:37 2008 (r184308) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson * Copyright (c) 2001-2005 McAfee, Inc. * Copyright (c) 2006 SPARTA, Inc. * Copyright (c) 2008 Apple Inc. @@ -84,6 +84,7 @@ SYSCTL_NODE(_security_mac, OID_AUTO, tes #define MAGIC_DEVFS 0x9ee79c32 #define MAGIC_IFNET 0xc218b120 #define MAGIC_INPCB 0x4440f7bb +#define MAGIC_IP6Q 0x0870e1b7 #define MAGIC_IPQ 0x206188ef #define MAGIC_MBUF 0xbbefa5bb #define MAGIC_MOUNT 0xc7c46e47 @@ -564,6 +565,76 @@ test_inpcb_sosetlabel(struct socket *so, COUNTER_INC(inpcb_sosetlabel); } +COUNTER_DECL(ip6q_create); +static void +test_ip6q_create(struct mbuf *fragment, struct label *fragmentlabel, + struct ip6q *q6, struct label *q6label) +{ + + LABEL_CHECK(fragmentlabel, MAGIC_MBUF); + LABEL_CHECK(q6label, MAGIC_IP6Q); + COUNTER_INC(ip6q_create); +} + +COUNTER_DECL(ip6q_destroy_label); +static void +test_ip6q_destroy_label(struct label *label) +{ + + LABEL_DESTROY(label, MAGIC_IP6Q); + COUNTER_INC(ip6q_destroy_label); +} + +COUNTER_DECL(ip6q_init_label); +static int +test_ip6q_init_label(struct label *label, int flag) +{ + + if (flag & M_WAITOK) + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, + "test_ip6q_init_label() at %s:%d", __FILE__, + __LINE__); + + LABEL_INIT(label, MAGIC_IP6Q); + COUNTER_INC(ip6q_init_label); + return (0); +} + +COUNTER_DECL(ip6q_match); +static int +test_ip6q_match(struct mbuf *fragment, struct label *fragmentlabel, + struct ip6q *q6, struct label *q6label) +{ + + LABEL_CHECK(fragmentlabel, MAGIC_MBUF); + LABEL_CHECK(q6label, MAGIC_IP6Q); + COUNTER_INC(ip6q_match); + + return (1); +} + +COUNTER_DECL(ip6q_reassemble); +static void +test_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, + struct label *mlabel) +{ + + LABEL_CHECK(q6label, MAGIC_IP6Q); + LABEL_CHECK(mlabel, MAGIC_MBUF); + COUNTER_INC(ip6q_reassemble); +} + +COUNTER_DECL(ip6q_update); +static void +test_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, + struct label *q6label) +{ + + LABEL_CHECK(mlabel, MAGIC_MBUF); + LABEL_CHECK(q6label, MAGIC_IP6Q); + COUNTER_INC(ip6q_update); +} + COUNTER_DECL(ipq_create); static void test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, @@ -2860,6 +2931,13 @@ static struct mac_policy_ops test_ops = .mpo_inpcb_init_label = test_inpcb_init_label, .mpo_inpcb_sosetlabel = test_inpcb_sosetlabel, + .mpo_ip6q_create = test_ip6q_create, + .mpo_ip6q_destroy_label = test_ip6q_destroy_label, + .mpo_ip6q_init_label = test_ip6q_init_label, + .mpo_ip6q_match = test_ip6q_match, + .mpo_ip6q_reassemble = test_ip6q_reassemble, + .mpo_ip6q_update = test_ip6q_update, + .mpo_ipq_create = test_ipq_create, .mpo_ipq_destroy_label = test_ipq_destroy_label, .mpo_ipq_init_label = test_ipq_init_label, From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 22:52:57 2008 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 64813106567A; Sun, 26 Oct 2008 22:52:57 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52D148FC08; Sun, 26 Oct 2008 22:52:57 +0000 (UTC) (envelope-from stas@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 m9QMqv8R000294; Sun, 26 Oct 2008 22:52:57 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QMqvXF000293; Sun, 26 Oct 2008 22:52:57 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200810262252.m9QMqvXF000293@svn.freebsd.org> From: Stanislav Sedov Date: Sun, 26 Oct 2008 22:52:57 +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: r184309 - head/sys/arm/at91 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: Sun, 26 Oct 2008 22:52:57 -0000 Author: stas Date: Sun Oct 26 22:52:57 2008 New Revision: 184309 URL: http://svn.freebsd.org/changeset/base/184309 Log: - Add a missing NULL-pointer check. Reviewed by: cognet Approved by: kib (mentor, implicit) MFC after: 3 days Modified: head/sys/arm/at91/at91.c Modified: head/sys/arm/at91/at91.c ============================================================================== --- head/sys/arm/at91/at91.c Sun Oct 26 22:46:37 2008 (r184308) +++ head/sys/arm/at91/at91.c Sun Oct 26 22:52:57 2008 (r184309) @@ -534,8 +534,10 @@ at91_alloc_resource(device_t dev, device case SYS_RES_MEMORY: rle->res = rman_reserve_resource(&sc->sc_mem_rman, start, end, count, flags, child); - rman_set_bustag(rle->res, &at91_bs_tag); - rman_set_bushandle(rle->res, start); + if (rle->res != NULL) { + rman_set_bustag(rle->res, &at91_bs_tag); + rman_set_bushandle(rle->res, start); + } break; } if (rle->res) { From owner-svn-src-head@FreeBSD.ORG Sun Oct 26 22:54:00 2008 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 3FB92106569F; Sun, 26 Oct 2008 22:54:00 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2DF338FC22; Sun, 26 Oct 2008 22:54:00 +0000 (UTC) (envelope-from stas@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 m9QMs0TG000414; Sun, 26 Oct 2008 22:54:00 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9QMs0aJ000413; Sun, 26 Oct 2008 22:54:00 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200810262254.m9QMs0aJ000413@svn.freebsd.org> From: Stanislav Sedov Date: Sun, 26 Oct 2008 22:54:00 +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: r184310 - head/sys/arm/at91 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: Sun, 26 Oct 2008 22:54:00 -0000 Author: stas Date: Sun Oct 26 22:53:59 2008 New Revision: 184310 URL: http://svn.freebsd.org/changeset/base/184310 Log: - Add stream bus_space operations. Reviewed by: cognet Approved by: kib (mentor, implicit) MFC after: 1 week Modified: head/sys/arm/at91/at91.c Modified: head/sys/arm/at91/at91.c ============================================================================== --- head/sys/arm/at91/at91.c Sun Oct 26 22:52:57 2008 (r184309) +++ head/sys/arm/at91/at91.c Sun Oct 26 22:53:59 2008 (r184310) @@ -168,6 +168,42 @@ struct bus_space at91_bs_tag = { generic_armv4_bs_c_2, NULL, NULL, + + /* read (single) stream */ + generic_bs_r_1, + generic_armv4_bs_r_2, + generic_bs_r_4, + NULL, + + /* read multiple stream */ + generic_bs_rm_1, + generic_armv4_bs_rm_2, + generic_bs_rm_4, + NULL, + + /* read region stream */ + generic_bs_rr_1, + generic_armv4_bs_rr_2, + generic_bs_rr_4, + NULL, + + /* write (single) stream */ + generic_bs_w_1, + generic_armv4_bs_w_2, + generic_bs_w_4, + NULL, + + /* write multiple stream */ + generic_bs_wm_1, + generic_armv4_bs_wm_2, + generic_bs_wm_4, + NULL, + + /* write region stream */ + NULL, + generic_armv4_bs_wr_2, + generic_bs_wr_4, + NULL, }; static int From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 00:09:14 2008 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 B0E07106567F; Mon, 27 Oct 2008 00:09:14 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9E50F8FC14; Mon, 27 Oct 2008 00:09:14 +0000 (UTC) (envelope-from nwhitehorn@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 m9R09EPS008077; Mon, 27 Oct 2008 00:09:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R09ExS008076; Mon, 27 Oct 2008 00:09:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200810270009.m9R09ExS008076@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 27 Oct 2008 00:09:14 +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: r184314 - head/sys/powerpc/powermac 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: Mon, 27 Oct 2008 00:09:14 -0000 Author: nwhitehorn Date: Mon Oct 27 00:09:14 2008 New Revision: 184314 URL: http://svn.freebsd.org/changeset/base/184314 Log: Bring Kauai ATA driver in line with Macio ATA by reading the PIO config reg to set the initial PIO mode instead of assuming PIO4. There are still a few nagging issues: - There are some problems with 64 K DMA transfers waiting on lower level changes. - ATAPI DMA is broken on Marcel's Mac Mini because we need an ATA SELECT hook propagated up to individual drivers for hardware without timing registers for each ATA channel. Modified: head/sys/powerpc/powermac/ata_kauai.c Modified: head/sys/powerpc/powermac/ata_kauai.c ============================================================================== --- head/sys/powerpc/powermac/ata_kauai.c Sun Oct 26 23:11:25 2008 (r184313) +++ head/sys/powerpc/powermac/ata_kauai.c Mon Oct 27 00:09:14 2008 (r184314) @@ -292,16 +292,12 @@ ata_kauai_attach(device_t dev) #endif /* Set up initial mode */ - if (sc->shasta) - sc->pioconf[0] = sc->pioconf[1] = pio_timing_shasta[4]; - else - sc->pioconf[0] = sc->pioconf[1] = pio_timing_kauai[4]; + sc->pioconf[0] = sc->pioconf[1] = + bus_read_4(sc->sc_memr, PIO_CONFIG_REG) & 0x0f000fff; sc->udmaconf[0] = sc->udmaconf[1] = 0; sc->wdmaconf[0] = sc->wdmaconf[1] = 0; - bus_write_4(sc->sc_memr, PIO_CONFIG_REG, sc->pioconf[0]); - /* Magic FCR value from Apple */ bus_write_4(sc->sc_memr, 0, 0x00000007); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 00:26:07 2008 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 5F6791065699; Mon, 27 Oct 2008 00:26:07 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF628FC12; Mon, 27 Oct 2008 00:26:07 +0000 (UTC) (envelope-from marcel@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 m9R0Q7dS009720; Mon, 27 Oct 2008 00:26:07 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R0Q75c009719; Mon, 27 Oct 2008 00:26:07 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200810270026.m9R0Q75c009719@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 27 Oct 2008 00:26:07 +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: r184316 - head/sys/powerpc/include 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: Mon, 27 Oct 2008 00:26:07 -0000 Author: marcel Date: Mon Oct 27 00:26:07 2008 New Revision: 184316 URL: http://svn.freebsd.org/changeset/base/184316 Log: Declare btext and etext. Needed by sys/kern/subr_prof.c for for kernel profiling. Modified: head/sys/powerpc/include/cpu.h Modified: head/sys/powerpc/include/cpu.h ============================================================================== --- head/sys/powerpc/include/cpu.h Mon Oct 27 00:23:09 2008 (r184315) +++ head/sys/powerpc/include/cpu.h Mon Oct 27 00:26:07 2008 (r184316) @@ -69,6 +69,9 @@ get_cyclecount(void) #define cpu_getstack(td) ((td)->td_frame->fixreg[1]) #define cpu_spinwait() /* nothing */ +extern char btext[]; +extern char etext[]; + void cpu_halt(void); void cpu_reset(void); void fork_trampoline(void); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 01:05:10 2008 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 791FF1065675; Mon, 27 Oct 2008 01:05:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 677B68FC0A; Mon, 27 Oct 2008 01:05:10 +0000 (UTC) (envelope-from thompsa@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 m9R15AQB013691; Mon, 27 Oct 2008 01:05:10 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R15AvS013690; Mon, 27 Oct 2008 01:05:10 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200810270105.m9R15AvS013690@svn.freebsd.org> From: Andrew Thompson Date: Mon, 27 Oct 2008 01:05:10 +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: r184317 - head/etc 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: Mon, 27 Oct 2008 01:05:10 -0000 Author: thompsa Date: Mon Oct 27 01:05:09 2008 New Revision: 184317 URL: http://svn.freebsd.org/changeset/base/184317 Log: Show which rc script is running since the default ^T just shows 'sh' as the process. Modified: head/etc/rc.subr Modified: head/etc/rc.subr ============================================================================== --- head/etc/rc.subr Mon Oct 27 00:26:07 2008 (r184316) +++ head/etc/rc.subr Mon Oct 27 01:05:09 2008 (r184317) @@ -913,6 +913,7 @@ run_rc_script() else ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 trap "echo Script $_file interrupted; exit 1" 2 + trap "echo Script $_file running" 29 set $_arg; . $_file ) fi fi From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 01:51:30 2008 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 96A55106567F; Mon, 27 Oct 2008 01:51:30 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 84C538FC13; Mon, 27 Oct 2008 01:51:30 +0000 (UTC) (envelope-from marcel@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 m9R1pUhY017216; Mon, 27 Oct 2008 01:51:30 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R1pUgW017215; Mon, 27 Oct 2008 01:51:30 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200810270151.m9R1pUgW017215@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 27 Oct 2008 01:51:30 +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: r184318 - head/sys/powerpc/booke 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: Mon, 27 Oct 2008 01:51:30 -0000 Author: marcel Date: Mon Oct 27 01:51:30 2008 New Revision: 184318 URL: http://svn.freebsd.org/changeset/base/184318 Log: Remove unused declarations (interrupt_vector_{base|top}). Modified: head/sys/powerpc/booke/trap.c Modified: head/sys/powerpc/booke/trap.c ============================================================================== --- head/sys/powerpc/booke/trap.c Mon Oct 27 01:05:09 2008 (r184317) +++ head/sys/powerpc/booke/trap.c Mon Oct 27 01:51:30 2008 (r184318) @@ -103,9 +103,6 @@ int badaddr_read(void *, size_t, int *); extern char *syscallnames[]; -extern char interrupt_vector_base[]; -extern char interrupt_vector_top[]; - struct powerpc_exception { u_int vector; char *name; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 02:36:04 2008 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 11DE21065673; Mon, 27 Oct 2008 02:36:04 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F3D108FC08; Mon, 27 Oct 2008 02:36:03 +0000 (UTC) (envelope-from marcel@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 m9R2a3q7019154; Mon, 27 Oct 2008 02:36:03 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R2a3cS019151; Mon, 27 Oct 2008 02:36:03 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200810270236.m9R2a3cS019151@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 27 Oct 2008 02:36:03 +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: r184319 - in head/sys/powerpc: aim booke include 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: Mon, 27 Oct 2008 02:36:04 -0000 Author: marcel Date: Mon Oct 27 02:36:03 2008 New Revision: 184319 URL: http://svn.freebsd.org/changeset/base/184319 Log: Add support for kernel profiling for both AIM and BookE. Obtained from: Juniper Networks, Inc (BookE support). Modified: head/sys/powerpc/aim/locore.S head/sys/powerpc/booke/locore.S head/sys/powerpc/include/profile.h Modified: head/sys/powerpc/aim/locore.S ============================================================================== --- head/sys/powerpc/aim/locore.S Mon Oct 27 01:51:30 2008 (r184318) +++ head/sys/powerpc/aim/locore.S Mon Oct 27 02:36:03 2008 (r184319) @@ -111,11 +111,14 @@ openfirmware_entry: srsave: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .text + .globl btext +btext: + /* * This symbol is here for the benefit of kvm_mkdb, and is supposed to * mark the start of kernel text. */ - .text .globl kernel_text kernel_text: Modified: head/sys/powerpc/booke/locore.S ============================================================================== --- head/sys/powerpc/booke/locore.S Mon Oct 27 01:51:30 2008 (r184318) +++ head/sys/powerpc/booke/locore.S Mon Oct 27 02:36:03 2008 (r184319) @@ -41,11 +41,14 @@ #define TMPSTACKSZ 16384 + .text + .globl btext +btext: + /* * This symbol is here for the benefit of kvm_mkdb, and is supposed to * mark the start of kernel text. */ - .text .globl kernel_text kernel_text: Modified: head/sys/powerpc/include/profile.h ============================================================================== --- head/sys/powerpc/include/profile.h Mon Oct 27 01:51:30 2008 (r184318) +++ head/sys/powerpc/include/profile.h Mon Oct 27 02:36:03 2008 (r184319) @@ -81,61 +81,87 @@ typedef u_int fptrdiff_t; #define _PLT #endif -#define MCOUNT \ -__asm(" .globl _mcount \n" \ -" .type _mcount,@function \n" \ -"_mcount: \n" \ -" stwu %r1,-64(%r1) /* alloca for reg save space */ \n" \ -" stw %r3,16(%r1) /* save parameter registers, */ \n" \ -" stw %r4,20(%r1) /* r3-10 */ \n" \ -" stw %r5,24(%r1) \n" \ -" stw %r6,28(%r1) \n" \ -" stw %r7,32(%r1) \n" \ -" stw %r8,36(%r1) \n" \ -" stw %r9,40(%r1) \n" \ -" stw %r10,44(%r1) \n" \ -" \n" \ -" mflr %r4 /* link register is 'selfpc' */ \n" \ -" stw %r4,48(%r1) /* save since bl will scrub */ \n" \ -" lwz %r3,68(%r1) /* get 'frompc' from LR-save */ \n" \ -" bl __mcount" _PLT " /* __mcount(frompc, selfpc)*/ \n" \ -" lwz %r3,68(%r1) \n" \ -" mtlr %r3 /* restore caller's lr */ \n" \ -" lwz %r4,48(%r1) \n" \ -" mtctr %r4 /* set up ctr for call back */ \n" \ -" /* note that blr is not used!*/ \n" \ -" lwz %r3,16(%r1) /* restore r3-10 parameters */ \n" \ -" lwz %r4,20(%r1) \n" \ -" lwz %r5,24(%r1) \n" \ -" lwz %r6,28(%r1) \n" \ -" lwz %r7,32(%r1) \n" \ -" lwz %r8,36(%r1) \n" \ -" lwz %r9,40(%r1) \n" \ -" lwz %r10,44(%r1) \n" \ -" addi %r1,%r1,64 /* blow away alloca save area */ \n" \ -" bctr /* return with indirect call */ \n" \ -"_mcount_end: \n" \ -" .size _mcount,_mcount_end-_mcount"); - +#define MCOUNT \ +__asm( " .globl _mcount \n" \ + " .type _mcount,@function \n" \ + " .align 4 \n" \ + "_mcount: \n" \ + " stwu %r1,-64(%r1) \n" \ + " stw %r3,16(%r1) \n" \ + " stw %r4,20(%r1) \n" \ + " stw %r5,24(%r1) \n" \ + " stw %r6,28(%r1) \n" \ + " stw %r7,32(%r1) \n" \ + " stw %r8,36(%r1) \n" \ + " stw %r9,40(%r1) \n" \ + " stw %r10,44(%r1) \n" \ + " mflr %r4 \n" \ + " stw %r4,48(%r1) \n" \ + " lwz %r3,68(%r1) \n" \ + " bl __mcount" _PLT " \n" \ + " lwz %r3,68(%r1) \n" \ + " mtlr %r3 \n" \ + " lwz %r4,48(%r1) \n" \ + " mtctr %r4 \n" \ + " lwz %r3,16(%r1) \n" \ + " lwz %r4,20(%r1) \n" \ + " lwz %r5,24(%r1) \n" \ + " lwz %r6,28(%r1) \n" \ + " lwz %r7,32(%r1) \n" \ + " lwz %r8,36(%r1) \n" \ + " lwz %r9,40(%r1) \n" \ + " lwz %r10,44(%r1) \n" \ + " addi %r1,%r1,64 \n" \ + " bctr \n" \ + "_mcount_end: \n" \ + " .size _mcount,_mcount_end-_mcount"); #ifdef _KERNEL -#define MCOUNT_ENTER(s) s = intr_disable(); -#define MCOUNT_EXIT(s) intr_restore(s); -#define MCOUNT_DECL(s) register_t s - -void bintr(void); -void btrap(void); -void eintr(void); -void user(void); - -#define MCOUNT_FROMPC_USER(pc) \ - ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) - -#define MCOUNT_FROMPC_INTR(pc) \ - ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ - ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ - (uintfptr_t)btrap) : ~0U) +#define MCOUNT_ENTER(s) s = intr_disable() +#define MCOUNT_EXIT(s) intr_restore(s) +#define MCOUNT_DECL(s) register_t s; + +#ifndef COMPILING_LINT +#ifdef AIM +#include +#define __PROFILE_VECTOR_BASE EXC_RST +#define __PROFILE_VECTOR_TOP (EXC_LAST + 0x100) +#endif /* AIM */ +#ifdef E500 +extern char interrupt_vector_base[]; +extern char interrupt_vector_top[]; +#define __PROFILE_VECTOR_BASE (uintfptr_t)interrupt_vector_base +#define __PROFILE_VECTOR_TOP (uintfptr_t)interrupt_vector_top +#endif /* E500 */ +#endif /* !COMPILING_LINT */ + +#ifndef __PROFILE_VECTOR_BASE +#define __PROFILE_VECTOR_BASE 0 +#endif +#ifndef __PROFILE_VECTOR_TOP +#define __PROFILE_VECTOR_TOP 1 +#endif + +static __inline void +powerpc_profile_interrupt(void) +{ +} + +static __inline void +powerpc_profile_userspace(void) +{ +} + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? \ + (uintfptr_t)powerpc_profile_userspace : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= __PROFILE_VECTOR_BASE && \ + pc < __PROFILE_VECTOR_TOP) ? \ + (uintfptr_t)powerpc_profile_interrupt : ~0U) +void __mcount(uintfptr_t frompc, uintfptr_t selfpc); #else /* !_KERNEL */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 06:25:02 2008 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 B5DAB106567C; Mon, 27 Oct 2008 06:25:02 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A4C308FC1C; Mon, 27 Oct 2008 06:25:02 +0000 (UTC) (envelope-from sobomax@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 m9R6P2i9029702; Mon, 27 Oct 2008 06:25:02 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R6P2a8029701; Mon, 27 Oct 2008 06:25:02 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810270625.m9R6P2a8029701@svn.freebsd.org> From: Maxim Sobolev Date: Mon, 27 Oct 2008 06:25:02 +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: r184323 - head/sys/kern 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: Mon, 27 Oct 2008 06:25:02 -0000 Author: sobomax Date: Mon Oct 27 06:25:02 2008 New Revision: 184323 URL: http://svn.freebsd.org/changeset/base/184323 Log: Default HZ value (1,000) on i386/amd64 is not very virtual machine friendly. Due to the nature of the beast it causes lot of unproductive overhead. This is especially bad when running SMP kernel on VMWare with several virtual processors - idle FreeBSD guest with SMP kernel takes 150% host CPU time on my dual-core MacBook Pro when I am enabling two virtual CPUs, making even host not very usable. Detect when we are running in the sandbox and reduce HZ to 10 (can be adjusted via VM_HZ in the kernel config) in such cases. This brings host CPU usage of idle FreeBSD/SMP on two virtual processors down to 10%. Detect most popular VM platforms out there - VMWare, Parallels, VirtualBox and VirtualPC. MFC after: 2 weeks Modified: head/sys/kern/subr_param.c Modified: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Mon Oct 27 05:28:08 2008 (r184322) +++ head/sys/kern/subr_param.c Mon Oct 27 06:25:02 2008 (r184323) @@ -57,6 +57,13 @@ __FBSDID("$FreeBSD$"); # else # define HZ 100 # endif +# ifndef HZ_VM +# define HZ_VM 10 +# endif +#else +# ifndef HZ_VM +# define HZ_VM HZ +# endif #endif #define NPROC (20 + 16 * maxusers) #ifndef NBUF @@ -111,6 +118,30 @@ SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, */ struct buf *swbuf; +char *vm_pnames[] = { + "VMware Virtual Platform", /* VMWare VM */ + "Virtual Machine", /* Microsoft VirtualPC */ + "VirtualBox", /* Sun xVM VirtualBox */ + "Parallels Virtual Platform", /* Parallels VM */ + NULL +}; + +static int +detect_virtual(void) +{ + char *sysenv; + int i; + + sysenv = getenv("smbios.system.product"); + if (sysenv != NULL) { + for (i = 0; vm_pnames[i] != NULL; i++) { + if (strcmp(sysenv, vm_pnames[i]) == 0) + return 1; + } + } + return 0; +} + /* * Boot time overrides that are not scaled against main memory */ @@ -118,8 +149,15 @@ void init_param1(void) { - hz = HZ; + hz = -1; TUNABLE_INT_FETCH("kern.hz", &hz); + if (hz == -1) { + if (detect_virtual()) { + hz = HZ_VM; + } else { + hz = HZ; + } + } tick = 1000000 / hz; #ifdef VM_SWZONE_SIZE_MAX From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 06:34:41 2008 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 866E21065670; Mon, 27 Oct 2008 06:34:41 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7519C8FC1D; Mon, 27 Oct 2008 06:34:41 +0000 (UTC) (envelope-from sobomax@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 m9R6YfiX030256; Mon, 27 Oct 2008 06:34:41 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R6YfLG030255; Mon, 27 Oct 2008 06:34:41 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810270634.m9R6YfLG030255@svn.freebsd.org> From: Maxim Sobolev Date: Mon, 27 Oct 2008 06:34:41 +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: r184324 - head/sys/kern 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: Mon, 27 Oct 2008 06:34:41 -0000 Author: sobomax Date: Mon Oct 27 06:34:41 2008 New Revision: 184324 URL: http://svn.freebsd.org/changeset/base/184324 Log: vm_pnames has no reason to be global. MFC after: 2 weeks Modified: head/sys/kern/subr_param.c Modified: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Mon Oct 27 06:25:02 2008 (r184323) +++ head/sys/kern/subr_param.c Mon Oct 27 06:34:41 2008 (r184324) @@ -118,7 +118,7 @@ SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, */ struct buf *swbuf; -char *vm_pnames[] = { +static char *vm_pnames[] = { "VMware Virtual Platform", /* VMWare VM */ "Virtual Machine", /* Microsoft VirtualPC */ "VirtualBox", /* Sun xVM VirtualBox */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 08:09:05 2008 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 A25671065679; Mon, 27 Oct 2008 08:09:05 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 91D828FC1C; Mon, 27 Oct 2008 08:09:05 +0000 (UTC) (envelope-from sobomax@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 m9R8956E032152; Mon, 27 Oct 2008 08:09:05 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R895IY032151; Mon, 27 Oct 2008 08:09:05 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810270809.m9R895IY032151@svn.freebsd.org> From: Maxim Sobolev Date: Mon, 27 Oct 2008 08:09:05 +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: r184326 - head/sys/kern 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: Mon, 27 Oct 2008 08:09:05 -0000 Author: sobomax Date: Mon Oct 27 08:09:05 2008 New Revision: 184326 URL: http://svn.freebsd.org/changeset/base/184326 Log: vm_pnames should be "const char *const[]". Submitted by: Christoph Mallon Modified: head/sys/kern/subr_param.c Modified: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Mon Oct 27 07:01:14 2008 (r184325) +++ head/sys/kern/subr_param.c Mon Oct 27 08:09:05 2008 (r184326) @@ -118,7 +118,7 @@ SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, */ struct buf *swbuf; -static char *vm_pnames[] = { +static const char *const vm_pnames[] = { "VMware Virtual Platform", /* VMWare VM */ "Virtual Machine", /* Microsoft VirtualPC */ "VirtualBox", /* Sun xVM VirtualBox */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 08:40:14 2008 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 1C8AB106566B; Mon, 27 Oct 2008 08:40:14 +0000 (UTC) (envelope-from kato@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B98A8FC16; Mon, 27 Oct 2008 08:40:14 +0000 (UTC) (envelope-from kato@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 m9R8eDxx032820; Mon, 27 Oct 2008 08:40:13 GMT (envelope-from kato@svn.freebsd.org) Received: (from kato@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R8eDlX032818; Mon, 27 Oct 2008 08:40:13 GMT (envelope-from kato@svn.freebsd.org) Message-Id: <200810270840.m9R8eDlX032818@svn.freebsd.org> From: KATO Takenori Date: Mon, 27 Oct 2008 08:40:13 +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: r184327 - head/sys/pc98/pc98 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: Mon, 27 Oct 2008 08:40:14 -0000 Author: kato Date: Mon Oct 27 08:40:13 2008 New Revision: 184327 URL: http://svn.freebsd.org/changeset/base/184327 Log: Improved IDE HDD geometry adjustment. Previous code didn't work with certain ATA-6 drives including CF cards. The IDE geometry of the PC98 is calculated from the drive capacity. In addition to the algorithm in NEC BIOS, a variety of algorithms are provided by 3'rd party boards and BIOS hacks. This change has implemented the three algorithms: IDE BIOS compatible mode, SCSI BIOS compatible mode and same way as the previous version. The tunable machdep.ad_geom_method selects the algorithm. I have been using this change for a year with CF cards. Reminded by: nyan Modified: head/sys/pc98/pc98/pc98_machdep.c head/sys/pc98/pc98/pc98_machdep.h Modified: head/sys/pc98/pc98/pc98_machdep.c ============================================================================== --- head/sys/pc98/pc98/pc98_machdep.c Mon Oct 27 08:09:05 2008 (r184326) +++ head/sys/pc98/pc98/pc98_machdep.c Mon Oct 27 08:40:13 2008 (r184327) @@ -36,15 +36,23 @@ #include #include -#include -#include #include #include #include +#include +#include +#include +#include #include #include #include +static int ad_geom_method = AD_GEOM_ADJUST_COMPATIDE; + +TUNABLE_INT("machdep.ad_geom_method", &ad_geom_method); +SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RW, &ad_geom_method, 0, + "IDE disk geometry conversion method"); + /* * Initialize DMA controller */ @@ -198,12 +206,62 @@ scsi_da_bios_params(struct ccb_calc_geom } /* - * Get the geometry of the ATA HDD from the BIOS work area. - * - * XXX for now, we hack it + * Adjust the geometry of the IDE HDD. */ -void -pc98_ad_firmware_geom_adjust(device_t dev, struct disk *disk) + +/* IDE BIOS compatible mode. */ +static void +pc98_ad_geom_adjust_idebios(struct disk *disk) +{ + + if (disk->d_mediasize < MEDIASIZE_4_3G) { + disk->d_fwsectors = 17; + disk->d_fwheads = 8; + } else if (disk->d_mediasize < MEDIASIZE_29_5G) { + disk->d_fwsectors = 63; + if (disk->d_fwheads != 15) /* Allow 15H63S. */ + disk->d_fwheads = 16; + } else if (disk->d_mediasize < MEDIASIZE_31_5G) { + disk->d_fwsectors = 63; + disk->d_fwheads = 16; + } else if (disk->d_mediasize < MEDIASIZE_127G) { + disk->d_fwsectors = 255; + disk->d_fwheads = 16; + } else { + /* XXX */ + disk->d_fwsectors = 255; + disk->d_fwheads = 255; + } +} + +/* SCSI BIOS compatible mode. */ +static void +pc98_ad_geom_adjust_scsibios(struct disk *disk) +{ + + if (disk->d_mediasize < MEDIASIZE_8G) { + disk->d_fwsectors = 32; + disk->d_fwheads = 8; + } else if (disk->d_mediasize < MEDIASIZE_32G) { + disk->d_fwsectors = 128; + disk->d_fwheads = 8; + } else if (disk->d_mediasize < MEDIASIZE_60G) { + /* Compatible with IFC-USP 1.2. */ + disk->d_fwsectors = 128; + disk->d_fwheads = 15; + } else if (disk->d_mediasize < MEDIASIZE_120G) { + disk->d_fwsectors = 255; + disk->d_fwheads = 15; + } else { + /* XXX */ + disk->d_fwsectors = 255; + disk->d_fwheads = 255; + } +} + +/* Compatible with the revision 1.28. */ +static void +pc98_ad_geom_adjust_cyl16bit(struct disk *disk) { off_t totsec = disk->d_mediasize / disk->d_sectorsize; off_t cyl = totsec / disk->d_fwsectors / disk->d_fwheads; @@ -229,3 +287,35 @@ pc98_ad_firmware_geom_adjust(device_t de } } } + +void +pc98_ad_firmware_geom_adjust(device_t dev, struct disk *disk) +{ + u_int oldsectors, oldheads; + + oldsectors = disk->d_fwsectors; + oldheads = disk->d_fwheads; + + switch (ad_geom_method) { + case AD_GEOM_ADJUST_COMPATIDE: + pc98_ad_geom_adjust_idebios(disk); + break; + case AD_GEOM_ADJUST_COMPATSCSI: + pc98_ad_geom_adjust_scsibios(disk); + break; + case AD_GEOM_ADJUST_COMPATCYL16: + pc98_ad_geom_adjust_cyl16bit(disk); + break; + default: + /* Do nothing. */ + break; + } + + if (bootverbose && + (oldsectors != disk->d_fwsectors || oldheads != disk->d_fwheads)) + device_printf(dev, + "geometry adjusted from [%dH/%dS] to [%dH/%dS]\n", + oldheads, oldsectors, + disk->d_fwheads, disk->d_fwsectors); + +} Modified: head/sys/pc98/pc98/pc98_machdep.h ============================================================================== --- head/sys/pc98/pc98/pc98_machdep.h Mon Oct 27 08:09:05 2008 (r184326) +++ head/sys/pc98/pc98/pc98_machdep.h Mon Oct 27 08:40:13 2008 (r184327) @@ -85,6 +85,21 @@ extern unsigned char pc98_system_paramet #define EPSON_PC486_SR 0x38 #define EPSON_PC486_HA 0x3b +/* IDE HDD geometry conversion. */ +#define AD_GEOM_ADJUST_NONE 0 /* Do nothing. */ +#define AD_GEOM_ADJUST_COMPATIDE 1 /* PC-98 IDE BIOS. */ +#define AD_GEOM_ADJUST_COMPATSCSI 2 /* PC-98 SCSI. */ +#define AD_GEOM_ADJUST_COMPATCYL16 100 /* Compat Rev. 1.28. */ + +#define MEDIASIZE_4_3G (4351LL * 1024LL * 1024LL) /* 4351M */ +#define MEDIASIZE_8G (8192LL * 1024LL * 1024LL) /* 8192M */ +#define MEDIASIZE_29_5G (30239LL * 1024LL * 1024LL) /* 30239M */ +#define MEDIASIZE_31_5G (32255LL * 1024 * 1024) /* 32255M */ +#define MEDIASIZE_32G (32768LL * 1024LL * 1024LL) /* 32768M */ +#define MEDIASIZE_60G (61440LL * 1024LL * 1024LL) /* 61440M */ +#define MEDIASIZE_120G (122400LL * 1024LL * 1024LL) /* 122400M */ +#define MEDIASIZE_127G (130558LL * 1024LL * 1024LL) /* 130558M */ + #endif /* _KERNEL */ #endif /* __PC98_PC98_PC98_MACHDEP_H__ */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 09:26:24 2008 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 967A0106567E; Mon, 27 Oct 2008 09:26:24 +0000 (UTC) (envelope-from sos@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8625D8FC12; Mon, 27 Oct 2008 09:26:24 +0000 (UTC) (envelope-from sos@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 m9R9QONJ033764; Mon, 27 Oct 2008 09:26:24 GMT (envelope-from sos@svn.freebsd.org) Received: (from sos@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9R9QOZQ033763; Mon, 27 Oct 2008 09:26:24 GMT (envelope-from sos@svn.freebsd.org) Message-Id: <200810270926.m9R9QOZQ033763@svn.freebsd.org> From: Søren Schmidt Date: Mon, 27 Oct 2008 09:26:24 +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: r184328 - head/sys/dev/ata 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: Mon, 27 Oct 2008 09:26:24 -0000 Author: sos Date: Mon Oct 27 09:26:24 2008 New Revision: 184328 URL: http://svn.freebsd.org/changeset/base/184328 Log: Only call dma.unload() if initialized. Reported by: Stanislav Sedov Modified: head/sys/dev/ata/ata-queue.c Modified: head/sys/dev/ata/ata-queue.c ============================================================================== --- head/sys/dev/ata/ata-queue.c Mon Oct 27 08:40:13 2008 (r184327) +++ head/sys/dev/ata/ata-queue.c Mon Oct 27 09:26:24 2008 (r184328) @@ -503,7 +503,8 @@ ata_timeout(struct ata_request *request) request->flags |= ATA_R_TIMEOUT; mtx_unlock(&ch->state_mtx); ATA_LOCKING(ch->dev, ATA_LF_UNLOCK); - ch->dma.unload(request); + if (ch->dma.unload) + ch->dma.unload(request); ata_finish(request); } else { From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 10:32:07 2008 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 AC5DD1065675; Mon, 27 Oct 2008 10:32:07 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by mx1.freebsd.org (Postfix) with ESMTP id 7D48D8FC1C; Mon, 27 Oct 2008 10:32:07 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 0ADBA186D3D; Mon, 27 Oct 2008 06:31:39 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 27 Oct 2008 06:31:40 -0400 X-Sasl-enc: YgrdceUgiHQ1VlkqsGPWfTHl/OGknA0O7j6O6hIIclVC 1225103486 Received: from empiric.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id E5D5F1CA2D; Mon, 27 Oct 2008 06:31:25 -0400 (EDT) Message-ID: <4905987C.5080203@FreeBSD.org> Date: Mon, 27 Oct 2008 10:31:24 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 2.0.0.14 (X11/20080514) MIME-Version: 1.0 To: Warner Losh References: <200810250618.m9P6ICWl023370@svn.freebsd.org> <4902DE9E.2090004@FreeBSD.org> <20081025.202057.74716595.imp@bsdimp.com> In-Reply-To: <20081025.202057.74716595.imp@bsdimp.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, marcel@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys 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: Mon, 27 Oct 2008 10:32:07 -0000 Warner Losh wrote: >> Thanks for bringing this code in. Hopefully it shouldn't be too hard to >> add MTD-like support on top, and/or port it to other parts. >> > > What, exactly, do you mean here? The partitioning stuff, the flash > erase stuff, moving all things through the /dev/mt* or something else? > Well, everything... it's going to take a while to sort through all this without a commercial entity driving things (got bills to pay after all). I guess we need to deal with stuff like block erase at the BIO layer. I know that in previous discussions it has been by suggested by others that GEOM isn't the right place for flash partitioning to be handled, I'm inclined to disagree, as it takes care of a lot of the rigmarole of creating device nodes for each slice, etc, but whoever gets it done, wins the argument, really. From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 11:45:32 2008 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 2F7E7106567E; Mon, 27 Oct 2008 11:45:32 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D0E08FC13; Mon, 27 Oct 2008 11:45:32 +0000 (UTC) (envelope-from ed@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 m9RBjVN2038318; Mon, 27 Oct 2008 11:45:32 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RBjVAY038315; Mon, 27 Oct 2008 11:45:31 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200810271145.m9RBjVAY038315@svn.freebsd.org> From: Ed Schouten Date: Mon, 27 Oct 2008 11:45:31 +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: r184329 - in head/sys: dev/cfe dev/ofw dev/xen/console sys 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: Mon, 27 Oct 2008 11:45:32 -0000 Author: ed Date: Mon Oct 27 11:45:31 2008 New Revision: 184329 URL: http://svn.freebsd.org/changeset/base/184329 Log: Remove unused consdev structure fields. The cn_unit and cn_tp fields don't seem to be used anywhere. Some drivers set them, while others don't. Just remove them, in an attempt to make our consdev code a little easier to understand. Modified: head/sys/dev/cfe/cfe_console.c head/sys/dev/ofw/ofw_console.c head/sys/dev/xen/console/console.c head/sys/sys/cons.h Modified: head/sys/dev/cfe/cfe_console.c ============================================================================== --- head/sys/dev/cfe/cfe_console.c Mon Oct 27 09:26:24 2008 (r184328) +++ head/sys/dev/cfe/cfe_console.c Mon Oct 27 11:45:31 2008 (r184329) @@ -173,8 +173,7 @@ static void cfe_cninit(struct consdev *cp) { - sprintf(cp->cn_name, "cfecons"); - cp->cn_tp = cfe_tp; + strcpy(cp->cn_name, "cfecons"); } static void Modified: head/sys/dev/ofw/ofw_console.c ============================================================================== --- head/sys/dev/ofw/ofw_console.c Mon Oct 27 09:26:24 2008 (r184328) +++ head/sys/dev/ofw/ofw_console.c Mon Oct 27 11:45:31 2008 (r184329) @@ -60,7 +60,6 @@ static struct ttydevsw ofw_ttydevsw = { .tsw_outwakeup = ofwtty_outwakeup, }; -static struct tty *ofw_tp = NULL; static int polltime; static struct callout_handle ofw_timeouthandle = CALLOUT_HANDLE_INITIALIZER(&ofw_timeouthandle); @@ -186,8 +185,7 @@ ofw_cninit(struct consdev *cp) { /* XXX: This is the alias, but that should be good enough */ - sprintf(cp->cn_name, "ofwcons"); - cp->cn_tp = ofw_tp; + strcpy(cp->cn_name, "ofwcons"); } static void Modified: head/sys/dev/xen/console/console.c ============================================================================== --- head/sys/dev/xen/console/console.c Mon Oct 27 09:26:24 2008 (r184328) +++ head/sys/dev/xen/console/console.c Mon Oct 27 11:45:31 2008 (r184329) @@ -107,7 +107,6 @@ static void xccnprobe(struct consdev *cp) { cp->cn_pri = CN_REMOTE; - cp->cn_tp = xccons; sprintf(cp->cn_name, "%s0", driver_name); } Modified: head/sys/sys/cons.h ============================================================================== --- head/sys/sys/cons.h Mon Oct 27 09:26:24 2008 (r184328) +++ head/sys/sys/cons.h Mon Oct 27 11:45:31 2008 (r184329) @@ -61,10 +61,8 @@ struct consdev { /* kernel "return char if available" interface */ cn_putc_t *cn_putc; /* kernel putchar interface */ - struct tty *cn_tp; /* tty structure for console device */ short cn_pri; /* pecking order; the higher the better */ void *cn_arg; /* drivers method argument */ - int cn_unit; /* some drivers prefer this */ int cn_flags; /* capabilities of this console */ char cn_name[SPECNAMELEN + 1]; /* console (device) name */ }; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 11:46:20 2008 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 4D4021065685; Mon, 27 Oct 2008 11:46:20 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 392FE8FC08; Mon, 27 Oct 2008 11:46:20 +0000 (UTC) (envelope-from rwatson@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 m9RBkKNI038370; Mon, 27 Oct 2008 11:46:20 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RBkKZo038368; Mon, 27 Oct 2008 11:46:20 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810271146.m9RBkKZo038368@svn.freebsd.org> From: Robert Watson Date: Mon, 27 Oct 2008 11:46:20 +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: r184330 - head/sys/security/mac_bsdextended 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: Mon, 27 Oct 2008 11:46:20 -0000 Author: rwatson Date: Mon Oct 27 11:46:19 2008 New Revision: 184330 URL: http://svn.freebsd.org/changeset/base/184330 Log: Copy mac_bsdextended.c to two object-specific files as a prototype for how modularize MAC policy layout. Obtained from: TrustedBSD Project Added: head/sys/security/mac_bsdextended/ugidfw_system.c (props changed) - copied unchanged from r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c head/sys/security/mac_bsdextended/ugidfw_vnode.c (props changed) - copied unchanged from r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c Copied: head/sys/security/mac_bsdextended/ugidfw_system.c (from r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/security/mac_bsdextended/ugidfw_system.c Mon Oct 27 11:46:19 2008 (r184330, copy of r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c) @@ -0,0 +1,768 @@ +/*- + * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 2001-2005 Networks Associates Technology, Inc. + * Copyright (c) 2005 Tom Rhodes + * Copyright (c) 2006 SPARTA, Inc. + * All rights reserved. + * + * This software was developed by Robert Watson for the TrustedBSD Project. + * It was later enhanced by Tom Rhodes for the TrustedBSD Project. + * + * This software was developed for the FreeBSD Project in part by Network + * Associates Laboratories, the Security Research Division of Network + * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), + * as part of the DARPA CHATS research program. + * + * This software was enhanced by SPARTA ISSO under SPAWAR contract + * N66001-04-C-6019 ("SEFOS"). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Developed by the TrustedBSD Project. + * + * "BSD Extended" MAC policy, allowing the administrator to impose mandatory + * firewall-like rules regarding users and file system objects. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static struct mtx ugidfw_mtx; + +SYSCTL_DECL(_security_mac); + +SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, + "TrustedBSD extended BSD MAC policy controls"); + +static int ugidfw_enabled = 1; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, + &ugidfw_enabled, 0, "Enforce extended BSD policy"); +TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); + +MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); + +#define MAC_BSDEXTENDED_MAXRULES 250 +static struct mac_bsdextended_rule *rules[MAC_BSDEXTENDED_MAXRULES]; +static int rule_count = 0; +static int rule_slots = 0; +static int rule_version = MB_VERSION; + +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_count, CTLFLAG_RD, + &rule_count, 0, "Number of defined rules\n"); +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_slots, CTLFLAG_RD, + &rule_slots, 0, "Number of used rule slots\n"); +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_version, CTLFLAG_RD, + &rule_version, 0, "Version number for API\n"); + +/* + * This is just used for logging purposes, eventually we would like to log + * much more then failed requests. + */ +static int ugidfw_logging; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, logging, CTLFLAG_RW, + &ugidfw_logging, 0, "Log failed authorization requests"); + +/* + * This tunable is here for compatibility. It will allow the user to switch + * between the new mode (first rule matches) and the old functionality (all + * rules match). + */ +static int ugidfw_firstmatch_enabled; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, firstmatch_enabled, + CTLFLAG_RW, &ugidfw_firstmatch_enabled, 1, + "Disable/enable match first rule functionality"); + +static int +ugidfw_rule_valid(struct mac_bsdextended_rule *rule) +{ + + if ((rule->mbr_subject.mbs_flags | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_subject.mbs_neg | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_flags | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_neg | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_neg | MBO_TYPE_DEFINED) && + (rule->mbr_object.mbo_type | MBO_ALL_TYPE) != MBO_ALL_TYPE) + return (EINVAL); + if ((rule->mbr_mode | MBI_ALLPERM) != MBI_ALLPERM) + return (EINVAL); + return (0); +} + +static int +sysctl_rule(SYSCTL_HANDLER_ARGS) +{ + struct mac_bsdextended_rule temprule, *ruleptr; + u_int namelen; + int error, index, *name; + + error = 0; + name = (int *)arg1; + namelen = arg2; + if (namelen != 1) + return (EINVAL); + index = name[0]; + if (index >= MAC_BSDEXTENDED_MAXRULES) + return (ENOENT); + + ruleptr = NULL; + if (req->newptr && req->newlen != 0) { + error = SYSCTL_IN(req, &temprule, sizeof(temprule)); + if (error) + return (error); + ruleptr = malloc(sizeof(*ruleptr), M_MACBSDEXTENDED, + M_WAITOK | M_ZERO); + } + + mtx_lock(&ugidfw_mtx); + if (req->oldptr) { + if (index < 0 || index > rule_slots + 1) { + error = ENOENT; + goto out; + } + if (rules[index] == NULL) { + error = ENOENT; + goto out; + } + temprule = *rules[index]; + } + if (req->newptr && req->newlen == 0) { + KASSERT(ruleptr == NULL, ("sysctl_rule: ruleptr != NULL")); + ruleptr = rules[index]; + if (ruleptr == NULL) { + error = ENOENT; + goto out; + } + rule_count--; + rules[index] = NULL; + } else if (req->newptr) { + error = ugidfw_rule_valid(&temprule); + if (error) + goto out; + if (rules[index] == NULL) { + *ruleptr = temprule; + rules[index] = ruleptr; + ruleptr = NULL; + if (index + 1 > rule_slots) + rule_slots = index + 1; + rule_count++; + } else + *rules[index] = temprule; + } +out: + mtx_unlock(&ugidfw_mtx); + if (ruleptr != NULL) + free(ruleptr, M_MACBSDEXTENDED); + if (req->oldptr && error == 0) + error = SYSCTL_OUT(req, &temprule, sizeof(temprule)); + return (error); +} + +SYSCTL_NODE(_security_mac_bsdextended, OID_AUTO, rules, CTLFLAG_RW, + sysctl_rule, "BSD extended MAC rules"); + +static void +ugidfw_init(struct mac_policy_conf *mpc) +{ + + mtx_init(&ugidfw_mtx, "mac_bsdextended lock", NULL, MTX_DEF); +} + +static void +ugidfw_destroy(struct mac_policy_conf *mpc) +{ + + mtx_destroy(&ugidfw_mtx); +} + +static int +ugidfw_rulecheck(struct mac_bsdextended_rule *rule, + struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) +{ + int mac_granted, match, priv_granted; + int i; + + /* + * Is there a subject match? + */ + mtx_assert(&ugidfw_mtx, MA_OWNED); + if (rule->mbr_subject.mbs_flags & MBS_UID_DEFINED) { + match = ((cred->cr_uid <= rule->mbr_subject.mbs_uid_max && + cred->cr_uid >= rule->mbr_subject.mbs_uid_min) || + (cred->cr_ruid <= rule->mbr_subject.mbs_uid_max && + cred->cr_ruid >= rule->mbr_subject.mbs_uid_min) || + (cred->cr_svuid <= rule->mbr_subject.mbs_uid_max && + cred->cr_svuid >= rule->mbr_subject.mbs_uid_min)); + if (rule->mbr_subject.mbs_neg & MBS_UID_DEFINED) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_subject.mbs_flags & MBS_GID_DEFINED) { + match = ((cred->cr_rgid <= rule->mbr_subject.mbs_gid_max && + cred->cr_rgid >= rule->mbr_subject.mbs_gid_min) || + (cred->cr_svgid <= rule->mbr_subject.mbs_gid_max && + cred->cr_svgid >= rule->mbr_subject.mbs_gid_min)); + if (!match) { + for (i = 0; i < cred->cr_ngroups; i++) { + if (cred->cr_groups[i] + <= rule->mbr_subject.mbs_gid_max && + cred->cr_groups[i] + >= rule->mbr_subject.mbs_gid_min) { + match = 1; + break; + } + } + } + if (rule->mbr_subject.mbs_neg & MBS_GID_DEFINED) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_subject.mbs_flags & MBS_PRISON_DEFINED) { + match = (cred->cr_prison != NULL && + cred->cr_prison->pr_id == rule->mbr_subject.mbs_prison); + if (rule->mbr_subject.mbs_neg & MBS_PRISON_DEFINED) + match = !match; + if (!match) + return (0); + } + + /* + * Is there an object match? + */ + if (rule->mbr_object.mbo_flags & MBO_UID_DEFINED) { + match = (vap->va_uid <= rule->mbr_object.mbo_uid_max && + vap->va_uid >= rule->mbr_object.mbo_uid_min); + if (rule->mbr_object.mbo_neg & MBO_UID_DEFINED) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_GID_DEFINED) { + match = (vap->va_gid <= rule->mbr_object.mbo_gid_max && + vap->va_gid >= rule->mbr_object.mbo_gid_min); + if (rule->mbr_object.mbo_neg & MBO_GID_DEFINED) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_FSID_DEFINED) { + match = (bcmp(&(vp->v_mount->mnt_stat.f_fsid), + &(rule->mbr_object.mbo_fsid), + sizeof(rule->mbr_object.mbo_fsid)) == 0); + if (rule->mbr_object.mbo_neg & MBO_FSID_DEFINED) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_SUID) { + match = (vap->va_mode & S_ISUID); + if (rule->mbr_object.mbo_neg & MBO_SUID) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_SGID) { + match = (vap->va_mode & S_ISGID); + if (rule->mbr_object.mbo_neg & MBO_SGID) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_UID_SUBJECT) { + match = (vap->va_uid == cred->cr_uid || + vap->va_uid == cred->cr_ruid || + vap->va_uid == cred->cr_svuid); + if (rule->mbr_object.mbo_neg & MBO_UID_SUBJECT) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_GID_SUBJECT) { + match = (groupmember(vap->va_gid, cred) || + vap->va_gid == cred->cr_rgid || + vap->va_gid == cred->cr_svgid); + if (rule->mbr_object.mbo_neg & MBO_GID_SUBJECT) + match = !match; + if (!match) + return (0); + } + + if (rule->mbr_object.mbo_flags & MBO_TYPE_DEFINED) { + switch (vap->va_type) { + case VREG: + match = (rule->mbr_object.mbo_type & MBO_TYPE_REG); + break; + case VDIR: + match = (rule->mbr_object.mbo_type & MBO_TYPE_DIR); + break; + case VBLK: + match = (rule->mbr_object.mbo_type & MBO_TYPE_BLK); + break; + case VCHR: + match = (rule->mbr_object.mbo_type & MBO_TYPE_CHR); + break; + case VLNK: + match = (rule->mbr_object.mbo_type & MBO_TYPE_LNK); + break; + case VSOCK: + match = (rule->mbr_object.mbo_type & MBO_TYPE_SOCK); + break; + case VFIFO: + match = (rule->mbr_object.mbo_type & MBO_TYPE_FIFO); + break; + default: + match = 0; + } + if (rule->mbr_object.mbo_neg & MBO_TYPE_DEFINED) + match = !match; + if (!match) + return (0); + } + + /* + * MBI_APPEND should not be here as it should get converted to + * MBI_WRITE. + */ + priv_granted = 0; + mac_granted = rule->mbr_mode; + if ((acc_mode & MBI_ADMIN) && (mac_granted & MBI_ADMIN) == 0 && + priv_check_cred(cred, PRIV_VFS_ADMIN, 0) == 0) + priv_granted |= MBI_ADMIN; + if ((acc_mode & MBI_EXEC) && (mac_granted & MBI_EXEC) == 0 && + priv_check_cred(cred, (vap->va_type == VDIR) ? PRIV_VFS_LOOKUP : + PRIV_VFS_EXEC, 0) == 0) + priv_granted |= MBI_EXEC; + if ((acc_mode & MBI_READ) && (mac_granted & MBI_READ) == 0 && + priv_check_cred(cred, PRIV_VFS_READ, 0) == 0) + priv_granted |= MBI_READ; + if ((acc_mode & MBI_STAT) && (mac_granted & MBI_STAT) == 0 && + priv_check_cred(cred, PRIV_VFS_STAT, 0) == 0) + priv_granted |= MBI_STAT; + if ((acc_mode & MBI_WRITE) && (mac_granted & MBI_WRITE) == 0 && + priv_check_cred(cred, PRIV_VFS_WRITE, 0) == 0) + priv_granted |= MBI_WRITE; + /* + * Is the access permitted? + */ + if (((mac_granted | priv_granted) & acc_mode) != acc_mode) { + if (ugidfw_logging) + log(LOG_AUTHPRIV, "mac_bsdextended: %d:%d request %d" + " on %d:%d failed. \n", cred->cr_ruid, + cred->cr_rgid, acc_mode, vap->va_uid, + vap->va_gid); + return (EACCES); + } + + /* + * If the rule matched, permits access, and first match is enabled, + * return success. + */ + if (ugidfw_firstmatch_enabled) + return (EJUSTRETURN); + else + return (0); +} + +static int +ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, + int acc_mode) +{ + int error, i; + + /* + * Since we do not separately handle append, map append to write. + */ + if (acc_mode & MBI_APPEND) { + acc_mode &= ~MBI_APPEND; + acc_mode |= MBI_WRITE; + } + mtx_lock(&ugidfw_mtx); + for (i = 0; i < rule_slots; i++) { + if (rules[i] == NULL) + continue; + error = ugidfw_rulecheck(rules[i], cred, + vp, vap, acc_mode); + if (error == EJUSTRETURN) + break; + if (error) { + mtx_unlock(&ugidfw_mtx); + return (error); + } + } + mtx_unlock(&ugidfw_mtx); + return (0); +} + +static int +ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode) +{ + int error; + struct vattr vap; + + if (!ugidfw_enabled) + return (0); + error = VOP_GETATTR(vp, &vap, cred); + if (error) + return (error); + return (ugidfw_check(cred, vp, &vap, acc_mode)); +} + +/* + * Object-specific entry point implementations are sorted alphabetically by + * object type and then by operation. + */ +static int +ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp, + struct label *vplabel) +{ + + if (vp != NULL) + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); + else + return (0); +} + +static int +ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp, + struct label *vplabel) +{ + + if (vp != NULL) + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); + else + return (0); +} + +static int +ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp, + struct label *vplabel) +{ + + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static int +ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int acc_mode) +{ + + return (ugidfw_check_vp(cred, vp, acc_mode)); +} + +static int +ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel) +{ + + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); +} + +static int +ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel) +{ + + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); +} + +static int +ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct componentname *cnp, struct vattr *vap) +{ + + return (ugidfw_check_vp(cred, dvp, MBI_WRITE)); +} + +static int +ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name) +{ + + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static int +ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct image_params *imgp, + struct label *execlabel) +{ + + return (ugidfw_check_vp(cred, vp, MBI_READ|MBI_EXEC)); +} + +static int +ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type) +{ + + return (ugidfw_check_vp(cred, vp, MBI_STAT)); +} + +static int +ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name, + struct uio *uio) +{ + + return (ugidfw_check_vp(cred, vp, MBI_READ)); +} + +static int +ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *label, + struct componentname *cnp) +{ + int error; + + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); + if (error) + return (error); + error = ugidfw_check_vp(cred, vp, MBI_WRITE); + if (error) + return (error); + return (0); +} + +static int +ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace) +{ + + return (ugidfw_check_vp(cred, vp, MBI_READ)); +} + +static int +ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct componentname *cnp) +{ + + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); +} + +static int +ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int acc_mode) +{ + + return (ugidfw_check_vp(cred, vp, acc_mode)); +} + +static int +ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel) +{ + + return (ugidfw_check_vp(cred, dvp, MBI_READ)); +} + +static int +ugidfw_vnode_check_readdlink(struct ucred *cred, struct vnode *vp, + struct label *vplabel) +{ + + return (ugidfw_check_vp(cred, vp, MBI_READ)); +} + +static int +ugidfw_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + struct componentname *cnp) +{ + int error; + + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); + if (error) + return (error); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static int +ugidfw_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + int samedir, struct componentname *cnp) +{ + int error; + + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); + if (error) + return (error); + if (vp != NULL) + error = ugidfw_check_vp(cred, vp, MBI_WRITE); + return (error); +} + +static int +ugidfw_vnode_check_revoke(struct ucred *cred, struct vnode *vp, + struct label *vplabel) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_check_setacl_vnode(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type, struct acl *acl) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name, + struct uio *uio) +{ + + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static int +ugidfw_vnode_check_setflags(struct ucred *cred, struct vnode *vp, + struct label *vplabel, u_long flags) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_setmode(struct ucred *cred, struct vnode *vp, + struct label *vplabel, mode_t mode) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_setowner(struct ucred *cred, struct vnode *vp, + struct label *vplabel, uid_t uid, gid_t gid) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct timespec atime, struct timespec utime) +{ + + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); +} + +static int +ugidfw_vnode_check_stat(struct ucred *active_cred, + struct ucred *file_cred, struct vnode *vp, struct label *vplabel) +{ + + return (ugidfw_check_vp(active_cred, vp, MBI_STAT)); +} + +static int +ugidfw_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + struct componentname *cnp) +{ + int error; + + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); + if (error) + return (error); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static struct mac_policy_ops ugidfw_ops = +{ + .mpo_destroy = ugidfw_destroy, + .mpo_init = ugidfw_init, + .mpo_system_check_acct = ugidfw_system_check_acct, + .mpo_system_check_auditctl = ugidfw_system_check_auditctl, + .mpo_system_check_swapon = ugidfw_system_check_swapon, + .mpo_vnode_check_access = ugidfw_vnode_check_access, + .mpo_vnode_check_chdir = ugidfw_vnode_check_chdir, + .mpo_vnode_check_chroot = ugidfw_vnode_check_chroot, + .mpo_vnode_check_create = ugidfw_check_create_vnode, + .mpo_vnode_check_deleteacl = ugidfw_vnode_check_deleteacl, + .mpo_vnode_check_deleteextattr = ugidfw_vnode_check_deleteextattr, + .mpo_vnode_check_exec = ugidfw_vnode_check_exec, + .mpo_vnode_check_getacl = ugidfw_vnode_check_getacl, + .mpo_vnode_check_getextattr = ugidfw_vnode_check_getextattr, + .mpo_vnode_check_link = ugidfw_vnode_check_link, + .mpo_vnode_check_listextattr = ugidfw_vnode_check_listextattr, + .mpo_vnode_check_lookup = ugidfw_vnode_check_lookup, + .mpo_vnode_check_open = ugidfw_vnode_check_open, + .mpo_vnode_check_readdir = ugidfw_vnode_check_readdir, + .mpo_vnode_check_readlink = ugidfw_vnode_check_readdlink, + .mpo_vnode_check_rename_from = ugidfw_vnode_check_rename_from, + .mpo_vnode_check_rename_to = ugidfw_vnode_check_rename_to, + .mpo_vnode_check_revoke = ugidfw_vnode_check_revoke, + .mpo_vnode_check_setacl = ugidfw_check_setacl_vnode, + .mpo_vnode_check_setextattr = ugidfw_vnode_check_setextattr, + .mpo_vnode_check_setflags = ugidfw_vnode_check_setflags, + .mpo_vnode_check_setmode = ugidfw_vnode_check_setmode, + .mpo_vnode_check_setowner = ugidfw_vnode_check_setowner, + .mpo_vnode_check_setutimes = ugidfw_vnode_check_setutimes, + .mpo_vnode_check_stat = ugidfw_vnode_check_stat, + .mpo_vnode_check_unlink = ugidfw_vnode_check_unlink, +}; + +MAC_POLICY_SET(&ugidfw_ops, mac_bsdextended, "TrustedBSD MAC/BSD Extended", + MPC_LOADTIME_FLAG_UNLOADOK, NULL, 0); Copied: head/sys/security/mac_bsdextended/ugidfw_vnode.c (from r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/security/mac_bsdextended/ugidfw_vnode.c Mon Oct 27 11:46:19 2008 (r184330, copy of r184328, head/sys/security/mac_bsdextended/mac_bsdextended.c) @@ -0,0 +1,768 @@ +/*- + * Copyright (c) 1999-2002, 2007 Robert N. M. Watson + * Copyright (c) 2001-2005 Networks Associates Technology, Inc. + * Copyright (c) 2005 Tom Rhodes + * Copyright (c) 2006 SPARTA, Inc. + * All rights reserved. + * + * This software was developed by Robert Watson for the TrustedBSD Project. + * It was later enhanced by Tom Rhodes for the TrustedBSD Project. + * + * This software was developed for the FreeBSD Project in part by Network + * Associates Laboratories, the Security Research Division of Network + * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), + * as part of the DARPA CHATS research program. + * + * This software was enhanced by SPARTA ISSO under SPAWAR contract + * N66001-04-C-6019 ("SEFOS"). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Developed by the TrustedBSD Project. + * + * "BSD Extended" MAC policy, allowing the administrator to impose mandatory + * firewall-like rules regarding users and file system objects. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static struct mtx ugidfw_mtx; + +SYSCTL_DECL(_security_mac); + +SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, + "TrustedBSD extended BSD MAC policy controls"); + +static int ugidfw_enabled = 1; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, + &ugidfw_enabled, 0, "Enforce extended BSD policy"); +TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); + +MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); + +#define MAC_BSDEXTENDED_MAXRULES 250 +static struct mac_bsdextended_rule *rules[MAC_BSDEXTENDED_MAXRULES]; +static int rule_count = 0; +static int rule_slots = 0; +static int rule_version = MB_VERSION; + +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_count, CTLFLAG_RD, + &rule_count, 0, "Number of defined rules\n"); +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_slots, CTLFLAG_RD, + &rule_slots, 0, "Number of used rule slots\n"); +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_version, CTLFLAG_RD, + &rule_version, 0, "Version number for API\n"); + +/* + * This is just used for logging purposes, eventually we would like to log + * much more then failed requests. + */ +static int ugidfw_logging; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, logging, CTLFLAG_RW, + &ugidfw_logging, 0, "Log failed authorization requests"); + +/* + * This tunable is here for compatibility. It will allow the user to switch + * between the new mode (first rule matches) and the old functionality (all + * rules match). + */ +static int ugidfw_firstmatch_enabled; +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, firstmatch_enabled, + CTLFLAG_RW, &ugidfw_firstmatch_enabled, 1, + "Disable/enable match first rule functionality"); + +static int +ugidfw_rule_valid(struct mac_bsdextended_rule *rule) +{ + + if ((rule->mbr_subject.mbs_flags | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_subject.mbs_neg | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_flags | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_neg | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) + return (EINVAL); + if ((rule->mbr_object.mbo_neg | MBO_TYPE_DEFINED) && + (rule->mbr_object.mbo_type | MBO_ALL_TYPE) != MBO_ALL_TYPE) + return (EINVAL); + if ((rule->mbr_mode | MBI_ALLPERM) != MBI_ALLPERM) + return (EINVAL); + return (0); +} + +static int +sysctl_rule(SYSCTL_HANDLER_ARGS) +{ + struct mac_bsdextended_rule temprule, *ruleptr; + u_int namelen; + int error, index, *name; + + error = 0; + name = (int *)arg1; + namelen = arg2; + if (namelen != 1) + return (EINVAL); + index = name[0]; + if (index >= MAC_BSDEXTENDED_MAXRULES) + return (ENOENT); + + ruleptr = NULL; + if (req->newptr && req->newlen != 0) { + error = SYSCTL_IN(req, &temprule, sizeof(temprule)); + if (error) + return (error); + ruleptr = malloc(sizeof(*ruleptr), M_MACBSDEXTENDED, + M_WAITOK | M_ZERO); + } + + mtx_lock(&ugidfw_mtx); + if (req->oldptr) { + if (index < 0 || index > rule_slots + 1) { + error = ENOENT; + goto out; + } + if (rules[index] == NULL) { + error = ENOENT; + goto out; + } + temprule = *rules[index]; + } + if (req->newptr && req->newlen == 0) { + KASSERT(ruleptr == NULL, ("sysctl_rule: ruleptr != NULL")); + ruleptr = rules[index]; + if (ruleptr == NULL) { + error = ENOENT; + goto out; + } + rule_count--; + rules[index] = NULL; + } else if (req->newptr) { + error = ugidfw_rule_valid(&temprule); + if (error) + goto out; + if (rules[index] == NULL) { + *ruleptr = temprule; + rules[index] = ruleptr; + ruleptr = NULL; + if (index + 1 > rule_slots) + rule_slots = index + 1; + rule_count++; + } else + *rules[index] = temprule; + } +out: + mtx_unlock(&ugidfw_mtx); + if (ruleptr != NULL) + free(ruleptr, M_MACBSDEXTENDED); + if (req->oldptr && error == 0) + error = SYSCTL_OUT(req, &temprule, sizeof(temprule)); + return (error); +} + +SYSCTL_NODE(_security_mac_bsdextended, OID_AUTO, rules, CTLFLAG_RW, + sysctl_rule, "BSD extended MAC rules"); + +static void +ugidfw_init(struct mac_policy_conf *mpc) +{ + + mtx_init(&ugidfw_mtx, "mac_bsdextended lock", NULL, MTX_DEF); +} + +static void +ugidfw_destroy(struct mac_policy_conf *mpc) +{ + + mtx_destroy(&ugidfw_mtx); +} + +static int +ugidfw_rulecheck(struct mac_bsdextended_rule *rule, + struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) +{ + int mac_granted, match, priv_granted; + int i; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 12:09:16 2008 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 71566106569F; Mon, 27 Oct 2008 12:09:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CA6B8FC14; Mon, 27 Oct 2008 12:09:16 +0000 (UTC) (envelope-from rwatson@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 m9RC9GQ7038868; Mon, 27 Oct 2008 12:09:16 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RC9Gu4038863; Mon, 27 Oct 2008 12:09:16 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810271209.m9RC9Gu4038863@svn.freebsd.org> From: Robert Watson Date: Mon, 27 Oct 2008 12:09:16 +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: r184331 - in head/sys: modules/mac_bsdextended security/mac_bsdextended 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: Mon, 27 Oct 2008 12:09:16 -0000 Author: rwatson Date: Mon Oct 27 12:09:15 2008 New Revision: 184331 URL: http://svn.freebsd.org/changeset/base/184331 Log: Break mac_bsdextended.c out into multiple .c files, with the base access control logic and policy registration remaining in that file, and access control checks broken out into other files by class of check. Obtained from: TrustedBSD Project Added: head/sys/security/mac_bsdextended/ugidfw_internal.h (contents, props changed) Modified: head/sys/modules/mac_bsdextended/Makefile head/sys/security/mac_bsdextended/mac_bsdextended.c head/sys/security/mac_bsdextended/ugidfw_system.c head/sys/security/mac_bsdextended/ugidfw_vnode.c Modified: head/sys/modules/mac_bsdextended/Makefile ============================================================================== --- head/sys/modules/mac_bsdextended/Makefile Mon Oct 27 11:46:19 2008 (r184330) +++ head/sys/modules/mac_bsdextended/Makefile Mon Oct 27 12:09:15 2008 (r184331) @@ -4,6 +4,9 @@ KMOD= mac_bsdextended SRCS= vnode_if.h \ - mac_bsdextended.c + mac_bsdextended.h \ + mac_bsdextended.c \ + ugidfw_system.c \ + ugidfw_vnode.c .include Modified: head/sys/security/mac_bsdextended/mac_bsdextended.c ============================================================================== --- head/sys/security/mac_bsdextended/mac_bsdextended.c Mon Oct 27 11:46:19 2008 (r184330) +++ head/sys/security/mac_bsdextended/mac_bsdextended.c Mon Oct 27 12:09:15 2008 (r184331) @@ -65,6 +65,7 @@ #include #include +#include static struct mtx ugidfw_mtx; @@ -415,7 +416,7 @@ ugidfw_rulecheck(struct mac_bsdextended_ return (0); } -static int +int ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) { @@ -445,7 +446,7 @@ ugidfw_check(struct ucred *cred, struct return (0); } -static int +int ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode) { int error; @@ -459,276 +460,6 @@ ugidfw_check_vp(struct ucred *cred, stru return (ugidfw_check(cred, vp, &vap, acc_mode)); } -/* - * Object-specific entry point implementations are sorted alphabetically by - * object type and then by operation. - */ -static int -ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp, - struct label *vplabel) -{ - - if (vp != NULL) - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); - else - return (0); -} - -static int -ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp, - struct label *vplabel) -{ - - if (vp != NULL) - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); - else - return (0); -} - -static int -ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp, - struct label *vplabel) -{ - - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int acc_mode) -{ - - return (ugidfw_check_vp(cred, vp, acc_mode)); -} - -static int -ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct componentname *cnp, struct vattr *vap) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, - struct label *vplabel, acl_type_t type) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace, const char *name) -{ - - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp, - struct label *vplabel, struct image_params *imgp, - struct label *execlabel) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ|MBI_EXEC)); -} - -static int -ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp, - struct label *vplabel, acl_type_t type) -{ - - return (ugidfw_check_vp(cred, vp, MBI_STAT)); -} - -static int -ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace, const char *name, - struct uio *uio) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ)); -} - -static int -ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct vnode *vp, struct label *label, - struct componentname *cnp) -{ - int error; - - error = ugidfw_check_vp(cred, dvp, MBI_WRITE); - if (error) - return (error); - error = ugidfw_check_vp(cred, vp, MBI_WRITE); - if (error) - return (error); - return (0); -} - -static int -ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ)); -} - -static int -ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct componentname *cnp) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int acc_mode) -{ - - return (ugidfw_check_vp(cred, vp, acc_mode)); -} - -static int -ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_READ)); -} - -static int -ugidfw_vnode_check_readdlink(struct ucred *cred, struct vnode *vp, - struct label *vplabel) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ)); -} - -static int -ugidfw_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct vnode *vp, struct label *vplabel, - struct componentname *cnp) -{ - int error; - - error = ugidfw_check_vp(cred, dvp, MBI_WRITE); - if (error) - return (error); - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct vnode *vp, struct label *vplabel, - int samedir, struct componentname *cnp) -{ - int error; - - error = ugidfw_check_vp(cred, dvp, MBI_WRITE); - if (error) - return (error); - if (vp != NULL) - error = ugidfw_check_vp(cred, vp, MBI_WRITE); - return (error); -} - -static int -ugidfw_vnode_check_revoke(struct ucred *cred, struct vnode *vp, - struct label *vplabel) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_check_setacl_vnode(struct ucred *cred, struct vnode *vp, - struct label *vplabel, acl_type_t type, struct acl *acl) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace, const char *name, - struct uio *uio) -{ - - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_setflags(struct ucred *cred, struct vnode *vp, - struct label *vplabel, u_long flags) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_setmode(struct ucred *cred, struct vnode *vp, - struct label *vplabel, mode_t mode) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_setowner(struct ucred *cred, struct vnode *vp, - struct label *vplabel, uid_t uid, gid_t gid) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, - struct label *vplabel, struct timespec atime, struct timespec utime) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_stat(struct ucred *active_cred, - struct ucred *file_cred, struct vnode *vp, struct label *vplabel) -{ - - return (ugidfw_check_vp(active_cred, vp, MBI_STAT)); -} - -static int -ugidfw_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct vnode *vp, struct label *vplabel, - struct componentname *cnp) -{ - int error; - - error = ugidfw_check_vp(cred, dvp, MBI_WRITE); - if (error) - return (error); - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - static struct mac_policy_ops ugidfw_ops = { .mpo_destroy = ugidfw_destroy, Added: head/sys/security/mac_bsdextended/ugidfw_internal.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/security/mac_bsdextended/ugidfw_internal.h Mon Oct 27 12:09:15 2008 (r184331) @@ -0,0 +1,115 @@ +/*- + * Copyright (c) 2008 Robert N. M. Watson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H +#define _SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H + +/* + * Central access control routines used by object-specific checks. + */ +int ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, + int acc_mode); +int ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode); + +/* + * System access control checks. + */ +int ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp, + struct label *vplabel); +int ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp, + struct label *vplabel); +int ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp, + struct label *vplabel); + +/* + * Vnode access control checks. + */ +int ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int acc_mode); +int ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel); +int ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel); +int ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct componentname *cnp, + struct vattr *vap); +int ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type); +int ugidfw_vnode_check_deleteextattr(struct ucred *cred, + struct vnode *vp, struct label *vplabel, int attrnamespace, + const char *name); +int ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct image_params *imgp, + struct label *execlabel); +int ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type); +int ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name, + struct uio *uio); +int ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *label, + struct componentname *cnp); +int ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace); +int ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct componentname *cnp); +int ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int acc_mode); +int ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel); +int ugidfw_vnode_check_readdlink(struct ucred *cred, struct vnode *vp, + struct label *vplabel); +int ugidfw_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + struct componentname *cnp); +int ugidfw_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + int samedir, struct componentname *cnp); +int ugidfw_vnode_check_revoke(struct ucred *cred, struct vnode *vp, + struct label *vplabel); +int ugidfw_check_setacl_vnode(struct ucred *cred, struct vnode *vp, + struct label *vplabel, acl_type_t type, struct acl *acl); +int ugidfw_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name, + struct uio *uio); +int ugidfw_vnode_check_setflags(struct ucred *cred, struct vnode *vp, + struct label *vplabel, u_long flags); +int ugidfw_vnode_check_setmode(struct ucred *cred, struct vnode *vp, + struct label *vplabel, mode_t mode); +int ugidfw_vnode_check_setowner(struct ucred *cred, struct vnode *vp, + struct label *vplabel, uid_t uid, gid_t gid); +int ugidfw_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, + struct label *vplabel, struct timespec atime, + struct timespec utime); +int ugidfw_vnode_check_stat(struct ucred *active_cred, + struct ucred *file_cred, struct vnode *vp, struct label *vplabel); +int ugidfw_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct vnode *vp, struct label *vplabel, + struct componentname *cnp); + +#endif /* _SYS_SECURITY_MAC_BSDEXTENDED_UGIDFW_INTERNAL_H */ Modified: head/sys/security/mac_bsdextended/ugidfw_system.c ============================================================================== --- head/sys/security/mac_bsdextended/ugidfw_system.c Mon Oct 27 11:46:19 2008 (r184330) +++ head/sys/security/mac_bsdextended/ugidfw_system.c Mon Oct 27 12:09:15 2008 (r184331) @@ -40,13 +40,6 @@ * $FreeBSD$ */ -/* - * Developed by the TrustedBSD Project. - * - * "BSD Extended" MAC policy, allowing the administrator to impose mandatory - * firewall-like rules regarding users and file system objects. - */ - #include #include #include @@ -65,405 +58,9 @@ #include #include +#include -static struct mtx ugidfw_mtx; - -SYSCTL_DECL(_security_mac); - -SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, - "TrustedBSD extended BSD MAC policy controls"); - -static int ugidfw_enabled = 1; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, - &ugidfw_enabled, 0, "Enforce extended BSD policy"); -TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); - -MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); - -#define MAC_BSDEXTENDED_MAXRULES 250 -static struct mac_bsdextended_rule *rules[MAC_BSDEXTENDED_MAXRULES]; -static int rule_count = 0; -static int rule_slots = 0; -static int rule_version = MB_VERSION; - -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_count, CTLFLAG_RD, - &rule_count, 0, "Number of defined rules\n"); -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_slots, CTLFLAG_RD, - &rule_slots, 0, "Number of used rule slots\n"); -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_version, CTLFLAG_RD, - &rule_version, 0, "Version number for API\n"); - -/* - * This is just used for logging purposes, eventually we would like to log - * much more then failed requests. - */ -static int ugidfw_logging; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, logging, CTLFLAG_RW, - &ugidfw_logging, 0, "Log failed authorization requests"); - -/* - * This tunable is here for compatibility. It will allow the user to switch - * between the new mode (first rule matches) and the old functionality (all - * rules match). - */ -static int ugidfw_firstmatch_enabled; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, firstmatch_enabled, - CTLFLAG_RW, &ugidfw_firstmatch_enabled, 1, - "Disable/enable match first rule functionality"); - -static int -ugidfw_rule_valid(struct mac_bsdextended_rule *rule) -{ - - if ((rule->mbr_subject.mbs_flags | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) - return (EINVAL); - if ((rule->mbr_subject.mbs_neg | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) - return (EINVAL); - if ((rule->mbr_object.mbo_flags | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) - return (EINVAL); - if ((rule->mbr_object.mbo_neg | MBO_ALL_FLAGS) != MBO_ALL_FLAGS) - return (EINVAL); - if ((rule->mbr_object.mbo_neg | MBO_TYPE_DEFINED) && - (rule->mbr_object.mbo_type | MBO_ALL_TYPE) != MBO_ALL_TYPE) - return (EINVAL); - if ((rule->mbr_mode | MBI_ALLPERM) != MBI_ALLPERM) - return (EINVAL); - return (0); -} - -static int -sysctl_rule(SYSCTL_HANDLER_ARGS) -{ - struct mac_bsdextended_rule temprule, *ruleptr; - u_int namelen; - int error, index, *name; - - error = 0; - name = (int *)arg1; - namelen = arg2; - if (namelen != 1) - return (EINVAL); - index = name[0]; - if (index >= MAC_BSDEXTENDED_MAXRULES) - return (ENOENT); - - ruleptr = NULL; - if (req->newptr && req->newlen != 0) { - error = SYSCTL_IN(req, &temprule, sizeof(temprule)); - if (error) - return (error); - ruleptr = malloc(sizeof(*ruleptr), M_MACBSDEXTENDED, - M_WAITOK | M_ZERO); - } - - mtx_lock(&ugidfw_mtx); - if (req->oldptr) { - if (index < 0 || index > rule_slots + 1) { - error = ENOENT; - goto out; - } - if (rules[index] == NULL) { - error = ENOENT; - goto out; - } - temprule = *rules[index]; - } - if (req->newptr && req->newlen == 0) { - KASSERT(ruleptr == NULL, ("sysctl_rule: ruleptr != NULL")); - ruleptr = rules[index]; - if (ruleptr == NULL) { - error = ENOENT; - goto out; - } - rule_count--; - rules[index] = NULL; - } else if (req->newptr) { - error = ugidfw_rule_valid(&temprule); - if (error) - goto out; - if (rules[index] == NULL) { - *ruleptr = temprule; - rules[index] = ruleptr; - ruleptr = NULL; - if (index + 1 > rule_slots) - rule_slots = index + 1; - rule_count++; - } else - *rules[index] = temprule; - } -out: - mtx_unlock(&ugidfw_mtx); - if (ruleptr != NULL) - free(ruleptr, M_MACBSDEXTENDED); - if (req->oldptr && error == 0) - error = SYSCTL_OUT(req, &temprule, sizeof(temprule)); - return (error); -} - -SYSCTL_NODE(_security_mac_bsdextended, OID_AUTO, rules, CTLFLAG_RW, - sysctl_rule, "BSD extended MAC rules"); - -static void -ugidfw_init(struct mac_policy_conf *mpc) -{ - - mtx_init(&ugidfw_mtx, "mac_bsdextended lock", NULL, MTX_DEF); -} - -static void -ugidfw_destroy(struct mac_policy_conf *mpc) -{ - - mtx_destroy(&ugidfw_mtx); -} - -static int -ugidfw_rulecheck(struct mac_bsdextended_rule *rule, - struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) -{ - int mac_granted, match, priv_granted; - int i; - - /* - * Is there a subject match? - */ - mtx_assert(&ugidfw_mtx, MA_OWNED); - if (rule->mbr_subject.mbs_flags & MBS_UID_DEFINED) { - match = ((cred->cr_uid <= rule->mbr_subject.mbs_uid_max && - cred->cr_uid >= rule->mbr_subject.mbs_uid_min) || - (cred->cr_ruid <= rule->mbr_subject.mbs_uid_max && - cred->cr_ruid >= rule->mbr_subject.mbs_uid_min) || - (cred->cr_svuid <= rule->mbr_subject.mbs_uid_max && - cred->cr_svuid >= rule->mbr_subject.mbs_uid_min)); - if (rule->mbr_subject.mbs_neg & MBS_UID_DEFINED) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_subject.mbs_flags & MBS_GID_DEFINED) { - match = ((cred->cr_rgid <= rule->mbr_subject.mbs_gid_max && - cred->cr_rgid >= rule->mbr_subject.mbs_gid_min) || - (cred->cr_svgid <= rule->mbr_subject.mbs_gid_max && - cred->cr_svgid >= rule->mbr_subject.mbs_gid_min)); - if (!match) { - for (i = 0; i < cred->cr_ngroups; i++) { - if (cred->cr_groups[i] - <= rule->mbr_subject.mbs_gid_max && - cred->cr_groups[i] - >= rule->mbr_subject.mbs_gid_min) { - match = 1; - break; - } - } - } - if (rule->mbr_subject.mbs_neg & MBS_GID_DEFINED) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_subject.mbs_flags & MBS_PRISON_DEFINED) { - match = (cred->cr_prison != NULL && - cred->cr_prison->pr_id == rule->mbr_subject.mbs_prison); - if (rule->mbr_subject.mbs_neg & MBS_PRISON_DEFINED) - match = !match; - if (!match) - return (0); - } - - /* - * Is there an object match? - */ - if (rule->mbr_object.mbo_flags & MBO_UID_DEFINED) { - match = (vap->va_uid <= rule->mbr_object.mbo_uid_max && - vap->va_uid >= rule->mbr_object.mbo_uid_min); - if (rule->mbr_object.mbo_neg & MBO_UID_DEFINED) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_GID_DEFINED) { - match = (vap->va_gid <= rule->mbr_object.mbo_gid_max && - vap->va_gid >= rule->mbr_object.mbo_gid_min); - if (rule->mbr_object.mbo_neg & MBO_GID_DEFINED) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_FSID_DEFINED) { - match = (bcmp(&(vp->v_mount->mnt_stat.f_fsid), - &(rule->mbr_object.mbo_fsid), - sizeof(rule->mbr_object.mbo_fsid)) == 0); - if (rule->mbr_object.mbo_neg & MBO_FSID_DEFINED) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_SUID) { - match = (vap->va_mode & S_ISUID); - if (rule->mbr_object.mbo_neg & MBO_SUID) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_SGID) { - match = (vap->va_mode & S_ISGID); - if (rule->mbr_object.mbo_neg & MBO_SGID) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_UID_SUBJECT) { - match = (vap->va_uid == cred->cr_uid || - vap->va_uid == cred->cr_ruid || - vap->va_uid == cred->cr_svuid); - if (rule->mbr_object.mbo_neg & MBO_UID_SUBJECT) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_GID_SUBJECT) { - match = (groupmember(vap->va_gid, cred) || - vap->va_gid == cred->cr_rgid || - vap->va_gid == cred->cr_svgid); - if (rule->mbr_object.mbo_neg & MBO_GID_SUBJECT) - match = !match; - if (!match) - return (0); - } - - if (rule->mbr_object.mbo_flags & MBO_TYPE_DEFINED) { - switch (vap->va_type) { - case VREG: - match = (rule->mbr_object.mbo_type & MBO_TYPE_REG); - break; - case VDIR: - match = (rule->mbr_object.mbo_type & MBO_TYPE_DIR); - break; - case VBLK: - match = (rule->mbr_object.mbo_type & MBO_TYPE_BLK); - break; - case VCHR: - match = (rule->mbr_object.mbo_type & MBO_TYPE_CHR); - break; - case VLNK: - match = (rule->mbr_object.mbo_type & MBO_TYPE_LNK); - break; - case VSOCK: - match = (rule->mbr_object.mbo_type & MBO_TYPE_SOCK); - break; - case VFIFO: - match = (rule->mbr_object.mbo_type & MBO_TYPE_FIFO); - break; - default: - match = 0; - } - if (rule->mbr_object.mbo_neg & MBO_TYPE_DEFINED) - match = !match; - if (!match) - return (0); - } - - /* - * MBI_APPEND should not be here as it should get converted to - * MBI_WRITE. - */ - priv_granted = 0; - mac_granted = rule->mbr_mode; - if ((acc_mode & MBI_ADMIN) && (mac_granted & MBI_ADMIN) == 0 && - priv_check_cred(cred, PRIV_VFS_ADMIN, 0) == 0) - priv_granted |= MBI_ADMIN; - if ((acc_mode & MBI_EXEC) && (mac_granted & MBI_EXEC) == 0 && - priv_check_cred(cred, (vap->va_type == VDIR) ? PRIV_VFS_LOOKUP : - PRIV_VFS_EXEC, 0) == 0) - priv_granted |= MBI_EXEC; - if ((acc_mode & MBI_READ) && (mac_granted & MBI_READ) == 0 && - priv_check_cred(cred, PRIV_VFS_READ, 0) == 0) - priv_granted |= MBI_READ; - if ((acc_mode & MBI_STAT) && (mac_granted & MBI_STAT) == 0 && - priv_check_cred(cred, PRIV_VFS_STAT, 0) == 0) - priv_granted |= MBI_STAT; - if ((acc_mode & MBI_WRITE) && (mac_granted & MBI_WRITE) == 0 && - priv_check_cred(cred, PRIV_VFS_WRITE, 0) == 0) - priv_granted |= MBI_WRITE; - /* - * Is the access permitted? - */ - if (((mac_granted | priv_granted) & acc_mode) != acc_mode) { - if (ugidfw_logging) - log(LOG_AUTHPRIV, "mac_bsdextended: %d:%d request %d" - " on %d:%d failed. \n", cred->cr_ruid, - cred->cr_rgid, acc_mode, vap->va_uid, - vap->va_gid); - return (EACCES); - } - - /* - * If the rule matched, permits access, and first match is enabled, - * return success. - */ - if (ugidfw_firstmatch_enabled) - return (EJUSTRETURN); - else - return (0); -} - -static int -ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, - int acc_mode) -{ - int error, i; - - /* - * Since we do not separately handle append, map append to write. - */ - if (acc_mode & MBI_APPEND) { - acc_mode &= ~MBI_APPEND; - acc_mode |= MBI_WRITE; - } - mtx_lock(&ugidfw_mtx); - for (i = 0; i < rule_slots; i++) { - if (rules[i] == NULL) - continue; - error = ugidfw_rulecheck(rules[i], cred, - vp, vap, acc_mode); - if (error == EJUSTRETURN) - break; - if (error) { - mtx_unlock(&ugidfw_mtx); - return (error); - } - } - mtx_unlock(&ugidfw_mtx); - return (0); -} - -static int -ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode) -{ - int error; - struct vattr vap; - - if (!ugidfw_enabled) - return (0); - error = VOP_GETATTR(vp, &vap, cred); - if (error) - return (error); - return (ugidfw_check(cred, vp, &vap, acc_mode)); -} - -/* - * Object-specific entry point implementations are sorted alphabetically by - * object type and then by operation. - */ -static int +int ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -474,7 +71,7 @@ ugidfw_system_check_acct(struct ucred *c return (0); } -static int +int ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -485,284 +82,10 @@ ugidfw_system_check_auditctl(struct ucre return (0); } -static int +int ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } - -static int -ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int acc_mode) -{ - - return (ugidfw_check_vp(cred, vp, acc_mode)); -} - -static int -ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct componentname *cnp, struct vattr *vap) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, - struct label *vplabel, acl_type_t type) -{ - - return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); -} - -static int -ugidfw_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace, const char *name) -{ - - return (ugidfw_check_vp(cred, vp, MBI_WRITE)); -} - -static int -ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp, - struct label *vplabel, struct image_params *imgp, - struct label *execlabel) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ|MBI_EXEC)); -} - -static int -ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp, - struct label *vplabel, acl_type_t type) -{ - - return (ugidfw_check_vp(cred, vp, MBI_STAT)); -} - -static int -ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace, const char *name, - struct uio *uio) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ)); -} - -static int -ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct vnode *vp, struct label *label, - struct componentname *cnp) -{ - int error; - - error = ugidfw_check_vp(cred, dvp, MBI_WRITE); - if (error) - return (error); - error = ugidfw_check_vp(cred, vp, MBI_WRITE); - if (error) - return (error); - return (0); -} - -static int -ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int attrnamespace) -{ - - return (ugidfw_check_vp(cred, vp, MBI_READ)); -} - -static int -ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct componentname *cnp) -{ - - return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); -} - -static int -ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int acc_mode) -{ - - return (ugidfw_check_vp(cred, vp, acc_mode)); -} - -static int -ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 12:12:24 2008 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 579101065676; Mon, 27 Oct 2008 12:12:24 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 456A48FC24; Mon, 27 Oct 2008 12:12:24 +0000 (UTC) (envelope-from rwatson@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 m9RCCNlG038967; Mon, 27 Oct 2008 12:12:23 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RCCNga038966; Mon, 27 Oct 2008 12:12:23 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810271212.m9RCCNga038966@svn.freebsd.org> From: Robert Watson Date: Mon, 27 Oct 2008 12:12:23 +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: r184332 - head/sys/security/mac_bsdextended 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: Mon, 27 Oct 2008 12:12:24 -0000 Author: rwatson Date: Mon Oct 27 12:12:23 2008 New Revision: 184332 URL: http://svn.freebsd.org/changeset/base/184332 Log: Add TrustedBSD credit to new ugidfw_internal.h file. Modified: head/sys/security/mac_bsdextended/ugidfw_internal.h Modified: head/sys/security/mac_bsdextended/ugidfw_internal.h ============================================================================== --- head/sys/security/mac_bsdextended/ugidfw_internal.h Mon Oct 27 12:09:15 2008 (r184331) +++ head/sys/security/mac_bsdextended/ugidfw_internal.h Mon Oct 27 12:12:23 2008 (r184332) @@ -2,6 +2,8 @@ * Copyright (c) 2008 Robert N. M. Watson * All rights reserved. * + * This software was developed by Robert Watson for the TrustedBSD Project. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 12:56:46 2008 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 553D0106566C; Mon, 27 Oct 2008 12:56:46 +0000 (UTC) (envelope-from stas@ht-systems.ru) Received: from smtp.ht-systems.ru (mr0.ht-systems.ru [78.110.50.55]) by mx1.freebsd.org (Postfix) with ESMTP id 049458FC1B; Mon, 27 Oct 2008 12:56:45 +0000 (UTC) (envelope-from stas@ht-systems.ru) Received: from [78.110.49.49] (helo=quasar.ht-systems.ru) by smtp.ht-systems.ru with esmtpa (Exim 4.62) (envelope-from ) id 1KuRI2-0002L0-Pr; Mon, 27 Oct 2008 15:33:46 +0300 Received: by quasar.ht-systems.ru (Postfix, from userid 1024) id B0B6273023; Mon, 27 Oct 2008 15:33:45 +0300 (MSK) Date: Mon, 27 Oct 2008 15:33:45 +0300 From: Stanislav Sedov To: Marcel Moolenaar Message-Id: <20081027153345.d4e9dcad.stas@FreeBSD.org> In-Reply-To: <200810250618.m9P6ICWl023370@svn.freebsd.org> References: <200810250618.m9P6ICWl023370@svn.freebsd.org> Organization: The FreeBSD Project X-XMPP: ssedov@jabber.ru X-Voice: +7 916 849 20 23 X-PGP-Fingerprint: F21E D6CC 5626 9609 6CE2 A385 2BF5 5993 EB26 9581 X-Mailer: carrier-pigeon Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Mon__27_Oct_2008_15_33_45_+0300_iW_bfaa=sdp+hUmy" Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys 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: Mon, 27 Oct 2008 12:56:46 -0000 --Signature=_Mon__27_Oct_2008_15_33_45_+0300_iW_bfaa=sdp+hUmy Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, 25 Oct 2008 06:18:12 +0000 (UTC) Marcel Moolenaar mentioned: > Author: marcel > Date: Sat Oct 25 06:18:12 2008 > New Revision: 184251 > URL: http://svn.freebsd.org/changeset/base/184251 >=20 > Log: > Add a driver for flash memory that implements to the Common Flash > Memory Interface (CFI). The flash memory can be read and written > to through /dev/cfi# and an ioctl() exists so processes can read > the query information. > The driver supports the AMD and Intel command set, though only > the AMD command has been tested. > =20 > Obtained from: Juniper Networks, Inc. Do you plan to introduce some infrastructure so other flash-like drivers could be attached (e.g. non-CFI compliant, SPI flashes, etc)? I've started working on such thing and don't want to do the duplicate works, so if you have something in mind it's time to share:-) And thanks for this great work! --=20 Stanislav Sedov ST4096-RIPE --Signature=_Mon__27_Oct_2008_15_33_45_+0300_iW_bfaa=sdp+hUmy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkkFtSkACgkQK/VZk+smlYG6xwCeLHIByP6sf8i1V8dJ+snWwoPc boUAn0WPzvJkJgNGsrcp50wWafIkO6oy =r24C -----END PGP SIGNATURE----- --Signature=_Mon__27_Oct_2008_15_33_45_+0300_iW_bfaa=sdp+hUmy-- From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 13:53:31 2008 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 D943C1065671; Mon, 27 Oct 2008 13:53:31 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7F968FC2D; Mon, 27 Oct 2008 13:53:31 +0000 (UTC) (envelope-from rrs@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 m9RDrVKa040959; Mon, 27 Oct 2008 13:53:31 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RDrVvp040957; Mon, 27 Oct 2008 13:53:31 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200810271353.m9RDrVvp040957@svn.freebsd.org> From: Randall Stewart Date: Mon, 27 Oct 2008 13:53:31 +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: r184333 - head/sys/netinet 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: Mon, 27 Oct 2008 13:53:32 -0000 Author: rrs Date: Mon Oct 27 13:53:31 2008 New Revision: 184333 URL: http://svn.freebsd.org/changeset/base/184333 Log: Invariants changes that make more sense. Modified: head/sys/netinet/sctp_timer.c head/sys/netinet/sctp_timer.h Modified: head/sys/netinet/sctp_timer.c ============================================================================== --- head/sys/netinet/sctp_timer.c Mon Oct 27 12:12:23 2008 (r184332) +++ head/sys/netinet/sctp_timer.c Mon Oct 27 13:53:31 2008 (r184333) @@ -561,7 +561,8 @@ sctp_backoff_on_timeout(struct sctp_tcb } } -void +#ifndef INVARIANTS +static void sctp_recover_sent_list(struct sctp_tcb *stcb) { struct sctp_tmit_chunk *chk, *tp2; @@ -604,6 +605,8 @@ sctp_recover_sent_list(struct sctp_tcb * } } +#endif + static int sctp_mark_all_for_resend(struct sctp_tcb *stcb, struct sctp_nets *net, @@ -679,7 +682,9 @@ sctp_mark_all_for_resend(struct sctp_tcb /* Now on to each chunk */ num_mk = cnt_mk = 0; tsnfirst = tsnlast = 0; +#ifndef INVARIANTS start_again: +#endif chk = TAILQ_FIRST(&stcb->asoc.sent_queue); for (; chk != NULL; chk = tp2) { tp2 = TAILQ_NEXT(chk, sctp_next); @@ -693,8 +698,6 @@ start_again: recovery_cnt++; #ifdef INVARIANTS panic("last acked >= chk on sent-Q"); - /* to keep compiler happy */ - goto start_again; #else SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt); sctp_recover_sent_list(stcb); Modified: head/sys/netinet/sctp_timer.h ============================================================================== --- head/sys/netinet/sctp_timer.h Mon Oct 27 12:12:23 2008 (r184332) +++ head/sys/netinet/sctp_timer.h Mon Oct 27 13:53:31 2008 (r184333) @@ -99,8 +99,6 @@ void sctp_audit_retranmission_queue(stru void sctp_iterator_timer(struct sctp_iterator *it); -void sctp_recover_sent_list(struct sctp_tcb *stcb); - #endif #endif From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 13:54:54 2008 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 8346B1065676; Mon, 27 Oct 2008 13:54:54 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71F1B8FC0C; Mon, 27 Oct 2008 13:54:54 +0000 (UTC) (envelope-from rrs@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 m9RDssbO041037; Mon, 27 Oct 2008 13:54:54 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RDssD3041036; Mon, 27 Oct 2008 13:54:54 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200810271354.m9RDssD3041036@svn.freebsd.org> From: Randall Stewart Date: Mon, 27 Oct 2008 13:54:54 +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: r184334 - head/sys/netinet 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: Mon, 27 Oct 2008 13:54:54 -0000 Author: rrs Date: Mon Oct 27 13:54:54 2008 New Revision: 184334 URL: http://svn.freebsd.org/changeset/base/184334 Log: Get rid of ifdef for vimage on version 8 comparison. Now the scrubbing program properly takes care of this. Modified: head/sys/netinet/sctp_os_bsd.h Modified: head/sys/netinet/sctp_os_bsd.h ============================================================================== --- head/sys/netinet/sctp_os_bsd.h Mon Oct 27 13:53:31 2008 (r184333) +++ head/sys/netinet/sctp_os_bsd.h Mon Oct 27 13:54:54 2008 (r184334) @@ -61,9 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#if defined(__FreeBSD__) && __FreeBSD_version >= 800044 #include -#endif #include #include From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 14:01:23 2008 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 A9B5A1065670; Mon, 27 Oct 2008 14:01:23 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 980818FC22; Mon, 27 Oct 2008 14:01:23 +0000 (UTC) (envelope-from rrs@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 m9RE1N8n041282; Mon, 27 Oct 2008 14:01:23 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RE1NGF041281; Mon, 27 Oct 2008 14:01:23 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200810271401.m9RE1NGF041281@svn.freebsd.org> From: Randall Stewart Date: Mon, 27 Oct 2008 14:01:23 +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: r184336 - head/sys/netinet 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: Mon, 27 Oct 2008 14:01:23 -0000 Author: rrs Date: Mon Oct 27 14:01:23 2008 New Revision: 184336 URL: http://svn.freebsd.org/changeset/base/184336 Log: Two inter-related bugs. - If we send EXACTLY the size left in the send buffer and then send again, we end up with exactly 0 bytes and don't hit the pre-block code to wait for more space. - If we fall into the loop with our max_len == 0 (the bug above) we then call in to copy out the data, setup the length of the waiting to transmit data to 0 and call the mbuf copy routine which 0 indicates copy all the data to the mbuf chain.. which it does. This then leaves a "stuck" message on the stream queue with its size exactly 0 bytes but all the data there and thus nothing left in the uio structure. We then reach a stuck forever state never being able to send data. Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Mon Oct 27 13:56:27 2008 (r184335) +++ head/sys/netinet/sctp_output.c Mon Oct 27 14:01:23 2008 (r184336) @@ -11682,7 +11682,12 @@ sctp_copy_it_in(struct sctp_tcb *stcb, sp->put_last_out = 0; resv_in_first = sizeof(struct sctp_data_chunk); sp->data = sp->tail_mbuf = NULL; + if (sp->length == 0) { + *error = 0; + goto skip_copy; + } *error = sctp_copy_one(sp, uio, resv_in_first); +skip_copy: if (*error) { sctp_free_a_strmoq(stcb, sp); sp = NULL; @@ -12443,7 +12448,8 @@ sctp_lower_sosend(struct socket *so, goto skip_preblock; } if (((max_len <= local_add_more) && - (SCTP_SB_LIMIT_SND(so) > local_add_more)) || + (SCTP_SB_LIMIT_SND(so) >= local_add_more)) || + (max_len == 0) || ((stcb->asoc.chunks_on_out_queue + stcb->asoc.stream_queue_cnt) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) { /* if */ /* No room right now ! */ SOCKBUF_LOCK(&so->so_snd); @@ -13058,7 +13064,7 @@ skip_out_eof: (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, &reason, 1, &cwnd_full, 1, &now, &now_filled, frag_point, SCTP_SO_LOCKED); } - SCTPDBG(SCTP_DEBUG_OUTPUT1, "USR Send complete qo:%d prw:%d unsent:%d tf:%d cooq:%d toqs:%d err:%d", + SCTPDBG(SCTP_DEBUG_OUTPUT1, "USR Send complete qo:%d prw:%d unsent:%d tf:%d cooq:%d toqs:%d err:%d\n", queue_only, stcb->asoc.peers_rwnd, un_sent, stcb->asoc.total_flight, stcb->asoc.chunks_on_out_queue, stcb->asoc.total_output_queue_size, error); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 14:49:13 2008 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 2B4981065672; Mon, 27 Oct 2008 14:49:13 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1A2438FC0A; Mon, 27 Oct 2008 14:49:13 +0000 (UTC) (envelope-from rrs@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 m9REnCxs042438; Mon, 27 Oct 2008 14:49:12 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9REnCsd042437; Mon, 27 Oct 2008 14:49:12 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200810271449.m9REnCsd042437@svn.freebsd.org> From: Randall Stewart Date: Mon, 27 Oct 2008 14:49:12 +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: r184340 - head/sys/netinet 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: Mon, 27 Oct 2008 14:49:13 -0000 Author: rrs Date: Mon Oct 27 14:49:12 2008 New Revision: 184340 URL: http://svn.freebsd.org/changeset/base/184340 Log: More issues with pre-blocking: a) Need for EEOR mode to take the min of the socket buffer size and the add more threshold, otherwise if you are so silly as to set a send buf size less than the add-more you could block forever in eeor mode. b) We were incorrectly using the sysctl vs the calculated value. This causes us to block forever if the addmore theshold is larger than then the socket buffer size. Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Mon Oct 27 14:29:49 2008 (r184339) +++ head/sys/netinet/sctp_output.c Mon Oct 27 14:49:12 2008 (r184340) @@ -12435,7 +12435,7 @@ sctp_lower_sosend(struct socket *so, goto out_unlocked; } if (user_marks_eor) { - local_add_more = SCTP_BASE_SYSCTL(sctp_add_more_threshold); + local_add_more = min(SCTP_SB_LIMIT_SND(so), SCTP_BASE_SYSCTL(sctp_add_more_threshold)); } else { /*- * For non-eeor the whole message must fit in @@ -12454,9 +12454,15 @@ sctp_lower_sosend(struct socket *so, /* No room right now ! */ SOCKBUF_LOCK(&so->so_snd); inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * sizeof(struct sctp_data_chunk)); - while ((SCTP_SB_LIMIT_SND(so) < (inqueue_bytes + SCTP_BASE_SYSCTL(sctp_add_more_threshold))) || - ((stcb->asoc.stream_queue_cnt + stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) /* while */ )) { - + while ((SCTP_SB_LIMIT_SND(so) < (inqueue_bytes + local_add_more)) || + ((stcb->asoc.stream_queue_cnt + stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue)) /* while */ ) { + SCTPDBG(SCTP_DEBUG_OUTPUT1, "pre_block limit:%d <(inq:%d + %d) || (%d+%d > %d)\n", + SCTP_SB_LIMIT_SND(so), + inqueue_bytes, + local_add_more, + stcb->asoc.stream_queue_cnt, + stcb->asoc.chunks_on_out_queue, + SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue)); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_BLK_LOGGING_ENABLE) { sctp_log_block(SCTP_BLOCK_LOG_INTO_BLKA, so, asoc, sndlen); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 15:15:09 2008 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 4798C1065674; Mon, 27 Oct 2008 15:15:09 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 36F038FC1E; Mon, 27 Oct 2008 15:15:09 +0000 (UTC) (envelope-from bz@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 m9RFF8U5042971; Mon, 27 Oct 2008 15:15:08 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RFF86d042970; Mon, 27 Oct 2008 15:15:08 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200810271515.m9RFF86d042970@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Mon, 27 Oct 2008 15:15:08 +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: r184341 - head/usr.sbin 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: Mon, 27 Oct 2008 15:15:09 -0000 Author: bz Date: Mon Oct 27 15:15:08 2008 New Revision: 184341 URL: http://svn.freebsd.org/changeset/base/184341 Log: We do not have a libkse anymore and Mk/bsd.* does not know about LIBKSE anymore, so s,MK_LIBKSE,MK_LIBPTHREAD,. Modified: head/usr.sbin/Makefile Modified: head/usr.sbin/Makefile ============================================================================== --- head/usr.sbin/Makefile Mon Oct 27 14:49:12 2008 (r184340) +++ head/usr.sbin/Makefile Mon Oct 27 15:15:08 2008 (r184341) @@ -292,7 +292,7 @@ _moused= moused _vidcontrol= vidcontrol .endif -.if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" +.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" .if ${MK_PPP} != "no" _pppctl= pppctl .endif From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 15:21:15 2008 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 D59081065682; Mon, 27 Oct 2008 15:21:15 +0000 (UTC) (envelope-from dds@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C47258FC08; Mon, 27 Oct 2008 15:21:15 +0000 (UTC) (envelope-from dds@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 m9RFLFIG043135; Mon, 27 Oct 2008 15:21:15 GMT (envelope-from dds@svn.freebsd.org) Received: (from dds@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RFLFpj043134; Mon, 27 Oct 2008 15:21:15 GMT (envelope-from dds@svn.freebsd.org) Message-Id: <200810271521.m9RFLFpj043134@svn.freebsd.org> From: Diomidis Spinellis Date: Mon, 27 Oct 2008 15:21:15 +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: r184342 - head/bin/cp 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: Mon, 27 Oct 2008 15:21:15 -0000 Author: dds Date: Mon Oct 27 15:21:15 2008 New Revision: 184342 URL: http://svn.freebsd.org/changeset/base/184342 Log: Add fallback when mmap fails on regular files. Some filesystems, like smbnetfs, do not support mmap. Reported by: Harti Brandt MFC after: 1 month Modified: head/bin/cp/utils.c Modified: head/bin/cp/utils.c ============================================================================== --- head/bin/cp/utils.c Mon Oct 27 15:15:08 2008 (r184341) +++ head/bin/cp/utils.c Mon Oct 27 15:21:15 2008 (r184342) @@ -137,41 +137,39 @@ copy_file(const FTSENT *entp, int dne) * Mmap and write if less than 8M (the limit is so we don't totally * trash memory on big files. This is really a minor hack, but it * wins some CPU back. + * Some filesystems, such as smbnetfs, don't support mmap, + * so this is a best-effort attempt. */ #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED if (S_ISREG(fs->st_mode) && fs->st_size > 0 && - fs->st_size <= 8 * 1048576) { - if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, - MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { + fs->st_size <= 8 * 1024 * 1024 && + (p = mmap(NULL, (size_t)fs->st_size, PROT_READ, + MAP_SHARED, from_fd, (off_t)0)) != MAP_FAILED) { + wtotal = 0; + for (bufp = p, wresid = fs->st_size; ; + bufp += wcount, wresid -= (size_t)wcount) { + wcount = write(to_fd, bufp, wresid); + if (wcount <= 0) + break; + wtotal += wcount; + if (info) { + info = 0; + (void)fprintf(stderr, + "%s -> %s %3d%%\n", + entp->fts_path, to.p_path, + cp_pct(wtotal, fs->st_size)); + } + if (wcount >= (ssize_t)wresid) + break; + } + if (wcount != (ssize_t)wresid) { + warn("%s", to.p_path); + rval = 1; + } + /* Some systems don't unmap on close(2). */ + if (munmap(p, fs->st_size) < 0) { warn("%s", entp->fts_path); rval = 1; - } else { - wtotal = 0; - for (bufp = p, wresid = fs->st_size; ; - bufp += wcount, wresid -= (size_t)wcount) { - wcount = write(to_fd, bufp, wresid); - if (wcount <= 0) - break; - wtotal += wcount; - if (info) { - info = 0; - (void)fprintf(stderr, - "%s -> %s %3d%%\n", - entp->fts_path, to.p_path, - cp_pct(wtotal, fs->st_size)); - } - if (wcount >= (ssize_t)wresid) - break; - } - if (wcount != (ssize_t)wresid) { - warn("%s", to.p_path); - rval = 1; - } - /* Some systems don't unmap on close(2). */ - if (munmap(p, fs->st_size) < 0) { - warn("%s", entp->fts_path); - rval = 1; - } } } else #endif From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 15:27:43 2008 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 E113C1065684; Mon, 27 Oct 2008 15:27:43 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout021.mac.com (asmtpout021.mac.com [17.148.16.96]) by mx1.freebsd.org (Postfix) with ESMTP id C9BE08FC1E; Mon, 27 Oct 2008 15:27:43 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed Received: from srangarajan-lt.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp021.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0K9E0012YLM37450@asmtp021.mac.com>; Mon, 27 Oct 2008 08:27:41 -0700 (PDT) Message-id: <0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com> From: Marcel Moolenaar To: Stanislav Sedov In-reply-to: <20081027153345.d4e9dcad.stas@FreeBSD.org> Date: Mon, 27 Oct 2008 08:27:39 -0700 References: <200810250618.m9P6ICWl023370@svn.freebsd.org> <20081027153345.d4e9dcad.stas@FreeBSD.org> X-Mailer: Apple Mail (2.929.2) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys 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: Mon, 27 Oct 2008 15:27:44 -0000 On Oct 27, 2008, at 5:33 AM, Stanislav Sedov wrote: >> Add a driver for flash memory that implements to the Common Flash >> Memory Interface (CFI). The flash memory can be read and written >> to through /dev/cfi# and an ioctl() exists so processes can read >> the query information. >> The driver supports the AMD and Intel command set, though only >> the AMD command has been tested. >> >> Obtained from: Juniper Networks, Inc. > > Do you plan to introduce some infrastructure so other flash-like > drivers could be attached (e.g. non-CFI compliant, SPI flashes, etc)? > I've started working on such thing and don't want to do the duplicate > works, so if you have something in mind it's time to share:-) I have been thinking about it, but I don't have anything yet. As it is, I probably won't have the time for it either. If you started with something, then feel free to take cfi(4) and integrate it. Also, access to the raw flash is nice, but one typically uses it for various things. It would be great if we had an infrastructure in which we could allow access to the flash through more high-level interfaces. For example: The flash may contain U-Boot (possibly with embedded environment), FreeBSD loader, separate blocks for U-Boot environment, a file system, etc. Those parts of the flash that are used for disk-like storage should ideally be exposed through GEOM. Environments should ideally be exposed through a standardized interface so that we only have to write a single utility to modify environments. Open Firmware and/or EFI environment variables could then also be exposed through that interfaces, eliminating the need for drivers like powermc_nvram and special-purpose tools like nvram(8). It's not easy, but probably worth thinking about... > And thanks for this great work! You're welcome. I hope it's a good start... -- Marcel Moolenaar xcllnt@mac.com From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:03:19 2008 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 4E5D510656DC for ; Mon, 27 Oct 2008 16:03:19 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 83F988FC1D for ; Mon, 27 Oct 2008 16:03:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RG2Y1e012952; Mon, 27 Oct 2008 12:03:10 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Warner Losh Date: Mon, 27 Oct 2008 11:59:31 -0400 User-Agent: KMail/1.9.7 References: <868wsewzos.fsf@ds4.des.no> <200810241031.08780.jhb@freebsd.org> <20081024.164740.74747369.imp@bsdimp.com> In-Reply-To: <20081024.164740.74747369.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810271159.31843.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 12:03:11 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8508/Mon Oct 27 09:02:44 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: danfe@freebsd.org, marcel@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org, des@des.no Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf 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: Mon, 27 Oct 2008 16:03:19 -0000 On Friday 24 October 2008 06:47:40 pm Warner Losh wrote: > From: John Baldwin > Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf > Date: Fri, 24 Oct 2008 10:31:07 -0400 > > > On Friday 24 October 2008 09:27:03 am Alexey Dokuchaev wrote: > > > On Fri, Oct 24, 2008 at 03:26:43AM +0200, Dag-Erling Sm??rgrav wrote: > > > > Warner Losh writes: > > > > > We already have a better mechanism for including config files. We > > > > > should be using that instead of poluting another port with the > > > > > DEFAULTS file. > > > > > > > > Should we even have DEFAULTS files at all? IMHO they just confuse > > > > matters by introducing "stealth" options into your config. > > > > > > I tend to second this. I always try to get everything possible out of > > > my kernel to modules, and thus was surprised to see io.ko and mem.ko > > > fail to load because they were silently included into my custom kernel. > > > > > > I understand that some things like 'device isa' and > > > 'device npx' aren't really optional, but if something is useful to have, > > > but can be loaded as a module, it belongs to GENERIC rather than > > > DEFAULTS. Killing the latter altogether and throwing a comment that > > > says particular option or device is mandatory in GENERIC is probably > > > even better (and more transparent). > > > > The one thing I think DEFAULTS is useful for are replacing NO_FOO options with > > FOO options. That is, if someone wants to turn a feature on by default, I'd > > rather them put 'options FOO' in DEFAULTS rather than rename all the > > #ifdef's,e tc. to '#ifndef NO_FOO'. > > Wouldn't it be better to move to a system where we explicitly include > std.i386 and have them all defined there? We already encourage stuff > like this with advice to include GENERIC with nodev... I wouldn't mind a std.i386, and if we make config's include keyword fall back to 'sys/conf' for relative path name lookups if the lookup in '.' fails then you can even put those files in sys/conf with the still-clean syntax of 'include std.i386'. However, I don't know about you, but I _never_ build a config by including GENERIC and then weeding stuff out. Too much stuff to weed out. Once I have a customized config for a machine I then include that in development branches to install kernels to different directories under /boot, etc. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:13:28 2008 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 89613106567A; Mon, 27 Oct 2008 16:13:28 +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 781148FC75; Mon, 27 Oct 2008 16:13:28 +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 m9RGDSWT044217; Mon, 27 Oct 2008 16:13:28 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RGDSSU044216; Mon, 27 Oct 2008 16:13:28 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271613.m9RGDSSU044216@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 16:13:28 +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: r184343 - head/etc 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: Mon, 27 Oct 2008 16:13:28 -0000 Author: sam Date: Mon Oct 27 16:13:28 2008 New Revision: 184343 URL: http://svn.freebsd.org/changeset/base/184343 Log: o fix MK_TCSH == no: the default master.passwd sets up root to use /bin/csh but there won't be one so root won't be able to login; edit the installed file to use /bin/sh in this case. o while here split csh-related files apart from sh and only install them when requested Modified: head/etc/Makefile Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Mon Oct 27 15:21:15 2008 (r184342) +++ head/etc/Makefile Mon Oct 27 16:13:28 2008 (r184343) @@ -8,7 +8,7 @@ SUBDIR= sendmail .endif BIN1= auth.conf \ - crontab csh.cshrc csh.login csh.logout devd.conf devfs.conf \ + crontab devd.conf devfs.conf \ ddb.conf dhclient.conf disktab fbtab \ ftpusers gettytab group \ hosts hosts.allow hosts.equiv \ @@ -84,6 +84,10 @@ BIN1+= portsnap.conf BIN1+= pf.os .endif +.if ${MK_TCSH} != "no" +BIN1+= csh.cshrc csh.login csh.logout +.endif + .if ${MK_WIRELESS} != "no" BIN1+= regdomain.xml .endif @@ -148,9 +152,12 @@ distribution: ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 \ ${BIN2} ${DESTDIR}/etc; \ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \ - master.passwd nsmb.conf opieaccess ${DESTDIR}/etc; \ - pwd_mkdb ${PWD_MKDB_ENDIAN} -i -p -d ${DESTDIR}/etc \ - ${DESTDIR}/etc/master.passwd + master.passwd nsmb.conf opieaccess ${DESTDIR}/etc; +.if ${MK_TCSH} == "no" + sed -i "" -e 's;/bin/csh;;' ${DESTDIR}/etc/master.passwd +.endif + pwd_mkdb ${PWD_MKDB_ENDIAN} -i -p -d ${DESTDIR}/etc \ + ${DESTDIR}/etc/master.passwd .if ${MK_BLUETOOTH} != "no" ${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install .endif @@ -195,14 +202,18 @@ distribution: .endif cd ${.CURDIR}/root; \ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ + dot.profile ${DESTDIR}/root/.profile; \ + rm -f ${DESTDIR}/.profile; \ + ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile +.if ${MK_TCSH} != "no" + cd ${.CURDIR}/root; \ + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ dot.cshrc ${DESTDIR}/root/.cshrc; \ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ dot.login ${DESTDIR}/root/.login; \ - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ - dot.profile ${DESTDIR}/root/.profile; \ - rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \ - ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \ - ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile + rm -f ${DESTDIR}/.cshrc; \ + ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc +.endif cd ${.CURDIR}/mtree; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \ ${MTREE} ${DESTDIR}/etc/mtree .if ${MK_PPP} != "no" From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:20:40 2008 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 D4592106566B; Mon, 27 Oct 2008 16:20:40 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C3AA58FC08; Mon, 27 Oct 2008 16:20:40 +0000 (UTC) (envelope-from thompsa@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 m9RGKe9X044442; Mon, 27 Oct 2008 16:20:40 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RGKeRZ044441; Mon, 27 Oct 2008 16:20:40 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200810271620.m9RGKeRZ044441@svn.freebsd.org> From: Andrew Thompson Date: Mon, 27 Oct 2008 16:20:40 +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: r184344 - head/etc 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: Mon, 27 Oct 2008 16:20:40 -0000 Author: thompsa Date: Mon Oct 27 16:20:40 2008 New Revision: 184344 URL: http://svn.freebsd.org/changeset/base/184344 Log: Make a note about the notify codes for the four special function keys above the keyboard on the EeePC. Modified: head/etc/devd.conf Modified: head/etc/devd.conf ============================================================================== --- head/etc/devd.conf Mon Oct 27 16:13:28 2008 (r184343) +++ head/etc/devd.conf Mon Oct 27 16:20:40 2008 (r184344) @@ -256,6 +256,7 @@ notify 10 { }; # The next blocks enable volume hotkeys that can be found on the Asus EeePC +# The four keys above the keyboard notify 0x1a through to 0x1d respectively notify 0 { match "system" "ACPI"; match "subsystem" "ASUS-Eee"; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:46:51 2008 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 48184106567F; Mon, 27 Oct 2008 16:46:51 +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 358508FC26; Mon, 27 Oct 2008 16:46:51 +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 m9RGkoUK045674; Mon, 27 Oct 2008 16:46:50 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RGkoKa045665; Mon, 27 Oct 2008 16:46:50 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271646.m9RGkoKa045665@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 16:46:50 +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: r184345 - in head/sys: dev/ath dev/iwn dev/ral dev/usb dev/wpi 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: Mon, 27 Oct 2008 16:46:51 -0000 Author: sam Date: Mon Oct 27 16:46:50 2008 New Revision: 184345 URL: http://svn.freebsd.org/changeset/base/184345 Log: o use the new association callback to notify the driver when joining a bss in sta and adhoc modes; this should've been done forever ago as most all drivers use this hook to set per-station transmit parameters such as for tx rate control o adjust drivers to remove explicit calls to the driver newassoc method Modified: head/sys/dev/ath/if_ath.c head/sys/dev/iwn/if_iwn.c head/sys/dev/ral/rt2560.c head/sys/dev/ral/rt2661.c head/sys/dev/usb/if_zyd.c head/sys/dev/wpi/if_wpi.c head/sys/net80211/ieee80211_adhoc.c head/sys/net80211/ieee80211_sta.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 16:46:50 2008 (r184345) @@ -5722,10 +5722,6 @@ ath_newstate(struct ieee80211vap *vap, e break; case IEEE80211_M_STA: /* - * Fakeup since we're not called by net80211. - */ - ath_newassoc(ni, 1); - /* * Defer beacon timer configuration to the next * beacon frame so we have a current TSF to use * (any TSF collected when scanning is likely old). Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/iwn/if_iwn.c Mon Oct 27 16:46:50 2008 (r184345) @@ -3648,11 +3648,6 @@ iwn_run(struct iwn_softc *sc) return error; } - if (ic->ic_opmode == IEEE80211_M_STA) { - /* fake a join to init the tx rate */ - iwn_newassoc(ni, 1); - } - error = iwn_init_sensitivity(sc); if (error != 0) { device_printf(sc->sc_dev, Modified: head/sys/dev/ral/rt2560.c ============================================================================== --- head/sys/dev/ral/rt2560.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/ral/rt2560.c Mon Oct 27 16:46:50 2008 (r184345) @@ -831,13 +831,8 @@ rt2560_newstate(struct ieee80211vap *vap /* turn assocation led on */ rt2560_update_led(sc, 1, 0); - if (vap->iv_opmode != IEEE80211_M_MONITOR) { - if (vap->iv_opmode == IEEE80211_M_STA) { - /* fake a join to init the tx rate */ - rt2560_newassoc(ni, 1); - } + if (vap->iv_opmode != IEEE80211_M_MONITOR) rt2560_enable_tsf_sync(sc); - } } return error; } Modified: head/sys/dev/ral/rt2661.c ============================================================================== --- head/sys/dev/ral/rt2661.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/ral/rt2661.c Mon Oct 27 16:46:50 2008 (r184345) @@ -830,13 +830,8 @@ rt2661_newstate(struct ieee80211vap *vap if (error != 0) return error; } - if (vap->iv_opmode != IEEE80211_M_MONITOR) { - if (vap->iv_opmode == IEEE80211_M_STA) { - /* fake a join to init the tx rate */ - rt2661_newassoc(ni, 1); - } + if (vap->iv_opmode != IEEE80211_M_MONITOR) rt2661_enable_tsf_sync(sc); - } } return error; } Modified: head/sys/dev/usb/if_zyd.c ============================================================================== --- head/sys/dev/usb/if_zyd.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/usb/if_zyd.c Mon Oct 27 16:46:50 2008 (r184345) @@ -740,11 +740,6 @@ zyd_task(void *arg) IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid); zyd_set_bssid(sc, sc->sc_bssid); } - - if (vap->iv_opmode == IEEE80211_M_STA) { - /* fake a join to init the tx rate */ - zyd_newassoc(ni, 1); - } break; } default: Modified: head/sys/dev/wpi/if_wpi.c ============================================================================== --- head/sys/dev/wpi/if_wpi.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/dev/wpi/if_wpi.c Mon Oct 27 16:46:50 2008 (r184345) @@ -2522,11 +2522,6 @@ wpi_run(struct wpi_softc *sc, struct iee return error; } - if (vap->iv_opmode == IEEE80211_M_STA) { - /* fake a join to init the tx rate */ - wpi_newassoc(ni, 1); - } - /* link LED always on while associated */ wpi_set_led(sc, WPI_LED_LINK, 0, 1); Modified: head/sys/net80211/ieee80211_adhoc.c ============================================================================== --- head/sys/net80211/ieee80211_adhoc.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/net80211/ieee80211_adhoc.c Mon Oct 27 16:46:50 2008 (r184345) @@ -104,9 +104,7 @@ adhoc_vattach(struct ieee80211vap *vap) static int adhoc_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { -#ifdef IEEE80211_DEBUG struct ieee80211com *ic = vap->iv_ic; -#endif struct ieee80211_node *ni; enum ieee80211_state ostate; @@ -208,6 +206,12 @@ adhoc_newstate(struct ieee80211vap *vap, */ if (ni->ni_authmode != IEEE80211_AUTH_8021X) ieee80211_node_authorize(ni); + /* + * Fake association when joining an existing bss. + */ + if (!IEEE80211_ADDR_EQ(ni->ni_macaddr, vap->iv_myaddr) && + ic->ic_newassoc != NULL) + ic->ic_newassoc(ni, ostate != IEEE80211_S_RUN); break; case IEEE80211_S_SLEEP: ieee80211_sta_pwrsave(vap, 0); Modified: head/sys/net80211/ieee80211_sta.c ============================================================================== --- head/sys/net80211/ieee80211_sta.c Mon Oct 27 16:20:40 2008 (r184344) +++ head/sys/net80211/ieee80211_sta.c Mon Oct 27 16:46:50 2008 (r184345) @@ -400,6 +400,11 @@ sta_newstate(struct ieee80211vap *vap, e */ if (ni->ni_authmode != IEEE80211_AUTH_8021X) ieee80211_node_authorize(ni); + /* + * Fake association when joining an existing bss. + */ + if (ic->ic_newassoc != NULL) + ic->ic_newassoc(vap->iv_bss, ostate != IEEE80211_S_RUN); break; case IEEE80211_S_SLEEP: ieee80211_sta_pwrsave(vap, 0); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:47:52 2008 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 379FB1065675; Mon, 27 Oct 2008 16:47:52 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from ebb.errno.com (ebb.errno.com [69.12.149.25]) by mx1.freebsd.org (Postfix) with ESMTP id 0DB9B8FC1E; Mon, 27 Oct 2008 16:47:51 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from trouble.errno.com (trouble.errno.com [10.0.0.248]) (authenticated bits=0) by ebb.errno.com (8.13.6/8.12.6) with ESMTP id m9RGlpid025636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Oct 2008 09:47:51 -0700 (PDT) (envelope-from sam@freebsd.org) Message-ID: <4905F0B7.2030103@freebsd.org> Date: Mon, 27 Oct 2008 09:47:51 -0700 From: Sam Leffler Organization: FreeBSD Project User-Agent: Thunderbird 2.0.0.9 (X11/20071125) MIME-Version: 1.0 To: Sam Leffler References: <200810271646.m9RGkoKa045665@svn.freebsd.org> In-Reply-To: <200810271646.m9RGkoKa045665@svn.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DCC-Rhyolite-Metrics: ebb.errno.com; whitelist Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184345 - in head/sys: dev/ath dev/iwn dev/ral dev/usb dev/wpi 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: Mon, 27 Oct 2008 16:47:52 -0000 Sam Leffler wrote: > Author: sam > Date: Mon Oct 27 16:46:50 2008 > New Revision: 184345 > URL: http://svn.freebsd.org/changeset/base/184345 > > Log: > o use the new association callback to notify the driver when joining a bss > in sta and adhoc modes; this should've been done forever ago as most all > drivers use this hook to set per-station transmit parameters such as for > tx rate control > o adjust drivers to remove explicit calls to the driver newassoc method > > Reviewed by: thompsa From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 16:58:07 2008 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 06C2A106567B; Mon, 27 Oct 2008 16:58:07 +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 E83218FC1C; Mon, 27 Oct 2008 16:58:06 +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 m9RGw6G4045919; Mon, 27 Oct 2008 16:58:06 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RGw6iL045914; Mon, 27 Oct 2008 16:58:06 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271658.m9RGw6iL045914@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 16:58:06 +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: r184346 - in head/sys/dev/ath: . ath_rate/amrr ath_rate/onoe ath_rate/sample 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: Mon, 27 Oct 2008 16:58:07 -0000 Author: sam Date: Mon Oct 27 16:58:06 2008 New Revision: 184346 URL: http://svn.freebsd.org/changeset/base/184346 Log: now that the new association callback is used when joining a bss we can eliminate the ath_rate_newassoc callback and associated code Modified: head/sys/dev/ath/ath_rate/amrr/amrr.c head/sys/dev/ath/ath_rate/onoe/onoe.c head/sys/dev/ath/ath_rate/sample/sample.c head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athrate.h Modified: head/sys/dev/ath/ath_rate/amrr/amrr.c ============================================================================== --- head/sys/dev/ath/ath_rate/amrr/amrr.c Mon Oct 27 16:46:50 2008 (r184345) +++ head/sys/dev/ath/ath_rate/amrr/amrr.c Mon Oct 27 16:58:06 2008 (r184346) @@ -321,49 +321,6 @@ ath_rate_ctl_start(struct ath_softc *sc, #undef RATE } -static void -ath_rate_cb(void *arg, struct ieee80211_node *ni) -{ - struct ath_softc *sc = arg; - - ath_rate_update(sc, ni, 0); -} - -/* - * Reset the rate control state for each 802.11 state transition. - */ -void -ath_rate_newstate(struct ieee80211vap *vap, enum ieee80211_state state) -{ - struct ieee80211com *ic = vap->iv_ic; - struct ath_softc *sc = ic->ic_ifp->if_softc; - struct ieee80211_node *ni; - - if (state == IEEE80211_S_INIT) - return; - if (vap->iv_opmode == IEEE80211_M_STA) { - /* - * Reset local xmit state; this is really only - * meaningful when operating in station mode. - */ - ni = vap->iv_bss; - if (state == IEEE80211_S_RUN) { - ath_rate_ctl_start(sc, ni); - } else { - ath_rate_update(sc, ni, 0); - } - } else { - /* - * When operating as a station the node table holds - * the AP's that were discovered during scanning. - * For any other operating mode we want to reset the - * tx rate state of each node. - */ - ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_cb, sc); - ath_rate_update(sc, vap->iv_bss, 0); - } -} - /* * Examine and potentially adjust the transmit rate. */ Modified: head/sys/dev/ath/ath_rate/onoe/onoe.c ============================================================================== --- head/sys/dev/ath/ath_rate/onoe/onoe.c Mon Oct 27 16:46:50 2008 (r184345) +++ head/sys/dev/ath/ath_rate/onoe/onoe.c Mon Oct 27 16:58:06 2008 (r184346) @@ -295,49 +295,6 @@ ath_rate_ctl_start(struct ath_softc *sc, #undef RATE } -static void -ath_rate_cb(void *arg, struct ieee80211_node *ni) -{ - struct ath_softc *sc = arg; - - ath_rate_update(sc, ni, 0); -} - -/* - * Reset the rate control state for each 802.11 state transition. - */ -void -ath_rate_newstate(struct ieee80211vap *vap, enum ieee80211_state state) -{ - struct ieee80211com *ic = vap->iv_ic; - struct ath_softc *sc = ic->ic_ifp->if_softc; - struct ieee80211_node *ni; - - if (state == IEEE80211_S_INIT) - return; - if (vap->iv_opmode == IEEE80211_M_STA) { - /* - * Reset local xmit state; this is really only - * meaningful when operating in station mode. - */ - ni = vap->iv_bss; - if (state == IEEE80211_S_RUN) { - ath_rate_ctl_start(sc, ni); - } else { - ath_rate_update(sc, ni, 0); - } - } else { - /* - * When operating as a station the node table holds - * the AP's that were discovered during scanning. - * For any other operating mode we want to reset the - * tx rate state of each node. - */ - ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_cb, sc); - ath_rate_update(sc, vap->iv_bss, 0); - } -} - /* * Examine and potentially adjust the transmit rate. */ Modified: head/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 16:46:50 2008 (r184345) +++ head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 16:58:06 2008 (r184346) @@ -759,34 +759,6 @@ ath_rate_ctl_reset(struct ath_softc *sc, } static void -rate_cb(void *arg, struct ieee80211_node *ni) -{ - struct ath_softc *sc = arg; - - ath_rate_newassoc(sc, ATH_NODE(ni), 1); -} - -/* - * Reset the rate control state for each 802.11 state transition. - */ -void -ath_rate_newstate(struct ieee80211vap *vap, enum ieee80211_state state) -{ - struct ieee80211com *ic = vap->iv_ic; - struct ath_softc *sc = ic->ic_ifp->if_softc; - - if (state == IEEE80211_S_RUN) { - if (vap->iv_opmode != IEEE80211_M_STA) { - /* - * Sync rates for associated stations and neighbors. - */ - ieee80211_iterate_nodes(&ic->ic_sta, rate_cb, sc); - } - ath_rate_newassoc(sc, ATH_NODE(vap->iv_bss), 1); - } -} - -static void ath_rate_sysctlattach(struct ath_softc *sc, struct sample_softc *osc) { struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 16:46:50 2008 (r184345) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 16:58:06 2008 (r184346) @@ -5664,11 +5664,6 @@ ath_newstate(struct ieee80211vap *vap, e if (ath_hal_keyisvalid(ah, i)) ath_hal_keysetmac(ah, i, ni->ni_bssid); } - /* - * Notify the rate control algorithm so rates - * are setup should ath_beacon_alloc be called. - */ - ath_rate_newstate(vap, nstate); /* * Invoke the parent method to do net80211 work. Modified: head/sys/dev/ath/if_athrate.h ============================================================================== --- head/sys/dev/ath/if_athrate.h Mon Oct 27 16:46:50 2008 (r184345) +++ head/sys/dev/ath/if_athrate.h Mon Oct 27 16:58:06 2008 (r184346) @@ -97,12 +97,6 @@ void ath_rate_node_cleanup(struct ath_so */ void ath_rate_newassoc(struct ath_softc *, struct ath_node *, int isNewAssociation); -/* - * Update/reset rate control state for 802.11 state transitions. - * Important mostly as the analog to ath_rate_newassoc when operating - * in station mode. - */ -void ath_rate_newstate(struct ieee80211vap *, enum ieee80211_state); /* * Transmit handling. From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:03:25 2008 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 1D4AC106566C; Mon, 27 Oct 2008 17:03:25 +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 04D598FC1F; Mon, 27 Oct 2008 17:03:25 +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 m9RH3OlW046067; Mon, 27 Oct 2008 17:03:24 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RH3OjD046062; Mon, 27 Oct 2008 17:03:24 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271703.m9RH3OjD046062@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:03:24 +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: r184347 - in head/sys/dev/ath: . ath_rate/amrr ath_rate/onoe ath_rate/sample 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: Mon, 27 Oct 2008 17:03:25 -0000 Author: sam Date: Mon Oct 27 17:03:24 2008 New Revision: 184347 URL: http://svn.freebsd.org/changeset/base/184347 Log: remove driver-private equivalent of ni_txparms; it's now superfluous Modified: head/sys/dev/ath/ath_rate/amrr/amrr.c head/sys/dev/ath/ath_rate/onoe/onoe.c head/sys/dev/ath/ath_rate/sample/sample.c head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/ath_rate/amrr/amrr.c ============================================================================== --- head/sys/dev/ath/ath_rate/amrr/amrr.c Mon Oct 27 16:58:06 2008 (r184346) +++ head/sys/dev/ath/ath_rate/amrr/amrr.c Mon Oct 27 17:03:24 2008 (r184347) @@ -277,8 +277,7 @@ static void ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni) { #define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) - struct ath_node *an = ATH_NODE(ni); - const struct ieee80211_txparam *tp = an->an_tp; + const struct ieee80211_txparam *tp = ni->ni_txparms; int srate; KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); Modified: head/sys/dev/ath/ath_rate/onoe/onoe.c ============================================================================== --- head/sys/dev/ath/ath_rate/onoe/onoe.c Mon Oct 27 16:58:06 2008 (r184346) +++ head/sys/dev/ath/ath_rate/onoe/onoe.c Mon Oct 27 17:03:24 2008 (r184347) @@ -251,8 +251,7 @@ static void ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni) { #define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) - struct ath_node *an = ATH_NODE(ni); - const struct ieee80211_txparam *tp = an->an_tp; + const struct ieee80211_txparam *tp = ni->ni_txparms; int srate; KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); Modified: head/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 16:58:06 2008 (r184346) +++ head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 17:03:24 2008 (r184347) @@ -654,7 +654,7 @@ ath_rate_ctl_reset(struct ath_softc *sc, { #define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) struct ath_node *an = ATH_NODE(ni); - const struct ieee80211_txparam *tp = an->an_tp; + const struct ieee80211_txparam *tp = ni->ni_txparms; struct sample_node *sn = ATH_NODE_SAMPLE(an); const HAL_RATE_TABLE *rt = sc->sc_currates; int x, y, srate; Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 16:58:06 2008 (r184346) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:03:24 2008 (r184347) @@ -5820,29 +5820,10 @@ ath_newassoc(struct ieee80211_node *ni, struct ath_node *an = ATH_NODE(ni); struct ieee80211vap *vap = ni->ni_vap; struct ath_softc *sc = vap->iv_ic->ic_ifp->if_softc; - const struct ieee80211_txparam *tp; - enum ieee80211_phymode mode; + const struct ieee80211_txparam *tp = ni->ni_txparms; - /* - * Deduce netband of station to simplify setting up xmit - * parameters. Note this allows us to assign different - * parameters to each station in a mixed bss (b/g, n/[abg]). - */ - if (ni->ni_flags & IEEE80211_NODE_HT) { - if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) - mode = IEEE80211_MODE_11NA; - else - mode = IEEE80211_MODE_11NG; - } else if (IEEE80211_IS_CHAN_A(ni->ni_chan)) - mode = IEEE80211_MODE_11A; - else if (ni->ni_flags & IEEE80211_NODE_ERP) - mode = IEEE80211_MODE_11G; - else - mode = IEEE80211_MODE_11B; - tp = &vap->iv_txparms[mode]; - an->an_tp = tp; - an->an_mcastrix = ath_tx_findrix(sc->sc_rates[mode], tp->mcastrate); - an->an_mgmtrix = ath_tx_findrix(sc->sc_rates[mode], tp->mgmtrate); + an->an_mcastrix = ath_tx_findrix(sc->sc_currates, tp->mcastrate); + an->an_mgmtrix = ath_tx_findrix(sc->sc_currates, tp->mgmtrate); ath_rate_newassoc(sc, an, isnew); if (isnew && Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 16:58:06 2008 (r184346) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 17:03:24 2008 (r184347) @@ -82,7 +82,6 @@ struct ath_buf; /* driver-specific node state */ struct ath_node { struct ieee80211_node an_node; /* base class */ - const struct ieee80211_txparam *an_tp; u_int8_t an_mgmtrix; /* min h/w rate index */ u_int8_t an_mcastrix; /* mcast h/w rate index */ struct ath_buf *an_ff_buf[WME_NUM_AC]; /* ff staging area */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:10:22 2008 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 42285106566C; Mon, 27 Oct 2008 17:10:22 +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 306E48FC1D; Mon, 27 Oct 2008 17:10:22 +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 m9RHAM4L046230; Mon, 27 Oct 2008 17:10:22 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHAMQ7046229; Mon, 27 Oct 2008 17:10:22 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271710.m9RHAMQ7046229@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:10:22 +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: r184348 - head/sys/dev/ath/ath_rate/sample 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: Mon, 27 Oct 2008 17:10:22 -0000 Author: sam Date: Mon Oct 27 17:10:21 2008 New Revision: 184348 URL: http://svn.freebsd.org/changeset/base/184348 Log: move complaints about bad rate codes up a level so we can print the h/w rate code and other useful info Modified: head/sys/dev/ath/ath_rate/sample/sample.c Modified: head/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 17:03:24 2008 (r184347) +++ head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 17:10:21 2008 (r184348) @@ -393,11 +393,8 @@ update_stats(struct ath_softc *sc, struc size_bin = size_to_bin(frame_size); size = bin_to_size(size_bin); - if (!(0 <= ndx0 && ndx0 < sn->num_rates)) { - printf("%s: bogus ndx0 %d, max %u, mode %u\n", - __func__, ndx0, sn->num_rates, sc->sc_curmode); + if (!(0 <= ndx0 && ndx0 < sn->num_rates)) return; - } rate = sn->rates[ndx0].rate; tt += calc_usecs_unicast_packet(sc, size, sn->rates[ndx0].rix, @@ -405,11 +402,8 @@ update_stats(struct ath_softc *sc, struc MIN(tries0, tries) - 1); tries_so_far += tries0; if (tries1 && tries0 < tries) { - if (!(0 <= ndx1 && ndx1 < sn->num_rates)) { - printf("%s: bogus ndx1 %d, max %u, mode %u\n", - __func__, ndx1, sn->num_rates, sc->sc_curmode); + if (!(0 <= ndx1 && ndx1 < sn->num_rates)) return; - } tt += calc_usecs_unicast_packet(sc, size, sn->rates[ndx1].rix, short_tries, MIN(tries1 + tries_so_far, tries) - tries_so_far - 1); @@ -417,11 +411,8 @@ update_stats(struct ath_softc *sc, struc tries_so_far += tries1; if (tries2 && tries0 + tries1 < tries) { - if (!(0 <= ndx2 && ndx2 < sn->num_rates)) { - printf("%s: bogus ndx2 %d, max %u, mode %u\n", - __func__, ndx2, sn->num_rates, sc->sc_curmode); + if (!(0 <= ndx2 && ndx2 < sn->num_rates)) return; - } tt += calc_usecs_unicast_packet(sc, size, sn->rates[ndx2].rix, short_tries, MIN(tries2 + tries_so_far, tries) - tries_so_far - 1); @@ -430,11 +421,8 @@ update_stats(struct ath_softc *sc, struc tries_so_far += tries2; if (tries3 && tries0 + tries1 + tries2 < tries) { - if (!(0 <= ndx3 && ndx3 < sn->num_rates)) { - printf("%s: bogus ndx3 %d, max %u, mode %u\n", - __func__, ndx3, sn->num_rates, sc->sc_curmode); + if (!(0 <= ndx3 && ndx3 < sn->num_rates)) return; - } tt += calc_usecs_unicast_packet(sc, size, sn->rates[ndx3].rix, short_tries, MIN(tries3 + tries_so_far, tries) - tries_so_far - 1); @@ -488,6 +476,13 @@ update_stats(struct ath_softc *sc, struc } } +static void +badrate(struct ifnet *ifp, int series, int hwrate, int tries, int status) +{ + if_printf(ifp, "bad series%d hwrate 0x%x, tries %u ts_status 0x%x\n", + series, hwrate, tries, status); +} + void ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an, const struct ath_buf *bf) @@ -521,6 +516,10 @@ ath_rate_tx_complete(struct ath_softc *s if (!mrr || !(ts->ts_rate & HAL_TXSTAT_ALTRATE)) { int ndx = rate_to_ndx(sn, final_rate); + if (ndx < 0) { + badrate(ifp, 0, ts->ts_rate, long_tries, ts->ts_status); + return; + } /* * Only one rate was used; optimize work. */ @@ -574,6 +573,15 @@ ath_rate_tx_complete(struct ath_softc *s tries3 = MS(ds0->ds_ctl2, AR_XmitDataTries3); ndx3 = rate_to_ndx(sn, rate3); + if (tries0 && ndx0 < 0) + badrate(ifp, 0, hwrate0, tries0, ts->ts_status); + if (tries1 && ndx1 < 0) + badrate(ifp, 1, hwrate1, tries1, ts->ts_status); + if (tries2 && ndx2 < 0) + badrate(ifp, 2, hwrate2, tries2, ts->ts_status); + if (tries3 && ndx3 < 0) + badrate(ifp, 3, hwrate3, tries3, ts->ts_status); + IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, "%s: size %d finaltsidx %d tries %d %s rate/try [%d/%d %d/%d %d/%d %d/%d]", From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:12:41 2008 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 941831065679; Mon, 27 Oct 2008 17:12:41 +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 82ECE8FC16; Mon, 27 Oct 2008 17:12:41 +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 m9RHCfMK046330; Mon, 27 Oct 2008 17:12:41 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHCfH5046328; Mon, 27 Oct 2008 17:12:41 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271712.m9RHCfH5046328@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:12:41 +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: r184349 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:12:41 -0000 Author: sam Date: Mon Oct 27 17:12:41 2008 New Revision: 184349 URL: http://svn.freebsd.org/changeset/base/184349 Log: intercept IEEE80211_IOC_TXPOWER and service tx power changes immediately Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:10:21 2008 (r184348) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:12:41 2008 (r184349) @@ -1566,7 +1566,23 @@ ath_reset(struct ifnet *ifp) static int ath_reset_vap(struct ieee80211vap *vap, u_long cmd) { - return ath_reset(vap->iv_ic->ic_ifp); + struct ieee80211com *ic = vap->iv_ic; + struct ifnet *ifp = ic->ic_ifp; + struct ath_softc *sc = ifp->if_softc; + struct ath_hal *ah = sc->sc_ah; + + switch (cmd) { + case IEEE80211_IOC_TXPOWER: + /* + * If per-packet TPC is enabled, then we have nothing + * to do; otherwise we need to force the global limit. + * All this can happen directly; no need to reset. + */ + if (!ath_hal_gettpc(ah)) + ath_hal_settxpowlimit(ah, ic->ic_txpowlimit); + return 0; + } + return ath_reset(ifp); } static int From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:14:39 2008 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 C8EBE1065672; Mon, 27 Oct 2008 17:14:39 +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 B715B8FC16; Mon, 27 Oct 2008 17:14:39 +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 m9RHEdxb046403; Mon, 27 Oct 2008 17:14:39 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHEddN046401; Mon, 27 Oct 2008 17:14:39 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271714.m9RHEddN046401@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:14:39 +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: r184350 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:14:39 -0000 Author: sam Date: Mon Oct 27 17:14:39 2008 New Revision: 184350 URL: http://svn.freebsd.org/changeset/base/184350 Log: use the ic's opmode instead of our hal equivalent to check for adhoc mode; they are always the same Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:12:41 2008 (r184349) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:14:39 2008 (r184350) @@ -2588,7 +2588,7 @@ ath_calcrxfilter(struct ath_softc *sc) if (ic->ic_opmode == IEEE80211_M_MONITOR || (ifp->if_flags & IFF_PROMISC)) rfilt |= HAL_RX_FILTER_PROM; if (ic->ic_opmode == IEEE80211_M_STA || - sc->sc_opmode == HAL_M_IBSS || + ic->ic_opmode == IEEE80211_M_IBSS || sc->sc_swbmiss || sc->sc_scanning) rfilt |= HAL_RX_FILTER_BEACON; /* From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:16:46 2008 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 7D19A1065670; Mon, 27 Oct 2008 17:16:46 +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 6BB858FC0A; Mon, 27 Oct 2008 17:16:46 +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 m9RHGkhd046477; Mon, 27 Oct 2008 17:16:46 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHGkpN046474; Mon, 27 Oct 2008 17:16:46 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271716.m9RHGkpN046474@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:16:46 +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: r184351 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:16:46 -0000 Author: sam Date: Mon Oct 27 17:16:46 2008 New Revision: 184351 URL: http://svn.freebsd.org/changeset/base/184351 Log: rename bf_flags to bf_txflags in preparation for the addition of flags separate from the tx descriptor flags currently recorded Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:14:39 2008 (r184350) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:16:46 2008 (r184351) @@ -4958,7 +4958,7 @@ ath_tx_start(struct ath_softc *sc, struc , ctsrate /* rts/cts rate */ , ctsduration /* rts/cts duration */ ); - bf->bf_flags = flags; + bf->bf_txflags = flags; /* * Setup the multi-rate retry state only when we're * going to use it. This assumes ath_hal_setuptxdesc @@ -5054,7 +5054,7 @@ ath_tx_processq(struct ath_softc *sc, st * Hand the descriptor to the rate control algorithm. */ if ((ts->ts_status & HAL_TXERR_FILT) == 0 && - (bf->bf_flags & HAL_TXDESC_NOACK) == 0) { + (bf->bf_txflags & HAL_TXDESC_NOACK) == 0) { /* * If frame was ack'd update the last rx time * used to workaround phantom bmiss interrupts. @@ -6220,7 +6220,7 @@ ath_printtxbuf(const struct ath_buf *bf, printf(" (DS.V:%p DS.P:%p) L:%08x D:%08x F:04%x%s\n" " %08x %08x %08x %08x %08x %08x\n", ds, (const struct ath_desc *)bf->bf_daddr + i, - ds->ds_link, ds->ds_data, bf->bf_flags, + ds->ds_link, ds->ds_data, bf->bf_txflags, !done ? "" : (ts->ts_status == 0) ? " *" : " !", ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3]); @@ -6863,7 +6863,7 @@ ath_tx_raw_start(struct ath_softc *sc, s , ctsrate /* rts/cts rate */ , ctsduration /* rts/cts duration */ ); - bf->bf_flags = flags; + bf->bf_txflags = flags; if (ismrr) { rix = ath_tx_findrix(rt, params->ibp_rate1); Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 17:14:39 2008 (r184350) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 17:16:46 2008 (r184351) @@ -106,7 +106,7 @@ struct ath_buf { TAILQ_ENTRY(ath_buf) bf_stagelist; /* stage queue list */ u_int32_t bf_age; /* age when placed on stageq */ int bf_nseg; - int bf_flags; /* tx descriptor flags */ + int bf_txflags; /* tx descriptor flags */ struct ath_desc *bf_desc; /* virtual addr of desc */ struct ath_desc_status bf_status; /* tx/rx status */ bus_addr_t bf_daddr; /* physical addr of desc */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:19:14 2008 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 F13251065681; Mon, 27 Oct 2008 17:19:14 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E005E8FC17; Mon, 27 Oct 2008 17:19:14 +0000 (UTC) (envelope-from thompsa@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 m9RHJEtI046555; Mon, 27 Oct 2008 17:19:14 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHJERi046554; Mon, 27 Oct 2008 17:19:14 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200810271719.m9RHJERi046554@svn.freebsd.org> From: Andrew Thompson Date: Mon, 27 Oct 2008 17:19:14 +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: r184352 - head/etc 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: Mon, 27 Oct 2008 17:19:15 -0000 Author: thompsa Date: Mon Oct 27 17:19:14 2008 New Revision: 184352 URL: http://svn.freebsd.org/changeset/base/184352 Log: Add ucomX shortcuts just like its uart sibling. Modified: head/etc/remote Modified: head/etc/remote ============================================================================== --- head/etc/remote Mon Oct 27 17:16:46 2008 (r184351) +++ head/etc/remote Mon Oct 27 17:19:14 2008 (r184352) @@ -66,3 +66,11 @@ uart4|com5:dv=/dev/cuau4:br#9600:pa=none uart5|com6:dv=/dev/cuau5:br#9600:pa=none: uart6|com7:dv=/dev/cuau6:br#9600:pa=none: uart7|com8:dv=/dev/cuau7:br#9600:pa=none: +ucom1:dv=/dev/cuaU0:br#9600:pa=none: +ucom2:dv=/dev/cuaU1:br#9600:pa=none: +ucom3:dv=/dev/cuaU2:br#9600:pa=none: +ucom4:dv=/dev/cuaU3:br#9600:pa=none: +ucom5:dv=/dev/cuaU4:br#9600:pa=none: +ucom6:dv=/dev/cuaU5:br#9600:pa=none: +ucom7:dv=/dev/cuaU6:br#9600:pa=none: +ucom8:dv=/dev/cuaU7:br#9600:pa=none: From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:19:39 2008 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 BD052106566C; Mon, 27 Oct 2008 17:19:39 +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 ABF258FC13; Mon, 27 Oct 2008 17:19:39 +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 m9RHJdhk046596; Mon, 27 Oct 2008 17:19:39 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHJdjl046594; Mon, 27 Oct 2008 17:19:39 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271719.m9RHJdjl046594@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:19:39 +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: r184353 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:19:39 -0000 Author: sam Date: Mon Oct 27 17:19:39 2008 New Revision: 184353 URL: http://svn.freebsd.org/changeset/base/184353 Log: shuffle debug setup to simplify debugging events during attach Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:19:14 2008 (r184352) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:19:39 2008 (r184353) @@ -238,10 +238,6 @@ SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTL TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); #ifdef ATH_DEBUG -static int ath_debug = 0; -SYSCTL_INT(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, - 0, "control debugging printfs"); -TUNABLE_INT("hw.ath.debug", &ath_debug); enum { ATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ ATH_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ @@ -266,6 +262,11 @@ enum { ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ ATH_DEBUG_ANY = 0xffffffff }; +static int ath_debug = 0; +SYSCTL_INT(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, + 0, "control debugging printfs"); +TUNABLE_INT("hw.ath.debug", &ath_debug); + #define IFF_DUMPPKTS(sc, m) \ ((sc->sc_debug & (m)) || \ (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) @@ -331,6 +332,9 @@ ath_attach(u_int16_t devid, struct ath_s } sc->sc_ah = ah; sc->sc_invalid = 0; /* ready to go, enable interrupt handling */ +#ifdef ATH_DEBUG + sc->sc_debug = ath_debug; +#endif /* * Check if the MAC has multi-rate retry support. @@ -6635,7 +6639,6 @@ ath_sysctlattach(struct ath_softc *sc) "regdomain", CTLFLAG_RD, &sc->sc_eerd, 0, "EEPROM regdomain code"); #ifdef ATH_DEBUG - sc->sc_debug = ath_debug; SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "debug", CTLFLAG_RW, &sc->sc_debug, 0, "control debugging printfs"); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:22:47 2008 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 0A2A7106566B; Mon, 27 Oct 2008 17:22:47 +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 EC7D28FC08; Mon, 27 Oct 2008 17:22:46 +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 m9RHMkSC046696; Mon, 27 Oct 2008 17:22:46 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHMkHl046693; Mon, 27 Oct 2008 17:22:46 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271722.m9RHMkHl046693@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:22:46 +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: r184354 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:22:47 -0000 Author: sam Date: Mon Oct 27 17:22:46 2008 New Revision: 184354 URL: http://svn.freebsd.org/changeset/base/184354 Log: add sys.dev.ath.X.intmit knob to enable/disable ANI (the intmit name is historical) Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:19:39 2008 (r184353) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:22:46 2008 (r184354) @@ -6625,6 +6625,19 @@ ath_sysctl_tpcts(SYSCTL_HANDLER_ARGS) return !ath_hal_settpcts(sc->sc_ah, tpcts) ? EINVAL : 0; } +static int +ath_sysctl_intmit(SYSCTL_HANDLER_ARGS) +{ + struct ath_softc *sc = arg1; + int intmit, error; + + intmit = ath_hal_getintmit(sc->sc_ah); + error = sysctl_handle_int(oidp, &intmit, 0, req); + if (error || !req->newptr) + return error; + return !ath_hal_setintmit(sc->sc_ah, intmit) ? EINVAL : 0; +} + static void ath_sysctlattach(struct ath_softc *sc) { @@ -6713,6 +6726,11 @@ ath_sysctlattach(struct ath_softc *sc) "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_rfkill, "I", "enable/disable RF kill switch"); } + if (ath_hal_hasintmit(ah)) { + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "intmit", CTLTYPE_INT | CTLFLAG_RW, sc, 0, + ath_sysctl_intmit, "I", "interference mitigation"); + } sc->sc_monpass = HAL_RXERR_DECRYPT | HAL_RXERR_MIC; SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "monpass", CTLFLAG_RW, &sc->sc_monpass, 0, Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 17:19:39 2008 (r184353) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 17:22:46 2008 (r184354) @@ -601,6 +601,12 @@ void ath_intr(void *); (ath_hal_getcapability(_ah, HAL_CAP_TPC_CTS, 0, _ptpcts) == HAL_OK) #define ath_hal_settpcts(_ah, _tpcts) \ ath_hal_setcapability(_ah, HAL_CAP_TPC_CTS, 0, _tpcts, NULL) +#define ath_hal_hasintmit(_ah) \ + (ath_hal_getcapability(_ah, HAL_CAP_INTMIT, 0, NULL) == HAL_OK) +#define ath_hal_getintmit(_ah) \ + (ath_hal_getcapability(_ah, HAL_CAP_INTMIT, 1, NULL) == HAL_OK) +#define ath_hal_setintmit(_ah, _v) \ + ath_hal_setcapability(_ah, HAL_CAP_INTMIT, 1, _v, NULL) #define ath_hal_getchannoise(_ah, _c) \ ((*(_ah)->ah_getChanNoise)((_ah), (_c))) #if HAL_ABI_VERSION < 0x05122200 From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:35:10 2008 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 28245106571D; Mon, 27 Oct 2008 17:35:10 +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 1642D8FC14; Mon, 27 Oct 2008 17:35:10 +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 m9RHZ9Qs046959; Mon, 27 Oct 2008 17:35:09 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHZ9Ph046957; Mon, 27 Oct 2008 17:35:09 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271735.m9RHZ9Ph046957@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:35:09 +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: r184355 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:35:10 -0000 Author: sam Date: Mon Oct 27 17:35:09 2008 New Revision: 184355 URL: http://svn.freebsd.org/changeset/base/184355 Log: add regdomain debug msgs Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:22:46 2008 (r184354) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:35:09 2008 (r184355) @@ -259,6 +259,7 @@ enum { ATH_DEBUG_LED = 0x00100000, /* led management */ ATH_DEBUG_FF = 0x00200000, /* fast frames */ ATH_DEBUG_DFS = 0x00400000, /* DFS processing */ + ATH_DEBUG_REGDOMAIN = 0x02000000, /* regulatory processing */ ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ ATH_DEBUG_ANY = 0xffffffff }; @@ -5860,6 +5861,9 @@ getchannels(struct ath_softc *sc, int *n HAL_CHANNEL *halchans; int i, nhalchans, error; + DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: cc %u outdoor %u ecm %u\n", + __func__, cc, outdoor, ecm); + halchans = malloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL), M_TEMP, M_NOWAIT | M_ZERO); if (halchans == NULL) { @@ -5933,7 +5937,11 @@ ath_setregdomain(struct ieee80211com *ic (void) ath_hal_getregdomain(ah, &ord); /* XXX map sku->rd */ + DPRINTF(sc, ATH_DEBUG_REGDOMAIN, + "%s: rd %u cc %u location %c ecm %u\n", + __func__, rd->regdomain, rd->country, rd->location, rd->ecm); ath_hal_setregdomain(ah, rd->regdomain); + error = getchannels(sc, &nchans, chans, rd->country, rd->ecm ? AH_TRUE : AH_FALSE, rd->location == 'O' ? AH_TRUE : AH_FALSE); @@ -5959,6 +5967,10 @@ ath_getradiocaps(struct ieee80211com *ic u_int32_t ord; (void) ath_hal_getregdomain(ah, &ord); + + DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: use rd %u cc %d, ord %u\n", + __func__, 0, CTRY_DEBUG, ord); + ath_hal_setregdomain(ah, 0); /* XXX not quite right but close enough for now */ getchannels(sc, nchans, chans, CTRY_DEBUG, AH_TRUE, AH_FALSE); @@ -6007,6 +6019,12 @@ ath_getchannels(struct ath_softc *sc) ic->ic_regdomain.location = 'I'; ic->ic_regdomain.isocc[0] = ' '; /* XXX don't know */ ic->ic_regdomain.isocc[1] = ' '; + + DPRINTF(sc, ATH_DEBUG_REGDOMAIN, + "%s: eeprom rd %u cc %u (mapped rd %u cc %u) location %c ecm %u\n", + __func__, sc->sc_eerd, sc->sc_eecc, + ic->ic_regdomain.regdomain, ic->ic_regdomain.country, + ic->ic_regdomain.location, ic->ic_regdomain.ecm); return 0; } From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:41:32 2008 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 836B41065670; Mon, 27 Oct 2008 17:41:32 +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 7120A8FC0A; Mon, 27 Oct 2008 17:41: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 m9RHfWZq047106; Mon, 27 Oct 2008 17:41:32 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHfWAc047104; Mon, 27 Oct 2008 17:41:32 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271741.m9RHfWAc047104@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:41: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: r184356 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:41:32 -0000 Author: sam Date: Mon Oct 27 17:41:32 2008 New Revision: 184356 URL: http://svn.freebsd.org/changeset/base/184356 Log: Regdomain fixups: o pass country code, outdoor indication, and ecm mode into the hal when requesting a channel list o add a console msg when regulatory setup fails o add placeholder code to map between Atheros sku's and 802.11 sku's that handles only the debug country code used to unlock the full channel list (to be used only for debugging) o fix multiple instances of mismapping the 802.11 location to the outdoor indication (anywhere may be outdoor also) Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:35:09 2008 (r184355) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:41:32 2008 (r184356) @@ -5873,7 +5873,11 @@ getchannels(struct ath_softc *sc, int *n } error = 0; if (!ath_hal_init_channels(ah, halchans, IEEE80211_CHAN_MAX, &nhalchans, - NULL, 0, NULL, CTRY_DEFAULT, HAL_MODE_ALL, AH_FALSE, AH_TRUE)) { + NULL, 0, NULL, cc, HAL_MODE_ALL, outdoor, ecm)) { + u_int32_t rd; + (void) ath_hal_getregdomain(ah, &rd); + device_printf(sc->sc_dev, "ath_hal_init_channels failed, " + "rd %d cc %u outdoor %u ecm %u\n", rd, cc, outdoor, ecm); error = EINVAL; goto done; } @@ -5926,25 +5930,47 @@ done: return error; } +/* XXX hard to include ieee80211_regdomain.h right now */ +#define SKU_DEBUG 0x1ff + +static void +ath_maprd(const struct ieee80211_regdomain *rd, + u_int32_t *ath_rd, u_int32_t *ath_cc) +{ + /* map SKU's to Atheros sku's */ + switch (rd->regdomain) { + case SKU_DEBUG: + if (rd->country == 0) { + *ath_rd = 0; + *ath_cc = CTRY_DEBUG; + return; + } + break; + } + *ath_rd = rd->regdomain; + *ath_cc = rd->country; +} + static int ath_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, int nchans, struct ieee80211_channel chans[]) { struct ath_softc *sc = ic->ic_ifp->if_softc; struct ath_hal *ah = sc->sc_ah; - u_int32_t ord; + u_int32_t ord, regdomain, cc; int error; (void) ath_hal_getregdomain(ah, &ord); - /* XXX map sku->rd */ + ath_maprd(rd, ®domain, &cc); DPRINTF(sc, ATH_DEBUG_REGDOMAIN, - "%s: rd %u cc %u location %c ecm %u\n", - __func__, rd->regdomain, rd->country, rd->location, rd->ecm); - ath_hal_setregdomain(ah, rd->regdomain); + "%s: rd %u cc %u location %c ecm %u (mapped rd %u cc %u)\n", + __func__, rd->regdomain, rd->country, rd->location, rd->ecm, + regdomain, cc); + ath_hal_setregdomain(ah, regdomain); - error = getchannels(sc, &nchans, chans, rd->country, + error = getchannels(sc, &nchans, chans, cc, rd->ecm ? AH_TRUE : AH_FALSE, - rd->location == 'O' ? AH_TRUE : AH_FALSE); + rd->location != 'I' ? AH_TRUE : AH_FALSE); if (error != 0) { /* * Restore previous state. @@ -5952,7 +5978,7 @@ ath_setregdomain(struct ieee80211com *ic ath_hal_setregdomain(ah, ord); (void) getchannels(sc, NULL, NULL, ic->ic_regdomain.country, ic->ic_regdomain.ecm ? AH_TRUE : AH_FALSE, - ic->ic_regdomain.location == 'O' ? AH_TRUE : AH_FALSE); + ic->ic_regdomain.location != 'I' ? AH_TRUE : AH_FALSE); return error; } return 0; @@ -5979,14 +6005,28 @@ ath_getradiocaps(struct ieee80211com *ic ath_hal_setregdomain(ah, ord); (void) getchannels(sc, NULL, NULL, ic->ic_regdomain.country, ic->ic_regdomain.ecm ? AH_TRUE : AH_FALSE, - ic->ic_regdomain.location == 'O' ? AH_TRUE : AH_FALSE); + ic->ic_regdomain.location != 'I' ? AH_TRUE : AH_FALSE); } -static int -ath_mapregdomain(struct ath_softc *sc, u_int32_t rd) +static void +ath_mapsku(u_int32_t ath_rd, u_int32_t ath_cc, struct ieee80211_regdomain *rd) { - /* map Atheros rd's to SKU's */ - return rd; + rd->isocc[0] = ' '; /* XXX don't know */ + rd->isocc[1] = ' '; + + /* map Atheros sku's to SKU's */ + switch (ath_rd) { + case 0: + if (ath_cc == CTRY_DEBUG) { + rd->regdomain = SKU_DEBUG; + rd->country = 0; + return; + } + break; + } + /* XXX net80211 types too small */ + rd->regdomain = (uint16_t) ath_rd; + rd->country = (uint16_t) ath_cc; } static int @@ -6013,12 +6053,9 @@ ath_getchannels(struct ath_softc *sc) } return error; } - ic->ic_regdomain.regdomain = ath_mapregdomain(sc, sc->sc_eerd); - ic->ic_regdomain.country = sc->sc_eecc; ic->ic_regdomain.ecm = 1; ic->ic_regdomain.location = 'I'; - ic->ic_regdomain.isocc[0] = ' '; /* XXX don't know */ - ic->ic_regdomain.isocc[1] = ' '; + ath_mapsku(sc->sc_eerd, sc->sc_eecc, &ic->ic_regdomain); DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: eeprom rd %u cc %u (mapped rd %u cc %u) location %c ecm %u\n", From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:43:24 2008 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 F26A61065673; Mon, 27 Oct 2008 17:43:23 +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 D9CF78FC16; Mon, 27 Oct 2008 17:43:23 +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 m9RHhNSC047173; Mon, 27 Oct 2008 17:43:23 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHhNpZ047171; Mon, 27 Oct 2008 17:43:23 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271743.m9RHhNpZ047171@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:43:23 +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: r184357 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:43:24 -0000 Author: sam Date: Mon Oct 27 17:43:23 2008 New Revision: 184357 URL: http://svn.freebsd.org/changeset/base/184357 Log: update the sta inactivity timer only if we actually received an ACK Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:41:32 2008 (r184356) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:43:23 2008 (r184357) @@ -5040,7 +5040,8 @@ ath_tx_processq(struct ath_softc *sc, st pri = M_WME_GETAC(bf->bf_m); if (pri >= WME_AC_VO) ic->ic_wme.wme_hipri_traffic++; - ni->ni_inact = ni->ni_inact_reload; + if ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0) + ni->ni_inact = ni->ni_inact_reload; } else { if (ts->ts_status & HAL_TXERR_XRETRY) sc->sc_stats.ast_tx_xretries++; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:51:25 2008 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 03888106566C; Mon, 27 Oct 2008 17:51:25 +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 E61E28FC1A; Mon, 27 Oct 2008 17:51:24 +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 m9RHpOa5047352; Mon, 27 Oct 2008 17:51:24 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHpOhI047349; Mon, 27 Oct 2008 17:51:24 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271751.m9RHpOhI047349@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:51:24 +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: r184358 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:51:25 -0000 Author: sam Date: Mon Oct 27 17:51:24 2008 New Revision: 184358 URL: http://svn.freebsd.org/changeset/base/184358 Log: Fixup statistics: o update tx rssi data only when an ACK was received o return tx rssi from sampled data instead of the last frame o track noise floor o return rx rssi and noise floor (was broken) Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:43:23 2008 (r184357) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:51:24 2008 (r184358) @@ -3978,6 +3978,7 @@ ath_rx_proc(void *arg, int npending) DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s: pending %u\n", __func__, npending); ngood = 0; nf = ath_hal_getchannoise(ah, &sc->sc_curchan); + sc->sc_stats.ast_rx_noise = nf; tsf = ath_hal_gettsf64(ah); do { bf = STAILQ_FIRST(&sc->sc_rxbuf); @@ -5034,9 +5035,6 @@ ath_tx_processq(struct ath_softc *sc, st sc->sc_ant_tx[txant]++; if (ts->ts_rate & HAL_TXSTAT_ALTRATE) sc->sc_stats.ast_tx_altrate++; - sc->sc_stats.ast_tx_rssi = ts->ts_rssi; - ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, - ts->ts_rssi); pri = M_WME_GETAC(bf->bf_m); if (pri >= WME_AC_VO) ic->ic_wme.wme_hipri_traffic++; @@ -5062,11 +5060,16 @@ ath_tx_processq(struct ath_softc *sc, st if ((ts->ts_status & HAL_TXERR_FILT) == 0 && (bf->bf_txflags & HAL_TXDESC_NOACK) == 0) { /* - * If frame was ack'd update the last rx time - * used to workaround phantom bmiss interrupts. + * If frame was ack'd update statistics, + * including the last rx time used to + * workaround phantom bmiss interrupts. */ - if (ts->ts_status == 0) + if (ts->ts_status == 0) { nacked++; + sc->sc_stats.ast_tx_rssi = ts->ts_rssi; + ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, + ts->ts_rssi); + } ath_rate_tx_complete(sc, an, bf); } /* @@ -6372,6 +6375,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, struct ath_softc *sc = ifp->if_softc; struct ieee80211com *ic = ifp->if_l2com; struct ifreq *ifr = (struct ifreq *)data; + const HAL_RATE_TABLE *rt; int error = 0; switch (cmd) { @@ -6414,10 +6418,9 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, /* NB: embed these numbers to get a consistent view */ sc->sc_stats.ast_tx_packets = ifp->if_opackets; sc->sc_stats.ast_rx_packets = ifp->if_ipackets; -#if 0 - ieee80211_getsignal(ic, &sc->sc_stats.ast_rx_rssi, - &sc->sc_stats.ast_rx_noise); -#endif + sc->sc_stats.ast_tx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgtxrssi); + sc->sc_stats.ast_rx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgrssi); + rt = sc->sc_currates; sc->sc_stats.ast_tx_rate = sc->sc_hwmap[sc->sc_txrate].ieeerate; return copyout(&sc->sc_stats, ifr->ifr_data, sizeof (sc->sc_stats)); Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 17:43:23 2008 (r184357) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 17:51:24 2008 (r184358) @@ -100,6 +100,9 @@ struct ath_node { if ((y) >= -20) \ x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \ } while (0) +#define ATH_EP_RND(x,mul) \ + ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) +#define ATH_RSSI(x) ATH_EP_RND(x, HAL_RSSI_EP_MULTIPLIER) struct ath_buf { STAILQ_ENTRY(ath_buf) bf_list; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:52:41 2008 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 DD6C71065685; Mon, 27 Oct 2008 17:52:41 +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 CC2888FC2B; Mon, 27 Oct 2008 17:52:41 +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 m9RHqfPp047413; Mon, 27 Oct 2008 17:52:41 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHqfCd047411; Mon, 27 Oct 2008 17:52:41 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271752.m9RHqfCd047411@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:52:41 +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: r184359 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:52:42 -0000 Author: sam Date: Mon Oct 27 17:52:41 2008 New Revision: 184359 URL: http://svn.freebsd.org/changeset/base/184359 Log: correct callback status parameter; only indicate success when an ACK was received Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:51:24 2008 (r184358) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:52:41 2008 (r184359) @@ -5078,7 +5078,8 @@ ath_tx_processq(struct ath_softc *sc, st */ if (bf->bf_m->m_flags & M_TXCB) ieee80211_process_callback(ni, bf->bf_m, - ts->ts_status); + (bf->bf_txflags & HAL_TXDESC_NOACK) == 0 ? + ts->ts_status : HAL_TXERR_XRETRY); /* * Reclaim reference to node. * From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:53:34 2008 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 95114106567C; Mon, 27 Oct 2008 17:53:34 +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 83AA98FC2E; Mon, 27 Oct 2008 17:53:34 +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 m9RHrYb6047467; Mon, 27 Oct 2008 17:53:34 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHrYfA047465; Mon, 27 Oct 2008 17:53:34 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271753.m9RHrYfA047465@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:53:34 +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: r184360 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:53:34 -0000 Author: sam Date: Mon Oct 27 17:53:34 2008 New Revision: 184360 URL: http://svn.freebsd.org/changeset/base/184360 Log: fix comment Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:52:41 2008 (r184359) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:53:34 2008 (r184360) @@ -5218,7 +5218,7 @@ ath_tx_draintxq(struct ath_softc *sc, st /* * NB: this assumes output has been stopped and - * we do not need to block ath_tx_tasklet + * we do not need to block ath_tx_proc */ for (ix = 0;; ix++) { ATH_TXQ_LOCK(txq); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:54:17 2008 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 88797106566C; Mon, 27 Oct 2008 17:54:17 +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 779538FC28; Mon, 27 Oct 2008 17:54:17 +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 m9RHsHjF047528; Mon, 27 Oct 2008 17:54:17 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHsH72047526; Mon, 27 Oct 2008 17:54:17 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271754.m9RHsH72047526@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:54:17 +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: r184361 - head/sys/dev/ath 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: Mon, 27 Oct 2008 17:54:17 -0000 Author: sam Date: Mon Oct 27 17:54:17 2008 New Revision: 184361 URL: http://svn.freebsd.org/changeset/base/184361 Log: install bssid for ahdemo mode too Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 17:53:34 2008 (r184360) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:54:17 2008 (r184361) @@ -5673,6 +5673,7 @@ ath_newstate(struct ieee80211vap *vap, e ni = vap->iv_bss; rfilt = ath_calcrxfilter(sc); stamode = (vap->iv_opmode == IEEE80211_M_STA || + vap->iv_opmode == IEEE80211_M_AHDEMO || vap->iv_opmode == IEEE80211_M_IBSS); if (stamode && nstate == IEEE80211_S_RUN) { sc->sc_curaid = ni->ni_associd; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 17:57:04 2008 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 22E68106567A; Mon, 27 Oct 2008 17:57:04 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 11FBB8FC20; Mon, 27 Oct 2008 17:57:04 +0000 (UTC) (envelope-from bz@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 m9RHv3bo047651; Mon, 27 Oct 2008 17:57:03 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHv3Wb047650; Mon, 27 Oct 2008 17:57:03 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200810271757.m9RHv3Wb047650@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Mon, 27 Oct 2008 17:57:03 +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: r184362 - head/sys/conf 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: Mon, 27 Oct 2008 17:57:04 -0000 Author: bz Date: Mon Oct 27 17:57:03 2008 New Revision: 184362 URL: http://svn.freebsd.org/changeset/base/184362 Log: Add the files missed with r184331 to make mac_bsdextended compile again. Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Oct 27 17:54:17 2008 (r184361) +++ head/sys/conf/files Mon Oct 27 17:57:03 2008 (r184362) @@ -2194,6 +2194,8 @@ security/mac/mac_sysv_shm.c optional mac security/mac/mac_vfs.c optional mac security/mac_biba/mac_biba.c optional mac_biba security/mac_bsdextended/mac_bsdextended.c optional mac_bsdextended +security/mac_bsdextended/ugidfw_system.c optional mac_bsdextended +security/mac_bsdextended/ugidfw_vnode.c optional mac_bsdextended security/mac_ifoff/mac_ifoff.c optional mac_ifoff security/mac_lomac/mac_lomac.c optional mac_lomac security/mac_mls/mac_mls.c optional mac_mls From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:00:44 2008 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 05BDE1065674; Mon, 27 Oct 2008 18:00:44 +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 E81038FC18; Mon, 27 Oct 2008 18:00:43 +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 m9RI0h5p047846; Mon, 27 Oct 2008 18:00:43 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RI0h3e047844; Mon, 27 Oct 2008 18:00:43 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271800.m9RI0h3e047844@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:00:43 +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: r184364 - head/sys/dev/ath 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: Mon, 27 Oct 2008 18:00:44 -0000 Author: sam Date: Mon Oct 27 18:00:43 2008 New Revision: 184364 URL: http://svn.freebsd.org/changeset/base/184364 Log: add hack to deal with Ubiquiti XR9 cards, they have a different mapping between 900MHz and 2.4GHz frequencies than SR9 cards; they are distinguished by different country codes Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:00:39 2008 (r184363) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:00:43 2008 (r184364) @@ -120,6 +120,8 @@ enum { ATH_LED_POLL, }; +#define CTRY_XR9 5001 /* Ubiquiti XR9 */ + static struct ieee80211vap *ath_vap_create(struct ieee80211com *, const char name[IFNAMSIZ], int unit, int opmode, int flags, const uint8_t bssid[IEEE80211_ADDR_LEN], @@ -1317,7 +1319,8 @@ ath_bmiss_proc(void *arg, int pending) * the frequency possibly mapped for GSM channels. */ static void -ath_mapchan(HAL_CHANNEL *hc, const struct ieee80211_channel *chan) +ath_mapchan(const struct ieee80211com *ic, + HAL_CHANNEL *hc, const struct ieee80211_channel *chan) { #define N(a) (sizeof(a) / sizeof(a[0])) static const u_int modeflags[IEEE80211_MODE_MAX] = { @@ -1348,8 +1351,13 @@ ath_mapchan(HAL_CHANNEL *hc, const struc if (IEEE80211_IS_CHAN_HT40U(chan)) hc->channelFlags |= CHANNEL_HT40PLUS; - hc->channel = IEEE80211_IS_CHAN_GSM(chan) ? - 2422 + (922 - chan->ic_freq) : chan->ic_freq; + if (IEEE80211_IS_CHAN_GSM(chan)) { + if (ic->ic_regdomain.country == CTRY_XR9) + hc->channel = 2427 + (chan->ic_freq - 907); + else + hc->channel = 2422 + (922 - chan->ic_freq); + } else + hc->channel = chan->ic_freq; #undef N } @@ -1402,7 +1410,7 @@ ath_init(void *arg) * be followed by initialization of the appropriate bits * and then setup of the interrupt mask. */ - ath_mapchan(&sc->sc_curchan, ic->ic_curchan); + ath_mapchan(ic, &sc->sc_curchan, ic->ic_curchan); ath_settkipmic(sc); if (!ath_hal_reset(ah, sc->sc_opmode, &sc->sc_curchan, AH_FALSE, &status)) { if_printf(ifp, "unable to reset hardware; hal status %u\n", @@ -1539,7 +1547,7 @@ ath_reset(struct ifnet *ifp) * Convert to a HAL channel description with the flags * constrained to reflect the current operating mode. */ - ath_mapchan(&sc->sc_curchan, ic->ic_curchan); + ath_mapchan(ic, &sc->sc_curchan, ic->ic_curchan); ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop xmit side */ @@ -3723,7 +3731,7 @@ ath_node_getsignal(const struct ieee8021 *rssi = ic->ic_node_getrssi(ni); if (ni->ni_chan != IEEE80211_CHAN_ANYC) { - ath_mapchan(&hchan, ni->ni_chan); + ath_mapchan(ic, &hchan, ni->ni_chan); *noise = ath_hal_getchannoise(ah, &hchan); } else *noise = -95; /* nominally correct */ @@ -5435,7 +5443,7 @@ ath_chan_set(struct ath_softc *sc, struc * the flags constrained to reflect the current * operating mode. */ - ath_mapchan(&hchan, chan); + ath_mapchan(ic, &hchan, chan); DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, hal flags 0x%x) -> %u (%u MHz, hal flags 0x%x)\n", @@ -5918,8 +5926,15 @@ getchannels(struct ath_softc *sc, int *n } if (ath_hal_isgsmsku(ah)) { - /* remap to true frequencies */ - ichan->ic_freq = 922 + (2422 - ichan->ic_freq); + /* + * Remap to true frequencies: Ubiquiti XR9 cards use a + * frequency mapping different from their SR9 cards. + * We define special country codes to deal with this. + */ + if (cc == CTRY_XR9) + ichan->ic_freq = 907 + (ichan->ic_freq - 2427); + else + ichan->ic_freq = 922 + (2422 - ichan->ic_freq); ichan->ic_flags |= IEEE80211_CHAN_GSM; ichan->ic_ieee = ieee80211_mhz2ieee(ichan->ic_freq, ichan->ic_flags); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:02:47 2008 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 B081A1065676; Mon, 27 Oct 2008 18:02:47 +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 9EF8F8FC1D; Mon, 27 Oct 2008 18:02:47 +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 m9RI2lFF047916; Mon, 27 Oct 2008 18:02:47 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RI2lIb047915; Mon, 27 Oct 2008 18:02:47 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271802.m9RI2lIb047915@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:02:47 +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: r184365 - head/sys/dev/ath 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: Mon, 27 Oct 2008 18:02:47 -0000 Author: sam Date: Mon Oct 27 18:02:47 2008 New Revision: 184365 URL: http://svn.freebsd.org/changeset/base/184365 Log: fix handling of HT rates; these overlap legacy rates and need to be marked as MCS in the inverse mapping table Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:00:43 2008 (r184364) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:02:47 2008 (r184365) @@ -6225,8 +6225,13 @@ ath_setcurmode(struct ath_softc *sc, enu memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); rt = sc->sc_rates[mode]; KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode)); - for (i = 0; i < rt->rateCount; i++) - sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i; + for (i = 0; i < rt->rateCount; i++) { + uint8_t ieeerate = rt->info[i].dot11Rate & IEEE80211_RATE_VAL; + if (rt->info[i].phy != IEEE80211_T_HT) + sc->sc_rixmap[ieeerate] = i; + else + sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; + } memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); for (i = 0; i < 32; i++) { u_int8_t ix = rt->rateCodeToIndex[i]; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:03:19 2008 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 5AB10106567B; Mon, 27 Oct 2008 18:03:19 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 34C738FC1B; Mon, 27 Oct 2008 18:03:19 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTP id AFFCF46B06; Mon, 27 Oct 2008 14:03:18 -0400 (EDT) Date: Mon, 27 Oct 2008 18:03:18 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: "Bjoern A. Zeeb" In-Reply-To: <200810271757.m9RHv3Wb047650@svn.freebsd.org> Message-ID: References: <200810271757.m9RHv3Wb047650@svn.freebsd.org> User-Agent: Alpine 1.10 (BSF 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184362 - head/sys/conf 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: Mon, 27 Oct 2008 18:03:19 -0000 On Mon, 27 Oct 2008, Bjoern A. Zeeb wrote: > Log: > Add the files missed with r184331 to make mac_bsdextended compile again. Thanks -- apparently I missed the conf directory when committing! Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > head/sys/conf/files > > Modified: head/sys/conf/files > ============================================================================== > --- head/sys/conf/files Mon Oct 27 17:54:17 2008 (r184361) > +++ head/sys/conf/files Mon Oct 27 17:57:03 2008 (r184362) > @@ -2194,6 +2194,8 @@ security/mac/mac_sysv_shm.c optional mac > security/mac/mac_vfs.c optional mac > security/mac_biba/mac_biba.c optional mac_biba > security/mac_bsdextended/mac_bsdextended.c optional mac_bsdextended > +security/mac_bsdextended/ugidfw_system.c optional mac_bsdextended > +security/mac_bsdextended/ugidfw_vnode.c optional mac_bsdextended > security/mac_ifoff/mac_ifoff.c optional mac_ifoff > security/mac_lomac/mac_lomac.c optional mac_lomac > security/mac_mls/mac_mls.c optional mac_mls > From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:05:26 2008 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 A986D106566B; Mon, 27 Oct 2008 18:05:26 +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 986A68FC1D; Mon, 27 Oct 2008 18:05:26 +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 m9RI5QFN048007; Mon, 27 Oct 2008 18:05:26 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RI5Q4d048006; Mon, 27 Oct 2008 18:05:26 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271805.m9RI5Q4d048006@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:05:26 +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: r184366 - head/sys/dev/ath 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: Mon, 27 Oct 2008 18:05:26 -0000 Author: sam Date: Mon Oct 27 18:05:26 2008 New Revision: 184366 URL: http://svn.freebsd.org/changeset/base/184366 Log: prefer #define to naked constant Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:02:47 2008 (r184365) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:05:26 2008 (r184366) @@ -6243,7 +6243,7 @@ ath_setcurmode(struct ath_softc *sc, enu sc->sc_hwmap[i].ieeerate = rt->info[ix].dot11Rate & IEEE80211_RATE_VAL; if (rt->info[ix].phy == IEEE80211_T_HT) - sc->sc_hwmap[i].ieeerate |= 0x80; /* MCS */ + sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS; sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; if (rt->info[ix].shortPreamble || rt->info[ix].phy == IEEE80211_T_OFDM) From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:08:13 2008 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 54BFF106567E; Mon, 27 Oct 2008 18:08:13 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 42F1C8FC19; Mon, 27 Oct 2008 18:08:13 +0000 (UTC) (envelope-from rwatson@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 m9RI8D0X048110; Mon, 27 Oct 2008 18:08:13 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RI8Di9048109; Mon, 27 Oct 2008 18:08:13 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810271808.m9RI8Di9048109@svn.freebsd.org> From: Robert Watson Date: Mon, 27 Oct 2008 18:08:13 +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: r184367 - head/sys/security/mac_bsdextended 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: Mon, 27 Oct 2008 18:08:13 -0000 Author: rwatson Date: Mon Oct 27 18:08:12 2008 New Revision: 184367 URL: http://svn.freebsd.org/changeset/base/184367 Log: When the mac_bsdextended policy is unloaded, free rule memory. Obtained from: TrustedBSD Project MFC after: 3 days Modified: head/sys/security/mac_bsdextended/mac_bsdextended.c Modified: head/sys/security/mac_bsdextended/mac_bsdextended.c ============================================================================== --- head/sys/security/mac_bsdextended/mac_bsdextended.c Mon Oct 27 18:05:26 2008 (r184366) +++ head/sys/security/mac_bsdextended/mac_bsdextended.c Mon Oct 27 18:08:12 2008 (r184367) @@ -214,7 +214,12 @@ ugidfw_init(struct mac_policy_conf *mpc) static void ugidfw_destroy(struct mac_policy_conf *mpc) { + int i; + for (i = 0; i < MAC_BSDEXTENDED_MAXRULES; i++) { + if (rules[i] != NULL) + free(rules[i], M_MACBSDEXTENDED); + } mtx_destroy(&ugidfw_mtx); } From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:22:44 2008 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 E8D25106567C; Mon, 27 Oct 2008 18:22:44 +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 D57A18FC14; Mon, 27 Oct 2008 18:22:44 +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 m9RIMikx049028; Mon, 27 Oct 2008 18:22:44 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RIMiKh049025; Mon, 27 Oct 2008 18:22:44 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271822.m9RIMiKh049025@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:22:44 +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: r184368 - in head/sys/dev/ath: . ath_rate/sample 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: Mon, 27 Oct 2008 18:22:45 -0000 Author: sam Date: Mon Oct 27 18:22:44 2008 New Revision: 184368 URL: http://svn.freebsd.org/changeset/base/184368 Log: o With the addition of HT rates the set of h/w codes has a much wider range making the use of sc_hwmap to do direct mapping impractical. Switch to indexing by the rate index instead of the rate code and adjust associated state and logic appropriately. This has several benefits including simplification of the led code. o fix radiotap capture of HT rates o fix conditional compilation of HT radiotap support to be based on the hal having 5416 support; not the ABI version as hal builds may or may not include 5416 support Modified: head/sys/dev/ath/ath_rate/sample/sample.c head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 18:08:12 2008 (r184367) +++ head/sys/dev/ath/ath_rate/sample/sample.c Mon Oct 27 18:22:44 2008 (r184368) @@ -493,9 +493,11 @@ ath_rate_tx_complete(struct ath_softc *s const struct ath_tx_status *ts = &bf->bf_status.ds_txstat; const struct ath_desc *ds0 = &bf->bf_desc[0]; int final_rate, short_tries, long_tries, frame_size; + const HAL_RATE_TABLE *rt = sc->sc_currates; int mrr; - final_rate = sc->sc_hwmap[ts->ts_rate &~ HAL_TXSTAT_ALTRATE].ieeerate; + final_rate = sc->sc_hwmap[ + rt->rateCodeToIndex[ts->ts_rate &~ HAL_TXSTAT_ALTRATE]].ieeerate; short_tries = ts->ts_shortretry; long_tries = ts->ts_longretry + 1; frame_size = ds0->ds_ctl0 & 0x0fff; /* low-order 12 bits of ds_ctl0 */ @@ -557,19 +559,19 @@ ath_rate_tx_complete(struct ath_softc *s hwrate3 = MS(ds0->ds_ctl3, AR5416_XmitRate3); } - rate0 = sc->sc_hwmap[hwrate0].ieeerate; + rate0 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate0]].ieeerate; tries0 = MS(ds0->ds_ctl2, AR_XmitDataTries0); ndx0 = rate_to_ndx(sn, rate0); - rate1 = sc->sc_hwmap[hwrate1].ieeerate; + rate1 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate1]].ieeerate; tries1 = MS(ds0->ds_ctl2, AR_XmitDataTries1); ndx1 = rate_to_ndx(sn, rate1); - rate2 = sc->sc_hwmap[hwrate2].ieeerate; + rate2 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate2]].ieeerate; tries2 = MS(ds0->ds_ctl2, AR_XmitDataTries2); ndx2 = rate_to_ndx(sn, rate2); - rate3 = sc->sc_hwmap[hwrate3].ieeerate; + rate3 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate3]].ieeerate; tries3 = MS(ds0->ds_ctl2, AR_XmitDataTries3); ndx3 = rate_to_ndx(sn, rate3); Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:08:12 2008 (r184367) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:22:44 2008 (r184368) @@ -114,12 +114,6 @@ CTASSERT(ATH_BCBUF <= 8); ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) -enum { - ATH_LED_TX, - ATH_LED_RX, - ATH_LED_POLL, -}; - #define CTRY_XR9 5001 /* Ubiquiti XR9 */ static struct ieee80211vap *ath_vap_create(struct ieee80211com *, @@ -3898,12 +3892,13 @@ static int ath_rx_tap(struct ifnet *ifp, struct mbuf *m, const struct ath_rx_status *rs, u_int64_t tsf, int16_t nf) { -#define CHAN_HT htole32(CHANNEL_HT20|CHANNEL_HT40PLUS|CHANNEL_HT40MINUS) #define CHAN_HT20 htole32(IEEE80211_CHAN_HT20) #define CHAN_HT40U htole32(IEEE80211_CHAN_HT40U) #define CHAN_HT40D htole32(IEEE80211_CHAN_HT40D) +#define CHAN_HT (CHAN_HT20|CHAN_HT40U|CHAN_HT40D) struct ath_softc *sc = ifp->if_softc; - u_int8_t rix; + const HAL_RATE_TABLE *rt; + uint8_t rix; /* * Discard anything shorter than an ack or cts. @@ -3914,12 +3909,14 @@ ath_rx_tap(struct ifnet *ifp, struct mbu sc->sc_stats.ast_rx_tooshort++; return 0; } - rix = rs->rs_rate; + rt = sc->sc_currates; + KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); + rix = rt->rateCodeToIndex[rs->rs_rate]; sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate; sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].rxflags; -#if HAL_ABI_VERSION >= 0x07050400 +#ifdef AH_SUPPORT_AR5416 sc->sc_rx_th.wr_chan_flags &= ~CHAN_HT; - if (sc->sc_rx_th.wr_rate & 0x80) { /* HT rate */ + if (sc->sc_rx_th.wr_rate & IEEE80211_RATE_MCS) { /* HT rate */ if ((rs->rs_flags & HAL_RX_2040) == 0) sc->sc_rx_th.wr_chan_flags |= CHAN_HT20; else if (sc->sc_curchan.channelFlags & CHANNEL_HT40PLUS) @@ -3941,10 +3938,10 @@ ath_rx_tap(struct ifnet *ifp, struct mbu bpf_mtap2(ifp->if_bpf, &sc->sc_rx_th, sc->sc_rx_th_len, m); return 1; +#undef CHAN_HT #undef CHAN_HT20 #undef CHAN_HT40U #undef CHAN_HT40D -#undef CHAN_HT } static void @@ -4175,9 +4172,11 @@ rx_accept: } if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) { + const HAL_RATE_TABLE *rt = sc->sc_currates; + uint8_t rix = rt->rateCodeToIndex[rs->rs_rate]; + ieee80211_dump_pkt(ic, mtod(m, caddr_t), len, - sc->sc_hwmap[rs->rs_rate].ieeerate, - rs->rs_rssi); + sc->sc_hwmap[rix].ieeerate, rs->rs_rssi); } m_adj(m, -IEEE80211_CRC_LEN); @@ -4235,10 +4234,11 @@ rx_accept: * periodic beacon frames to trigger the poll event. */ if (type == IEEE80211_FC0_TYPE_DATA) { - sc->sc_rxrate = rs->rs_rate; - ath_led_event(sc, ATH_LED_RX); + const HAL_RATE_TABLE *rt = sc->sc_currates; + ath_led_event(sc, + rt->rateCodeToIndex[rs->rs_rate]); } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle) - ath_led_event(sc, ATH_LED_POLL); + ath_led_event(sc, 0); } rx_next: STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); @@ -4759,7 +4759,7 @@ ath_tx_start(struct ath_softc *sc, struc } else { ath_rate_findrate(sc, an, shortPreamble, pktlen, &rix, &try0, &txrate); - sc->sc_txrate = txrate; /* for LED blinking */ + sc->sc_txrix = rix; /* for LED blinking */ sc->sc_lastdatarix = rix; /* for fast frames */ if (try0 != ATH_TXMAXTRY) ismrr = 1; @@ -4916,18 +4916,18 @@ ath_tx_start(struct ath_softc *sc, struc if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT)) ieee80211_dump_pkt(ic, mtod(m0, caddr_t), m0->m_len, - sc->sc_hwmap[txrate].ieeerate, -1); + sc->sc_hwmap[rix].ieeerate, -1); if (bpf_peers_present(ifp->if_bpf)) { u_int64_t tsf = ath_hal_gettsf64(ah); sc->sc_tx_th.wt_tsf = htole64(tsf); - sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags; + sc->sc_tx_th.wt_flags = sc->sc_hwmap[rix].txflags; if (iswep) sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; if (isfrag) sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_FRAG; - sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate; + sc->sc_tx_th.wt_rate = sc->sc_hwmap[rix].ieeerate; sc->sc_tx_th.wt_txpower = ni->ni_txpower; sc->sc_tx_th.wt_antenna = sc->sc_txantenna; @@ -5143,7 +5143,7 @@ ath_tx_proc_q0(void *arg, int npending) ifp->if_timer = 0; if (sc->sc_softled) - ath_led_event(sc, ATH_LED_TX); + ath_led_event(sc, sc->sc_txrix); ath_start(ifp); } @@ -5180,7 +5180,7 @@ ath_tx_proc_q0123(void *arg, int npendin ifp->if_timer = 0; if (sc->sc_softled) - ath_led_event(sc, ATH_LED_TX); + ath_led_event(sc, sc->sc_txrix); ath_start(ifp); } @@ -5209,7 +5209,7 @@ ath_tx_proc(void *arg, int npending) ifp->if_timer = 0; if (sc->sc_softled) - ath_led_event(sc, ATH_LED_TX); + ath_led_event(sc, sc->sc_txrix); ath_start(ifp); } @@ -6121,26 +6121,12 @@ ath_led_blink(struct ath_softc *sc, int } static void -ath_led_event(struct ath_softc *sc, int event) +ath_led_event(struct ath_softc *sc, int rix) { - sc->sc_ledevent = ticks; /* time of last event */ if (sc->sc_blinking) /* don't interrupt active blink */ return; - switch (event) { - case ATH_LED_POLL: - ath_led_blink(sc, sc->sc_hwmap[0].ledon, - sc->sc_hwmap[0].ledoff); - break; - case ATH_LED_TX: - ath_led_blink(sc, sc->sc_hwmap[sc->sc_txrate].ledon, - sc->sc_hwmap[sc->sc_txrate].ledoff); - break; - case ATH_LED_RX: - ath_led_blink(sc, sc->sc_hwmap[sc->sc_rxrate].ledon, - sc->sc_hwmap[sc->sc_rxrate].ledoff); - break; - } + ath_led_blink(sc, sc->sc_hwmap[rix].ledon, sc->sc_hwmap[rix].ledoff); } static int @@ -6233,20 +6219,19 @@ ath_setcurmode(struct ath_softc *sc, enu sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; } memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); - for (i = 0; i < 32; i++) { - u_int8_t ix = rt->rateCodeToIndex[i]; - if (ix == 0xff) { + for (i = 0; i < N(sc->sc_hwmap); i++) { + if (i >= rt->rateCount) { sc->sc_hwmap[i].ledon = (500 * hz) / 1000; sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; continue; } sc->sc_hwmap[i].ieeerate = - rt->info[ix].dot11Rate & IEEE80211_RATE_VAL; - if (rt->info[ix].phy == IEEE80211_T_HT) + rt->info[i].dot11Rate & IEEE80211_RATE_VAL; + if (rt->info[i].phy == IEEE80211_T_HT) sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS; sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; - if (rt->info[ix].shortPreamble || - rt->info[ix].phy == IEEE80211_T_OFDM) + if (rt->info[i].shortPreamble || + rt->info[i].phy == IEEE80211_T_OFDM) sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; /* NB: receive frames include FCS */ sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags | @@ -6443,7 +6428,9 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, sc->sc_stats.ast_tx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgtxrssi); sc->sc_stats.ast_rx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgrssi); rt = sc->sc_currates; - sc->sc_stats.ast_tx_rate = sc->sc_hwmap[sc->sc_txrate].ieeerate; + /* XXX HT rates */ + sc->sc_stats.ast_tx_rate = + rt->info[sc->sc_txrix].dot11Rate &~ IEEE80211_RATE_BASIC; return copyout(&sc->sc_stats, ifr->ifr_data, sizeof (sc->sc_stats)); #ifdef ATH_DIAGAPI @@ -6894,7 +6881,7 @@ ath_tx_raw_start(struct ath_softc *sc, s txrate = rt->info[rix].rateCode; if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) txrate |= rt->info[rix].shortPreamble; - sc->sc_txrate = txrate; + sc->sc_txrix = rix; try0 = params->ibp_try0; ismrr = (params->ibp_try1 != 0); txantenna = params->ibp_pri >> 2; @@ -6932,16 +6919,16 @@ ath_tx_raw_start(struct ath_softc *sc, s if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT)) ieee80211_dump_pkt(ic, mtod(m0, caddr_t), m0->m_len, - sc->sc_hwmap[txrate].ieeerate, -1); + sc->sc_hwmap[rix].ieeerate, -1); if (bpf_peers_present(ifp->if_bpf)) { u_int64_t tsf = ath_hal_gettsf64(ah); sc->sc_tx_th.wt_tsf = htole64(tsf); - sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags; + sc->sc_tx_th.wt_flags = sc->sc_hwmap[rix].txflags; if (wh->i_fc[1] & IEEE80211_FC1_WEP) sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; - sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate; + sc->sc_tx_th.wt_rate = sc->sc_hwmap[rix].ieeerate; sc->sc_tx_th.wt_txpower = ni->ni_txpower; sc->sc_tx_th.wt_antenna = sc->sc_txantenna; Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 18:08:12 2008 (r184367) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 18:22:44 2008 (r184368) @@ -284,8 +284,7 @@ struct ath_softc { u_int sc_ledon; /* pin setting for LED on */ u_int sc_ledidle; /* idle polling interval */ int sc_ledevent; /* time of last LED event */ - u_int8_t sc_rxrate; /* current rx rate for LED */ - u_int8_t sc_txrate; /* current tx rate for LED */ + u_int8_t sc_txrix; /* current tx rate for LED */ u_int16_t sc_ledoff; /* off time for current blink */ struct callout sc_ledtimer; /* led off timer */ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:30:33 2008 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 865B11065673; Mon, 27 Oct 2008 18:30: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 743238FC17; Mon, 27 Oct 2008 18:30:33 +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 m9RIUXZe049560; Mon, 27 Oct 2008 18:30:33 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RIUXvn049557; Mon, 27 Oct 2008 18:30:33 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271830.m9RIUXvn049557@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:30:33 +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: r184369 - head/sys/dev/ath 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: Mon, 27 Oct 2008 18:30:33 -0000 Author: sam Date: Mon Oct 27 18:30:33 2008 New Revision: 184369 URL: http://svn.freebsd.org/changeset/base/184369 Log: prepare for a new hal Modified: head/sys/dev/ath/ah_osdep.c head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/ah_osdep.c ============================================================================== --- head/sys/dev/ath/ah_osdep.c Mon Oct 27 18:22:44 2008 (r184368) +++ head/sys/dev/ath/ah_osdep.c Mon Oct 27 18:30:33 2008 (r184369) @@ -71,8 +71,12 @@ extern void ath_hal_assert_failed(const int lineno, const char* msg); #endif #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +extern void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...); +#else extern void HALDEBUG(struct ath_hal *ah, const char* fmt, ...); extern void HALDEBUGn(struct ath_hal *ah, u_int level, const char* fmt, ...); +#endif #endif /* AH_DEBUG */ /* NB: put this here instead of the driver to avoid circular references */ @@ -139,6 +143,18 @@ ath_hal_ether_sprintf(const u_int8_t *ma } #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +void +HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) +{ + if (ath_hal_debug & mask) { + __va_list ap; + va_start(ap, fmt); + ath_hal_vprintf(ah, fmt, ap); + va_end(ap); + } +} +#else void HALDEBUG(struct ath_hal *ah, const char* fmt, ...) { @@ -160,6 +176,7 @@ HALDEBUGn(struct ath_hal *ah, u_int leve va_end(ap); } } +#endif #endif /* AH_DEBUG */ #ifdef AH_DEBUG_ALQ Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:22:44 2008 (r184368) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:30:33 2008 (r184369) @@ -298,6 +298,7 @@ ath_attach(u_int16_t devid, struct ath_s struct ath_hal *ah = NULL; HAL_STATUS status; int error = 0, i; + u_int wmodes; DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); @@ -605,7 +606,8 @@ ath_attach(u_int16_t devid, struct ath_s sc->sc_hastsfadd = ath_hal_hastsfadjust(ah); if (ath_hal_hasfastframes(ah)) ic->ic_caps |= IEEE80211_C_FF; - if (ath_hal_getwirelessmodes(ah, ic->ic_regdomain.country) & (HAL_MODE_108G|HAL_MODE_TURBO)) + wmodes = ath_hal_getwirelessmodes(ah, ic->ic_regdomain.country); + if (wmodes & (HAL_MODE_108G|HAL_MODE_TURBO)) ic->ic_caps |= IEEE80211_C_TURBOP; /* @@ -2550,10 +2552,10 @@ ath_key_update_end(struct ieee80211vap * * * o always accept unicast, broadcast, and multicast traffic * o accept PHY error frames when hardware doesn't have MIB support - * to count and we need them for ANI (sta mode only at the moment) + * to count and we need them for ANI (sta mode only until recently) * and we are not scanning (ANI is disabled) - * NB: only with recent hal's; older hal's add rx filter bits out - * of sight and we need to blindly preserve them + * NB: older hal's add rx filter bits out of sight and we need to + * blindly preserve them * o probe request frames are accepted only when operating in * hostap, adhoc, or monitor modes * o enable promiscuous mode @@ -2580,15 +2582,17 @@ ath_calcrxfilter(struct ath_softc *sc) struct ieee80211com *ic = ifp->if_l2com; u_int32_t rfilt; -#if HAL_ABI_VERSION < 0x08011600 - rfilt = (ath_hal_getrxfilter(sc->sc_ah) & - (HAL_RX_FILTER_PHYRADAR | HAL_RX_FILTER_PHYERR)) - | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; -#else rfilt = HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; +#if HAL_ABI_VERSION < 0x08011600 + rfilt |= (ath_hal_getrxfilter(sc->sc_ah) & + (HAL_RX_FILTER_PHYRADAR | HAL_RX_FILTER_PHYERR)); +#elif HAL_ABI_VERSION < 0x08060100 if (ic->ic_opmode == IEEE80211_M_STA && !sc->sc_needmib && !sc->sc_scanning) rfilt |= HAL_RX_FILTER_PHYERR; +#else + if (!sc->sc_needmib && !sc->sc_scanning) + rfilt |= HAL_RX_FILTER_PHYERR; #endif if (ic->ic_opmode != IEEE80211_M_STA) rfilt |= HAL_RX_FILTER_PROBEREQ; Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Mon Oct 27 18:22:44 2008 (r184368) +++ head/sys/dev/ath/if_athvar.h Mon Oct 27 18:30:33 2008 (r184369) @@ -506,6 +506,8 @@ void ath_intr(void *); (ath_hal_getcapability(_ah, HAL_CAP_CIPHER, _cipher, NULL) == HAL_OK) #define ath_hal_getregdomain(_ah, _prd) \ (ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK) +#if HAL_ABI_VERSION < 0x08090100 +/* XXX wrong for anything but amd64 and i386 */ #if defined(__LP64__) #define ath_hal_setregdomain(_ah, _rd) \ (*(uint16_t *)(((uint8_t *)&(_ah)[1]) + 176) = (_rd)) @@ -513,6 +515,10 @@ void ath_intr(void *); #define ath_hal_setregdomain(_ah, _rd) \ (*(uint16_t *)(((uint8_t *)&(_ah)[1]) + 128) = (_rd)) #endif +#else +#define ath_hal_setregdomain(_ah, _rd) \ + ath_hal_setcapability(_ah, HAL_CAP_REG_DMN, 0, _rd, NULL) +#endif #define ath_hal_getcountrycode(_ah, _pcc) \ (*(_pcc) = (_ah)->ah_countryCode) #define ath_hal_gettkipmic(_ah) \ From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:47:48 2008 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 771CC1065670; Mon, 27 Oct 2008 18:47:48 +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 6566C8FC31; Mon, 27 Oct 2008 18:47:48 +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 m9RIlmrL050258; Mon, 27 Oct 2008 18:47:48 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RIlm1W050257; Mon, 27 Oct 2008 18:47:48 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271847.m9RIlm1W050257@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:47:48 +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: r184370 - head/tools/tools/ath/athdebug 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: Mon, 27 Oct 2008 18:47:48 -0000 Author: sam Date: Mon Oct 27 18:47:48 2008 New Revision: 184370 URL: http://svn.freebsd.org/changeset/base/184370 Log: add regdomain knob Modified: head/tools/tools/ath/athdebug/athdebug.c Modified: head/tools/tools/ath/athdebug/athdebug.c ============================================================================== --- head/tools/tools/ath/athdebug/athdebug.c Mon Oct 27 18:30:33 2008 (r184369) +++ head/tools/tools/ath/athdebug/athdebug.c Mon Oct 27 18:47:48 2008 (r184370) @@ -41,6 +41,7 @@ #include #include #include +#include #define N(a) (sizeof(a)/sizeof(a[0])) @@ -68,6 +69,7 @@ enum { ATH_DEBUG_FF = 0x00200000, /* fast frames */ ATH_DEBUG_DFS = 0x00400000, /* DFS processing */ ATH_DEBUG_TDMA = 0x00800000, /* TDMA processing */ + ATH_DEBUG_REGDOMAIN = 0x02000000, /* regulatory processing */ ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ ATH_DEBUG_ANY = 0xffffffff }; @@ -97,6 +99,7 @@ static struct { { "ff", ATH_DEBUG_FF }, { "dfs", ATH_DEBUG_DFS }, { "tdma", ATH_DEBUG_TDMA }, + { "regdomain", ATH_DEBUG_REGDOMAIN }, { "fatal", ATH_DEBUG_FATAL }, }; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:50:46 2008 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 60ED11065673; Mon, 27 Oct 2008 18:50:46 +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 4EB568FC08; Mon, 27 Oct 2008 18:50:46 +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 m9RIokWj050377; Mon, 27 Oct 2008 18:50:46 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RIokT9050374; Mon, 27 Oct 2008 18:50:46 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271850.m9RIokT9050374@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:50:46 +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: r184371 - head/tools/tools/ath/athstats 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: Mon, 27 Oct 2008 18:50:46 -0000 Author: sam Date: Mon Oct 27 18:50:46 2008 New Revision: 184371 URL: http://svn.freebsd.org/changeset/base/184371 Log: sync w/ driver updates; this also brings in ani stats Modified: head/tools/tools/ath/athstats/Makefile head/tools/tools/ath/athstats/athstats.c head/tools/tools/ath/athstats/main.c Modified: head/tools/tools/ath/athstats/Makefile ============================================================================== --- head/tools/tools/ath/athstats/Makefile Mon Oct 27 18:47:48 2008 (r184370) +++ head/tools/tools/ath/athstats/Makefile Mon Oct 27 18:50:46 2008 (r184371) @@ -8,12 +8,16 @@ SRCS= main.c statfoo.c athstats.c .include -CFLAGS+= -I. +SRCDIR= ${.CURDIR}/../../../.. + CLEANFILES+= opt_ah.h ah_osdep.h -CFLAGS+=-I../../../../sys/contrib/dev/ath -CFLAGS+=-I../../../../sys/net80211 -CFLAGS+=-I../../../../sys/dev/ath +CFLAGS+=-DATH_SUPPORT_ANI + +CFLAGS+=-I${.CURDIR} +CFLAGS+=-I${SRCDIR}/sys/contrib/dev/ath +CFLAGS+=-I${SRCDIR}/sys/net80211 +CFLAGS+=-I${SRCDIR}/sys/dev/ath athstats.o: opt_ah.h ah_osdep.h Modified: head/tools/tools/ath/athstats/athstats.c ============================================================================== --- head/tools/tools/ath/athstats/athstats.c Mon Oct 27 18:47:48 2008 (r184370) +++ head/tools/tools/ath/athstats/athstats.c Mon Oct 27 18:50:46 2008 (r184371) @@ -55,6 +55,12 @@ #include "athstats.h" +#ifdef ATH_SUPPORT_ANI +#define HAL_EP_RND(x,mul) \ + ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) +#define HAL_RSSI(x) HAL_EP_RND(x, HAL_RSSI_EP_MULTIPLIER) +#endif + #define NOTPRESENT { 0, "", "" } #define AFTER(prev) ((prev)+1) @@ -85,7 +91,7 @@ static const struct fmt athstats[] = { #else #define S_RATE AFTER(S_MIB) #endif - { 4, "rate", "rate", "current transmit rate" }, + { 5, "rate", "rate", "current transmit rate" }, #define S_WATCHDOG AFTER(S_RATE) { 5, "wdog", "wdog", "watchdog timeouts" }, #define S_FATAL AFTER(S_WATCHDOG) @@ -155,21 +161,21 @@ static const struct fmt athstats[] = { #define S_RX_PHY_ERR AFTER(S_RX_CTL) { 7, "phyerr", "phyerr", "rx failed 'cuz of PHY err" }, #define S_RX_PHY_UNDERRUN AFTER(S_RX_PHY_ERR) - { 6, "phyund", "phyund", "transmit underrun" }, + { 4, "phyund", "TUnd", "transmit underrun" }, #define S_RX_PHY_TIMING AFTER(S_RX_PHY_UNDERRUN) - { 6, "phytim", "phytim", "timing error" }, + { 4, "phytim", "Tim", "timing error" }, #define S_RX_PHY_PARITY AFTER(S_RX_PHY_TIMING) - { 6, "phypar", "phypar", "illegal parity" }, + { 4, "phypar", "IPar", "illegal parity" }, #define S_RX_PHY_RATE AFTER(S_RX_PHY_PARITY) - { 6, "phyrate", "phyrate", "illegal rate" }, + { 4, "phyrate", "IRate", "illegal rate" }, #define S_RX_PHY_LENGTH AFTER(S_RX_PHY_RATE) - { 6, "phylen", "phylen", "illegal length" }, + { 4, "phylen", "ILen", "illegal length" }, #define S_RX_PHY_RADAR AFTER(S_RX_PHY_LENGTH) - { 6, "phyradar", "phyradar", "radar detect" }, + { 4, "phyradar", "Radar", "radar detect" }, #define S_RX_PHY_SERVICE AFTER(S_RX_PHY_RADAR) - { 6, "physervice", "physervice", "illegal service" }, + { 4, "physervice", "Service", "illegal service" }, #define S_RX_PHY_TOR AFTER(S_RX_PHY_SERVICE) - { 6, "phytor", "phytor", "transmit override receive" }, + { 4, "phytor", "TOR", "transmit override receive" }, #define S_RX_PHY_OFDM_TIMING AFTER(S_RX_PHY_TOR) { 6, "ofdmtim", "ofdmtim", "OFDM timing" }, #define S_RX_PHY_OFDM_SIGNAL_PARITY AFTER(S_RX_PHY_OFDM_TIMING) @@ -258,7 +264,71 @@ static const struct fmt athstats[] = { { 5, "defsw", "defsw", "switched default/rx antenna" }, #define S_ANT_TXSWITCH AFTER(S_ANT_DEFSWITCH) { 5, "txsw", "txsw", "tx used alternate antenna" }, +#ifdef ATH_SUPPORT_ANI +#define S_ANI_NOISE AFTER(S_ANT_TXSWITCH) + { 2, "ni", "NI", "noise immunity level" }, +#define S_ANI_SPUR AFTER(S_ANI_NOISE) + { 2, "si", "SI", "spur immunity level" }, +#define S_ANI_STEP AFTER(S_ANI_SPUR) + { 2, "step", "ST", "first step level" }, +#define S_ANI_OFDM AFTER(S_ANI_STEP) + { 4, "owsd", "OWSD", "OFDM weak signal detect" }, +#define S_ANI_CCK AFTER(S_ANI_OFDM) + { 4, "cwst", "CWST", "CCK weak signal threshold" }, +#define S_ANI_MAXSPUR AFTER(S_ANI_CCK) + { 3, "maxsi","MSI", "max spur immunity level" }, +#define S_ANI_LISTEN AFTER(S_ANI_MAXSPUR) + { 6, "listen","LISTEN", "listen time" }, +#define S_ANI_NIUP AFTER(S_ANI_LISTEN) + { 4, "ni+", "NI-", "ANI increased noise immunity" }, +#define S_ANI_NIDOWN AFTER(S_ANI_NIUP) + { 4, "ni-", "NI-", "ANI decrease noise immunity" }, +#define S_ANI_SIUP AFTER(S_ANI_NIDOWN) + { 4, "si+", "SI+", "ANI increased spur immunity" }, +#define S_ANI_SIDOWN AFTER(S_ANI_SIUP) + { 4, "si-", "SI-", "ANI decrease spur immunity" }, +#define S_ANI_OFDMON AFTER(S_ANI_SIDOWN) + { 5, "ofdm+","OFDM+", "ANI enabled OFDM weak signal detect" }, +#define S_ANI_OFDMOFF AFTER(S_ANI_OFDMON) + { 5, "ofdm-","OFDM-", "ANI disabled OFDM weak signal detect" }, +#define S_ANI_CCKHI AFTER(S_ANI_OFDMOFF) + { 5, "cck+", "CCK+", "ANI enabled CCK weak signal threshold" }, +#define S_ANI_CCKLO AFTER(S_ANI_CCKHI) + { 5, "cck-", "CCK-", "ANI disabled CCK weak signal threshold" }, +#define S_ANI_STEPUP AFTER(S_ANI_CCKLO) + { 5, "step+","STEP+", "ANI increased first step level" }, +#define S_ANI_STEPDOWN AFTER(S_ANI_STEPUP) + { 5, "step-","STEP-", "ANI decreased first step level" }, +#define S_ANI_OFDMERRS AFTER(S_ANI_STEPDOWN) + { 8, "ofdm", "OFDM", "cumulative ofdm phy error count" }, +#define S_ANI_CCKERRS AFTER(S_ANI_OFDMERRS) + { 8, "cck", "CCK", "cumulative cck phy error count" }, +#define S_ANI_RESET AFTER(S_ANI_CCKERRS) + { 5, "reset","RESET", "ANI parameters zero'd for non-STA operation" }, +#define S_ANI_LZERO AFTER(S_ANI_RESET) + { 5, "lzero","LZERO", "ANI forced listen time to zero" }, +#define S_ANI_LNEG AFTER(S_ANI_LZERO) + { 5, "lneg", "LNEG", "ANI calculated listen time < 0" }, +#define S_MIB_ACKBAD AFTER(S_ANI_LNEG) + { 5, "ackbad","ACKBAD", "bad ACK's" }, +#define S_MIB_RTSBAD AFTER(S_MIB_ACKBAD) + { 5, "rtsbad","RTSBAD", "bad RTS" }, +#define S_MIB_RTSGOOD AFTER(S_MIB_RTSBAD) + { 5, "rtsgood","RTSGOOD", "good RTS" }, +#define S_MIB_FCSBAD AFTER(S_MIB_RTSGOOD) + { 5, "fcsbad","FCSBAD", "bad FCS" }, +#define S_MIB_BEACONS AFTER(S_MIB_FCSBAD) + { 5, "beacons","beacons", "beacons received" }, +#define S_NODE_AVGBRSSI AFTER(S_MIB_BEACONS) + { 3, "avgbrssi","BSI", "average rssi (beacons only)" }, +#define S_NODE_AVGRSSI AFTER(S_NODE_AVGBRSSI) + { 3, "avgrssi","DSI", "average rssi (all rx'd frames)" }, +#define S_NODE_AVGARSSI AFTER(S_NODE_AVGRSSI) + { 3, "avgtxrssi","TSI", "average rssi (ACKs only)" }, +#define S_ANT_TX0 AFTER(S_NODE_AVGARSSI) +#else #define S_ANT_TX0 AFTER(S_ANT_TXSWITCH) +#endif /* ATH_SUPPORT_ANI */ { 8, "tx0", "ant0(tx)", "frames tx on antenna 0" }, #define S_ANT_TX1 AFTER(S_ANT_TX0) { 8, "tx1", "ant1(tx)", "frames tx on antenna 1" }, @@ -302,12 +372,41 @@ static const struct fmt athstats[] = { struct _athstats { struct ath_stats ath; +#ifdef ATH_SUPPORT_ANI + struct { + uint32_t ast_ani_niup; /* increased noise immunity */ + uint32_t ast_ani_nidown; /* decreased noise immunity */ + uint32_t ast_ani_spurup; /* increased spur immunity */ + uint32_t ast_ani_spurdown; /* descreased spur immunity */ + uint32_t ast_ani_ofdmon; /* OFDM weak signal detect on */ + uint32_t ast_ani_ofdmoff; /* OFDM weak signal detect off*/ + uint32_t ast_ani_cckhigh; /* CCK weak signal thr high */ + uint32_t ast_ani_ccklow; /* CCK weak signal thr low */ + uint32_t ast_ani_stepup; /* increased first step level */ + uint32_t ast_ani_stepdown; /* decreased first step level */ + uint32_t ast_ani_ofdmerrs; /* cumulative ofdm phy err cnt*/ + uint32_t ast_ani_cckerrs; /* cumulative cck phy err cnt */ + uint32_t ast_ani_reset; /* params zero'd for non-STA */ + uint32_t ast_ani_lzero; /* listen time forced to zero */ + uint32_t ast_ani_lneg; /* listen time calculated < 0 */ + HAL_MIB_STATS ast_mibstats; /* MIB counter stats */ + HAL_NODE_STATS ast_nodestats; /* latest rssi stats */ + } ani_stats; + struct { + uint8_t noiseImmunityLevel; + uint8_t spurImmunityLevel; + uint8_t firstepLevel; + uint8_t ofdmWeakSigDetectOff; + uint32_t listenTime; + } ani_state; +#endif }; struct athstatfoo_p { struct athstatfoo base; int s; int optstats; +#define ATHSTATS_ANI 0x0001 struct ifreq ifr; struct ath_diag atd; struct _athstats cur; @@ -320,6 +419,10 @@ ath_setifname(struct athstatfoo *wf0, co struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0; strncpy(wf->ifr.ifr_name, ifname, sizeof (wf->ifr.ifr_name)); +#ifdef ATH_SUPPORT_ANI + strncpy(wf->atd.ad_name, ifname, sizeof (wf->atd.ad_name)); + wf->optstats |= ATHSTATS_ANI; +#endif } static void @@ -328,6 +431,22 @@ ath_collect(struct athstatfoo_p *wf, str wf->ifr.ifr_data = (caddr_t) &stats->ath; if (ioctl(wf->s, SIOCGATHSTATS, &wf->ifr) < 0) err(1, wf->ifr.ifr_name); +#ifdef ATH_SUPPORT_ANI + if (wf->optstats & ATHSTATS_ANI) { + wf->atd.ad_id = 5; + wf->atd.ad_out_data = (caddr_t) &stats->ani_state; + wf->atd.ad_out_size = sizeof(stats->ani_state); + if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) { + warn(wf->atd.ad_name); + wf->optstats &= ~ATHSTATS_ANI; + } + wf->atd.ad_id = 8; + wf->atd.ad_out_data = (caddr_t) &stats->ani_stats; + wf->atd.ad_out_size = sizeof(stats->ani_stats); + if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) + warn(wf->atd.ad_name); + } +#endif /* ATH_SUPPORT_ANI */ } static void @@ -354,6 +473,17 @@ ath_update_tot(struct statfoo *sf) wf->total = wf->cur; } +static void +snprintrate(char b[], size_t bs, int rate) +{ + if (rate & IEEE80211_RATE_MCS) + snprintf(b, bs, "MCS%u", rate &~ IEEE80211_RATE_MCS); + else if (rate & 1) + snprintf(b, bs, "%u.5M", rate / 2); + else + snprintf(b, bs, "%uM", rate / 2); +} + static int ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) { @@ -362,6 +492,12 @@ ath_get_curstat(struct statfoo *sf, int snprintf(b, bs, "%u", wf->cur.ath.ast_##x - wf->total.ath.ast_##x); return 1 #define PHY(x) \ snprintf(b, bs, "%u", wf->cur.ath.ast_rx_phy[x] - wf->total.ath.ast_rx_phy[x]); return 1 +#define ANI(x) \ + snprintf(b, bs, "%u", wf->cur.ani_state.x); return 1 +#define ANISTAT(x) \ + snprintf(b, bs, "%u", wf->cur.ani_stats.ast_ani_##x - wf->total.ani_stats.ast_ani_##x); return 1 +#define MIBSTAT(x) \ + snprintf(b, bs, "%u", wf->cur.ani_stats.ast_mibstats.x - wf->total.ani_stats.ast_mibstats.x); return 1 #define TXANT(x) \ snprintf(b, bs, "%u", wf->cur.ath.ast_ant_tx[x] - wf->total.ath.ast_ant_tx[x]); return 1 #define RXANT(x) \ @@ -378,7 +514,7 @@ ath_get_curstat(struct statfoo *sf, int wf->cur.ath.ast_tx_packets - wf->total.ath.ast_tx_packets); return 1; case S_RATE: - snprintf(b, bs, "%uM", wf->cur.ath.ast_tx_rate / 2); + snprintrate(b, bs, wf->cur.ath.ast_tx_rate); return 1; case S_WATCHDOG: STAT(watchdog); case S_FATAL: STAT(hardware); @@ -472,6 +608,45 @@ ath_get_curstat(struct statfoo *sf, int case S_RATE_DROP: STAT(rate_drop); case S_ANT_DEFSWITCH: STAT(ant_defswitch); case S_ANT_TXSWITCH: STAT(ant_txswitch); +#ifdef S_ANI_NOISE + case S_ANI_NOISE: ANI(noiseImmunityLevel); + case S_ANI_SPUR: ANI(spurImmunityLevel); + case S_ANI_STEP: ANI(firstepLevel); + case S_ANI_OFDM: ANI(ofdmWeakSigDetectOff); + case S_ANI_LISTEN: ANI(listenTime); + case S_ANI_NIUP: ANISTAT(niup); + case S_ANI_NIDOWN: ANISTAT(nidown); + case S_ANI_SIUP: ANISTAT(spurup); + case S_ANI_SIDOWN: ANISTAT(spurdown); + case S_ANI_OFDMON: ANISTAT(ofdmon); + case S_ANI_OFDMOFF: ANISTAT(ofdmoff); + case S_ANI_CCKHI: ANISTAT(cckhigh); + case S_ANI_CCKLO: ANISTAT(ccklow); + case S_ANI_STEPUP: ANISTAT(stepup); + case S_ANI_STEPDOWN: ANISTAT(stepdown); + case S_ANI_OFDMERRS: ANISTAT(ofdmerrs); + case S_ANI_CCKERRS: ANISTAT(cckerrs); + case S_ANI_RESET: ANISTAT(reset); + case S_ANI_LZERO: ANISTAT(lzero); + case S_ANI_LNEG: ANISTAT(lneg); + case S_MIB_ACKBAD: MIBSTAT(ackrcv_bad); + case S_MIB_RTSBAD: MIBSTAT(rts_bad); + case S_MIB_RTSGOOD: MIBSTAT(rts_good); + case S_MIB_FCSBAD: MIBSTAT(fcs_bad); + case S_MIB_BEACONS: MIBSTAT(beacons); + case S_NODE_AVGBRSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgbrssi)); + return 1; + case S_NODE_AVGRSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgrssi)); + return 1; + case S_NODE_AVGARSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgtxrssi)); + return 1; +#endif case S_ANT_TX0: TXANT(0); case S_ANT_TX1: TXANT(1); case S_ANT_TX2: TXANT(2); @@ -513,6 +688,9 @@ ath_get_curstat(struct statfoo *sf, int return 0; #undef RXANT #undef TXANT +#undef ANI +#undef ANISTAT +#undef MIBSTAT #undef PHY #undef STAT } @@ -525,6 +703,12 @@ ath_get_totstat(struct statfoo *sf, int snprintf(b, bs, "%u", wf->total.ath.ast_##x); return 1 #define PHY(x) \ snprintf(b, bs, "%u", wf->total.ath.ast_rx_phy[x]); return 1 +#define ANI(x) \ + snprintf(b, bs, "%u", wf->total.ani_state.x); return 1 +#define ANISTAT(x) \ + snprintf(b, bs, "%u", wf->total.ani_stats.ast_ani_##x); return 1 +#define MIBSTAT(x) \ + snprintf(b, bs, "%u", wf->total.ani_stats.ast_mibstats.x); return 1 #define TXANT(x) \ snprintf(b, bs, "%u", wf->total.ath.ast_ant_tx[x]); return 1 #define RXANT(x) \ @@ -539,7 +723,7 @@ ath_get_totstat(struct statfoo *sf, int snprintf(b, bs, "%lu", wf->total.ath.ast_tx_packets); return 1; case S_RATE: - snprintf(b, bs, "%uM", wf->total.ath.ast_tx_rate / 2); + snprintrate(b, bs, wf->total.ath.ast_tx_rate); return 1; case S_WATCHDOG: STAT(watchdog); case S_FATAL: STAT(hardware); @@ -633,6 +817,44 @@ ath_get_totstat(struct statfoo *sf, int case S_RATE_DROP: STAT(rate_drop); case S_ANT_DEFSWITCH: STAT(ant_defswitch); case S_ANT_TXSWITCH: STAT(ant_txswitch); +#ifdef S_ANI_NOISE + case S_ANI_NOISE: ANI(noiseImmunityLevel); + case S_ANI_SPUR: ANI(spurImmunityLevel); + case S_ANI_STEP: ANI(firstepLevel); + case S_ANI_LISTEN: ANI(listenTime); + case S_ANI_NIUP: ANISTAT(niup); + case S_ANI_NIDOWN: ANISTAT(nidown); + case S_ANI_SIUP: ANISTAT(spurup); + case S_ANI_SIDOWN: ANISTAT(spurdown); + case S_ANI_OFDMON: ANISTAT(ofdmon); + case S_ANI_OFDMOFF: ANISTAT(ofdmoff); + case S_ANI_CCKHI: ANISTAT(cckhigh); + case S_ANI_CCKLO: ANISTAT(ccklow); + case S_ANI_STEPUP: ANISTAT(stepup); + case S_ANI_STEPDOWN: ANISTAT(stepdown); + case S_ANI_OFDMERRS: ANISTAT(ofdmerrs); + case S_ANI_CCKERRS: ANISTAT(cckerrs); + case S_ANI_RESET: ANISTAT(reset); + case S_ANI_LZERO: ANISTAT(lzero); + case S_ANI_LNEG: ANISTAT(lneg); + case S_MIB_ACKBAD: MIBSTAT(ackrcv_bad); + case S_MIB_RTSBAD: MIBSTAT(rts_bad); + case S_MIB_RTSGOOD: MIBSTAT(rts_good); + case S_MIB_FCSBAD: MIBSTAT(fcs_bad); + case S_MIB_BEACONS: MIBSTAT(beacons); + case S_NODE_AVGBRSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgbrssi)); + return 1; + case S_NODE_AVGRSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgrssi)); + return 1; + case S_NODE_AVGARSSI: + snprintf(b, bs, "%u", + HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgtxrssi)); + return 1; +#endif case S_ANT_TX0: TXANT(0); case S_ANT_TX1: TXANT(1); case S_ANT_TX2: TXANT(2); @@ -674,6 +896,9 @@ ath_get_totstat(struct statfoo *sf, int return 0; #undef RXANT #undef TXANT +#undef ANI +#undef ANISTAT +#undef MIBSTAT #undef PHY #undef STAT } Modified: head/tools/tools/ath/athstats/main.c ============================================================================== --- head/tools/tools/ath/athstats/main.c Mon Oct 27 18:47:48 2008 (r184370) +++ head/tools/tools/ath/athstats/main.c Mon Oct 27 18:50:46 2008 (r184371) @@ -49,8 +49,30 @@ #include "athstats.h" -#define S_DEFAULT \ - "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" +static struct { + const char *tag; + const char *fmt; +} tags[] = { + { "default", + "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" + }, + { "ani", + "avgbrssi,avgrssi,avgtxrssi,NI,SI,step,owsd,cwst,NI+,NI-,SI+,SI-,OFDM,CCK,LISTEN" + }, +}; + +static const char * +getfmt(const char *tag) +{ +#define N(a) (sizeof(a)/sizeof(a[0])) + int i; + for (i = 0; i < N(tags); i++) + if (strcasecmp(tags[i].tag, tag) == 0) + return tags[i].fmt; + errx(-1, "unknown tag \%s\"", tag); + /*NOTREACHED*/ +#undef N +} static int signalled; @@ -70,7 +92,7 @@ main(int argc, char *argv[]) ifname = getenv("ATH"); if (ifname == NULL) ifname = "ath0"; - wf = athstats_new(ifname, S_DEFAULT); + wf = athstats_new(ifname, getfmt("default")); while ((c = getopt(argc, argv, "i:lo:")) != -1) { switch (c) { case 'i': @@ -80,7 +102,7 @@ main(int argc, char *argv[]) wf->print_fields(wf, stdout); return 0; case 'o': - wf->setfmt(wf, optarg); + wf->setfmt(wf, getfmt(optarg)); break; default: errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 19:21:26 2008 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 3BA40106566B; Mon, 27 Oct 2008 19:21:26 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B20608FC13; Mon, 27 Oct 2008 19:21:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RJLJMO014395; Mon, 27 Oct 2008 15:21:19 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Maxim Sobolev Date: Mon, 27 Oct 2008 14:11:11 -0400 User-Agent: KMail/1.9.7 References: <200810261858.m9QIw4YV091893@svn.freebsd.org> In-Reply-To: <200810261858.m9QIw4YV091893@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810271411.11813.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 15:21:19 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8511/Mon Oct 27 14:23:52 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386 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: Mon, 27 Oct 2008 19:21:26 -0000 On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote: > Author: sobomax > Date: Sun Oct 26 18:58:04 2008 > New Revision: 184293 > URL: http://svn.freebsd.org/changeset/base/184293 > > Log: > Fix division by zero panic if kern.hz less than 32. > > MFC after: 1 day This is wrong. In the case you are worried about here, lapic_timer_hz is less than 128. There is no way you are going to fire stathz 128 times per second from a timer running at < 128 hz. You are effectively running stathz at lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case. Also, I would drop the extra {}'s to match style(9) as well as the existing style of the file. > Modified: > head/sys/amd64/amd64/local_apic.c > head/sys/i386/i386/local_apic.c > > Modified: head/sys/amd64/amd64/local_apic.c > ============================================================================== > --- head/sys/amd64/amd64/local_apic.c Sun Oct 26 17:20:37 2008 (r184292) > +++ head/sys/amd64/amd64/local_apic.c Sun Oct 26 18:58:04 2008 (r184293) > @@ -401,7 +401,11 @@ lapic_setup_clock(void) > lapic_timer_hz = hz * 2; > else > lapic_timer_hz = hz * 4; > - stathz = lapic_timer_hz / (lapic_timer_hz / 128); > + if (lapic_timer_hz < 128) { > + stathz = 128; > + } else { > + stathz = lapic_timer_hz / (lapic_timer_hz / 128); > + } > profhz = lapic_timer_hz; > lapic_timer_period = value / lapic_timer_hz; -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 19:21:32 2008 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 DD0AD106574B; Mon, 27 Oct 2008 19:21:32 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 991E78FC16; Mon, 27 Oct 2008 19:21:31 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RJLJMP014395; Mon, 27 Oct 2008 15:21:25 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: "Bjoern A. Zeeb" Date: Mon, 27 Oct 2008 14:18:40 -0400 User-Agent: KMail/1.9.7 References: <200810271515.m9RFF86d042970@svn.freebsd.org> In-Reply-To: <200810271515.m9RFF86d042970@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810271418.41291.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 15:21:25 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8511/Mon Oct 27 14:23:52 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184341 - head/usr.sbin 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: Mon, 27 Oct 2008 19:21:33 -0000 On Monday 27 October 2008 11:15:08 am Bjoern A. Zeeb wrote: > Author: bz > Date: Mon Oct 27 15:15:08 2008 > New Revision: 184341 > URL: http://svn.freebsd.org/changeset/base/184341 > > Log: > We do not have a libkse anymore and Mk/bsd.* does not know > about LIBKSE anymore, so s,MK_LIBKSE,MK_LIBPTHREAD,. Shouldn't you just remove it instead? These two options are now basically identical. (We probably should rename libthr to libpthread at some point.) > Modified: > head/usr.sbin/Makefile > > Modified: head/usr.sbin/Makefile > ============================================================================== > --- head/usr.sbin/Makefile Mon Oct 27 14:49:12 2008 (r184340) > +++ head/usr.sbin/Makefile Mon Oct 27 15:15:08 2008 (r184341) > @@ -292,7 +292,7 @@ _moused= moused > _vidcontrol= vidcontrol > .endif > > -.if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" > +.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" > .if ${MK_PPP} != "no" > _pppctl= pppctl > .endif > -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 19:21:51 2008 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 4A0D510656AF; Mon, 27 Oct 2008 19:21:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B91618FC0C; Mon, 27 Oct 2008 19:21:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RJLJMS014395; Mon, 27 Oct 2008 15:21:42 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Sam Leffler Date: Mon, 27 Oct 2008 14:28:02 -0400 User-Agent: KMail/1.9.7 References: <200810230151.m9N1ptUe044619@svn.freebsd.org> <20081023.190942.74668946.imp@bsdimp.com> <4901F173.2070701@freebsd.org> In-Reply-To: <4901F173.2070701@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810271428.03345.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 15:21:42 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8511/Mon Oct 27 14:23:52 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, marcel@freebsd.org, src-committers@freebsd.org, Warner Losh Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf 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: Mon, 27 Oct 2008 19:21:51 -0000 On Friday 24 October 2008 12:01:55 pm Sam Leffler wrote: > Warner Losh wrote: > > From: Marcel Moolenaar > > Subject: svn commit: r184193 - in head/sys: arm/conf conf > > Date: Thu, 23 Oct 2008 01:51:55 +0000 (UTC) > > > > > >> Author: marcel > >> Date: Thu Oct 23 01:51:55 2008 > >> New Revision: 184193 > >> URL: http://svn.freebsd.org/changeset/base/184193 > >> > >> Log: > >> Add arm/conf/DEFAULTS and populate it with: > >> machine arm > >> device mem > >> options GEOM_BSD > >> options GEOM_MBR > >> > >> Remove the first two from all kernel configuration files and > >> change geom_bsd and geom_mbr from standard to optional. > >> > >> Added: > >> head/sys/arm/conf/DEFAULTS (contents, props changed) > >> > > > > We already have a better mechanism for including config files. We > > should be using that instead of poluting another port with the > > DEFAULTS file. > > > More importantly this change forces GEOM_BSD and GEOM_MBR on every > target platform. This is just wrong and clearly Marvel never discussed > it with anyone working on arm systems or he'd have gotten an earful. > > Marcel, please back this stuff out. Sam, I have to say that if you look at what Marcel did, he actually helped your cause. Previously, any ARM kernel you built _always_ had GEOM_BSD and GEOM_MBR in unless you hacked sys/conf/files.arm. Now you can just put 'nooptions GEOM_BSD' or 'nooptions GEOM_MBR' in your kernel config to remove them without having to hack sys/conf/files.arm. This is a step forward, not a step backwards. Of course, you are always free to add explicit GEOM_MBR/GEOM_BSD lines to the ARM configs that need it and then remove them from DEFAULTS. But this change 1) preserves people's existing kernel configs to still do the same thing as before and 2) introduces the _new_ ability to turn off GEOM_MBR/GEOM_BSD that _wasn't_ _there_ _before_ without local hacks. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 20:10:40 2008 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 AB2201065675; Mon, 27 Oct 2008 20:10:40 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from sippysoft.com (gk1.360sip.com [72.236.70.240]) by mx1.freebsd.org (Postfix) with ESMTP id 737898FC24; Mon, 27 Oct 2008 20:10:40 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from [192.168.1.23] (S0106001372fd1e07.vs.shawcable.net [70.71.2.169]) (authenticated bits=0) by sippysoft.com (8.13.8/8.13.8) with ESMTP id m9RJaMtc043601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Oct 2008 12:36:22 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Message-ID: <4906185C.1010900@FreeBSD.org> Date: Mon, 27 Oct 2008 12:37:00 -0700 From: Maxim Sobolev Organization: Sippy Software, Inc. User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: John Baldwin References: <200810261858.m9QIw4YV091893@svn.freebsd.org> <200810271411.11813.jhb@freebsd.org> In-Reply-To: <200810271411.11813.jhb@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386 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: Mon, 27 Oct 2008 20:10:40 -0000 John Baldwin wrote: > On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote: >> Author: sobomax >> Date: Sun Oct 26 18:58:04 2008 >> New Revision: 184293 >> URL: http://svn.freebsd.org/changeset/base/184293 >> >> Log: >> Fix division by zero panic if kern.hz less than 32. >> >> MFC after: 1 day > > This is wrong. In the case you are worried about here, lapic_timer_hz is less > than 128. There is no way you are going to fire stathz 128 times per second > from a timer running at < 128 hz. You are effectively running stathz at > lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case. > Also, I would drop the extra {}'s to match style(9) as well as the existing > style of the file. It might be wrong, but it's better than division by zero panic. And it actually works, check this screenshot: http://sobomax.sippysoft.com/~sobomax/ScreenShot362.png [ssp-root@sippy ~]$ sysctl -a | grep hz kern.clockrate: { hz = 10, tick = 100000, profhz = 40, stathz = 128 } As for the style(9), I am not really sure that applies, the exact quote: Space after keywords (if, while, for, return, switch). No braces (`{' and `}') are used for control statements with zero or only a single statement unless that statement is more than a single line in which case they are permitted. Forever loops are done with for's, not while's. To me the following if: if () stmt1; else stmt2; falls into the category of statements with more than single line (3 in this case), so that {} is appropriate. So that either my change is OK, or style(9) needs to be clarified to include if/else explicitly. -Maxim From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 20:25:57 2008 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 E609F1065672; Mon, 27 Oct 2008 20:25:56 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 7378E8FC16; Mon, 27 Oct 2008 20:25:56 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RKPhrs014912; Mon, 27 Oct 2008 16:25:50 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Maxim Sobolev Date: Mon, 27 Oct 2008 16:25:36 -0400 User-Agent: KMail/1.9.7 References: <200810261858.m9QIw4YV091893@svn.freebsd.org> <200810271411.11813.jhb@freebsd.org> <4906185C.1010900@FreeBSD.org> In-Reply-To: <4906185C.1010900@FreeBSD.org> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200810271625.36538.jhb@freebsd.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 16:25:50 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8511/Mon Oct 27 14:23:52 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386 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: Mon, 27 Oct 2008 20:25:57 -0000 On Monday 27 October 2008 03:37:00 pm Maxim Sobolev wrote: > John Baldwin wrote: > > On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote: > >> Author: sobomax > >> Date: Sun Oct 26 18:58:04 2008 > >> New Revision: 184293 > >> URL: http://svn.freebsd.org/changeset/base/184293 > >> > >> Log: > >> Fix division by zero panic if kern.hz less than 32. > >> > >> MFC after: 1 day > > > > This is wrong. In the case you are worried about here, lapic_timer_hz is less > > than 128. There is no way you are going to fire stathz 128 times per second > > from a timer running at < 128 hz. You are effectively running stathz at > > lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case. > > Also, I would drop the extra {}'s to match style(9) as well as the existing > > style of the file. > > It might be wrong, but it's better than division by zero panic. And it > actually works, check this screenshot: > > http://sobomax.sippysoft.com/~sobomax/ScreenShot362.png You didn't read a word I wrote apparently. :( > [ssp-root@sippy ~]$ sysctl -a | grep hz > kern.clockrate: { hz = 10, tick = 100000, profhz = 40, stathz = 128 } Yes, so now the kernel lies to userland, congratulations. :( stathz is running at 40hz, but userland will think it runs at 128, so if any code tries to actually use stathz directly (e.g. divide some stat counter by stathz, etc.) it will compute wrong results. > As for the style(9), I am not really sure that applies, the exact quote: > > > Space after keywords (if, while, for, return, switch). No braces (`{' > and `}') are used for control statements with zero or only a single > statement unless that statement is more than a single line in which case > they are permitted. Forever loops are done with for's, not while's. > > > To me the following if: > > if () > stmt1; > else > stmt2; > > falls into the category of statements with more than single line (3 in > this case), so that {} is appropriate. So that either my change is OK, > or style(9) needs to be clarified to include if/else explicitly. 1) I disagree with your interpretation. For one, 'else' is clearly not a statement by itself. In fact, if you check the BNF in "The C Programming Language", both "if (expression) statement" and "if (expression) statement else statement" are part of the "selection-statement" definition. So rather than 'else' being a statement, the entire thing is a single 'statement'. 2) The bigger rule is to be consistent within a file. Look at the 4 lines immediately preceding your change. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:06:17 2008 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 3257D106566B; Mon, 27 Oct 2008 21:06:17 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 204378FC17; Mon, 27 Oct 2008 21:06:17 +0000 (UTC) (envelope-from sobomax@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 m9RL6G5j053077; Mon, 27 Oct 2008 21:06:16 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RL6GMu053076; Mon, 27 Oct 2008 21:06:16 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810272106.m9RL6GMu053076@svn.freebsd.org> From: Maxim Sobolev Date: Mon, 27 Oct 2008 21:06:16 +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: r184372 - head/sys/i386/i386 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: Mon, 27 Oct 2008 21:06:17 -0000 Author: sobomax Date: Mon Oct 27 21:06:16 2008 New Revision: 184372 URL: http://svn.freebsd.org/changeset/base/184372 Log: Fix r184323 - set stathz to be the same as lapic_timer_hz when lapic_timer_hz is less than 128. Remove extra {} to match existing style. Modified: head/sys/i386/i386/local_apic.c Modified: head/sys/i386/i386/local_apic.c ============================================================================== --- head/sys/i386/i386/local_apic.c Mon Oct 27 18:50:46 2008 (r184371) +++ head/sys/i386/i386/local_apic.c Mon Oct 27 21:06:16 2008 (r184372) @@ -403,11 +403,10 @@ lapic_setup_clock(void) lapic_timer_hz = hz * 2; else lapic_timer_hz = hz * 4; - if (lapic_timer_hz < 128) { - stathz = 128; - } else { + if (lapic_timer_hz < 128) + stathz = lapic_timer_hz; + else stathz = lapic_timer_hz / (lapic_timer_hz / 128); - } profhz = lapic_timer_hz; lapic_timer_period = value / lapic_timer_hz; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:16:07 2008 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 9564E1065670; Mon, 27 Oct 2008 21:16:07 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 842B58FC0C; Mon, 27 Oct 2008 21:16:07 +0000 (UTC) (envelope-from rnoland@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 m9RLG7vU053331; Mon, 27 Oct 2008 21:16:07 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLG7RR053330; Mon, 27 Oct 2008 21:16:07 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200810272116.m9RLG7RR053330@svn.freebsd.org> From: Robert Noland Date: Mon, 27 Oct 2008 21:16:07 +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: r184373 - head/sys/dev/drm 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: Mon, 27 Oct 2008 21:16:07 -0000 Author: rnoland Date: Mon Oct 27 21:16:07 2008 New Revision: 184373 URL: http://svn.freebsd.org/changeset/base/184373 Log: Don't report GEM capability until we actually have GEM support. This was causing the newer Intel video drivers to fail and abort X. Approved by: jhb (mentor) Modified: head/sys/dev/drm/i915_dma.c Modified: head/sys/dev/drm/i915_dma.c ============================================================================== --- head/sys/dev/drm/i915_dma.c Mon Oct 27 21:06:16 2008 (r184372) +++ head/sys/dev/drm/i915_dma.c Mon Oct 27 21:16:07 2008 (r184373) @@ -914,7 +914,8 @@ static int i915_getparam(struct drm_devi value = dev->pci_device; break; case I915_PARAM_HAS_GEM: - value = 1; + /* We need to reset this to 1 once we have GEM */ + value = 0; break; default: DRM_ERROR("Unknown parameter %d\n", param->param); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:21:36 2008 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 ACBF11065679; Mon, 27 Oct 2008 21:21:36 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AA548FC25; Mon, 27 Oct 2008 21:21:36 +0000 (UTC) (envelope-from rnoland@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 m9RLLa5E053462; Mon, 27 Oct 2008 21:21:36 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLLapV053460; Mon, 27 Oct 2008 21:21:36 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200810272121.m9RLLapV053460@svn.freebsd.org> From: Robert Noland Date: Mon, 27 Oct 2008 21:21:36 +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: r184374 - head/sys/dev/drm 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: Mon, 27 Oct 2008 21:21:36 -0000 Author: rnoland Date: Mon Oct 27 21:21:36 2008 New Revision: 184374 URL: http://svn.freebsd.org/changeset/base/184374 Log: Fix some fallout from the busmaster disable cleanup rs400 is just like rs480 Approved by: jhb (mentor) Obtained from: drm git Modified: head/sys/dev/drm/radeon_cp.c head/sys/dev/drm/radeon_drv.h Modified: head/sys/dev/drm/radeon_cp.c ============================================================================== --- head/sys/dev/drm/radeon_cp.c Mon Oct 27 21:16:07 2008 (r184373) +++ head/sys/dev/drm/radeon_cp.c Mon Oct 27 21:21:36 2008 (r184374) @@ -655,15 +655,14 @@ static void radeon_cp_init_ring_buffer(s RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7); /* Turn on bus mastering */ - if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) || - ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) { - /* rs400, rs690/rs740 */ - tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS400_BUS_MASTER_DIS; + /* rs600/rs690/rs740 */ + tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS; RADEON_WRITE(RADEON_BUS_CNTL, tmp); } else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) || ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) { - /* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ + /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */ tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; RADEON_WRITE(RADEON_BUS_CNTL, tmp); } /* PCIE cards appears to not need this */ Modified: head/sys/dev/drm/radeon_drv.h ============================================================================== --- head/sys/dev/drm/radeon_drv.h Mon Oct 27 21:16:07 2008 (r184373) +++ head/sys/dev/drm/radeon_drv.h Mon Oct 27 21:21:36 2008 (r184374) @@ -442,11 +442,11 @@ extern int r300_do_cp_cmdbuf(struct drm_ * handling, not bus mastering itself. */ #define RADEON_BUS_CNTL 0x0030 -/* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ +/* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */ # define RADEON_BUS_MASTER_DIS (1 << 6) -/* rs400, rs690/rs740 */ -# define RS400_BUS_MASTER_DIS (1 << 14) -# define RS400_MSI_REARM (1 << 20) +/* rs600/rs690/rs740 */ +# define RS600_BUS_MASTER_DIS (1 << 14) +# define RS600_MSI_REARM (1 << 20) /* see RS480_MSI_REARM in AIC_CNTL for rs480 */ #define RADEON_BUS_CNTL1 0x0034 @@ -939,7 +939,7 @@ extern int r300_do_cp_cmdbuf(struct drm_ #define RADEON_AIC_CNTL 0x01d0 # define RADEON_PCIGART_TRANSLATE_EN (1 << 0) -# define RS480_MSI_REARM (1 << 3) +# define RS400_MSI_REARM (1 << 3) #define RADEON_AIC_STAT 0x01d4 #define RADEON_AIC_PT_BASE 0x01d8 #define RADEON_AIC_LO_ADDR 0x01dc From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:24:35 2008 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 0B5BD1065672; Mon, 27 Oct 2008 21:24:35 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB67F8FC16; Mon, 27 Oct 2008 21:24:34 +0000 (UTC) (envelope-from rnoland@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 m9RLOY1A053584; Mon, 27 Oct 2008 21:24:34 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLOYWt053583; Mon, 27 Oct 2008 21:24:34 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200810272124.m9RLOYWt053583@svn.freebsd.org> From: Robert Noland Date: Mon, 27 Oct 2008 21:24:34 +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: r184375 - head/sys/dev/drm 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: Mon, 27 Oct 2008 21:24:35 -0000 Author: rnoland Date: Mon Oct 27 21:24:34 2008 New Revision: 184375 URL: http://svn.freebsd.org/changeset/base/184375 Log: Fix error in busmaster enable logic rs400/rs480 should clear the RADEON_BUS_MASTER_DIS bit. This should get the rs485 IGP chips going again. Approved by: jhb (mentor) Obtained from: drm git master Modified: head/sys/dev/drm/radeon_cp.c Modified: head/sys/dev/drm/radeon_cp.c ============================================================================== --- head/sys/dev/drm/radeon_cp.c Mon Oct 27 21:21:36 2008 (r184374) +++ head/sys/dev/drm/radeon_cp.c Mon Oct 27 21:24:34 2008 (r184375) @@ -660,8 +660,10 @@ static void radeon_cp_init_ring_buffer(s /* rs600/rs690/rs740 */ tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS; RADEON_WRITE(RADEON_BUS_CNTL, tmp); - } else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) || - ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) { + } else if (((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV350) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R420) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS480)) { /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */ tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; RADEON_WRITE(RADEON_BUS_CNTL, tmp); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:31:14 2008 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 8F7661065675; Mon, 27 Oct 2008 21:31:14 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C5678FC0C; Mon, 27 Oct 2008 21:31:14 +0000 (UTC) (envelope-from marius@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 m9RLVERo053739; Mon, 27 Oct 2008 21:31:14 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLVERs053735; Mon, 27 Oct 2008 21:31:14 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200810272131.m9RLVERs053735@svn.freebsd.org> From: Marius Strobl Date: Mon, 27 Oct 2008 21:31:14 +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: r184376 - in head/sys: sparc64/sparc64 sun4v/sun4v 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: Mon, 27 Oct 2008 21:31:14 -0000 Author: marius Date: Mon Oct 27 21:31:14 2008 New Revision: 184376 URL: http://svn.freebsd.org/changeset/base/184376 Log: - In GCC 4.2 __builtin_frame_address() was fixed to include the V9 stack bias so we no longer need to add it in db_backtrace() and stack_capture() respectively. This also reverts r182018, which kludged around the resulting unaligned access. - Sync the sun4v versions of db_trace.c and stack_machdep.c with the sparc64 ones and fix some style bugs. MFC after: 3 days Modified: head/sys/sparc64/sparc64/db_trace.c head/sys/sparc64/sparc64/stack_machdep.c head/sys/sun4v/sun4v/db_trace.c head/sys/sun4v/sun4v/stack_machdep.c Modified: head/sys/sparc64/sparc64/db_trace.c ============================================================================== --- head/sys/sparc64/sparc64/db_trace.c Mon Oct 27 21:24:34 2008 (r184375) +++ head/sys/sparc64/sparc64/db_trace.c Mon Oct 27 21:31:14 2008 (r184376) @@ -276,10 +276,9 @@ db_backtrace(struct thread *td, struct f void db_trace_self(void) { - db_expr_t addr; - addr = (db_expr_t)__builtin_frame_address(1); - db_backtrace(curthread, (struct frame *)(addr + SPOFF), -1); + db_backtrace(curthread, + (struct frame *)__builtin_frame_address(1), -1); } int @@ -288,5 +287,6 @@ db_trace_thread(struct thread *td, int c struct pcb *ctx; ctx = kdb_thr_ctx(td); - return (db_backtrace(td, (struct frame*)(ctx->pcb_sp + SPOFF), count)); + return (db_backtrace(td, + (struct frame *)(ctx->pcb_sp + SPOFF), count)); } Modified: head/sys/sparc64/sparc64/stack_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/stack_machdep.c Mon Oct 27 21:24:34 2008 (r184375) +++ head/sys/sparc64/sparc64/stack_machdep.c Mon Oct 27 21:31:14 2008 (r184376) @@ -28,31 +28,24 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include -#include -#include -#include - -#include #include #include -#include #include +static void stack_capture(struct stack *st, struct frame *fp); + static void -stack_capture(struct stack *st, uint64_t addr) +stack_capture(struct stack *st, struct frame *fp) { vm_offset_t callpc; stack_zero(st); while (1) { - addr += SPOFF; - callpc = - be64dec((void *)(addr + offsetof(struct frame, fr_pc))); + callpc = fp->fr_pc; if (!INKERNEL(callpc)) break; /* Don't bother traversing trap frames. */ @@ -63,30 +56,25 @@ stack_capture(struct stack *st, uint64_t break; if (stack_put(st, callpc) == -1) break; - addr = - be64dec((void *)(addr + offsetof(struct frame, fr_fp))); + fp = v9next_frame(fp); } } void stack_save_td(struct stack *st, struct thread *td) { - uint64_t addr; if (TD_IS_SWAPPED(td)) panic("stack_save_td: swapped"); if (TD_IS_RUNNING(td)) panic("stack_save_td: running"); - addr = td->td_pcb->pcb_sp; - stack_capture(st, addr); + stack_capture(st, (struct frame *)(td->td_pcb->pcb_sp + SPOFF)); } void stack_save(struct stack *st) { - uint64_t addr; - addr = (uint64_t)__builtin_frame_address(1); - stack_capture(st, addr); + stack_capture(st, (struct frame *)__builtin_frame_address(1)); } Modified: head/sys/sun4v/sun4v/db_trace.c ============================================================================== --- head/sys/sun4v/sun4v/db_trace.c Mon Oct 27 21:24:34 2008 (r184375) +++ head/sys/sun4v/sun4v/db_trace.c Mon Oct 27 21:31:14 2008 (r184376) @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -241,7 +242,6 @@ db_backtrace(struct thread *td, struct f db_addr_t pc; int trap; int user; - int quit; if (count == -1) count = 1024; @@ -249,7 +249,6 @@ db_backtrace(struct thread *td, struct f trap = 0; user = 0; npc = 0; - quit = 0; while (count-- && !user && !db_pager_quit) { pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, sizeof(fp->fr_pc), FALSE); @@ -288,10 +287,9 @@ db_backtrace(struct thread *td, struct f void db_trace_self(void) { - db_expr_t addr; - addr = (db_expr_t)__builtin_frame_address(1); - db_backtrace(curthread, (struct frame *)(addr + SPOFF), -1); + db_backtrace(curthread, + (struct frame *)__builtin_frame_address(1), -1); } int @@ -300,5 +298,6 @@ db_trace_thread(struct thread *td, int c struct pcb *ctx; ctx = kdb_thr_ctx(td); - return (db_backtrace(td, (struct frame*)(ctx->pcb_sp + SPOFF), count)); + return (db_backtrace(td, + (struct frame *)(ctx->pcb_sp + SPOFF), count)); } Modified: head/sys/sun4v/sun4v/stack_machdep.c ============================================================================== --- head/sys/sun4v/sun4v/stack_machdep.c Mon Oct 27 21:24:34 2008 (r184375) +++ head/sys/sun4v/sun4v/stack_machdep.c Mon Oct 27 21:31:14 2008 (r184376) @@ -32,54 +32,43 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include - -#include #include #include -#include #include +static void stack_capture(struct stack *st, struct frame *fp); + static void -stack_capture(struct stack *st, uint64_t addr) +stack_capture(struct stack *st, struct frame *fp) { - struct frame *fp; vm_offset_t callpc; stack_zero(st); - fp = (struct frame *)(addr + SPOFF); while (1) { callpc = fp->fr_pc; if (!INKERNEL(callpc)) break; if (stack_put(st, callpc) == -1) break; - fp = (struct frame *)(fp->fr_fp + SPOFF); + fp = v9next_frame(fp); } - } void stack_save_td(struct stack *st, struct thread *td) { - uint64_t addr; if (TD_IS_SWAPPED(td)) panic("stack_save_td: swapped"); if (TD_IS_RUNNING(td)) panic("stack_save_td: running"); - addr = td->td_pcb->pcb_sp; - stack_capture(st, addr); + stack_capture(st, (struct frame *)(td->td_pcb->pcb_sp + SPOFF)); } void stack_save(struct stack *st) { - uint64_t addr; - addr = (uint64_t)__builtin_frame_address(1); - stack_capture(st, addr); + stack_capture(st, (struct frame *)__builtin_frame_address(1)); } From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:38:29 2008 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 3AC751065670; Mon, 27 Oct 2008 21:38:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id D13718FC1F; Mon, 27 Oct 2008 21:38:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9RLcGSp015423; Mon, 27 Oct 2008 17:38:23 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Maxim Sobolev Date: Mon, 27 Oct 2008 17:37:35 -0400 User-Agent: KMail/1.9.7 References: <200810272106.m9RL6GMu053076@svn.freebsd.org> In-Reply-To: <200810272106.m9RL6GMu053076@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810271737.36072.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 27 Oct 2008 17:38:23 -0400 (EDT) X-Virus-Scanned: ClamAV 0.93.1/8513/Mon Oct 27 16:06:35 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184372 - head/sys/i386/i386 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: Mon, 27 Oct 2008 21:38:29 -0000 On Monday 27 October 2008 05:06:16 pm Maxim Sobolev wrote: > Author: sobomax > Date: Mon Oct 27 21:06:16 2008 > New Revision: 184372 > URL: http://svn.freebsd.org/changeset/base/184372 > > Log: > Fix r184323 - set stathz to be the same as lapic_timer_hz when lapic_timer_hz > is less than 128. Remove extra {} to match existing style. > > Modified: > head/sys/i386/i386/local_apic.c Thanks. Don't forget amd64 as well though. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:41:56 2008 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 0FD59106567F; Mon, 27 Oct 2008 21:41:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F271E8FC12; Mon, 27 Oct 2008 21:41:55 +0000 (UTC) (envelope-from jhb@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 m9RLftLI053959; Mon, 27 Oct 2008 21:41:55 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLftEW053958; Mon, 27 Oct 2008 21:41:55 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200810272141.m9RLftEW053958@svn.freebsd.org> From: John Baldwin Date: Mon, 27 Oct 2008 21:41:55 +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: r184377 - head/sys/kern 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: Mon, 27 Oct 2008 21:41:56 -0000 Author: jhb Date: Mon Oct 27 21:41:55 2008 New Revision: 184377 URL: http://svn.freebsd.org/changeset/base/184377 Log: - Whitespace fix for vop_poll. - Use the right label for vop_vptofh lock assertions so they are enforced. Modified: head/sys/kern/vnode_if.src Modified: head/sys/kern/vnode_if.src ============================================================================== --- head/sys/kern/vnode_if.src Mon Oct 27 21:31:14 2008 (r184376) +++ head/sys/kern/vnode_if.src Mon Oct 27 21:41:55 2008 (r184377) @@ -216,7 +216,7 @@ vop_ioctl { }; -%% poll vp U U U +%% poll vp U U U vop_poll { IN struct vnode *vp; @@ -589,7 +589,7 @@ vop_setlabel { }; -%% setlabel vp = = = +%% vptofh vp = = = vop_vptofh { IN struct vnode *vp; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:45:18 2008 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 CDF061065673; Mon, 27 Oct 2008 21:45:18 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC9938FC24; Mon, 27 Oct 2008 21:45:18 +0000 (UTC) (envelope-from sobomax@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 m9RLjIYZ054081; Mon, 27 Oct 2008 21:45:18 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLjIZN054080; Mon, 27 Oct 2008 21:45:18 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <200810272145.m9RLjIZN054080@svn.freebsd.org> From: Maxim Sobolev Date: Mon, 27 Oct 2008 21:45:18 +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: r184378 - head/sys/amd64/amd64 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: Mon, 27 Oct 2008 21:45:18 -0000 Author: sobomax Date: Mon Oct 27 21:45:18 2008 New Revision: 184378 URL: http://svn.freebsd.org/changeset/base/184378 Log: Fix r184323 - set stathz to be the same as lapic_timer_hz when lapic_timer_hz is less than 128. Remove extra {} to match existing style. Modified: head/sys/amd64/amd64/local_apic.c Modified: head/sys/amd64/amd64/local_apic.c ============================================================================== --- head/sys/amd64/amd64/local_apic.c Mon Oct 27 21:41:55 2008 (r184377) +++ head/sys/amd64/amd64/local_apic.c Mon Oct 27 21:45:18 2008 (r184378) @@ -401,11 +401,10 @@ lapic_setup_clock(void) lapic_timer_hz = hz * 2; else lapic_timer_hz = hz * 4; - if (lapic_timer_hz < 128) { - stathz = 128; - } else { + if (lapic_timer_hz < 128) + stathz = lapic_timer_hz; + else stathz = lapic_timer_hz / (lapic_timer_hz / 128); - } profhz = lapic_timer_hz; lapic_timer_period = value / lapic_timer_hz; From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 21:46:58 2008 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 5B6151065670; Mon, 27 Oct 2008 21:46:58 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49E4C8FC13; Mon, 27 Oct 2008 21:46:58 +0000 (UTC) (envelope-from marius@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 m9RLkwI3054141; Mon, 27 Oct 2008 21:46:58 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RLkwo4054140; Mon, 27 Oct 2008 21:46:58 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200810272146.m9RLkwo4054140@svn.freebsd.org> From: Marius Strobl Date: Mon, 27 Oct 2008 21:46:58 +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: r184379 - head/lib/libcam 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: Mon, 27 Oct 2008 21:46:58 -0000 Author: marius Date: Mon Oct 27 21:46:58 2008 New Revision: 184379 URL: http://svn.freebsd.org/changeset/base/184379 Log: Supply a valid Connect ID when issuing XPT_DEV_MATCH, which according to my reading of the CAM draft is mandatory for all CCB function calls and enforced by xptioctl() since at least r168752. Previously we happened to use 0 as the Path ID, causing the XPT_DEV_MATCH call to fail if there's no SCSI bus 0. Basically the same bug was also fixed the same way for camcontrol(8) as part of r126514. PR: 127605 Submitted by: Eygene Ryabinkin Approved by: silence from ken and scottl MFC after: 1 week Modified: head/lib/libcam/camlib.c Modified: head/lib/libcam/camlib.c ============================================================================== --- head/lib/libcam/camlib.c Mon Oct 27 21:45:18 2008 (r184378) +++ head/lib/libcam/camlib.c Mon Oct 27 21:46:58 2008 (r184379) @@ -346,6 +346,9 @@ cam_open_btl(path_id_t path_id, target_i bzero(&ccb, sizeof(union ccb)); ccb.ccb_h.func_code = XPT_DEV_MATCH; + ccb.ccb_h.path_id = CAM_XPT_PATH_ID; + ccb.ccb_h.target_id = CAM_TARGET_WILDCARD; + ccb.ccb_h.target_lun = CAM_LUN_WILDCARD; /* Setup the result buffer */ bufsize = sizeof(struct dev_match_result); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 22:10:02 2008 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 E3A2E1065673; Mon, 27 Oct 2008 22:10:01 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D1AA68FC13; Mon, 27 Oct 2008 22:10:01 +0000 (UTC) (envelope-from marius@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 m9RMA1TU054619; Mon, 27 Oct 2008 22:10:01 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RMA11M054618; Mon, 27 Oct 2008 22:10:01 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200810272210.m9RMA11M054618@svn.freebsd.org> From: Marius Strobl Date: Mon, 27 Oct 2008 22:10:01 +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: r184380 - head/sys/dev/bge 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: Mon, 27 Oct 2008 22:10:02 -0000 Author: marius Date: Mon Oct 27 22:10:01 2008 New Revision: 184380 URL: http://svn.freebsd.org/changeset/base/184380 Log: Do as the Linux tg3 driver does and enable MSI support also for the BCM5714 revision A0 when in a multi-port configuration and unconditionally for the remainder of the class of BCM575X and beyond chips. This was prodded by mav and is based on a suggestion and a patch submitted by jhb. Reviewed by: jhb MFC after: 2 months Modified: head/sys/dev/bge/if_bge.c Modified: head/sys/dev/bge/if_bge.c ============================================================================== --- head/sys/dev/bge/if_bge.c Mon Oct 27 21:46:58 2008 (r184379) +++ head/sys/dev/bge/if_bge.c Mon Oct 27 22:10:01 2008 (r184380) @@ -2328,10 +2328,11 @@ bge_can_use_msi(struct bge_softc *sc) int can_use_msi = 0; switch (sc->bge_asicrev) { + case BGE_ASICREV_BCM5714_A0: case BGE_ASICREV_BCM5714: /* - * Apparently, MSI doesn't work when this chip is configured - * in single-port mode. + * Apparently, MSI doesn't work when these chips are + * configured in single-port mode. */ if (bge_has_multiple_ports(sc)) can_use_msi = 1; @@ -2341,10 +2342,9 @@ bge_can_use_msi(struct bge_softc *sc) sc->bge_chiprev != BGE_CHIPREV_5750_BX) can_use_msi = 1; break; - case BGE_ASICREV_BCM5752: - case BGE_ASICREV_BCM5780: - can_use_msi = 1; - break; + default: + if (BGE_IS_575X_PLUS(sc)) + can_use_msi = 1; } return (can_use_msi); } From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 22:44:22 2008 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 C606E106566C; Mon, 27 Oct 2008 22:44:22 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B26908FC0A; Mon, 27 Oct 2008 22:44:22 +0000 (UTC) (envelope-from n_hibma@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 m9RMiMYC055358; Mon, 27 Oct 2008 22:44:22 GMT (envelope-from n_hibma@svn.freebsd.org) Received: (from n_hibma@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RMiMK6055357; Mon, 27 Oct 2008 22:44:22 GMT (envelope-from n_hibma@svn.freebsd.org) Message-Id: <200810272244.m9RMiMK6055357@svn.freebsd.org> From: Nick Hibma Date: Mon, 27 Oct 2008 22:44:22 +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: r184381 - head/sys/dev/usb 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: Mon, 27 Oct 2008 22:44:22 -0000 Author: n_hibma Date: Mon Oct 27 22:44:22 2008 New Revision: 184381 URL: http://svn.freebsd.org/changeset/base/184381 Log: Grab Sierra and Novatel init functions from NetBSD version of the u3g driver (rev 1.3), by Joerg Sonnenberger. Note: This change is untested as I do not own the hardware. Let me know if things work or do not work for you by sending me the output dmesg (and usbctl -f /dev/usbX if possible). Thanks. Modified: head/sys/dev/usb/u3g.c Modified: head/sys/dev/usb/u3g.c ============================================================================== --- head/sys/dev/usb/u3g.c Mon Oct 27 22:10:01 2008 (r184380) +++ head/sys/dev/usb/u3g.c Mon Oct 27 22:44:22 2008 (r184381) @@ -53,7 +53,7 @@ //#define U3G_DEBUG #ifdef U3G_DEBUG -#define DPRINTF(x...) do { if (u3gdebug) device_printf(self, ##x); } while (0) +#define DPRINTF(x...) do { if (u3gdebug) device_printf(sc->dev, ##x); } while (0) #define DPRINTFN(n, x...) do { if (u3gdebug > (n)) device_printf(self, ##x); } while (0) int u3gdebug = 1; #else @@ -118,8 +118,10 @@ struct u3g_dev_type_s { u_int8_t speed; u_int8_t flags; #define U3GFL_NONE 0x00 -#define U3GFL_HUAWEI_INIT 0x01 // Requires init (Huawei cards) -#define U3GFL_STUB_WAIT 0x02 // Device reappears after a short delay +#define U3GFL_HUAWEI_INIT 0x01 // Requires init command (Huawei cards) +#define U3GFL_SCSI_EJECT 0x02 // Requires SCSI eject command (Novatel) +#define U3GFL_SIERRA_INIT 0x04 // Requires init command (Sierra cards) +#define U3GFL_STUB_WAIT 0x08 // Device reappears after a short delay }; // Note: The entries marked with XXX should be checked for the correct speed @@ -138,22 +140,22 @@ static const struct u3g_dev_type_s u3g_d {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, U3GSP_HSDPA, U3GFL_HUAWEI_INIT }, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, U3GSP_HSPA, U3GFL_HUAWEI_INIT }, /* OEM: Novatel */ - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, U3GSP_CDMA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D }, U3GSP_HSUPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 }, U3GSP_HSDPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 }, U3GSP_HSDPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 }, U3GSP_UMTS, U3GFL_STUB_WAIT }, // XXX - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 }, U3GSP_HSDPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D }, U3GSP_HSUPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 }, U3GSP_HSDPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ZEROCD }, U3GSP_HSUPA, U3GFL_STUB_WAIT }, - {{ USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, U3GSP_HSDPA, U3GFL_STUB_WAIT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, U3GSP_CDMA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D }, U3GSP_HSUPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 }, U3GSP_HSDPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 }, U3GSP_HSDPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 }, U3GSP_UMTS, U3GFL_SCSI_EJECT }, // XXX + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 }, U3GSP_HSDPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D }, U3GSP_HSUPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 }, U3GSP_HSDPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ZEROCD }, U3GSP_HSUPA, U3GFL_SCSI_EJECT }, + {{ USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, U3GSP_HSDPA, U3GFL_SCSI_EJECT }, /* OEM: Merlin */ {{ USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 }, U3GSP_UMTS, U3GFL_NONE }, // XXX /* OEM: Sierra Wireless: */ @@ -182,6 +184,7 @@ static const struct u3g_dev_type_s u3g_d {{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8775_2 }, U3GSP_UMTS, U3GFL_NONE }, // XXX {{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8780 }, U3GSP_UMTS, U3GFL_NONE }, // XXX {{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8781 }, U3GSP_UMTS, U3GFL_NONE }, // XXX + {{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_TRUINSTALL }, U3GSP_UMTS, U3GFL_SIERRA_INIT }, // Sierra TruInstaller device ID }; #define u3g_lookup(v, p) ((const struct u3g_dev_type_s *)usb_lookup(u3g_devs, v, p)) @@ -423,8 +426,15 @@ MODULE_VERSION(u3g, 1); ****** Stub driver to hide devices that need to reinitialise ****** *******************************************************************/ -static void -u3gstub_huawei_init(usbd_device_handle dev) +struct u3gstub_softc { + device_t sc_dev; + usbd_device_handle sc_udev; + usbd_pipe_handle sc_pipe; + usbd_xfer_handle sc_xfer; +}; + +static int +u3gstub_huawei_init(struct u3gstub_softc *sc, struct usb_attach_arg *uaa) { usb_device_request_t req; @@ -434,7 +444,89 @@ u3gstub_huawei_init(usbd_device_handle d USETW(req.wIndex, UHF_PORT_SUSPEND); USETW(req.wLength, 0); - (void) usbd_do_request(dev, &req, 0); /* ignore any error */ + (void) usbd_do_request(uaa->device, &req, 0); /* ignore any error */ + + return 1; +} + +static int +u3gstub_scsi_eject(struct u3gstub_softc *sc, struct usb_attach_arg *uaa) +{ + unsigned char cmd[31]; +#ifdef U3G_DEBUG + device_t self = uaa->device; +#endif + usb_interface_descriptor_t *id; + usb_endpoint_descriptor_t *ed = NULL; + int i; + + memset(cmd, 0, sizeof(cmd)); + cmd[0] = 0x55; /* Byte 0..3: Command Block Wrapper (CBW) signature */ + cmd[1] = 0x53; + cmd[2] = 0x42; + cmd[3] = 0x43; + cmd[4] = 0x01; /* 4..7: CBW Tag, has to unique, but only a single transfer used. */ + /* 8..11: CBW Transfer Length, no data here */ + /* 12: CBW Flag: output, so 0 */ + /* 13: CBW Lun: 0 */ + /* 14: CBW Length */ + cmd[14] = 0x06; + cmd[15] = 0x1b; /* 0: SCSI START/STOP opcode */ + /* 1..3 unused */ + cmd[15+4] = 0x02; /* 4 Load/Eject command */ + /* 5: unused */ + + + /* Find the bulk-out endpoints */ + id = usbd_get_interface_descriptor(uaa->iface); + for (i = 0 ; i < id->bNumEndpoints ; i++) { + ed = usbd_interface2endpoint_descriptor(uaa->iface, i); + if (ed != NULL + && UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_OUT + && (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) + break; + } + + if (i == id->bNumEndpoints) + return 0; + + if (usbd_open_pipe(uaa->iface, ed->bEndpointAddress, + USBD_EXCLUSIVE_USE, &sc->sc_pipe) != USBD_NORMAL_COMPLETION) { + DPRINTF("failed to open bulk-out pipe on endpoint %d\n", + ed->bEndpointAddress); + return 0; + } + + sc->sc_xfer = usbd_alloc_xfer(uaa->device); + if (sc->sc_xfer == NULL) { + DPRINTF("failed to allocate xfer\n"); + return 0; + } + + usbd_setup_xfer(sc->sc_xfer, sc->sc_pipe, NULL, cmd, sizeof(cmd), + 0, USBD_DEFAULT_TIMEOUT, NULL); + if (usbd_transfer(sc->sc_xfer) != USBD_NORMAL_COMPLETION) { + DPRINTF("failed to start transfer\n"); + return 0; + } + + return 1; +} + +static int +u3gstub_sierra_init(struct u3gstub_softc *sc, struct usb_attach_arg *uaa) +{ + usb_device_request_t req; + + req.bmRequestType = UT_VENDOR; + req.bRequest = UR_SET_INTERFACE; + USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP); + USETW(req.wIndex, UHF_PORT_CONNECTION); + USETW(req.wLength, 0); + + (void) usbd_do_request(uaa->device, &req, 0); /* ignore any error */ + + return 1; } static int @@ -457,6 +549,8 @@ u3gstub_match(device_t self) return UMATCH_NONE; if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT + || u3g_dev_type->flags&U3GFL_SIERRA_INIT + || u3g_dev_type->flags&U3GFL_SCSI_EJECT || u3g_dev_type->flags&U3GFL_STUB_WAIT) { /* We assume that if the first interface is still a mass * storage device the device has not yet changed appearance. @@ -472,6 +566,7 @@ u3gstub_match(device_t self) static int u3gstub_attach(device_t self) { + struct u3gstub_softc *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); const struct u3g_dev_type_s *u3g_dev_type; int i; @@ -480,16 +575,26 @@ u3gstub_attach(device_t self) device_quiet(self); #endif + sc->sc_dev = self; + sc->sc_udev = uaa->device; + if (uaa->iface) for (i = 0; i < uaa->nifaces; i++) uaa->ifaces[i] = NULL; // claim all interfaces u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product); if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT) { - /* XXX Should we delay the kick? - */ DPRINTF("changing Huawei modem to modem mode\n"); - u3gstub_huawei_init(uaa->device); + if (!u3gstub_huawei_init(sc, uaa)) + return ENXIO; + } else if (u3g_dev_type->flags&U3GFL_SCSI_EJECT) { + DPRINTF("sending CD eject command to change to modem mode \n"); + if (!u3gstub_scsi_eject(sc, uaa)) + return ENXIO; + } else if (u3g_dev_type->flags&U3GFL_SIERRA_INIT) { + DPRINTF("changing Sierra modem to modem mode\n"); + if (!u3gstub_sierra_init(sc, uaa)) + return ENXIO; } else if (u3g_dev_type->flags&U3GFL_STUB_WAIT) { /* nop */ } @@ -500,6 +605,16 @@ u3gstub_attach(device_t self) static int u3gstub_detach(device_t self) { + struct u3gstub_softc *sc = device_get_softc(self); + + if (sc->sc_xfer) + usbd_free_xfer(sc->sc_xfer); + + if (sc->sc_pipe) { + usbd_abort_pipe(sc->sc_pipe); + usbd_close_pipe(sc->sc_pipe); + } + return 0; } @@ -515,7 +630,7 @@ static device_method_t u3gstub_methods[] static driver_t u3gstub_driver = { "u3gstub", u3gstub_methods, - 0 + sizeof (struct u3gstub_softc) }; DRIVER_MODULE(u3gstub, uhub, u3gstub_driver, ucom_devclass, usbd_driver_load, 0); From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 23:11:15 2008 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 177E81065670; Mon, 27 Oct 2008 23:11:15 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 050B48FC1E; Mon, 27 Oct 2008 23:11:15 +0000 (UTC) (envelope-from nwhitehorn@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 m9RNBElY055930; Mon, 27 Oct 2008 23:11:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RNBEaR055928; Mon, 27 Oct 2008 23:11:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200810272311.m9RNBEaR055928@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 27 Oct 2008 23:11:14 +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: r184382 - head/sys/powerpc/powermac 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: Mon, 27 Oct 2008 23:11:15 -0000 Author: nwhitehorn Date: Mon Oct 27 23:11:14 2008 New Revision: 184382 URL: http://svn.freebsd.org/changeset/base/184382 Log: Clean up some magic numbers in the DBDMA code by replacing them with appropriately defined constants. Suggested by: gnn Modified: head/sys/powerpc/powermac/dbdma.c head/sys/powerpc/powermac/dbdmavar.h Modified: head/sys/powerpc/powermac/dbdma.c ============================================================================== --- head/sys/powerpc/powermac/dbdma.c Mon Oct 27 22:44:22 2008 (r184381) +++ head/sys/powerpc/powermac/dbdma.c Mon Oct 27 23:11:14 2008 (r184382) @@ -93,7 +93,7 @@ int dbdma_resize_channel(dbdma_channel_t *chan, int newslots) { - if (newslots > (PAGE_SIZE / 16)) + if (newslots > (PAGE_SIZE / sizeof(struct dbdma_command))) return (-1); chan->sc_nslots = newslots; @@ -159,7 +159,8 @@ dbdma_run(dbdma_channel_t *chan) control_reg = DBDMA_STATUS_RUN | DBDMA_STATUS_PAUSE | DBDMA_STATUS_WAKE | DBDMA_STATUS_DEAD; - control_reg <<= 16; + control_reg <<= DBDMA_REG_MASK_SHIFT; + control_reg |= DBDMA_STATUS_RUN; dbdma_write_reg(chan, CHAN_CONTROL_REG, control_reg); } @@ -170,7 +171,8 @@ dbdma_pause(dbdma_channel_t *chan) uint32_t control_reg; control_reg = DBDMA_STATUS_PAUSE; - control_reg <<= 16; + control_reg <<= DBDMA_REG_MASK_SHIFT; + control_reg |= DBDMA_STATUS_PAUSE; dbdma_write_reg(chan, CHAN_CONTROL_REG, control_reg); } @@ -182,7 +184,8 @@ dbdma_wake(dbdma_channel_t *chan) control_reg = DBDMA_STATUS_WAKE | DBDMA_STATUS_PAUSE | DBDMA_STATUS_RUN | DBDMA_STATUS_DEAD; - control_reg <<= 16; + control_reg <<= DBDMA_REG_MASK_SHIFT; + control_reg |= DBDMA_STATUS_WAKE | DBDMA_STATUS_RUN; dbdma_write_reg(chan, CHAN_CONTROL_REG, control_reg); } @@ -193,7 +196,8 @@ dbdma_stop(dbdma_channel_t *chan) uint32_t control_reg; control_reg = DBDMA_STATUS_RUN; - control_reg <<= 16; + control_reg <<= DBDMA_REG_MASK_SHIFT; + dbdma_write_reg(chan, CHAN_CONTROL_REG, control_reg); while (dbdma_read_reg(chan, CHAN_STATUS_REG) & DBDMA_STATUS_ACTIVE) @@ -205,7 +209,7 @@ dbdma_set_current_cmd(dbdma_channel_t *c { uint32_t cmd; - cmd = chan->sc_slots_pa + slot * 16; + cmd = chan->sc_slots_pa + slot * sizeof(struct dbdma_command); dbdma_write_reg(chan, CHAN_CMDPTR, cmd); } @@ -230,7 +234,7 @@ dbdma_set_device_status(dbdma_channel_t uint32_t control_reg; control_reg = mask; - control_reg <<= 16; + control_reg <<= DBDMA_REG_MASK_SHIFT; control_reg |= value; dbdma_write_reg(chan, CHAN_CONTROL_REG, control_reg); @@ -242,7 +246,8 @@ dbdma_set_interrupt_selector(dbdma_chann uint32_t intr_select; intr_select = mask; - intr_select <<= 16; + intr_select <<= DBDMA_REG_MASK_SHIFT; + intr_select |= val; dbdma_write_reg(chan, CHAN_INTR_SELECT, intr_select); } @@ -253,7 +258,8 @@ dbdma_set_branch_selector(dbdma_channel_ uint32_t br_select; br_select = mask; - br_select <<= 16; + br_select <<= DBDMA_REG_MASK_SHIFT; + br_select |= val; dbdma_write_reg(chan, CHAN_BRANCH_SELECT, br_select); } @@ -264,7 +270,7 @@ dbdma_set_wait_selector(dbdma_channel_t uint32_t wait_select; wait_select = mask; - wait_select <<= 16; + wait_select <<= DBDMA_REG_MASK_SHIFT; wait_select |= val; dbdma_write_reg(chan, CHAN_WAIT_SELECT, wait_select); } @@ -286,7 +292,8 @@ dbdma_insert_command(dbdma_channel_t *ch cmd.reqCount = count; cmd.address = (uint32_t)(data); if (command != DBDMA_STORE_QUAD && command != DBDMA_LOAD_QUAD) - cmd.cmdDep = chan->sc_slots_pa + branch_slot * 16; + cmd.cmdDep = chan->sc_slots_pa + + branch_slot * sizeof(struct dbdma_command); else cmd.cmdDep = branch_slot; Modified: head/sys/powerpc/powermac/dbdmavar.h ============================================================================== --- head/sys/powerpc/powermac/dbdmavar.h Mon Oct 27 22:44:22 2008 (r184381) +++ head/sys/powerpc/powermac/dbdmavar.h Mon Oct 27 23:11:14 2008 (r184382) @@ -87,6 +87,8 @@ struct dbdma_channel { /* Channel control is the write channel to channel status, the upper 16 bits are a mask of which bytes to change */ +#define DBDMA_REG_MASK_SHIFT 16 + /* Status bits 0-7 are device dependent status bits */ /* From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 03:26:25 2008 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 EE19D1065681; Tue, 28 Oct 2008 03:26:25 +0000 (UTC) (envelope-from peter@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCCB28FC08; Tue, 28 Oct 2008 03:26:25 +0000 (UTC) (envelope-from peter@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 m9S3QPdh080878; Tue, 28 Oct 2008 03:26:25 GMT (envelope-from peter@svn.freebsd.org) Received: (from peter@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S3QPit080877; Tue, 28 Oct 2008 03:26:25 GMT (envelope-from peter@svn.freebsd.org) Message-Id: <200810280326.m9S3QPit080877@svn.freebsd.org> From: Peter Wemm Date: Tue, 28 Oct 2008 03:26:25 +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: r184385 - head/sys/kern 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, 28 Oct 2008 03:26:26 -0000 Author: peter Date: Tue Oct 28 03:26:25 2008 New Revision: 184385 URL: http://svn.freebsd.org/changeset/base/184385 Log: After a machine has been up for a bit more than 20 days with HZ=1000, "ticks" goes negative. This breaks the signed comparison in softclock. This causes sleep() to never wake up, tcp to stop, etc etc. This is bad(TM). Use the SEQ_LT() method from tcp's sequence number comparisons. Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Tue Oct 28 02:15:17 2008 (r184384) +++ head/sys/kern/kern_timeout.c Tue Oct 28 03:26:25 2008 (r184385) @@ -233,7 +233,7 @@ callout_tick(void) need_softclock = 0; cc = CC_SELF(); mtx_lock_spin_flags(&cc->cc_lock, MTX_QUIET); - for (; cc->cc_softticks < ticks; cc->cc_softticks++) { + for (; (cc->cc_softticks - ticks) < 0; cc->cc_softticks++) { bucket = cc->cc_softticks & callwheelmask; if (!TAILQ_EMPTY(&cc->cc_callwheel[bucket])) { need_softclock = 1; From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 03:47:07 2008 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 32BE4106566B; Tue, 28 Oct 2008 03:47:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 9ADE08FC0A; Tue, 28 Oct 2008 03:47:06 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m9S3icwb007895; Mon, 27 Oct 2008 21:44:38 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 27 Oct 2008 21:45:47 -0600 (MDT) Message-Id: <20081027.214547.709404828.imp@bsdimp.com> To: xcllnt@mac.com From: "M. Warner Losh" In-Reply-To: <0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com> References: <200810250618.m9P6ICWl023370@svn.freebsd.org> <20081027153345.d4e9dcad.stas@FreeBSD.org> <0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: stas@FreeBSD.org, svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys 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, 28 Oct 2008 03:47:07 -0000 In message: <0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com> Marcel Moolenaar writes: : : On Oct 27, 2008, at 5:33 AM, Stanislav Sedov wrote: : : >> Add a driver for flash memory that implements to the Common Flash : >> Memory Interface (CFI). The flash memory can be read and written : >> to through /dev/cfi# and an ioctl() exists so processes can read : >> the query information. : >> The driver supports the AMD and Intel command set, though only : >> the AMD command has been tested. : >> : >> Obtained from: Juniper Networks, Inc. : > : > Do you plan to introduce some infrastructure so other flash-like : > drivers could be attached (e.g. non-CFI compliant, SPI flashes, etc)? : > I've started working on such thing and don't want to do the duplicate : > works, so if you have something in mind it's time to share:-) : : I have been thinking about it, but I don't have anything : yet. As it is, I probably won't have the time for it : either. If you started with something, then feel free to : take cfi(4) and integrate it. : : Also, access to the raw flash is nice, but one typically : uses it for various things. It would be great if we had : an infrastructure in which we could allow access to the : flash through more high-level interfaces. For example: : The flash may contain U-Boot (possibly with embedded : environment), FreeBSD loader, separate blocks for U-Boot : environment, a file system, etc. Those parts of the : flash that are used for disk-like storage should ideally : be exposed through GEOM. Environments should ideally be : exposed through a standardized interface so that we only : have to write a single utility to modify environments. : Open Firmware and/or EFI environment variables could then : also be exposed through that interfaces, eliminating the : need for drivers like powermc_nvram and special-purpose : tools like nvram(8). That's the main reason I made the SPI flash support I did on the at91rm9200 be a block device: people could update the flash part w/o the need of a special program, just dd. Ditto for the i2c eeprom stuff... I tend to think that we should handle the partitioning in GEOM, with higher level things figuring the rest out. We should expose flash, and its properties upstream in GEOM, but not have a separate layer for flash ala mdt. Warner From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 04:20:07 2008 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 2CE471065672; Tue, 28 Oct 2008 04:20:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id B5C3F8FC18; Tue, 28 Oct 2008 04:20:06 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m9S4I01w008246; Mon, 27 Oct 2008 22:18:00 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 27 Oct 2008 22:19:10 -0600 (MDT) Message-Id: <20081027.221910.1508179985.imp@bsdimp.com> To: jhb@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <200810271159.31843.jhb@freebsd.org> References: <200810241031.08780.jhb@freebsd.org> <20081024.164740.74747369.imp@bsdimp.com> <200810271159.31843.jhb@freebsd.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Oct_27_22_19_10_2008_262)--" Content-Transfer-Encoding: 7bit Cc: danfe@FreeBSD.org, marcel@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-head@FreeBSD.org, des@des.no Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf 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, 28 Oct 2008 04:20:07 -0000 ----Next_Part(Mon_Oct_27_22_19_10_2008_262)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit In message: <200810271159.31843.jhb@freebsd.org> John Baldwin writes: : On Friday 24 October 2008 06:47:40 pm Warner Losh wrote: : > From: John Baldwin : > Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf : > Date: Fri, 24 Oct 2008 10:31:07 -0400 : > : > > On Friday 24 October 2008 09:27:03 am Alexey Dokuchaev wrote: : > > > On Fri, Oct 24, 2008 at 03:26:43AM +0200, Dag-Erling Sm??rgrav wrote: : > > > > Warner Losh writes: : > > > > > We already have a better mechanism for including config files. We : > > > > > should be using that instead of poluting another port with the : > > > > > DEFAULTS file. : > > > > : > > > > Should we even have DEFAULTS files at all? IMHO they just confuse : > > > > matters by introducing "stealth" options into your config. : > > > : > > > I tend to second this. I always try to get everything possible out of : > > > my kernel to modules, and thus was surprised to see io.ko and mem.ko : > > > fail to load because they were silently included into my custom kernel. : > > > : > > > I understand that some things like 'device isa' and : > > > 'device npx' aren't really optional, but if something is useful to have, : > > > but can be loaded as a module, it belongs to GENERIC rather than : > > > DEFAULTS. Killing the latter altogether and throwing a comment that : > > > says particular option or device is mandatory in GENERIC is probably : > > > even better (and more transparent). : > > : > > The one thing I think DEFAULTS is useful for are replacing NO_FOO options : with : > > FOO options. That is, if someone wants to turn a feature on by default, : I'd : > > rather them put 'options FOO' in DEFAULTS rather than rename all the : > > #ifdef's,e tc. to '#ifndef NO_FOO'. : > : > Wouldn't it be better to move to a system where we explicitly include : > std.i386 and have them all defined there? We already encourage stuff : > like this with advice to include GENERIC with nodev... : : I wouldn't mind a std.i386, and if we make config's include keyword fall back : to 'sys/conf' for relative path name lookups if the lookup in '.' fails then : you can even put those files in sys/conf with the still-clean syntax : of 'include std.i386'. Already works that way... : However, I don't know about you, but I _never_ build a config by including : GENERIC and then weeding stuff out. Too much stuff to weed out. Once I have : a customized config for a machine I then include that in development branches : to install kernels to different directories under /boot, etc. Yea, Well, I was thinking of std.firewire, et al. Trouble is we'd then have to slice thing by bus (std.pccard, std.cardbus, std.pci, std.iic, std.usb) and by function (std.wireless, std.scsi, std.serial) which slices across different functional groups... Warner P.S. Here's a diff of something we can do today... This is just a quickie demo, not a proposed patch to the tree... It also assumes that we have nocpu defined in config, which I haven't verified. ----Next_Part(Mon_Oct_27_22_19_10_2008_262)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="defaults.diff" Index: conf/std.i386 =================================================================== --- conf/std.i386 (revision 0) +++ conf/std.i386 (revision 0) @@ -0,0 +1,33 @@ +# +# DEFAULTS -- Default kernel configuration file for FreeBSD/i386 +# +# $FreeBSD: head/sys/i386/conf/DEFAULTS 181776 2008-08-15 20:58:57Z kmacy $ + +machine i386 + +# Default CPU support +cpu I486_CPU +cpu I586_CPU +cpu I686_CPU + +# Bus support. +device isa +options ISAPNP + +# Floating point support. +device npx + +# Pseudo devices. +device mem # Memory and kernel memory devices +device io # I/O device + +# UART chips on this platform +device uart_ns8250 + +# Default partitioning schemes +options GEOM_BSD +options GEOM_MBR + +# enable support for native hardware +options NATIVE +device atpic Index: i386/conf/DEFAULTS =================================================================== --- i386/conf/DEFAULTS (revision 184107) +++ i386/conf/DEFAULTS (working copy) @@ -1,28 +0,0 @@ -# -# DEFAULTS -- Default kernel configuration file for FreeBSD/i386 -# -# $FreeBSD$ - -machine i386 - -# Bus support. -device isa -options ISAPNP - -# Floating point support. -device npx - -# Pseudo devices. -device mem # Memory and kernel memory devices -device io # I/O device - -# UART chips on this platform -device uart_ns8250 - -# Default partitioning schemes -options GEOM_BSD -options GEOM_MBR - -# enable support for native hardware -options NATIVE -device atpic Index: i386/conf/GENERIC =================================================================== --- i386/conf/GENERIC (revision 184107) +++ i386/conf/GENERIC (working copy) @@ -18,9 +18,8 @@ # # $FreeBSD$ -cpu I486_CPU -cpu I586_CPU -cpu I686_CPU +include "std.i386" + ident GENERIC # To statically compile in device wiring instead of /boot/device.hints ----Next_Part(Mon_Oct_27_22_19_10_2008_262)---- From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 04:32:41 2008 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 6D3311065676; Tue, 28 Oct 2008 04:32:41 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5BB518FC08; Tue, 28 Oct 2008 04:32:41 +0000 (UTC) (envelope-from imp@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 m9S4WfTp082264; Tue, 28 Oct 2008 04:32:41 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S4WfbP082263; Tue, 28 Oct 2008 04:32:41 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200810280432.m9S4WfbP082263@svn.freebsd.org> From: Warner Losh Date: Tue, 28 Oct 2008 04:32:41 +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: r184386 - head/sys/i386/isa 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, 28 Oct 2008 04:32:41 -0000 Author: imp Date: Tue Oct 28 04:32:41 2008 New Revision: 184386 URL: http://svn.freebsd.org/changeset/base/184386 Log: style(9) nit: remove unnecessary {} pair. Modified: head/sys/i386/isa/pmtimer.c Modified: head/sys/i386/isa/pmtimer.c ============================================================================== --- head/sys/i386/isa/pmtimer.c Tue Oct 28 03:26:25 2008 (r184385) +++ head/sys/i386/isa/pmtimer.c Tue Oct 28 04:32:41 2008 (r184386) @@ -69,9 +69,8 @@ static int pmtimer_probe(device_t dev) { - if (ISA_PNP_PROBE(device_get_parent(dev), dev, pmtimer_ids) == ENXIO) { + if (ISA_PNP_PROBE(device_get_parent(dev), dev, pmtimer_ids) == ENXIO) return (ENXIO); - } /* only one instance always */ return (device_get_unit(dev)); From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 06:00:13 2008 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 C97DB1065673; Tue, 28 Oct 2008 06:00:13 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7C618FC14; Tue, 28 Oct 2008 06:00:13 +0000 (UTC) (envelope-from ed@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 m9S60Dqn084122; Tue, 28 Oct 2008 06:00:13 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S60Dn9084121; Tue, 28 Oct 2008 06:00:13 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200810280600.m9S60Dn9084121@svn.freebsd.org> From: Ed Schouten Date: Tue, 28 Oct 2008 06:00:13 +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: r184389 - head/lib/libutil 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, 28 Oct 2008 06:00:13 -0000 Author: ed Date: Tue Oct 28 06:00:13 2008 New Revision: 184389 URL: http://svn.freebsd.org/changeset/base/184389 Log: Remove unneeded call to revoke() inside openpty(). As discussed on the commits list, there is no need to call revoke() inside openpty(). On RELENG_6 and RELENG_7 unlockpt() will call revoke(). On HEAD we create pseudo-terminals on demand, so there is no need to revoke the slave device node. This change should never be MFC'd, because the implementation we have in RELENG_6 and RELENG_7 should work flawlessly with older versions of libc. Discussed with: jhb MFC after: never Modified: head/lib/libutil/pty.c Modified: head/lib/libutil/pty.c ============================================================================== --- head/lib/libutil/pty.c Tue Oct 28 05:50:28 2008 (r184388) +++ head/lib/libutil/pty.c Tue Oct 28 06:00:13 2008 (r184389) @@ -47,7 +47,6 @@ static char sccsid[] = "@(#)pty.c 8.3 (B #include #include #include -#include int openpty(int *amaster, int *aslave, char *name, struct termios *termp, @@ -70,9 +69,6 @@ openpty(int *amaster, int *aslave, char if (slavename == NULL) goto bad; - if (revoke(slavename) == -1) - goto bad; - slave = open(slavename, O_RDWR); if (slave == -1) goto bad; From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 07:19:16 2008 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 19FE61065679; Tue, 28 Oct 2008 07:19:16 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.cksoft.de (mail.cksoft.de [62.111.66.27]) by mx1.freebsd.org (Postfix) with ESMTP id C681C8FC23; Tue, 28 Oct 2008 07:19:15 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from localhost (amavis.str.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id 7050F41C69F; Tue, 28 Oct 2008 08:00:06 +0100 (CET) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([62.111.66.27]) by localhost (amavis.str.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id ozyvvlXKWrfW; Tue, 28 Oct 2008 08:00:06 +0100 (CET) Received: by mail.cksoft.de (Postfix, from userid 66) id 1304841C733; Tue, 28 Oct 2008 08:00:06 +0100 (CET) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id ED79E44487F; Tue, 28 Oct 2008 06:56:23 +0000 (UTC) Date: Tue, 28 Oct 2008 06:56:23 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: John Baldwin In-Reply-To: <200810271418.41291.jhb@freebsd.org> Message-ID: <20081028065010.A2978@maildrop.int.zabbadoz.net> References: <200810271515.m9RFF86d042970@svn.freebsd.org> <200810271418.41291.jhb@freebsd.org> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184341 - head/usr.sbin 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, 28 Oct 2008 07:19:16 -0000 On Mon, 27 Oct 2008, John Baldwin wrote: > On Monday 27 October 2008 11:15:08 am Bjoern A. Zeeb wrote: >> Author: bz >> Date: Mon Oct 27 15:15:08 2008 >> New Revision: 184341 >> URL: http://svn.freebsd.org/changeset/base/184341 >> >> Log: >> We do not have a libkse anymore and Mk/bsd.* does not know >> about LIBKSE anymore, so s,MK_LIBKSE,MK_LIBPTHREAD,. > > Shouldn't you just remove it instead? These two options are now basically > identical. (We probably should rename libthr to libpthread at some point.) tools/build/options/WITHOUT_LIBPTHREAD still talks about kse and thus does src.conf(5). I wouldn't object to removing one of the options but according to the src.conf my bet would be LIBTHR and not LIBPTHREAD. So updating the documentation might be a good initial step as well. I have to admit that I lost track about our threading libs in different branches at one time; how many are left in head - 1 or 2? Is only libthr left and we build it as libthr and add symlinks for libpthread? >> Modified: >> head/usr.sbin/Makefile >> >> Modified: head/usr.sbin/Makefile >> > ============================================================================== >> --- head/usr.sbin/Makefile Mon Oct 27 14:49:12 2008 (r184340) >> +++ head/usr.sbin/Makefile Mon Oct 27 15:15:08 2008 (r184341) >> @@ -292,7 +292,7 @@ _moused= moused >> _vidcontrol= vidcontrol >> .endif >> >> -.if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" >> +.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" >> .if ${MK_PPP} != "no" >> _pppctl= pppctl >> .endif >> > > > > -- Bjoern A. Zeeb Stop bit received. Insert coin for new game. From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 08:50:10 2008 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 DBD5E106566B; Tue, 28 Oct 2008 08:50:10 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB3ED8FC0A; Tue, 28 Oct 2008 08:50:10 +0000 (UTC) (envelope-from rwatson@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 m9S8o9a0088119; Tue, 28 Oct 2008 08:50:09 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S8o9Hr088118; Tue, 28 Oct 2008 08:50:09 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810280850.m9S8o9Hr088118@svn.freebsd.org> From: Robert Watson Date: Tue, 28 Oct 2008 08:50:09 +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: r184400 - head/sys/security/mac_stub 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, 28 Oct 2008 08:50:11 -0000 Author: rwatson Date: Tue Oct 28 08:50:09 2008 New Revision: 184400 URL: http://svn.freebsd.org/changeset/base/184400 Log: Improve alphabetical sort order of stub entry points. Modified: head/sys/security/mac_stub/mac_stub.c Modified: head/sys/security/mac_stub/mac_stub.c ============================================================================== --- head/sys/security/mac_stub/mac_stub.c Tue Oct 28 08:41:25 2008 (r184399) +++ head/sys/security/mac_stub/mac_stub.c Tue Oct 28 08:50:09 2008 (r184400) @@ -1020,38 +1020,6 @@ stub_system_check_sysctl(struct ucred *c return (0); } -static int -stub_vnode_check_access(struct ucred *cred, struct vnode *vp, - struct label *vplabel, int acc_mode) -{ - - return (0); -} - -static int -stub_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (0); -} - -static int -stub_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel) -{ - - return (0); -} - -static int -stub_vnode_check_create(struct ucred *cred, struct vnode *dvp, - struct label *dvplabel, struct componentname *cnp, struct vattr *vap) -{ - - return (0); -} - static void stub_sysvmsg_cleanup(struct label *msglabel) { @@ -1246,6 +1214,38 @@ stub_vnode_associate_singlelabel(struct } static int +stub_vnode_check_access(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int acc_mode) +{ + + return (0); +} + +static int +stub_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel) +{ + + return (0); +} + +static int +stub_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel) +{ + + return (0); +} + +static int +stub_vnode_check_create(struct ucred *cred, struct vnode *dvp, + struct label *dvplabel, struct componentname *cnp, struct vattr *vap) +{ + + return (0); +} + +static int stub_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 09:12:13 2008 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 6F1D8106567D; Tue, 28 Oct 2008 09:12:13 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E5CF8FC20; Tue, 28 Oct 2008 09:12:13 +0000 (UTC) (envelope-from rwatson@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 m9S9CDjj088603; Tue, 28 Oct 2008 09:12:13 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S9CDLh088602; Tue, 28 Oct 2008 09:12:13 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810280912.m9S9CDLh088602@svn.freebsd.org> From: Robert Watson Date: Tue, 28 Oct 2008 09:12:13 +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: r184401 - head/sys/security/mac_partition 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, 28 Oct 2008 09:12:13 -0000 Author: rwatson Date: Tue Oct 28 09:12:13 2008 New Revision: 184401 URL: http://svn.freebsd.org/changeset/base/184401 Log: Rename label_on_label() to partition_check(), which is far more suggestive as to its actual function. Obtained from: TrustedBSD Project MFC after: 3 days Modified: head/sys/security/mac_partition/mac_partition.c Modified: head/sys/security/mac_partition/mac_partition.c ============================================================================== --- head/sys/security/mac_partition/mac_partition.c Tue Oct 28 08:50:09 2008 (r184400) +++ head/sys/security/mac_partition/mac_partition.c Tue Oct 28 09:12:13 2008 (r184401) @@ -77,7 +77,7 @@ static int partition_slot; #define SLOT_SET(l, v) mac_label_set((l), partition_slot, (v)) static int -label_on_label(struct label *subject, struct label *object) +partition_check(struct label *subject, struct label *object) { if (partition_enabled == 0) @@ -133,7 +133,7 @@ partition_cred_check_visible(struct ucre { int error; - error = label_on_label(cr1->cr_label, cr2->cr_label); + error = partition_check(cr1->cr_label, cr2->cr_label); return (error == 0 ? 0 : ESRCH); } @@ -209,7 +209,7 @@ partition_inpcb_check_visible(struct ucr { int error; - error = label_on_label(cred->cr_label, inp->inp_cred->cr_label); + error = partition_check(cred->cr_label, inp->inp_cred->cr_label); return (error ? ENOENT : 0); } @@ -219,7 +219,7 @@ partition_proc_check_debug(struct ucred { int error; - error = label_on_label(cred->cr_label, p->p_ucred->cr_label); + error = partition_check(cred->cr_label, p->p_ucred->cr_label); return (error ? ESRCH : 0); } @@ -229,7 +229,7 @@ partition_proc_check_sched(struct ucred { int error; - error = label_on_label(cred->cr_label, p->p_ucred->cr_label); + error = partition_check(cred->cr_label, p->p_ucred->cr_label); return (error ? ESRCH : 0); } @@ -240,7 +240,7 @@ partition_proc_check_signal(struct ucred { int error; - error = label_on_label(cred->cr_label, p->p_ucred->cr_label); + error = partition_check(cred->cr_label, p->p_ucred->cr_label); return (error ? ESRCH : 0); } @@ -265,7 +265,7 @@ partition_socket_check_visible(struct uc { int error; - error = label_on_label(cred->cr_label, so->so_cred->cr_label); + error = partition_check(cred->cr_label, so->so_cred->cr_label); return (error ? ENOENT : 0); } From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 09:16:35 2008 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 45C98106566B; Tue, 28 Oct 2008 09:16:35 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 352E28FC1A; Tue, 28 Oct 2008 09:16:35 +0000 (UTC) (envelope-from rwatson@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 m9S9GZRt088761; Tue, 28 Oct 2008 09:16:35 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S9GZDX088760; Tue, 28 Oct 2008 09:16:35 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200810280916.m9S9GZDX088760@svn.freebsd.org> From: Robert Watson Date: Tue, 28 Oct 2008 09:16:35 +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: r184402 - head/sys/security/mac_partition 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, 28 Oct 2008 09:16:35 -0000 Author: rwatson Date: Tue Oct 28 09:16:34 2008 New Revision: 184402 URL: http://svn.freebsd.org/changeset/base/184402 Log: Extended comment on why we consider a partition relabel request of "0" to be a no-op request, and why this might have to change if we want to allow leaving a partition someday. Obtained from: TrustedBSD Project MFC after: 3 days Modified: head/sys/security/mac_partition/mac_partition.c Modified: head/sys/security/mac_partition/mac_partition.c ============================================================================== --- head/sys/security/mac_partition/mac_partition.c Tue Oct 28 09:12:13 2008 (r184401) +++ head/sys/security/mac_partition/mac_partition.c Tue Oct 28 09:16:34 2008 (r184402) @@ -114,7 +114,13 @@ partition_cred_check_relabel(struct ucre error = 0; - /* Treat "0" as a no-op request. */ + /* + * Treat "0" as a no-op request because it reflects an unset + * partition label. If we ever want to support switching back to an + * unpartitioned state for a process, we'll need to differentiate the + * "not in a partition" and "no partition defined during internalize" + * conditions. + */ if (SLOT(newlabel) != 0) { /* * Require BSD privilege in order to change the partition. From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 09:45:08 2008 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 E5457106569D; Tue, 28 Oct 2008 09:45:08 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4CEB8FC18; Tue, 28 Oct 2008 09:45:08 +0000 (UTC) (envelope-from bz@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 m9S9j7fE089423; Tue, 28 Oct 2008 09:45:07 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9S9j7H8089422; Tue, 28 Oct 2008 09:45:07 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200810280945.m9S9j7H8089422@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 28 Oct 2008 09:45:07 +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: r184403 - head/sys/dev/usb 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, 28 Oct 2008 09:45:09 -0000 Author: bz Date: Tue Oct 28 09:45:07 2008 New Revision: 184403 URL: http://svn.freebsd.org/changeset/base/184403 Log: Unbreak LINT from r184381 using the correct variable in debugging DPRINTF for the device and remove dead code. Modified: head/sys/dev/usb/u3g.c Modified: head/sys/dev/usb/u3g.c ============================================================================== --- head/sys/dev/usb/u3g.c Tue Oct 28 09:16:34 2008 (r184402) +++ head/sys/dev/usb/u3g.c Tue Oct 28 09:45:07 2008 (r184403) @@ -53,7 +53,7 @@ //#define U3G_DEBUG #ifdef U3G_DEBUG -#define DPRINTF(x...) do { if (u3gdebug) device_printf(sc->dev, ##x); } while (0) +#define DPRINTF(x...) do { if (u3gdebug) device_printf(sc->sc_dev, ##x); } while (0) #define DPRINTFN(n, x...) do { if (u3gdebug > (n)) device_printf(self, ##x); } while (0) int u3gdebug = 1; #else @@ -453,9 +453,6 @@ static int u3gstub_scsi_eject(struct u3gstub_softc *sc, struct usb_attach_arg *uaa) { unsigned char cmd[31]; -#ifdef U3G_DEBUG - device_t self = uaa->device; -#endif usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed = NULL; int i; From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 09:55:34 2008 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 38E68106567E; Tue, 28 Oct 2008 09:55:34 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id C5C318FC18; Tue, 28 Oct 2008 09:55:33 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-151-199.carlnfd1.nsw.optusnet.com.au (c122-106-151-199.carlnfd1.nsw.optusnet.com.au [122.106.151.199]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m9S9tSkT006706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Oct 2008 20:55:30 +1100 Date: Tue, 28 Oct 2008 20:55:28 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: John Baldwin In-Reply-To: <200810271411.11813.jhb@freebsd.org> Message-ID: <20081028202701.E85964@delplex.bde.org> References: <200810261858.m9QIw4YV091893@svn.freebsd.org> <200810271411.11813.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Maxim Sobolev , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386 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, 28 Oct 2008 09:55:34 -0000 On Mon, 27 Oct 2008, John Baldwin wrote: > On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote: >> Author: sobomax >> Date: Sun Oct 26 18:58:04 2008 >> New Revision: 184293 >> URL: http://svn.freebsd.org/changeset/base/184293 >> >> Log: >> Fix division by zero panic if kern.hz less than 32. >> >> MFC after: 1 day > > This is wrong. In the case you are worried about here, lapic_timer_hz is less > than 128. There is no way you are going to fire stathz 128 times per second > from a timer running at < 128 hz. You are effectively running stathz at > lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case. stathz needs to be about 128 to work as intended, at least for SCHED_4BSD. > Also, I would drop the extra {}'s to match style(9) as well as the existing > style of the file. I noticed this bug in the main commit too. Also, hz = 10 cannot work on i386 without lapic_timer, since the i8254 timer has a maximum interrupt period of 55 ms and thus a minimum frequency of 18.2 Hz. Attempts to set it to 10 Hz cause similar bugs to the ones here -- the best approximation of 18.2 is (supposed to be) used, but the system is not informed about the enormous error in this approximation and still thinks that 10 Hz is used. I use hz = stathz = 100 = lapic_timer_hz on all systems with lapic timer, mainly to avoid the large changes to scale all the timers perfectly. (This makes profhz = lapic_timer_hz = 100 more broken than before. Perfect scaling rarely matters, and asynchronicity of the timers is broken anyway.) hz != 100 is still supported in a simple way that makes stathz = 100 (and lapic_timer_hz unnecessarily large -- 1000) if hz < 100: lapic_timer_hz = howmany(imax(hz, 100), hz) * hz; stathz = lapic_timer_hz / (lapic_timer_hz < 100 ? 1 : lapic_timer_hz / 100); >> --- head/sys/amd64/amd64/local_apic.c Sun Oct 26 17:20:37 2008 (r184292) >> +++ head/sys/amd64/amd64/local_apic.c Sun Oct 26 18:58:04 2008 (r184293) >> @@ -401,7 +401,11 @@ lapic_setup_clock(void) >> lapic_timer_hz = hz * 2; >> else >> lapic_timer_hz = hz * 4; >> - stathz = lapic_timer_hz / (lapic_timer_hz / 128); >> + if (lapic_timer_hz < 128) { >> + stathz = 128; >> + } else { >> + stathz = lapic_timer_hz / (lapic_timer_hz / 128); >> + } Use of if/else instead a conditional expression as in the above may be another style bug here. Bruce From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 10:37:40 2008 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 D17A21065684; Tue, 28 Oct 2008 10:37:40 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C0A348FC34; Tue, 28 Oct 2008 10:37:40 +0000 (UTC) (envelope-from edwin@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 m9SAbe7M091728; Tue, 28 Oct 2008 10:37:40 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SAbepV091726; Tue, 28 Oct 2008 10:37:40 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200810281037.m9SAbepV091726@svn.freebsd.org> From: Edwin Groothuis Date: Tue, 28 Oct 2008 10:37:40 +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: r184406 - head/share/zoneinfo 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, 28 Oct 2008 10:37:40 -0000 Author: edwin Date: Tue Oct 28 10:37:40 2008 New Revision: 184406 URL: http://svn.freebsd.org/changeset/base/184406 Log: MFV of tzdata2008i. - United States zone reordering and recommenting - Argentina DST changes update. Modified: head/share/zoneinfo/ (props changed) head/share/zoneinfo/southamerica head/share/zoneinfo/zone.tab Modified: head/share/zoneinfo/southamerica ============================================================================== --- head/share/zoneinfo/southamerica Tue Oct 28 10:35:17 2008 (r184405) +++ head/share/zoneinfo/southamerica Tue Oct 28 10:37:40 2008 (r184406) @@ -1,4 +1,4 @@ -# @(#)southamerica 8.30 +# @(#)southamerica 8.33 #
 
 # This data is by no means authoritative; if you think you know better,
@@ -193,6 +193,26 @@ Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 # 
 # So there is no summer time in Argentina for now.
 
+# From Mariano Absatz (2008-10-20):
+# Decree 1693/2008 applies Law 26.350 for the summer 2008/2009 establishing DST in Argentina
+# From 2008-10-19 until 2009-03-15
+# 
+# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=16102008&pi=3&pf=4&s=0&sec=01
+# 
+#
+# Decree 1705/2008 excepting 12 Provinces from applying DST in the summer 2008/2009:
+# Catamarca, La Rioja, Mendoza, Salta, San Juan, San Luis, La Pampa, Neuquen, Rio Negro, Chubut, Santa Cruz
+# and Tierra del Fuego
+# 
+# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=17102008&pi=1&pf=1&s=0&sec=01
+# 
+#
+# Press release 235 dated Saturday October 18th, from the Government of the Province of Jujuy saying
+# it will not apply DST either (even when it was not included in Decree 1705/2008)
+# 
+# http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
+# 
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
 Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
 Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S
@@ -343,9 +363,8 @@ Zone America/Argentina/Buenos_Aires -3:5
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT
 #
-# Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN), Chaco (CC),
-# Formosa (FM), Salta (SA), Santiago del Estero (SE), Cordoba (CB),
-# La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
+# Cordoba (CB), Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN),
+# Chaco (CC), Formosa (FM), Santiago del Estero (SE)
 #
 # Shanks & Pottenger also make the following claims, which we haven't verified:
 # - Formosa switched to -3:00 on 1991-01-07.
@@ -364,6 +383,18 @@ Zone America/Argentina/Cordoba -4:16:48 
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT
 #
+# Salta (SA), La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
+Zone America/Argentina/Salta -4:21:40 - LMT	1894 Oct 31
+			-4:16:48 -	CMT	1920 May
+			-4:00	-	ART	1930 Dec
+			-4:00	Arg	AR%sT	1969 Oct  5
+			-3:00	Arg	AR%sT	1991 Mar  3
+			-4:00	-	WART	1991 Oct 20
+			-3:00	Arg	AR%sT	1999 Oct  3
+			-4:00	Arg	AR%sT	2000 Mar  3
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
+#
 # Tucuman (TM)
 Zone America/Argentina/Tucuman -4:20:52 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
@@ -388,7 +419,8 @@ Zone America/Argentina/La_Rioja -4:27:24
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # San Juan (SJ)
 Zone America/Argentina/San_Juan -4:34:04 - LMT	1894 Oct 31
@@ -401,7 +433,8 @@ Zone America/Argentina/San_Juan -4:34:04
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # Jujuy (JY)
 Zone America/Argentina/Jujuy -4:21:12 -	LMT	1894 Oct 31
@@ -415,7 +448,8 @@ Zone America/Argentina/Jujuy -4:21:12 -	
 			-3:00	1:00	ARST	1992
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # Catamarca (CT), Chubut (CH)
 Zone America/Argentina/Catamarca -4:23:08 - LMT	1894 Oct 31
@@ -428,7 +462,8 @@ Zone America/Argentina/Catamarca -4:23:0
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # Mendoza (MZ)
 Zone America/Argentina/Mendoza -4:35:16 - LMT	1894 Oct 31
@@ -445,7 +480,8 @@ Zone America/Argentina/Mendoza -4:35:16 
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 23
 			-4:00	-	WART	2004 Sep 26
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # San Luis (SL)
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
@@ -473,7 +509,8 @@ Zone America/Argentina/Rio_Gallegos -4:3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 #
 # Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF)
 Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
@@ -484,7 +521,8 @@ Zone America/Argentina/Ushuaia -4:33:12 
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 30
 			-4:00	-	WART	2004 Jun 20
-			-3:00	Arg	AR%sT
+			-3:00	Arg	AR%sT	2008 Oct 18
+			-3:00	-	ART
 
 # Aruba
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]

Modified: head/share/zoneinfo/zone.tab
==============================================================================
--- head/share/zoneinfo/zone.tab	Tue Oct 28 10:35:17 2008	(r184405)
+++ head/share/zoneinfo/zone.tab	Tue Oct 28 10:37:40 2008	(r184406)
@@ -1,4 +1,4 @@
-# @(#)zone.tab	8.19
+# @(#)zone.tab	8.21
 #
 # TZ zone descriptions
 #
@@ -42,14 +42,15 @@ AQ	-7824+10654	Antarctica/Vostok	Vostok 
 AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Terre Adelie
 AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
 AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
-AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF)
-AR	-3319-06621	America/Argentina/San_Luis	San Luis (SL)
+AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, MN, SE, SF)
+AR	-2447-06525	America/Argentina/Salta	(SA, LP, NQ, RN)
 AR	-2411-06518	America/Argentina/Jujuy	Jujuy (JY)
 AR	-2649-06513	America/Argentina/Tucuman	Tucuman (TM)
 AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT), Chubut (CH)
 AR	-2926-06651	America/Argentina/La_Rioja	La Rioja (LR)
 AR	-3132-06831	America/Argentina/San_Juan	San Juan (SJ)
 AR	-3253-06849	America/Argentina/Mendoza	Mendoza (MZ)
+AR	-3319-06621	America/Argentina/San_Luis	San Luis (SL)
 AR	-5138-06913	America/Argentina/Rio_Gallegos	Santa Cruz (SC)
 AR	-5448-06818	America/Argentina/Ushuaia	Tierra del Fuego (TF)
 AS	-1416-17042	Pacific/Pago_Pago
@@ -384,13 +385,13 @@ US	+381515-0854534	America/Kentucky/Loui
 US	+364947-0845057	America/Kentucky/Monticello	Eastern Time - Kentucky - Wayne County
 US	+394606-0860929	America/Indiana/Indianapolis	Eastern Time - Indiana - most locations
 US	+384038-0873143	America/Indiana/Vincennes	Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
-US	+411745-0863730	America/Indiana/Knox	Eastern Time - Indiana - Starke County
 US	+410305-0863611	America/Indiana/Winamac	Eastern Time - Indiana - Pulaski County
 US	+382232-0862041	America/Indiana/Marengo	Eastern Time - Indiana - Crawford County
+US	+382931-0871643	America/Indiana/Petersburg	Eastern Time - Indiana - Pike County
 US	+384452-0850402	America/Indiana/Vevay	Eastern Time - Indiana - Switzerland County
 US	+415100-0873900	America/Chicago	Central Time
 US	+375711-0864541	America/Indiana/Tell_City	Central Time - Indiana - Perry County
-US	+382931-0871643	America/Indiana/Petersburg	Central Time - Indiana - Pike County
+US	+411745-0863730	America/Indiana/Knox	Central Time - Indiana - Starke County
 US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
 US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
 US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota - Morton County (except Mandan area)

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 10:42:43 2008
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 A15CF106566B;
	Tue, 28 Oct 2008 10:42:43 +0000 (UTC)
	(envelope-from sobomax@FreeBSD.org)
Received: from sippysoft.com (gk1.360sip.com [72.236.70.240])
	by mx1.freebsd.org (Postfix) with ESMTP id 67F178FC2B;
	Tue, 28 Oct 2008 10:42:43 +0000 (UTC)
	(envelope-from sobomax@FreeBSD.org)
Received: from [192.168.1.23] (S0106001372fd1e07.vs.shawcable.net
	[70.71.2.169]) (authenticated bits=0)
	by sippysoft.com (8.13.8/8.13.8) with ESMTP id m9SAgfeO088126
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Tue, 28 Oct 2008 03:42:42 -0700 (PDT)
	(envelope-from sobomax@FreeBSD.org)
Message-ID: <4906ECC1.4080907@FreeBSD.org>
Date: Tue, 28 Oct 2008 03:43:13 -0700
From: Maxim Sobolev 
Organization: Sippy Software, Inc.
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: Bruce Evans 
References: <200810261858.m9QIw4YV091893@svn.freebsd.org>
	<200810271411.11813.jhb@freebsd.org>
	<20081028202701.E85964@delplex.bde.org>
In-Reply-To: <20081028202701.E85964@delplex.bde.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org, John Baldwin 
Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386
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, 28 Oct 2008 10:42:43 -0000

Bruce Evans wrote:
> On Mon, 27 Oct 2008, John Baldwin wrote:
> 
>> On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote:
>>> Author: sobomax
>>> Date: Sun Oct 26 18:58:04 2008
>>> New Revision: 184293
>>> URL: http://svn.freebsd.org/changeset/base/184293
>>>
>>> Log:
>>>   Fix division by zero panic if kern.hz less than 32.
>>>
>>>   MFC after:    1 day
>>
>> This is wrong.  In the case you are worried about here, lapic_timer_hz 
>> is less
>> than 128.  There is no way you are going to fire stathz 128 times per 
>> second
>> from a timer running at < 128 hz.  You are effectively running stathz at
>> lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case.
> 
> stathz needs to be about 128 to work as intended, at least for SCHED_4BSD.
> 
>> Also, I would drop the extra {}'s to match style(9) as well as the 
>> existing
>> style of the file.
> 
> I noticed this bug in the main commit too.
> 
> Also, hz = 10 cannot work on i386 without lapic_timer, since the i8254 
> timer
> has a maximum interrupt period of 55 ms and thus a minimum frequency of
> 18.2 Hz.  Attempts to set it to 10 Hz cause similar bugs to the ones here
> -- the best approximation of 18.2 is (supposed to be) used, but the system
> is not informed about the enormous error in this approximation and still
> thinks that 10 Hz is used.

Does it suggest that we simply need to place lower limit of 128 on 
lapic_timer_hz and lower limit of 18 on i8254 timer? As far as I 
understand timer frequency could be higher than actual HZ (at least 
lapic code suggest that it can). Will it help or cause any other issues?

-Maxim

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 08:21:08 2008
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 87E9B1065674;
	Tue, 28 Oct 2008 08:21:08 +0000 (UTC)
	(envelope-from stas@FreeBSD.org)
Received: from smtp.ht-systems.ru (mr0.ht-systems.ru [78.110.50.55])
	by mx1.freebsd.org (Postfix) with ESMTP id 375BB8FC08;
	Tue, 28 Oct 2008 08:21:07 +0000 (UTC)
	(envelope-from stas@FreeBSD.org)
Received: from [85.21.245.235] (helo=orion.SpringDaemons.com)
	by smtp.ht-systems.ru with esmtpa (Exim 4.62)
	(envelope-from )
	id 1KujEy-0004gZ-Bx; Tue, 28 Oct 2008 10:43:48 +0300
Received: from orion (localhost [127.0.0.1])
	by orion.SpringDaemons.com (Postfix) with SMTP id 1E03E39956;
	Tue, 28 Oct 2008 10:44:41 +0300 (MSK)
Date: Tue, 28 Oct 2008 10:44:35 +0300
From: Stanislav Sedov 
To: "M. Warner Losh" 
Message-Id: <20081028104435.50b3fb0f.stas@FreeBSD.org>
In-Reply-To: <20081027.214547.709404828.imp@bsdimp.com>
References: <200810250618.m9P6ICWl023370@svn.freebsd.org>
	<20081027153345.d4e9dcad.stas@FreeBSD.org>
	<0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com>
	<20081027.214547.709404828.imp@bsdimp.com>
Organization: The FreeBSD Project
X-XMPP: ssedov@jabber.ru
X-Voice: +7 916 849 20 23
X-PGP-Fingerprint: F21E D6CC 5626 9609 6CE2  A385 2BF5 5993 EB26 9581
X-Mailer: carrier-pigeon
Mime-Version: 1.0
Content-Type: multipart/signed; protocol="application/pgp-signature";
	micalg="PGP-SHA1";
	boundary="Signature=_Tue__28_Oct_2008_10_44_35_+0300_em0nLI1ADPhWsZ.4"
X-Mailman-Approved-At: Tue, 28 Oct 2008 11:20:09 +0000
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, xcllnt@mac.com,
	src-committers@FreeBSD.org
Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys
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, 28 Oct 2008 08:21:08 -0000

--Signature=_Tue__28_Oct_2008_10_44_35_+0300_em0nLI1ADPhWsZ.4
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, 27 Oct 2008 21:45:47 -0600 (MDT)
"M. Warner Losh"  mentioned:

>=20
> I tend to think that we should handle the partitioning in GEOM, with
> higher level things figuring the rest out.  We should expose flash,
> and its properties upstream in GEOM, but not have a separate layer for
> flash ala mdt.
>=20

Yeah, GEOM is the right place for this kind of stuff, indeed. Wear levering
and similar things could be provided via GEOM too, probably.

--=20
Stanislav Sedov
ST4096-RIPE

--Signature=_Tue__28_Oct_2008_10_44_35_+0300_em0nLI1ADPhWsZ.4
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkkGwugACgkQK/VZk+smlYG7sQCdE74Gk/t2Ybc2h/w9h7/RFg0/
tDMAn1+DmgQvZSkstpQAOutQxCXPo3S+
=zaPA
-----END PGP SIGNATURE-----

--Signature=_Tue__28_Oct_2008_10_44_35_+0300_em0nLI1ADPhWsZ.4--

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 11:33:07 2008
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 12478106566C;
	Tue, 28 Oct 2008 11:33:07 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F28E98FC0C;
	Tue, 28 Oct 2008 11:33:06 +0000 (UTC)
	(envelope-from rwatson@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 m9SBX6jX092847;
	Tue, 28 Oct 2008 11:33:06 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SBX65A092836;
	Tue, 28 Oct 2008 11:33:06 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810281133.m9SBX65A092836@svn.freebsd.org>
From: Robert Watson 
Date: Tue, 28 Oct 2008 11:33:06 +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: r184407 - in head/sys: kern nfsserver security/mac
	security/mac_biba security/mac_lomac security/mac_mls
	security/mac_partition security/mac_stub security/mac_test
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, 28 Oct 2008 11:33:07 -0000

Author: rwatson
Date: Tue Oct 28 11:33:06 2008
New Revision: 184407
URL: http://svn.freebsd.org/changeset/base/184407

Log:
  Rename three MAC entry points from _proc_ to _cred_ to reflect the fact
  that they operate directly on credentials: mac_proc_create_swapper(),
  mac_proc_create_init(), and mac_proc_associate_nfsd().  Update policies.
  
  Obtained from:	TrustedBSD Project

Modified:
  head/sys/kern/init_main.c
  head/sys/nfsserver/nfs_srvsock.c
  head/sys/security/mac/mac_framework.h
  head/sys/security/mac/mac_policy.h
  head/sys/security/mac/mac_process.c
  head/sys/security/mac_biba/mac_biba.c
  head/sys/security/mac_lomac/mac_lomac.c
  head/sys/security/mac_mls/mac_mls.c
  head/sys/security/mac_partition/mac_partition.c
  head/sys/security/mac_stub/mac_stub.c
  head/sys/security/mac_test/mac_test.c

Modified: head/sys/kern/init_main.c
==============================================================================
--- head/sys/kern/init_main.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/kern/init_main.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -456,7 +456,7 @@ proc0_init(void *dummy __unused)
 	audit_cred_kproc0(p->p_ucred);
 #endif
 #ifdef MAC
-	mac_proc_create_swapper(p->p_ucred);
+	mac_cred_create_swapper(p->p_ucred);
 #endif
 	td->td_ucred = crhold(p->p_ucred);
 
@@ -736,7 +736,7 @@ create_init(const void *udata __unused)
 	oldcred = initproc->p_ucred;
 	crcopy(newcred, oldcred);
 #ifdef MAC
-	mac_proc_create_init(newcred);
+	mac_cred_create_init(newcred);
 #endif
 #ifdef AUDIT
 	audit_cred_proc1(newcred);

Modified: head/sys/nfsserver/nfs_srvsock.c
==============================================================================
--- head/sys/nfsserver/nfs_srvsock.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/nfsserver/nfs_srvsock.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -360,7 +360,7 @@ nfs_getreq(struct nfsrv_descript *nd, st
 		nd->nd_cr->cr_groups[0] = nd->nd_cr->cr_rgid =
 		    nd->nd_cr->cr_svgid = fxdr_unsigned(gid_t, *tl++);
 #ifdef MAC
-		mac_proc_associate_nfsd(nd->nd_cr);
+		mac_cred_associate_nfsd(nd->nd_cr);
 #endif
 		len = fxdr_unsigned(int, *tl);
 		if (len < 0 || len > RPCAUTH_UNIXGIDS) {

Modified: head/sys/security/mac/mac_framework.h
==============================================================================
--- head/sys/security/mac/mac_framework.h	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac/mac_framework.h	Tue Oct 28 11:33:06 2008	(r184407)
@@ -103,8 +103,11 @@ void	mac_bpfdesc_create_mbuf(struct bpf_
 void	mac_bpfdesc_destroy(struct bpf_d *);
 void	mac_bpfdesc_init(struct bpf_d *);
 
+void	mac_cred_associate_nfsd(struct ucred *cred);
 int	mac_cred_check_visible(struct ucred *cr1, struct ucred *cr2);
 void	mac_cred_copy(struct ucred *cr1, struct ucred *cr2);
+void	mac_cred_create_init(struct ucred *cred);
+void	mac_cred_create_swapper(struct ucred *cred);
 void	mac_cred_destroy(struct ucred *);
 void	mac_cred_init(struct ucred *);
 
@@ -227,7 +230,6 @@ void	mac_posixshm_init(struct shmfd *);
 int	mac_priv_check(struct ucred *cred, int priv);
 int	mac_priv_grant(struct ucred *cred, int priv);
 
-void	mac_proc_associate_nfsd(struct ucred *cred);
 int	mac_proc_check_debug(struct ucred *cred, struct proc *p);
 int	mac_proc_check_sched(struct ucred *cred, struct proc *p);
 int	mac_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai);
@@ -255,8 +257,6 @@ int	mac_proc_check_setuid(struct proc *p
 int	mac_proc_check_signal(struct ucred *cred, struct proc *p,
 	    int signum);
 int	mac_proc_check_wait(struct ucred *cred, struct proc *p);
-void	mac_proc_create_init(struct ucred *cred);
-void	mac_proc_create_swapper(struct ucred *cred);
 void	mac_proc_destroy(struct proc *);
 void	mac_proc_init(struct proc *);
 int	mac_execve_enter(struct image_params *imgp, struct mac *mac_p);

Modified: head/sys/security/mac/mac_policy.h
==============================================================================
--- head/sys/security/mac/mac_policy.h	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac/mac_policy.h	Tue Oct 28 11:33:06 2008	(r184407)
@@ -128,12 +128,15 @@ typedef void	(*mpo_bpfdesc_create_mbuf_t
 typedef void	(*mpo_bpfdesc_destroy_label_t)(struct label *label);
 typedef void	(*mpo_bpfdesc_init_label_t)(struct label *label);
 
+typedef void	(*mpo_cred_associate_nfsd_t)(struct ucred *cred);
 typedef int	(*mpo_cred_check_relabel_t)(struct ucred *cred,
 		    struct label *newlabel);
 typedef int	(*mpo_cred_check_visible_t)(struct ucred *cr1,
 		    struct ucred *cr2);
 typedef void	(*mpo_cred_copy_label_t)(struct label *src,
 		    struct label *dest);
+typedef void	(*mpo_cred_create_init_t)(struct ucred *cred);
+typedef void	(*mpo_cred_create_swapper_t)(struct ucred *cred);
 typedef void	(*mpo_cred_destroy_label_t)(struct label *label);
 typedef int	(*mpo_cred_externalize_label_t)(struct label *label,
 		    char *element_name, struct sbuf *sb, int *claimed);
@@ -345,7 +348,6 @@ typedef void	(*mpo_posixshm_init_label_t
 typedef int	(*mpo_priv_check_t)(struct ucred *cred, int priv);
 typedef int	(*mpo_priv_grant_t)(struct ucred *cred, int priv);
 
-typedef void	(*mpo_proc_associate_nfsd_t)(struct ucred *cred);
 typedef int	(*mpo_proc_check_debug_t)(struct ucred *cred,
 		    struct proc *p);
 typedef int	(*mpo_proc_check_sched_t)(struct ucred *cred,
@@ -373,8 +375,6 @@ typedef int	(*mpo_proc_check_signal_t)(s
 		    struct proc *proc, int signum);
 typedef int	(*mpo_proc_check_wait_t)(struct ucred *cred,
 		    struct proc *proc);
-typedef void	(*mpo_proc_create_init_t)(struct ucred *cred);
-typedef void	(*mpo_proc_create_swapper_t)(struct ucred *cred);
 typedef void	(*mpo_proc_destroy_label_t)(struct label *label);
 typedef void	(*mpo_proc_init_label_t)(struct label *label);
 
@@ -674,9 +674,12 @@ struct mac_policy_ops {
 	mpo_bpfdesc_destroy_label_t		mpo_bpfdesc_destroy_label;
 	mpo_bpfdesc_init_label_t		mpo_bpfdesc_init_label;
 
+	mpo_cred_associate_nfsd_t		mpo_cred_associate_nfsd;
 	mpo_cred_check_relabel_t		mpo_cred_check_relabel;
 	mpo_cred_check_visible_t		mpo_cred_check_visible;
 	mpo_cred_copy_label_t			mpo_cred_copy_label;
+	mpo_cred_create_swapper_t		mpo_cred_create_swapper;
+	mpo_cred_create_init_t			mpo_cred_create_init;
 	mpo_cred_destroy_label_t		mpo_cred_destroy_label;
 	mpo_cred_externalize_label_t		mpo_cred_externalize_label;
 	mpo_cred_init_label_t			mpo_cred_init_label;
@@ -790,7 +793,6 @@ struct mac_policy_ops {
 	mpo_priv_check_t			mpo_priv_check;
 	mpo_priv_grant_t			mpo_priv_grant;
 
-	mpo_proc_associate_nfsd_t		mpo_proc_associate_nfsd;
 	mpo_proc_check_debug_t			mpo_proc_check_debug;
 	mpo_proc_check_sched_t			mpo_proc_check_sched;
 	mpo_proc_check_setaudit_t		mpo_proc_check_setaudit;
@@ -807,8 +809,6 @@ struct mac_policy_ops {
 	mpo_proc_check_setresgid_t		mpo_proc_check_setresgid;
 	mpo_proc_check_signal_t			mpo_proc_check_signal;
 	mpo_proc_check_wait_t			mpo_proc_check_wait;
-	mpo_proc_create_swapper_t		mpo_proc_create_swapper;
-	mpo_proc_create_init_t			mpo_proc_create_init;
 	mpo_proc_destroy_label_t		mpo_proc_destroy_label;
 	mpo_proc_init_label_t			mpo_proc_init_label;
 

Modified: head/sys/security/mac/mac_process.c
==============================================================================
--- head/sys/security/mac/mac_process.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac/mac_process.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2008 Robert N. M. Watson
  * Copyright (c) 2001 Ilmar S. Habibulin
  * Copyright (c) 2001-2003 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Samy Al Bahra
@@ -160,25 +160,20 @@ mac_proc_destroy(struct proc *p)
 	}
 }
 
-int
-mac_cred_externalize_label(struct label *label, char *elements,
-    char *outbuf, size_t outbuflen)
-{
-	int error;
-
-	MAC_EXTERNALIZE(cred, label, elements, outbuf, outbuflen);
-
-	return (error);
-}
-
-int
-mac_cred_internalize_label(struct label *label, char *string)
+/*
+ * When a thread becomes an NFS server daemon, its credential may need to be
+ * updated to reflect this so that policies can recognize when file system
+ * operations originate from the network.
+ *
+ * At some point, it would be desirable if the credential used for each NFS
+ * RPC could be set based on the RPC context (i.e., source system, etc) to
+ * provide more fine-grained access control.
+ */
+void
+mac_cred_associate_nfsd(struct ucred *cred)
 {
-	int error;
 
-	MAC_INTERNALIZE(cred, label, string);
-
-	return (error);
+	MAC_PERFORM(cred_associate_nfsd, cred);
 }
 
 /*
@@ -186,10 +181,10 @@ mac_cred_internalize_label(struct label 
  * processes and threads are spawned.
  */
 void
-mac_proc_create_swapper(struct ucred *cred)
+mac_cred_create_swapper(struct ucred *cred)
 {
 
-	MAC_PERFORM(proc_create_swapper, cred);
+	MAC_PERFORM(cred_create_swapper, cred);
 }
 
 /*
@@ -197,26 +192,31 @@ mac_proc_create_swapper(struct ucred *cr
  * userland processes and threads are spawned.
  */
 void
-mac_proc_create_init(struct ucred *cred)
+mac_cred_create_init(struct ucred *cred)
 {
 
-	MAC_PERFORM(proc_create_init, cred);
+	MAC_PERFORM(cred_create_init, cred);
 }
 
-/*
- * When a thread becomes an NFS server daemon, its credential may need to be
- * updated to reflect this so that policies can recognize when file system
- * operations originate from the network.
- *
- * At some point, it would be desirable if the credential used for each NFS
- * RPC could be set based on the RPC context (i.e., source system, etc) to
- * provide more fine-grained access control.
- */
-void
-mac_proc_associate_nfsd(struct ucred *cred)
+int
+mac_cred_externalize_label(struct label *label, char *elements,
+    char *outbuf, size_t outbuflen)
 {
+	int error;
 
-	MAC_PERFORM(proc_associate_nfsd, cred);
+	MAC_EXTERNALIZE(cred, label, elements, outbuf, outbuflen);
+
+	return (error);
+}
+
+int
+mac_cred_internalize_label(struct label *label, char *string)
+{
+	int error;
+
+	MAC_INTERNALIZE(cred, label, string);
+
+	return (error);
 }
 
 void

Modified: head/sys/security/mac_biba/mac_biba.c
==============================================================================
--- head/sys/security/mac_biba/mac_biba.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_biba/mac_biba.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -815,6 +815,17 @@ biba_bpfdesc_create_mbuf(struct bpf_d *d
 	biba_copy_effective(source, dest);
 }
 
+static void
+biba_cred_associate_nfsd(struct ucred *cred)
+{
+	struct mac_biba *label;
+
+	label = SLOT(cred->cr_label);
+	biba_set_effective(label, MAC_BIBA_TYPE_LOW, 0, NULL);
+	biba_set_range(label, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
+	    0, NULL);
+}
+
 static int
 biba_cred_check_relabel(struct ucred *cred, struct label *newlabel)
 {
@@ -895,6 +906,30 @@ biba_cred_check_visible(struct ucred *u1
 }
 
 static void
+biba_cred_create_init(struct ucred *cred)
+{
+	struct mac_biba *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	biba_set_effective(dest, MAC_BIBA_TYPE_HIGH, 0, NULL);
+	biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
+	    0, NULL);
+}
+
+static void
+biba_cred_create_swapper(struct ucred *cred)
+{
+	struct mac_biba *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL);
+	biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
+	    0, NULL);
+}
+
+static void
 biba_cred_relabel(struct ucred *cred, struct label *newlabel)
 {
 	struct mac_biba *source, *dest;
@@ -1818,17 +1853,6 @@ biba_priv_check(struct ucred *cred, int 
 	return (0);
 }
 
-static void
-biba_proc_associate_nfsd(struct ucred *cred)
-{
-	struct mac_biba *label;
-
-	label = SLOT(cred->cr_label);
-	biba_set_effective(label, MAC_BIBA_TYPE_LOW, 0, NULL);
-	biba_set_range(label, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
-	    0, NULL);
-}
-
 static int
 biba_proc_check_debug(struct ucred *cred, struct proc *p)
 {
@@ -1904,30 +1928,6 @@ biba_socket_check_deliver(struct socket 
 	return (biba_equal_effective(p, s) ? 0 : EACCES);
 }
 
-static void
-biba_proc_create_init(struct ucred *cred)
-{
-	struct mac_biba *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	biba_set_effective(dest, MAC_BIBA_TYPE_HIGH, 0, NULL);
-	biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
-	    0, NULL);
-}
-
-static void
-biba_proc_create_swapper(struct ucred *cred)
-{
-	struct mac_biba *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL);
-	biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH,
-	    0, NULL);
-}
-
 static int
 biba_socket_check_relabel(struct ucred *cred, struct socket *so,
     struct label *solabel, struct label *newlabel)
@@ -3334,9 +3334,12 @@ static struct mac_policy_ops mac_biba_op
 	.mpo_bpfdesc_destroy_label = biba_destroy_label,
 	.mpo_bpfdesc_init_label = biba_init_label,
 
+	.mpo_cred_associate_nfsd = biba_cred_associate_nfsd,
 	.mpo_cred_check_relabel = biba_cred_check_relabel,
 	.mpo_cred_check_visible = biba_cred_check_visible,
 	.mpo_cred_copy_label = biba_copy_label,
+	.mpo_cred_create_init = biba_cred_create_init,
+	.mpo_cred_create_swapper = biba_cred_create_swapper,
 	.mpo_cred_destroy_label = biba_destroy_label,
 	.mpo_cred_externalize_label = biba_externalize_label,
 	.mpo_cred_init_label = biba_init_label,
@@ -3432,12 +3435,9 @@ static struct mac_policy_ops mac_biba_op
 
 	.mpo_priv_check = biba_priv_check,
 
-	.mpo_proc_associate_nfsd = biba_proc_associate_nfsd,
 	.mpo_proc_check_debug = biba_proc_check_debug,
 	.mpo_proc_check_sched = biba_proc_check_sched,
 	.mpo_proc_check_signal = biba_proc_check_signal,
-	.mpo_proc_create_init = biba_proc_create_init,
-	.mpo_proc_create_swapper = biba_proc_create_swapper,
 
 	.mpo_socket_check_deliver = biba_socket_check_deliver,
 	.mpo_socket_check_relabel = biba_socket_check_relabel,

Modified: head/sys/security/mac_lomac/mac_lomac.c
==============================================================================
--- head/sys/security/mac_lomac/mac_lomac.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_lomac/mac_lomac.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -993,6 +993,29 @@ lomac_cred_check_visible(struct ucred *c
 
 	return (0);
 }
+
+static void
+lomac_cred_create_init(struct ucred *cred)
+{
+	struct mac_lomac *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	lomac_set_single(dest, MAC_LOMAC_TYPE_HIGH, 0);
+	lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0);
+}
+
+static void
+lomac_cred_create_swapper(struct ucred *cred)
+{
+	struct mac_lomac *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0);
+	lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0);
+}
+
 static void
 lomac_cred_relabel(struct ucred *cred, struct label *newlabel)
 {
@@ -1885,28 +1908,6 @@ lomac_proc_check_signal(struct ucred *cr
 }
 
 static void
-lomac_proc_create_init(struct ucred *cred)
-{
-	struct mac_lomac *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	lomac_set_single(dest, MAC_LOMAC_TYPE_HIGH, 0);
-	lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0);
-}
-
-static void
-lomac_proc_create_swapper(struct ucred *cred)
-{
-	struct mac_lomac *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0);
-	lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0);
-}
-
-static void
 lomac_proc_destroy_label(struct label *label)
 {
 
@@ -2894,6 +2895,8 @@ static struct mac_policy_ops lomac_ops =
 	.mpo_cred_check_relabel = lomac_cred_check_relabel,
 	.mpo_cred_check_visible = lomac_cred_check_visible,
 	.mpo_cred_copy_label = lomac_copy_label,
+	.mpo_cred_create_swapper = lomac_cred_create_swapper,
+	.mpo_cred_create_init = lomac_cred_create_init,
 	.mpo_cred_destroy_label = lomac_destroy_label,
 	.mpo_cred_externalize_label = lomac_externalize_label,
 	.mpo_cred_init_label = lomac_init_label,
@@ -2983,8 +2986,6 @@ static struct mac_policy_ops lomac_ops =
 	.mpo_proc_check_debug = lomac_proc_check_debug,
 	.mpo_proc_check_sched = lomac_proc_check_sched,
 	.mpo_proc_check_signal = lomac_proc_check_signal,
-	.mpo_proc_create_swapper = lomac_proc_create_swapper,
-	.mpo_proc_create_init = lomac_proc_create_init,
 	.mpo_proc_destroy_label = lomac_proc_destroy_label,
 	.mpo_proc_init_label = lomac_proc_init_label,
 

Modified: head/sys/security/mac_mls/mac_mls.c
==============================================================================
--- head/sys/security/mac_mls/mac_mls.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_mls/mac_mls.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -776,6 +776,17 @@ mls_bpfdesc_create_mbuf(struct bpf_d *d,
 	mls_copy_effective(source, dest);
 }
 
+static void
+mls_cred_associate_nfsd(struct ucred *cred) 
+{
+	struct mac_mls *label;
+
+	label = SLOT(cred->cr_label);
+	mls_set_effective(label, MAC_MLS_TYPE_LOW, 0, NULL);
+	mls_set_range(label, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
+	    NULL);
+}
+
 static int
 mls_cred_check_relabel(struct ucred *cred, struct label *newlabel)
 {
@@ -855,6 +866,30 @@ mls_cred_check_visible(struct ucred *cr1
 }
 
 static void
+mls_cred_create_init(struct ucred *cred)
+{
+	struct mac_mls *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL);
+	mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
+	    NULL);
+}
+
+static void
+mls_cred_create_swapper(struct ucred *cred)
+{
+	struct mac_mls *dest;
+
+	dest = SLOT(cred->cr_label);
+
+	mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
+	mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
+	    NULL);
+}
+
+static void
 mls_cred_relabel(struct ucred *cred, struct label *newlabel)
 {
 	struct mac_mls *source, *dest;
@@ -1523,17 +1558,6 @@ mls_posixsem_create(struct ucred *cred, 
 	mls_copy_effective(source, dest);
 }
 
-static void
-mls_proc_associate_nfsd(struct ucred *cred) 
-{
-	struct mac_mls *label;
-
-	label = SLOT(cred->cr_label);
-	mls_set_effective(label, MAC_MLS_TYPE_LOW, 0, NULL);
-	mls_set_range(label, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
-	    NULL);
-}
-
 static int
 mls_proc_check_debug(struct ucred *cred, struct proc *p)
 {
@@ -1594,30 +1618,6 @@ mls_proc_check_signal(struct ucred *cred
 	return (0);
 }
 
-static void
-mls_proc_create_init(struct ucred *cred)
-{
-	struct mac_mls *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL);
-	mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
-	    NULL);
-}
-
-static void
-mls_proc_create_swapper(struct ucred *cred)
-{
-	struct mac_mls *dest;
-
-	dest = SLOT(cred->cr_label);
-
-	mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
-	mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0,
-	    NULL);
-}
-
 static int
 mls_socket_check_deliver(struct socket *so, struct label *solabel,
     struct mbuf *m, struct label *mlabel)
@@ -2957,9 +2957,12 @@ static struct mac_policy_ops mls_ops =
 	.mpo_bpfdesc_destroy_label = mls_destroy_label,
 	.mpo_bpfdesc_init_label = mls_init_label,
 
+	.mpo_cred_associate_nfsd = mls_cred_associate_nfsd,
 	.mpo_cred_check_relabel = mls_cred_check_relabel,
 	.mpo_cred_check_visible = mls_cred_check_visible,
 	.mpo_cred_copy_label = mls_copy_label,
+	.mpo_cred_create_init = mls_cred_create_init,
+	.mpo_cred_create_swapper = mls_cred_create_swapper,
 	.mpo_cred_destroy_label = mls_destroy_label,
 	.mpo_cred_externalize_label = mls_externalize_label,
 	.mpo_cred_init_label = mls_init_label,
@@ -3051,12 +3054,9 @@ static struct mac_policy_ops mls_ops =
 	.mpo_posixsem_destroy_label = mls_destroy_label,
 	.mpo_posixsem_init_label = mls_init_label,
 
-	.mpo_proc_associate_nfsd = mls_proc_associate_nfsd,
 	.mpo_proc_check_debug = mls_proc_check_debug,
 	.mpo_proc_check_sched = mls_proc_check_sched,
 	.mpo_proc_check_signal = mls_proc_check_signal,
-	.mpo_proc_create_init = mls_proc_create_init,
-	.mpo_proc_create_swapper = mls_proc_create_swapper,
 
 	.mpo_socket_check_deliver = mls_socket_check_deliver,
 	.mpo_socket_check_relabel = mls_socket_check_relabel,

Modified: head/sys/security/mac_partition/mac_partition.c
==============================================================================
--- head/sys/security/mac_partition/mac_partition.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_partition/mac_partition.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson
  * Copyright (c) 2001-2002 Networks Associates Technology, Inc.
  * Copyright (c) 2006 SPARTA, Inc.
  * Copyright (c) 2008 Apple Inc.
@@ -155,6 +155,20 @@ partition_cred_copy_label(struct label *
 }
 
 static void
+partition_cred_create_init(struct ucred *cred)
+{
+
+	SLOT_SET(cred->cr_label, 0);
+}
+
+static void
+partition_cred_create_swapper(struct ucred *cred)
+{
+
+	SLOT_SET(cred->cr_label, 0);
+}
+
+static void
 partition_cred_destroy_label(struct label *label)
 {
 
@@ -251,20 +265,6 @@ partition_proc_check_signal(struct ucred
 	return (error ? ESRCH : 0);
 }
 
-static void
-partition_proc_create_init(struct ucred *cred)
-{
-
-	SLOT_SET(cred->cr_label, 0);
-}
-
-static void
-partition_proc_create_swapper(struct ucred *cred)
-{
-
-	SLOT_SET(cred->cr_label, 0);
-}
-
 static int
 partition_socket_check_visible(struct ucred *cred, struct socket *so,
     struct label *solabel)
@@ -300,6 +300,8 @@ static struct mac_policy_ops partition_o
 	.mpo_cred_check_relabel = partition_cred_check_relabel,
 	.mpo_cred_check_visible = partition_cred_check_visible,
 	.mpo_cred_copy_label = partition_cred_copy_label,
+	.mpo_cred_create_init = partition_cred_create_init,
+	.mpo_cred_create_swapper = partition_cred_create_swapper,
 	.mpo_cred_destroy_label = partition_cred_destroy_label,
 	.mpo_cred_externalize_label = partition_cred_externalize_label,
 	.mpo_cred_init_label = partition_cred_init_label,
@@ -309,8 +311,6 @@ static struct mac_policy_ops partition_o
 	.mpo_proc_check_debug = partition_proc_check_debug,
 	.mpo_proc_check_sched = partition_proc_check_sched,
 	.mpo_proc_check_signal = partition_proc_check_signal,
-	.mpo_proc_create_init = partition_proc_create_init,
-	.mpo_proc_create_swapper = partition_proc_create_swapper,
 	.mpo_socket_check_visible = partition_socket_check_visible,
 	.mpo_vnode_check_exec = partition_vnode_check_exec,
 };

Modified: head/sys/security/mac_stub/mac_stub.c
==============================================================================
--- head/sys/security/mac_stub/mac_stub.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_stub/mac_stub.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -185,6 +185,12 @@ stub_bpfdesc_create_mbuf(struct bpf_d *d
 
 }
 
+static void
+stub_cred_associate_nfsd(struct ucred *cred)
+{
+
+}
+
 static int
 stub_cred_check_relabel(struct ucred *cred, struct label *newlabel)
 {
@@ -200,6 +206,18 @@ stub_cred_check_visible(struct ucred *cr
 }
 
 static void
+stub_cred_create_init(struct ucred *cred)
+{
+
+}
+
+static void
+stub_cred_create_swapper(struct ucred *cred)
+{
+
+}
+
+static void
 stub_cred_relabel(struct ucred *cred, struct label *newlabel)
 {
 
@@ -668,12 +686,6 @@ stub_priv_grant(struct ucred *cred, int 
 	return (EPERM);
 }
 
-static void
-stub_proc_associate_nfsd(struct ucred *cred)
-{
-
-}
-
 static int
 stub_proc_check_debug(struct ucred *cred, struct proc *p)
 {
@@ -789,18 +801,6 @@ stub_proc_check_wait(struct ucred *cred,
 	return (0);
 }
 
-static void
-stub_proc_create_init(struct ucred *cred)
-{
-
-}
-
-static void
-stub_proc_create_swapper(struct ucred *cred)
-{
-
-}
-
 static int
 stub_socket_check_accept(struct ucred *cred, struct socket *so,
     struct label *solabel)
@@ -1539,9 +1539,12 @@ static struct mac_policy_ops stub_ops =
 	.mpo_bpfdesc_destroy_label = stub_destroy_label,
 	.mpo_bpfdesc_init_label = stub_init_label,
 
+	.mpo_cred_associate_nfsd = stub_cred_associate_nfsd,
 	.mpo_cred_check_relabel = stub_cred_check_relabel,
 	.mpo_cred_check_visible = stub_cred_check_visible,
 	.mpo_cred_copy_label = stub_copy_label,
+	.mpo_cred_create_init = stub_cred_create_init,
+	.mpo_cred_create_swapper = stub_cred_create_swapper,
 	.mpo_cred_destroy_label = stub_destroy_label,
 	.mpo_cred_externalize_label = stub_externalize_label,
 	.mpo_cred_init_label = stub_init_label,
@@ -1655,7 +1658,6 @@ static struct mac_policy_ops stub_ops =
 	.mpo_priv_check = stub_priv_check,
 	.mpo_priv_grant = stub_priv_grant,
 
-	.mpo_proc_associate_nfsd = stub_proc_associate_nfsd,
 	.mpo_proc_check_debug = stub_proc_check_debug,
 	.mpo_proc_check_sched = stub_proc_check_sched,
 	.mpo_proc_check_setaudit = stub_proc_check_setaudit,
@@ -1672,8 +1674,6 @@ static struct mac_policy_ops stub_ops =
 	.mpo_proc_check_setuid = stub_proc_check_setuid,
 	.mpo_proc_check_signal = stub_proc_check_signal,
 	.mpo_proc_check_wait = stub_proc_check_wait,
-	.mpo_proc_create_init = stub_proc_create_init,
-	.mpo_proc_create_swapper = stub_proc_create_swapper,
 
 	.mpo_socket_check_accept = stub_socket_check_accept,
 	.mpo_socket_check_bind = stub_socket_check_bind,

Modified: head/sys/security/mac_test/mac_test.c
==============================================================================
--- head/sys/security/mac_test/mac_test.c	Tue Oct 28 10:37:40 2008	(r184406)
+++ head/sys/security/mac_test/mac_test.c	Tue Oct 28 11:33:06 2008	(r184407)
@@ -242,6 +242,24 @@ test_cred_copy_label(struct label *src, 
 	COUNTER_INC(cred_copy_label);
 }
 
+COUNTER_DECL(cred_create_init);
+static void
+test_cred_create_init(struct ucred *cred)
+{
+
+	LABEL_CHECK(cred->cr_label, MAGIC_CRED);
+	COUNTER_INC(cred_create_init);
+}
+
+COUNTER_DECL(cred_create_swapper);
+static void
+test_cred_create_swapper(struct ucred *cred)
+{
+
+	LABEL_CHECK(cred->cr_label, MAGIC_CRED);
+	COUNTER_INC(cred_create_swapper);
+}
+
 COUNTER_DECL(cred_destroy_label);
 static void
 test_cred_destroy_label(struct label *label)
@@ -1480,24 +1498,6 @@ test_proc_check_wait(struct ucred *cred,
 	return (0);
 }
 
-COUNTER_DECL(proc_create_init);
-static void
-test_proc_create_init(struct ucred *cred)
-{
-
-	LABEL_CHECK(cred->cr_label, MAGIC_CRED);
-	COUNTER_INC(proc_create_init);
-}
-
-COUNTER_DECL(proc_create_swapper);
-static void
-test_proc_create_swapper(struct ucred *cred)
-{
-
-	LABEL_CHECK(cred->cr_label, MAGIC_CRED);
-	COUNTER_INC(proc_create_swapper);
-}
-
 COUNTER_DECL(proc_destroy_label);
 static void
 test_proc_destroy_label(struct label *label)
@@ -2883,6 +2883,8 @@ static struct mac_policy_ops test_ops =
 	.mpo_cred_check_relabel = test_cred_check_relabel,
 	.mpo_cred_check_visible = test_cred_check_visible,
 	.mpo_cred_copy_label = test_cred_copy_label,
+	.mpo_cred_create_init = test_cred_create_init,
+	.mpo_cred_create_swapper = test_cred_create_swapper,
 	.mpo_cred_destroy_label = test_cred_destroy_label,
 	.mpo_cred_externalize_label = test_cred_externalize_label,
 	.mpo_cred_init_label = test_cred_init_label,
@@ -3022,8 +3024,6 @@ static struct mac_policy_ops test_ops =
 	.mpo_proc_check_setuid = test_proc_check_setuid,
 	.mpo_proc_check_signal = test_proc_check_signal,
 	.mpo_proc_check_wait = test_proc_check_wait,
-	.mpo_proc_create_init = test_proc_create_init,
-	.mpo_proc_create_swapper = test_proc_create_swapper,
 	.mpo_proc_destroy_label = test_proc_destroy_label,
 	.mpo_proc_init_label = test_proc_init_label,
 

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 12:00:29 2008
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 34B6A10656CC;
	Tue, 28 Oct 2008 12:00:29 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 24E188FC23;
	Tue, 28 Oct 2008 12:00:29 +0000 (UTC) (envelope-from kib@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 m9SC0THt093349;
	Tue, 28 Oct 2008 12:00:29 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SC0TPn093348;
	Tue, 28 Oct 2008 12:00:29 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810281200.m9SC0TPn093348@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 28 Oct 2008 12:00:29 +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: r184408 - head/sys/ufs/ufs
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, 28 Oct 2008 12:00:29 -0000

Author: kib
Date: Tue Oct 28 12:00:28 2008
New Revision: 184408
URL: http://svn.freebsd.org/changeset/base/184408

Log:
  Provide an explanation for getinoquota() call in the ufs_access vop.
  
  MFC after:	3 days

Modified:
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- head/sys/ufs/ufs/ufs_vnops.c	Tue Oct 28 11:33:06 2008	(r184407)
+++ head/sys/ufs/ufs/ufs_vnops.c	Tue Oct 28 12:00:28 2008	(r184408)
@@ -330,7 +330,18 @@ ufs_access(ap)
 			if (vp->v_mount->mnt_flag & MNT_RDONLY)
 				return (EROFS);
 #ifdef QUOTA
+			/*
+			 * Inode is accounted in the quotas only if struct
+			 * dquot is attached to it. VOP_ACCESS() is called
+			 * from vn_open_cred() and provides a convenient
+			 * point to call getinoquota().
+			 */
 			if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) {
+
+				/*
+				 * Upgrade vnode lock, since getinoquota()
+				 * requires exclusive lock to modify inode.
+				 */
 				relocked = 1;
 				vhold(vp);
 				vn_lock(vp, LK_UPGRADE | LK_RETRY);

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 12:08:36 2008
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 EEF801065671;
	Tue, 28 Oct 2008 12:08:36 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DEEFC8FC0A;
	Tue, 28 Oct 2008 12:08:36 +0000 (UTC) (envelope-from kib@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 m9SC8aRQ093518;
	Tue, 28 Oct 2008 12:08:36 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SC8aOA093517;
	Tue, 28 Oct 2008 12:08:36 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810281208.m9SC8aOA093517@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 28 Oct 2008 12:08:36 +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: r184409 - head/sys/kern
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, 28 Oct 2008 12:08:37 -0000

Author: kib
Date: Tue Oct 28 12:08:36 2008
New Revision: 184409
URL: http://svn.freebsd.org/changeset/base/184409

Log:
  Protect check for v_pollinfo == NULL and assignment of the newly allocated
  vpollinfo with vnode interlock. Fully initialize vpollinfo before putting
  pointer to it into vp->v_pollinfo.
  
  Discussed with:	dwhite
  Tested by:	pho
  MFC after:	1 week

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Tue Oct 28 12:00:28 2008	(r184408)
+++ head/sys/kern/vfs_subr.c	Tue Oct 28 12:08:36 2008	(r184409)
@@ -113,7 +113,7 @@ static void	vgonel(struct vnode *);
 static void	vfs_knllock(void *arg);
 static void	vfs_knlunlock(void *arg);
 static int	vfs_knllocked(void *arg);
-
+static void	destroy_vpollinfo(struct vpollinfo *vi);
 
 /*
  * Enable Giant pushdown based on whether or not the vm is mpsafe in this
@@ -819,11 +819,8 @@ vdestroy(struct vnode *vp)
 #ifdef MAC
 	mac_vnode_destroy(vp);
 #endif
-	if (vp->v_pollinfo != NULL) {
-		knlist_destroy(&vp->v_pollinfo->vpi_selinfo.si_note);
-		mtx_destroy(&vp->v_pollinfo->vpi_lock);
-		uma_zfree(vnodepoll_zone, vp->v_pollinfo);
-	}
+	if (vp->v_pollinfo != NULL)
+		destroy_vpollinfo(vp->v_pollinfo);
 #ifdef INVARIANTS
 	/* XXX Elsewhere we can detect an already freed vnode via NULL v_op. */
 	vp->v_op = NULL;
@@ -3197,6 +3194,14 @@ vbusy(struct vnode *vp)
 	mtx_unlock(&vnode_free_list_mtx);
 }
 
+static void
+destroy_vpollinfo(struct vpollinfo *vi)
+{
+	knlist_destroy(&vi->vpi_selinfo.si_note);
+	mtx_destroy(&vi->vpi_lock);
+	uma_zfree(vnodepoll_zone, vi);
+}
+
 /*
  * Initalize per-vnode helper structure to hold poll-related state.
  */
@@ -3205,15 +3210,20 @@ v_addpollinfo(struct vnode *vp)
 {
 	struct vpollinfo *vi;
 
+	if (vp->v_pollinfo != NULL)
+		return;
 	vi = uma_zalloc(vnodepoll_zone, M_WAITOK);
+	mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF);
+	knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock,
+	    vfs_knlunlock, vfs_knllocked);
+	VI_LOCK(vp);
 	if (vp->v_pollinfo != NULL) {
-		uma_zfree(vnodepoll_zone, vi);
+		VI_UNLOCK(vp);
+		destroy_vpollinfo(vi);
 		return;
 	}
 	vp->v_pollinfo = vi;
-	mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", NULL, MTX_DEF);
-	knlist_init(&vp->v_pollinfo->vpi_selinfo.si_note, vp, vfs_knllock,
-	    vfs_knlunlock, vfs_knllocked);
+	VI_UNLOCK(vp);
 }
 
 /*
@@ -3228,8 +3238,7 @@ int
 vn_pollrecord(struct vnode *vp, struct thread *td, int events)
 {
 
-	if (vp->v_pollinfo == NULL)
-		v_addpollinfo(vp);
+	v_addpollinfo(vp);
 	mtx_lock(&vp->v_pollinfo->vpi_lock);
 	if (vp->v_pollinfo->vpi_revents & events) {
 		/*
@@ -4065,8 +4074,7 @@ vfs_kqfilter(struct vop_kqfilter_args *a
 
 	kn->kn_hook = (caddr_t)vp;
 
-	if (vp->v_pollinfo == NULL)
-		v_addpollinfo(vp);
+	v_addpollinfo(vp);
 	if (vp->v_pollinfo == NULL)
 		return (ENOMEM);
 	knl = &vp->v_pollinfo->vpi_selinfo.si_note;

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 12:15:11 2008
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 6CF241065679;
	Tue, 28 Oct 2008 12:15:11 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5CB298FC1E;
	Tue, 28 Oct 2008 12:15:11 +0000 (UTC) (envelope-from kib@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 m9SCFBX7093686;
	Tue, 28 Oct 2008 12:15:11 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SCFBOr093685;
	Tue, 28 Oct 2008 12:15:11 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810281215.m9SCFBOr093685@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 28 Oct 2008 12:15:11 +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: r184410 - head/sys/gnu/fs/ext2fs
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, 28 Oct 2008 12:15:11 -0000

Author: kib
Date: Tue Oct 28 12:15:11 2008
New Revision: 184410
URL: http://svn.freebsd.org/changeset/base/184410

Log:
  Garbage-collect ext2_kqfilter vop that is now a copy of vop_stdkqfilter().

Modified:
  head/sys/gnu/fs/ext2fs/ext2_vnops.c

Modified: head/sys/gnu/fs/ext2fs/ext2_vnops.c
==============================================================================
--- head/sys/gnu/fs/ext2fs/ext2_vnops.c	Tue Oct 28 12:08:36 2008	(r184409)
+++ head/sys/gnu/fs/ext2fs/ext2_vnops.c	Tue Oct 28 12:15:11 2008	(r184410)
@@ -90,7 +90,6 @@ static vop_close_t	ext2_close;
 static vop_create_t	ext2_create;
 static vop_fsync_t	ext2_fsync;
 static vop_getattr_t	ext2_getattr;
-static vop_kqfilter_t	ext2_kqfilter;
 static vop_link_t	ext2_link;
 static vop_mkdir_t	ext2_mkdir;
 static vop_mknod_t	ext2_mknod;
@@ -109,10 +108,6 @@ static vop_write_t	ext2_write;
 static vop_vptofh_t	ext2_vptofh;
 static vop_close_t	ext2fifo_close;
 static vop_kqfilter_t	ext2fifo_kqfilter;
-static int filt_ext2read(struct knote *kn, long hint);
-static int filt_ext2write(struct knote *kn, long hint);
-static int filt_ext2vnode(struct knote *kn, long hint);
-static void filt_ext2detach(struct knote *kn);
 
 /* Global vfs data structures for ext2. */
 struct vop_vector ext2_vnodeops = {
@@ -132,7 +127,6 @@ struct vop_vector ext2_vnodeops = {
 	.vop_open =		ext2_open,
 	.vop_pathconf =		ext2_pathconf,
 	.vop_poll =		vop_stdpoll,
-	.vop_kqfilter =		ext2_kqfilter,
 	.vop_print =		ext2_print,
 	.vop_read =		ext2_read,
 	.vop_readdir =		ext2_readdir,
@@ -1475,7 +1469,7 @@ ext2fifo_kqfilter(ap)
 
 	error = fifo_specops.vop_kqfilter(ap);
 	if (error)
-		error = ext2_kqfilter(ap);
+		error = vfs_kqfilter(ap);
 	return (error);
 }
 
@@ -1650,103 +1644,3 @@ bad:
 	vput(tvp);
 	return (error);
 }
-
-static struct filterops ext2read_filtops = 
-	{ 1, NULL, filt_ext2detach, filt_ext2read };
-static struct filterops ext2write_filtops = 
-	{ 1, NULL, filt_ext2detach, filt_ext2write };
-static struct filterops ext2vnode_filtops = 
-	{ 1, NULL, filt_ext2detach, filt_ext2vnode };
-
-static int
-ext2_kqfilter(ap)
-	struct vop_kqfilter_args /* {
-		struct vnode *a_vp;
-		struct knote *a_kn;
-	} */ *ap;
-{
-	struct vnode *vp = ap->a_vp;
-	struct knote *kn = ap->a_kn;
-
-	switch (kn->kn_filter) {
-	case EVFILT_READ:
-		kn->kn_fop = &ext2read_filtops;
-		break;
-	case EVFILT_WRITE:
-		kn->kn_fop = &ext2write_filtops;
-		break;
-	case EVFILT_VNODE:
-		kn->kn_fop = &ext2vnode_filtops;
-		break;
-	default:
-		return (1);
-	}
-
-	kn->kn_hook = (caddr_t)vp;
-
-	if (vp->v_pollinfo == NULL)
-		v_addpollinfo(vp);
-	if (vp->v_pollinfo == NULL)
-		return ENOMEM;
-	knlist_add(&vp->v_pollinfo->vpi_selinfo.si_note, kn, 0);
-
-	return (0);
-}
-
-static void
-filt_ext2detach(struct knote *kn)
-{
-	struct vnode *vp = (struct vnode *)kn->kn_hook;
-
-	KASSERT(vp->v_pollinfo != NULL, ("Mising v_pollinfo"));
-	knlist_remove(&vp->v_pollinfo->vpi_selinfo.si_note, kn, 0);
-}
-
-/*ARGSUSED*/
-static int
-filt_ext2read(struct knote *kn, long hint)
-{
-	struct vnode *vp = (struct vnode *)kn->kn_hook;
-	struct inode *ip = VTOI(vp);
-
-	/*
-	 * filesystem is gone, so set the EOF flag and schedule 
-	 * the knote for deletion.
-	 */
-	if (hint == NOTE_REVOKE) {
-		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
-		return (1);
-	}
-
-        kn->kn_data = ip->i_size - kn->kn_fp->f_offset;
-        return (kn->kn_data != 0);
-}
-
-/*ARGSUSED*/
-static int
-filt_ext2write(struct knote *kn, long hint)
-{
-
-	/*
-	 * filesystem is gone, so set the EOF flag and schedule 
-	 * the knote for deletion.
-	 */
-	if (hint == NOTE_REVOKE)
-		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
-
-        kn->kn_data = 0;
-        return (1);
-}
-
-static int
-filt_ext2vnode(struct knote *kn, long hint)
-{
-
-	if (kn->kn_sfflags & hint)
-		kn->kn_fflags |= hint;
-	if (hint == NOTE_REVOKE) {
-		kn->kn_flags |= EV_EOF;
-		return (1);
-	}
-	return (kn->kn_fflags != 0);
-}

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 12:22:34 2008
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 43B5B1065671;
	Tue, 28 Oct 2008 12:22:34 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 33A828FC2C;
	Tue, 28 Oct 2008 12:22:34 +0000 (UTC) (envelope-from kib@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 m9SCMYgi093840;
	Tue, 28 Oct 2008 12:22:34 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SCMY9x093839;
	Tue, 28 Oct 2008 12:22:34 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810281222.m9SCMY9x093839@svn.freebsd.org>
From: Konstantin Belousov 
Date: Tue, 28 Oct 2008 12:22:34 +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: r184411 - head/sys/kern
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, 28 Oct 2008 12:22:34 -0000

Author: kib
Date: Tue Oct 28 12:22:33 2008
New Revision: 184411
URL: http://svn.freebsd.org/changeset/base/184411

Log:
  Style return statements in vn_pollrecord().

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Tue Oct 28 12:15:11 2008	(r184410)
+++ head/sys/kern/vfs_subr.c	Tue Oct 28 12:22:33 2008	(r184411)
@@ -3252,12 +3252,12 @@ vn_pollrecord(struct vnode *vp, struct t
 		vp->v_pollinfo->vpi_revents &= ~events;
 
 		mtx_unlock(&vp->v_pollinfo->vpi_lock);
-		return events;
+		return (events);
 	}
 	vp->v_pollinfo->vpi_events |= events;
 	selrecord(td, &vp->v_pollinfo->vpi_selinfo);
 	mtx_unlock(&vp->v_pollinfo->vpi_lock);
-	return 0;
+	return (0);
 }
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 12:49:07 2008
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 E310A106566B;
	Tue, 28 Oct 2008 12:49:07 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D2C958FC17;
	Tue, 28 Oct 2008 12:49:07 +0000 (UTC)
	(envelope-from rwatson@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 m9SCn7H9094377;
	Tue, 28 Oct 2008 12:49:07 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SCn7Q9094373;
	Tue, 28 Oct 2008 12:49:07 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810281249.m9SCn7Q9094373@svn.freebsd.org>
From: Robert Watson 
Date: Tue, 28 Oct 2008 12:49:07 +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: r184412 - in head/sys/security: mac mac_lomac
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, 28 Oct 2008 12:49:08 -0000

Author: rwatson
Date: Tue Oct 28 12:49:07 2008
New Revision: 184412
URL: http://svn.freebsd.org/changeset/base/184412

Log:
  Rename mac_cred_mmapped_drop_perms(), which revokes access to virtual
  memory mappings when the MAC label on a process changes, to
  mac_proc_vm_revoke(),
  
  It now also acquires its own credential reference directly from the
  affected process rather than accepting one passed by the the caller,
  simplifying the API and consumer code.
  
  Obtained from:	TrustedBSD Project

Modified:
  head/sys/security/mac/mac_framework.h
  head/sys/security/mac/mac_process.c
  head/sys/security/mac/mac_syscalls.c
  head/sys/security/mac_lomac/mac_lomac.c

Modified: head/sys/security/mac/mac_framework.h
==============================================================================
--- head/sys/security/mac/mac_framework.h	Tue Oct 28 12:22:33 2008	(r184411)
+++ head/sys/security/mac/mac_framework.h	Tue Oct 28 12:49:07 2008	(r184412)
@@ -259,6 +259,7 @@ int	mac_proc_check_signal(struct ucred *
 int	mac_proc_check_wait(struct ucred *cred, struct proc *p);
 void	mac_proc_destroy(struct proc *);
 void	mac_proc_init(struct proc *);
+void	mac_proc_vm_revoke(struct thread *td);
 int	mac_execve_enter(struct image_params *imgp, struct mac *mac_p);
 void	mac_execve_exit(struct image_params *imgp);
 void	mac_execve_interpreter_enter(struct vnode *interpvp,
@@ -434,8 +435,6 @@ int	mac_vnode_execve_will_transition(str
 void	mac_vnode_relabel(struct ucred *cred, struct vnode *vp,
 	    struct label *newlabel);
 
-void	mac_cred_mmapped_drop_perms(struct thread *td, struct ucred *cred);
-
 /*
  * Calls to help various file systems implement labeling functionality using
  * their existing EA implementation.

Modified: head/sys/security/mac/mac_process.c
==============================================================================
--- head/sys/security/mac/mac_process.c	Tue Oct 28 12:22:33 2008	(r184411)
+++ head/sys/security/mac/mac_process.c	Tue Oct 28 12:49:07 2008	(r184412)
@@ -81,7 +81,7 @@ SYSCTL_INT(_security_mac, OID_AUTO, mmap
     &mac_mmap_revocation_via_cow, 0, "Revoke mmap access to files via "
     "copy-on-write semantics, or by removing all write access");
 
-static void	mac_cred_mmapped_drop_perms_recurse(struct thread *td,
+static void	mac_proc_vm_revoke_recurse(struct thread *td,
 		    struct ucred *cred, struct vm_map *map);
 
 struct label *
@@ -314,13 +314,20 @@ mac_execve_interpreter_exit(struct label
  * The process lock is not held here.
  */
 void
-mac_cred_mmapped_drop_perms(struct thread *td, struct ucred *cred)
+mac_proc_vm_revoke(struct thread *td)
 {
+	struct ucred *cred;
+
+	PROC_LOCK(td->td_proc);
+	cred = crhold(td->td_proc->p_ucred);
+	PROC_UNLOCK(td->td_proc);
 
 	/* XXX freeze all other threads */
-	mac_cred_mmapped_drop_perms_recurse(td, cred,
+	mac_proc_vm_revoke_recurse(td, cred,
 	    &td->td_proc->p_vmspace->vm_map);
 	/* XXX allow other threads to continue */
+
+	crfree(cred);
 }
 
 static __inline const char *
@@ -348,7 +355,7 @@ prot2str(vm_prot_t prot)
 }
 
 static void
-mac_cred_mmapped_drop_perms_recurse(struct thread *td, struct ucred *cred,
+mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
     struct vm_map *map)
 {
 	struct vm_map_entry *vme;
@@ -365,7 +372,7 @@ mac_cred_mmapped_drop_perms_recurse(stru
 	vm_map_lock_read(map);
 	for (vme = map->header.next; vme != &map->header; vme = vme->next) {
 		if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) {
-			mac_cred_mmapped_drop_perms_recurse(td, cred,
+			mac_proc_vm_revoke_recurse(td, cred,
 			    vme->object.sub_map);
 			continue;
 		}

Modified: head/sys/security/mac/mac_syscalls.c
==============================================================================
--- head/sys/security/mac/mac_syscalls.c	Tue Oct 28 12:22:33 2008	(r184411)
+++ head/sys/security/mac/mac_syscalls.c	Tue Oct 28 12:49:07 2008	(r184412)
@@ -203,17 +203,9 @@ __mac_set_proc(struct thread *td, struct
 	mac_cred_relabel(newcred, intlabel);
 	p->p_ucred = newcred;
 
-	/*
-	 * Grab additional reference for use while revoking mmaps, prior to
-	 * releasing the proc lock and sharing the cred.
-	 */
-	crhold(newcred);
 	PROC_UNLOCK(p);
-
-	mac_cred_mmapped_drop_perms(td, newcred);
-
-	crfree(newcred);	/* Free revocation reference. */
 	crfree(oldcred);
+	mac_proc_vm_revoke(td);
 
 out:
 	mac_cred_label_free(intlabel);

Modified: head/sys/security/mac_lomac/mac_lomac.c
==============================================================================
--- head/sys/security/mac_lomac/mac_lomac.c	Tue Oct 28 12:22:33 2008	(r184411)
+++ head/sys/security/mac_lomac/mac_lomac.c	Tue Oct 28 12:49:07 2008	(r184412)
@@ -2225,9 +2225,9 @@ lomac_thread_userret(struct thread *td)
 		mtx_unlock(&subj->mtx);
 		newcred = crget();
 		/*
-		 * Prevent a lock order reversal in
-		 * mac_cred_mmapped_drop_perms; ideally, the other user of
-		 * subj->mtx wouldn't be holding Giant.
+		 * Prevent a lock order reversal in mac_proc_vm_revoke;
+		 * ideally, the other user of subj->mtx wouldn't be holding
+		 * Giant.
 		 */
 		mtx_lock(&Giant);
 		PROC_LOCK(p);
@@ -2250,7 +2250,7 @@ lomac_thread_userret(struct thread *td)
 		mtx_unlock(&subj->mtx);
 		PROC_UNLOCK(p);
 		if (dodrop)
-			mac_cred_mmapped_drop_perms(curthread, newcred);
+			mac_proc_vm_revoke(curthread);
 		mtx_unlock(&Giant);
 	} else {
 		mtx_unlock(&subj->mtx);

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 13:44:12 2008
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 E62F41065674;
	Tue, 28 Oct 2008 13:44:12 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D27578FC21;
	Tue, 28 Oct 2008 13:44:12 +0000 (UTC)
	(envelope-from trasz@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 m9SDiCYk095399;
	Tue, 28 Oct 2008 13:44:12 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SDiBX3095365;
	Tue, 28 Oct 2008 13:44:11 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <200810281344.m9SDiBX3095365@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 28 Oct 2008 13:44:11 +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: r184413 - in head: share/man/man9
	sys/cddl/compat/opensolaris/kern sys/cddl/compat/opensolaris/sys
	sys/cddl/contrib/opensolaris/uts/common/fs/zfs
	sys/compat/linux sys/fs/cd9660 sys/fs/c...
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, 28 Oct 2008 13:44:13 -0000

Author: trasz
Date: Tue Oct 28 13:44:11 2008
New Revision: 184413
URL: http://svn.freebsd.org/changeset/base/184413

Log:
  Introduce accmode_t.  This is required for NFSv4 ACLs - it will be neccessary
  to add more V* constants, and the variables changed by this patch were often
  being assigned to mode_t variables, which is 16 bit.
  
  Approved by:	rwatson (mentor)

Modified:
  head/share/man/man9/VOP_ACCESS.9
  head/share/man/man9/vaccess.9
  head/share/man/man9/vaccess_acl_posix1e.9
  head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
  head/sys/cddl/compat/opensolaris/sys/policy.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  head/sys/compat/linux/linux_getcwd.c
  head/sys/fs/cd9660/cd9660_vfsops.c
  head/sys/fs/cd9660/cd9660_vnops.c
  head/sys/fs/coda/coda_vnops.c
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/fs/hpfs/hpfs_vnops.c
  head/sys/fs/msdosfs/msdosfs_vfsops.c
  head/sys/fs/msdosfs/msdosfs_vnops.c
  head/sys/fs/ntfs/ntfs_vnops.c
  head/sys/fs/nullfs/null_vnops.c
  head/sys/fs/nwfs/nwfs_vnops.c
  head/sys/fs/pseudofs/pseudofs_vnops.c
  head/sys/fs/smbfs/smbfs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/fs/udf/udf_vnops.c
  head/sys/fs/unionfs/union_vnops.c
  head/sys/gnu/fs/ext2fs/ext2_vfsops.c
  head/sys/gnu/fs/ext2fs/ext2_vnops.c
  head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c
  head/sys/gnu/fs/reiserfs/reiserfs_vnops.c
  head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c
  head/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c
  head/sys/kern/subr_acl_posix1e.c
  head/sys/kern/uipc_mqueue.c
  head/sys/kern/uipc_shm.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vfs_vnops.c
  head/sys/kern/vnode_if.src
  head/sys/nfs4client/nfs4_vnops.c
  head/sys/nfsclient/nfs_vnops.c
  head/sys/nfsserver/nfs_serv.c
  head/sys/security/mac/mac_framework.h
  head/sys/security/mac/mac_policy.h
  head/sys/security/mac/mac_vfs.c
  head/sys/security/mac_biba/mac_biba.c
  head/sys/security/mac_bsdextended/ugidfw_internal.h
  head/sys/security/mac_bsdextended/ugidfw_vnode.c
  head/sys/security/mac_lomac/mac_lomac.c
  head/sys/security/mac_mls/mac_mls.c
  head/sys/security/mac_stub/mac_stub.c
  head/sys/security/mac_test/mac_test.c
  head/sys/sys/_types.h
  head/sys/sys/extattr.h
  head/sys/sys/types.h
  head/sys/sys/vnode.h
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/share/man/man9/VOP_ACCESS.9
==============================================================================
--- head/share/man/man9/VOP_ACCESS.9	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/share/man/man9/VOP_ACCESS.9	Tue Oct 28 13:44:11 2008	(r184413)
@@ -39,16 +39,16 @@
 .In sys/param.h
 .In sys/vnode.h
 .Ft int
-.Fn VOP_ACCESS "struct vnode *vp" "int mode" "struct ucred *cred" "struct thread *td"
+.Fn VOP_ACCESS "struct vnode *vp" "accmode_t accmode" "struct ucred *cred" "struct thread *td"
 .Sh DESCRIPTION
 This entry point checks the access permissions of the file against the
 given credentials.
 .Pp
 Its arguments are:
-.Bl -tag -width mode
+.Bl -tag -width accmode
 .It Fa vp
 The vnode of the file to check.
-.It Fa mode
+.It Fa accmode
 The type of access required.
 .It Fa cred
 The user credentials to check.
@@ -57,8 +57,8 @@ The thread which is checking.
 .El
 .Pp
 The
-.Fa mode
-is a mask which can contain
+.Fa accmode
+is a mask which can contain flags described in , e.g.
 .Dv VREAD ,
 .Dv VWRITE
 or
@@ -71,7 +71,7 @@ otherwise an appropriate error code is r
 .Sh PSEUDOCODE
 .Bd -literal
 int
-vop_access(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
+vop_access(struct vnode *vp, accmode_t accmode, struct ucred *cred, struct thread *td)
 {
     int error;
 
@@ -80,7 +80,7 @@ vop_access(struct vnode *vp, int mode, s
      * unless the file is a socket, fifo, or a block or
      * character device resident on the filesystem.
      */
-    if (mode & VWRITE) {
+    if (accmode & VWRITE) {
 	switch (vp->v_type) {
 	case VDIR:
 	case VLNK:
@@ -93,7 +93,7 @@ vop_access(struct vnode *vp, int mode, s
     }
 
     /* If immutable bit set, nobody gets to write it. */
-    if ((mode & VWRITE) && vp has immutable bit set)
+    if ((accmode & VWRITE) && vp has immutable bit set)
 	return EPERM;
 
     /* Otherwise, user id 0 always gets access. */
@@ -104,11 +104,11 @@ vop_access(struct vnode *vp, int mode, s
 
     /* Otherwise, check the owner. */
     if (cred->cr_uid == owner of vp) {
-	if (mode & VEXEC)
+	if (accmode & VEXEC)
 	    mask |= S_IXUSR;
-	if (mode & VREAD)
+	if (accmode & VREAD)
 	    mask |= S_IRUSR;
-	if (mode & VWRITE)
+	if (accmode & VWRITE)
 	    mask |= S_IWUSR;
 	return (((mode of vp) & mask) == mask ? 0 : EACCES);
     }
@@ -116,21 +116,21 @@ vop_access(struct vnode *vp, int mode, s
     /* Otherwise, check the groups. */
     for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
 	if (group of vp == *gp) {
-	    if (mode & VEXEC)
+	    if (accmode & VEXEC)
 		mask |= S_IXGRP;
-	    if (mode & VREAD)
+	    if (accmode & VREAD)
 		mask |= S_IRGRP;
-	    if (mode & VWRITE)
+	    if (accmode & VWRITE)
 		mask |= S_IWGRP;
 	    return (((mode of vp) & mask) == mask ? 0 : EACCES);
 	}
 
     /* Otherwise, check everyone else. */
-    if (mode & VEXEC)
+    if (accmode & VEXEC)
 	mask |= S_IXOTH;
-    if (mode & VREAD)
+    if (accmode & VREAD)
 	mask |= S_IROTH;
-    if (mode & VWRITE)
+    if (accmode & VWRITE)
 	mask |= S_IWOTH;
     return (((mode of vp) & mask) == mask ? 0 : EACCES);
 }

Modified: head/share/man/man9/vaccess.9
==============================================================================
--- head/share/man/man9/vaccess.9	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/share/man/man9/vaccess.9	Tue Oct 28 13:44:11 2008	(r184413)
@@ -40,7 +40,7 @@
 .Fa "mode_t file_mode"
 .Fa "uid_t file_uid"
 .Fa "gid_t file_gid"
-.Fa "mode_t acc_mode"
+.Fa "accmode_t accmode"
 .Fa "struct ucred *cred"
 .Fa "int *privused"
 .Fc
@@ -59,7 +59,7 @@ owning UID
 owning GID
 .Fa file_gid ,
 desired access mode
-.Fa acc_mode ,
+.Fa accmode ,
 requesting credential
 .Fa cred ,
 and an optional call-by-reference

Modified: head/share/man/man9/vaccess_acl_posix1e.9
==============================================================================
--- head/share/man/man9/vaccess_acl_posix1e.9	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/share/man/man9/vaccess_acl_posix1e.9	Tue Oct 28 13:44:11 2008	(r184413)
@@ -41,7 +41,7 @@
 .Fa "uid_t file_uid"
 .Fa "gid_t file_gid"
 .Fa "struct acl *acl"
-.Fa "mode_t acc_mode"
+.Fa "accmode_t accmode"
 .Fa "struct ucred *cred"
 .Fa "int *privused"
 .Fc
@@ -59,7 +59,7 @@ owning GID
 access ACL for the file
 .Fa acl ,
 desired access mode
-.Fa acc_mode ,
+.Fa accmode ,
 requesting credential
 .Fa cred ,
 and an optional call-by-reference

Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
==============================================================================
--- head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -91,17 +91,17 @@ secpolicy_vnode_remove(struct ucred *cre
 
 int
 secpolicy_vnode_access(struct ucred *cred, struct vnode *vp, uint64_t owner,
-    int mode)
+    accmode_t accmode)
 {
 
-	if ((mode & VREAD) && priv_check_cred(cred, PRIV_VFS_READ, 0) != 0) {
+	if ((accmode & VREAD) && priv_check_cred(cred, PRIV_VFS_READ, 0) != 0) {
 		return (EACCES);
 	}
-	if ((mode & VWRITE) &&
+	if ((accmode & VWRITE) &&
 	    priv_check_cred(cred, PRIV_VFS_WRITE, 0) != 0) {
 		return (EACCES);
 	}
-	if (mode & VEXEC) {
+	if (accmode & VEXEC) {
 		if (vp->v_type == VDIR) {
 			if (priv_check_cred(cred, PRIV_VFS_LOOKUP, 0) != 0) {
 				return (EACCES);

Modified: head/sys/cddl/compat/opensolaris/sys/policy.h
==============================================================================
--- head/sys/cddl/compat/opensolaris/sys/policy.h	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/cddl/compat/opensolaris/sys/policy.h	Tue Oct 28 13:44:11 2008	(r184413)
@@ -46,7 +46,7 @@ int	secpolicy_basic_link(struct ucred  *
 int	secpolicy_vnode_stky_modify(struct ucred *cred);
 int	secpolicy_vnode_remove(struct ucred *cred);
 int	secpolicy_vnode_access(struct ucred *cred, struct vnode *vp,
-	    uint64_t owner, int mode);
+	    uint64_t owner, accmode_t accmode);
 int	secpolicy_vnode_setdac(struct ucred *cred, uid_t owner);
 int	secpolicy_vnode_setattr(struct ucred *cred, struct vnode *vp,
 	    struct vattr *vap, const struct vattr *ovap, int flags,

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -237,14 +237,14 @@ static int
 zfsctl_common_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
-	int mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 
-	if (mode & VWRITE)
+	if (accmode & VWRITE)
 		return (EACCES);
 
 	return (0);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -3194,13 +3194,13 @@ static int
 zfs_freebsd_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 
-	return (zfs_access(ap->a_vp, ap->a_mode, 0, ap->a_cred));
+	return (zfs_access(ap->a_vp, ap->a_accmode, 0, ap->a_cred));
 }
 
 static int

Modified: head/sys/compat/linux/linux_getcwd.c
==============================================================================
--- head/sys/compat/linux/linux_getcwd.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/compat/linux/linux_getcwd.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -307,7 +307,7 @@ linux_getcwd_common (lvp, rvp, bpp, bufp
 	struct vnode *uvp = NULL;
 	char *bp = NULL;
 	int error;
-	int perms = VEXEC;
+	accmode_t accmode = VEXEC;
 
 	if (rvp == NULL) {
 		rvp = fdp->fd_rdir;
@@ -352,10 +352,10 @@ linux_getcwd_common (lvp, rvp, bpp, bufp
 		 * whether or not caller cares.
 		 */
 		if (flags & GETCWD_CHECK_ACCESS) {
-			error = VOP_ACCESS(lvp, perms, td->td_ucred, td);
+			error = VOP_ACCESS(lvp, accmode, td->td_ucred, td);
 			if (error)
 				goto out;
-			perms = VEXEC|VREAD;
+			accmode = VEXEC|VREAD;
 		}
 		
 		/*

Modified: head/sys/fs/cd9660/cd9660_vfsops.c
==============================================================================
--- head/sys/fs/cd9660/cd9660_vfsops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/cd9660/cd9660_vfsops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -128,7 +128,7 @@ cd9660_mount(struct mount *mp, struct th
 	struct vnode *devvp;
 	char *fspec;
 	int error;
-	mode_t accessmode;
+	accmode_t accmode;
 	struct nameidata ndp;
 	struct iso_mnt *imp = 0;
 
@@ -168,9 +168,9 @@ cd9660_mount(struct mount *mp, struct th
 	 * Verify that user has necessary permissions on the device,
 	 * or has superuser abilities
 	 */
-	accessmode = VREAD;
+	accmode = VREAD;
 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
-	error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
+	error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
 	if (error)
 		error = priv_check(td, PRIV_VFS_MOUNT_PERM);
 	if (error) {

Modified: head/sys/fs/cd9660/cd9660_vnops.c
==============================================================================
--- head/sys/fs/cd9660/cd9660_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/cd9660/cd9660_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -125,14 +125,14 @@ static int
 cd9660_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 	struct vnode *vp = ap->a_vp;
 	struct iso_node *ip = VTOI(vp);
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 
 	if (vp->v_type == VCHR || vp->v_type == VBLK)
 		return (EOPNOTSUPP);
@@ -142,7 +142,7 @@ cd9660_access(ap)
 	 * fifo, or a block or character device resident on the
 	 * filesystem.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -155,7 +155,7 @@ cd9660_access(ap)
 	}
 
 	return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid,
-	    ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL));
+	    ip->inode.iso_gid, ap->a_accmode, ap->a_cred, NULL));
 }
 
 static int

Modified: head/sys/fs/coda/coda_vnops.c
==============================================================================
--- head/sys/fs/coda/coda_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/coda/coda_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -607,7 +607,7 @@ coda_access(struct vop_access_args *ap)
 	/* true args */
 	struct vnode *vp = ap->a_vp;
 	struct cnode *cp = VTOC(vp);
-	int mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 	struct ucred *cred = ap->a_cred;
 	struct thread *td = ap->a_td;
 	/* locals */
@@ -624,7 +624,7 @@ coda_access(struct vop_access_args *ap)
 		 * Bogus hack - all will be marked as successes.
 		 */
 		MARK_INT_SAT(CODA_ACCESS_STATS);
-		return (((mode & VREAD) && !(mode & (VWRITE | VEXEC)))
+		return (((accmode & VREAD) && !(accmode & (VWRITE | VEXEC)))
 		    ? 0 : EACCES);
 	}
 
@@ -636,11 +636,11 @@ coda_access(struct vop_access_args *ap)
 	 */
 	if (coda_access_cache && VALID_ACCCACHE(cp) &&
 	    (cred->cr_uid == cp->c_cached_uid) &&
-	    (mode & cp->c_cached_mode) == mode) {
+	    (accmode & cp->c_cached_mode) == accmode) {
 		MARK_INT_SAT(CODA_ACCESS_STATS);
 		return (0);
 	}
-	error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, td->td_proc);
+	error = venus_access(vtomi(vp), &cp->c_fid, accmode, cred, td->td_proc);
 	if (error == 0 && coda_access_cache) {
 		/*-
 		 * When we have a new successful request, we consider three
@@ -658,10 +658,10 @@ coda_access(struct vop_access_args *ap)
 		 */
 		cp->c_flags |= C_ACCCACHE;
 		if (cp->c_cached_uid != cred->cr_uid) {
-			cp->c_cached_mode = mode;
+			cp->c_cached_mode = accmode;
 			cp->c_cached_uid = cred->cr_uid;
 		} else
-			cp->c_cached_mode |= mode;
+			cp->c_cached_mode |= accmode;
 	}
 	return (error);
 }

Modified: head/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- head/sys/fs/devfs/devfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/devfs/devfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -372,7 +372,7 @@ devfs_access(struct vop_access_args *ap)
 		de = de->de_dir;
 
 	error = vaccess(vp->v_type, de->de_mode, de->de_uid, de->de_gid,
-	    ap->a_mode, ap->a_cred, NULL);
+	    ap->a_accmode, ap->a_cred, NULL);
 	if (!error)
 		return (error);
 	if (error != EACCES)

Modified: head/sys/fs/hpfs/hpfs_vnops.c
==============================================================================
--- head/sys/fs/hpfs/hpfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/hpfs/hpfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -683,14 +683,14 @@ int
 hpfs_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 	struct vnode *vp = ap->a_vp;
 	struct hpfsnode *hp = VTOHP(vp);
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 
 	dprintf(("hpfs_access(0x%x):\n", hp->h_no));
 
@@ -699,7 +699,7 @@ hpfs_access(ap)
 	 * unless the file is a socket, fifo, or a block or
 	 * character device resident on the filesystem.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch ((int)vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -711,7 +711,7 @@ hpfs_access(ap)
 	}
 
 	return (vaccess(vp->v_type, hp->h_mode, hp->h_uid, hp->h_gid,
-	    ap->a_mode, ap->a_cred, NULL));
+	    ap->a_accmode, ap->a_cred, NULL));
 }
 
 /*

Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -240,7 +240,7 @@ msdosfs_mount(struct mount *mp, struct t
 	struct msdosfsmount *pmp = NULL;
 	struct nameidata ndp;
 	int error, flags;
-	mode_t accessmode;
+	accmode_t accmode;
 	char *from;
 
 	if (vfs_filteropt(mp->mnt_optnew, msdosfs_opts))
@@ -363,10 +363,10 @@ msdosfs_mount(struct mount *mp, struct t
 	 * If mount by non-root, then verify that user has necessary
 	 * permissions on the device.
 	 */
-	accessmode = VREAD;
+	accmode = VREAD;
 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
-		accessmode |= VWRITE;
-	error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
+		accmode |= VWRITE;
+	error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
 	if (error)
 		error = priv_check(td, PRIV_VFS_MOUNT_PERM);
 	if (error) {

Modified: head/sys/fs/msdosfs/msdosfs_vnops.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/msdosfs/msdosfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -249,7 +249,7 @@ static int
 msdosfs_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
@@ -257,7 +257,8 @@ msdosfs_access(ap)
 	struct vnode *vp = ap->a_vp;
 	struct denode *dep = VTODE(ap->a_vp);
 	struct msdosfsmount *pmp = dep->de_pmp;
-	mode_t file_mode, mode = ap->a_mode;
+	mode_t file_mode;
+	accmode_t accmode = ap->a_accmode;
 
 	file_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) |
 	    ((dep->de_Attributes & ATTR_READONLY) ? 0 : (S_IWUSR|S_IWGRP|S_IWOTH));
@@ -267,7 +268,7 @@ msdosfs_access(ap)
 	 * Disallow writing to directories and regular files if the
 	 * filesystem is read-only.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VREG:
@@ -280,7 +281,7 @@ msdosfs_access(ap)
 	}
 
 	return (vaccess(vp->v_type, file_mode, pmp->pm_uid, pmp->pm_gid,
-	    ap->a_mode, ap->a_cred, NULL));
+	    ap->a_accmode, ap->a_cred, NULL));
 }
 
 static int

Modified: head/sys/fs/ntfs/ntfs_vnops.c
==============================================================================
--- head/sys/fs/ntfs/ntfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/ntfs/ntfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -386,14 +386,14 @@ int
 ntfs_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 	struct vnode *vp = ap->a_vp;
 	struct ntnode *ip = VTONT(vp);
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 #ifdef QUOTA
 	int error;
 #endif
@@ -405,7 +405,7 @@ ntfs_access(ap)
 	 * unless the file is a socket, fifo, or a block or
 	 * character device resident on the filesystem.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch ((int)vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -421,7 +421,7 @@ ntfs_access(ap)
 	}
 
 	return (vaccess(vp->v_type, ip->i_mp->ntm_mode, ip->i_mp->ntm_uid,
-	    ip->i_mp->ntm_gid, ap->a_mode, ap->a_cred, NULL));
+	    ip->i_mp->ntm_gid, ap->a_accmode, ap->a_cred, NULL));
 } 
 
 /*

Modified: head/sys/fs/nullfs/null_vnops.c
==============================================================================
--- head/sys/fs/nullfs/null_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/nullfs/null_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -451,14 +451,14 @@ static int
 null_access(struct vop_access_args *ap)
 {
 	struct vnode *vp = ap->a_vp;
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 
 	/*
 	 * Disallow write attempts on read-only layers;
 	 * unless the file is a socket, fifo, or a block or
 	 * character device resident on the filesystem.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VLNK:

Modified: head/sys/fs/nwfs/nwfs_vnops.c
==============================================================================
--- head/sys/fs/nwfs/nwfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/nwfs/nwfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -121,7 +121,7 @@ static int
 nwfs_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *td;
 	} */ *ap;
@@ -131,7 +131,7 @@ nwfs_access(ap)
 	struct nwmount *nmp = VTONWFS(vp);
 
 	NCPVNDEBUG("\n");
-	if ((ap->a_mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
+	if ((ap->a_accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
 		switch (vp->v_type) {
 		    case VREG: case VDIR: case VLNK:
 			return (EROFS);
@@ -142,7 +142,7 @@ nwfs_access(ap)
 	mpmode = vp->v_type == VREG ? nmp->m.file_mode :
 	    nmp->m.dir_mode;
         return (vaccess(vp->v_type, mpmode, nmp->m.uid,
-            nmp->m.gid, ap->a_mode, ap->a_cred, NULL));
+            nmp->m.gid, ap->a_accmode, ap->a_cred, NULL));
 }
 /*
  * nwfs_open vnode op

Modified: head/sys/fs/pseudofs/pseudofs_vnops.c
==============================================================================
--- head/sys/fs/pseudofs/pseudofs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/pseudofs/pseudofs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -132,7 +132,7 @@ pfs_access(struct vop_access_args *va)
 	if (error)
 		PFS_RETURN (error);
 	error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid,
-	    vattr.va_gid, va->a_mode, va->a_cred, NULL);
+	    vattr.va_gid, va->a_accmode, va->a_cred, NULL);
 	PFS_RETURN (error);
 }
 

Modified: head/sys/fs/smbfs/smbfs_vnops.c
==============================================================================
--- head/sys/fs/smbfs/smbfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/smbfs/smbfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -123,18 +123,18 @@ static int
 smbfs_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 	struct vnode *vp = ap->a_vp;
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 	mode_t mpmode;
 	struct smbmount *smp = VTOSMBFS(vp);
 
 	SMBVDEBUG("\n");
-	if ((mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
+	if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
 		switch (vp->v_type) {
 		    case VREG: case VDIR: case VLNK:
 			return EROFS;
@@ -144,7 +144,7 @@ smbfs_access(ap)
 	}
 	mpmode = vp->v_type == VREG ? smp->sm_file_mode : smp->sm_dir_mode;
 	return (vaccess(vp->v_type, mpmode, smp->sm_uid,
-	    smp->sm_gid, ap->a_mode, ap->a_cred, NULL));
+	    smp->sm_gid, ap->a_accmode, ap->a_cred, NULL));
 }
 
 /* ARGSUSED */

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -282,7 +282,7 @@ int
 tmpfs_access(struct vop_access_args *v)
 {
 	struct vnode *vp = v->a_vp;
-	int mode = v->a_mode;
+	accmode_t accmode = v->a_accmode;
 	struct ucred *cred = v->a_cred;
 
 	int error;
@@ -298,7 +298,7 @@ tmpfs_access(struct vop_access_args *v)
 	case VLNK:
 		/* FALLTHROUGH */
 	case VREG:
-		if (mode & VWRITE && vp->v_mount->mnt_flag & MNT_RDONLY) {
+		if (accmode & VWRITE && vp->v_mount->mnt_flag & MNT_RDONLY) {
 			error = EROFS;
 			goto out;
 		}
@@ -318,13 +318,13 @@ tmpfs_access(struct vop_access_args *v)
 		goto out;
 	}
 
-	if (mode & VWRITE && node->tn_flags & IMMUTABLE) {
+	if (accmode & VWRITE && node->tn_flags & IMMUTABLE) {
 		error = EPERM;
 		goto out;
 	}
 
 	error = vaccess(vp->v_type, node->tn_mode, node->tn_uid,
-	    node->tn_gid, mode, cred, NULL);
+	    node->tn_gid, accmode, cred, NULL);
 
 out:
 	MPASS(VOP_ISLOCKED(vp));

Modified: head/sys/fs/udf/udf_vnops.c
==============================================================================
--- head/sys/fs/udf/udf_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/udf/udf_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -139,13 +139,14 @@ udf_access(struct vop_access_args *a)
 {
 	struct vnode *vp;
 	struct udf_node *node;
-	mode_t a_mode, mode;
+	accmode_t accmode;
+	mode_t mode;
 
 	vp = a->a_vp;
 	node = VTON(vp);
-	a_mode = a->a_mode;
+	accmode = a->a_accmode;
 
-	if (a_mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -160,7 +161,7 @@ udf_access(struct vop_access_args *a)
 	mode = udf_permtomode(node);
 
 	return (vaccess(vp->v_type, mode, node->fentry->uid, node->fentry->gid,
-	    a_mode, a->a_cred, NULL));
+	    accmode, a->a_cred, NULL));
 }
 
 static int

Modified: head/sys/fs/unionfs/union_vnops.c
==============================================================================
--- head/sys/fs/unionfs/union_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/fs/unionfs/union_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -583,7 +583,7 @@ unionfs_close_abort:
  * Check the access mode toward shadow file/dir.
  */
 static int
-unionfs_check_corrected_access(u_short mode,
+unionfs_check_corrected_access(accmode_t accmode,
 			     struct vattr *va,
 			     struct ucred *cred)
 {
@@ -601,11 +601,11 @@ unionfs_check_corrected_access(u_short m
 
 	/* check owner */
 	if (cred->cr_uid == uid) {
-		if (mode & VEXEC)
+		if (accmode & VEXEC)
 			mask |= S_IXUSR;
-		if (mode & VREAD)
+		if (accmode & VREAD)
 			mask |= S_IRUSR;
-		if (mode & VWRITE)
+		if (accmode & VWRITE)
 			mask |= S_IWUSR;
 		return ((vmode & mask) == mask ? 0 : EACCES);
 	}
@@ -615,22 +615,22 @@ unionfs_check_corrected_access(u_short m
 	gp = cred->cr_groups;
 	for (; count < cred->cr_ngroups; count++, gp++) {
 		if (gid == *gp) {
-			if (mode & VEXEC)
+			if (accmode & VEXEC)
 				mask |= S_IXGRP;
-			if (mode & VREAD)
+			if (accmode & VREAD)
 				mask |= S_IRGRP;
-			if (mode & VWRITE)
+			if (accmode & VWRITE)
 				mask |= S_IWGRP;
 			return ((vmode & mask) == mask ? 0 : EACCES);
 		}
 	}
 
 	/* check other */
-	if (mode & VEXEC)
+	if (accmode & VEXEC)
 		mask |= S_IXOTH;
-	if (mode & VREAD)
+	if (accmode & VREAD)
 		mask |= S_IROTH;
-	if (mode & VWRITE)
+	if (accmode & VWRITE)
 		mask |= S_IWOTH;
 
 	return ((vmode & mask) == mask ? 0 : EACCES);
@@ -645,7 +645,7 @@ unionfs_access(struct vop_access_args *a
 	struct vnode   *lvp;
 	struct thread  *td;
 	struct vattr	va;
-	int		mode;
+	accmode_t	accmode;
 	int		error;
 
 	UNIONFS_INTERNAL_DEBUG("unionfs_access: enter\n");
@@ -655,10 +655,10 @@ unionfs_access(struct vop_access_args *a
 	uvp = unp->un_uppervp;
 	lvp = unp->un_lowervp;
 	td = ap->a_td;
-	mode = ap->a_mode;
+	accmode = ap->a_accmode;
 	error = EACCES;
 
-	if ((mode & VWRITE) &&
+	if ((accmode & VWRITE) &&
 	    (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) {
 		switch (ap->a_vp->v_type) {
 		case VREG:
@@ -671,7 +671,7 @@ unionfs_access(struct vop_access_args *a
 	}
 
 	if (uvp != NULLVP) {
-		error = VOP_ACCESS(uvp, mode, ap->a_cred, td);
+		error = VOP_ACCESS(uvp, accmode, ap->a_cred, td);
 
 		UNIONFS_INTERNAL_DEBUG("unionfs_access: leave (%d)\n", error);
 
@@ -679,7 +679,7 @@ unionfs_access(struct vop_access_args *a
 	}
 
 	if (lvp != NULLVP) {
-		if (mode & VWRITE) {
+		if (accmode & VWRITE) {
 			if (ump->um_uppervp->v_mount->mnt_flag & MNT_RDONLY) {
 				switch (ap->a_vp->v_type) {
 				case VREG:
@@ -698,15 +698,15 @@ unionfs_access(struct vop_access_args *a
 						return (error);
 
 					error = unionfs_check_corrected_access(
-					    mode, &va, ap->a_cred);
+					    accmode, &va, ap->a_cred);
 					if (error != 0)
 						return (error);
 				}
 			}
-			mode &= ~VWRITE;
-			mode |= VREAD; /* will copy to upper */
+			accmode &= ~VWRITE;
+			accmode |= VREAD; /* will copy to upper */
 		}
-		error = VOP_ACCESS(lvp, mode, ap->a_cred, td);
+		error = VOP_ACCESS(lvp, accmode, ap->a_cred, td);
 	}
 
 	UNIONFS_INTERNAL_DEBUG("unionfs_access: leave (%d)\n", error);

Modified: head/sys/gnu/fs/ext2fs/ext2_vfsops.c
==============================================================================
--- head/sys/gnu/fs/ext2fs/ext2_vfsops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/ext2fs/ext2_vfsops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -137,7 +137,7 @@ ext2_mount(mp, td)
 	struct ext2_sb_info *fs;
 	char *path, *fspec;
 	int error, flags, len;
-	mode_t accessmode;
+	accmode_t accmode;
 	struct nameidata nd, *ndp = &nd;
 
 	opts = mp->mnt_optnew;
@@ -265,10 +265,10 @@ ext2_mount(mp, td)
 	 *
 	 * XXXRW: VOP_ACCESS() enough?
 	 */
-	accessmode = VREAD;
+	accmode = VREAD;
 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
-		accessmode |= VWRITE;
-	error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
+		accmode |= VWRITE;
+	error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
 	if (error)
 		error = priv_check(td, PRIV_VFS_MOUNT_PERM);
 	if (error) {

Modified: head/sys/gnu/fs/ext2fs/ext2_vnops.c
==============================================================================
--- head/sys/gnu/fs/ext2fs/ext2_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/ext2fs/ext2_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -283,14 +283,14 @@ static int
 ext2_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
 {
 	struct vnode *vp = ap->a_vp;
 	struct inode *ip = VTOI(vp);
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 	int error;
 
 	if (vp->v_type == VBLK || vp->v_type == VCHR)
@@ -301,7 +301,7 @@ ext2_access(ap)
 	 * unless the file is a socket, fifo, or a block or
 	 * character device resident on the file system.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -315,11 +315,11 @@ ext2_access(ap)
 	}
 
 	/* If immutable bit set, nobody gets to write it. */
-	if ((mode & VWRITE) && (ip->i_flags & (IMMUTABLE | SF_SNAPSHOT)))
+	if ((accmode & VWRITE) && (ip->i_flags & (IMMUTABLE | SF_SNAPSHOT)))
 		return (EPERM);
 
 	error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid,
-	    ap->a_mode, ap->a_cred, NULL);
+	    ap->a_accmode, ap->a_cred, NULL);
 	return (error);
 }
 

Modified: head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c
==============================================================================
--- head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -74,7 +74,7 @@ reiserfs_mount(struct mount *mp, struct 
 {
 	size_t size;
 	int error, len;
-	mode_t accessmode;
+	accmode_t accmode;
 	char *path, *fspec;
 	struct vnode *devvp;
 	struct vfsoptlist *opts;
@@ -124,10 +124,10 @@ reiserfs_mount(struct mount *mp, struct 
 
 	/* If mount by non-root, then verify that user has necessary
 	 * permissions on the device. */
-	accessmode = VREAD;
+	accmode = VREAD;
 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
-		accessmode |= VWRITE;
-	error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
+		accmode |= VWRITE;
+	error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
 	if (error)
 		error = priv_check(td, PRIV_VFS_MOUNT_PERM);
 	if (error) {

Modified: head/sys/gnu/fs/reiserfs/reiserfs_vnops.c
==============================================================================
--- head/sys/gnu/fs/reiserfs/reiserfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/reiserfs/reiserfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -57,14 +57,14 @@ reiserfs_access(struct vop_access_args *
 	int error;
 	struct vnode *vp = ap->a_vp;
 	struct reiserfs_node *ip = VTOI(vp);
-	mode_t mode = ap->a_mode;
+	accmode_t accmode = ap->a_accmode;
 
 	/*
 	 * Disallow write attempts on read-only file systems; unless the file
 	 * is a socket, fifo, or a block or character device resident on the
 	 * file system.
 	 */
-	if (mode & VWRITE) {
+	if (accmode & VWRITE) {
 		switch (vp->v_type) {
 		case VDIR:
 		case VLNK:
@@ -81,13 +81,13 @@ reiserfs_access(struct vop_access_args *
 	}
 
 	/* If immutable bit set, nobody gets to write it. */
-	if ((mode & VWRITE) && (ip->i_flags & (IMMUTABLE | SF_SNAPSHOT))) {
+	if ((accmode & VWRITE) && (ip->i_flags & (IMMUTABLE | SF_SNAPSHOT))) {
 		reiserfs_log(LOG_DEBUG, "no write access (immutable)\n");
 		return (EPERM);
 	}
 
 	error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid,
-	    ap->a_mode, ap->a_cred, NULL);
+	    ap->a_accmode, ap->a_cred, NULL);
 	return (error);
 }
 

Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c
==============================================================================
--- head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -133,7 +133,7 @@ xfs_blkdev_get(
 	struct vnode		*devvp;
 	struct g_consumer	*cp;
 	struct g_provider	*pp;
-	mode_t			accessmode;
+	accmode_t		accmode;
 
 	td = curthread;
 
@@ -151,10 +151,10 @@ xfs_blkdev_get(
 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
 
 	ronly = ((XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) != 0);
-	accessmode = VREAD;
+	accmode = VREAD;
 	if (!ronly)
-		accessmode |= VWRITE;
-	error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
+		accmode |= VWRITE;
+	error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
 	if (error)
 		error = priv_check(td, PRIV_VFS_MOUNT_PERM);
 	if (error) {

Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c
==============================================================================
--- head/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -180,14 +180,14 @@ static int
 _xfs_access(
     	struct vop_access_args /* {
 		struct vnode *a_vp;
-		int  a_mode;
+		accmode_t a_accmode;
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap)
 {
 	int error;
 
-	XVOP_ACCESS(VPTOXFSVP(ap->a_vp), ap->a_mode, ap->a_cred, error);
+	XVOP_ACCESS(VPTOXFSVP(ap->a_vp), ap->a_accmode, ap->a_cred, error);
 	return (error);
 }
 

Modified: head/sys/kern/subr_acl_posix1e.c
==============================================================================
--- head/sys/kern/subr_acl_posix1e.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/kern/subr_acl_posix1e.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -53,12 +53,12 @@ __FBSDID("$FreeBSD$");
  */
 int
 vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
-    struct acl *acl, mode_t acc_mode, struct ucred *cred, int *privused)
+    struct acl *acl, accmode_t acc_mode, struct ucred *cred, int *privused)
 {
 	struct acl_entry *acl_other, *acl_mask;
-	mode_t dac_granted;
-	mode_t priv_granted;
-	mode_t acl_mask_granted;
+	accmode_t dac_granted;
+	accmode_t priv_granted;
+	accmode_t acl_mask_granted;
 	int group_matched, i;
 
 	/*

Modified: head/sys/kern/uipc_mqueue.c
==============================================================================
--- head/sys/kern/uipc_mqueue.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/kern/uipc_mqueue.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -1120,7 +1120,7 @@ mqfs_close(struct vop_close_args *ap)
 struct vop_access_args {
 	struct vop_generic_args a_gen;
 	struct vnode *a_vp;
-	int a_mode;
+	accmode_t a_accmode;
 	struct ucred *a_cred;
 	struct thread *a_td;
 };
@@ -1140,7 +1140,7 @@ mqfs_access(struct vop_access_args *ap)
 	if (error)
 		return (error);
 	error = vaccess(vp->v_type, vattr.va_mode, vattr.va_uid,
-	    vattr.va_gid, ap->a_mode, ap->a_cred, NULL);
+	    vattr.va_gid, ap->a_accmode, ap->a_cred, NULL);
 	return (error);
 }
 
@@ -2003,14 +2003,14 @@ kmq_open(struct thread *td, struct kmq_o
 		if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) {
 			error = EEXIST;
 		} else {
-			int acc_mode = 0;
+			accmode_t accmode = 0;
 
 			if (flags & FREAD)
-				acc_mode |= VREAD;
+				accmode |= VREAD;
 			if (flags & FWRITE)
-				acc_mode |= VWRITE;
+				accmode |= VWRITE;
 			error = vaccess(VREG, pn->mn_mode, pn->mn_uid,
-				    pn->mn_gid, acc_mode, td->td_ucred, NULL);
+				    pn->mn_gid, accmode, td->td_ucred, NULL);
 		}
 	}
 

Modified: head/sys/kern/uipc_shm.c
==============================================================================
--- head/sys/kern/uipc_shm.c	Tue Oct 28 12:49:07 2008	(r184412)
+++ head/sys/kern/uipc_shm.c	Tue Oct 28 13:44:11 2008	(r184413)
@@ -367,15 +367,15 @@ shm_drop(struct shmfd *shmfd)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 14:14:57 2008
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 799C11065672;
	Tue, 28 Oct 2008 14:14:57 +0000 (UTC)
	(envelope-from oleg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6A9B48FC08;
	Tue, 28 Oct 2008 14:14:57 +0000 (UTC)
	(envelope-from oleg@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 m9SEEvKI096009;
	Tue, 28 Oct 2008 14:14:57 GMT (envelope-from oleg@svn.freebsd.org)
Received: (from oleg@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SEEvZE096007;
	Tue, 28 Oct 2008 14:14:57 GMT (envelope-from oleg@svn.freebsd.org)
Message-Id: <200810281414.m9SEEvZE096007@svn.freebsd.org>
From: Oleg Bulyzhin 
Date: Tue, 28 Oct 2008 14:14:57 +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: r184414 - in head: . sys/netinet
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, 28 Oct 2008 14:14:57 -0000

Author: oleg
Date: Tue Oct 28 14:14:57 2008
New Revision: 184414
URL: http://svn.freebsd.org/changeset/base/184414

Log:
  Type of q_time (start of queue idle time) has changed: uint32_t -> uint64_t.
  This should fix q_time overflow, which happens after 2^32/(86400*hz) days of
  uptime (~50days for hz = 1000).
  q_time overflow cause following:
  - traffic shaping may not work in 'fast' mode (not enabled by default).
  - incorrect average queue length calculation in RED/GRED algorithm.
  
  NB: due to ABI change this change is not applicable to stable.
  
  PR:		kern/128401

Modified:
  head/UPDATING
  head/sys/netinet/ip_dummynet.h

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Tue Oct 28 13:44:11 2008	(r184413)
+++ head/UPDATING	Tue Oct 28 14:14:57 2008	(r184414)
@@ -22,6 +22,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
 	to maximize performance.  (To disable malloc debugging, run
 	ln -s aj /etc/malloc.conf.)
 
+20081028:
+	dummynet(4) ABI has changed. ipfw(8) needs to be recompiled.
+
 20081009:
 	The uhci, ohci, ehci and slhci USB Host controller drivers have
 	been put into separate modules. If you load the usb module

Modified: head/sys/netinet/ip_dummynet.h
==============================================================================
--- head/sys/netinet/ip_dummynet.h	Tue Oct 28 13:44:11 2008	(r184413)
+++ head/sys/netinet/ip_dummynet.h	Tue Oct 28 14:14:57 2008	(r184414)
@@ -216,7 +216,7 @@ struct dn_flow_queue {
     int avg ;                   /* average queue length est. (scaled) */
     int count ;                 /* arrivals since last RED drop */
     int random ;                /* random value (scaled) */
-    u_int32_t q_time ;          /* start of queue idle time */
+    dn_key q_time;		/* start of queue idle time */
 
     /* WF2Q+ support */
     struct dn_flow_set *fs ;	/* parent flow set */

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 15:30:51 2008
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 9C55A106567F;
	Tue, 28 Oct 2008 15:30:51 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net
	[IPv6:2001:470:1f10:75::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 3B8AF8FC19;
	Tue, 28 Oct 2008 15:30:51 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1])
	(authenticated bits=0)
	by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9SFUCWl024647;
	Tue, 28 Oct 2008 11:30:45 -0400 (EDT) (envelope-from jhb@freebsd.org)
From: John Baldwin 
To: Peter Wemm 
Date: Tue, 28 Oct 2008 10:22:41 -0400
User-Agent: KMail/1.9.7
References: <200810280326.m9S3QPit080877@svn.freebsd.org>
In-Reply-To: <200810280326.m9S3QPit080877@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200810281022.41296.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by
	milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]);
	Tue, 28 Oct 2008 11:30:45 -0400 (EDT)
X-Virus-Scanned: ClamAV 0.93.1/8526/Tue Oct 28 09:21:35 2008 on
	server.baldwin.cx
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS 
	autolearn=ham version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184385 - head/sys/kern
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, 28 Oct 2008 15:30:51 -0000

On Monday 27 October 2008 11:26:25 pm Peter Wemm wrote:
> Author: peter
> Date: Tue Oct 28 03:26:25 2008
> New Revision: 184385
> URL: http://svn.freebsd.org/changeset/base/184385
> 
> Log:
>   After a machine has been up for a bit more than 20 days with HZ=1000,
>   "ticks" goes negative.  This breaks the signed comparison in softclock.
>   This causes sleep() to never wake up, tcp to stop, etc etc.  This is
>   bad(TM).  Use the SEQ_LT() method from tcp's sequence number comparisons.
> 
> Modified:
>   head/sys/kern/kern_timeout.c

I wonder why this used < rather than the != that older branches used.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 15:31:03 2008
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 EBC9B10656C8
	for ; Tue, 28 Oct 2008 15:31:03 +0000 (UTC)
	(envelope-from jhb@freebsd.org)
Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net
	[IPv6:2001:470:1f10:75::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 94DC48FC23
	for ; Tue, 28 Oct 2008 15:31:03 +0000 (UTC)
	(envelope-from jhb@freebsd.org)
Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1])
	(authenticated bits=0)
	by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9SFUCWn024647;
	Tue, 28 Oct 2008 11:30:57 -0400 (EDT) (envelope-from jhb@freebsd.org)
From: John Baldwin 
To: "M. Warner Losh" 
Date: Tue, 28 Oct 2008 11:08:05 -0400
User-Agent: KMail/1.9.7
References: <200810241031.08780.jhb@freebsd.org>
	<200810271159.31843.jhb@freebsd.org>
	<20081027.221910.1508179985.imp@bsdimp.com>
In-Reply-To: <20081027.221910.1508179985.imp@bsdimp.com>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200810281108.06010.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by
	milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]);
	Tue, 28 Oct 2008 11:30:57 -0400 (EDT)
X-Virus-Scanned: ClamAV 0.93.1/8526/Tue Oct 28 09:21:35 2008 on
	server.baldwin.cx
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS 
	autolearn=ham version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx
Cc: danfe@freebsd.org, marcel@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, svn-src-head@freebsd.org, des@des.no
Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf
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, 28 Oct 2008 15:31:04 -0000

On Tuesday 28 October 2008 12:19:10 am M. Warner Losh wrote:
> In message: <200810271159.31843.jhb@freebsd.org>
>             John Baldwin  writes:
> : On Friday 24 October 2008 06:47:40 pm Warner Losh wrote:
> : > From: John Baldwin 
> : > Subject: Re: svn commit: r184193 - in head/sys: arm/conf conf
> : > Date: Fri, 24 Oct 2008 10:31:07 -0400
> : > 
> : > > On Friday 24 October 2008 09:27:03 am Alexey Dokuchaev wrote:
> : > > > On Fri, Oct 24, 2008 at 03:26:43AM +0200, Dag-Erling Sm??rgrav 
wrote:
> : > > > > Warner Losh  writes:
> : > > > > > We already have a better mechanism for including config files.  
We
> : > > > > > should be using that instead of poluting another port with the
> : > > > > > DEFAULTS file.
> : > > > > 
> : > > > > Should we even have DEFAULTS files at all?  IMHO they just confuse
> : > > > > matters by introducing "stealth" options into your config.
> : > > > 
> : > > > I tend to second this.  I always try to get everything possible out 
of
> : > > > my kernel to modules, and thus was surprised to see io.ko and mem.ko
> : > > > fail to load because they were silently included into my custom 
kernel.
> : > > > 
> : > > > I understand that some things like 'device isa' and
> : > > > 'device npx' aren't really optional, but if something is useful to 
have,
> : > > > but can be loaded as a module, it belongs to GENERIC rather than
> : > > > DEFAULTS.  Killing the latter altogether and throwing a comment that
> : > > > says particular option or device is mandatory in GENERIC is probably
> : > > > even better (and more transparent).
> : > > 
> : > > The one thing I think DEFAULTS is useful for are replacing NO_FOO 
options 
> : with 
> : > > FOO options.  That is, if someone wants to turn a feature on by 
default, 
> : I'd 
> : > > rather them put 'options FOO' in DEFAULTS rather than rename all the 
> : > > #ifdef's,e tc. to '#ifndef NO_FOO'.
> : > 
> : > Wouldn't it be better to move to a system where we explicitly include
> : > std.i386 and have them all defined there?  We already encourage stuff
> : > like this with advice to include GENERIC with nodev...
> : 
> : I wouldn't mind a std.i386, and if we make config's include keyword fall 
back 
> : to 'sys/conf' for relative path name lookups if the lookup in '.' fails 
then 
> : you can even put those files in sys/conf with the still-clean syntax 
> : of 'include std.i386'.
> 
> Already works that way...
> 
> : However, I don't know about you, but I _never_ build a config by including 
> : GENERIC and then weeding stuff out.  Too much stuff to weed out.  Once I 
have 
> : a customized config for a machine I then include that in development 
branches 
> : to install kernels to different directories under /boot, etc.
> 
> Yea,  Well, I was thinking of std.firewire, et al.  Trouble is we'd
> then have to slice thing by bus (std.pccard, std.cardbus, std.pci,
> std.iic, std.usb) and by function (std.wireless, std.scsi, std.serial)
> which slices across different functional groups...
> 
> Warner
> 
> P.S.  Here's a diff of something we can do today...  This is just a
> quickie demo, not a proposed patch to the tree...  It also assumes
> that we have nocpu defined in config, which I haven't verified.

I wouldn't bother doing the CPU bits yet, I would just rename the existing 
DEFAULTS files and then remove the code from config(8) to auto-include 
DEFAULTS.  Then if you wanted to do further tweaks to std. you can do 
that later.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 15:31:17 2008
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 E745F1065879;
	Tue, 28 Oct 2008 15:31:17 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net
	[IPv6:2001:470:1f10:75::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 68EF68FC1D;
	Tue, 28 Oct 2008 15:31:17 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1])
	(authenticated bits=0)
	by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9SFUCWp024647;
	Tue, 28 Oct 2008 11:31:11 -0400 (EDT) (envelope-from jhb@freebsd.org)
From: John Baldwin 
To: "Bjoern A. Zeeb" 
Date: Tue, 28 Oct 2008 11:11:48 -0400
User-Agent: KMail/1.9.7
References: <200810271515.m9RFF86d042970@svn.freebsd.org>
	<200810271418.41291.jhb@freebsd.org>
	<20081028065010.A2978@maildrop.int.zabbadoz.net>
In-Reply-To: <20081028065010.A2978@maildrop.int.zabbadoz.net>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200810281111.48833.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by
	milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]);
	Tue, 28 Oct 2008 11:31:11 -0400 (EDT)
X-Virus-Scanned: ClamAV 0.93.1/8526/Tue Oct 28 09:21:35 2008 on
	server.baldwin.cx
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS 
	autolearn=ham version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184341 - head/usr.sbin
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, 28 Oct 2008 15:31:18 -0000

On Tuesday 28 October 2008 02:56:23 am Bjoern A. Zeeb wrote:
> On Mon, 27 Oct 2008, John Baldwin wrote:
> 
> > On Monday 27 October 2008 11:15:08 am Bjoern A. Zeeb wrote:
> >> Author: bz
> >> Date: Mon Oct 27 15:15:08 2008
> >> New Revision: 184341
> >> URL: http://svn.freebsd.org/changeset/base/184341
> >>
> >> Log:
> >>   We do not have a libkse anymore and Mk/bsd.* does not know
> >>   about LIBKSE anymore, so s,MK_LIBKSE,MK_LIBPTHREAD,.
> >
> > Shouldn't you just remove it instead?  These two options are now basically
> > identical.  (We probably should rename libthr to libpthread at some 
point.)
> 
> tools/build/options/WITHOUT_LIBPTHREAD still talks about kse and thus
> does src.conf(5).

That should be updated.

> I wouldn't object to removing one of the options but according to the
> src.conf my bet would be LIBTHR and not LIBPTHREAD.
> So updating the documentation might be a good initial step as well.

Note that MK_LIBTHR == "NO" implies MK_LIBPTHREAD == "NO" (see bsd.own.mk), 
but not the other way around.  So for now the correct knob to check in 
Makefiles is MK_LIBTHR (since it gets set to NO in both the WITHOUT_LIBTHR 
and WITHOUT_LIBPTHREAD cases, but MK_LIBPTHREAD isn't set to NO if you just 
do WITHOUT_LIBTHR).

> I have to admit that I lost track about our threading libs in
> different branches at one time; how many are left in head - 1 or 2?
> Is only libthr left and we build it as libthr and add symlinks for
> libpthread?

Yes.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 15:53:04 2008
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 282BD1065683;
	Tue, 28 Oct 2008 15:53:04 +0000 (UTC) (envelope-from imp@bsdimp.com)
Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85])
	by mx1.freebsd.org (Postfix) with ESMTP id D97678FC16;
	Tue, 28 Oct 2008 15:53:03 +0000 (UTC) (envelope-from imp@bsdimp.com)
Received: from localhost (localhost [127.0.0.1])
	by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m9SFqj2g025717;
	Tue, 28 Oct 2008 09:52:45 -0600 (MDT) (envelope-from imp@bsdimp.com)
Date: Tue, 28 Oct 2008 09:53:56 -0600 (MDT)
Message-Id: <20081028.095356.2040345174.imp@bsdimp.com>
To: stas@FreeBSD.org
From: "M. Warner Losh" 
In-Reply-To: <20081028104435.50b3fb0f.stas@FreeBSD.org>
References: <0BBCA616-4F9D-48D5-9360-CACA69480632@mac.com>
	<20081027.214547.709404828.imp@bsdimp.com>
	<20081028104435.50b3fb0f.stas@FreeBSD.org>
X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, xcllnt@mac.com,
	src-committers@FreeBSD.org
Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys
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, 28 Oct 2008 15:53:04 -0000

In message: <20081028104435.50b3fb0f.stas@FreeBSD.org>
            Stanislav Sedov  writes:
: On Mon, 27 Oct 2008 21:45:47 -0600 (MDT)
: "M. Warner Losh"  mentioned:
: 
: > 
: > I tend to think that we should handle the partitioning in GEOM, with
: > higher level things figuring the rest out.  We should expose flash,
: > and its properties upstream in GEOM, but not have a separate layer for
: > flash ala mdt.
: > 
: 
: Yeah, GEOM is the right place for this kind of stuff, indeed. Wear levering
: and similar things could be provided via GEOM too, probably.

Especially if the wear averaging were optional.  Then we could put
'legacy' file systems on top of the wear averaging layer, but could
also develop more optimized file systems with wear averaging built
in.  Which one to use can also be highly application specific for the
best performance.  The story from the Linux world indicates that many
applications just don't matter, but the ones that do often depend on a
specific type of flash is used.  NAND and NOR memories have very
different performance characteristics, and papers presented at Linux
conferences show gains for teams that have created new file systems
for the specific type of flash.

Right now, I expose the SPI flash as 1056 byte blocks (since that's
the size of the block).  A wear averaging layer would write metadata
in the 32 bytes and expose 1024 or 512 byte blocks...

Warner

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 17:15:46 2008
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 ADF4F1065685;
	Tue, 28 Oct 2008 17:15:46 +0000 (UTC)
	(envelope-from rdivacky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 84A438FC1A;
	Tue, 28 Oct 2008 17:15:46 +0000 (UTC)
	(envelope-from rdivacky@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 m9SHFkYA099448;
	Tue, 28 Oct 2008 17:15:46 GMT
	(envelope-from rdivacky@svn.freebsd.org)
Received: (from rdivacky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SHFkRV099447;
	Tue, 28 Oct 2008 17:15:46 GMT
	(envelope-from rdivacky@svn.freebsd.org)
Message-Id: <200810281715.m9SHFkRV099447@svn.freebsd.org>
From: Roman Divacky 
Date: Tue, 28 Oct 2008 17:15:46 +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: r184418 - head/bin/rcp
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, 28 Oct 2008 17:15:46 -0000

Author: rdivacky
Date: Tue Oct 28 17:15:46 2008
New Revision: 184418
URL: http://svn.freebsd.org/changeset/base/184418

Log:
  Remove superfluous va_end which was left there in rev 1.38.
  
  Approved by: kib (mentor)

Modified:
  head/bin/rcp/rcp.c

Modified: head/bin/rcp/rcp.c
==============================================================================
--- head/bin/rcp/rcp.c	Tue Oct 28 17:01:16 2008	(r184417)
+++ head/bin/rcp/rcp.c	Tue Oct 28 17:15:46 2008	(r184418)
@@ -789,6 +789,4 @@ run_err(const char *fmt, ...)
 		vwarnx(fmt, ap);
 		va_end(ap);
 	}
-
-	va_end(ap);
 }

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 21:08:28 2008
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 9F0DB10657B5;
	Tue, 28 Oct 2008 21:08:28 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E520090457;
	Tue, 28 Oct 2008 19:48:58 +0000 (UTC)
	(envelope-from trasz@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 m9SJmwhI002341;
	Tue, 28 Oct 2008 19:48:58 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SJmwDb002340;
	Tue, 28 Oct 2008 19:48:58 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <200810281948.m9SJmwDb002340@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 28 Oct 2008 19:48:58 +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: r184419 - head/sys/sys
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, 28 Oct 2008 21:08:29 -0000

Author: trasz
Date: Tue Oct 28 19:48:58 2008
New Revision: 184419
URL: http://svn.freebsd.org/changeset/base/184419

Log:
  Bump __FreeBSD_version after accmode_t introduction.
  
  Approved by:	rwatson (mentor)

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h	Tue Oct 28 17:15:46 2008	(r184418)
+++ head/sys/sys/param.h	Tue Oct 28 19:48:58 2008	(r184419)
@@ -57,7 +57,7 @@
  *		is created, otherwise 1.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 800051	/* Master, propagated to newvers */
+#define __FreeBSD_version 800052	/* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include 

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 21:53:11 2008
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 1F169106564A;
	Tue, 28 Oct 2008 21:53:11 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0A9E28FC16;
	Tue, 28 Oct 2008 21:53:11 +0000 (UTC)
	(envelope-from rwatson@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 m9SLrBof004842;
	Tue, 28 Oct 2008 21:53:11 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SLrA9H004839;
	Tue, 28 Oct 2008 21:53:10 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810282153.m9SLrA9H004839@svn.freebsd.org>
From: Robert Watson 
Date: Tue, 28 Oct 2008 21:53:10 +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: r184425 - in head/sys: conf security/mac
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, 28 Oct 2008 21:53:11 -0000

Author: rwatson
Date: Tue Oct 28 21:53:10 2008
New Revision: 184425
URL: http://svn.freebsd.org/changeset/base/184425

Log:
  Break out strictly credential-related portions of mac_process.c into a
  new file, mac_cred.c.
  
  Obtained from:	TrustedBSD Project

Added:
  head/sys/security/mac/mac_cred.c   (contents, props changed)
     - copied, changed from r184412, head/sys/security/mac/mac_process.c
Modified:
  head/sys/conf/files
  head/sys/security/mac/mac_process.c

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Tue Oct 28 21:05:09 2008	(r184424)
+++ head/sys/conf/files	Tue Oct 28 21:53:10 2008	(r184425)
@@ -2175,6 +2175,7 @@ security/audit/audit_trigger.c	optional 
 security/audit/audit_worker.c	optional audit
 security/mac/mac_atalk.c	optional mac netatalk
 security/mac/mac_audit.c	optional mac audit
+security/mac/mac_cred.c		optional mac
 security/mac/mac_framework.c	optional mac
 security/mac/mac_inet.c		optional mac inet
 security/mac/mac_inet6.c	optional mac inet6

Copied and modified: head/sys/security/mac/mac_cred.c (from r184412, head/sys/security/mac/mac_process.c)
==============================================================================
--- head/sys/security/mac/mac_process.c	Tue Oct 28 12:49:07 2008	(r184412, copy source)
+++ head/sys/security/mac/mac_cred.c	Tue Oct 28 21:53:10 2008	(r184425)
@@ -71,19 +71,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-static int	mac_mmap_revocation = 1;
-SYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation, CTLFLAG_RW,
-    &mac_mmap_revocation, 0, "Revoke mmap access to files on subject "
-    "relabel");
-
-static int	mac_mmap_revocation_via_cow = 0;
-SYSCTL_INT(_security_mac, OID_AUTO, mmap_revocation_via_cow, CTLFLAG_RW,
-    &mac_mmap_revocation_via_cow, 0, "Revoke mmap access to files via "
-    "copy-on-write semantics, or by removing all write access");
-
-static void	mac_proc_vm_revoke_recurse(struct thread *td,
-		    struct ucred *cred, struct vm_map *map);
-
 struct label *
 mac_cred_label_alloc(void)
 {
@@ -104,26 +91,6 @@ mac_cred_init(struct ucred *cred)
 		cred->cr_label = NULL;
 }
 
-static struct label *
-mac_proc_label_alloc(void)
-{
-	struct label *label;
-
-	label = mac_labelzone_alloc(M_WAITOK);
-	MAC_PERFORM(proc_init_label, label);
-	return (label);
-}
-
-void
-mac_proc_init(struct proc *p)
-{
-
-	if (mac_labeled & MPC_OBJECT_PROC)
-		p->p_label = mac_proc_label_alloc();
-	else
-		p->p_label = NULL;
-}
-
 void
 mac_cred_label_free(struct label *label)
 {
@@ -142,24 +109,6 @@ mac_cred_destroy(struct ucred *cred)
 	}
 }
 
-static void
-mac_proc_label_free(struct label *label)
-{
-
-	MAC_PERFORM(proc_destroy_label, label);
-	mac_labelzone_free(label);
-}
-
-void
-mac_proc_destroy(struct proc *p)
-{
-
-	if (p->p_label != NULL) {
-		mac_proc_label_free(p->p_label);
-		p->p_label = NULL;
-	}
-}
-
 /*
  * When a thread becomes an NFS server daemon, its credential may need to be
  * updated to reflect this so that policies can recognize when file system
@@ -219,13 +168,6 @@ mac_cred_internalize_label(struct label 
 	return (error);
 }
 
-void
-mac_thread_userret(struct thread *td)
-{
-
-	MAC_PERFORM(thread_userret, td);
-}
-
 /*
  * When a new process is created, its label must be initialized.  Generally,
  * this involves inheritence from the parent process, modulo possible deltas.
@@ -238,252 +180,6 @@ mac_cred_copy(struct ucred *src, struct 
 	MAC_PERFORM(cred_copy_label, src->cr_label, dest->cr_label);
 }
 
-int
-mac_execve_enter(struct image_params *imgp, struct mac *mac_p)
-{
-	struct label *label;
-	struct mac mac;
-	char *buffer;
-	int error;
-
-	if (mac_p == NULL)
-		return (0);
-
-	if (!(mac_labeled & MPC_OBJECT_CRED))
-		return (EINVAL);
-
-	error = copyin(mac_p, &mac, sizeof(mac));
-	if (error)
-		return (error);
-
-	error = mac_check_structmac_consistent(&mac);
-	if (error)
-		return (error);
-
-	buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
-	error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL);
-	if (error) {
-		free(buffer, M_MACTEMP);
-		return (error);
-	}
-
-	label = mac_cred_label_alloc();
-	error = mac_cred_internalize_label(label, buffer);
-	free(buffer, M_MACTEMP);
-	if (error) {
-		mac_cred_label_free(label);
-		return (error);
-	}
-	imgp->execlabel = label;
-	return (0);
-}
-
-void
-mac_execve_exit(struct image_params *imgp)
-{
-	if (imgp->execlabel != NULL) {
-		mac_cred_label_free(imgp->execlabel);
-		imgp->execlabel = NULL;
-	}
-}
-
-void
-mac_execve_interpreter_enter(struct vnode *interpvp,
-    struct label **interpvplabel)
-{
-
-	if (mac_labeled & MPC_OBJECT_VNODE) {
-		*interpvplabel = mac_vnode_label_alloc();
-		mac_vnode_copy_label(interpvp->v_label, *interpvplabel);
-	} else
-		*interpvplabel = NULL;
-}
-
-void
-mac_execve_interpreter_exit(struct label *interpvplabel)
-{
-
-	if (interpvplabel != NULL)
-		mac_vnode_label_free(interpvplabel);
-}
-
-/*
- * When relabeling a process, call out to the policies for the maximum
- * permission allowed for each object type we know about in its memory space,
- * and revoke access (in the least surprising ways we know) when necessary.
- * The process lock is not held here.
- */
-void
-mac_proc_vm_revoke(struct thread *td)
-{
-	struct ucred *cred;
-
-	PROC_LOCK(td->td_proc);
-	cred = crhold(td->td_proc->p_ucred);
-	PROC_UNLOCK(td->td_proc);
-
-	/* XXX freeze all other threads */
-	mac_proc_vm_revoke_recurse(td, cred,
-	    &td->td_proc->p_vmspace->vm_map);
-	/* XXX allow other threads to continue */
-
-	crfree(cred);
-}
-
-static __inline const char *
-prot2str(vm_prot_t prot)
-{
-
-	switch (prot & VM_PROT_ALL) {
-	case VM_PROT_READ:
-		return ("r--");
-	case VM_PROT_READ | VM_PROT_WRITE:
-		return ("rw-");
-	case VM_PROT_READ | VM_PROT_EXECUTE:
-		return ("r-x");
-	case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE:
-		return ("rwx");
-	case VM_PROT_WRITE:
-		return ("-w-");
-	case VM_PROT_EXECUTE:
-		return ("--x");
-	case VM_PROT_WRITE | VM_PROT_EXECUTE:
-		return ("-wx");
-	default:
-		return ("---");
-	}
-}
-
-static void
-mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
-    struct vm_map *map)
-{
-	struct vm_map_entry *vme;
-	int vfslocked, result;
-	vm_prot_t revokeperms;
-	vm_object_t backing_object, object;
-	vm_ooffset_t offset;
-	struct vnode *vp;
-	struct mount *mp;
-
-	if (!mac_mmap_revocation)
-		return;
-
-	vm_map_lock_read(map);
-	for (vme = map->header.next; vme != &map->header; vme = vme->next) {
-		if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) {
-			mac_proc_vm_revoke_recurse(td, cred,
-			    vme->object.sub_map);
-			continue;
-		}
-		/*
-		 * Skip over entries that obviously are not shared.
-		 */
-		if (vme->eflags & (MAP_ENTRY_COW | MAP_ENTRY_NOSYNC) ||
-		    !vme->max_protection)
-			continue;
-		/*
-		 * Drill down to the deepest backing object.
-		 */
-		offset = vme->offset;
-		object = vme->object.vm_object;
-		if (object == NULL)
-			continue;
-		VM_OBJECT_LOCK(object);
-		while ((backing_object = object->backing_object) != NULL) {
-			VM_OBJECT_LOCK(backing_object);
-			offset += object->backing_object_offset;
-			VM_OBJECT_UNLOCK(object);
-			object = backing_object;
-		}
-		VM_OBJECT_UNLOCK(object);
-		/*
-		 * At the moment, vm_maps and objects aren't considered by
-		 * the MAC system, so only things with backing by a normal
-		 * object (read: vnodes) are checked.
-		 */
-		if (object->type != OBJT_VNODE)
-			continue;
-		vp = (struct vnode *)object->handle;
-		vfslocked = VFS_LOCK_GIANT(vp->v_mount);
-		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-		result = vme->max_protection;
-		mac_vnode_check_mmap_downgrade(cred, vp, &result);
-		VOP_UNLOCK(vp, 0);
-		/*
-		 * Find out what maximum protection we may be allowing now
-		 * but a policy needs to get removed.
-		 */
-		revokeperms = vme->max_protection & ~result;
-		if (!revokeperms) {
-			VFS_UNLOCK_GIANT(vfslocked);
-			continue;
-		}
-		printf("pid %ld: revoking %s perms from %#lx:%ld "
-		    "(max %s/cur %s)\n", (long)td->td_proc->p_pid,
-		    prot2str(revokeperms), (u_long)vme->start,
-		    (long)(vme->end - vme->start),
-		    prot2str(vme->max_protection), prot2str(vme->protection));
-		vm_map_lock_upgrade(map);
-		/*
-		 * This is the really simple case: if a map has more
-		 * max_protection than is allowed, but it's not being
-		 * actually used (that is, the current protection is still
-		 * allowed), we can just wipe it out and do nothing more.
-		 */
-		if ((vme->protection & revokeperms) == 0) {
-			vme->max_protection -= revokeperms;
-		} else {
-			if (revokeperms & VM_PROT_WRITE) {
-				/*
-				 * In the more complicated case, flush out all
-				 * pending changes to the object then turn it
-				 * copy-on-write.
-				 */
-				vm_object_reference(object);
-				(void) vn_start_write(vp, &mp, V_WAIT);
-				vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-				VM_OBJECT_LOCK(object);
-				vm_object_page_clean(object,
-				    OFF_TO_IDX(offset),
-				    OFF_TO_IDX(offset + vme->end - vme->start +
-					PAGE_MASK),
-				    OBJPC_SYNC);
-				VM_OBJECT_UNLOCK(object);
-				VOP_UNLOCK(vp, 0);
-				vn_finished_write(mp);
-				vm_object_deallocate(object);
-				/*
-				 * Why bother if there's no read permissions
-				 * anymore?  For the rest, we need to leave
-				 * the write permissions on for COW, or
-				 * remove them entirely if configured to.
-				 */
-				if (!mac_mmap_revocation_via_cow) {
-					vme->max_protection &= ~VM_PROT_WRITE;
-					vme->protection &= ~VM_PROT_WRITE;
-				} if ((revokeperms & VM_PROT_READ) == 0)
-					vme->eflags |= MAP_ENTRY_COW |
-					    MAP_ENTRY_NEEDS_COPY;
-			}
-			if (revokeperms & VM_PROT_EXECUTE) {
-				vme->max_protection &= ~VM_PROT_EXECUTE;
-				vme->protection &= ~VM_PROT_EXECUTE;
-			}
-			if (revokeperms & VM_PROT_READ) {
-				vme->max_protection = 0;
-				vme->protection = 0;
-			}
-			pmap_protect(map->pmap, vme->start, vme->end,
-			    vme->protection & ~revokeperms);
-			vm_map_simplify_entry(map, vme);
-		}
-		vm_map_lock_downgrade(map);
-		VFS_UNLOCK_GIANT(vfslocked);
-	}
-	vm_map_unlock_read(map);
-}
-
 /*
  * When the subject's label changes, it may require revocation of privilege
  * to mapped objects.  This can't be done on-the-fly later with a unified
@@ -515,160 +211,3 @@ mac_cred_check_visible(struct ucred *cr1
 
 	return (error);
 }
-
-int
-mac_proc_check_debug(struct ucred *cred, struct proc *p)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_debug, cred, p);
-
-	return (error);
-}
-
-int
-mac_proc_check_sched(struct ucred *cred, struct proc *p)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_sched, cred, p);
-
-	return (error);
-}
-
-int
-mac_proc_check_signal(struct ucred *cred, struct proc *p, int signum)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_signal, cred, p, signum);
-
-	return (error);
-}
-
-int
-mac_proc_check_setuid(struct proc *p, struct ucred *cred, uid_t uid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setuid, cred, uid);
-	return (error);
-}
-
-int
-mac_proc_check_seteuid(struct proc *p, struct ucred *cred, uid_t euid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_seteuid, cred, euid);
-	return (error);
-}
-
-int
-mac_proc_check_setgid(struct proc *p, struct ucred *cred, gid_t gid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setgid, cred, gid);
-
-	return (error);
-}
-
-int
-mac_proc_check_setegid(struct proc *p, struct ucred *cred, gid_t egid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setegid, cred, egid);
-
-	return (error);
-}
-
-int
-mac_proc_check_setgroups(struct proc *p, struct ucred *cred, int ngroups,
-    gid_t *gidset)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setgroups, cred, ngroups, gidset);
-	return (error);
-}
-
-int
-mac_proc_check_setreuid(struct proc *p, struct ucred *cred, uid_t ruid,
-    uid_t euid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setreuid, cred, ruid, euid);
-
-	return (error);
-}
-
-int
-mac_proc_check_setregid(struct proc *proc, struct ucred *cred, gid_t rgid,
-    gid_t egid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(proc, MA_OWNED);
-
-	MAC_CHECK(proc_check_setregid, cred, rgid, egid);
-
-	return (error);
-}
-
-int
-mac_proc_check_setresuid(struct proc *p, struct ucred *cred, uid_t ruid,
-    uid_t euid, uid_t suid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setresuid, cred, ruid, euid, suid);
-	return (error);
-}
-
-int
-mac_proc_check_setresgid(struct proc *p, struct ucred *cred, gid_t rgid,
-    gid_t egid, gid_t sgid)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_setresgid, cred, rgid, egid, sgid);
-
-	return (error);
-}
-
-int
-mac_proc_check_wait(struct ucred *cred, struct proc *p)
-{
-	int error;
-
-	PROC_LOCK_ASSERT(p, MA_OWNED);
-
-	MAC_CHECK(proc_check_wait, cred, p);
-
-	return (error);
-}

Modified: head/sys/security/mac/mac_process.c
==============================================================================
--- head/sys/security/mac/mac_process.c	Tue Oct 28 21:05:09 2008	(r184424)
+++ head/sys/security/mac/mac_process.c	Tue Oct 28 21:53:10 2008	(r184425)
@@ -84,26 +84,6 @@ SYSCTL_INT(_security_mac, OID_AUTO, mmap
 static void	mac_proc_vm_revoke_recurse(struct thread *td,
 		    struct ucred *cred, struct vm_map *map);
 
-struct label *
-mac_cred_label_alloc(void)
-{
-	struct label *label;
-
-	label = mac_labelzone_alloc(M_WAITOK);
-	MAC_PERFORM(cred_init_label, label);
-	return (label);
-}
-
-void
-mac_cred_init(struct ucred *cred)
-{
-
-	if (mac_labeled & MPC_OBJECT_CRED)
-		cred->cr_label = mac_cred_label_alloc();
-	else
-		cred->cr_label = NULL;
-}
-
 static struct label *
 mac_proc_label_alloc(void)
 {
@@ -124,24 +104,6 @@ mac_proc_init(struct proc *p)
 		p->p_label = NULL;
 }
 
-void
-mac_cred_label_free(struct label *label)
-{
-
-	MAC_PERFORM(cred_destroy_label, label);
-	mac_labelzone_free(label);
-}
-
-void
-mac_cred_destroy(struct ucred *cred)
-{
-
-	if (cred->cr_label != NULL) {
-		mac_cred_label_free(cred->cr_label);
-		cred->cr_label = NULL;
-	}
-}
-
 static void
 mac_proc_label_free(struct label *label)
 {
@@ -160,65 +122,6 @@ mac_proc_destroy(struct proc *p)
 	}
 }
 
-/*
- * When a thread becomes an NFS server daemon, its credential may need to be
- * updated to reflect this so that policies can recognize when file system
- * operations originate from the network.
- *
- * At some point, it would be desirable if the credential used for each NFS
- * RPC could be set based on the RPC context (i.e., source system, etc) to
- * provide more fine-grained access control.
- */
-void
-mac_cred_associate_nfsd(struct ucred *cred)
-{
-
-	MAC_PERFORM(cred_associate_nfsd, cred);
-}
-
-/*
- * Initialize MAC label for the first kernel process, from which other kernel
- * processes and threads are spawned.
- */
-void
-mac_cred_create_swapper(struct ucred *cred)
-{
-
-	MAC_PERFORM(cred_create_swapper, cred);
-}
-
-/*
- * Initialize MAC label for the first userland process, from which other
- * userland processes and threads are spawned.
- */
-void
-mac_cred_create_init(struct ucred *cred)
-{
-
-	MAC_PERFORM(cred_create_init, cred);
-}
-
-int
-mac_cred_externalize_label(struct label *label, char *elements,
-    char *outbuf, size_t outbuflen)
-{
-	int error;
-
-	MAC_EXTERNALIZE(cred, label, elements, outbuf, outbuflen);
-
-	return (error);
-}
-
-int
-mac_cred_internalize_label(struct label *label, char *string)
-{
-	int error;
-
-	MAC_INTERNALIZE(cred, label, string);
-
-	return (error);
-}
-
 void
 mac_thread_userret(struct thread *td)
 {
@@ -226,18 +129,6 @@ mac_thread_userret(struct thread *td)
 	MAC_PERFORM(thread_userret, td);
 }
 
-/*
- * When a new process is created, its label must be initialized.  Generally,
- * this involves inheritence from the parent process, modulo possible deltas.
- * This function allows that processing to take place.
- */
-void
-mac_cred_copy(struct ucred *src, struct ucred *dest)
-{
-
-	MAC_PERFORM(cred_copy_label, src->cr_label, dest->cr_label);
-}
-
 int
 mac_execve_enter(struct image_params *imgp, struct mac *mac_p)
 {
@@ -484,38 +375,6 @@ mac_proc_vm_revoke_recurse(struct thread
 	vm_map_unlock_read(map);
 }
 
-/*
- * When the subject's label changes, it may require revocation of privilege
- * to mapped objects.  This can't be done on-the-fly later with a unified
- * buffer cache.
- */
-void
-mac_cred_relabel(struct ucred *cred, struct label *newlabel)
-{
-
-	MAC_PERFORM(cred_relabel, cred, newlabel);
-}
-
-int
-mac_cred_check_relabel(struct ucred *cred, struct label *newlabel)
-{
-	int error;
-
-	MAC_CHECK(cred_check_relabel, cred, newlabel);
-
-	return (error);
-}
-
-int
-mac_cred_check_visible(struct ucred *cr1, struct ucred *cr2)
-{
-	int error;
-
-	MAC_CHECK(cred_check_visible, cr1, cr2);
-
-	return (error);
-}
-
 int
 mac_proc_check_debug(struct ucred *cred, struct proc *p)
 {

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 21:57:32 2008
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 F195D1065688;
	Tue, 28 Oct 2008 21:57:32 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DE3148FC1F;
	Tue, 28 Oct 2008 21:57:32 +0000 (UTC)
	(envelope-from trasz@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 m9SLvWkT004964;
	Tue, 28 Oct 2008 21:57:32 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SLvWrw004963;
	Tue, 28 Oct 2008 21:57:32 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <200810282157.m9SLvWrw004963@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 28 Oct 2008 21:57: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: r184426 - head/sys/security/mac_stub
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, 28 Oct 2008 21:57:33 -0000

Author: trasz
Date: Tue Oct 28 21:57:32 2008
New Revision: 184426
URL: http://svn.freebsd.org/changeset/base/184426

Log:
  Commit part of accmode_t changes that I missed in previous commit.
  
  Approved by:	rwatson (mentor)

Modified:
  head/sys/security/mac_stub/mac_stub.c

Modified: head/sys/security/mac_stub/mac_stub.c
==============================================================================
--- head/sys/security/mac_stub/mac_stub.c	Tue Oct 28 21:53:10 2008	(r184425)
+++ head/sys/security/mac_stub/mac_stub.c	Tue Oct 28 21:57:32 2008	(r184426)
@@ -1215,7 +1215,7 @@ stub_vnode_associate_singlelabel(struct 
 
 static int
 stub_vnode_check_access(struct ucred *cred, struct vnode *vp,
-    struct label *vplabel, int acc_mode)
+    struct label *vplabel, accmode_t accmode)
 {
 
 	return (0);

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 21:58:48 2008
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 A5B9B106567D;
	Tue, 28 Oct 2008 21:58:48 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 92B0C8FC0A;
	Tue, 28 Oct 2008 21:58:48 +0000 (UTC)
	(envelope-from trasz@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 m9SLwm8o005027;
	Tue, 28 Oct 2008 21:58:48 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SLwmF4005026;
	Tue, 28 Oct 2008 21:58:48 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <200810282158.m9SLwmF4005026@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 28 Oct 2008 21:58:48 +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: r184427 - head/sys/kern
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, 28 Oct 2008 21:58:48 -0000

Author: trasz
Date: Tue Oct 28 21:58:48 2008
New Revision: 184427
URL: http://svn.freebsd.org/changeset/base/184427

Log:
  Rename a variable missed in previous accmode_t-related commits.
  
  Approved by:	rwatson (mentor)

Modified:
  head/sys/kern/subr_acl_posix1e.c

Modified: head/sys/kern/subr_acl_posix1e.c
==============================================================================
--- head/sys/kern/subr_acl_posix1e.c	Tue Oct 28 21:57:32 2008	(r184426)
+++ head/sys/kern/subr_acl_posix1e.c	Tue Oct 28 21:58:48 2008	(r184427)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
  */
 int
 vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
-    struct acl *acl, accmode_t acc_mode, struct ucred *cred, int *privused)
+    struct acl *acl, accmode_t accmode, struct ucred *cred, int *privused)
 {
 	struct acl_entry *acl_other, *acl_mask;
 	accmode_t dac_granted;
@@ -81,23 +81,23 @@ vaccess_acl_posix1e(enum vtype type, uid
 	priv_granted = 0;
 
 	if (type == VDIR) {
-		if ((acc_mode & VEXEC) && !priv_check_cred(cred,
+		if ((accmode & VEXEC) && !priv_check_cred(cred,
 		     PRIV_VFS_LOOKUP, 0))
 			priv_granted |= VEXEC;
 	} else {
-		if ((acc_mode & VEXEC) && !priv_check_cred(cred,
+		if ((accmode & VEXEC) && !priv_check_cred(cred,
 		    PRIV_VFS_EXEC, 0))
 			priv_granted |= VEXEC;
 	}
 
-	if ((acc_mode & VREAD) && !priv_check_cred(cred, PRIV_VFS_READ, 0))
+	if ((accmode & VREAD) && !priv_check_cred(cred, PRIV_VFS_READ, 0))
 		priv_granted |= VREAD;
 
-	if (((acc_mode & VWRITE) || (acc_mode & VAPPEND)) &&
+	if (((accmode & VWRITE) || (accmode & VAPPEND)) &&
 	    !priv_check_cred(cred, PRIV_VFS_WRITE, 0))
 		priv_granted |= (VWRITE | VAPPEND);
 
-	if ((acc_mode & VADMIN) && !priv_check_cred(cred, PRIV_VFS_ADMIN, 0))
+	if ((accmode & VADMIN) && !priv_check_cred(cred, PRIV_VFS_ADMIN, 0))
 		priv_granted |= VADMIN;
 
 	/*
@@ -120,14 +120,14 @@ vaccess_acl_posix1e(enum vtype type, uid
 				dac_granted |= VREAD;
 			if (acl->acl_entry[i].ae_perm & ACL_WRITE)
 				dac_granted |= (VWRITE | VAPPEND);
-			if ((acc_mode & dac_granted) == acc_mode)
+			if ((accmode & dac_granted) == accmode)
 				return (0);
 
 			/*
 			 * XXXRW: Do privilege lookup here.
 			 */
-			if ((acc_mode & (dac_granted | priv_granted)) ==
-			    acc_mode) {
+			if ((accmode & (dac_granted | priv_granted)) ==
+			    accmode) {
 				if (privused != NULL)
 					*privused = 1;
 				return (0);
@@ -197,13 +197,13 @@ vaccess_acl_posix1e(enum vtype type, uid
 			if (acl->acl_entry[i].ae_perm & ACL_WRITE)
 				dac_granted |= (VWRITE | VAPPEND);
 			dac_granted &= acl_mask_granted;
-			if ((acc_mode & dac_granted) == acc_mode)
+			if ((accmode & dac_granted) == accmode)
 				return (0);
 			/*
 			 * XXXRW: Do privilege lookup here.
 			 */
-			if ((acc_mode & (dac_granted | priv_granted)) !=
-			    acc_mode)
+			if ((accmode & (dac_granted | priv_granted)) !=
+			    accmode)
 				goto error;
 
 			if (privused != NULL)
@@ -234,7 +234,7 @@ vaccess_acl_posix1e(enum vtype type, uid
 				dac_granted |= (VWRITE | VAPPEND);
 			dac_granted  &= acl_mask_granted;
 
-			if ((acc_mode & dac_granted) == acc_mode)
+			if ((accmode & dac_granted) == accmode)
 				return (0);
 
 			group_matched = 1;
@@ -252,7 +252,7 @@ vaccess_acl_posix1e(enum vtype type, uid
 				dac_granted |= (VWRITE | VAPPEND);
 			dac_granted  &= acl_mask_granted;
 
-			if ((acc_mode & dac_granted) == acc_mode)
+			if ((accmode & dac_granted) == accmode)
 				return (0);
 
 			group_matched = 1;
@@ -285,8 +285,8 @@ vaccess_acl_posix1e(enum vtype type, uid
 				/*
 				 * XXXRW: Do privilege lookup here.
 				 */
-				if ((acc_mode & (dac_granted | priv_granted))
-				    != acc_mode)
+				if ((accmode & (dac_granted | priv_granted))
+				    != accmode)
 					break;
 
 				if (privused != NULL)
@@ -309,8 +309,8 @@ vaccess_acl_posix1e(enum vtype type, uid
 				/*
 				 * XXXRW: Do privilege lookup here.
 				 */
-				if ((acc_mode & (dac_granted | priv_granted))
-				    != acc_mode)
+				if ((accmode & (dac_granted | priv_granted))
+				    != accmode)
 					break;
 
 				if (privused != NULL)
@@ -339,19 +339,19 @@ vaccess_acl_posix1e(enum vtype type, uid
 	if (acl_other->ae_perm & ACL_WRITE)
 		dac_granted |= (VWRITE | VAPPEND);
 
-	if ((acc_mode & dac_granted) == acc_mode)
+	if ((accmode & dac_granted) == accmode)
 		return (0);
 	/*
 	 * XXXRW: Do privilege lookup here.
 	 */
-	if ((acc_mode & (dac_granted | priv_granted)) == acc_mode) {
+	if ((accmode & (dac_granted | priv_granted)) == accmode) {
 		if (privused != NULL)
 			*privused = 1;
 		return (0);
 	}
 
 error:
-	return ((acc_mode & VADMIN) ? EPERM : EACCES);
+	return ((accmode & VADMIN) ? EPERM : EACCES);
 }
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 22:05:21 2008
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 4C739106567A;
	Tue, 28 Oct 2008 22:05:21 +0000 (UTC)
	(envelope-from marius@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 38FD48FC13;
	Tue, 28 Oct 2008 22:05:21 +0000 (UTC)
	(envelope-from marius@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 m9SM5LUe005196;
	Tue, 28 Oct 2008 22:05:21 GMT (envelope-from marius@svn.freebsd.org)
Received: (from marius@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SM5L0H005195;
	Tue, 28 Oct 2008 22:05:21 GMT (envelope-from marius@svn.freebsd.org)
Message-Id: <200810282205.m9SM5L0H005195@svn.freebsd.org>
From: Marius Strobl 
Date: Tue, 28 Oct 2008 22:05:21 +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: r184428 - head/sys/sparc64/pci
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, 28 Oct 2008 22:05:21 -0000

Author: marius
Date: Tue Oct 28 22:05:20 2008
New Revision: 184428
URL: http://svn.freebsd.org/changeset/base/184428

Log:
  - Turn off interrupts instead of only entering a critical section
    while doing the block store workaround so we restore the correct
    floating-point registers state in case of nested floating-point
    operations resulting from nested interrupts. This allows the
    VIS-based block copy/zero functions to be used on machines
    requiring this workaround. Alternatively, we could take care of
    saving the floating-point registers here, which would be more
    inefficiently though and also involves turning off interrupts.
  - It turns out that the SCZ_PCI_DMA_SYNC register doesn't work
    like the TOMXMS_PCI_DMA_SYNC_PEND one (but more like the
    corresponding register in of Hummingbird and Sabre bridges)
    and writing the INO of the respective device to it causes a
    Safari bus error. However, due to the Schizo errata I-23,
    SCZ_PCI_DMA_SYNC can't be used as intended either, so remove
    consistent DMA syncing for Schzio bridges for now, which means
    that add-on cards with non-"sun4u compliant" (whatever that
    means exactly) PCI-PCI-bridges should be avoided until the
    proper workaround is implemented. [1]
  
  Reported by:	Michael Moll [1]

Modified:
  head/sys/sparc64/pci/schizo.c

Modified: head/sys/sparc64/pci/schizo.c
==============================================================================
--- head/sys/sparc64/pci/schizo.c	Tue Oct 28 21:58:48 2008	(r184427)
+++ head/sys/sparc64/pci/schizo.c	Tue Oct 28 22:05:20 2008	(r184428)
@@ -175,7 +175,6 @@ struct schizo_dmasync {
 	driver_filter_t		*sds_handler;
 	void			*sds_arg;
 	void			*sds_cookie;
-	bus_size_t		sds_syncreg;
 	uint64_t		sds_syncval;
 	u_int			sds_bswar;
 };
@@ -955,25 +954,25 @@ schizo_dmasync(void *arg)
 	static u_char buf[VIS_BLOCKSIZE] __aligned(VIS_BLOCKSIZE);
 	struct schizo_dmasync *sds = arg;
 	struct schizo_softc *sc = sds->sds_sc;
-	uint64_t reg;
+	register_t reg, s;
 	int timeout;
 
-	SCHIZO_PCI_WRITE_8(sc, sds->sds_syncreg, sds->sds_syncval);
+	SCHIZO_PCI_WRITE_8(sc, TOMXMS_PCI_DMA_SYNC_PEND, sds->sds_syncval);
 	timeout = 1000000;
-	for (; (SCHIZO_PCI_READ_8(sc, sds->sds_syncreg) &
+	for (; (SCHIZO_PCI_READ_8(sc, TOMXMS_PCI_DMA_SYNC_PEND) &
 	    sds->sds_syncval) != 0;)
 		if (--timeout < 0)
 			panic("%s: DMA does not sync", __func__);
 
 	if (sds->sds_bswar != 0) {
-		critical_enter();
+		s = intr_disable();
 		reg = rd(fprs);
 		wr(fprs, reg | FPRS_FEF, 0);
-		__asm__ __volatile__("stda %%f0, [%0] %1"
+		__asm __volatile("stda %%f0, [%0] %1"
 		    : : "r" (buf), "n" (ASI_BLK_COMMIT_S));
-		wr(fprs, reg, 0);
 		membar(Sync);
-		critical_exit();
+		wr(fprs, reg, 0);
+		intr_restore(s);
 	}
 	return (sds->sds_handler(sds->sds_arg));
 }
@@ -1039,8 +1038,8 @@ schizo_setup_intr(device_t dev, device_t
 	}
 
 	/*
-	 * Schizo revision >= 2.3 (i.e. version >= 5) and Tomatillo bridges
-	 * need to be manually told to sync DMA writes.
+	 * Tomatillo and XMITS bridges need to be told to sync DMA writes
+	 * based on the INO of the respective device.
 	 * Tomatillo revision <= 2.3 (i.e. version <= 4) bridges additionally
 	 * need a block store as a workaround for a hardware bug.
 	 * XXX setup of the wrapper and the contents of schizo_dmasync()
@@ -1049,15 +1048,12 @@ schizo_setup_intr(device_t dev, device_t
 	 * is newbus'ified, so the wrapper isn't only applied for interrupt
 	 * handlers but also for polling(4) callbacks.
 	 */
-	if ((sc->sc_mode == SCHIZO_MODE_SCZ && sc->sc_ver >= 5) ||
-	    sc->sc_mode == SCHIZO_MODE_TOM) {
+	if (sc->sc_mode == SCHIZO_MODE_TOM || sc->sc_mode == SCHIZO_MODE_XMS) {
 		sds = malloc(sizeof(*sds), M_DEVBUF, M_NOWAIT | M_ZERO);
 		if (sds == NULL)
 			return (ENOMEM);
 		sds->sds_sc = sc;
 		sds->sds_arg = arg;
-		sds->sds_syncreg = sc->sc_mode == SCHIZO_MODE_SCZ ?
-		    SCZ_PCI_DMA_SYNC : TOMXMS_PCI_DMA_SYNC_PEND;
 		sds->sds_syncval = 1ULL << INTINO(vec);
 		if (sc->sc_mode == SCHIZO_MODE_TOM && sc->sc_ver <= 4)
 			sds->sds_bswar = 1;

From owner-svn-src-head@FreeBSD.ORG  Tue Oct 28 22:09:30 2008
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 A5372106567F;
	Tue, 28 Oct 2008 22:09:30 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 914B18FC08;
	Tue, 28 Oct 2008 22:09:30 +0000 (UTC)
	(envelope-from nwhitehorn@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 m9SM9UGs005357;
	Tue, 28 Oct 2008 22:09:30 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9SM9UMQ005356;
	Tue, 28 Oct 2008 22:09:30 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <200810282209.m9SM9UMQ005356@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Tue, 28 Oct 2008 22:09:30 +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: r184429 - head/sys/powerpc/powermac
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, 28 Oct 2008 22:09:30 -0000

Author: nwhitehorn
Date: Tue Oct 28 22:09:30 2008
New Revision: 184429
URL: http://svn.freebsd.org/changeset/base/184429

Log:
  DBDMA can transfer a maximum of 64K - 1 bytes per descriptor, as the byte
  count field is 16 bits. Inform ATA of this fact.
  
  Reported by:	Marco Trillo

Modified:
  head/sys/powerpc/powermac/ata_dbdma.c

Modified: head/sys/powerpc/powermac/ata_dbdma.c
==============================================================================
--- head/sys/powerpc/powermac/ata_dbdma.c	Tue Oct 28 22:05:20 2008	(r184428)
+++ head/sys/powerpc/powermac/ata_dbdma.c	Tue Oct 28 22:09:30 2008	(r184429)
@@ -275,6 +275,12 @@ ata_dbdma_dmainit(device_t dev)
 	sc->sc_ch.dma.load = ata_dbdma_load;
 	sc->sc_ch.dma.reset = ata_dbdma_reset;
 
+	/*
+	 * DBDMA's field for transfer size is 16 bits. This will overflow
+	 * if we try to do a 64K transfer, so stop short of 64K.
+	 */
+	sc->sc_ch.dma.segsize = 126 * DEV_BSIZE;
+
 	sc->sc_ch.hw.status = ata_dbdma_status;
 
 	mtx_init(&sc->dbdma_mtx, "ATA DBDMA", NULL, MTX_DEF);

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 08:08:55 2008
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 F166E106564A;
	Wed, 29 Oct 2008 08:08:55 +0000 (UTC)
	(envelope-from n_hibma@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C5B378FC1D;
	Wed, 29 Oct 2008 08:08:55 +0000 (UTC)
	(envelope-from n_hibma@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 m9T88thi016762;
	Wed, 29 Oct 2008 08:08:55 GMT (envelope-from n_hibma@svn.freebsd.org)
Received: (from n_hibma@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9T88tDD016760;
	Wed, 29 Oct 2008 08:08:55 GMT (envelope-from n_hibma@svn.freebsd.org)
Message-Id: <200810290808.m9T88tDD016760@svn.freebsd.org>
From: Nick Hibma 
Date: Wed, 29 Oct 2008 08:08:55 +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: r184436 - head/sys/dev/usb
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: Wed, 29 Oct 2008 08:08:56 -0000

Author: n_hibma
Date: Wed Oct 29 08:08:55 2008
New Revision: 184436
URL: http://svn.freebsd.org/changeset/base/184436

Log:
  Add the device ID for the mass storage device that appears before the
  modem appears to facilitate faster switching to modem mode.

Modified:
  head/sys/dev/usb/u3g.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Wed Oct 29 07:16:49 2008	(r184435)
+++ head/sys/dev/usb/u3g.c	Wed Oct 29 08:08:55 2008	(r184436)
@@ -51,14 +51,12 @@
 #endif
 #include "usbdevs.h"
 
-//#define U3G_DEBUG
+#define U3G_DEBUG
 #ifdef U3G_DEBUG
 #define DPRINTF(x...)		do { if (u3gdebug) device_printf(sc->sc_dev, ##x); } while (0)
-#define DPRINTFN(n, x...)	do { if (u3gdebug > (n)) device_printf(self, ##x); } while (0)
 int	u3gdebug = 1;
 #else
 #define DPRINTF(x...)		/* nop */
-#define DPRINTFN(n, x...)	/* nop */
 #endif
 
 #define U3G_MAXPORTS		4
@@ -135,7 +133,8 @@ static const struct u3g_dev_type_s u3g_d
 	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAXHSUPA },		U3GSP_HSDPA,	U3GFL_NONE },
 	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G },	U3GSP_UMTS,	U3GFL_NONE },
 	/* OEM: Qualcomm, Inc. */
-	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GSP_CDMA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_ZTE_STOR },	U3GSP_CDMA,	U3GFL_SCSI_EJECT },
+	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GSP_CDMA,	U3GFL_SCSI_EJECT },
 	/* OEM: Huawei */
 	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },		U3GSP_HSDPA,	U3GFL_HUAWEI_INIT },
 	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },		U3GSP_HSPA,	U3GFL_HUAWEI_INIT },

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Wed Oct 29 07:16:49 2008	(r184435)
+++ head/sys/dev/usb/usbdevs	Wed Oct 29 08:08:55 2008	(r184436)
@@ -1996,6 +1996,7 @@ product QUALCOMM CDMA_MSM	0x6000	CDMA Te
 product QUALCOMM2 RWT_FCT	0x3100	RWT FCT-CDMA 2000 1xRTT modem
 product QUALCOMM2 CDMA_MSM	0x3196	CDMA Technologies MSM modem
 product QUALCOMMINC CDMA_MSM	0x0001	CDMA Technologies MSM modem
+product QUALCOMMINC ZTE_STOR	0x2000	USB ZTE Storage
 
 /* Qtronix products */
 product QTRONIX 980N		0x2011	Scorpion-980N keyboard

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 08:13:18 2008
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 BE83E1065679;
	Wed, 29 Oct 2008 08:13:18 +0000 (UTC) (envelope-from rink@rink.nu)
Received: from mx1.rink.nu (gloom.rink.nu [213.34.49.2])
	by mx1.freebsd.org (Postfix) with ESMTP id 7BFF18FC12;
	Wed, 29 Oct 2008 08:13:18 +0000 (UTC) (envelope-from rink@rink.nu)
Received: from localhost (localhost [127.0.0.1])
	by mx1.rink.nu (Postfix) with ESMTP id 10DF56D42B;
	Wed, 29 Oct 2008 09:13:47 +0100 (CET)
X-Virus-Scanned: amavisd-new at rink.nu
Received: from mx1.rink.nu ([213.34.49.2])
	by localhost (gloom.rink.nu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 5C+VoZKHMySs; Wed, 29 Oct 2008 09:13:44 +0100 (CET)
Received: by mx1.rink.nu (Postfix, from userid 1000)
	id F1DC36D423; Wed, 29 Oct 2008 09:13:43 +0100 (CET)
Date: Wed, 29 Oct 2008 09:13:43 +0100
From: Rink Springer 
To: Nick Hibma 
Message-ID: <20081029081343.GA28461@rink.nu>
References: <200810290808.m9T88tDD016760@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200810290808.m9T88tDD016760@svn.freebsd.org>
User-Agent: Mutt/1.5.18 (2008-05-17)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184436 - head/sys/dev/usb
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: Wed, 29 Oct 2008 08:13:18 -0000

On Wed, Oct 29, 2008 at 08:08:55AM +0000, Nick Hibma wrote:
> Modified: head/sys/dev/usb/u3g.c
> ==============================================================================
> --- head/sys/dev/usb/u3g.c	Wed Oct 29 07:16:49 2008	(r184435)
> +++ head/sys/dev/usb/u3g.c	Wed Oct 29 08:08:55 2008	(r184436)
> @@ -51,14 +51,12 @@
>  #endif
>  #include "usbdevs.h"
>  
> -//#define U3G_DEBUG
> +#define U3G_DEBUG
>  #ifdef U3G_DEBUG
>  #define DPRINTF(x...)		do { if (u3gdebug) device_printf(sc->sc_dev, ##x); } while (0)
> -#define DPRINTFN(n, x...)	do { if (u3gdebug > (n)) device_printf(self, ##x); } while (0)
>  int	u3gdebug = 1;
>  #else
>  #define DPRINTF(x...)		/* nop */
> -#define DPRINTFN(n, x...)	/* nop */
>  #endif

Were these changes also intended?

-- 
Rink P.W. Springer                                - http://rink.nu
"Anyway boys, this is America. Just because you get more votes doesn't
 mean you win." - Fox Mulder

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 08:20:08 2008
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 B8BB51065687;
	Wed, 29 Oct 2008 08:20:08 +0000 (UTC)
	(envelope-from bzeeb-lists@lists.zabbadoz.net)
Received: from mail.cksoft.de (mail.cksoft.de [62.111.66.27])
	by mx1.freebsd.org (Postfix) with ESMTP id 6D4B68FC16;
	Wed, 29 Oct 2008 08:20:08 +0000 (UTC)
	(envelope-from bzeeb-lists@lists.zabbadoz.net)
Received: from localhost (amavis.str.cksoft.de [192.168.74.71])
	by mail.cksoft.de (Postfix) with ESMTP id 4B0BB41C4AB;
	Wed, 29 Oct 2008 09:20:07 +0100 (CET)
X-Virus-Scanned: amavisd-new at cksoft.de
Received: from mail.cksoft.de ([62.111.66.27])
	by localhost (amavis.str.cksoft.de [192.168.74.71]) (amavisd-new,
	port 10024)
	with ESMTP id Cv8DIiiBo+aa; Wed, 29 Oct 2008 09:20:05 +0100 (CET)
Received: by mail.cksoft.de (Postfix, from userid 66)
	id BD8DE41C6B4; Wed, 29 Oct 2008 09:20:05 +0100 (CET)
Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net
	[10.111.66.10])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mail.int.zabbadoz.net (Postfix) with ESMTP id 0776444487F;
	Wed, 29 Oct 2008 08:18:09 +0000 (UTC)
Date: Wed, 29 Oct 2008 08:18:08 +0000 (UTC)
From: "Bjoern A. Zeeb" 
X-X-Sender: bz@maildrop.int.zabbadoz.net
To: Nick Hibma 
In-Reply-To: <200810290808.m9T88tDD016760@svn.freebsd.org>
Message-ID: <20081029081728.M2978@maildrop.int.zabbadoz.net>
References: <200810290808.m9T88tDD016760@svn.freebsd.org>
X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184436 - head/sys/dev/usb
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: Wed, 29 Oct 2008 08:20:08 -0000

On Wed, 29 Oct 2008, Nick Hibma wrote:

> Author: n_hibma
> Date: Wed Oct 29 08:08:55 2008
> New Revision: 184436
> URL: http://svn.freebsd.org/changeset/base/184436
>
> Log:
>  Add the device ID for the mass storage device that appears before the
>  modem appears to facilitate faster switching to modem mode.
>
> Modified:
>  head/sys/dev/usb/u3g.c
>  head/sys/dev/usb/usbdevs
>
> Modified: head/sys/dev/usb/u3g.c
> ==============================================================================
> --- head/sys/dev/usb/u3g.c	Wed Oct 29 07:16:49 2008	(r184435)
> +++ head/sys/dev/usb/u3g.c	Wed Oct 29 08:08:55 2008	(r184436)
> @@ -51,14 +51,12 @@
> #endif
> #include "usbdevs.h"
>
> -//#define U3G_DEBUG
> +#define U3G_DEBUG

^^^^^^^^^^^^^^^^^^^^^
you did not want to commit this, did you?


-- 
Bjoern A. Zeeb              Stop bit received. Insert coin for new game.

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 11:03:15 2008
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 ED7D41065672;
	Wed, 29 Oct 2008 11:03:15 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DCE018FC1F;
	Wed, 29 Oct 2008 11:03:15 +0000 (UTC) (envelope-from bz@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 m9TB3Ftk021100;
	Wed, 29 Oct 2008 11:03:15 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TB3FUU021099;
	Wed, 29 Oct 2008 11:03:15 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <200810291103.m9TB3FUU021099@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Wed, 29 Oct 2008 11:03:15 +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: r184437 - head/sys/dev/usb
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: Wed, 29 Oct 2008 11:03:16 -0000

Author: bz
Date: Wed Oct 29 11:03:15 2008
New Revision: 184437
URL: http://svn.freebsd.org/changeset/base/184437

Log:
  Comment out #define turning on debugging which went in with r184436 and
  which is also in conf/NOTES and thus defined twice when building LINT.

Modified:
  head/sys/dev/usb/u3g.c

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Wed Oct 29 08:08:55 2008	(r184436)
+++ head/sys/dev/usb/u3g.c	Wed Oct 29 11:03:15 2008	(r184437)
@@ -51,7 +51,7 @@
 #endif
 #include "usbdevs.h"
 
-#define U3G_DEBUG
+/* #define U3G_DEBUG */
 #ifdef U3G_DEBUG
 #define DPRINTF(x...)		do { if (u3gdebug) device_printf(sc->sc_dev, ##x); } while (0)
 int	u3gdebug = 1;

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 11:34:42 2008
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 85B411065674;
	Wed, 29 Oct 2008 11:34:42 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from mail10.syd.optusnet.com.au (mail10.syd.optusnet.com.au
	[211.29.132.191])
	by mx1.freebsd.org (Postfix) with ESMTP id 1E3788FC25;
	Wed, 29 Oct 2008 11:34:41 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from besplex.bde.org (c122-106-151-199.carlnfd1.nsw.optusnet.com.au
	[122.106.151.199])
	by mail10.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	m9TBYcd4007961
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Wed, 29 Oct 2008 22:34:40 +1100
Date: Wed, 29 Oct 2008 22:34:38 +1100 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Maxim Sobolev 
In-Reply-To: <4906ECC1.4080907@FreeBSD.org>
Message-ID: <20081029220255.B4187@besplex.bde.org>
References: <200810261858.m9QIw4YV091893@svn.freebsd.org>
	<200810271411.11813.jhb@freebsd.org>
	<20081028202701.E85964@delplex.bde.org>
	<4906ECC1.4080907@FreeBSD.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org, John Baldwin ,
	Bruce Evans 
Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386
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: Wed, 29 Oct 2008 11:34:42 -0000

On Tue, 28 Oct 2008, Maxim Sobolev wrote:

> Bruce Evans wrote:
>> On Mon, 27 Oct 2008, John Baldwin wrote:
>> 
>>> On Sunday 26 October 2008 02:58:04 pm Maxim Sobolev wrote:
>>>> Author: sobomax
>>>> Date: Sun Oct 26 18:58:04 2008
>>>> New Revision: 184293
>>>> URL: http://svn.freebsd.org/changeset/base/184293
>>>> 
>>>> Log:
>>>>   Fix division by zero panic if kern.hz less than 32.
>>>> 
>>>>   MFC after:    1 day
>>> 
>>> This is wrong.  In the case you are worried about here, lapic_timer_hz is 
>>> less
>>> than 128.  There is no way you are going to fire stathz 128 times per 
>>> second
>>> from a timer running at < 128 hz.  You are effectively running stathz at
>>> lapic_timer_hz, so I would just set stathz = lapic_timer_hz in this case.
>> 
>> stathz needs to be about 128 to work as intended, at least for SCHED_4BSD.
>>> ...
>> Also, hz = 10 cannot work on i386 without lapic_timer, since the i8254 
>> timer
>> has a maximum interrupt period of 55 ms and thus a minimum frequency of
>> 18.2 Hz.  Attempts to set it to 10 Hz cause similar bugs to the ones here
>> -- the best approximation of 18.2 is (supposed to be) used, but the system
>> is not informed about the enormous error in this approximation and still
>> thinks that 10 Hz is used.
>
> Does it suggest that we simply need to place lower limit of 128 on 
> lapic_timer_hz and lower limit of 18 on i8254 timer? As far as I understand 
> timer frequency could be higher than actual HZ (at least lapic code suggest 
> that it can). Will it help or cause any other issues?

I use 100 for the minimum stathz but wouldn't want it to be much lower
than that.  I've tried much lower values (10 or 20) and noticed that
this mainly makes statistics fairly innacurate, as you might expect
(e.g., 180 seconds sys time for makeworld might become 160 or 200).
SCHED_4BSD requires stathz to be about 128 but doesn't need this and
can survive with weird values of stathz.

The limit for i8254 should be 19 if anything, since the actual limit
of 18.2 is not supported and the error between 18 and 18.2 is relatively
large.  Due to the nature of the interface, any frequency >= 18.2 can
be represented precisely (more precisely at low frequencies), but there
is no simple way to get anything lower than 18.2.  I don't like such
limits in general since they mainly get in the way of trying unusual
configurations which should be under control of the user, but here they
may be machine-generated.

For emulation, I think you don't want lapic_timer_hz to be large any more
than stathz or the i8254 interrupt frequency.  The emulator might not
like interrupting at a high rate, irrespective of the interrupt source,
depending on how much it does in software for each type of source.  So
lapic_timer_hz = hz = stathz = ~100 might be best.  (Once we have interrupted
at 100 Hz, there we can use this for hz at no extra cost in the emulator).

Also, since the lapic timer is more complicated than the i8254 timer,
interrupts on it might be more expensive, so using lapic_timer might
be a pessimization, except it normally reduces the number of interrupt
sources.  But use of the RTC can be avoided too.

Bruce

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 12:11:48 2008
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 E6C9E1065679;
	Wed, 29 Oct 2008 12:11:48 +0000 (UTC)
	(envelope-from davidxu@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D6A068FC39;
	Wed, 29 Oct 2008 12:11:48 +0000 (UTC)
	(envelope-from davidxu@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 m9TCBm2i022372;
	Wed, 29 Oct 2008 12:11:48 GMT (envelope-from davidxu@svn.freebsd.org)
Received: (from davidxu@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TCBmm7022371;
	Wed, 29 Oct 2008 12:11:48 GMT (envelope-from davidxu@svn.freebsd.org)
Message-Id: <200810291211.m9TCBmm7022371@svn.freebsd.org>
From: David Xu 
Date: Wed, 29 Oct 2008 12:11:48 +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: r184438 - head/sys/kern
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: Wed, 29 Oct 2008 12:11:49 -0000

Author: davidxu
Date: Wed Oct 29 12:11:48 2008
New Revision: 184438
URL: http://svn.freebsd.org/changeset/base/184438

Log:
  If threads limit is exceeded, increase the totoal number
  of failures.

Modified:
  head/sys/kern/kern_thr.c

Modified: head/sys/kern/kern_thr.c
==============================================================================
--- head/sys/kern/kern_thr.c	Wed Oct 29 11:03:15 2008	(r184437)
+++ head/sys/kern/kern_thr.c	Wed Oct 29 12:11:48 2008	(r184438)
@@ -76,6 +76,7 @@ suword_lwpid(void *addr, lwpid_t lwpid)
 #endif
 
 extern int max_threads_per_proc;
+extern int max_threads_hits;
 
 static int create_thread(struct thread *td, mcontext_t *ctx,
 			 void (*start_func)(void *), void *arg,
@@ -154,8 +155,10 @@ create_thread(struct thread *td, mcontex
 	p = td->td_proc;
 
 	/* Have race condition but it is cheap. */
-	if (p->p_numthreads >= max_threads_per_proc)
+	if (p->p_numthreads >= max_threads_per_proc) {
+		++max_threads_hits;
 		return (EPROCLIM);
+	}
 
 	if (rtp != NULL) {
 		switch(rtp->type) {

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 13:36:24 2008
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 1D0B21065679;
	Wed, 29 Oct 2008 13:36:24 +0000 (UTC)
	(envelope-from ivoras@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D2E08FC1A;
	Wed, 29 Oct 2008 13:36:24 +0000 (UTC)
	(envelope-from ivoras@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 m9TDaNWj023911;
	Wed, 29 Oct 2008 13:36:23 GMT (envelope-from ivoras@svn.freebsd.org)
Received: (from ivoras@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TDaNCn023910;
	Wed, 29 Oct 2008 13:36:23 GMT (envelope-from ivoras@svn.freebsd.org)
Message-Id: <200810291336.m9TDaNCn023910@svn.freebsd.org>
From: Ivan Voras 
Date: Wed, 29 Oct 2008 13:36:23 +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: r184439 - head/sys/kern
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: Wed, 29 Oct 2008 13:36:24 -0000

Author: ivoras
Date: Wed Oct 29 13:36:23 2008
New Revision: 184439
URL: http://svn.freebsd.org/changeset/base/184439

Log:
  Introduce a new sysctl, kern.sched.topology_spec, that returns an XML
  dump of detected ULE CPU topology. This dump can be used to check the
  topology detection and for general system information.
  
  An example of CPU topology dump is:
  kern.sched.topology_spec: 
   
     0, 1, 2, 3, 4, 5, 6, 7
     
     
       
         0, 1, 2, 3
         
       
       
         4, 5, 6, 7
         
       
     
   
  
  
  Reviewed by:	jeff
  Approved by:	gnn (mentor)

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c	Wed Oct 29 12:11:48 2008	(r184438)
+++ head/sys/kern/sched_ule.c	Wed Oct 29 13:36:23 2008	(r184439)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #ifdef KTRACE
 #include 
 #include 
@@ -223,7 +224,7 @@ struct tdq {
 #define	TDQ_IDLE	2
 
 #ifdef SMP
-struct cpu_group *cpu_top;
+struct cpu_group *cpu_top;		/* CPU topology */
 
 #define	SCHED_AFFINITY_DEFAULT	(max(1, hz / 1000))
 #define	SCHED_AFFINITY(ts, t)	((ts)->ts_rltick > ticks - ((t) * affinity))
@@ -293,6 +294,9 @@ static inline struct tdq *sched_setcpu(s
 static inline struct mtx *thread_block_switch(struct thread *);
 static inline void thread_unblock_switch(struct thread *, struct mtx *);
 static struct mtx *sched_switch_migrate(struct tdq *, struct thread *, int);
+static int sysctl_kern_sched_topology_spec(SYSCTL_HANDLER_ARGS);
+static int sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, 
+    struct cpu_group *cg, int indent);
 #endif
 
 static void sched_setup(void *dummy);
@@ -2601,6 +2605,83 @@ sched_fork_exit(struct thread *td)
 	    &TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__);
 }
 
+#ifdef SMP
+
+/*
+ * Build the CPU topology dump string. Is recursively called to collect
+ * the topology tree.
+ */
+static int
+sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, struct cpu_group *cg,
+    int indent)
+{
+	int i, first;
+
+	sbuf_printf(sb, "%*s\n", indent,
+	    "", indent, cg->cg_level);
+	sbuf_printf(sb, "%*s ", indent, "",
+	    cg->cg_count, cg->cg_mask);
+	first = TRUE;
+	for (i = 0; i < MAXCPU; i++) {
+		if ((cg->cg_mask & (1 << i)) != 0) {
+			if (!first)
+				sbuf_printf(sb, ", ");
+			else
+				first = FALSE;
+			sbuf_printf(sb, "%d", i);
+		}
+	}
+	sbuf_printf(sb, "\n");
+
+	sbuf_printf(sb, "%*s ", indent, "");
+	if (cg->cg_flags != 0) {
+		if ((cg->cg_flags & CG_FLAG_HTT) != 0)
+			sbuf_printf(sb, "HTT group");
+		if ((cg->cg_flags & CG_FLAG_THREAD) != 0)
+			sbuf_printf(sb, "SMT group");
+	}
+	sbuf_printf(sb, "\n");
+
+	if (cg->cg_children > 0) {
+		sbuf_printf(sb, "%*s \n", indent, "");
+		for (i = 0; i < cg->cg_children; i++)
+			sysctl_kern_sched_topology_spec_internal(sb, 
+			    &cg->cg_child[i], indent+2);
+		sbuf_printf(sb, "%*s \n", indent, "");
+	}
+	sbuf_printf(sb, "%*s\n", indent, "");
+	return (0);
+}
+
+/*
+ * Sysctl handler for retrieving topology dump. It's a wrapper for
+ * the recursive sysctl_kern_smp_topology_spec_internal().
+ */
+static int
+sysctl_kern_sched_topology_spec(SYSCTL_HANDLER_ARGS)
+{
+	struct sbuf *topo;
+	int err;
+
+	KASSERT(cpu_top != NULL, ("cpu_top isn't initialized"));
+
+	topo = sbuf_new(NULL, NULL, 100, SBUF_AUTOEXTEND);
+	if (topo == NULL)
+		return (ENOMEM);
+
+	sbuf_printf(topo, "\n");
+	err = sysctl_kern_sched_topology_spec_internal(topo, cpu_top, 1);
+	sbuf_printf(topo, "\n");
+
+	if (err == 0) {
+		sbuf_finish(topo);
+		err = SYSCTL_OUT(req, sbuf_data(topo), sbuf_len(topo));
+	}
+	sbuf_delete(topo);
+	return (err);
+}
+#endif
+
 SYSCTL_NODE(_kern, OID_AUTO, sched, CTLFLAG_RW, 0, "Scheduler");
 SYSCTL_STRING(_kern_sched, OID_AUTO, name, CTLFLAG_RD, "ULE", 0,
     "Scheduler name");
@@ -2630,6 +2711,11 @@ SYSCTL_INT(_kern_sched, OID_AUTO, steal_
     "Attempts to steal work from other cores before idling");
 SYSCTL_INT(_kern_sched, OID_AUTO, steal_thresh, CTLFLAG_RW, &steal_thresh, 0,
     "Minimum load on remote cpu before we'll steal");
+
+/* Retrieve SMP topology */
+SYSCTL_PROC(_kern_sched, OID_AUTO, topology_spec, CTLTYPE_STRING |
+    CTLFLAG_RD, NULL, 0, sysctl_kern_sched_topology_spec, "A", 
+    "XML dump of detected CPU topology");
 #endif
 
 /* ps compat.  All cpu percentages from ULE are weighted. */

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 13:44:04 2008
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 0BBDC1065688;
	Wed, 29 Oct 2008 13:44:04 +0000 (UTC) (envelope-from bms@FreeBSD.org)
Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com
	[66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id D33E18FC0A;
	Wed, 29 Oct 2008 13:44:03 +0000 (UTC) (envelope-from bms@FreeBSD.org)
Received: from compute2.internal (compute2.internal [10.202.2.42])
	by out1.messagingengine.com (Postfix) with ESMTP id D659D1897A9;
	Wed, 29 Oct 2008 09:44:02 -0400 (EDT)
Received: from heartbeat1.messagingengine.com ([10.202.2.160])
	by compute2.internal (MEProxy); Wed, 29 Oct 2008 09:44:02 -0400
X-Sasl-enc: OZ1+xAp7Bxanje71DPpt7VvPH7zk29KZG+Bd0ME9k5Op 1225287842
Received: from empiric.lon.incunabulum.net
	(82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254])
	by mail.messagingengine.com (Postfix) with ESMTPSA id 1AAF2D469;
	Wed, 29 Oct 2008 09:44:01 -0400 (EDT)
Message-ID: <490868A0.2000202@FreeBSD.org>
Date: Wed, 29 Oct 2008 13:44:00 +0000
From: "Bruce M. Simpson" 
User-Agent: Thunderbird 2.0.0.14 (X11/20080514)
MIME-Version: 1.0
To: Ivan Voras 
References: <200810291336.m9TDaNCn023910@svn.freebsd.org>
In-Reply-To: <200810291336.m9TDaNCn023910@svn.freebsd.org>
X-Enigmail-Version: 0.95.6
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184439 - head/sys/kern
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: Wed, 29 Oct 2008 13:44:04 -0000

Ivan Voras wrote:
> Log:
>   Introduce a new sysctl, kern.sched.topology_spec, that returns an XML
>   dump of detected ULE CPU topology. This dump can be used to check the
>   topology detection and for general system information.

This is kinda cool...

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 15:41:18 2008
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 6943410656A3;
	Wed, 29 Oct 2008 15:41:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net
	[IPv6:2001:470:1f10:75::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D1DC8FC17;
	Wed, 29 Oct 2008 15:41:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1])
	(authenticated bits=0)
	by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id m9TFf3Q4036267;
	Wed, 29 Oct 2008 11:41:12 -0400 (EDT) (envelope-from jhb@FreeBSD.org)
From: John Baldwin 
To: Nathan Whitehorn 
Date: Wed, 29 Oct 2008 11:11:47 -0400
User-Agent: KMail/1.9.7
References: <200810282209.m9SM9UMQ005356@svn.freebsd.org>
In-Reply-To: <200810282209.m9SM9UMQ005356@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200810291111.47677.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by
	milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]);
	Wed, 29 Oct 2008 11:41:12 -0400 (EDT)
X-Virus-Scanned: ClamAV 0.93.1/8537/Wed Oct 29 09:26:33 2008 on
	server.baldwin.cx
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.6 required=4.2 tests=BAYES_00,NO_RELAYS 
	autolearn=ham version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org
Subject: Re: svn commit: r184429 - head/sys/powerpc/powermac
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: Wed, 29 Oct 2008 15:41:18 -0000

On Tuesday 28 October 2008 06:09:30 pm Nathan Whitehorn wrote:
> Author: nwhitehorn
> Date: Tue Oct 28 22:09:30 2008
> New Revision: 184429
> URL: http://svn.freebsd.org/changeset/base/184429
> 
> Log:
>   DBDMA can transfer a maximum of 64K - 1 bytes per descriptor, as the byte
>   count field is 16 bits. Inform ATA of this fact.

You may want to use 32k transfers rather than 63k.  At least on the HT1000 
chipsets we got severe data corruption even with 63k transfers, and I'm not 
sure if some part of the kernel isn't dependent on power-of-2 transfers 
somehow.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 16:13:36 2008
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 799231065672;
	Wed, 29 Oct 2008 16:13:36 +0000 (UTC)
	(envelope-from scottl@samsco.org)
Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57])
	by mx1.freebsd.org (Postfix) with ESMTP id 2B57D8FC16;
	Wed, 29 Oct 2008 16:13:35 +0000 (UTC)
	(envelope-from scottl@samsco.org)
Received: from phobos.local ([192.168.254.200]) (authenticated bits=0)
	by pooker.samsco.org (8.14.2/8.14.2) with ESMTP id m9TGDT7e071843;
	Wed, 29 Oct 2008 10:13:29 -0600 (MDT)
	(envelope-from scottl@samsco.org)
Message-ID: <49088BA9.2000501@samsco.org>
Date: Wed, 29 Oct 2008 10:13:29 -0600
From: Scott Long 
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US;
	rv:1.8.1.13) Gecko/20080313 SeaMonkey/1.1.9
MIME-Version: 1.0
To: John Baldwin 
References: <200810282209.m9SM9UMQ005356@svn.freebsd.org>
	<200810291111.47677.jhb@freebsd.org>
In-Reply-To: <200810291111.47677.jhb@freebsd.org>
X-Enigmail-Version: 0.95.6
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Status: No, score=-4.4 required=3.8 tests=ALL_TRUSTED,BAYES_00
	autolearn=ham version=3.1.8
X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on pooker.samsco.org
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org, Nathan Whitehorn 
Subject: Re: svn commit: r184429 - head/sys/powerpc/powermac
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: Wed, 29 Oct 2008 16:13:36 -0000

John Baldwin wrote:
> On Tuesday 28 October 2008 06:09:30 pm Nathan Whitehorn wrote:
>> Author: nwhitehorn
>> Date: Tue Oct 28 22:09:30 2008
>> New Revision: 184429
>> URL: http://svn.freebsd.org/changeset/base/184429
>>
>> Log:
>>   DBDMA can transfer a maximum of 64K - 1 bytes per descriptor, as the byte
>>   count field is 16 bits. Inform ATA of this fact.
> 
> You may want to use 32k transfers rather than 63k.  At least on the HT1000 
> chipsets we got severe data corruption even with 63k transfers, and I'm not 
> sure if some part of the kernel isn't dependent on power-of-2 transfers 
> somehow.
> 

There are a number of places where direct I/O that is initiated by the
kernel works just fine for non-power-of-2 sizes and offsets,
particularly in GEOM taste routines and in several filesystem drivers.
I'm pretty sure I can also reliably demonstrate it from userland via
O_DIRECT.  Buffered I/O is a different matter, and there could possibly
be some edge cases that exist below the buffer layer.

Scott

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 16:17:35 2008
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 5EA451065679;
	Wed, 29 Oct 2008 16:17:35 +0000 (UTC)
	(envelope-from n_hibma@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 500DA8FC22;
	Wed, 29 Oct 2008 16:17:35 +0000 (UTC)
	(envelope-from n_hibma@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 m9TGHYbU027324;
	Wed, 29 Oct 2008 16:17:34 GMT (envelope-from n_hibma@svn.freebsd.org)
Received: (from n_hibma@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TGHYNr027322;
	Wed, 29 Oct 2008 16:17:34 GMT (envelope-from n_hibma@svn.freebsd.org)
Message-Id: <200810291617.m9TGHYNr027322@svn.freebsd.org>
From: Nick Hibma 
Date: Wed, 29 Oct 2008 16:17:34 +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: r184441 - head/share/man/man4
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: Wed, 29 Oct 2008 16:17:35 -0000

Author: n_hibma
Date: Wed Oct 29 16:17:34 2008
New Revision: 184441
URL: http://svn.freebsd.org/changeset/base/184441

Log:
  - Add documentation on how to temporarily display the umass devices that
    are automatically hidden by the u3gstub device.
  - Add a link to the u3g driver man page for u3gstub.

Modified:
  head/share/man/man4/Makefile
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/Makefile
==============================================================================
--- head/share/man/man4/Makefile	Wed Oct 29 15:52:22 2008	(r184440)
+++ head/share/man/man4/Makefile	Wed Oct 29 16:17:34 2008	(r184441)
@@ -553,6 +553,7 @@ MLINKS+=tl.4 if_tl.4
 MLINKS+=tun.4 if_tun.4
 MLINKS+=tx.4 if_tx.4
 MLINKS+=txp.4 if_txp.4
+MLINKS+=u3g.4 u3gstub.4
 MLINKS+=udav.4 if_udav.4
 MLINKS+=ural.4 if_ural.4
 MLINKS+=vge.4 if_vge.4

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Wed Oct 29 15:52:22 2008	(r184440)
+++ head/share/man/man4/u3g.4	Wed Oct 29 16:17:34 2008	(r184441)
@@ -2,7 +2,7 @@
 .\" Copyright (c) 2008 AnyWi Technologies
 .\" All rights reserved.
 .\"
-.\" This code is derived from uark.c 
+.\" This code is derived from uark.c
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -76,18 +76,26 @@ Novatal MC950D
 .It
 Sierra cards
 .El
-(See /sys/dev/u3g.c for the complete list of supported cards for each vendor
-mentioned above).
+.Pp
+See /sys/dev/u3g.c for the complete list of supported cards for each vendor
+mentioned above.
 .Pp
 The supported 3G cards provide the necessary modem port for ppp,
 pppd, or mpd connections as well as extra ports (depending on the specific
 device) to provide other functions (diagnostic port, SIM toolkit port)
 .Pp
-In some of these devices a mass storage device supported by the 
+In some of these devices a mass storage device supported by the
 .Xr umass 4
 driver is present which contains Windows and Mac OSX drivers. This device is
 hidden, unless the machine was booted in verbose (see
 .Xr boot 8 ).
+To temporarily unhide the device, set
+.Va debug.bootverbose
+to 1 using
+.Xr sysctl 8
+and replug the device. The
+.Xr u3gstub 4
+device will attach temporarily and detach within seconds.
 .Sh SEE ALSO
 .Xr tty 4 ,
 .Xr ucom 4 ,

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 18:10:40 2008
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 75154106568B;
	Wed, 29 Oct 2008 18:10:40 +0000 (UTC)
	(envelope-from sobomax@sippysoft.com)
Received: from sippysoft.com (gk1.360sip.com [72.236.70.240])
	by mx1.freebsd.org (Postfix) with ESMTP id 324628FC29;
	Wed, 29 Oct 2008 18:10:40 +0000 (UTC)
	(envelope-from sobomax@sippysoft.com)
Received: from [192.168.1.23] (S0106001372fd1e07.vs.shawcable.net
	[70.71.2.169]) (authenticated bits=0)
	by sippysoft.com (8.13.8/8.13.8) with ESMTP id m9THum92082010
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Wed, 29 Oct 2008 10:56:49 -0700 (PDT)
	(envelope-from sobomax@sippysoft.com)
Message-ID: <4908A3E0.8080005@sippysoft.com>
Date: Wed, 29 Oct 2008 10:56:48 -0700
From: Maxim Sobolev 
Organization: Sippy Software, Inc.
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: Bruce Evans 
References: <200810261858.m9QIw4YV091893@svn.freebsd.org>
	<200810271411.11813.jhb@freebsd.org>
	<20081028202701.E85964@delplex.bde.org>
	<4906ECC1.4080907@FreeBSD.org>
	<20081029220255.B4187@besplex.bde.org>
In-Reply-To: <20081029220255.B4187@besplex.bde.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG,
	src-committers@FreeBSD.ORG, John Baldwin 
Subject: Re: svn commit: r184293 - in head/sys: amd64/amd64 i386/i386
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: Wed, 29 Oct 2008 18:10:40 -0000

Bruce Evans wrote:
> lapic_timer_hz = hz = stathz = ~100 might be best.  (Once we have 
> interrupted
> at 100 Hz, there we can use this for hz at no extra cost in the emulator).

In't there more overhead in full userland context switch implied by HZ 
100 compared to (presumably)fast timer interrupt?

Regards,
-- 
Maksym Sobolyev
Sippy Software, Inc.
Internet Telephony (VoIP) Experts
T/F: +1-646-651-1110
Web: http://www.sippysoft.com

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 18:46:47 2008
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 BE8E81065677;
	Wed, 29 Oct 2008 18:46:47 +0000 (UTC) (envelope-from mp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B20F58FC1F;
	Wed, 29 Oct 2008 18:46:47 +0000 (UTC) (envelope-from mp@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 m9TIkltd030072;
	Wed, 29 Oct 2008 18:46:47 GMT (envelope-from mp@svn.freebsd.org)
Received: (from mp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TIklBk030071;
	Wed, 29 Oct 2008 18:46:47 GMT (envelope-from mp@svn.freebsd.org)
Message-Id: <200810291846.m9TIklBk030071@svn.freebsd.org>
From: Mark Peek 
Date: Wed, 29 Oct 2008 18:46:47 +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: r184443 - head/etc
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: Wed, 29 Oct 2008 18:46:47 -0000

Author: mp
Date: Wed Oct 29 18:46:47 2008
New Revision: 184443
URL: http://svn.freebsd.org/changeset/base/184443

Log:
  Explicitly set the shell to /bin/sh when MK_TCSH == no.
  
  Not objected to by:	sam

Modified:
  head/etc/Makefile

Modified: head/etc/Makefile
==============================================================================
--- head/etc/Makefile	Wed Oct 29 17:27:23 2008	(r184442)
+++ head/etc/Makefile	Wed Oct 29 18:46:47 2008	(r184443)
@@ -154,7 +154,7 @@ distribution:
 	    ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \
 		master.passwd nsmb.conf opieaccess ${DESTDIR}/etc;
 .if ${MK_TCSH} == "no"
-	sed -i "" -e 's;/bin/csh;;' ${DESTDIR}/etc/master.passwd
+	sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd
 .endif
 	pwd_mkdb ${PWD_MKDB_ENDIAN} -i -p -d ${DESTDIR}/etc \
 	    ${DESTDIR}/etc/master.passwd

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 18:49:38 2008
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 1D3D51065689;
	Wed, 29 Oct 2008 18:49:38 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0FFD78FC17;
	Wed, 29 Oct 2008 18:49:38 +0000 (UTC)
	(envelope-from brueffer@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 m9TInbDq030155;
	Wed, 29 Oct 2008 18:49:37 GMT
	(envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TInbHv030154;
	Wed, 29 Oct 2008 18:49:37 GMT
	(envelope-from brueffer@svn.freebsd.org)
Message-Id: <200810291849.m9TInbHv030154@svn.freebsd.org>
From: Christian Brueffer 
Date: Wed, 29 Oct 2008 18:49:37 +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: r184444 - head/share/man/man4
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: Wed, 29 Oct 2008 18:49:38 -0000

Author: brueffer
Date: Wed Oct 29 18:49:37 2008
New Revision: 184444
URL: http://svn.freebsd.org/changeset/base/184444

Log:
  Misc cleanup.

Modified:
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Wed Oct 29 18:46:47 2008	(r184443)
+++ head/share/man/man4/u3g.4	Wed Oct 29 18:49:37 2008	(r184444)
@@ -43,7 +43,7 @@ u3g_load="YES"
 The
 .Nm
 driver provides support for the multiple USB-to-serial interfaces exposed by
-many 3G usb/pccard modems.
+many 3G USB/PCCard modems.
 .Pp
 The device is accessed through the
 .Xr ucom 4
@@ -77,23 +77,27 @@ Novatal MC950D
 Sierra cards
 .El
 .Pp
-See /sys/dev/u3g.c for the complete list of supported cards for each vendor
+See
+.Pa /sys/dev/u3g.c
+for the complete list of supported cards for each vendor
 mentioned above.
 .Pp
 The supported 3G cards provide the necessary modem port for ppp,
 pppd, or mpd connections as well as extra ports (depending on the specific
-device) to provide other functions (diagnostic port, SIM toolkit port)
+device) to provide other functions (diagnostic port, SIM toolkit port).
 .Pp
 In some of these devices a mass storage device supported by the
 .Xr umass 4
-driver is present which contains Windows and Mac OSX drivers. This device is
-hidden, unless the machine was booted in verbose (see
-.Xr boot 8 ).
+driver is present which contains Windows and Mac OS X drivers.
+This device is
+hidden, unless the machine was booted in verbose mode (see
+.Xr boot 8 ) .
 To temporarily unhide the device, set
 .Va debug.bootverbose
 to 1 using
 .Xr sysctl 8
-and replug the device. The
+and replug the device.
+The
 .Xr u3gstub 4
 device will attach temporarily and detach within seconds.
 .Sh SEE ALSO
@@ -103,10 +107,11 @@ device will attach temporarily and detac
 .Sh HISTORY
 The
 .Nm
-driver
-appeared in
+driver appeared in
 .Fx 8.0 ,
-is based on the uark driver, and written by
+is based on the
+.Xr uark 4
+driver, and written by
 .An Andrea Guzzo Aq aguzzo@anywi.com
 in September 2008.
 .Sh AUTHORS
@@ -116,4 +121,4 @@ driver was written by
 .An Andrea Guzzo Aq aguzzo@anywi.com
 and
 .An Nick Hibma Aq n_hibma@freebsd.org .
-Hardware for testing provided by AnyWi Technologies, Leiden, NL.
+Hardware for testing was provided by AnyWi Technologies, Leiden, NL.

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 20:01:26 2008
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 A815D1065687;
	Wed, 29 Oct 2008 20:01:26 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9B2598FC25;
	Wed, 29 Oct 2008 20:01:26 +0000 (UTC) (envelope-from mav@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 m9TK1QAa031787;
	Wed, 29 Oct 2008 20:01:26 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TK1Qpv031781;
	Wed, 29 Oct 2008 20:01:26 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200810292001.m9TK1Qpv031781@svn.freebsd.org>
From: Alexander Motin 
Date: Wed, 29 Oct 2008 20:01:26 +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: r184452 - in head/sys: arm/at91 dev/mmc dev/sdhci
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: Wed, 29 Oct 2008 20:01:26 -0000

Author: mav
Date: Wed Oct 29 20:01:26 2008
New Revision: 184452
URL: http://svn.freebsd.org/changeset/base/184452

Log:
  Allow card reader bridge driver to report maximum supported transfer size.
  sdhci supports up to 65535 blocks transfers, at91_mci - one block.
  
  Enable multiblock operations disabled before to follow at91_mci driver
  limitations.
  
  Reviewed by:	imp@

Modified:
  head/sys/arm/at91/at91_mci.c
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcbrvar.h
  head/sys/dev/mmc/mmcsd.c
  head/sys/dev/mmc/mmcvar.h
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/arm/at91/at91_mci.c
==============================================================================
--- head/sys/arm/at91/at91_mci.c	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/arm/at91/at91_mci.c	Wed Oct 29 20:01:26 2008	(r184452)
@@ -642,6 +642,9 @@ at91_mci_read_ivar(device_t bus, device_
 	case MMCBR_IVAR_VDD:
 		*(int *)result = sc->host.ios.vdd;
 		break;
+	case MMCBR_IVAR_MAX_DATA:
+		*(int *)result = 1;
+		break;
 	}
 	return (0);
 }
@@ -682,6 +685,7 @@ at91_mci_write_ivar(device_t bus, device
 	case MMCBR_IVAR_HOST_OCR:
 	case MMCBR_IVAR_F_MIN:
 	case MMCBR_IVAR_F_MAX:
+	case MMCBR_IVAR_MAX_DATA:
 		return (EINVAL);
 	}
 	return (0);

Modified: head/sys/dev/mmc/mmc.c
==============================================================================
--- head/sys/dev/mmc/mmc.c	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/dev/mmc/mmc.c	Wed Oct 29 20:01:26 2008	(r184452)
@@ -1343,6 +1343,9 @@ mmc_read_ivar(device_t bus, device_t chi
 	case MMC_IVAR_ERASE_SECTOR:
 		*(int *)result = ivar->erase_sector;
 		break;
+	case MMC_IVAR_MAX_DATA:
+		*(int *)result = mmcbr_get_max_data(bus);
+		break;
 	}
 	return (0);
 }

Modified: head/sys/dev/mmc/mmcbrvar.h
==============================================================================
--- head/sys/dev/mmc/mmcbrvar.h	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/dev/mmc/mmcbrvar.h	Wed Oct 29 20:01:26 2008	(r184452)
@@ -72,6 +72,7 @@ enum mmcbr_device_ivars {
     MMCBR_IVAR_VDD,
     MMCBR_IVAR_CAPS,
     MMCBR_IVAR_TIMING,
+    MMCBR_IVAR_MAX_DATA,
 //    MMCBR_IVAR_,
 };
 
@@ -94,6 +95,7 @@ MMCBR_ACCESSOR(power_mode, POWER_MODE, i
 MMCBR_ACCESSOR(vdd, VDD, int)
 MMCBR_ACCESSOR(caps, CAPS, int)
 MMCBR_ACCESSOR(timing, TIMING, int)
+MMCBR_ACCESSOR(max_data, MAX_DATA, int)
 
 static int __inline
 mmcbr_update_ios(device_t dev)

Modified: head/sys/dev/mmc/mmcsd.c
==============================================================================
--- head/sys/dev/mmc/mmcsd.c	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/dev/mmc/mmcsd.c	Wed Oct 29 20:01:26 2008	(r184452)
@@ -81,8 +81,6 @@ struct mmcsd_softc {
 	int running;
 };
 
-#define	MULTI_BLOCK_BROKEN
-
 /* bus entry points */
 static int mmcsd_probe(device_t dev);
 static int mmcsd_attach(device_t dev);
@@ -235,12 +233,7 @@ mmcsd_rw(struct mmcsd_softc *sc, struct 
 	while (block < end) {
 		char *vaddr = bp->bio_data +
 		    (block - bp->bio_pblkno) * sz;
-		int numblocks;
-#ifdef MULTI_BLOCK
-		numblocks = end - block;
-#else
-		numblocks = 1;
-#endif
+		int numblocks = min(end - block, mmc_get_max_data(dev));
 		memset(&req, 0, sizeof(req));
     		memset(&cmd, 0, sizeof(cmd));
 		memset(&stop, 0, sizeof(stop));

Modified: head/sys/dev/mmc/mmcvar.h
==============================================================================
--- head/sys/dev/mmc/mmcvar.h	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/dev/mmc/mmcvar.h	Wed Oct 29 20:01:26 2008	(r184452)
@@ -68,6 +68,7 @@ enum mmc_device_ivars {
     MMC_IVAR_CARD_TYPE,
     MMC_IVAR_BUS_WIDTH,
     MMC_IVAR_ERASE_SECTOR,
+    MMC_IVAR_MAX_DATA,
 //    MMC_IVAR_,
 };
 
@@ -87,5 +88,6 @@ MMC_ACCESSOR(high_cap, HIGH_CAP, int)
 MMC_ACCESSOR(card_type, CARD_TYPE, int)
 MMC_ACCESSOR(bus_width, BUS_WIDTH, int)
 MMC_ACCESSOR(erase_sector, ERASE_SECTOR, int)
+MMC_ACCESSOR(max_data, MAX_DATA, int)
 
 #endif /* DEV_MMC_MMCVAR_H */

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c	Wed Oct 29 19:52:24 2008	(r184451)
+++ head/sys/dev/sdhci/sdhci.c	Wed Oct 29 20:01:26 2008	(r184452)
@@ -1440,6 +1440,9 @@ sdhci_read_ivar(device_t bus, device_t c
 	case MMCBR_IVAR_TIMING:
 		*(int *)result = slot->host.ios.timing;
 		break;
+	case MMCBR_IVAR_MAX_DATA:
+		*(int *)result = 65535;
+		break;
 	}
 	return (0);
 }
@@ -1494,6 +1497,7 @@ sdhci_write_ivar(device_t bus, device_t 
 	case MMCBR_IVAR_HOST_OCR:
 	case MMCBR_IVAR_F_MIN:
 	case MMCBR_IVAR_F_MAX:
+	case MMCBR_IVAR_MAX_DATA:
 		return (EINVAL);
 	}
 	return (0);

From owner-svn-src-head@FreeBSD.ORG  Wed Oct 29 20:19:54 2008
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 5B7FE1065680;
	Wed, 29 Oct 2008 20:19:54 +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 504BA8FC31;
	Wed, 29 Oct 2008 20:19:54 +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 m9TKJs5v032131;
	Wed, 29 Oct 2008 20:19:54 GMT (envelope-from sam@svn.freebsd.org)
Received: (from sam@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9TKJs82032130;
	Wed, 29 Oct 2008 20:19:54 GMT (envelope-from sam@svn.freebsd.org)
Message-Id: <200810292019.m9TKJs82032130@svn.freebsd.org>
From: Sam Leffler 
Date: Wed, 29 Oct 2008 20:19:54 +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: r184453 - head/tools/tools/ath/athstats
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: Wed, 29 Oct 2008 20:19:54 -0000

Author: sam
Date: Wed Oct 29 20:19:54 2008
New Revision: 184453
URL: http://svn.freebsd.org/changeset/base/184453

Log:
  o unbreak ani stat display
  o improve some labels

Modified:
  head/tools/tools/ath/athstats/athstats.c

Modified: head/tools/tools/ath/athstats/athstats.c
==============================================================================
--- head/tools/tools/ath/athstats/athstats.c	Wed Oct 29 20:01:26 2008	(r184452)
+++ head/tools/tools/ath/athstats/athstats.c	Wed Oct 29 20:19:54 2008	(r184453)
@@ -300,9 +300,9 @@ static const struct fmt athstats[] = {
 #define	S_ANI_STEPDOWN	AFTER(S_ANI_STEPUP)
 	{ 5,	"step-","STEP-",	"ANI decreased first step level" },
 #define	S_ANI_OFDMERRS	AFTER(S_ANI_STEPDOWN)
-	{ 8,	"ofdm",	"OFDM",		"cumulative ofdm phy error count" },
+	{ 8,	"ofdm",	"OFDM",		"cumulative OFDM phy error count" },
 #define	S_ANI_CCKERRS	AFTER(S_ANI_OFDMERRS)
-	{ 8,	"cck",	"CCK",		"cumulative cck phy error count" },
+	{ 8,	"cck",	"CCK",		"cumulative CCK phy error count" },
 #define	S_ANI_RESET	AFTER(S_ANI_CCKERRS)
 	{ 5,	"reset","RESET",	"ANI parameters zero'd for non-STA operation" },
 #define	S_ANI_LZERO	AFTER(S_ANI_RESET)
@@ -310,11 +310,11 @@ static const struct fmt athstats[] = {
 #define	S_ANI_LNEG	AFTER(S_ANI_LZERO)
 	{ 5,	"lneg",	"LNEG",		"ANI calculated listen time < 0" },
 #define	S_MIB_ACKBAD	AFTER(S_ANI_LNEG)
-	{ 5,	"ackbad","ACKBAD",	"bad ACK's" },
+	{ 5,	"ackbad","ACKBAD",	"missing ACK's" },
 #define	S_MIB_RTSBAD	AFTER(S_MIB_ACKBAD)
-	{ 5,	"rtsbad","RTSBAD",	"bad RTS" },
+	{ 5,	"rtsbad","RTSBAD",	"RTS without CTS" },
 #define	S_MIB_RTSGOOD	AFTER(S_MIB_RTSBAD)
-	{ 5,	"rtsgood","RTSGOOD",	"good RTS" },
+	{ 5,	"rtsgood","RTSGOOD",	"successful RTS" },
 #define	S_MIB_FCSBAD	AFTER(S_MIB_RTSGOOD)
 	{ 5,	"fcsbad","FCSBAD",	"bad FCS" },
 #define	S_MIB_BEACONS	AFTER(S_MIB_FCSBAD)
@@ -397,6 +397,7 @@ struct _athstats {
 		uint8_t	spurImmunityLevel;
 		uint8_t	firstepLevel;
 		uint8_t	ofdmWeakSigDetectOff;
+		uint8_t	cckWeakSigThreshold;
 		uint32_t listenTime;
 	} ani_state;
 #endif
@@ -613,6 +614,7 @@ ath_get_curstat(struct statfoo *sf, int 
 	case S_ANI_SPUR:	ANI(spurImmunityLevel);
 	case S_ANI_STEP:	ANI(firstepLevel);
 	case S_ANI_OFDM:	ANI(ofdmWeakSigDetectOff);
+	case S_ANI_CCK:		ANI(cckWeakSigThreshold);
 	case S_ANI_LISTEN:	ANI(listenTime);
 	case S_ANI_NIUP:	ANISTAT(niup);
 	case S_ANI_NIDOWN:	ANISTAT(nidown);
@@ -821,6 +823,8 @@ ath_get_totstat(struct statfoo *sf, int 
 	case S_ANI_NOISE:	ANI(noiseImmunityLevel);
 	case S_ANI_SPUR:	ANI(spurImmunityLevel);
 	case S_ANI_STEP:	ANI(firstepLevel);
+	case S_ANI_OFDM:	ANI(ofdmWeakSigDetectOff);
+	case S_ANI_CCK:		ANI(cckWeakSigThreshold);
 	case S_ANI_LISTEN:	ANI(listenTime);
 	case S_ANI_NIUP:	ANISTAT(niup);
 	case S_ANI_NIDOWN:	ANISTAT(nidown);

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 00:19:20 2008
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 3A20D1065670;
	Thu, 30 Oct 2008 00:19:20 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 284F28FC2F;
	Thu, 30 Oct 2008 00:19:20 +0000 (UTC)
	(envelope-from delphij@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 m9U0JKa1036691;
	Thu, 30 Oct 2008 00:19:20 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U0JKCr036690;
	Thu, 30 Oct 2008 00:19:20 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <200810300019.m9U0JKCr036690@svn.freebsd.org>
From: Xin LI 
Date: Thu, 30 Oct 2008 00:19:20 +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: r184458 - head/lib/libc/stdtime
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: Thu, 30 Oct 2008 00:19:20 -0000

Author: delphij
Date: Thu Oct 30 00:19:19 2008
New Revision: 184458
URL: http://svn.freebsd.org/changeset/base/184458

Log:
  Pass a pointer to warn2 so the warn2 == IN_ALL would not be an
  always-false condition.

Modified:
  head/lib/libc/stdtime/strftime.c

Modified: head/lib/libc/stdtime/strftime.c
==============================================================================
--- head/lib/libc/stdtime/strftime.c	Wed Oct 29 21:43:14 2008	(r184457)
+++ head/lib/libc/stdtime/strftime.c	Thu Oct 30 00:19:19 2008	(r184458)
@@ -177,7 +177,7 @@ label:
 				{
 				int warn2 = IN_SOME;
 
-				pt = _fmt(tptr->c_fmt, t, pt, ptlim, warnp);
+				pt = _fmt(tptr->c_fmt, t, pt, ptlim, &warn2);
 				if (warn2 == IN_ALL)
 					warn2 = IN_THIS;
 				if (warn2 > *warnp)

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 01:54:32 2008
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 68DAC1065693;
	Thu, 30 Oct 2008 01:54:32 +0000 (UTC)
	(envelope-from rafan@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 52CCE8FC1B;
	Thu, 30 Oct 2008 01:54:32 +0000 (UTC)
	(envelope-from rafan@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 m9U1sWct038387;
	Thu, 30 Oct 2008 01:54:32 GMT (envelope-from rafan@svn.freebsd.org)
Received: (from rafan@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U1sWgv038386;
	Thu, 30 Oct 2008 01:54:32 GMT (envelope-from rafan@svn.freebsd.org)
Message-Id: <200810300154.m9U1sWgv038386@svn.freebsd.org>
From: Rong-En Fan 
Date: Thu, 30 Oct 2008 01:54: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: r184459 - head/usr.sbin/rpc.yppasswdd
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: Thu, 30 Oct 2008 01:54:32 -0000

Author: rafan
Date: Thu Oct 30 01:54:31 2008
New Revision: 184459
URL: http://svn.freebsd.org/changeset/base/184459

Log:
  - Whenever a password/shell is changed via rpc.yppasswdd, the daemon leaves
    one zombie process because it does not do the cleanup. For a long running
    NIS/YP server, it will have lots of zombie processes on it. Fix that by
    ignoring the SIGCHLD signal since we don't really care about the exit
    status in this case.
  
  PR:		bin/91980
  Reported by:	Arjan van der Velde 
  Submitted by:	Jui-Nan Lin" 
  Reviewed by:	delphij
  MFC after:	1 month

Modified:
  head/usr.sbin/rpc.yppasswdd/yppasswdd_main.c

Modified: head/usr.sbin/rpc.yppasswdd/yppasswdd_main.c
==============================================================================
--- head/usr.sbin/rpc.yppasswdd/yppasswdd_main.c	Thu Oct 30 00:19:19 2008	(r184458)
+++ head/usr.sbin/rpc.yppasswdd/yppasswdd_main.c	Thu Oct 30 01:54:31 2008	(r184459)
@@ -165,6 +165,7 @@ main(int argc, char *argv[])
 	struct sockaddr_in saddr;
 	socklen_t asize = sizeof (saddr);
 	struct netconfig *nconf;
+	struct sigaction sa;
 	void *localhandle;
 	int ch;
 	char *mastername;
@@ -268,6 +269,9 @@ the %s domain -- aborting", yppasswd_dom
 		}
 	}
 	openlog("rpc.yppasswdd", LOG_PID, LOG_DAEMON);
+	memset(&sa, 0, sizeof(sa));
+	sa.sa_flags = SA_NOCLDWAIT;
+	sigaction(SIGCHLD, &sa, NULL);
 
 	rpcb_unset(YPPASSWDPROG, YPPASSWDVERS, NULL);
 	rpcb_unset(MASTER_YPPASSWDPROG, MASTER_YPPASSWDVERS, NULL);

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 03:31:33 2008
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 73421106567F;
	Thu, 30 Oct 2008 03:31:33 +0000 (UTC)
	(envelope-from marcel@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5AFDE8FC1E;
	Thu, 30 Oct 2008 03:31:33 +0000 (UTC)
	(envelope-from marcel@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 m9U3VXxq040364;
	Thu, 30 Oct 2008 03:31:33 GMT (envelope-from marcel@svn.freebsd.org)
Received: (from marcel@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U3VX3k040363;
	Thu, 30 Oct 2008 03:31:33 GMT (envelope-from marcel@svn.freebsd.org)
Message-Id: <200810300331.m9U3VX3k040363@svn.freebsd.org>
From: Marcel Moolenaar 
Date: Thu, 30 Oct 2008 03:31:33 +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: r184460 - head/sys/powerpc/include
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: Thu, 30 Oct 2008 03:31:33 -0000

Author: marcel
Date: Thu Oct 30 03:31:33 2008
New Revision: 184460
URL: http://svn.freebsd.org/changeset/base/184460

Log:
  Add support for little-endian compilations to this file.

Modified:
  head/sys/powerpc/include/endian.h

Modified: head/sys/powerpc/include/endian.h
==============================================================================
--- head/sys/powerpc/include/endian.h	Thu Oct 30 01:54:31 2008	(r184459)
+++ head/sys/powerpc/include/endian.h	Thu Oct 30 03:31:33 2008	(r184460)
@@ -44,15 +44,29 @@
 #define	_QUAD_LOWWORD 1
 
 /*
+ * GCC defines _BIG_ENDIAN and _LITTLE_ENDIAN equal to __BIG_ENDIAN__
+ * and __LITTLE_ENDIAN__ (resp).
+ */
+#ifdef _BIG_ENDIAN
+#undef _BIG_ENDIAN
+#endif
+#ifdef _LITTLE_ENDIAN
+#undef _LITTLE_ENDIAN
+#endif
+
+/*
  * Definitions for byte order, according to byte significance from low
  * address to high.
  */
-#undef  _BIG_ENDIAN		/* GCC annoyingly defines this for PowerPC */
 #define	_LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
 #define	_BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
 #define	_PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
 
+#ifdef __LITTLE_ENDIAN__
+#define	_BYTE_ORDER	_LITTLE_ENDIAN
+#else
 #define	_BYTE_ORDER	_BIG_ENDIAN
+#endif
 
 /*
  * Deprecated variants that don't have enough underscores to be useful in more

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 08:13:50 2008
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 0DBCA1065672;
	Thu, 30 Oct 2008 08:13:50 +0000 (UTC)
	(envelope-from n_hibma@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F0F8F8FC1A;
	Thu, 30 Oct 2008 08:13:49 +0000 (UTC)
	(envelope-from n_hibma@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 m9U8DnWJ045387;
	Thu, 30 Oct 2008 08:13:49 GMT (envelope-from n_hibma@svn.freebsd.org)
Received: (from n_hibma@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U8DnXX045386;
	Thu, 30 Oct 2008 08:13:49 GMT (envelope-from n_hibma@svn.freebsd.org)
Message-Id: <200810300813.m9U8DnXX045386@svn.freebsd.org>
From: Nick Hibma 
Date: Thu, 30 Oct 2008 08:13:49 +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: r184464 - head/sys/dev/usb
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: Thu, 30 Oct 2008 08:13:50 -0000

Author: n_hibma
Date: Thu Oct 30 08:13:49 2008
New Revision: 184464
URL: http://svn.freebsd.org/changeset/base/184464

Log:
  Return USBD_NORMAL_COMPLETION instead of a hard coded 0.

Modified:
  head/sys/dev/usb/usbdi.c

Modified: head/sys/dev/usb/usbdi.c
==============================================================================
--- head/sys/dev/usb/usbdi.c	Thu Oct 30 04:55:12 2008	(r184463)
+++ head/sys/dev/usb/usbdi.c	Thu Oct 30 08:13:49 2008	(r184464)
@@ -325,7 +325,7 @@ usbd_transfer(usbd_xfer_handle xfer)
 	}
 
 	if (!(xfer->flags & USBD_SYNCHRONOUS))
-		return (xfer->done ? 0 : USBD_IN_PROGRESS);
+		return (xfer->done ? USBD_NORMAL_COMPLETION : USBD_IN_PROGRESS);
 
 	/* Sync transfer, wait for completion. */
 	s = splusb();

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 08:17:28 2008
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 623921065676;
	Thu, 30 Oct 2008 08:17:28 +0000 (UTC)
	(envelope-from n_hibma@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 515D68FC1D;
	Thu, 30 Oct 2008 08:17:28 +0000 (UTC)
	(envelope-from n_hibma@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 m9U8HSOE045477;
	Thu, 30 Oct 2008 08:17:28 GMT (envelope-from n_hibma@svn.freebsd.org)
Received: (from n_hibma@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U8HSKF045476;
	Thu, 30 Oct 2008 08:17:28 GMT (envelope-from n_hibma@svn.freebsd.org)
Message-Id: <200810300817.m9U8HSKF045476@svn.freebsd.org>
From: Nick Hibma 
Date: Thu, 30 Oct 2008 08:17:28 +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: r184465 - head/sys/dev/usb
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: Thu, 30 Oct 2008 08:17:28 -0000

Author: n_hibma
Date: Thu Oct 30 08:17:27 2008
New Revision: 184465
URL: http://svn.freebsd.org/changeset/base/184465

Log:
  Bugfix: Check the error code for in progress as well, after starting the
  transfer.
  
  Some changes to improve the debugging experience.

Modified:
  head/sys/dev/usb/u3g.c

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Thu Oct 30 08:13:49 2008	(r184464)
+++ head/sys/dev/usb/u3g.c	Thu Oct 30 08:17:27 2008	(r184465)
@@ -51,7 +51,7 @@
 #endif
 #include "usbdevs.h"
 
-/* #define U3G_DEBUG */
+//#define U3G_DEBUG
 #ifdef U3G_DEBUG
 #define DPRINTF(x...)		do { if (u3gdebug) device_printf(sc->sc_dev, ##x); } while (0)
 int	u3gdebug = 1;
@@ -483,8 +483,10 @@ u3gstub_scsi_eject(struct u3gstub_softc 
 			break;
 	}
 
-	if (i == id->bNumEndpoints)
+	if (i == id->bNumEndpoints) {
+		DPRINTF("failed to find bulk-out pipe\n");
 		return 0;
+	}
 
 	if (usbd_open_pipe(uaa->iface, ed->bEndpointAddress,
 			   USBD_EXCLUSIVE_USE, &sc->sc_pipe) != USBD_NORMAL_COMPLETION) {
@@ -501,7 +503,8 @@ u3gstub_scsi_eject(struct u3gstub_softc 
 
 	usbd_setup_xfer(sc->sc_xfer, sc->sc_pipe, NULL, cmd, sizeof(cmd),
 			0, USBD_DEFAULT_TIMEOUT, NULL);
-	if (usbd_transfer(sc->sc_xfer) != USBD_NORMAL_COMPLETION) {
+	int err = usbd_transfer(sc->sc_xfer) != USBD_NORMAL_COMPLETION;
+	if (err != USBD_NORMAL_COMPLETION && err != USBD_IN_PROGRESS) {
 		DPRINTF("failed to start transfer\n");
 		return 0;
 	}
@@ -545,8 +548,8 @@ u3gstub_match(device_t self)
 		return UMATCH_NONE;
 
 	if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT
-	    || u3g_dev_type->flags&U3GFL_SIERRA_INIT
 	    || u3g_dev_type->flags&U3GFL_SCSI_EJECT
+	    || u3g_dev_type->flags&U3GFL_SIERRA_INIT
 	    || u3g_dev_type->flags&U3GFL_STUB_WAIT) {
 		/* We assume that if the first interface is still a mass
 		 * storage device the device has not yet changed appearance.
@@ -574,9 +577,8 @@ u3gstub_attach(device_t self)
 	sc->sc_dev = self;
 	sc->sc_udev = uaa->device;
 
-	if (uaa->iface)
-		for (i = 0; i < uaa->nifaces; i++)
-			uaa->ifaces[i] = NULL;		// claim all interfaces
+	for (i = 0; i < uaa->nifaces; i++)
+		uaa->ifaces[i] = NULL;		// claim all interfaces
 
 	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
 	if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT) {
@@ -584,7 +586,7 @@ u3gstub_attach(device_t self)
 		if (!u3gstub_huawei_init(sc, uaa))
 			return ENXIO;
 	} else if (u3g_dev_type->flags&U3GFL_SCSI_EJECT) {
-		DPRINTF("sending CD eject command to change to modem mode \n");
+		DPRINTF("sending CD eject command to change to modem mode\n");
 		if (!u3gstub_scsi_eject(sc, uaa))
 			return ENXIO;
 	} else if (u3g_dev_type->flags&U3GFL_SIERRA_INIT) {

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 08:32:18 2008
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 D53F41065676;
	Thu, 30 Oct 2008 08:32:18 +0000 (UTC)
	(envelope-from n_hibma@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C42E68FC17;
	Thu, 30 Oct 2008 08:32:18 +0000 (UTC)
	(envelope-from n_hibma@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 m9U8WI9o045753;
	Thu, 30 Oct 2008 08:32:18 GMT (envelope-from n_hibma@svn.freebsd.org)
Received: (from n_hibma@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9U8WInO045752;
	Thu, 30 Oct 2008 08:32:18 GMT (envelope-from n_hibma@svn.freebsd.org)
Message-Id: <200810300832.m9U8WInO045752@svn.freebsd.org>
From: Nick Hibma 
Date: Thu, 30 Oct 2008 08:32:18 +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: r184466 - head/sys/dev/usb
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: Thu, 30 Oct 2008 08:32:19 -0000

Author: n_hibma
Date: Thu Oct 30 08:32:18 2008
New Revision: 184466
URL: http://svn.freebsd.org/changeset/base/184466

Log:
  We need to print out the device info ourselves on FBSD 6.
  
  Submitted by:	Thomas Nystrom

Modified:
  head/sys/dev/usb/u3g.c

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Thu Oct 30 08:17:27 2008	(r184465)
+++ head/sys/dev/usb/u3g.c	Thu Oct 30 08:32:18 2008	(r184466)
@@ -227,6 +227,13 @@ u3g_attach(device_t self)
 	usb_config_descriptor_t *cd;
 	char devnamefmt[32];
 
+#if __FreeBSD_version < 700000
+	char *devinfo = malloc(1024, M_USBDEV, M_WAITOK);
+	usbd_devinfo(dev, 0, devinfo);
+	device_printf(self, "%s\n", devinfo);
+	free(devinfo, M_USBDEV);
+#endif
+
 	/* get the config descriptor */
 	cd = usbd_get_config_descriptor(dev);
 	if (cd == NULL) {

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 10:13:53 2008
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 6CBD51065698;
	Thu, 30 Oct 2008 10:13:53 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 573A28FC68;
	Thu, 30 Oct 2008 10:13:53 +0000 (UTC)
	(envelope-from rwatson@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 m9UADrZ3047731;
	Thu, 30 Oct 2008 10:13:53 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UADrQ6047728;
	Thu, 30 Oct 2008 10:13:53 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810301013.m9UADrQ6047728@svn.freebsd.org>
From: Robert Watson 
Date: Thu, 30 Oct 2008 10:13:53 +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: r184467 - head/sys/security/mac_bsdextended
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: Thu, 30 Oct 2008 10:13:53 -0000

Author: rwatson
Date: Thu Oct 30 10:13:53 2008
New Revision: 184467
URL: http://svn.freebsd.org/changeset/base/184467

Log:
  The V* flags passed using an accmode_t to the access() and open()
  access control checks in mac_bsdextended are not in the same
  namespace as the MBI_ flags used in ugidfw policies, so add an
  explicit conversion routine to get from one to the other.
  
  Obtained from:	TrustedBSD Project

Modified:
  head/sys/security/mac_bsdextended/mac_bsdextended.c
  head/sys/security/mac_bsdextended/ugidfw_internal.h
  head/sys/security/mac_bsdextended/ugidfw_vnode.c

Modified: head/sys/security/mac_bsdextended/mac_bsdextended.c
==============================================================================
--- head/sys/security/mac_bsdextended/mac_bsdextended.c	Thu Oct 30 08:32:18 2008	(r184466)
+++ head/sys/security/mac_bsdextended/mac_bsdextended.c	Thu Oct 30 10:13:53 2008	(r184467)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson
  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Tom Rhodes
  * Copyright (c) 2006 SPARTA, Inc.
@@ -465,6 +465,27 @@ ugidfw_check_vp(struct ucred *cred, stru
 	return (ugidfw_check(cred, vp, &vap, acc_mode));
 }
 
+int
+ugidfw_accmode2mbi(accmode_t accmode)
+{
+	int mbi;
+
+	mbi = 0;
+	if (accmode & VEXEC)
+		mbi |= MBI_EXEC;
+	if (accmode & VWRITE)
+		mbi |= MBI_WRITE;
+	if (accmode & VREAD)
+		mbi |= MBI_READ;
+	if (accmode & VADMIN)
+		mbi |= MBI_ADMIN;
+	if (accmode & VSTAT)
+		mbi |= MBI_STAT;
+	if (accmode & VAPPEND)
+		mbi |= MBI_APPEND;
+	return (mbi);
+}
+
 static struct mac_policy_ops ugidfw_ops =
 {
 	.mpo_destroy = ugidfw_destroy,

Modified: head/sys/security/mac_bsdextended/ugidfw_internal.h
==============================================================================
--- head/sys/security/mac_bsdextended/ugidfw_internal.h	Thu Oct 30 08:32:18 2008	(r184466)
+++ head/sys/security/mac_bsdextended/ugidfw_internal.h	Thu Oct 30 10:13:53 2008	(r184467)
@@ -34,6 +34,7 @@
 /*
  * Central access control routines used by object-specific checks.
  */
+int	ugidfw_accmode2mbi(accmode_t accmode);
 int	ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap,
 	    int acc_mode);
 int	ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode);

Modified: head/sys/security/mac_bsdextended/ugidfw_vnode.c
==============================================================================
--- head/sys/security/mac_bsdextended/ugidfw_vnode.c	Thu Oct 30 08:32:18 2008	(r184466)
+++ head/sys/security/mac_bsdextended/ugidfw_vnode.c	Thu Oct 30 10:13:53 2008	(r184467)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson
  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Tom Rhodes
  * Copyright (c) 2006 SPARTA, Inc.
@@ -65,11 +65,7 @@ ugidfw_vnode_check_access(struct ucred *
     struct label *vplabel, accmode_t accmode)
 {
 
-	/*
-	 * XXX: We pass accmode_t variable containing V* constants
-	 *	as an int containing MBI_* constants.
-	 */
-	return (ugidfw_check_vp(cred, vp, (int)accmode));
+	return (ugidfw_check_vp(cred, vp, ugidfw_accmode2mbi(accmode)));
 }
 
 int
@@ -175,11 +171,7 @@ ugidfw_vnode_check_open(struct ucred *cr
     struct label *vplabel, accmode_t accmode)
 {
 
-	/*
-	 * XXX: We pass accmode_t variable containing V* constants
-	 *	as an int containing MBI_* constants.
-	 */
-	return (ugidfw_check_vp(cred, vp, (int)accmode));
+	return (ugidfw_check_vp(cred, vp, ugidfw_accmode2mbi(accmode)));
 }
 
 int

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 12:20:35 2008
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 CAED51065679;
	Thu, 30 Oct 2008 12:20:35 +0000 (UTC) (envelope-from des@des.no)
Received: from tim.des.no (tim.des.no [194.63.250.121])
	by mx1.freebsd.org (Postfix) with ESMTP id 86FB28FC16;
	Thu, 30 Oct 2008 12:20:35 +0000 (UTC) (envelope-from des@des.no)
Received: from ds4.des.no (des.no [84.49.246.2])
	by smtp.des.no (Postfix) with ESMTP id 66FF16D449;
	Thu, 30 Oct 2008 12:20:34 +0000 (UTC)
Received: by ds4.des.no (Postfix, from userid 1001)
	id 4EC6C84494; Thu, 30 Oct 2008 13:20:34 +0100 (CET)
From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= 
To: Maxim Sobolev 
References: <200810270625.m9R6P2a8029701@svn.freebsd.org>
Date: Thu, 30 Oct 2008 13:20:34 +0100
In-Reply-To: <200810270625.m9R6P2a8029701@svn.freebsd.org> (Maxim Sobolev's
	message of "Mon, 27 Oct 2008 06:25:02 +0000 (UTC)")
Message-ID: <86wsfqgtpp.fsf@ds4.des.no>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184323 - head/sys/kern
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: Thu, 30 Oct 2008 12:20:35 -0000

Maxim Sobolev  writes:
> Log:
>   Default HZ value (1,000) on i386/amd64 is not very virtual machine frie=
ndly.
>   Due to the nature of the beast it causes lot of unproductive overhead. =
This
>   is especially bad when running SMP kernel on VMWare with several virtual
>   processors - idle FreeBSD guest with SMP kernel takes 150% host CPU tim=
e on my
>   dual-core MacBook Pro when I am enabling two virtual CPUs, making even =
host
>   not very usable. Detect when we are running in the sandbox and reduce HZ
>   to 10 (can be adjusted via VM_HZ in the kernel config) in such cases. T=
his
>   brings host CPU usage of idle FreeBSD/SMP on two virtual processors down
>   to 10%.

What, too chicken to go whole hog and make the kernel tickless?  :)

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 14:05:58 2008
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 429C61065678;
	Thu, 30 Oct 2008 14:05:58 +0000 (UTC)
	(envelope-from ivoras@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2F6D78FC27;
	Thu, 30 Oct 2008 14:05:58 +0000 (UTC)
	(envelope-from ivoras@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 m9UE5w4G053252;
	Thu, 30 Oct 2008 14:05:58 GMT (envelope-from ivoras@svn.freebsd.org)
Received: (from ivoras@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UE5wwZ053250;
	Thu, 30 Oct 2008 14:05:58 GMT (envelope-from ivoras@svn.freebsd.org)
Message-Id: <200810301405.m9UE5wwZ053250@svn.freebsd.org>
From: Ivan Voras 
Date: Thu, 30 Oct 2008 14:05:58 +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: r184471 - in head/bin: cat cp
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: Thu, 30 Oct 2008 14:05:58 -0000

Author: ivoras
Date: Thu Oct 30 14:05:57 2008
New Revision: 184471
URL: http://svn.freebsd.org/changeset/base/184471

Log:
  Teach cat(1) and cp(1) to use a larger buffer if enough memory is present
  in the system. A simple heuristics is used to detect what is "enough"
  memory: if number of physmem pages is greater than 32k (equalling 128 MB
  on machines with 4 kB pages).
  
  Typical immediate result of these changes is reduction in context switches
  and the goal is to increase efficiency by using large buffers:
  before: /usr/bin/time -hlp cat file1 > file2
  ...
         163  voluntary context switches
       11194  involuntary context switches
  after: /usr/bin/time -hlp ./cat file1 > file2
  ...
         417  voluntary context switches
         272  involuntary context switches
  
  Reviewed by:    hackers@ (no objections to earlier version of cat patch)
  Approved by:    gnn (mentor)
  MFC after:      4 months

Modified:
  head/bin/cat/cat.c
  head/bin/cp/utils.c

Modified: head/bin/cat/cat.c
==============================================================================
--- head/bin/cat/cat.c	Thu Oct 30 13:18:28 2008	(r184470)
+++ head/bin/cat/cat.c	Thu Oct 30 14:05:57 2008	(r184471)
@@ -77,6 +77,17 @@ static void raw_cat(int);
 static int udom_open(const char *path, int flags);
 #endif
 
+/* Memory strategy threshold, in pages: if physmem is larger then this, use a 
+ * large buffer */
+#define PHYSPAGES_THRESHOLD (32*1024)
+
+/* Maximum buffer size in bytes - do not allow it to grow larger than this */
+#define BUFSIZE_MAX (2*1024*1024)
+
+/* Small (default) buffer size in bytes. It's inefficient for this to be
+ * smaller than MAXPHYS */
+#define BUFSIZE_SMALL (MAXPHYS)
+
 int
 main(int argc, char *argv[])
 {
@@ -247,9 +258,17 @@ raw_cat(int rfd)
 	if (buf == NULL) {
 		if (fstat(wfd, &sbuf))
 			err(1, "%s", filename);
-		bsize = MAX(sbuf.st_blksize, 1024);
+		if (S_ISREG(sbuf.st_mode)) {
+			/* If there's plenty of RAM, use a large copy buffer */
+			if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
+				bsize = MIN(BUFSIZE_MAX, MAXPHYS*8);
+			else
+				bsize = BUFSIZE_SMALL;
+		} else
+			bsize = MAX(sbuf.st_blksize, 
+					(blksize_t)sysconf(_SC_PAGESIZE));
 		if ((buf = malloc(bsize)) == NULL)
-			err(1, "buffer");
+			err(1, "malloc() failure of IO buffer");
 	}
 	while ((nr = read(rfd, buf, bsize)) > 0)
 		for (off = 0; nr; nr -= nw, off += nw)

Modified: head/bin/cp/utils.c
==============================================================================
--- head/bin/cp/utils.c	Thu Oct 30 13:18:28 2008	(r184470)
+++ head/bin/cp/utils.c	Thu Oct 30 14:05:57 2008	(r184471)
@@ -57,10 +57,22 @@ __FBSDID("$FreeBSD$");
 
 #define	cp_pct(x, y)	((y == 0) ? 0 : (int)(100.0 * (x) / (y)))
 
+/* Memory strategy threshold, in pages: if physmem is larger then this, use a 
+ * large buffer */
+#define PHYSPAGES_THRESHOLD (32*1024)
+
+/* Maximum buffer size in bytes - do not allow it to grow larger than this */
+#define BUFSIZE_MAX (2*1024*1024)
+
+/* Small (default) buffer size in bytes. It's inefficient for this to be
+ * smaller than MAXPHYS */
+#define BUFSIZE_SMALL (MAXPHYS)
+
 int
 copy_file(const FTSENT *entp, int dne)
 {
-	static char buf[MAXBSIZE];
+	static char *buf = NULL;
+	static size_t bufsize;
 	struct stat *fs;
 	ssize_t wcount;
 	size_t wresid;
@@ -174,8 +186,23 @@ copy_file(const FTSENT *entp, int dne)
 		} else
 #endif
 		{
+			if (buf == NULL) {
+				/*
+				 * Note that buf and bufsize are static. If
+				 * malloc() fails, it will fail at the start
+				 * and not copy only some files. 
+				 */ 
+				if (sysconf(_SC_PHYS_PAGES) > 
+				    PHYSPAGES_THRESHOLD)
+					bufsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
+				else
+					bufsize = BUFSIZE_SMALL;
+				buf = malloc(bufsize);
+				if (buf == NULL)
+					err(1, "Not enough memory");
+			}
 			wtotal = 0;
-			while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
+			while ((rcount = read(from_fd, buf, bufsize)) > 0) {
 				for (bufp = buf, wresid = rcount; ;
 			    	bufp += wcount, wresid -= wcount) {
 					wcount = write(to_fd, bufp, wresid);

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 15:27:13 2008
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 C7C811065673;
	Thu, 30 Oct 2008 15:27:13 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B51B68FC0A;
	Thu, 30 Oct 2008 15:27:13 +0000 (UTC)
	(envelope-from nwhitehorn@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 m9UFRD6Q054784;
	Thu, 30 Oct 2008 15:27:13 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UFRDPD054780;
	Thu, 30 Oct 2008 15:27:13 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <200810301527.m9UFRDPD054780@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Thu, 30 Oct 2008 15:27:13 +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: r184473 - in head/sys: dev/adb powerpc/powermac
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: Thu, 30 Oct 2008 15:27:13 -0000

Author: nwhitehorn
Date: Thu Oct 30 15:27:13 2008
New Revision: 184473
URL: http://svn.freebsd.org/changeset/base/184473

Log:
  Fix some possible infinite loops in the ADB code, and remove some hacks
  that were inserted in desperation during bring-up. In addition, move ADB bus
  enumeration and child attachment to when interrupts are available.

Modified:
  head/sys/dev/adb/adb_bus.c
  head/sys/dev/adb/adbvar.h
  head/sys/powerpc/powermac/cuda.c
  head/sys/powerpc/powermac/pmu.c

Modified: head/sys/dev/adb/adb_bus.c
==============================================================================
--- head/sys/dev/adb/adb_bus.c	Thu Oct 30 14:30:49 2008	(r184472)
+++ head/sys/dev/adb/adb_bus.c	Thu Oct 30 15:27:13 2008	(r184473)
@@ -44,6 +44,7 @@
 static int adb_bus_probe(device_t dev);
 static int adb_bus_attach(device_t dev);
 static int adb_bus_detach(device_t dev);
+static void adb_bus_enumerate(void *xdev);
 static void adb_probe_nomatch(device_t dev, device_t child);
 static int adb_print_child(device_t dev, device_t child);
 
@@ -88,6 +89,27 @@ static int
 adb_bus_attach(device_t dev)
 {
 	struct adb_softc *sc = device_get_softc(dev);
+	sc->enum_hook.ich_func = adb_bus_enumerate;
+	sc->enum_hook.ich_arg = dev;
+
+	/*
+	 * We should wait until interrupts are enabled to try to probe
+	 * the bus. Enumerating the ADB involves receiving packets,
+	 * which works best with interrupts enabled.
+	 */
+	
+	if (config_intrhook_establish(&sc->enum_hook) != 0)
+		return (ENOMEM);
+
+	return (0);
+}
+	
+static void
+adb_bus_enumerate(void *xdev)
+{
+	device_t dev = (device_t)xdev;
+
+	struct adb_softc *sc = device_get_softc(dev);
 	uint8_t i, next_free;
 	uint16_t r3;
 
@@ -165,7 +187,9 @@ adb_bus_attach(device_t dev)
 		}
 	}
 
-	return (bus_generic_attach(dev));
+	bus_generic_attach(dev);
+
+	config_intrhook_disestablish(&sc->enum_hook);
 }
 
 static int adb_bus_detach(device_t dev)
@@ -315,10 +339,13 @@ adb_send_raw_packet_sync(device_t dev, u
 	ADB_HB_SEND_RAW_PACKET(sc->parent, command_byte, len, data, 1);
 
 	while (!atomic_fetchadd_int(&sc->packet_reply,0)) {
-		/* Sometimes CUDA controllers hang up during cold boots.
-		   Try poking them. */
-		if (i > 10)
-			ADB_HB_CONTROLLER_POLL(sc->parent);
+		/*
+		 * Maybe the command got lost? Try resending and polling the 
+		 * controller.
+		 */
+		if (i > 40)
+			ADB_HB_SEND_RAW_PACKET(sc->parent, command_byte, 
+			    len, data, 1);
 
 		DELAY(100);
 		i++;

Modified: head/sys/dev/adb/adbvar.h
==============================================================================
--- head/sys/dev/adb/adbvar.h	Thu Oct 30 14:30:49 2008	(r184472)
+++ head/sys/dev/adb/adbvar.h	Thu Oct 30 15:27:13 2008	(r184473)
@@ -37,16 +37,15 @@ enum {
 
 struct adb_softc {
 	device_t	sc_dev;
-
 	device_t	parent;
 
+	struct intr_config_hook enum_hook;
 	struct mtx	sc_sync_mtx;
 	
 	volatile int 	sync_packet;
 	volatile int	packet_reply;
 
 	uint16_t	autopoll_mask;
-
 	uint8_t		syncreg[8];
 
 	device_t	children[16];

Modified: head/sys/powerpc/powermac/cuda.c
==============================================================================
--- head/sys/powerpc/powermac/cuda.c	Thu Oct 30 14:30:49 2008	(r184472)
+++ head/sys/powerpc/powermac/cuda.c	Thu Oct 30 15:27:13 2008	(r184473)
@@ -341,10 +341,7 @@ cuda_send(void *cookie, int poll, int le
 
 	mtx_lock(&sc->sc_mutex);
 
-	if ((sc->sc_state == CUDA_IDLE) /*&& 
-	    ((cuda_read_reg(sc, vBufB) & vPB3) == vPB3)*/) {
-		/* fine */
-	} else {
+	if (sc->sc_state != CUDA_IDLE) {
 		if (sc->sc_waiting == 0) {
 			sc->sc_waiting = 1;
 		} else {
@@ -381,12 +378,12 @@ cuda_poll(device_t dev)
 {
 	struct cuda_softc *sc = device_get_softc(dev);
 
-	while ((sc->sc_state != CUDA_IDLE) ||
-	       (cuda_intr_state(sc)) ||
-	       (sc->sc_waiting == 1)) {
-		if ((cuda_read_reg(sc, vIFR) & vSR_INT) == vSR_INT)
-			cuda_intr(dev);
-	}
+	if (sc->sc_state == CUDA_IDLE && !cuda_intr_state(sc) && 
+	    !sc->sc_waiting)
+		return;
+
+	if ((cuda_read_reg(sc, vIFR) & vSR_INT) == vSR_INT)
+		cuda_intr(dev);
 }
 
 static void
@@ -615,6 +612,7 @@ cuda_adb_autopoll(device_t dev, uint16_t
 	uint8_t cmd[] = {CUDA_PSEUDO, CMD_AUTOPOLL, mask != 0};
 
 	mtx_lock(&sc->sc_mutex);
+
 	if (cmd[2] == sc->sc_autopoll) {
 		mtx_unlock(&sc->sc_mutex);
 		return 0;
@@ -624,18 +622,10 @@ cuda_adb_autopoll(device_t dev, uint16_t
 		mtx_sleep(dev,&sc->sc_mutex,0,"cuda",1);
 
 	sc->sc_autopoll = -1;
-	mtx_unlock(&sc->sc_mutex);
-
 	cuda_send(sc, 0, 3, cmd);
-	
-	mtx_lock(&sc->sc_mutex);
-	while(sc->sc_autopoll == -1) {
-		mtx_sleep(dev,&sc->sc_mutex,0,"cuda",100);
-		cuda_poll(dev);
-	}
 
 	mtx_unlock(&sc->sc_mutex);
-
+	
 	return 0;
 }
 

Modified: head/sys/powerpc/powermac/pmu.c
==============================================================================
--- head/sys/powerpc/powermac/pmu.c	Thu Oct 30 14:30:49 2008	(r184472)
+++ head/sys/powerpc/powermac/pmu.c	Thu Oct 30 15:27:13 2008	(r184473)
@@ -591,8 +591,6 @@ pmu_adb_autopoll(device_t dev, uint16_t 
 {
 	struct pmu_softc *sc = device_get_softc(dev);
 
-	mask = 0xffff;
-
 	/* magical incantation to re-enable autopolling */
 	uint8_t cmd[] = {0, PMU_SET_POLL_MASK, (mask >> 8) & 0xff, mask & 0xff};
 	uint8_t resp[16];

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 16:11:07 2008
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 5C007106567C;
	Thu, 30 Oct 2008 16:11:07 +0000 (UTC) (envelope-from dfr@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4B1698FC1F;
	Thu, 30 Oct 2008 16:11:07 +0000 (UTC) (envelope-from dfr@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 m9UGB7Ow055779;
	Thu, 30 Oct 2008 16:11:07 GMT (envelope-from dfr@svn.freebsd.org)
Received: (from dfr@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UGB73w055778;
	Thu, 30 Oct 2008 16:11:07 GMT (envelope-from dfr@svn.freebsd.org)
Message-Id: <200810301611.m9UGB73w055778@svn.freebsd.org>
From: Doug Rabson 
Date: Thu, 30 Oct 2008 16:11:07 +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: r184477 - head/sys/opencrypto
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: Thu, 30 Oct 2008 16:11:07 -0000

Author: dfr
Date: Thu Oct 30 16:11:07 2008
New Revision: 184477
URL: http://svn.freebsd.org/changeset/base/184477

Log:
  Don't hang if encrypting/decrypting using struct iovecs where one of the
  iovecs ends on a crypto block boundary.

Modified:
  head/sys/opencrypto/cryptosoft.c

Modified: head/sys/opencrypto/cryptosoft.c
==============================================================================
--- head/sys/opencrypto/cryptosoft.c	Thu Oct 30 16:09:08 2008	(r184476)
+++ head/sys/opencrypto/cryptosoft.c	Thu Oct 30 16:11:07 2008	(r184477)
@@ -352,6 +352,10 @@ swcr_encdec(struct cryptodesc *crd, stru
 				k += blks;
 				i -= blks;
 			}
+			if (k == iov->iov_len) {
+				iov++;
+				k = 0;
+			}
 		}
 
 		return 0; /* Done with iovec encryption/decryption */

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 16:22:04 2008
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 9DF2E1065678;
	Thu, 30 Oct 2008 16:22:04 +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 8C55E8FC1A;
	Thu, 30 Oct 2008 16:22:04 +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 m9UGM4LR056114;
	Thu, 30 Oct 2008 16:22:04 GMT (envelope-from sam@svn.freebsd.org)
Received: (from sam@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UGM4Bg056108;
	Thu, 30 Oct 2008 16:22:04 GMT (envelope-from sam@svn.freebsd.org)
Message-Id: <200810301622.m9UGM4Bg056108@svn.freebsd.org>
From: Sam Leffler 
Date: Thu, 30 Oct 2008 16:22:04 +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: r184480 - in head/sys: dev/ath 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: Thu, 30 Oct 2008 16:22:04 -0000

Author: sam
Date: Thu Oct 30 16:22:04 2008
New Revision: 184480
URL: http://svn.freebsd.org/changeset/base/184480

Log:
  Fix checks for fast frames negotiation.  ni_ath_flags holds the
  capabilities reported by the ap.  These need to be cross-checked
  against the local configuration in the vap.  Previously we were
  only checking the ap capabilities which meant that if an ap reported
  it was ff-capable but we were not setup to use them we'd try to do
  ff aggregation and drop the frame.
  
  There are a number of problems to be fixed here but applying this
  fix immediately as the problem causes all traffic to stop (and has
  not workaround).
  
  Reported by:	Ashish Shukla

Modified:
  head/sys/dev/ath/if_ath.c
  head/sys/net80211/ieee80211_adhoc.c
  head/sys/net80211/ieee80211_hostap.c
  head/sys/net80211/ieee80211_sta.c
  head/sys/net80211/ieee80211_wds.c

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Thu Oct 30 16:20:42 2008	(r184479)
+++ head/sys/dev/ath/if_ath.c	Thu Oct 30 16:22:04 2008	(r184480)
@@ -1999,7 +1999,7 @@ ath_start(struct ifnet *ifp)
 		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
 		pri = M_WME_GETAC(m);
 		txq = sc->sc_ac2q[pri];
-		if (ni->ni_ath_flags & IEEE80211_NODE_FF) {
+		if (IEEE80211_ATH_CAP(ni->ni_vap, ni, IEEE80211_NODE_FF)) {
 			/*
 			 * Check queue length; if too deep drop this
 			 * frame (tail drop considered good).

Modified: head/sys/net80211/ieee80211_adhoc.c
==============================================================================
--- head/sys/net80211/ieee80211_adhoc.c	Thu Oct 30 16:20:42 2008	(r184479)
+++ head/sys/net80211/ieee80211_adhoc.c	Thu Oct 30 16:22:04 2008	(r184480)
@@ -553,7 +553,7 @@ adhoc_input(struct ieee80211_node *ni, s
 			m = ieee80211_decap_amsdu(ni, m);
 			if (m == NULL)
 				return IEEE80211_FC0_TYPE_DATA;
-		} else if ((ni->ni_ath_flags & IEEE80211_NODE_FF) &&
+		} else if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) &&
 #define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
 		    m->m_pkthdr.len >= 3*FF_LLC_SIZE) {
 			struct llc *llc;

Modified: head/sys/net80211/ieee80211_hostap.c
==============================================================================
--- head/sys/net80211/ieee80211_hostap.c	Thu Oct 30 16:20:42 2008	(r184479)
+++ head/sys/net80211/ieee80211_hostap.c	Thu Oct 30 16:22:04 2008	(r184480)
@@ -752,7 +752,7 @@ hostap_input(struct ieee80211_node *ni, 
 			m = ieee80211_decap_amsdu(ni, m);
 			if (m == NULL)
 				return IEEE80211_FC0_TYPE_DATA;
-		} else if ((ni->ni_ath_flags & IEEE80211_NODE_FF) &&
+		} else if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) &&
 #define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
 		    m->m_pkthdr.len >= 3*FF_LLC_SIZE) {
 			struct llc *llc;

Modified: head/sys/net80211/ieee80211_sta.c
==============================================================================
--- head/sys/net80211/ieee80211_sta.c	Thu Oct 30 16:20:42 2008	(r184479)
+++ head/sys/net80211/ieee80211_sta.c	Thu Oct 30 16:22:04 2008	(r184480)
@@ -795,7 +795,7 @@ sta_input(struct ieee80211_node *ni, str
 			m = ieee80211_decap_amsdu(ni, m);
 			if (m == NULL)
 				return IEEE80211_FC0_TYPE_DATA;
-		} else if ((ni->ni_ath_flags & IEEE80211_NODE_FF) &&
+		} else if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) &&
 #define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
 		    m->m_pkthdr.len >= 3*FF_LLC_SIZE) {
 			struct llc *llc;

Modified: head/sys/net80211/ieee80211_wds.c
==============================================================================
--- head/sys/net80211/ieee80211_wds.c	Thu Oct 30 16:20:42 2008	(r184479)
+++ head/sys/net80211/ieee80211_wds.c	Thu Oct 30 16:22:04 2008	(r184480)
@@ -728,7 +728,7 @@ wds_input(struct ieee80211_node *ni, str
 			m = ieee80211_decap_amsdu(ni, m);
 			if (m == NULL)
 				return IEEE80211_FC0_TYPE_DATA;
-		} else if ((ni->ni_ath_flags & IEEE80211_NODE_FF) &&
+		} else if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) &&
 #define	FF_LLC_SIZE	(sizeof(struct ether_header) + sizeof(struct llc))
 		    m->m_pkthdr.len >= 3*FF_LLC_SIZE) {
 			struct llc *llc;

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 17:47:58 2008
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 407FA1065670;
	Thu, 30 Oct 2008 17:47:58 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2EB128FC16;
	Thu, 30 Oct 2008 17:47:58 +0000 (UTC)
	(envelope-from rwatson@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 m9UHlwBI057770;
	Thu, 30 Oct 2008 17:47:58 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UHlwbj057769;
	Thu, 30 Oct 2008 17:47:58 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810301747.m9UHlwbj057769@svn.freebsd.org>
From: Robert Watson 
Date: Thu, 30 Oct 2008 17:47:58 +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: r184482 - head/sys/security/audit
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: Thu, 30 Oct 2008 17:47:58 -0000

Author: rwatson
Date: Thu Oct 30 17:47:57 2008
New Revision: 184482
URL: http://svn.freebsd.org/changeset/base/184482

Log:
  Protect the event->class lookup database using an rwlock instead of a
  mutex, as it's rarely changed but frequently accessed read-only from
  multiple threads, so a potentially significant source of contention.
  
  MFC after:	1 month
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_bsm_klib.c

Modified: head/sys/security/audit/audit_bsm_klib.c
==============================================================================
--- head/sys/security/audit/audit_bsm_klib.c	Thu Oct 30 16:29:04 2008	(r184481)
+++ head/sys/security/audit/audit_bsm_klib.c	Thu Oct 30 17:47:57 2008	(r184482)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999-2005 Apple Inc.
+ * Copyright (c) 1999-2008 Apple Inc.
  * Copyright (c) 2005 Robert N. M. Watson
  * All rights reserved.
  *
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -65,9 +66,15 @@ struct evclass_list {
 };
 
 static MALLOC_DEFINE(M_AUDITEVCLASS, "audit_evclass", "Audit event class");
-static struct mtx		evclass_mtx;
+static struct rwlock		evclass_lock;
 static struct evclass_list	evclass_hash[EVCLASSMAP_HASH_TABLE_SIZE];
 
+#define	EVCLASS_LOCK_INIT()	rw_init(&evclass_lock, "evclass_lock")
+#define	EVCLASS_RLOCK()		rw_rlock(&evclass_lock)
+#define	EVCLASS_RUNLOCK()	rw_runlock(&evclass_lock)
+#define	EVCLASS_WLOCK()		rw_wlock(&evclass_lock)
+#define	EVCLASS_WUNLOCK()	rw_wunlock(&evclass_lock)
+
 /*
  * Look up the class for an audit event in the class mapping table.
  */
@@ -78,7 +85,7 @@ au_event_class(au_event_t event)
 	struct evclass_elem *evc;
 	au_class_t class;
 
-	mtx_lock(&evclass_mtx);
+	EVCLASS_RLOCK();
 	evcl = &evclass_hash[event % EVCLASSMAP_HASH_TABLE_SIZE];
 	class = 0;
 	LIST_FOREACH(evc, &evcl->head, entry) {
@@ -88,7 +95,7 @@ au_event_class(au_event_t event)
 		}
 	}
 out:
-	mtx_unlock(&evclass_mtx);
+	EVCLASS_RUNLOCK();
 	return (class);
 }
 
@@ -111,12 +118,12 @@ au_evclassmap_insert(au_event_t event, a
 	 */
 	evc_new = malloc(sizeof(*evc), M_AUDITEVCLASS, M_WAITOK);
 
-	mtx_lock(&evclass_mtx);
+	EVCLASS_WLOCK();
 	evcl = &evclass_hash[event % EVCLASSMAP_HASH_TABLE_SIZE];
 	LIST_FOREACH(evc, &evcl->head, entry) {
 		if (evc->event == event) {
 			evc->class = class;
-			mtx_unlock(&evclass_mtx);
+			EVCLASS_WUNLOCK();
 			free(evc_new, M_AUDITEVCLASS);
 			return;
 		}
@@ -125,7 +132,7 @@ au_evclassmap_insert(au_event_t event, a
 	evc->event = event;
 	evc->class = class;
 	LIST_INSERT_HEAD(&evcl->head, evc, entry);
-	mtx_unlock(&evclass_mtx);
+	EVCLASS_WUNLOCK();
 }
 
 void
@@ -133,7 +140,7 @@ au_evclassmap_init(void)
 {
 	int i;
 
-	mtx_init(&evclass_mtx, "evclass_mtx", NULL, MTX_DEF);
+	EVCLASS_LOCK_INIT();
 	for (i = 0; i < EVCLASSMAP_HASH_TABLE_SIZE; i++)
 		LIST_INIT(&evclass_hash[i].head);
 

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 17:54:20 2008
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 5FCB51065678;
	Thu, 30 Oct 2008 17:54:20 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4EEE48FC26;
	Thu, 30 Oct 2008 17:54:20 +0000 (UTC) (envelope-from mav@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 m9UHsKCc057923;
	Thu, 30 Oct 2008 17:54:20 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UHsKIi057922;
	Thu, 30 Oct 2008 17:54:20 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <200810301754.m9UHsKIi057922@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 30 Oct 2008 17:54:20 +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: r184483 - head/sys/dev/sound/pci/hda
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: Thu, 30 Oct 2008 17:54:20 -0000

Author: mav
Date: Thu Oct 30 17:54:20 2008
New Revision: 184483
URL: http://svn.freebsd.org/changeset/base/184483

Log:
  Add quirk to set GPIO2 to enable internal speaker on Dell Vostro 1400.
  
  Tested by:	Sergio Veloso

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Thu Oct 30 17:47:57 2008	(r184482)
+++ head/sys/dev/sound/pci/hda/hdac.c	Thu Oct 30 17:54:20 2008	(r184483)
@@ -83,7 +83,7 @@
 
 #include "mixer_if.h"
 
-#define HDA_DRV_TEST_REV	"20081024_0114"
+#define HDA_DRV_TEST_REV	"20081030_0115"
 
 SND_DECLARE_FILE("$FreeBSD$");
 
@@ -204,6 +204,7 @@ SND_DECLARE_FILE("$FreeBSD$");
 #define DELL_VENDORID		0x1028
 #define DELL_D630_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01f9)
 #define DELL_D820_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01cc)
+#define DELL_V1400_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0227)
 #define DELL_V1500_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0228)
 #define DELL_I1300_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01c9)
 #define DELL_XPSM1210_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01d7)
@@ -4427,6 +4428,8 @@ static const struct {
 	    HDA_QUIRK_GPIO0 | HDA_QUIRK_GPIO1, 0 },
 	{ DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205X,
 	    HDA_QUIRK_GPIO0, 0 },
+	{ DELL_V1400_SUBVENDOR, HDA_CODEC_STAC9228X,
+	    HDA_QUIRK_GPIO2, 0 },
 	{ DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205X,
 	    HDA_QUIRK_GPIO0, 0 },
 	{ HDA_MATCH_ALL, HDA_CODEC_AD1988,

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 19:51:03 2008
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 5D6F31065696;
	Thu, 30 Oct 2008 19:51:03 +0000 (UTC)
	(envelope-from joerg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4B90E8FC1A;
	Thu, 30 Oct 2008 19:51:03 +0000 (UTC)
	(envelope-from joerg@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 m9UJp2ue060201;
	Thu, 30 Oct 2008 19:51:02 GMT (envelope-from joerg@svn.freebsd.org)
Received: (from joerg@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UJp20Z060200;
	Thu, 30 Oct 2008 19:51:02 GMT (envelope-from joerg@svn.freebsd.org)
Message-Id: <200810301951.m9UJp20Z060200@svn.freebsd.org>
From: Joerg Wunsch 
Date: Thu, 30 Oct 2008 19:51:02 +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: r184484 - head/bin/chio
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: Thu, 30 Oct 2008 19:51:03 -0000

Author: joerg
Date: Thu Oct 30 19:51:02 2008
New Revision: 184484
URL: http://svn.freebsd.org/changeset/base/184484

Log:
  When running a "chio return" operation using a physical source unit
  rather than a voltag name, do not set the CESR_VOLTAGS flags in the
  CHIOGSTATUS command requesting the current status.  As voltags are an
  optional feature that must be handled as "reserved" by media changers
  not implementing the feature, always setting CESR_VOLTAGS resulted in
  the command being aborted with an `Invalid field in CDB', and
  consequently the "chio return" failed, for media changers that do not
  support voltags.
  
  MFC after:	1 week

Modified:
  head/bin/chio/chio.c

Modified: head/bin/chio/chio.c
==============================================================================
--- head/bin/chio/chio.c	Thu Oct 30 17:54:20 2008	(r184483)
+++ head/bin/chio/chio.c	Thu Oct 30 19:51:02 2008	(r184484)
@@ -69,7 +69,7 @@ static	const char *bits_to_string(ces_st
 
 static	void find_element(char *, uint16_t *, uint16_t *);
 static	struct changer_element_status *get_element_status
-	   (unsigned int, unsigned int);
+	   (unsigned int, unsigned int, int);
 
 static	int do_move(const char *, int, char **);
 static	int do_exchange(const char *, int, char **);
@@ -969,7 +969,8 @@ do_return(const char *cname, int argc, c
 	++argv; --argc;
 
 	/* Get the status */
-	ces = get_element_status((unsigned int)type, (unsigned int)element);
+	ces = get_element_status((unsigned int)type, (unsigned int)element,
+	    CHET_VT == type);
 
 	if (NULL == ces)
 		errx(1, "%s: null element status pointer", cname);
@@ -1004,7 +1005,7 @@ usage:
  * should free() it when done.
  */
 static struct changer_element_status *
-get_element_status(unsigned int type, unsigned int element)
+get_element_status(unsigned int type, unsigned int element, int use_voltags)
 {
 	struct changer_element_status_request cesr;
 	struct changer_element_status *ces;
@@ -1020,7 +1021,8 @@ get_element_status(unsigned int type, un
 	cesr.cesr_element_type = (uint16_t)type;
 	cesr.cesr_element_base = (uint16_t)element;
 	cesr.cesr_element_count = 1;		/* Only this one element */
-	cesr.cesr_flags |= CESR_VOLTAGS;	/* Grab voltags as well */
+	if (use_voltags)
+		cesr.cesr_flags |= CESR_VOLTAGS; /* Grab voltags as well */
 	cesr.cesr_element_status = ces;
 
 	if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) {

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 20:24:26 2008
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 22E1B1065670;
	Thu, 30 Oct 2008 20:24:26 +0000 (UTC) (envelope-from pjd@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 118ED8FC2A;
	Thu, 30 Oct 2008 20:24:26 +0000 (UTC) (envelope-from pjd@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 m9UKOPj7060859;
	Thu, 30 Oct 2008 20:24:25 GMT (envelope-from pjd@svn.freebsd.org)
Received: (from pjd@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UKOPm4060858;
	Thu, 30 Oct 2008 20:24:25 GMT (envelope-from pjd@svn.freebsd.org)
Message-Id: <200810302024.m9UKOPm4060858@svn.freebsd.org>
From: Pawel Jakub Dawidek 
Date: Thu, 30 Oct 2008 20:24:25 +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: r184485 - head/etc/rc.d
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: Thu, 30 Oct 2008 20:24:26 -0000

Author: pjd
Date: Thu Oct 30 20:24:25 2008
New Revision: 184485
URL: http://svn.freebsd.org/changeset/base/184485

Log:
  ifconfig(8) can take only one interface at a time.

Modified:
  head/etc/rc.d/netif

Modified: head/etc/rc.d/netif
==============================================================================
--- head/etc/rc.d/netif	Thu Oct 30 19:51:02 2008	(r184484)
+++ head/etc/rc.d/netif	Thu Oct 30 20:24:25 2008	(r184485)
@@ -141,7 +141,9 @@ network_common()
 		esac
 		echo "${_str} Network:${_ok}."
 		if [ -z "${rc_quiet}" ]; then
-			/sbin/ifconfig ${_ok}
+			for ifn in ${_ok}; do
+				/sbin/ifconfig ${ifn}
+			done
 		fi
 	fi
 

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 21:02:00 2008
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 BDBA51065678;
	Thu, 30 Oct 2008 21:02:00 +0000 (UTC)
	(envelope-from sobomax@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AC2B28FC08;
	Thu, 30 Oct 2008 21:02:00 +0000 (UTC)
	(envelope-from sobomax@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 m9UL20md061671;
	Thu, 30 Oct 2008 21:02:00 GMT (envelope-from sobomax@svn.freebsd.org)
Received: (from sobomax@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UL20sH061670;
	Thu, 30 Oct 2008 21:02:00 GMT (envelope-from sobomax@svn.freebsd.org)
Message-Id: <200810302102.m9UL20sH061670@svn.freebsd.org>
From: Maxim Sobolev 
Date: Thu, 30 Oct 2008 21:02:00 +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: r184486 - head/sys/powerpc/include
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: Thu, 30 Oct 2008 21:02:00 -0000

Author: sobomax
Date: Thu Oct 30 21:02:00 2008
New Revision: 184486
URL: http://svn.freebsd.org/changeset/base/184486

Log:
  Fix compilation in the case when kernel doesn't have KDB ebabled.
  subr_kdb.c still references breakpoint() in this case.

Modified:
  head/sys/powerpc/include/cpufunc.h

Modified: head/sys/powerpc/include/cpufunc.h
==============================================================================
--- head/sys/powerpc/include/cpufunc.h	Thu Oct 30 20:24:25 2008	(r184485)
+++ head/sys/powerpc/include/cpufunc.h	Thu Oct 30 21:02:00 2008	(r184486)
@@ -50,6 +50,13 @@ struct thread;
 
 #ifdef KDB
 void breakpoint(void);
+#else
+static __inline void
+breakpoint(void)
+{
+
+	return;
+}
 #endif
 
 /* CPU register mangling inlines */

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 21:48:29 2008
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 53B32106567B;
	Thu, 30 Oct 2008 21:48:29 +0000 (UTC)
	(envelope-from sobomax@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 425858FC0C;
	Thu, 30 Oct 2008 21:48:29 +0000 (UTC)
	(envelope-from sobomax@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 m9ULmTLR062493;
	Thu, 30 Oct 2008 21:48:29 GMT (envelope-from sobomax@svn.freebsd.org)
Received: (from sobomax@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9ULmTDu062491;
	Thu, 30 Oct 2008 21:48:29 GMT (envelope-from sobomax@svn.freebsd.org)
Message-Id: <200810302148.m9ULmTDu062491@svn.freebsd.org>
From: Maxim Sobolev 
Date: Thu, 30 Oct 2008 21:48:28 +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: r184487 - in head/sys: conf kern
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: Thu, 30 Oct 2008 21:48:29 -0000

Author: sobomax
Date: Thu Oct 30 21:48:28 2008
New Revision: 184487
URL: http://svn.freebsd.org/changeset/base/184487

Log:
  Make it possible to compile kernel with KTR but without DDB.

Modified:
  head/sys/conf/files
  head/sys/kern/subr_stack.c

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Thu Oct 30 21:02:00 2008	(r184486)
+++ head/sys/conf/files	Thu Oct 30 21:48:28 2008	(r184487)
@@ -1691,7 +1691,7 @@ kern/subr_sbuf.c		standard
 kern/subr_scanf.c		standard
 kern/subr_sleepqueue.c		standard
 kern/subr_smp.c			standard
-kern/subr_stack.c		optional ddb | stack
+kern/subr_stack.c		optional ddb | stack | ktr
 kern/subr_taskqueue.c		standard
 kern/subr_trap.c		standard
 kern/subr_turnstile.c		standard

Modified: head/sys/kern/subr_stack.c
==============================================================================
--- head/sys/kern/subr_stack.c	Thu Oct 30 21:02:00 2008	(r184486)
+++ head/sys/kern/subr_stack.c	Thu Oct 30 21:48:28 2008	(r184487)
@@ -155,15 +155,18 @@ stack_sbuf_print_ddb(struct sbuf *sb, st
 		    name, offset);
 	}
 }
+#endif
 
 #ifdef KTR
 void
 stack_ktr(u_int mask, const char *file, int line, struct stack *st, u_int depth,
     int cheap)
 {
+#ifdef DDB
 	const char *name;
 	long offset;
 	int i;
+#endif
 
 	KASSERT(st->depth <= STACK_MAX, ("bogus stack"));
 	if (cheap) {
@@ -180,6 +183,7 @@ stack_ktr(u_int mask, const char *file, 
 		ktr_tracepoint(mask, file, line, "#2 %p %p %p %p %p %p",
 		    st->pcs[12], st->pcs[13], st->pcs[14], st->pcs[15],
 		    st->pcs[16], st->pcs[17]);
+#ifdef DDB
 	} else {
 		if (depth == 0 || st->depth < depth)
 			depth = st->depth;
@@ -188,10 +192,10 @@ stack_ktr(u_int mask, const char *file, 
 			ktr_tracepoint(mask, file, line, "#%d %p at %s+%#lx",
 			    i, st->pcs[i], (u_long)name, offset, 0, 0);
 		}
+#endif
 	}
 }
 #endif
-#endif
 
 /*
  * Two variants of stack symbol lookup -- one that uses the DDB interfaces

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 21:58:41 2008
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 6EF971065677;
	Thu, 30 Oct 2008 21:58:41 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1EFE98FC2B;
	Thu, 30 Oct 2008 21:58:40 +0000 (UTC)
	(envelope-from rwatson@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 m9ULwdLM062712;
	Thu, 30 Oct 2008 21:58:39 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9ULwdlk062711;
	Thu, 30 Oct 2008 21:58:39 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810302158.m9ULwdlk062711@svn.freebsd.org>
From: Robert Watson 
Date: Thu, 30 Oct 2008 21:58:39 +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: r184488 - head/sys/security/audit
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: Thu, 30 Oct 2008 21:58:41 -0000

Author: rwatson
Date: Thu Oct 30 21:58:39 2008
New Revision: 184488
URL: http://svn.freebsd.org/changeset/base/184488

Log:
  Break out single audit_pipe_mtx into two types of locks: a global rwlock
  protecting the list of audit pipes, and a per-pipe mutex protecting the
  queue.
  
  Likewise, replace the single global condition variable used to signal
  delivery of a record to one or more pipes, and add a per-pipe condition
  variable to avoid spurious wakeups when event subscriptions differ
  across multiple pipes.
  
  This slightly increases the cost of delivering to audit pipes, but should
  reduce lock contention in the presence of multiple readers as only the
  per-pipe lock is required to read from a pipe, as well as avoid
  overheading when different pipes are used in different ways.
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Thu Oct 30 21:48:28 2008	(r184487)
+++ head/sys/security/audit/audit_pipe.c	Thu Oct 30 21:58:39 2008	(r184488)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2006 Robert N. M. Watson
+ * Copyright (c) 2008 Apple, Inc.
  * All rights reserved.
  *
  * This software was developed by Robert Watson for the TrustedBSD Project.
@@ -41,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -115,6 +117,17 @@ struct audit_pipe {
 	struct selinfo			 ap_selinfo;
 	struct sigio			*ap_sigio;
 
+	/*
+	 * Per-pipe mutex protecting most fields in this data structure.
+	 */
+	struct mtx			 ap_lock;
+
+	/*
+	 * Condition variable to signal when data has been delivered to a
+	 * pipe.
+	 */
+	struct cv			 ap_cv;
+
 	u_int				 ap_qlen;
 	u_int				 ap_qlimit;
 
@@ -144,19 +157,31 @@ struct audit_pipe {
 	TAILQ_ENTRY(audit_pipe)		 ap_list;
 };
 
+#define	AUDIT_PIPE_LOCK(ap)	mtx_lock(&(ap)->ap_lock)
+#define	AUDIT_PIPE_LOCK_ASSERT(ap)	mtx_assert(&(ap)->ap_lock, MA_OWNED)
+#define	AUDIT_PIPE_LOCK_DESTROY(ap)	mtx_destroy(&(ap)->ap_lock)
+#define	AUDIT_PIPE_LOCK_INIT(ap)	mtx_init(&(ap)->ap_lock, \
+					    "audit_pipe_lock", NULL, MTX_DEF)
+#define	AUDIT_PIPE_UNLOCK(ap)	mtx_unlock(&(ap)->ap_lock)
+#define	AUDIT_PIPE_MTX(ap)	(&(ap)->ap_lock)
+
 /*
- * Global list of audit pipes, mutex to protect it and the pipes.  Finer
- * grained locking may be desirable at some point.
+ * Global list of audit pipes, rwlock to protect it.  Individual record
+ * queues on pipes are protected by per-pipe locks; these locks synchronize
+ * between threads walking the list to deliver to individual pipes and add/
+ * remove of pipes, and are mostly acquired for read.
  */
 static TAILQ_HEAD(, audit_pipe)	 audit_pipe_list;
-static struct mtx		 audit_pipe_mtx;
+static struct rwlock		 audit_pipe_lock;
 
-/*
- * This CV is used to wakeup on an audit record write.  Eventually, it might
- * be per-pipe to avoid unnecessary wakeups when several pipes with different
- * preselection masks are present.
- */
-static struct cv		 audit_pipe_cv;
+#define	AUDIT_PIPE_LIST_LOCK_INIT()	rw_init(&audit_pipe_lock, \
+					    "audit_pipe_list_lock")
+#define	AUDIT_PIPE_LIST_RLOCK()		rw_rlock(&audit_pipe_lock)
+#define	AUDIT_PIPE_LIST_RUNLOCK()	rw_runlock(&audit_pipe_lock)
+#define	AUDIT_PIPE_LIST_WLOCK()		rw_wlock(&audit_pipe_lock)
+#define	AUDIT_PIPE_LIST_WLOCK_ASSERT()	rw_assert(&audit_pipe_lock, \
+					    RA_WLOCKED)
+#define	AUDIT_PIPE_LIST_WUNLOCK()	rw_wunlock(&audit_pipe_lock)
 
 /*
  * Cloning related variables and constants.
@@ -224,7 +249,7 @@ audit_pipe_preselect_find(struct audit_p
 {
 	struct audit_pipe_preselect *app;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	TAILQ_FOREACH(app, &ap->ap_preselect_list, app_list) {
 		if (app->app_auid == auid)
@@ -243,14 +268,14 @@ audit_pipe_preselect_get(struct audit_pi
 	struct audit_pipe_preselect *app;
 	int error;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	app = audit_pipe_preselect_find(ap, auid);
 	if (app != NULL) {
 		*maskp = app->app_mask;
 		error = 0;
 	} else
 		error = ENOENT;
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 	return (error);
 }
 
@@ -268,7 +293,7 @@ audit_pipe_preselect_set(struct audit_pi
 	 * set, and allocate.  We will free it if it is unneeded.
 	 */
 	app_new = malloc(sizeof(*app_new), M_AUDIT_PIPE_PRESELECT, M_WAITOK);
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	app = audit_pipe_preselect_find(ap, auid);
 	if (app == NULL) {
 		app = app_new;
@@ -277,7 +302,7 @@ audit_pipe_preselect_set(struct audit_pi
 		TAILQ_INSERT_TAIL(&ap->ap_preselect_list, app, app_list);
 	}
 	app->app_mask = mask;
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 	if (app_new != NULL)
 		free(app_new, M_AUDIT_PIPE_PRESELECT);
 }
@@ -291,14 +316,14 @@ audit_pipe_preselect_delete(struct audit
 	struct audit_pipe_preselect *app;
 	int error;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	app = audit_pipe_preselect_find(ap, auid);
 	if (app != NULL) {
 		TAILQ_REMOVE(&ap->ap_preselect_list, app, app_list);
 		error = 0;
 	} else
 		error = ENOENT;
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 	if (app != NULL)
 		free(app, M_AUDIT_PIPE_PRESELECT);
 	return (error);
@@ -312,7 +337,7 @@ audit_pipe_preselect_flush_locked(struct
 {
 	struct audit_pipe_preselect *app;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	while ((app = TAILQ_FIRST(&ap->ap_preselect_list)) != NULL) {
 		TAILQ_REMOVE(&ap->ap_preselect_list, app, app_list);
@@ -324,9 +349,9 @@ static void
 audit_pipe_preselect_flush(struct audit_pipe *ap)
 {
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	audit_pipe_preselect_flush_locked(ap);
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 }
 
 /*-
@@ -345,7 +370,7 @@ audit_pipe_preselect_check(struct audit_
 {
 	struct audit_pipe_preselect *app;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	switch (ap->ap_preselect_mode) {
 	case AUDITPIPE_PRESELECT_MODE_TRAIL:
@@ -382,15 +407,18 @@ audit_pipe_preselect(au_id_t auid, au_ev
 {
 	struct audit_pipe *ap;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_RLOCK();
 	TAILQ_FOREACH(ap, &audit_pipe_list, ap_list) {
+		AUDIT_PIPE_LOCK(ap);
 		if (audit_pipe_preselect_check(ap, auid, event, class, sorf,
 		    trail_preselect)) {
-			mtx_unlock(&audit_pipe_mtx);
+			AUDIT_PIPE_UNLOCK(ap);
+			AUDIT_PIPE_LIST_RUNLOCK();
 			return (1);
 		}
+		AUDIT_PIPE_UNLOCK(ap);
 	}
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_RUNLOCK();
 	return (0);
 }
 
@@ -405,7 +433,7 @@ audit_pipe_append(struct audit_pipe *ap,
 {
 	struct audit_pipe_entry *ape, *ape_remove;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	ape = malloc(sizeof(*ape), M_AUDIT_PIPE_ENTRY, M_NOWAIT | M_ZERO);
 	if (ape == NULL) {
@@ -441,6 +469,7 @@ audit_pipe_append(struct audit_pipe *ap,
 	KNOTE_LOCKED(&ap->ap_selinfo.si_note, 0);
 	if (ap->ap_flags & AUDIT_PIPE_ASYNC)
 		pgsigio(&ap->ap_sigio, SIGIO, 0);
+	cv_broadcast(&ap->ap_cv);
 }
 
 /*
@@ -454,20 +483,23 @@ audit_pipe_submit(au_id_t auid, au_event
 	struct audit_pipe *ap;
 
 	/*
-	 * Lockless read to avoid mutex overhead if pipes are not in use.
+	 * Lockless read to avoid lock overhead if pipes are not in use.
 	 */
 	if (TAILQ_FIRST(&audit_pipe_list) == NULL)
 		return;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_RLOCK();
 	TAILQ_FOREACH(ap, &audit_pipe_list, ap_list) {
+		AUDIT_PIPE_LOCK(ap);
 		if (audit_pipe_preselect_check(ap, auid, event, class, sorf,
 		    trail_select))
 			audit_pipe_append(ap, record, record_len);
+		AUDIT_PIPE_UNLOCK(ap);
 	}
+	AUDIT_PIPE_LIST_RUNLOCK();
+
+	/* Unlocked increment. */
 	audit_pipe_records++;
-	mtx_unlock(&audit_pipe_mtx);
-	cv_broadcastpri(&audit_pipe_cv, PSOCK);
 }
 
 /*
@@ -484,17 +516,21 @@ audit_pipe_submit_user(void *record, u_i
 	struct audit_pipe *ap;
 
 	/*
-	 * Lockless read to avoid mutex overhead if pipes are not in use.
+	 * Lockless read to avoid lock overhead if pipes are not in use.
 	 */
 	if (TAILQ_FIRST(&audit_pipe_list) == NULL)
 		return;
 
-	mtx_lock(&audit_pipe_mtx);
-	TAILQ_FOREACH(ap, &audit_pipe_list, ap_list)
+	AUDIT_PIPE_LIST_RLOCK();
+	TAILQ_FOREACH(ap, &audit_pipe_list, ap_list) {
+		AUDIT_PIPE_LOCK(ap);
 		audit_pipe_append(ap, record, record_len);
+		AUDIT_PIPE_UNLOCK(ap);
+	}
+	AUDIT_PIPE_LIST_RUNLOCK();
+
+	/* Unlocked increment. */
 	audit_pipe_records++;
-	mtx_unlock(&audit_pipe_mtx);
-	cv_broadcastpri(&audit_pipe_cv, PSOCK);
 }
 
 /*
@@ -505,7 +541,7 @@ audit_pipe_pop(struct audit_pipe *ap)
 {
 	struct audit_pipe_entry *ape;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	ape = TAILQ_FIRST(&ap->ap_queue);
 	KASSERT((ape == NULL && ap->ap_qlen == 0) ||
@@ -526,15 +562,17 @@ audit_pipe_alloc(void)
 {
 	struct audit_pipe *ap;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LIST_WLOCK_ASSERT();
 
 	ap = malloc(sizeof(*ap), M_AUDIT_PIPE, M_NOWAIT | M_ZERO);
 	if (ap == NULL)
 		return (NULL);
 	ap->ap_qlimit = AUDIT_PIPE_QLIMIT_DEFAULT;
 	TAILQ_INIT(&ap->ap_queue);
-	knlist_init(&ap->ap_selinfo.si_note, &audit_pipe_mtx, NULL, NULL,
+	knlist_init(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap), NULL, NULL,
 	    NULL);
+	AUDIT_PIPE_LOCK_INIT(ap);
+	cv_init(&ap->ap_cv, "audit_pipe");
 
 	/*
 	 * Default flags, naflags, and auid-specific preselection settings to
@@ -566,7 +604,7 @@ audit_pipe_flush(struct audit_pipe *ap)
 {
 	struct audit_pipe_entry *ape;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	while ((ape = TAILQ_FIRST(&ap->ap_queue)) != NULL) {
 		TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
@@ -578,18 +616,21 @@ audit_pipe_flush(struct audit_pipe *ap)
 
 /*
  * Free an audit pipe; this means freeing all preselection state and all
- * records in the pipe.  Assumes mutex is held to prevent any new records
- * from being inserted during the free, and that the audit pipe is still on
- * the global list.
+ * records in the pipe.  Assumes global write lock and pipe mutex are held to
+ * prevent any new records from being inserted during the free, and that the
+ * audit pipe is still on the global list.
  */
 static void
 audit_pipe_free(struct audit_pipe *ap)
 {
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
+	AUDIT_PIPE_LIST_WLOCK_ASSERT();
+	AUDIT_PIPE_LOCK_ASSERT(ap);
 
 	audit_pipe_preselect_flush_locked(ap);
 	audit_pipe_flush(ap);
+	cv_destroy(&ap->ap_cv);
+	AUDIT_PIPE_LOCK_DESTROY(ap);
 	knlist_destroy(&ap->ap_selinfo.si_note);
 	TAILQ_REMOVE(&audit_pipe_list, ap, ap_list);
 	free(ap, M_AUDIT_PIPE);
@@ -635,22 +676,22 @@ audit_pipe_open(struct cdev *dev, int of
 {
 	struct audit_pipe *ap;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_WLOCK();
 	ap = dev->si_drv1;
 	if (ap == NULL) {
 		ap = audit_pipe_alloc();
 		if (ap == NULL) {
-			mtx_unlock(&audit_pipe_mtx);
+			AUDIT_PIPE_LIST_WUNLOCK();
 			return (ENOMEM);
 		}
 		dev->si_drv1 = ap;
 	} else {
 		KASSERT(ap->ap_open, ("audit_pipe_open: ap && !ap_open"));
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_LIST_WUNLOCK();
 		return (EBUSY);
 	}
-	ap->ap_open = 1;
-	mtx_unlock(&audit_pipe_mtx);
+	ap->ap_open = 1;	/* No lock required yet. */
+	AUDIT_PIPE_LIST_WUNLOCK();
 	fsetown(td->td_proc->p_pid, &ap->ap_sigio);
 	return (0);
 }
@@ -666,12 +707,14 @@ audit_pipe_close(struct cdev *dev, int f
 	ap = dev->si_drv1;
 	KASSERT(ap != NULL, ("audit_pipe_close: ap == NULL"));
 	KASSERT(ap->ap_open, ("audit_pipe_close: !ap_open"));
+
 	funsetown(&ap->ap_sigio);
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_WLOCK();
+	AUDIT_PIPE_LOCK(ap);
 	ap->ap_open = 0;
 	audit_pipe_free(ap);
 	dev->si_drv1 = NULL;
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_LIST_WUNLOCK();
 	return (0);
 }
 
@@ -702,33 +745,33 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 	 */
 	switch (cmd) {
 	case FIONBIO:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		if (*(int *)data)
 			ap->ap_flags |= AUDIT_PIPE_NBIO;
 		else
 			ap->ap_flags &= ~AUDIT_PIPE_NBIO;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
 	case FIONREAD:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		if (TAILQ_FIRST(&ap->ap_queue) != NULL)
 			*(int *)data =
 			    TAILQ_FIRST(&ap->ap_queue)->ape_record_len;
 		else
 			*(int *)data = 0;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
 	case FIOASYNC:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		if (*(int *)data)
 			ap->ap_flags |= AUDIT_PIPE_ASYNC;
 		else
 			ap->ap_flags &= ~AUDIT_PIPE_ASYNC;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
@@ -772,34 +815,34 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		break;
 
 	case AUDITPIPE_GET_PRESELECT_FLAGS:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		maskp = (au_mask_t *)data;
 		*maskp = ap->ap_preselect_flags;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
 	case AUDITPIPE_SET_PRESELECT_FLAGS:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		maskp = (au_mask_t *)data;
 		ap->ap_preselect_flags = *maskp;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
 	case AUDITPIPE_GET_PRESELECT_NAFLAGS:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		maskp = (au_mask_t *)data;
 		*maskp = ap->ap_preselect_naflags;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
 	case AUDITPIPE_SET_PRESELECT_NAFLAGS:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		maskp = (au_mask_t *)data;
 		ap->ap_preselect_naflags = *maskp;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
@@ -826,9 +869,9 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		break;
 
 	case AUDITPIPE_GET_PRESELECT_MODE:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		*(int *)data = ap->ap_preselect_mode;
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
@@ -837,9 +880,9 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		switch (mode) {
 		case AUDITPIPE_PRESELECT_MODE_TRAIL:
 		case AUDITPIPE_PRESELECT_MODE_LOCAL:
-			mtx_lock(&audit_pipe_mtx);
+			AUDIT_PIPE_LOCK(ap);
 			ap->ap_preselect_mode = mode;
-			mtx_unlock(&audit_pipe_mtx);
+			AUDIT_PIPE_UNLOCK(ap);
 			error = 0;
 			break;
 
@@ -849,9 +892,9 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		break;
 
 	case AUDITPIPE_FLUSH:
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		audit_pipe_flush(ap);
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
 
@@ -910,7 +953,8 @@ audit_pipe_read(struct cdev *dev, struct
 
 	ap = dev->si_drv1;
 	KASSERT(ap != NULL, ("audit_pipe_read: ap == NULL"));
-	mtx_lock(&audit_pipe_mtx);
+
+	AUDIT_PIPE_LOCK(ap);
 	do {
 		/*
 		 * Wait for a record that fits into the read buffer, dropping
@@ -920,12 +964,12 @@ audit_pipe_read(struct cdev *dev, struct
 		 */
 		while ((ape = audit_pipe_pop(ap)) == NULL) {
 			if (ap->ap_flags & AUDIT_PIPE_NBIO) {
-				mtx_unlock(&audit_pipe_mtx);
+				AUDIT_PIPE_UNLOCK(ap);
 				return (EAGAIN);
 			}
-			error = cv_wait_sig(&audit_pipe_cv, &audit_pipe_mtx);
+			error = cv_wait_sig(&ap->ap_cv, AUDIT_PIPE_MTX(ap));
 			if (error) {
-				mtx_unlock(&audit_pipe_mtx);
+				AUDIT_PIPE_UNLOCK(ap);
 				return (error);
 			}
 		}
@@ -935,7 +979,7 @@ audit_pipe_read(struct cdev *dev, struct
 		ap->ap_truncates++;
 	} while (1);
 	ap->ap_reads++;
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 
 	/*
 	 * Now read record to user space memory.  Even if the read is short,
@@ -959,13 +1003,14 @@ audit_pipe_poll(struct cdev *dev, int ev
 	revents = 0;
 	ap = dev->si_drv1;
 	KASSERT(ap != NULL, ("audit_pipe_poll: ap == NULL"));
+
 	if (events & (POLLIN | POLLRDNORM)) {
-		mtx_lock(&audit_pipe_mtx);
+		AUDIT_PIPE_LOCK(ap);
 		if (TAILQ_FIRST(&ap->ap_queue) != NULL)
 			revents |= events & (POLLIN | POLLRDNORM);
 		else
 			selrecord(td, &ap->ap_selinfo);
-		mtx_unlock(&audit_pipe_mtx);
+		AUDIT_PIPE_UNLOCK(ap);
 	}
 	return (revents);
 }
@@ -987,9 +1032,9 @@ audit_pipe_kqfilter(struct cdev *dev, st
 	kn->kn_fop = &audit_pipe_read_filterops;
 	kn->kn_hook = ap;
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	knlist_add(&ap->ap_selinfo.si_note, kn, 1);
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 	return (0);
 }
 
@@ -1002,11 +1047,11 @@ audit_pipe_kqread(struct knote *kn, long
 	struct audit_pipe_entry *ape;
 	struct audit_pipe *ap;
 
-	mtx_assert(&audit_pipe_mtx, MA_OWNED);
-
 	ap = (struct audit_pipe *)kn->kn_hook;
 	KASSERT(ap != NULL, ("audit_pipe_kqread: ap == NULL"));
 
+	AUDIT_PIPE_LOCK_ASSERT(ap);
+
 	if (ap->ap_qlen != 0) {
 		ape = TAILQ_FIRST(&ap->ap_queue);
 		KASSERT(ape != NULL, ("audit_pipe_kqread: ape == NULL"));
@@ -1030,9 +1075,9 @@ audit_pipe_kqdetach(struct knote *kn)
 	ap = (struct audit_pipe *)kn->kn_hook;
 	KASSERT(ap != NULL, ("audit_pipe_kqdetach: ap == NULL"));
 
-	mtx_lock(&audit_pipe_mtx);
+	AUDIT_PIPE_LOCK(ap);
 	knlist_remove(&ap->ap_selinfo.si_note, kn, 1);
-	mtx_unlock(&audit_pipe_mtx);
+	AUDIT_PIPE_UNLOCK(ap);
 }
 
 /*
@@ -1043,8 +1088,7 @@ audit_pipe_init(void *unused)
 {
 
 	TAILQ_INIT(&audit_pipe_list);
-	mtx_init(&audit_pipe_mtx, "audit_pipe_mtx", NULL, MTX_DEF);
-	cv_init(&audit_pipe_cv, "audit_pipe_cv");
+	AUDIT_PIPE_LIST_LOCK_INIT();
 
 	clone_setup(&audit_pipe_clones);
 	audit_pipe_eh_tag = EVENTHANDLER_REGISTER(dev_clone,

From owner-svn-src-head@FreeBSD.ORG  Thu Oct 30 23:09:20 2008
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 71F7E1065675;
	Thu, 30 Oct 2008 23:09:20 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 52D398FC1A;
	Thu, 30 Oct 2008 23:09:20 +0000 (UTC)
	(envelope-from rwatson@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 m9UN9K8M063984;
	Thu, 30 Oct 2008 23:09:20 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9UN9KdY063983;
	Thu, 30 Oct 2008 23:09:20 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810302309.m9UN9KdY063983@svn.freebsd.org>
From: Robert Watson 
Date: Thu, 30 Oct 2008 23:09:20 +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: r184489 - head/sys/security/audit
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: Thu, 30 Oct 2008 23:09:20 -0000

Author: rwatson
Date: Thu Oct 30 23:09:19 2008
New Revision: 184489
URL: http://svn.freebsd.org/changeset/base/184489

Log:
  When we drop an audit record going to and audit pipe because the audit
  pipe has overflowed, drop the newest, rather than oldest, record.  This
  makes overflow drop behavior consistent with memory allocation failure
  leading to drop, avoids touching the consumer end of the queue from a
  producer, and lowers the CPU overhead of dropping a record by dropping
  before memory allocation and copying.
  
  Obtained from:	Apple, Inc.
  MFC after:	2 months

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Thu Oct 30 21:58:39 2008	(r184488)
+++ head/sys/security/audit/audit_pipe.c	Thu Oct 30 23:09:19 2008	(r184489)
@@ -424,17 +424,22 @@ audit_pipe_preselect(au_id_t auid, au_ev
 
 /*
  * Append individual record to a queue -- allocate queue-local buffer, and
- * add to the queue.  We try to drop from the head of the queue so that more
- * recent events take precedence over older ones, but if allocation fails we
- * do drop the new event.
+ * add to the queue.  If the queue is full or we can't allocate memory, drop
+ * the newest record.
  */
 static void
 audit_pipe_append(struct audit_pipe *ap, void *record, u_int record_len)
 {
-	struct audit_pipe_entry *ape, *ape_remove;
+	struct audit_pipe_entry *ape;
 
 	AUDIT_PIPE_LOCK_ASSERT(ap);
 
+	if (ap->ap_qlen >= ap->ap_qlimit) {
+		ap->ap_drops++;
+		audit_pipe_drops++;
+		return;
+	}
+
 	ape = malloc(sizeof(*ape), M_AUDIT_PIPE_ENTRY, M_NOWAIT | M_ZERO);
 	if (ape == NULL) {
 		ap->ap_drops++;
@@ -453,15 +458,6 @@ audit_pipe_append(struct audit_pipe *ap,
 	bcopy(record, ape->ape_record, record_len);
 	ape->ape_record_len = record_len;
 
-	if (ap->ap_qlen >= ap->ap_qlimit) {
-		ape_remove = TAILQ_FIRST(&ap->ap_queue);
-		TAILQ_REMOVE(&ap->ap_queue, ape_remove, ape_queue);
-		audit_pipe_entry_free(ape_remove);
-		ap->ap_qlen--;
-		ap->ap_drops++;
-		audit_pipe_drops++;
-	}
-
 	TAILQ_INSERT_TAIL(&ap->ap_queue, ape, ape_queue);
 	ap->ap_inserts++;
 	ap->ap_qlen++;

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 00:52:31 2008
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 D17941065676;
	Fri, 31 Oct 2008 00:52:31 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BE34E8FC22;
	Fri, 31 Oct 2008 00:52:31 +0000 (UTC)
	(envelope-from nwhitehorn@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 m9V0qVLK065965;
	Fri, 31 Oct 2008 00:52:31 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9V0qV0F065963;
	Fri, 31 Oct 2008 00:52:31 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <200810310052.m9V0qV0F065963@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Fri, 31 Oct 2008 00:52:31 +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: r184490 - head/sys/boot/powerpc/boot1.chrp
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: Fri, 31 Oct 2008 00:52:31 -0000

Author: nwhitehorn
Date: Fri Oct 31 00:52:31 2008
New Revision: 184490
URL: http://svn.freebsd.org/changeset/base/184490

Log:
  Modify our boot block to pick an output device, without which boot1 will fail
  on G4 machines. On the assumption that most people using FreeBSD on Apple
  hardware are not using serial consoles, set boot1's output to screen. This
  should be revisited. While here, reduce verbosity of boot1.

Modified:
  head/sys/boot/powerpc/boot1.chrp/boot1.c
  head/sys/boot/powerpc/boot1.chrp/bootinfo.txt

Modified: head/sys/boot/powerpc/boot1.chrp/boot1.c
==============================================================================
--- head/sys/boot/powerpc/boot1.chrp/boot1.c	Thu Oct 30 23:09:19 2008	(r184489)
+++ head/sys/boot/powerpc/boot1.chrp/boot1.c	Fri Oct 31 00:52:31 2008	(r184490)
@@ -561,6 +561,10 @@ printf(const char *fmt, ...)
 	va_list ap;
 	int ret;
 
+	/* Don't annoy the user as we probe for partitions */
+	if (strcmp(fmt,"Not ufs\n") == 0)
+		return 0;
+
 	va_start(ap, fmt);
 	ret = vprintf(fmt, ap);
 	va_end(ap);

Modified: head/sys/boot/powerpc/boot1.chrp/bootinfo.txt
==============================================================================
--- head/sys/boot/powerpc/boot1.chrp/bootinfo.txt	Thu Oct 30 23:09:19 2008	(r184489)
+++ head/sys/boot/powerpc/boot1.chrp/bootinfo.txt	Fri Oct 31 00:52:31 2008	(r184490)
@@ -7,6 +7,7 @@
 MacRISC MacRISC3 MacRISC4
 
 
+" screen" output
 boot &device;:&partition;,\ppc\boot1.elf
 
 

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 05:43:19 2008
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 C4D7B1065670;
	Fri, 31 Oct 2008 05:43:19 +0000 (UTC)
	(envelope-from peter@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B75648FC12;
	Fri, 31 Oct 2008 05:43:19 +0000 (UTC)
	(envelope-from peter@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 m9V5hJS8071202;
	Fri, 31 Oct 2008 05:43:19 GMT (envelope-from peter@svn.freebsd.org)
Received: (from peter@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9V5hJwK071200;
	Fri, 31 Oct 2008 05:43:19 GMT (envelope-from peter@svn.freebsd.org)
Message-Id: <200810310543.m9V5hJwK071200@svn.freebsd.org>
From: Peter Wemm 
Date: Fri, 31 Oct 2008 05:43:19 +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: r184492 - in head/sys: kern sys
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: Fri, 31 Oct 2008 05:43:19 -0000

Author: peter
Date: Fri Oct 31 05:43:19 2008
New Revision: 184492
URL: http://svn.freebsd.org/changeset/base/184492

Log:
  Add three extra to the kinfo_proc_vmmap data.  kve_offset - the offset
  within an object that a mapping refers to.  fileid and fsid are inode/dev
  for vnodes.  (Linux procfs has these and valgrind is really unhappy
  without them.)  I believe I didn't change the size of the struct.

Modified:
  head/sys/kern/kern_proc.c
  head/sys/sys/user.h

Modified: head/sys/kern/kern_proc.c
==============================================================================
--- head/sys/kern/kern_proc.c	Fri Oct 31 02:36:28 2008	(r184491)
+++ head/sys/kern/kern_proc.c	Fri Oct 31 05:43:19 2008	(r184492)
@@ -1341,6 +1341,8 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR
 	unsigned int last_timestamp;
 	char *fullpath, *freepath;
 	struct kinfo_vmentry *kve;
+	struct vattr va;
+	struct ucred *cred;
 	int error, *name;
 	struct vnode *vp;
 	struct proc *p;
@@ -1400,6 +1402,8 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR
 			lobj = tobj;
 		}
 
+		kve->kve_fileid = 0;
+		kve->kve_fsid = 0;
 		freepath = NULL;
 		fullpath = "";
 		if (lobj) {
@@ -1440,6 +1444,11 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR
 				vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 				vn_fullpath(curthread, vp, &fullpath,
 				    &freepath);
+				cred = curthread->td_ucred;
+				if (VOP_GETATTR(vp, &va, cred) == 0) {
+					kve->kve_fileid = va.va_fileid;
+					kve->kve_fsid = va.va_fsid;
+				}
 				vput(vp);
 				VFS_UNLOCK_GIANT(vfslocked);
 			}
@@ -1451,6 +1460,7 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR
 
 		kve->kve_start = (void*)entry->start;
 		kve->kve_end = (void*)entry->end;
+		kve->kve_offset = (off_t)entry->offset;
 
 		if (entry->protection & VM_PROT_READ)
 			kve->kve_protection |= KVME_PROT_READ;

Modified: head/sys/sys/user.h
==============================================================================
--- head/sys/sys/user.h	Fri Oct 31 02:36:28 2008	(r184491)
+++ head/sys/sys/user.h	Fri Oct 31 05:43:19 2008	(r184492)
@@ -326,7 +326,10 @@ struct kinfo_vmentry {
 	int	 kve_shadow_count;		/* VM obj shadow count. */
 	char	 kve_path[PATH_MAX];		/* Path to VM obj, if any. */
 	void	*_kve_pspare[8];		/* Space for more stuff. */
-	int	 _kve_ispare[8];		/* Space for more stuff. */
+	off_t	 kve_offset;			/* Mapping offset in object */
+	uint64_t kve_fileid;			/* inode number of vnode */
+	dev_t	 kve_fsid;			/* dev_t of vnode location */
+	int	 _kve_ispare[3];		/* Space for more stuff. */
 };
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 06:48:22 2008
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 134481065673;
	Fri, 31 Oct 2008 06:48:22 +0000 (UTC)
	(envelope-from keramida@freebsd.org)
Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36])
	by mx1.freebsd.org (Postfix) with ESMTP id 996138FC12;
	Fri, 31 Oct 2008 06:48:21 +0000 (UTC)
	(envelope-from keramida@freebsd.org)
Received: from kobe.laptop (adsl25-227.kln.forthnet.gr [77.49.152.227])
	(authenticated bits=128)
	by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id m9V6mA0g004474
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Fri, 31 Oct 2008 08:48:16 +0200
Received: from kobe.laptop (kobe.laptop [127.0.0.1])
	by kobe.laptop (8.14.3/8.14.3) with ESMTP id m9V6m90S000453;
	Fri, 31 Oct 2008 08:48:09 +0200 (EET)
	(envelope-from keramida@freebsd.org)
Received: (from keramida@localhost)
	by kobe.laptop (8.14.3/8.14.3/Submit) id m9V6m9Vw000452;
	Fri, 31 Oct 2008 08:48:09 +0200 (EET)
	(envelope-from keramida@freebsd.org)
From: Giorgos Keramidas 
To: Ivan Voras 
References: <200810301405.m9UE5wwZ053250@svn.freebsd.org>
Date: Fri, 31 Oct 2008 08:48:09 +0200
In-Reply-To: <200810301405.m9UE5wwZ053250@svn.freebsd.org> (Ivan Voras's
	message of "Thu, 30 Oct 2008 14:05:58 +0000 (UTC)")
Message-ID: <877i7pdzva.fsf@kobe.laptop>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-MailScanner-ID: m9V6mA0g004474
X-Hellug-MailScanner: Found to be clean
X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached,
	score=-4.303, required 5, autolearn=not spam, ALL_TRUSTED -1.80,
	AWL 0.10, BAYES_00 -2.60)
X-Hellug-MailScanner-From: keramida@freebsd.org
X-Spam-Status: No
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184471 - in head/bin: cat cp
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: Fri, 31 Oct 2008 06:48:22 -0000

On Thu, 30 Oct 2008 14:05:58 +0000 (UTC), Ivan Voras  wrote:
> Author: ivoras
> Date: Thu Oct 30 14:05:57 2008
> New Revision: 184471
> URL: http://svn.freebsd.org/changeset/base/184471
>
> Log:
>   Teach cat(1) and cp(1) to use a larger buffer if enough memory is present
>   in the system. A simple heuristics is used to detect what is "enough"
>   memory: if number of physmem pages is greater than 32k (equalling 128 MB
>   on machines with 4 kB pages).
>
>   Typical immediate result of these changes is reduction in context switches
>   and the goal is to increase efficiency by using large buffers:
>   before: /usr/bin/time -hlp cat file1 > file2
>   ...
>          163  voluntary context switches
>        11194  involuntary context switches
>   after: /usr/bin/time -hlp ./cat file1 > file2
>   ...
>          417  voluntary context switches
>          272  involuntary context switches

Nice :)

I didn't notice this in -hackers, but it may be worth letting the buffer
size grow above 1 MB when we have more than, say, 512 MB of memory.  By
running dd(1) with buffer sizes of 1, 2, 4, 6, 8, 10, 12, 14, and 16 MB
there are larger buffer sizes that reduce involuntary context switches
even more.

My laptop (with more than 2 GB or memory), with powerd disabled, running
in single user mode, and copying a file of 200 MB using the script:

,-----------------------------------------------------------------------
| #!/bin/sh
|
| mblist="1 2 4 6 8 10 12 14 16"
|
| for bufsize in ${mblist} ; do
|         cmd="dd if=testfile bs=${bufsize}m | dd of=testfile.out bs=${bufsize}m"
|         logname=`printf '%02d.dd-times' "${bufsize}"`
|         true > "${logname}"
|         for cnt in `jot 30 1 30` ; do
|                 echo "Overwriting testfile"
|                 cat datafile > testfile
|                 printf '%2d MB buffer, run %2d, logfile=%s\n' \
|                     "${bufsize}" "${cnt}" "${logname}"
|                 /usr/bin/time -l sh -c "${cmd}" 2>> "${logname}"
|                 tail -1 "${logname}"
|         done
| done
`-----------------------------------------------------------------------

got the following results for sizes < 10 MB:

: tcsh% ministat -w 78 0?
: x 01
: + 02
: * 04
: % 06
: # 08
: +------------------------------------------------------------------------------+
: |     #               % #% *   *      +         x                              |
: |    ##    %#*#* %%%  # O%*O% ***+*  *+ + + x   x   x    x xx   x              |
: |## %### %%O#O#O##OOO#OOOOOOO *OO**@*O**++*xx x x xxx  x * xx   x x   x  x    x|
: |      |___|____AM|MA____||A|___A_M_|__| |__________MA__________|              |
: +------------------------------------------------------------------------------+
:     N           Min           Max        Median           Avg        Stddev
: x  30          1383          1653          1493        1496.1     69.360801
: +  30          1286          1434          1381     1371.0667     44.393952
: Difference at 95.0% confidence
:         -125.033 +/- 30.1005
:         -8.35728% +/- 2.01193%
:         (Student's t, pooled s = 58.2312)
: *  30          1242          1523          1342     1339.3667     56.059379
: Difference at 95.0% confidence
:         -156.733 +/- 32.5975
:         -10.4761% +/- 2.17883%
:         (Student's t, pooled s = 63.0618)
: %  30          1199          1401          1292     1293.1667     50.603996
: Difference at 95.0% confidence
:         -202.933 +/- 31.3824
:         -13.5642% +/- 2.09762%
:         (Student's t, pooled s = 60.7111)
: #  30          1179          1402          1275     1273.9667     57.161889
: Difference at 95.0% confidence
:         -222.133 +/- 32.8523
:         -14.8475% +/- 2.19586%
:         (Student's t, pooled s = 63.5547)

Buffer sizes even larger didn't yield as good results as 6 MB or 8 MB,
but there seems to be an improvement in 16 MB too:

: tcsh% ministat -w 78 01 1?
: x 01
: + 10
: * 12
: % 14
: # 16
: +------------------------------------------------------------------------------+
: |                 #    #         %    % %                                      |
: |          # # #  ##*  ##  O#+% OO*   %+%*  +  %*+ x*x x   x xx  x             |
: |# ##   #  #OO*#O OO* *OO%OOOOOOOO*OOOOOOO**@ xOO*%x*#%* * x xx  x x   x  x   x|
: |         |________A|_____||_|_AM___AAMM___|_||________A_________|             |
: +------------------------------------------------------------------------------+
:     N           Min           Max        Median           Avg        Stddev
: x  30          1383          1653          1493        1496.1     69.360801
: +  30          1200          1511          1383     1363.5667     69.974716
: Difference at 95.0% confidence
:         -132.533 +/- 36.0126
:         -8.85859% +/- 2.4071%
:         (Student's t, pooled s = 69.6684)
: *  30          1208          1496          1336     1333.1667     79.330858
: Difference at 95.0% confidence
:         -162.933 +/- 38.5167
:         -10.8905% +/- 2.57447%
:         (Student's t, pooled s = 74.5128)
: %  30          1208          1488          1377     1374.1333     59.381138
: Difference at 95.0% confidence
:         -121.967 +/- 33.3741
:         -8.15231% +/- 2.23074%
:         (Student's t, pooled s = 64.5641)
: #  30          1124          1363          1246     1245.7667     59.806979
: Difference at 95.0% confidence
:         -250.333 +/- 33.4755
:         -16.7324% +/- 2.23752%
:         (Student's t, pooled s = 64.7603)

It looks like it's probably worth pushing the limit up to 8 MB when we
have lots of memory :)


From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 09:59:42 2008
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 E334E1065690;
	Fri, 31 Oct 2008 09:59:42 +0000 (UTC) (envelope-from des@des.no)
Received: from tim.des.no (tim.des.no [194.63.250.121])
	by mx1.freebsd.org (Postfix) with ESMTP id A2B338FC1C;
	Fri, 31 Oct 2008 09:59:42 +0000 (UTC) (envelope-from des@des.no)
Received: from ds4.des.no (des.no [84.49.246.2])
	by smtp.des.no (Postfix) with ESMTP id ACD3D6D43F;
	Fri, 31 Oct 2008 09:59:41 +0000 (UTC)
Received: by ds4.des.no (Postfix, from userid 1001)
	id 82DF08448F; Fri, 31 Oct 2008 10:59:41 +0100 (CET)
From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= 
To: Marcel Moolenaar 
References: <200810250618.m9P6ICWl023370@svn.freebsd.org>
Date: Fri, 31 Oct 2008 10:59:41 +0100
In-Reply-To: <200810250618.m9P6ICWl023370@svn.freebsd.org> (Marcel Moolenaar's
	message of "Sat, 25 Oct 2008 06:18:12 +0000 (UTC)")
Message-ID: <863aidgk4y.fsf@ds4.des.no>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184251 - in head/sys: conf dev/cfi sys
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: Fri, 31 Oct 2008 09:59:43 -0000

Marcel Moolenaar  writes:
> Log:
>   Add a driver for flash memory that implements to the Common Flash
>   Memory Interface (CFI). The flash memory can be read and written
>   to through /dev/cfi# and an ioctl() exists so processes can read
>   the query information.
>   The driver supports the AMD and Intel command set, though only
>   the AMD command has been tested.
>=20=20=20
>   Obtained from:	Juniper Networks, Inc.

You may want to *carefully* review the license on this code.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 10:11:35 2008
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 D9A091065679;
	Fri, 31 Oct 2008 10:11:35 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C993B8FC20;
	Fri, 31 Oct 2008 10:11:35 +0000 (UTC) (envelope-from kib@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 m9VABZT3076454;
	Fri, 31 Oct 2008 10:11:35 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VABZGM076450;
	Fri, 31 Oct 2008 10:11:35 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810311011.m9VABZGM076450@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 31 Oct 2008 10:11:35 +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: r184499 - in head/sys: amd64/amd64 geom i386/i386
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: Fri, 31 Oct 2008 10:11:36 -0000

Author: kib
Date: Fri Oct 31 10:11:35 2008
New Revision: 184499
URL: http://svn.freebsd.org/changeset/base/184499

Log:
  Revert r184136. Instead, push the check for crashdumpmap overflow into the
  MD i386 and amd64 dump code.
  
  Requested by:	jhb
  Retested by:	pho
  MFC after:	3 days (+ 176304 + 184136)

Modified:
  head/sys/amd64/amd64/dump_machdep.c
  head/sys/amd64/amd64/minidump_machdep.c
  head/sys/geom/geom_disk.c
  head/sys/i386/i386/dump_machdep.c

Modified: head/sys/amd64/amd64/dump_machdep.c
==============================================================================
--- head/sys/amd64/amd64/dump_machdep.c	Fri Oct 31 09:41:06 2008	(r184498)
+++ head/sys/amd64/amd64/dump_machdep.c	Fri Oct 31 10:11:35 2008	(r184499)
@@ -165,7 +165,7 @@ cb_dumpdata(struct md_pa *mdp, int seqnr
 	va = 0;
 	pgs = mdp->md_size / PAGE_SIZE;
 	pa = mdp->md_start;
-	maxdumppgs = di->maxiosize / PAGE_SIZE;
+	maxdumppgs = min(di->maxiosize / PAGE_SIZE, MAXDUMPPGS);
 	if (maxdumppgs == 0)	/* seatbelt */
 		maxdumppgs = 1;
 

Modified: head/sys/amd64/amd64/minidump_machdep.c
==============================================================================
--- head/sys/amd64/amd64/minidump_machdep.c	Fri Oct 31 09:41:06 2008	(r184498)
+++ head/sys/amd64/amd64/minidump_machdep.c	Fri Oct 31 10:11:35 2008	(r184499)
@@ -104,7 +104,7 @@ blk_write(struct dumperinfo *di, char *p
 	int error, i, c;
 	u_int maxdumpsz;
 
-	maxdumpsz = di->maxiosize;
+	maxdumpsz = min(di->maxiosize, MAXDUMPPGS * PAGE_SIZE);
 	if (maxdumpsz == 0)	/* seatbelt */
 		maxdumpsz = PAGE_SIZE;
 	error = 0;

Modified: head/sys/geom/geom_disk.c
==============================================================================
--- head/sys/geom/geom_disk.c	Fri Oct 31 09:41:06 2008	(r184498)
+++ head/sys/geom/geom_disk.c	Fri Oct 31 10:11:35 2008	(r184499)
@@ -179,7 +179,7 @@ g_disk_kerneldump(struct bio *bp, struct
 	di.dumper = dp->d_dump;
 	di.priv = dp;
 	di.blocksize = dp->d_sectorsize;
-	di.maxiosize = min(dp->d_maxsize, MAXDUMPPGS * PAGE_SIZE);
+	di.maxiosize = dp->d_maxsize;
 	di.mediaoffset = gkd->offset;
 	if ((gkd->offset + gkd->length) > dp->d_mediasize)
 		gkd->length = dp->d_mediasize - gkd->offset;

Modified: head/sys/i386/i386/dump_machdep.c
==============================================================================
--- head/sys/i386/i386/dump_machdep.c	Fri Oct 31 09:41:06 2008	(r184498)
+++ head/sys/i386/i386/dump_machdep.c	Fri Oct 31 10:11:35 2008	(r184499)
@@ -165,7 +165,7 @@ cb_dumpdata(struct md_pa *mdp, int seqnr
 	va = 0;
 	pgs = mdp->md_size / PAGE_SIZE;
 	pa = mdp->md_start;
-	maxdumppgs = di->maxiosize / PAGE_SIZE;
+	maxdumppgs = min(di->maxiosize / PAGE_SIZE, MAXDUMPPGS);
 	if (maxdumppgs == 0)	/* seatbelt */
 		maxdumppgs = 1;
 

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 10:14:29 2008
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 2EE1D1065676;
	Fri, 31 Oct 2008 10:14:29 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1F1C28FC16;
	Fri, 31 Oct 2008 10:14:29 +0000 (UTC) (envelope-from kib@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 m9VAESw7076551;
	Fri, 31 Oct 2008 10:14:28 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VAEScx076550;
	Fri, 31 Oct 2008 10:14:28 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810311014.m9VAEScx076550@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 31 Oct 2008 10:14:28 +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: r184500 - head/sys/i386/i386
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: Fri, 31 Oct 2008 10:14:29 -0000

Author: kib
Date: Fri Oct 31 10:14:28 2008
New Revision: 184500
URL: http://svn.freebsd.org/changeset/base/184500

Log:
  The file was inadvertently excluded from r184499.

Modified:
  head/sys/i386/i386/minidump_machdep.c

Modified: head/sys/i386/i386/minidump_machdep.c
==============================================================================
--- head/sys/i386/i386/minidump_machdep.c	Fri Oct 31 10:11:35 2008	(r184499)
+++ head/sys/i386/i386/minidump_machdep.c	Fri Oct 31 10:14:28 2008	(r184500)
@@ -102,7 +102,7 @@ blk_write(struct dumperinfo *di, char *p
 	int error, i, c;
 	u_int maxdumpsz;
 
-	maxdumpsz = di->maxiosize;
+	maxdumpsz = min(di->maxiosize, MAXDUMPPGS * PAGE_SIZE);
 	if (maxdumpsz == 0)	/* seatbelt */
 		maxdumpsz = PAGE_SIZE;
 	error = 0;

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 10:38:30 2008
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 DA4D91065678;
	Fri, 31 Oct 2008 10:38:30 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C9B188FC1C;
	Fri, 31 Oct 2008 10:38:30 +0000 (UTC) (envelope-from kib@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 m9VAcUVU077070;
	Fri, 31 Oct 2008 10:38:30 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VAcUXg077069;
	Fri, 31 Oct 2008 10:38:30 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <200810311038.m9VAcUXg077069@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 31 Oct 2008 10:38:30 +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: r184501 - head/sys/compat/linux
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: Fri, 31 Oct 2008 10:38:31 -0000

Author: kib
Date: Fri Oct 31 10:38:30 2008
New Revision: 184501
URL: http://svn.freebsd.org/changeset/base/184501

Log:
  The code in linux_proc_exit() contains a race when multiple linux based
  processes exits at the same time.  The linux_emuldata structure is freed
  but p->p_emuldata is left as a dangling pointer to the just freed memory.
  
  The check for W_EXIT in the loop scanning the child processes isn't safe
  since the state of the child process can change right afterwards. Lock
  the process and check the W_EXIT before delivering signal.
  
  Submitted by:	tegge
  Reviewed by:	davidxu
  MFC after:	1 week

Modified:
  head/sys/compat/linux/linux_emul.c

Modified: head/sys/compat/linux/linux_emul.c
==============================================================================
--- head/sys/compat/linux/linux_emul.c	Fri Oct 31 10:14:28 2008	(r184500)
+++ head/sys/compat/linux/linux_emul.c	Fri Oct 31 10:38:30 2008	(r184501)
@@ -235,11 +235,11 @@ linux_proc_exit(void *arg __unused, stru
 			continue;
 		em = em_find(q, EMUL_DOLOCK);
 		KASSERT(em != NULL, ("linux_reparent: emuldata not found: %i\n", q->p_pid));
-		if (em->pdeath_signal != 0) {
-			PROC_LOCK(q);
+		PROC_LOCK(q);
+		if ((q->p_flag & P_WEXIT) == 0 && em->pdeath_signal != 0) {
 			psignal(q, em->pdeath_signal);
-			PROC_UNLOCK(q);
 		}
+		PROC_UNLOCK(q);
 		EMUL_UNLOCK(&emul_lock);
 	}
 	sx_xunlock(&proctree_lock);

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 14:40:22 2008
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 4A627106573E;
	Fri, 31 Oct 2008 14:40:22 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 353CB8FC12;
	Fri, 31 Oct 2008 14:40:21 +0000 (UTC)
	(envelope-from rwatson@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 m9VEeLaE083099;
	Fri, 31 Oct 2008 14:40:21 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VEeL10083098;
	Fri, 31 Oct 2008 14:40:21 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810311440.m9VEeL10083098@svn.freebsd.org>
From: Robert Watson 
Date: Fri, 31 Oct 2008 14:40:21 +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: r184508 - head/sys/security/audit
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: Fri, 31 Oct 2008 14:40:22 -0000

Author: rwatson
Date: Fri Oct 31 14:40:21 2008
New Revision: 184508
URL: http://svn.freebsd.org/changeset/base/184508

Log:
  Historically, /dev/auditpipe has allows only whole records to be read via
  read(2), which meant that records longer than the buffer passed to read(2)
  were dropped.  Instead take the approach of allowing partial reads to be
  continued across multiple system calls more in the style of streaming
  character device.
  
  This means retaining a record on the per-pipe queue in a partially read
  state, so maintain a current offset into the record.  Keep the record on
  the queue during a read, so add a new lock, ap_sx, to serialize removal
  of records from the queue by either read(2) or ioctl(2) requesting a pipe
  flush.  Modify the kqueue handler to return bytes left in the current
  record rather than simply the size of the current record.
  
  It is now possible to use praudit, which used the standard FILE * buffer
  sizes, to track much larger record sizes from /dev/auditpipe, such as
  very long command lines to execve(2).
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Fri Oct 31 14:30:33 2008	(r184507)
+++ head/sys/security/audit/audit_pipe.c	Fri Oct 31 14:40:21 2008	(r184508)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -84,6 +85,7 @@ static MALLOC_DEFINE(M_AUDIT_PIPE_PRESEL
 struct audit_pipe_entry {
 	void				*ape_record;
 	u_int				 ape_record_len;
+	u_int				 ape_record_offset;
 	TAILQ_ENTRY(audit_pipe_entry)	 ape_queue;
 };
 
@@ -120,7 +122,15 @@ struct audit_pipe {
 	/*
 	 * Per-pipe mutex protecting most fields in this data structure.
 	 */
-	struct mtx			 ap_lock;
+	struct mtx			 ap_mtx;
+
+	/*
+	 * Per-pipe sleep lock serializing user-generated reads and flushes.
+	 * uiomove() is called to copy out the current head record's data
+	 * while the record remains in the queue, so we prevent other threads
+	 * from removing it using this lock.
+	 */
+	struct sx			 ap_sx;
 
 	/*
 	 * Condition variable to signal when data has been delivered to a
@@ -147,7 +157,9 @@ struct audit_pipe {
 	TAILQ_HEAD(, audit_pipe_preselect)	ap_preselect_list;
 
 	/*
-	 * Current pending record list.
+	 * Current pending record list.  Protected by a combination of ap_mtx
+	 * and ap_sx.  Note particularly that *both* locks are required to
+	 * remove a record from the head of the queue, as an in-progress read		 * may sleep while copying and therefore cannot hold ap_mtx.
 	 */
 	TAILQ_HEAD(, audit_pipe_entry)	 ap_queue;
 
@@ -157,13 +169,19 @@ struct audit_pipe {
 	TAILQ_ENTRY(audit_pipe)		 ap_list;
 };
 
-#define	AUDIT_PIPE_LOCK(ap)	mtx_lock(&(ap)->ap_lock)
-#define	AUDIT_PIPE_LOCK_ASSERT(ap)	mtx_assert(&(ap)->ap_lock, MA_OWNED)
-#define	AUDIT_PIPE_LOCK_DESTROY(ap)	mtx_destroy(&(ap)->ap_lock)
-#define	AUDIT_PIPE_LOCK_INIT(ap)	mtx_init(&(ap)->ap_lock, \
-					    "audit_pipe_lock", NULL, MTX_DEF)
-#define	AUDIT_PIPE_UNLOCK(ap)	mtx_unlock(&(ap)->ap_lock)
-#define	AUDIT_PIPE_MTX(ap)	(&(ap)->ap_lock)
+#define	AUDIT_PIPE_LOCK(ap)		mtx_lock(&(ap)->ap_mtx)
+#define	AUDIT_PIPE_LOCK_ASSERT(ap)	mtx_assert(&(ap)->ap_mtx, MA_OWNED)
+#define	AUDIT_PIPE_LOCK_DESTROY(ap)	mtx_destroy(&(ap)->ap_mtx)
+#define	AUDIT_PIPE_LOCK_INIT(ap)	mtx_init(&(ap)->ap_mtx, \
+					    "audit_pipe_mtx", NULL, MTX_DEF)
+#define	AUDIT_PIPE_UNLOCK(ap)		mtx_unlock(&(ap)->ap_mtx)
+#define	AUDIT_PIPE_MTX(ap)		(&(ap)->ap_mtx)
+
+#define	AUDIT_PIPE_SX_LOCK_DESTROY(ap)	sx_destroy(&(ap)->ap_sx)
+#define	AUDIT_PIPE_SX_LOCK_INIT(ap)	sx_init(&(ap)->ap_sx, "audit_pipe_sx")
+#define	AUDIT_PIPE_SX_XLOCK_ASSERT(ap)	sx_assert(&(ap)->ap_sx, SA_XLOCKED)
+#define	AUDIT_PIPE_SX_XLOCK_SIG(ap)	sx_xlock_sig(&(ap)->ap_sx)
+#define	AUDIT_PIPE_SX_XUNLOCK(ap)	sx_xunlock(&(ap)->ap_sx)
 
 /*
  * Global list of audit pipes, rwlock to protect it.  Individual record
@@ -457,6 +475,7 @@ audit_pipe_append(struct audit_pipe *ap,
 
 	bcopy(record, ape->ape_record, record_len);
 	ape->ape_record_len = record_len;
+	ape->ape_record_offset = 0;
 
 	TAILQ_INSERT_TAIL(&ap->ap_queue, ape, ape_queue);
 	ap->ap_inserts++;
@@ -530,26 +549,6 @@ audit_pipe_submit_user(void *record, u_i
 }
 
 /*
- * Pop the next record off of an audit pipe.
- */
-static struct audit_pipe_entry *
-audit_pipe_pop(struct audit_pipe *ap)
-{
-	struct audit_pipe_entry *ape;
-
-	AUDIT_PIPE_LOCK_ASSERT(ap);
-
-	ape = TAILQ_FIRST(&ap->ap_queue);
-	KASSERT((ape == NULL && ap->ap_qlen == 0) ||
-	    (ape != NULL && ap->ap_qlen != 0), ("audit_pipe_pop: qlen"));
-	if (ape == NULL)
-		return (NULL);
-	TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
-	ap->ap_qlen--;
-	return (ape);
-}
-
-/*
  * Allocate a new audit pipe.  Connects the pipe, on success, to the global
  * list and updates statistics.
  */
@@ -568,6 +567,7 @@ audit_pipe_alloc(void)
 	knlist_init(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap), NULL, NULL,
 	    NULL);
 	AUDIT_PIPE_LOCK_INIT(ap);
+	AUDIT_PIPE_SX_LOCK_INIT(ap);
 	cv_init(&ap->ap_cv, "audit_pipe");
 
 	/*
@@ -626,6 +626,7 @@ audit_pipe_free(struct audit_pipe *ap)
 	audit_pipe_preselect_flush_locked(ap);
 	audit_pipe_flush(ap);
 	cv_destroy(&ap->ap_cv);
+	AUDIT_PIPE_SX_LOCK_DESTROY(ap);
 	AUDIT_PIPE_LOCK_DESTROY(ap);
 	knlist_destroy(&ap->ap_selinfo.si_note);
 	TAILQ_REMOVE(&audit_pipe_list, ap, ap_list);
@@ -754,7 +755,8 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		AUDIT_PIPE_LOCK(ap);
 		if (TAILQ_FIRST(&ap->ap_queue) != NULL)
 			*(int *)data =
-			    TAILQ_FIRST(&ap->ap_queue)->ape_record_len;
+			    TAILQ_FIRST(&ap->ap_queue)->ape_record_len -
+			    TAILQ_FIRST(&ap->ap_queue)->ape_record_offset;
 		else
 			*(int *)data = 0;
 		AUDIT_PIPE_UNLOCK(ap);
@@ -888,9 +890,12 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		break;
 
 	case AUDITPIPE_FLUSH:
+		if (AUDIT_PIPE_SX_XLOCK_SIG(ap) != 0)
+			return (EINTR);
 		AUDIT_PIPE_LOCK(ap);
 		audit_pipe_flush(ap);
 		AUDIT_PIPE_UNLOCK(ap);
+		AUDIT_PIPE_SX_XUNLOCK(ap);
 		error = 0;
 		break;
 
@@ -945,45 +950,68 @@ audit_pipe_read(struct cdev *dev, struct
 {
 	struct audit_pipe_entry *ape;
 	struct audit_pipe *ap;
+	u_int toread;
 	int error;
 
 	ap = dev->si_drv1;
 	KASSERT(ap != NULL, ("audit_pipe_read: ap == NULL"));
 
+	/*
+	 * We hold an sx(9) lock over read and flush because we rely on the
+	 * stability of a record in the queue during uiomove(9).
+	 */
+	if (AUDIT_PIPE_SX_XLOCK_SIG(ap) != 0)
+		return (EINTR);
 	AUDIT_PIPE_LOCK(ap);
-	do {
-		/*
-		 * Wait for a record that fits into the read buffer, dropping
-		 * records that would be truncated if actually passed to the
-		 * process.  This helps maintain the discreet record read
-		 * interface.
-		 */
-		while ((ape = audit_pipe_pop(ap)) == NULL) {
-			if (ap->ap_flags & AUDIT_PIPE_NBIO) {
-				AUDIT_PIPE_UNLOCK(ap);
-				return (EAGAIN);
-			}
-			error = cv_wait_sig(&ap->ap_cv, AUDIT_PIPE_MTX(ap));
-			if (error) {
-				AUDIT_PIPE_UNLOCK(ap);
-				return (error);
-			}
+	while (TAILQ_EMPTY(&ap->ap_queue)) {
+		if (ap->ap_flags & AUDIT_PIPE_NBIO) {
+			AUDIT_PIPE_UNLOCK(ap);
+			AUDIT_PIPE_SX_XUNLOCK(ap);
+			return (EAGAIN);
 		}
-		if (ape->ape_record_len <= uio->uio_resid)
-			break;
-		audit_pipe_entry_free(ape);
-		ap->ap_truncates++;
-	} while (1);
+		error = cv_wait_sig(&ap->ap_cv, AUDIT_PIPE_MTX(ap));
+		if (error) {
+			AUDIT_PIPE_UNLOCK(ap);
+			AUDIT_PIPE_SX_XUNLOCK(ap);
+			return (error);
+		}
+	}
+
+	/*
+	 * Copy as many remaining bytes from the current record to userspace
+	 * as we can.
+	 *
+	 * Note: we rely on the SX lock to maintain ape's stability here.
+	 */
 	ap->ap_reads++;
+	ape = TAILQ_FIRST(&ap->ap_queue);
+	toread = MIN(ape->ape_record_len - ape->ape_record_offset,
+	    uio->uio_resid);
 	AUDIT_PIPE_UNLOCK(ap);
+	error = uiomove((char *)ape->ape_record + ape->ape_record_offset,
+	    toread, uio);
+	if (error) {
+		AUDIT_PIPE_SX_XUNLOCK(ap);
+		return (error);
+	}
 
 	/*
-	 * Now read record to user space memory.  Even if the read is short,
-	 * we abandon the remainder of the record, supporting only discreet
-	 * record reads.
+	 * If the copy succeeded, update book-keeping, and if no bytes remain
+	 * in the current record, free it.
 	 */
-	error = uiomove(ape->ape_record, ape->ape_record_len, uio);
-	audit_pipe_entry_free(ape);
+	AUDIT_PIPE_LOCK(ap);
+	KASSERT(TAILQ_FIRST(&ap->ap_queue) == ape,
+	    ("audit_pipe_read: queue out of sync after uiomove"));
+	ape->ape_record_offset += toread;
+	if (ape->ape_record_offset == ape->ape_record_len) {
+		TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
+		ap->ap_qlen--;
+	} else
+		ape = NULL;
+	AUDIT_PIPE_UNLOCK(ap);
+	AUDIT_PIPE_SX_XUNLOCK(ap);
+	if (ape != NULL)
+		audit_pipe_entry_free(ape);
 	return (error);
 }
 
@@ -1052,7 +1080,7 @@ audit_pipe_kqread(struct knote *kn, long
 		ape = TAILQ_FIRST(&ap->ap_queue);
 		KASSERT(ape != NULL, ("audit_pipe_kqread: ape == NULL"));
 
-		kn->kn_data = ape->ape_record_len;
+		kn->kn_data = ape->ape_record_len - ape->ape_record_offset;
 		return (1);
 	} else {
 		kn->kn_data = 0;

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 14:47:15 2008
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 CA1B91065696;
	Fri, 31 Oct 2008 14:47:15 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B6FBE8FC24;
	Fri, 31 Oct 2008 14:47:15 +0000 (UTC)
	(envelope-from rwatson@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 m9VElF0u083251;
	Fri, 31 Oct 2008 14:47:15 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VElFtp083250;
	Fri, 31 Oct 2008 14:47:15 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810311447.m9VElFtp083250@svn.freebsd.org>
From: Robert Watson 
Date: Fri, 31 Oct 2008 14:47:15 +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: r184509 - head/share/man/man9
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: Fri, 31 Oct 2008 14:47:15 -0000

Author: rwatson
Date: Fri Oct 31 14:47:15 2008
New Revision: 184509
URL: http://svn.freebsd.org/changeset/base/184509

Log:
  In style(9) examples of err() and errx(), use sysexits(3) errors rather
  than returning 1.
  
  Submitted by:	Bruce Cran 
  MFC after:	3 days

Modified:
  head/share/man/man9/style.9

Modified: head/share/man/man9/style.9
==============================================================================
--- head/share/man/man9/style.9	Fri Oct 31 14:40:21 2008	(r184508)
+++ head/share/man/man9/style.9	Fri Oct 31 14:47:15 2008	(r184509)
@@ -716,9 +716,9 @@ or
 do not roll your own.
 .Bd -literal
 	if ((four = malloc(sizeof(struct foo))) == NULL)
-		err(1, (char *)NULL);
+		err(EX_OSERR, NULL);
 	if ((six = (int *)overflow()) == NULL)
-		errx(1, "number overflowed");
+		errx(EX_DATAERR, "number overflowed");
 	return (eight);
 }
 .Ed

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 15:11:01 2008
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 88864106564A;
	Fri, 31 Oct 2008 15:11:01 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 74FDF8FC21;
	Fri, 31 Oct 2008 15:11:01 +0000 (UTC)
	(envelope-from rwatson@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 m9VFB1Mk083691;
	Fri, 31 Oct 2008 15:11:01 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VFB1GG083690;
	Fri, 31 Oct 2008 15:11:01 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810311511.m9VFB1GG083690@svn.freebsd.org>
From: Robert Watson 
Date: Fri, 31 Oct 2008 15:11:01 +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: r184510 - head/sys/security/audit
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: Fri, 31 Oct 2008 15:11:01 -0000

Author: rwatson
Date: Fri Oct 31 15:11:01 2008
New Revision: 184510
URL: http://svn.freebsd.org/changeset/base/184510

Log:
  Since there is no longer the opportunity for record truncation, just
  return 0 if the truncation counter is queried on an audit pipe.
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Fri Oct 31 14:47:15 2008	(r184509)
+++ head/sys/security/audit/audit_pipe.c	Fri Oct 31 15:11:01 2008	(r184510)
@@ -144,7 +144,6 @@ struct audit_pipe {
 	u_int64_t			 ap_inserts;	/* Records added. */
 	u_int64_t			 ap_reads;	/* Records read. */
 	u_int64_t			 ap_drops;	/* Records dropped. */
-	u_int64_t			 ap_truncates;	/* Records too long. */
 
 	/*
 	 * Fields relating to pipe interest: global masks for unmatched
@@ -920,7 +919,7 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 		break;
 
 	case AUDITPIPE_GET_TRUNCATES:
-		*(u_int *)data = ap->ap_truncates;
+		*(u_int *)data = 0;
 		error = 0;
 		break;
 

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 15:14:41 2008
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 70B0810656D3;
	Fri, 31 Oct 2008 15:14:41 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 223E18FC1B;
	Fri, 31 Oct 2008 15:14:41 +0000 (UTC)
	(envelope-from rwatson@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 m9VFEfmq083786;
	Fri, 31 Oct 2008 15:14:41 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VFEfi9083785;
	Fri, 31 Oct 2008 15:14:41 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200810311514.m9VFEfi9083785@svn.freebsd.org>
From: Robert Watson 
Date: Fri, 31 Oct 2008 15:14:41 +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: r184511 - head/lib/libc/gen
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: Fri, 31 Oct 2008 15:14:41 -0000

Author: rwatson
Date: Fri Oct 31 15:14:40 2008
New Revision: 184511
URL: http://svn.freebsd.org/changeset/base/184511

Log:
  In example use of err(3) and errx(3), use sysexits(3) constants.
  
  MFC after:	3 days
  Submitted by:	Bruce Cran 

Modified:
  head/lib/libc/gen/err.3

Modified: head/lib/libc/gen/err.3
==============================================================================
--- head/lib/libc/gen/err.3	Fri Oct 31 15:11:01 2008	(r184510)
+++ head/lib/libc/gen/err.3	Fri Oct 31 15:14:40 2008	(r184511)
@@ -178,15 +178,16 @@ or a null pointer
 Display the current errno information string and exit:
 .Bd -literal -offset indent
 if ((p = malloc(size)) == NULL)
-	err(1, NULL);
+	err(EX_OSERR, NULL);
 if ((fd = open(file_name, O_RDONLY, 0)) == -1)
-	err(1, "%s", file_name);
+	err(EX_NOINPUT, "%s", file_name);
 .Ed
 .Pp
 Display an error message and exit:
 .Bd -literal -offset indent
 if (tm.tm_hour < START_TIME)
-	errx(1, "too early, wait until %s", start_time_string);
+	errx(EX_DATAERR, "too early, wait until %s",
+	    start_time_string);
 .Ed
 .Pp
 Warn of an error:
@@ -195,7 +196,7 @@ if ((fd = open(raw_device, O_RDONLY, 0))
 	warnx("%s: %s: trying the block device",
 	    raw_device, strerror(errno));
 if ((fd = open(block_device, O_RDONLY, 0)) == -1)
-	err(1, "%s", block_device);
+	err(EX_OSFILE, "%s", block_device);
 .Ed
 .Pp
 Warn of an error without using the global variable

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 23:24:14 2008
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 88E011065670;
	Fri, 31 Oct 2008 23:24:14 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 77DBD8FC13;
	Fri, 31 Oct 2008 23:24:14 +0000 (UTC) (envelope-from imp@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 m9VNOE4u093400;
	Fri, 31 Oct 2008 23:24:14 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9VNOE88093395;
	Fri, 31 Oct 2008 23:24:14 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <200810312324.m9VNOE88093395@svn.freebsd.org>
From: Warner Losh 
Date: Fri, 31 Oct 2008 23:24:14 +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: r184515 - in head/sys: conf modules/rl pci
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: Fri, 31 Oct 2008 23:24:14 -0000

Author: imp
Date: Fri Oct 31 23:24:13 2008
New Revision: 184515
URL: http://svn.freebsd.org/changeset/base/184515

Log:
  Add RL_TWISTER_ENABLE option.  This enables the magic bits to do long
  cable tuning.  This has helped in some installations for hardware
  deployed by a former employer.  Made optional because the lists aren't
  full of complaints about these cards... even when they were wildly
  popular.
  
  Reviewed by:	attilio@, jhb@, trhodes@ (all an older version of the patch)

Modified:
  head/sys/conf/options
  head/sys/modules/rl/Makefile
  head/sys/pci/if_rl.c
  head/sys/pci/if_rlreg.h

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Fri Oct 31 18:40:35 2008	(r184514)
+++ head/sys/conf/options	Fri Oct 31 23:24:13 2008	(r184515)
@@ -672,6 +672,9 @@ ED_SIC			opt_ed.h
 # bce driver
 BCE_DEBUG		opt_bce.h
 
+# rl driver
+RL_TWISTER_ENABLE	opt_rl.h
+
 SOCKBUF_DEBUG		opt_global.h
 
 # options for ubsec driver

Modified: head/sys/modules/rl/Makefile
==============================================================================
--- head/sys/modules/rl/Makefile	Fri Oct 31 18:40:35 2008	(r184514)
+++ head/sys/modules/rl/Makefile	Fri Oct 31 23:24:13 2008	(r184515)
@@ -3,7 +3,7 @@
 .PATH: ${.CURDIR}/../../pci
 
 KMOD=	if_rl
-SRCS=	if_rl.c device_if.h bus_if.h pci_if.h
+SRCS=	if_rl.c device_if.h bus_if.h pci_if.h opt_rl.h
 SRCS+=	miibus_if.h
 
 .include 

Modified: head/sys/pci/if_rl.c
==============================================================================
--- head/sys/pci/if_rl.c	Fri Oct 31 18:40:35 2008	(r184514)
+++ head/sys/pci/if_rl.c	Fri Oct 31 23:24:13 2008	(r184515)
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS
 #include "opt_device_polling.h"
+#include "opt_rl.h"
 #endif
 
 #include 
@@ -1383,19 +1384,143 @@ rl_txeof(struct rl_softc *sc)
 		sc->rl_watchdog_timer = 0;
 }
 
+#ifdef RL_TWISTER_ENABLE
+static void
+rl_twister_update(struct rl_softc *sc)
+{
+	uint16_t linktest;
+	/*
+	 * Table provided by RealTek (Kinston ) for
+	 * Linux driver.  Values undocumented otherwise.
+	 */
+	static const uint32_t param[4][4] = {
+		{0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
+		{0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
+		{0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
+		{0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
+	};
+
+	/*
+	 * Tune the so-called twister registers of the RTL8139.  These
+	 * are used to compensate for impendence mismatches.  The
+	 * method for tuning these registes is undocumented and the
+	 * following proceedure is collected from public sources.
+	 */
+	switch (sc->rl_twister)
+	{
+	case CHK_LINK:
+		/*
+		 * If we have a sufficent link, then we can proceed in
+		 * the state machine to the next stage.  If not, then
+		 * disable further tuning after writing sane defaults.
+		 */
+		if (CSR_READ_2(sc, RL_CSCFG) & RL_CSCFG_LINK_OK) {
+			CSR_WRITE_2(sc, RL_CSCFG, RL_CSCFG_LINK_DOWN_OFF_CMD);
+			sc->rl_twister = FIND_ROW;
+		} else {
+			CSR_WRITE_2(sc, RL_CSCFG, RL_CSCFG_LINK_DOWN_CMD);
+			CSR_WRITE_4(sc, RL_NWAYTST, RL_NWAYTST_CBL_TEST);
+			CSR_WRITE_4(sc, RL_PARA78, RL_PARA78_DEF);
+			CSR_WRITE_4(sc, RL_PARA7C, RL_PARA7C_DEF);
+			sc->rl_twister = DONE;
+		}
+		break;
+	case FIND_ROW:
+		/*
+		 * Read how long it took to see the echo to find the tuning
+		 * row to use.
+		 */
+		linktest = CSR_READ_2(sc, RL_CSCFG) & RL_CSCFG_STATUS;
+		if (linktest == RL_CSCFG_ROW3)
+			sc->rl_twist_row = 3;
+		else if (linktest == RL_CSCFG_ROW2)
+			sc->rl_twist_row = 2;
+		else if (linktest == RL_CSCFG_ROW1)
+			sc->rl_twist_row = 1;
+		else
+			sc->rl_twist_row = 0;
+		sc->rl_twist_col = 0;
+		sc->rl_twister = SET_PARAM;
+		break;
+	case SET_PARAM:
+		if (sc->rl_twist_col == 0)
+			CSR_WRITE_4(sc, RL_NWAYTST, RL_NWAYTST_RESET);
+		CSR_WRITE_4(sc, RL_PARA7C,
+		    param[sc->rl_twist_row][sc->rl_twist_col]);
+		if (++sc->rl_twist_col == 4) {
+			if (sc->rl_twist_row == 3)
+				sc->rl_twister = RECHK_LONG;
+			else
+				sc->rl_twister = DONE;
+		}
+		break;
+	case RECHK_LONG:
+		/*
+		 * For long cables, we have to double check to make sure we
+		 * don't mistune.
+		 */
+		linktest = CSR_READ_2(sc, RL_CSCFG) & RL_CSCFG_STATUS;
+		if (linktest == RL_CSCFG_ROW3)
+			sc->rl_twister = DONE;
+		else {
+			CSR_WRITE_4(sc, RL_PARA7C, RL_PARA7C_RETUNE);
+			sc->rl_twister = RETUNE;
+		}
+		break;
+	case RETUNE:
+		/* Retune for a shorter cable (try column 2) */
+		CSR_WRITE_4(sc, RL_NWAYTST, RL_NWAYTST_CBL_TEST);
+		CSR_WRITE_4(sc, RL_PARA78, RL_PARA78_DEF);
+		CSR_WRITE_4(sc, RL_PARA7C, RL_PARA7C_DEF);
+		CSR_WRITE_4(sc, RL_NWAYTST, RL_NWAYTST_RESET);
+		sc->rl_twist_row--;
+		sc->rl_twist_col = 0;
+		sc->rl_twister = SET_PARAM;
+		break;
+
+	case DONE:
+		break;
+	}
+	
+}
+#endif
+
 static void
 rl_tick(void *xsc)
 {
 	struct rl_softc		*sc = xsc;
 	struct mii_data		*mii;
+	int ticks;
 
 	RL_LOCK_ASSERT(sc);
+	/*
+	 * If we're doing the twister cable calibration, then we need to defer
+	 * watchdog timeouts.  This is a no-op in normal operations, but
+	 * can falsely trigger when the cable calibration takes a while and
+	 * there was traffic ready to go when rl was started.
+	 *
+	 * We don't defer mii_tick since that updates the mii status, which
+	 * helps the twister process, at least according to similar patches
+	 * for the Linux driver I found online while doing the fixes.  Worst
+	 * case is a few extra mii reads during calibration.
+	 */
 	mii = device_get_softc(sc->rl_miibus);
 	mii_tick(mii);
-
+#ifdef RL_TWISTER_ENABLE
+	if (sc->rl_twister == DONE)
+		rl_watchdog(sc);
+	else
+		rl_twister_update(sc);
+	if (sc->rl_twister == DONE)
+		ticks = hz;
+	else
+		ticks = hz / 10;
+#else
 	rl_watchdog(sc);
+	ticks = hz;
+#endif
 
-	callout_reset(&sc->rl_stat_callout, hz, rl_tick, sc);
+	callout_reset(&sc->rl_stat_callout, ticks, rl_tick, sc);
 }
 
 #ifdef DEVICE_POLLING
@@ -1643,6 +1768,14 @@ rl_init_locked(struct rl_softc *sc)
 	rl_stop(sc);
 
 	rl_reset(sc);
+#ifdef RL_TWISTER_ENABLE
+	/*
+	 * Reset twister register tuning state.  The twister registers
+	 * and their tuning are undocumented, but are necessary to cope
+	 * with bad links.  rl_twister = DONE here will disable this entirely.
+	 */
+	sc->rl_twister = CHK_LINK;
+#endif
 
 	/*
 	 * Init our MAC address.  Even though the chipset

Modified: head/sys/pci/if_rlreg.h
==============================================================================
--- head/sys/pci/if_rlreg.h	Fri Oct 31 18:40:35 2008	(r184514)
+++ head/sys/pci/if_rlreg.h	Fri Oct 31 23:24:13 2008	(r184515)
@@ -309,6 +309,27 @@
 #define RL_CMD_RESET		0x0010
 
 /*
+ * Twister register values.  These are completely undocumented and derived
+ * from public sources.
+ */
+#define RL_CSCFG_LINK_OK	0x0400
+#define RL_CSCFG_CHANGE		0x0800
+#define RL_CSCFG_STATUS		0xf000
+#define RL_CSCFG_ROW3		0x7000
+#define RL_CSCFG_ROW2		0x3000
+#define RL_CSCFG_ROW1		0x1000
+#define RL_CSCFG_LINK_DOWN_OFF_CMD 0x03c0
+#define RL_CSCFG_LINK_DOWN_CMD	0xf3c0
+
+#define RL_NWAYTST_RESET	0
+#define RL_NWAYTST_CBL_TEST	0x20
+
+#define RL_PARA78		0x78
+#define RL_PARA78_DEF		0x78fa8388
+#define RL_PARA7C		0x7C
+#define RL_PARA7C_DEF		0xcb38de43
+#define RL_PARA7C_RETUNE	0xfb38de03
+/*
  * EEPROM control register
  */
 #define RL_EE_DATAOUT		0x01	/* Data out */
@@ -809,6 +830,10 @@ struct rl_list_data {
 	bus_addr_t		rl_tx_list_addr;
 };
 
+#ifdef RL_TWISTER_ENABLE
+enum rl_twist { DONE, CHK_LINK, FIND_ROW, SET_PARAM, RECHK_LONG, RETUNE };
+#endif
+
 struct rl_softc {
 	struct ifnet		*rl_ifp;	/* interface info */
 	bus_space_handle_t	rl_bhandle;	/* bus space handle */
@@ -837,6 +862,11 @@ struct rl_softc {
 	uint32_t		rl_rxlenmask;
 	int			rl_testmode;
 	int			rl_if_flags;
+#ifdef RL_TWISTER_ENABLE
+	enum rl_twist		rl_twister;
+	int			rl_twist_row;
+	int			rl_twist_col;
+#endif
 	int			suspended;	/* 0 = normal  1 = suspended */
 #ifdef DEVICE_POLLING
 	int			rxcycles;

From owner-svn-src-head@FreeBSD.ORG  Fri Oct 31 23:28:09 2008
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 503621065672;
	Fri, 31 Oct 2008 23:28:09 +0000 (UTC) (envelope-from bms@FreeBSD.org)
Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com
	[66.111.4.27]) by mx1.freebsd.org (Postfix) with ESMTP id 22FA28FC0A;
	Fri, 31 Oct 2008 23:28:09 +0000 (UTC) (envelope-from bms@FreeBSD.org)
Received: from compute1.internal (compute1.internal [10.202.2.41])
	by out1.messagingengine.com (Postfix) with ESMTP id B924718A411;
	Fri, 31 Oct 2008 19:28:08 -0400 (EDT)
Received: from heartbeat1.messagingengine.com ([10.202.2.160])
	by compute1.internal (MEProxy); Fri, 31 Oct 2008 19:28:08 -0400
X-Sasl-enc: gZb7Uu+IHVwraZC2l7ywcCIHpBmL/pgUd2X9vktgH/yn 1225495688
Received: from empiric.lon.incunabulum.net
	(82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254])
	by mail.messagingengine.com (Postfix) with ESMTPSA id E6C9512D21;
	Fri, 31 Oct 2008 19:28:07 -0400 (EDT)
Message-ID: <490B9486.60204@FreeBSD.org>
Date: Fri, 31 Oct 2008 23:28:06 +0000
From: "Bruce M. Simpson" 
User-Agent: Thunderbird 2.0.0.14 (X11/20080514)
MIME-Version: 1.0
To: Warner Losh 
References: <200810312324.m9VNOE88093395@svn.freebsd.org>
In-Reply-To: <200810312324.m9VNOE88093395@svn.freebsd.org>
X-Enigmail-Version: 0.95.6
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184515 - in head/sys: conf modules/rl pci
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: Fri, 31 Oct 2008 23:28:09 -0000

This stuff is absolutely crazy, but I'm glad you checked it in.

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 00:28:44 2008
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 AFCFA1065675;
	Sat,  1 Nov 2008 00:28:44 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9EA808FC18;
	Sat,  1 Nov 2008 00:28:44 +0000 (UTC) (envelope-from imp@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 mA10SiF8094559;
	Sat, 1 Nov 2008 00:28:44 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA10SilF094558;
	Sat, 1 Nov 2008 00:28:44 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <200811010028.mA10SilF094558@svn.freebsd.org>
From: Warner Losh 
Date: Sat, 1 Nov 2008 00:28:44 +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: r184516 - head/sys/conf
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: Sat, 01 Nov 2008 00:28:44 -0000

Author: imp
Date: Sat Nov  1 00:28:44 2008
New Revision: 184516
URL: http://svn.freebsd.org/changeset/base/184516

Log:
  Add RL_TWISTER_ENABLE.

Modified:
  head/sys/conf/NOTES

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Fri Oct 31 23:24:13 2008	(r184515)
+++ head/sys/conf/NOTES	Sat Nov  1 00:28:44 2008	(r184516)
@@ -1875,6 +1875,7 @@ device		my		# Myson Fast Ethernet (MTD80
 device		nge		# NatSemi DP83820 gigabit Ethernet
 device		re		# RealTek 8139C+/8169/8169S/8110S
 device		rl		# RealTek 8129/8139
+options 	RL_TWISTER_ENABLE # Enable long cable compensation code
 device		pcn		# AMD Am79C97x PCI 10/100 NICs
 device		sf		# Adaptec AIC-6915 (``Starfire'')
 device		sis		# Silicon Integrated Systems SiS 900/SiS 7016

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 06:48:28 2008
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 BB62E1065676;
	Sat,  1 Nov 2008 06:48:28 +0000 (UTC)
	(envelope-from maxim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A9DE88FC0A;
	Sat,  1 Nov 2008 06:48:28 +0000 (UTC)
	(envelope-from maxim@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 mA16mSXO001527;
	Sat, 1 Nov 2008 06:48:28 GMT (envelope-from maxim@svn.freebsd.org)
Received: (from maxim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA16mSOA001526;
	Sat, 1 Nov 2008 06:48:28 GMT (envelope-from maxim@svn.freebsd.org)
Message-Id: <200811010648.mA16mSOA001526@svn.freebsd.org>
From: Maxim Konovalov 
Date: Sat, 1 Nov 2008 06:48:28 +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: r184517 - head/share/misc
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: Sat, 01 Nov 2008 06:48:28 -0000

Author: maxim
Date: Sat Nov  1 06:48:28 2008
New Revision: 184517
URL: http://svn.freebsd.org/changeset/base/184517

Log:
  o OpenBSD 4.4 added.

Modified:
  head/share/misc/bsd-family-tree

Modified: head/share/misc/bsd-family-tree
==============================================================================
--- head/share/misc/bsd-family-tree	Sat Nov  1 00:28:44 2008	(r184516)
+++ head/share/misc/bsd-family-tree	Sat Nov  1 06:48:28 2008	(r184517)
@@ -222,6 +222,7 @@ FreeBSD 5.2           |      |          
  |    7.0             |      |                 |                       |
  |     |              |      |             OpenBSD 4.3                 |
  |     V              |      |                 |                DragonFly 2.0.0
+ |                    |      |             OpenBSD 4.4                 |
  |                    |      |                 |                       |
 FreeBSD 8 -current    |  NetBSD -current  OpenBSD -current             |
  |                    |      |                 |                       |
@@ -486,6 +487,7 @@ DragonFly 1.12.0	2008-02-26 [DFB]
 FreeBSD 7.0		2008-02-27 [FBD]
 OpenBSD 4.3		2008-05-01 [OBD]
 DragonFly 2.0.0		2008-07-21 [DFB]
+OpenBSD 4.4		2008-11-01 [OBD]
 
 Bibliography
 ------------------------

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 07:12:01 2008
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 BC8A01065688;
	Sat,  1 Nov 2008 07:12:01 +0000 (UTC)
	(envelope-from wb@freebie.xs4all.nl)
Received: from smtp-vbr4.xs4all.nl (smtp-vbr4.xs4all.nl [194.109.24.24])
	by mx1.freebsd.org (Postfix) with ESMTP id 503D08FC18;
	Sat,  1 Nov 2008 07:12:01 +0000 (UTC)
	(envelope-from wb@freebie.xs4all.nl)
Received: from freebie.xs4all.nl (freebie.xs4all.nl [82.95.250.254])
	by smtp-vbr4.xs4all.nl (8.13.8/8.13.8) with ESMTP id mA16rp1m047968;
	Sat, 1 Nov 2008 07:53:52 +0100 (CET)
	(envelope-from wb@freebie.xs4all.nl)
Received: from freebie.xs4all.nl (localhost [127.0.0.1])
	by freebie.xs4all.nl (8.14.2/8.14.2) with ESMTP id mA16rpL9001283;
	Sat, 1 Nov 2008 07:53:51 +0100 (CET)
	(envelope-from wb@freebie.xs4all.nl)
Received: (from wb@localhost)
	by freebie.xs4all.nl (8.14.2/8.14.2/Submit) id mA16roYg001282;
	Sat, 1 Nov 2008 07:53:50 +0100 (CET) (envelope-from wb)
Date: Sat, 1 Nov 2008 07:53:50 +0100
From: Wilko Bulte 
To: "Bruce M. Simpson" 
Message-ID: <20081101065350.GA1270@freebie.xs4all.nl>
References: <200810312324.m9VNOE88093395@svn.freebsd.org>
	<490B9486.60204@FreeBSD.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <490B9486.60204@FreeBSD.org>
User-Agent: Mutt/1.5.16 (2007-06-09)
X-Virus-Scanned: by XS4ALL Virus Scanner
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org, Warner Losh 
Subject: Re: svn commit: r184515 - in head/sys: conf modules/rl pci
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: Sat, 01 Nov 2008 07:12:01 -0000

Quoting Bruce M. Simpson, who wrote on Fri, Oct 31, 2008 at 11:28:06PM +0000 ..
> This stuff is absolutely crazy, but I'm glad you checked it in.

/* you are not expected to understand this */


From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 08:07:02 2008
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 DA809106568B;
	Sat,  1 Nov 2008 08:07:02 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C8C238FC17;
	Sat,  1 Nov 2008 08:07:02 +0000 (UTC) (envelope-from ed@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 mA1872Ic002942;
	Sat, 1 Nov 2008 08:07:02 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA18725C002941;
	Sat, 1 Nov 2008 08:07:02 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <200811010807.mA18725C002941@svn.freebsd.org>
From: Ed Schouten 
Date: Sat, 1 Nov 2008 08:07:02 +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: r184520 - head/sys/dev/adb
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: Sat, 01 Nov 2008 08:07:03 -0000

Author: ed
Date: Sat Nov  1 08:07:02 2008
New Revision: 184520
URL: http://svn.freebsd.org/changeset/base/184520

Log:
  Allow a read() on /dev/ams[0-9] to be interrupted.
  
  Right now ams_read() uses cv_wait() to wait for new data to arrive on
  the mouse device. This means that when you run `cat /dev/ams0', it
  cannot be interrupted directly. After you press ^C, you first need to
  move the mouse before cat will quit. Make this function use
  cv_wait_sig(), which allows it to be interrupted directly.
  
  Reviewed by:	nwhitehorn

Modified:
  head/sys/dev/adb/adb_mouse.c

Modified: head/sys/dev/adb/adb_mouse.c
==============================================================================
--- head/sys/dev/adb/adb_mouse.c	Sat Nov  1 06:57:59 2008	(r184519)
+++ head/sys/dev/adb/adb_mouse.c	Sat Nov  1 08:07:02 2008	(r184520)
@@ -382,6 +382,7 @@ ams_read(struct cdev *dev, struct uio *u
 	struct adb_mouse_softc *sc;
 	size_t len;
 	int8_t outpacket[8];
+	int error;
 
 	sc = CDEV_GET_SOFTC(dev);
 	if (sc == NULL)
@@ -403,7 +404,11 @@ ams_read(struct cdev *dev, struct uio *u
 
 	
 			/* Otherwise, block on new data */
-			cv_wait(&sc->sc_cv,&sc->sc_mtx);
+			error = cv_wait_sig(&sc->sc_cv, &sc->sc_mtx);
+			if (error) {
+				mtx_unlock(&sc->sc_mtx);
+				return (error);
+			}
 		}
 
 		sc->packet[0] = 1 << 7;

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 08:35:29 2008
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 412921065680;
	Sat,  1 Nov 2008 08:35:29 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DE2C8FC08;
	Sat,  1 Nov 2008 08:35:29 +0000 (UTC) (envelope-from ed@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 mA18ZSS8003535;
	Sat, 1 Nov 2008 08:35:28 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA18ZSrZ003531;
	Sat, 1 Nov 2008 08:35:28 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <200811010835.mA18ZSrZ003531@svn.freebsd.org>
From: Ed Schouten 
Date: Sat, 1 Nov 2008 08:35:28 +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: r184521 - in head/sys: conf kern sys
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: Sat, 01 Nov 2008 08:35:29 -0000

Author: ed
Date: Sat Nov  1 08:35:28 2008
New Revision: 184521
URL: http://svn.freebsd.org/changeset/base/184521

Log:
  Reimplement the /dev/console device node.
  
  One of the pieces of code that I had left alone during the development
  of the MPSAFE TTY layer, was tty_cons.c. This file actually has two
  different functions:
  
  - It contains low-level console input/output routines (cnputc(), etc).
  
  - It creates /dev/console and wraps all its cdevsw calls to the
    appropriate TTY.
  
  This commit reimplements the second set of functions by moving it
  directly into the TTY layer. /dev/console is now a character device node
  that's basically a regular TTY, but does a lookup of `si_drv1' each time
  you open it. d_write has also been changed to call log_console().
  d_close() is not present, because we must make sure we don't revoke the
  TTY after writing a log message to it.
  
  Even though I'm not convinced this is in line with the future directions
  of our console code, it is a good move for now. It removes recursive
  locking from the top half of the TTY layer. The previous implementation
  called into the TTY layer with Giant held.
  
  I'm renaming tty_cons.c to kern_cons.c now. The code hardly contains any
  TTY related bits, so we'd better give it a less misleading name.
  
  Tested by:	Andrzej Tobola ,
  		Carlos A.M. dos Santos ,
  		Eygene Ryabinkin 

Added:
  head/sys/kern/kern_cons.c   (contents, props changed)
     - copied, changed from r184520, head/sys/kern/tty_cons.c
Deleted:
  head/sys/kern/tty_cons.c
Modified:
  head/sys/conf/files
  head/sys/kern/tty.c
  head/sys/sys/tty.h

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Sat Nov  1 08:07:02 2008	(r184520)
+++ head/sys/conf/files	Sat Nov  1 08:35:28 2008	(r184521)
@@ -1596,6 +1596,7 @@ kern/kern_alq.c			optional alq
 kern/kern_clock.c		standard
 kern/kern_condvar.c		standard
 kern/kern_conf.c		standard
+kern/kern_cons.c		standard
 kern/kern_cpu.c			standard
 kern/kern_cpuset.c		standard
 kern/kern_context.c		standard
@@ -1708,7 +1709,6 @@ kern/sysv_sem.c			optional sysvsem
 kern/sysv_shm.c			optional sysvshm
 kern/tty.c			standard
 kern/tty_compat.c		optional compat_43tty
-kern/tty_cons.c			standard
 kern/tty_info.c			standard
 kern/tty_inq.c			standard
 kern/tty_outq.c			standard

Copied and modified: head/sys/kern/kern_cons.c (from r184520, head/sys/kern/tty_cons.c)
==============================================================================
--- head/sys/kern/tty_cons.c	Sat Nov  1 08:07:02 2008	(r184520, copy source)
+++ head/sys/kern/kern_cons.c	Sat Nov  1 08:35:28 2008	(r184521)
@@ -68,30 +68,8 @@ __FBSDID("$FreeBSD$");
 
 static MALLOC_DEFINE(M_TTYCONS, "tty console", "tty console handling");
 
-static	d_open_t	cnopen;
-static	d_close_t	cnclose;
-static	d_read_t	cnread;
-static	d_write_t	cnwrite;
-static	d_ioctl_t	cnioctl;
-static	d_poll_t	cnpoll;
-static	d_kqfilter_t	cnkqfilter;
-
-static struct cdevsw cn_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_open =	cnopen,
-	.d_close =	cnclose,
-	.d_read =	cnread,
-	.d_write =	cnwrite,
-	.d_ioctl =	cnioctl,
-	.d_poll =	cnpoll,
-	.d_name =	"console",
-	.d_flags =	D_TTY | D_NEEDGIANT,
-	.d_kqfilter =	cnkqfilter,
-};
-
 struct cn_device {
 	STAILQ_ENTRY(cn_device) cnd_next;
-	struct		vnode *cnd_vp;
 	struct		consdev *cnd_cn;
 };
 
@@ -101,22 +79,12 @@ static struct cn_device cn_devtab[CNDEVT
 static STAILQ_HEAD(, cn_device) cn_devlist =
     STAILQ_HEAD_INITIALIZER(cn_devlist);
 
-#define CND_INVALID(cnd, td) 						\
-	(cnd == NULL || cnd->cnd_vp == NULL ||				\
-	    (cnd->cnd_vp->v_type == VBAD && !cn_devopen(cnd, td, 1)))
-
-static dev_t	cn_udev_t;
-SYSCTL_OPAQUE(_machdep, OID_AUTO, consdev, CTLFLAG_RD,
-	&cn_udev_t, sizeof cn_udev_t, "T,struct cdev *", "");
-
 int	cons_avail_mask = 0;	/* Bit mask. Each registered low level console
 				 * which is currently unavailable for inpit
 				 * (i.e., if it is in graphics mode) will have
 				 * this bit cleared.
 				 */
 static int cn_mute;
-static int openflag;			/* how /dev/console was opened */
-static int cn_is_open;
 static char *consbuf;			/* buffer used by `consmsgbuf' */
 static struct callout conscallout;	/* callout for outputting to constty */
 struct msgbuf consmsgbuf;		/* message buffer for console tty */
@@ -214,6 +182,8 @@ cnadd(struct consdev *cn)
 		printf("WARNING: console at %p has no name\n", cn);
 	}
 	STAILQ_INSERT_TAIL(&cn_devlist, cnd, cnd_next);
+	if (STAILQ_FIRST(&cn_devlist) == cnd)
+		ttyconsdev_select(cnd->cnd_cn->cn_name);
 
 	/* Add device to the active mask. */
 	cnavailable(cn, (cn->cn_flags & CN_FLAG_NOAVAIL) == 0);
@@ -230,10 +200,9 @@ cnremove(struct consdev *cn)
 	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
 		if (cnd->cnd_cn != cn)
 			continue;
+		if (STAILQ_FIRST(&cn_devlist) == cnd)
+			ttyconsdev_select(NULL);
 		STAILQ_REMOVE(&cn_devlist, cnd, cn_device, cnd_next);
-		if (cnd->cnd_vp != NULL)
-			vn_close(cnd->cnd_vp, openflag, NOCRED, NULL);
-		cnd->cnd_vp = NULL;
 		cnd->cnd_cn = NULL;
 
 		/* Remove this device from available mask. */
@@ -267,6 +236,7 @@ cnselect(struct consdev *cn)
 			return;
 		STAILQ_REMOVE(&cn_devlist, cnd, cn_device, cnd_next);
 		STAILQ_INSERT_HEAD(&cn_devlist, cnd, cnd_next);
+		ttyconsdev_select(cnd->cnd_cn->cn_name);
 		return;
 	}
 }
@@ -368,210 +338,12 @@ sysctl_kern_consmute(SYSCTL_HANDLER_ARGS
 	error = sysctl_handle_int(oidp, &cn_mute, 0, req);
 	if (error != 0 || req->newptr == NULL)
 		return (error);
-	if (ocn_mute && !cn_mute && cn_is_open)
-		error = cnopen(NULL, openflag, 0, curthread);
-	else if (!ocn_mute && cn_mute && cn_is_open) {
-		error = cnclose(NULL, openflag, 0, curthread);
-		cn_is_open = 1;		/* XXX hack */
-	}
 	return (error);
 }
 
 SYSCTL_PROC(_kern, OID_AUTO, consmute, CTLTYPE_INT|CTLFLAG_RW,
 	0, sizeof(cn_mute), sysctl_kern_consmute, "I", "");
 
-static int
-cn_devopen(struct cn_device *cnd, struct thread *td, int forceopen)
-{
-	char path[CNDEVPATHMAX];
-	struct nameidata nd;
-	struct vnode *vp;
-	struct cdev *dev;
-	struct cdevsw *csw;
-	int error;
-
-	if ((vp = cnd->cnd_vp) != NULL) {
-		if (!forceopen && vp->v_type != VBAD) {
-			dev = vp->v_rdev;
-			csw = dev_refthread(dev);
-			if (csw == NULL)
-				return (ENXIO);
-			error = (*csw->d_open)(dev, openflag, 0, td);
-			dev_relthread(dev);
-			return (error);
-		}
-		cnd->cnd_vp = NULL;
-		vn_close(vp, openflag, td->td_ucred, td);
-	}
-	snprintf(path, sizeof(path), "/dev/%s", cnd->cnd_cn->cn_name);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
-	error = vn_open(&nd, &openflag, 0, NULL);
-	if (error == 0) {
-		NDFREE(&nd, NDF_ONLY_PNBUF);
-		VOP_UNLOCK(nd.ni_vp, 0);
-		if (nd.ni_vp->v_type == VCHR)
-			cnd->cnd_vp = nd.ni_vp;
-		else
-			vn_close(nd.ni_vp, openflag, td->td_ucred, td);
-	}
-	return (cnd->cnd_vp != NULL);
-}
-
-static int
-cnopen(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	struct cn_device *cnd;
-
-	openflag = flag | FWRITE;	/* XXX */
-	cn_is_open = 1;			/* console is logically open */
-	if (cn_mute)
-		return (0);
-	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next)
-		cn_devopen(cnd, td, 0);
-	return (0);
-}
-
-static int
-cnclose(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	struct cn_device *cnd;
-	struct vnode *vp;
-
-	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
-		if ((vp = cnd->cnd_vp) == NULL)
-			continue; 
-		cnd->cnd_vp = NULL;
-		vn_close(vp, openflag, td->td_ucred, td);
-	}
-	cn_is_open = 0;
-	return (0);
-}
-
-static int
-cnread(struct cdev *dev, struct uio *uio, int flag)
-{
-	struct cn_device *cnd;
-	struct cdevsw *csw;
-	int error;
-
-	cnd = STAILQ_FIRST(&cn_devlist);
-	if (cn_mute || CND_INVALID(cnd, curthread))
-		return (0);
-	dev = cnd->cnd_vp->v_rdev;
-	csw = dev_refthread(dev);
-	if (csw == NULL)
-		return (ENXIO);
-	error = (csw->d_read)(dev, uio, flag);
-	dev_relthread(dev);
-	return (error);
-}
-
-static int
-cnwrite(struct cdev *dev, struct uio *uio, int flag)
-{
-	struct cn_device *cnd;
-	struct cdevsw *csw;
-	int error;
-
-	cnd = STAILQ_FIRST(&cn_devlist);
-	if (cn_mute || CND_INVALID(cnd, curthread))
-		goto done;
-	if (constty)
-		dev = constty->t_dev;
-	else
-		dev = cnd->cnd_vp->v_rdev;
-	if (dev != NULL) {
-		log_console(uio);
-		csw = dev_refthread(dev);
-		if (csw == NULL)
-			return (ENXIO);
-		error = (csw->d_write)(dev, uio, flag);
-		dev_relthread(dev);
-		return (error);
-	}
-done:
-	uio->uio_resid = 0; /* dump the data */
-	return (0);
-}
-
-static int
-cnioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-	struct cn_device *cnd;
-	struct cdevsw *csw;
-	int error;
-
-	cnd = STAILQ_FIRST(&cn_devlist);
-	if (cn_mute || CND_INVALID(cnd, td))
-		return (0);
-	/*
-	 * Superuser can always use this to wrest control of console
-	 * output from the "virtual" console.
-	 */
-	if (cmd == TIOCCONS && constty) {
-		error = priv_check(td, PRIV_TTY_CONSOLE);
-		if (error)
-			return (error);
-		constty = NULL;
-		return (0);
-	}
-	dev = cnd->cnd_vp->v_rdev;
-	if (dev == NULL)
-		return (0);	/* XXX : ENOTTY ? */
-	csw = dev_refthread(dev);
-	if (csw == NULL)
-		return (ENXIO);
-	error = (csw->d_ioctl)(dev, cmd, data, flag, td);
-	dev_relthread(dev);
-	return (error);
-}
-
-/*
- * XXX
- * poll/kqfilter do not appear to be correct
- */
-static int
-cnpoll(struct cdev *dev, int events, struct thread *td)
-{
-	struct cn_device *cnd;
-	struct cdevsw *csw;
-	int error;
-
-	cnd = STAILQ_FIRST(&cn_devlist);
-	if (cn_mute || CND_INVALID(cnd, td))
-		return (0);
-	dev = cnd->cnd_vp->v_rdev;
-	if (dev == NULL)
-		return (0);
-	csw = dev_refthread(dev);
-	if (csw == NULL)
-		return (ENXIO);
-	error = (csw->d_poll)(dev, events, td);
-	dev_relthread(dev);
-	return (error);
-}
-
-static int
-cnkqfilter(struct cdev *dev, struct knote *kn)
-{
-	struct cn_device *cnd;
-	struct cdevsw *csw;
-	int error;
-
-	cnd = STAILQ_FIRST(&cn_devlist);
-	if (cn_mute || CND_INVALID(cnd, curthread))
-		return (EINVAL);
-	dev = cnd->cnd_vp->v_rdev;
-	if (dev == NULL)
-		return (ENXIO);
-	csw = dev_refthread(dev);
-	if (csw == NULL)
-		return (ENXIO);
-	error = (csw->d_kqfilter)(dev, kn);
-	dev_relthread(dev);
-	return (error);
-}
-
 /*
  * Low level console routines.
  */
@@ -737,8 +509,6 @@ static void
 cn_drvinit(void *unused)
 {
 
-	make_dev(&cn_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "console");
-
 	mtx_init(&cnputs_mtx, "cnputs_mtx", NULL, MTX_SPIN | MTX_NOWITNESS);
 	use_cnputs_mtx = 1;
 }

Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c	Sat Nov  1 08:07:02 2008	(r184520)
+++ head/sys/kern/tty.c	Sat Nov  1 08:35:28 2008	(r184521)
@@ -73,6 +73,10 @@ static struct sx tty_list_sx;
 SX_SYSINIT(tty_list, &tty_list_sx, "tty list");
 static unsigned int tty_list_count = 0;
 
+/* Character device of /dev/console. */
+static struct cdev	*dev_console;
+static const char	*dev_console_filename;
+
 /*
  * Flags that are supported and stored by this implementation.
  */
@@ -86,7 +90,7 @@ static unsigned int tty_list_count = 0;
 			HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\
 			CDSR_OFLOW|CCAR_OFLOW)
 
-#define TTY_CALLOUT(tp,d) ((tp)->t_dev != (d))
+#define	TTY_CALLOUT(tp,d) ((d) != (tp)->t_dev && (d) != dev_console)
 
 /*
  * Set TTY buffer sizes.
@@ -1189,11 +1193,7 @@ tty_wait(struct tty *tp, struct cv *cv)
 	int error;
 	int revokecnt = tp->t_revokecnt;
 
-#if 0
-	/* XXX: /dev/console also picks up Giant. */
 	tty_lock_assert(tp, MA_OWNED|MA_NOTRECURSED);
-#endif
-	tty_lock_assert(tp, MA_OWNED);
 	MPASS(!tty_gone(tp));
 
 	error = cv_wait_sig(cv, tp->t_mtx);
@@ -1215,11 +1215,7 @@ tty_timedwait(struct tty *tp, struct cv 
 	int error;
 	int revokecnt = tp->t_revokecnt;
 
-#if 0
-	/* XXX: /dev/console also picks up Giant. */
 	tty_lock_assert(tp, MA_OWNED|MA_NOTRECURSED);
-#endif
-	tty_lock_assert(tp, MA_OWNED);
 	MPASS(!tty_gone(tp));
 
 	error = cv_timedwait_sig(cv, tp->t_mtx, hz);
@@ -1662,6 +1658,10 @@ tty_hiwat_in_unblock(struct tty *tp)
 		ttydevsw_inwakeup(tp);
 }
 
+/*
+ * TTY hooks interface.
+ */
+
 static int
 ttyhook_defrint(struct tty *tp, char c, int flags)
 {
@@ -1745,6 +1745,84 @@ ttyhook_unregister(struct tty *tp)
 	tty_rel_free(tp);
 }
 
+/*
+ * /dev/console handling.
+ */
+
+static int
+ttyconsdev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+{
+	struct tty *tp;
+
+	/* System has no console device. */
+	if (dev_console_filename == NULL)
+		return (ENXIO);
+
+	/* Look up corresponding TTY by device name. */
+	sx_slock(&tty_list_sx);
+	TAILQ_FOREACH(tp, &tty_list, t_list) {
+		if (strcmp(dev_console_filename, tty_devname(tp)) == 0) {
+			dev_console->si_drv1 = tp;
+			break;
+		}
+	}
+	sx_sunlock(&tty_list_sx);
+
+	/* System console has no TTY associated. */
+	if (dev_console->si_drv1 == NULL)
+		return (ENXIO);
+	
+	return (ttydev_open(dev, oflags, devtype, td));
+}
+
+static int
+ttyconsdev_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	log_console(uio);
+
+	return (ttydev_write(dev, uio, ioflag));
+}
+
+/*
+ * /dev/console is a little different than normal TTY's. Unlike regular
+ * TTY device nodes, this device node will not revoke the entire TTY
+ * upon closure and all data written to it will be logged.
+ */
+static struct cdevsw ttyconsdev_cdevsw = {
+	.d_version	= D_VERSION,
+	.d_open		= ttyconsdev_open,
+	.d_read		= ttydev_read,
+	.d_write	= ttyconsdev_write,
+	.d_ioctl	= ttydev_ioctl,
+	.d_kqfilter	= ttydev_kqfilter,
+	.d_poll		= ttydev_poll,
+	.d_mmap		= ttydev_mmap,
+	.d_name		= "ttyconsdev",
+	.d_flags	= D_TTY,
+};
+
+static void
+ttyconsdev_init(void *unused)
+{
+
+	dev_console = make_dev(&ttyconsdev_cdevsw, 0, UID_ROOT, GID_WHEEL,
+	    0600, "console");
+}
+
+SYSINIT(tty, SI_SUB_DRIVERS, SI_ORDER_FIRST, ttyconsdev_init, NULL);
+
+void
+ttyconsdev_select(const char *name)
+{
+
+	dev_console_filename = name;
+}
+
+/*
+ * Debugging routines.
+ */
+
 #include "opt_ddb.h"
 #ifdef DDB
 #include 

Modified: head/sys/sys/tty.h
==============================================================================
--- head/sys/sys/tty.h	Sat Nov  1 08:07:02 2008	(r184520)
+++ head/sys/sys/tty.h	Sat Nov  1 08:35:28 2008	(r184521)
@@ -192,6 +192,9 @@ dev_t	tty_udev(struct tty *tp);
 /* Status line printing. */
 void	tty_info(struct tty *tp);
 
+/* /dev/console selection. */
+void	ttyconsdev_select(const char *name);
+
 /* Pseudo-terminal hooks. */
 int	pts_alloc_external(int fd, struct thread *td, struct file *fp,
     struct cdev *dev, const char *name);

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 10:30:31 2008
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 22C8B1065673;
	Sat,  1 Nov 2008 10:30:31 +0000 (UTC)
	(envelope-from kostikbel@gmail.com)
Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147])
	by mx1.freebsd.org (Postfix) with ESMTP id B677F8FC12;
	Sat,  1 Nov 2008 10:30:30 +0000 (UTC)
	(envelope-from kostikbel@gmail.com)
Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua)
	by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256)
	(Exim 4.63 (FreeBSD)) (envelope-from )
	id 1KwDkS-0004LP-Qz; Sat, 01 Nov 2008 12:30:28 +0200
Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua
	[10.1.1.148])
	by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id mA1AUPCu053137
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 1 Nov 2008 12:30:25 +0200 (EET)
	(envelope-from kostikbel@gmail.com)
Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1])
	by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id
	mA1AUPk2034902; Sat, 1 Nov 2008 12:30:25 +0200 (EET)
	(envelope-from kostikbel@gmail.com)
Received: (from kostik@localhost)
	by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id mA1AUPZH034901; 
	Sat, 1 Nov 2008 12:30:25 +0200 (EET)
	(envelope-from kostikbel@gmail.com)
X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to
	kostikbel@gmail.com using -f
Date: Sat, 1 Nov 2008 12:30:25 +0200
From: Kostik Belousov 
To: Warner Losh 
Message-ID: <20081101103025.GU18100@deviant.kiev.zoral.com.ua>
References: <200810312324.m9VNOE88093395@svn.freebsd.org>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="xdFnWCcMW4kMaGnb"
Content-Disposition: inline
In-Reply-To: <200810312324.m9VNOE88093395@svn.freebsd.org>
User-Agent: Mutt/1.4.2.3i
X-Virus-Scanned: ClamAV version 0.93.3,
	clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua
X-Virus-Status: Clean
X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00
	autolearn=ham version=3.2.5
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on
	skuns.kiev.zoral.com.ua
X-Virus-Scanned: mail.terabit.net.ua 1KwDkS-0004LP-Qz
	4cac31941f32609220dbf0f125f91a04
X-Terabit: YES
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184515 - in head/sys: conf modules/rl pci
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: Sat, 01 Nov 2008 10:30:31 -0000


--xdFnWCcMW4kMaGnb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 31, 2008 at 11:24:14PM +0000, Warner Losh wrote:
> Author: imp
> Date: Fri Oct 31 23:24:13 2008
> New Revision: 184515
> URL: http://svn.freebsd.org/changeset/base/184515
>=20
> Log:
>   Add RL_TWISTER_ENABLE option.  This enables the magic bits to do long
>   cable tuning.  This has helped in some installations for hardware
>   deployed by a former employer.  Made optional because the lists aren't
>   full of complaints about these cards... even when they were wildly
>   popular.
>  =20
>   Reviewed by:	attilio@, jhb@, trhodes@ (all an older version of the patc=
h)
>=20
> Modified:
>   head/sys/conf/options
>   head/sys/modules/rl/Makefile
>   head/sys/pci/if_rl.c
>   head/sys/pci/if_rlreg.h
>=20
> Modified: head/sys/conf/options
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/conf/options	Fri Oct 31 18:40:35 2008	(r184514)
> +++ head/sys/conf/options	Fri Oct 31 23:24:13 2008	(r184515)
> @@ -672,6 +672,9 @@ ED_SIC			opt_ed.h
>  # bce driver
>  BCE_DEBUG		opt_bce.h
> =20
> +# rl driver
> +RL_TWISTER_ENABLE	opt_rl.h
Would it make sense to compile it unconditionally, but enable by a sysctl
or loader knob ?

--xdFnWCcMW4kMaGnb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkkML8AACgkQC3+MBN1Mb4joZACfbzNsZ3L73wv45JjcAvaYv5Ne
j+0An2UfRj86WoE3K2DAQtiU7bkRvN09
=yHwE
-----END PGP SIGNATURE-----

--xdFnWCcMW4kMaGnb--

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 11:05:45 2008
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 11E211065676;
	Sat,  1 Nov 2008 11:05:45 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au
	[211.29.132.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 896938FC18;
	Sat,  1 Nov 2008 11:05:44 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from c122-106-151-199.carlnfd1.nsw.optusnet.com.au
	(c122-106-151-199.carlnfd1.nsw.optusnet.com.au [122.106.151.199])
	by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	mA1B5f8n025247
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 1 Nov 2008 22:05:42 +1100
Date: Sat, 1 Nov 2008 22:05:41 +1100 (EST)
From: Bruce Evans 
X-X-Sender: bde@delplex.bde.org
To: Robert Watson 
In-Reply-To: <200810311447.m9VElFtp083250@svn.freebsd.org>
Message-ID: <20081101212937.D12448@delplex.bde.org>
References: <200810311447.m9VElFtp083250@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184509 - head/share/man/man9
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: Sat, 01 Nov 2008 11:05:45 -0000

On Fri, 31 Oct 2008, Robert Watson wrote:

> Log:
>  In style(9) examples of err() and errx(), use sysexits(3) errors rather
>  than returning 1.

style(9) was correct.  Using sysexits(3) is a style bug in most cases,
especially in err() and errx() messages where there is a text message
and not just a cryptic error code.  (Originally, in 4.4BSD, sysexits.3
doesn't exist and /usr/src/admin/style/style had no mention of sysexits.h.
What /usr/src/admin/style/style had was a rule to not label every error
exit with a unique error code, since this gives a large undocumented
set of program-specific error codes which no one remembers.  Using
sysexits gives the same results in practice -- it gives a large
documented set of generic error codes which no one remembers, so it
was a bug to change the rule from disallowing lots of error codes to
encouraging use of sysexits.  In 4.4BSD-Lite2, sysexits.3 still doesn't
exist, and sysexits.h is only referred to in 11 .c files.  This shows
that use of sysexits is very unusual in BSD code.  Some FreeBSD users
like it and added it to style.9 and some FreeBSD .c files, so it is
just unusual in FreeBSD code.)

Bruce

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 11:32:16 2008
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 87D4E1065670;
	Sat,  1 Nov 2008 11:32:16 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au
	[211.29.132.190])
	by mx1.freebsd.org (Postfix) with ESMTP id 267238FC1A;
	Sat,  1 Nov 2008 11:32:15 +0000 (UTC)
	(envelope-from brde@optusnet.com.au)
Received: from c122-106-151-199.carlnfd1.nsw.optusnet.com.au
	(c122-106-151-199.carlnfd1.nsw.optusnet.com.au [122.106.151.199])
	by mail09.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id
	mA1BWCjJ009469
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 1 Nov 2008 22:32:14 +1100
Date: Sat, 1 Nov 2008 22:32:12 +1100 (EST)
From: Bruce Evans 
X-X-Sender: bde@delplex.bde.org
To: Robert Watson 
In-Reply-To: <200810311514.m9VFEfi9083785@svn.freebsd.org>
Message-ID: <20081101220954.B12551@delplex.bde.org>
References: <200810311514.m9VFEfi9083785@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r184511 - head/lib/libc/gen
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: Sat, 01 Nov 2008 11:32:16 -0000

On Fri, 31 Oct 2008, Robert Watson wrote:

> Log:
>  In example use of err(3) and errx(3), use sysexits(3) constants.

Use of sysexits is a style bug here too (see a reply to the corresponding
change in style.9 for more details).

> Modified: head/lib/libc/gen/err.3
> ==============================================================================
> --- head/lib/libc/gen/err.3	Fri Oct 31 15:11:01 2008	(r184510)
> +++ head/lib/libc/gen/err.3	Fri Oct 31 15:14:40 2008	(r184511)
> @@ -178,15 +178,16 @@ or a null pointer
> Display the current errno information string and exit:
> .Bd -literal -offset indent
> if ((p = malloc(size)) == NULL)
> -	err(1, NULL);
> +	err(EX_OSERR, NULL);
> if ((fd = open(file_name, O_RDONLY, 0)) == -1)
> -	err(1, "%s", file_name);
> +	err(EX_NOINPUT, "%s", file_name);

These have other style bugs -- a null or incomplete error message makes
a sysexits error code almost useful.

Normal for malloc failure is errx(1, "malloc failed").  This intentionally
uses errx() instead of err() since the usual error ENOMEM for malloc()
failure is considered useless, and/or the code is supposed to be
portable to systems where malloc() is not guaranteed to set errno on
failure.  FreeBSD's actually malloc() claims to always set errno to
ENOMEM on error.  It seems to actually do this.  This involves clobbering
any possibly-more useful different errno set by mmap() etc. after
preserving the original errno in a nonstandard place.  Apart from this,
with malloc() being even more in userland and with possibly more
complicated failure modes, the printing error code might be more useful.
(Except of couse malloc9) neverl fails :-), and when it does the
MALLOC_OPTIONS="A" mistake makes it abort.)  Also, with malloc() more
in userland, EX_OSERR for malloc failure is wronger than before.

Normal for open failure is err(1, "cannot open %s", file_name);.

Bruce

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 13:40:46 2008
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 B976E1065672;
	Sat,  1 Nov 2008 13:40:46 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A9A208FC1A;
	Sat,  1 Nov 2008 13:40:46 +0000 (UTC) (envelope-from ed@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 mA1DekCT010310;
	Sat, 1 Nov 2008 13:40:46 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1Dekxr010308;
	Sat, 1 Nov 2008 13:40:46 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <200811011340.mA1Dekxr010308@svn.freebsd.org>
From: Ed Schouten 
Date: Sat, 1 Nov 2008 13:40:46 +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: r184522 - in head: sys/kern usr.sbin/pstat
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: Sat, 01 Nov 2008 13:40:46 -0000

Author: ed
Date: Sat Nov  1 13:40:46 2008
New Revision: 184522
URL: http://svn.freebsd.org/changeset/base/184522

Log:
  Clamp the values of t_column to 5 digits in `pstat -t' and `show all ttys'.
  
  We often run into these very high column numbers when we run curses
  applications, because they don't print any newlines. This messes up the
  table output of `pstat -t'. If these numbers get really high, they
  aren't of any use to the reader anyway. Convert them to `99999' when
  they run out of bounds.

Modified:
  head/sys/kern/tty.c
  head/usr.sbin/pstat/pstat.c

Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c	Sat Nov  1 08:35:28 2008	(r184521)
+++ head/sys/kern/tty.c	Sat Nov  1 13:40:46 2008	(r184522)
@@ -2007,7 +2007,7 @@ DB_SHOW_ALL_COMMAND(ttys, db_show_all_tt
 		    osiz,
 		    tp->t_outq.to_end - tp->t_outq.to_begin,
 		    osiz - tp->t_outlow,
-		    tp->t_column,
+		    MIN(tp->t_column, 99999),
 		    tp->t_session ? tp->t_session->s_sid : 0,
 		    tp->t_pgrp ? tp->t_pgrp->pg_id : 0);
 

Modified: head/usr.sbin/pstat/pstat.c
==============================================================================
--- head/usr.sbin/pstat/pstat.c	Sat Nov  1 08:35:28 2008	(r184521)
+++ head/usr.sbin/pstat/pstat.c	Sat Nov  1 13:40:46 2008	(r184522)
@@ -334,7 +334,7 @@ ttyprt(struct xtty *xt)
 	    xt->xt_insize, xt->xt_incc, xt->xt_inlc,
 	    (xt->xt_insize - xt->xt_inlow), xt->xt_outsize,
 	    xt->xt_outcc, (xt->xt_outsize - xt->xt_outlow),
-	    xt->xt_column, xt->xt_sid, xt->xt_pgid);
+	    MIN(xt->xt_column, 99999), xt->xt_sid, xt->xt_pgid);
 	for (i = j = 0; ttystates[i].flag; i++)
 		if (xt->xt_flags & ttystates[i].flag) {
 			putchar(ttystates[i].val);

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 14:19:56 2008
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 3222E1065670;
	Sat,  1 Nov 2008 14:19:56 +0000 (UTC)
	(envelope-from brueffer@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2083A8FC14;
	Sat,  1 Nov 2008 14:19:56 +0000 (UTC)
	(envelope-from brueffer@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 mA1EJu1T011421;
	Sat, 1 Nov 2008 14:19:56 GMT (envelope-from brueffer@svn.freebsd.org)
Received: (from brueffer@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1EJu4o011420;
	Sat, 1 Nov 2008 14:19:56 GMT (envelope-from brueffer@svn.freebsd.org)
Message-Id: <200811011419.mA1EJu4o011420@svn.freebsd.org>
From: Christian Brueffer 
Date: Sat, 1 Nov 2008 14:19:56 +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: r184523 - head/share/man/man4
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: Sat, 01 Nov 2008 14:19:56 -0000

Author: brueffer
Date: Sat Nov  1 14:19:55 2008
New Revision: 184523
URL: http://svn.freebsd.org/changeset/base/184523

Log:
  - Add one more supported adapter (1)
  - Fix a couple of typos
  
  Submitted by:	Horvath Andras (1)

Modified:
  head/share/man/man4/zyd.4

Modified: head/share/man/man4/zyd.4
==============================================================================
--- head/share/man/man4/zyd.4	Sat Nov  1 13:40:46 2008	(r184522)
+++ head/share/man/man4/zyd.4	Sat Nov  1 14:19:55 2008	(r184523)
@@ -32,7 +32,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 .\" THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd Apri 13, 2008
+.Dd November 1, 2008
 .Dt ZYD 4
 .Os
 .Sh NAME
@@ -84,7 +84,7 @@ driver:
 .It Airlink+ AWLL3025
 .It Airlink 101 AWLL3026
 .It AOpen 802.11g WL54
-.It Asus A9T integrated wirless
+.It Asus A9T integrated wireless
 .It Asus WL-159g
 .It Belkin F5D7050 v.4000
 .It Billion BiPAC 3011G
@@ -98,6 +98,7 @@ driver:
 .It Linksys WUSBF54G
 .It Longshine LCS-8131G3
 .It MSI US54SE
+.It MyTek MWU-201 USB adapter
 .It Philips SNU5600
 .It Planet WL-U356
 .It Planex GW-US54GZ
@@ -124,7 +125,7 @@ driver:
 .El
 .Sh EXAMPLES
 The following
-examples configures zyd0 to join any BSS network using WEP key
+example configures zyd0 to join any BSS network using WEP key
 .Dq 0x1deadbeef1 ,
 channel 11:
 .Bd -literal -offset indent
@@ -167,7 +168,7 @@ This should not happen.
 .Xr wlan_tkip 4 ,
 .Xr wlan_wep 4 ,
 .Xr ifconfig 8 ,
-.Xr wpa_supplicant 8 .
+.Xr wpa_supplicant 8
 .Sh AUTHORS
 .An -nosplit
 The original

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 16:47:21 2008
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 2F255106568C;
	Sat,  1 Nov 2008 16:47:21 +0000 (UTC) (envelope-from imp@bsdimp.com)
Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85])
	by mx1.freebsd.org (Postfix) with ESMTP id DF1C18FC14;
	Sat,  1 Nov 2008 16:47:20 +0000 (UTC) (envelope-from imp@bsdimp.com)
Received: from localhost (localhost [127.0.0.1])
	by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mA1GisrU015627;
	Sat, 1 Nov 2008 10:44:54 -0600 (MDT) (envelope-from imp@bsdimp.com)
Date: Sat, 01 Nov 2008 10:46:07 -0600 (MDT)
Message-Id: <20081101.104607.1844477909.imp@bsdimp.com>
To: kostikbel@gmail.com
From: "M. Warner Losh" 
In-Reply-To: <20081101103025.GU18100@deviant.kiev.zoral.com.ua>
References: <200810312324.m9VNOE88093395@svn.freebsd.org>
	<20081101103025.GU18100@deviant.kiev.zoral.com.ua>
X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org,
	src-committers@FreeBSD.org
Subject: Re: svn commit: r184515 - in head/sys: conf modules/rl pci
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: Sat, 01 Nov 2008 16:47:21 -0000

In message: <20081101103025.GU18100@deviant.kiev.zoral.com.ua>
            Kostik Belousov  writes:
: On Fri, Oct 31, 2008 at 11:24:14PM +0000, Warner Losh wrote:
: > Author: imp
: > Date: Fri Oct 31 23:24:13 2008
: > New Revision: 184515
: > URL: http://svn.freebsd.org/changeset/base/184515
: > 
: > Log:
: >   Add RL_TWISTER_ENABLE option.  This enables the magic bits to do long
: >   cable tuning.  This has helped in some installations for hardware
: >   deployed by a former employer.  Made optional because the lists aren't
: >   full of complaints about these cards... even when they were wildly
: >   popular.
: >   
: >   Reviewed by:	attilio@, jhb@, trhodes@ (all an older version of the patch)
: > 
: > Modified:
: >   head/sys/conf/options
: >   head/sys/modules/rl/Makefile
: >   head/sys/pci/if_rl.c
: >   head/sys/pci/if_rlreg.h
: > 
: > Modified: head/sys/conf/options
: > ==============================================================================
: > --- head/sys/conf/options	Fri Oct 31 18:40:35 2008	(r184514)
: > +++ head/sys/conf/options	Fri Oct 31 23:24:13 2008	(r184515)
: > @@ -672,6 +672,9 @@ ED_SIC			opt_ed.h
: >  # bce driver
: >  BCE_DEBUG		opt_bce.h
: >  
: > +# rl driver
: > +RL_TWISTER_ENABLE	opt_rl.h
: Would it make sense to compile it unconditionally, but enable by a sysctl
: or loader knob ?

That's a good idea.  Given the level of problems here, and my lack of
time, I'll leave it to someone else I think.

Warner

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 17:02:02 2008
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 72E2B1065673;
	Sat,  1 Nov 2008 17:02:02 +0000 (UTC) (envelope-from imp@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 60B7C8FC16;
	Sat,  1 Nov 2008 17:02:02 +0000 (UTC) (envelope-from imp@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 mA1H22F4014218;
	Sat, 1 Nov 2008 17:02:02 GMT (envelope-from imp@svn.freebsd.org)
Received: (from imp@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1H22vn014217;
	Sat, 1 Nov 2008 17:02:02 GMT (envelope-from imp@svn.freebsd.org)
Message-Id: <200811011702.mA1H22vn014217@svn.freebsd.org>
From: Warner Losh 
Date: Sat, 1 Nov 2008 17:02:02 +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: r184524 - head/sys/pci
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: Sat, 01 Nov 2008 17:02:02 -0000

Author: imp
Date: Sat Nov  1 17:02:01 2008
New Revision: 184524
URL: http://svn.freebsd.org/changeset/base/184524

Log:
  Fix a few typos/spelling errors in my comments from the last commit,
  plus a few others that had lingered in this driver...
  
  Submitted by:	"b." bf2006a att yahoo KIBO com

Modified:
  head/sys/pci/if_rl.c

Modified: head/sys/pci/if_rl.c
==============================================================================
--- head/sys/pci/if_rl.c	Sat Nov  1 14:19:55 2008	(r184523)
+++ head/sys/pci/if_rl.c	Sat Nov  1 17:02:01 2008	(r184524)
@@ -156,7 +156,7 @@ static struct rl_type rl_devs[] = {
 	{ DELTA_VENDORID, DELTA_DEVICEID_8139, RL_8139,
 		"Delta Electronics 8139 10/100BaseTX" },
 	{ ADDTRON_VENDORID, ADDTRON_DEVICEID_8139, RL_8139,
-		"Addtron Technolgy 8139 10/100BaseTX" },
+		"Addtron Technology 8139 10/100BaseTX" },
 	{ DLINK_VENDORID, DLINK_DEVICEID_530TXPLUS, RL_8139,
 		"D-Link DFE-530TX+ 10/100BaseTX" },
 	{ DLINK_VENDORID, DLINK_DEVICEID_690TXD, RL_8139,
@@ -1319,7 +1319,7 @@ rl_rxeof(struct rl_softc *sc)
 		RL_LOCK(sc);
 	}
 
-	/* No need to sync Rx memory block as we didn't mofify it. */
+	/* No need to sync Rx memory block as we didn't modify it. */
 }
 
 /*
@@ -1402,15 +1402,15 @@ rl_twister_update(struct rl_softc *sc)
 
 	/*
 	 * Tune the so-called twister registers of the RTL8139.  These
-	 * are used to compensate for impendence mismatches.  The
-	 * method for tuning these registes is undocumented and the
-	 * following proceedure is collected from public sources.
+	 * are used to compensate for impedance mismatches.  The
+	 * method for tuning these registers is undocumented and the
+	 * following procedure is collected from public sources.
 	 */
 	switch (sc->rl_twister)
 	{
 	case CHK_LINK:
 		/*
-		 * If we have a sufficent link, then we can proceed in
+		 * If we have a sufficient link, then we can proceed in
 		 * the state machine to the next stage.  If not, then
 		 * disable further tuning after writing sane defaults.
 		 */
@@ -1649,7 +1649,7 @@ rl_encap(struct rl_softc *sc, struct mbu
 
 	if (padlen > 0) {
 		/*
-		 * Make security concious people happy: zero out the
+		 * Make security-conscious people happy: zero out the
 		 * bytes in the pad area, since we don't know what
 		 * this mbuf cluster buffer's previous user might
 		 * have left in it.

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 19:02:05 2008
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 EBADE1065673;
	Sat,  1 Nov 2008 19:02:05 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D9DA58FC0A;
	Sat,  1 Nov 2008 19:02:05 +0000 (UTC)
	(envelope-from trasz@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 mA1J25EW016487;
	Sat, 1 Nov 2008 19:02:05 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1J25nC016486;
	Sat, 1 Nov 2008 19:02:05 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <200811011902.mA1J25nC016486@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Sat, 1 Nov 2008 19:02:05 +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: r184528 - head/share/man/man9
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: Sat, 01 Nov 2008 19:02:06 -0000

Author: trasz
Date: Sat Nov  1 19:02:05 2008
New Revision: 184528
URL: http://svn.freebsd.org/changeset/base/184528

Log:
  Remove obsolete pseudocode from VOP_ACCESS.9, replacing it with something
  closer to reality.
  
  Approved by:	rwatson (mentor)

Modified:
  head/share/man/man9/VOP_ACCESS.9

Modified: head/share/man/man9/VOP_ACCESS.9
==============================================================================
--- head/share/man/man9/VOP_ACCESS.9	Sat Nov  1 18:57:58 2008	(r184527)
+++ head/share/man/man9/VOP_ACCESS.9	Sat Nov  1 19:02:05 2008	(r184528)
@@ -94,45 +94,12 @@ vop_access(struct vnode *vp, accmode_t a
 
     /* If immutable bit set, nobody gets to write it. */
     if ((accmode & VWRITE) && vp has immutable bit set)
-	return EPERM;
+	return (EPERM);
 
-    /* Otherwise, user id 0 always gets access. */
-    if (cred->cr_uid == 0)
-	return 0;
+    error = vaccess(vp->v_type, mode of vp, owner of vp,
+        group of vp, ap->a_accmode, ap->a_cred, NULL);
 
-    mask = 0;
-
-    /* Otherwise, check the owner. */
-    if (cred->cr_uid == owner of vp) {
-	if (accmode & VEXEC)
-	    mask |= S_IXUSR;
-	if (accmode & VREAD)
-	    mask |= S_IRUSR;
-	if (accmode & VWRITE)
-	    mask |= S_IWUSR;
-	return (((mode of vp) & mask) == mask ? 0 : EACCES);
-    }
-
-    /* Otherwise, check the groups. */
-    for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
-	if (group of vp == *gp) {
-	    if (accmode & VEXEC)
-		mask |= S_IXGRP;
-	    if (accmode & VREAD)
-		mask |= S_IRGRP;
-	    if (accmode & VWRITE)
-		mask |= S_IWGRP;
-	    return (((mode of vp) & mask) == mask ? 0 : EACCES);
-	}
-
-    /* Otherwise, check everyone else. */
-    if (accmode & VEXEC)
-	mask |= S_IXOTH;
-    if (accmode & VREAD)
-	mask |= S_IROTH;
-    if (accmode & VWRITE)
-	mask |= S_IWOTH;
-    return (((mode of vp) & mask) == mask ? 0 : EACCES);
+    return (error);
 }
 .Ed
 .Sh ERRORS

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 19:11:21 2008
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 9E072106564A;
	Sat,  1 Nov 2008 19:11:21 +0000 (UTC)
	(envelope-from kientzle@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8CB2E8FC20;
	Sat,  1 Nov 2008 19:11:21 +0000 (UTC)
	(envelope-from kientzle@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 mA1JBLHP016674;
	Sat, 1 Nov 2008 19:11:21 GMT (envelope-from kientzle@svn.freebsd.org)
Received: (from kientzle@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1JBLXp016673;
	Sat, 1 Nov 2008 19:11:21 GMT (envelope-from kientzle@svn.freebsd.org)
Message-Id: <200811011911.mA1JBLXp016673@svn.freebsd.org>
From: Tim Kientzle 
Date: Sat, 1 Nov 2008 19:11:21 +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: r184529 - head/lib/libarchive
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: Sat, 01 Nov 2008 19:11:21 -0000

Author: kientzle
Date: Sat Nov  1 19:11:21 2008
New Revision: 184529
URL: http://svn.freebsd.org/changeset/base/184529

Log:
  Correct the documented declaration of the archive_write_callback to
  match the code.
  
  PR:		docs/128089
  Submitted by:	Mel
  MFC after:	3 days

Modified:
  head/lib/libarchive/archive_write.3

Modified: head/lib/libarchive/archive_write.3
==============================================================================
--- head/lib/libarchive/archive_write.3	Sat Nov  1 19:02:05 2008	(r184528)
+++ head/lib/libarchive/archive_write.3	Sat Nov  1 19:11:21 2008	(r184529)
@@ -342,7 +342,7 @@ to register an error code and message an
 .Fo archive_write_callback
 .Fa "struct archive *"
 .Fa "void *client_data"
-.Fa "void *buffer"
+.Fa "const void *buffer"
 .Fa "size_t length"
 .Fc
 .El
@@ -410,7 +410,7 @@ myopen(struct archive *a, void *client_d
 }
 
 ssize_t
-mywrite(struct archive *a, void *client_data, void *buff, size_t n)
+mywrite(struct archive *a, void *client_data, const void *buff, size_t n)
 {
   struct mydata *mydata = client_data;
 

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 21:16:09 2008
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 9CC531065672;
	Sat,  1 Nov 2008 21:16:09 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8A7A58FC0C;
	Sat,  1 Nov 2008 21:16:09 +0000 (UTC)
	(envelope-from rwatson@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 mA1LG95X019045;
	Sat, 1 Nov 2008 21:16:09 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1LG91K019044;
	Sat, 1 Nov 2008 21:16:09 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200811012116.mA1LG91K019044@svn.freebsd.org>
From: Robert Watson 
Date: Sat, 1 Nov 2008 21:16:09 +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: r184534 - head/sys/security/audit
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: Sat, 01 Nov 2008 21:16:09 -0000

Author: rwatson
Date: Sat Nov  1 21:16:09 2008
New Revision: 184534
URL: http://svn.freebsd.org/changeset/base/184534

Log:
  Allow a single read(2) system call on an audit pipe to retrieve data from
  more than one audit record at a time in order to improve efficiency.
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Sat Nov  1 20:54:52 2008	(r184533)
+++ head/sys/security/audit/audit_pipe.c	Sat Nov  1 21:16:09 2008	(r184534)
@@ -930,19 +930,8 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 }
 
 /*
- * Audit pipe read.  Pull one record off the queue and copy to user space.
- * On error, the record is dropped.
- *
- * Providing more sophisticated behavior, such as partial reads, is tricky
- * due to the potential for parallel I/O.  If partial read support is
- * required, it will require a per-pipe "current record being read" along
- * with an offset into that trecord which has already been read.  Threads
- * performing partial reads will need to allocate per-thread copies of the
- * data so that if another thread completes the read of the record, it can be
- * freed without adding reference count logic.  If this is added, a flag to
- * indicate that only atomic record reads are desired would be useful, as if
- * different threads are all waiting for records on the pipe, they will want
- * independent record reads, which is currently the behavior.
+ * Audit pipe read.  Read one or more partial or complete records to user
+ * memory.
  */
 static int
 audit_pipe_read(struct cdev *dev, struct uio *uio, int flag)
@@ -978,40 +967,43 @@ audit_pipe_read(struct cdev *dev, struct
 
 	/*
 	 * Copy as many remaining bytes from the current record to userspace
-	 * as we can.
+	 * as we can.  Keep processing records until we run out of records in
+	 * the queue, or until the user buffer runs out of space.
 	 *
 	 * Note: we rely on the SX lock to maintain ape's stability here.
 	 */
 	ap->ap_reads++;
-	ape = TAILQ_FIRST(&ap->ap_queue);
-	toread = MIN(ape->ape_record_len - ape->ape_record_offset,
-	    uio->uio_resid);
-	AUDIT_PIPE_UNLOCK(ap);
-	error = uiomove((char *)ape->ape_record + ape->ape_record_offset,
-	    toread, uio);
-	if (error) {
-		AUDIT_PIPE_SX_XUNLOCK(ap);
-		return (error);
-	}
+	while ((ape = TAILQ_FIRST(&ap->ap_queue)) != NULL &&
+	    uio->uio_resid > 0) {
+		AUDIT_PIPE_LOCK_ASSERT(ap);
 
-	/*
-	 * If the copy succeeded, update book-keeping, and if no bytes remain
-	 * in the current record, free it.
-	 */
-	AUDIT_PIPE_LOCK(ap);
-	KASSERT(TAILQ_FIRST(&ap->ap_queue) == ape,
-	    ("audit_pipe_read: queue out of sync after uiomove"));
-	ape->ape_record_offset += toread;
-	if (ape->ape_record_offset == ape->ape_record_len) {
-		TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
-		ap->ap_qlen--;
-	} else
-		ape = NULL;
+		toread = MIN(ape->ape_record_len - ape->ape_record_offset,
+		    uio->uio_resid);
+		AUDIT_PIPE_UNLOCK(ap);
+		error = uiomove((char *)ape->ape_record +
+		    ape->ape_record_offset, toread, uio);
+		if (error) {
+			AUDIT_PIPE_SX_XUNLOCK(ap);
+			return (error);
+		}
+
+		/*
+		 * If the copy succeeded, update book-keeping, and if no
+		 * bytes remain in the current record, free it.
+		 */
+		AUDIT_PIPE_LOCK(ap);
+		KASSERT(TAILQ_FIRST(&ap->ap_queue) == ape,
+		    ("audit_pipe_read: queue out of sync after uiomove"));
+		ape->ape_record_offset += toread;
+		if (ape->ape_record_offset == ape->ape_record_len) {
+			TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
+			audit_pipe_entry_free(ape);
+			ap->ap_qlen--;
+		}
+	}
 	AUDIT_PIPE_UNLOCK(ap);
 	AUDIT_PIPE_SX_XUNLOCK(ap);
-	if (ape != NULL)
-		audit_pipe_entry_free(ape);
-	return (error);
+	return (0);
 }
 
 /*

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 21:56:45 2008
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 A936A1065680;
	Sat,  1 Nov 2008 21:56:45 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 971C78FC1A;
	Sat,  1 Nov 2008 21:56:45 +0000 (UTC)
	(envelope-from rwatson@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 mA1LujDa019837;
	Sat, 1 Nov 2008 21:56:45 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1Lujju019836;
	Sat, 1 Nov 2008 21:56:45 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200811012156.mA1Lujju019836@svn.freebsd.org>
From: Robert Watson 
Date: Sat, 1 Nov 2008 21:56:45 +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: r184536 - head/sys/security/audit
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: Sat, 01 Nov 2008 21:56:45 -0000

Author: rwatson
Date: Sat Nov  1 21:56:45 2008
New Revision: 184536
URL: http://svn.freebsd.org/changeset/base/184536

Log:
  We only allow a partial read of the first record in an audit pipe
  record queue, so move the offset field from the per-record
  audit_pipe_entry structure to the audit_pipe structure.
  
  Now that we support reading more than one record at a time, add a
  new summary field to audit_pipe, ap_qbyteslen, which tracks the
  total number of bytes present in a pipe, and return that (minus
  the current offset) via FIONREAD and kqueue's data variable for
  the pending byte count rather than the number of bytes remaining
  in only the first record.
  
  Add a number of asserts to confirm that these counts and offsets
  following the expected rules.
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Sat Nov  1 21:49:32 2008	(r184535)
+++ head/sys/security/audit/audit_pipe.c	Sat Nov  1 21:56:45 2008	(r184536)
@@ -85,7 +85,6 @@ static MALLOC_DEFINE(M_AUDIT_PIPE_PRESEL
 struct audit_pipe_entry {
 	void				*ape_record;
 	u_int				 ape_record_len;
-	u_int				 ape_record_offset;
 	TAILQ_ENTRY(audit_pipe_entry)	 ape_queue;
 };
 
@@ -138,8 +137,17 @@ struct audit_pipe {
 	 */
 	struct cv			 ap_cv;
 
+	/*
+	 * Various queue-reated variables: qlen and qlimit are a count of
+	 * records in the queue; qbyteslen is the number of bytes of data
+	 * across all records, and qoffset is the amount read so far of the
+	 * first record in the queue.  The number of bytes available for
+	 * reading in the queue is qbyteslen - qoffset.
+	 */
 	u_int				 ap_qlen;
 	u_int				 ap_qlimit;
+	u_int				 ap_qbyteslen;
+	u_int				 ap_qoffset;
 
 	u_int64_t			 ap_inserts;	/* Records added. */
 	u_int64_t			 ap_reads;	/* Records read. */
@@ -474,11 +482,11 @@ audit_pipe_append(struct audit_pipe *ap,
 
 	bcopy(record, ape->ape_record, record_len);
 	ape->ape_record_len = record_len;
-	ape->ape_record_offset = 0;
 
 	TAILQ_INSERT_TAIL(&ap->ap_queue, ape, ape_queue);
 	ap->ap_inserts++;
 	ap->ap_qlen++;
+	ap->ap_qbyteslen += ape->ape_record_len;
 	selwakeuppri(&ap->ap_selinfo, PSOCK);
 	KNOTE_LOCKED(&ap->ap_selinfo.si_note, 0);
 	if (ap->ap_flags & AUDIT_PIPE_ASYNC)
@@ -603,10 +611,14 @@ audit_pipe_flush(struct audit_pipe *ap)
 
 	while ((ape = TAILQ_FIRST(&ap->ap_queue)) != NULL) {
 		TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
+		ap->ap_qbyteslen -= ape->ape_record_len;
 		audit_pipe_entry_free(ape);
 		ap->ap_qlen--;
 	}
-	KASSERT(ap->ap_qlen == 0, ("audit_pipe_free: ap_qlen"));
+	ap->ap_qoffset = 0;
+
+	KASSERT(ap->ap_qlen == 0, ("audit_pipe_free: ap_qbyteslen"));
+	KASSERT(ap->ap_qbyteslen == 0, ("audit_pipe_flush: ap_qbyteslen"));
 }
 
 /*
@@ -752,12 +764,7 @@ audit_pipe_ioctl(struct cdev *dev, u_lon
 
 	case FIONREAD:
 		AUDIT_PIPE_LOCK(ap);
-		if (TAILQ_FIRST(&ap->ap_queue) != NULL)
-			*(int *)data =
-			    TAILQ_FIRST(&ap->ap_queue)->ape_record_len -
-			    TAILQ_FIRST(&ap->ap_queue)->ape_record_offset;
-		else
-			*(int *)data = 0;
+		*(int *)data = ap->ap_qbyteslen - ap->ap_qoffset;
 		AUDIT_PIPE_UNLOCK(ap);
 		error = 0;
 		break;
@@ -977,11 +984,13 @@ audit_pipe_read(struct cdev *dev, struct
 	    uio->uio_resid > 0) {
 		AUDIT_PIPE_LOCK_ASSERT(ap);
 
-		toread = MIN(ape->ape_record_len - ape->ape_record_offset,
+		KASSERT(ape->ape_record_len > ap->ap_qoffset,
+		    ("audit_pipe_read: record_len > qoffset (1)"));
+		toread = MIN(ape->ape_record_len - ap->ap_qoffset,
 		    uio->uio_resid);
 		AUDIT_PIPE_UNLOCK(ap);
-		error = uiomove((char *)ape->ape_record +
-		    ape->ape_record_offset, toread, uio);
+		error = uiomove((char *)ape->ape_record + ap->ap_qoffset,
+		    toread, uio);
 		if (error) {
 			AUDIT_PIPE_SX_XUNLOCK(ap);
 			return (error);
@@ -994,11 +1003,15 @@ audit_pipe_read(struct cdev *dev, struct
 		AUDIT_PIPE_LOCK(ap);
 		KASSERT(TAILQ_FIRST(&ap->ap_queue) == ape,
 		    ("audit_pipe_read: queue out of sync after uiomove"));
-		ape->ape_record_offset += toread;
-		if (ape->ape_record_offset == ape->ape_record_len) {
+		ap->ap_qoffset += toread;
+		KASSERT(ape->ape_record_len >= ap->ap_qoffset,
+		    ("audit_pipe_read: record_len >= qoffset (2)"));
+		if (ap->ap_qoffset == ape->ape_record_len) {
 			TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue);
+			ap->ap_qbyteslen -= ape->ape_record_len;
 			audit_pipe_entry_free(ape);
 			ap->ap_qlen--;
+			ap->ap_qoffset = 0;
 		}
 	}
 	AUDIT_PIPE_UNLOCK(ap);
@@ -1071,7 +1084,7 @@ audit_pipe_kqread(struct knote *kn, long
 		ape = TAILQ_FIRST(&ap->ap_queue);
 		KASSERT(ape != NULL, ("audit_pipe_kqread: ape == NULL"));
 
-		kn->kn_data = ape->ape_record_len - ape->ape_record_offset;
+		kn->kn_data = ap->ap_qbyteslen - ap->ap_qoffset;
 		return (1);
 	} else {
 		kn->kn_data = 0;

From owner-svn-src-head@FreeBSD.ORG  Sat Nov  1 23:05:49 2008
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 B39271065674;
	Sat,  1 Nov 2008 23:05:49 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A18CC8FC14;
	Sat,  1 Nov 2008 23:05:49 +0000 (UTC)
	(envelope-from rwatson@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 mA1N5nHn022065;
	Sat, 1 Nov 2008 23:05:49 GMT (envelope-from rwatson@svn.freebsd.org)
Received: (from rwatson@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA1N5nRU022064;
	Sat, 1 Nov 2008 23:05:49 GMT (envelope-from rwatson@svn.freebsd.org)
Message-Id: <200811012305.mA1N5nRU022064@svn.freebsd.org>
From: Robert Watson 
Date: Sat, 1 Nov 2008 23:05:49 +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: r184540 - head/sys/security/audit
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: Sat, 01 Nov 2008 23:05:49 -0000

Author: rwatson
Date: Sat Nov  1 23:05:49 2008
New Revision: 184540
URL: http://svn.freebsd.org/changeset/base/184540

Log:
  Add comment for per-pipe stats.
  
  MFC after:	2 months
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Sat Nov  1 22:18:49 2008	(r184539)
+++ head/sys/security/audit/audit_pipe.c	Sat Nov  1 23:05:49 2008	(r184540)
@@ -149,6 +149,9 @@ struct audit_pipe {
 	u_int				 ap_qbyteslen;
 	u_int				 ap_qoffset;
 
+	/*
+	 * Per-pipe operation statistics.
+	 */
 	u_int64_t			 ap_inserts;	/* Records added. */
 	u_int64_t			 ap_reads;	/* Records read. */
 	u_int64_t			 ap_drops;	/* Records dropped. */