From owner-svn-src-stable-8@FreeBSD.ORG Sun Aug 23 06:33:42 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8529D106568D; Sun, 23 Aug 2009 06:33:42 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 741AF8FC12; Sun, 23 Aug 2009 06:33:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7N6XgXW049222; Sun, 23 Aug 2009 06:33:42 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7N6Xg4a049220; Sun, 23 Aug 2009 06:33:42 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <200908230633.n7N6Xg4a049220@svn.freebsd.org> From: Ken Smith Date: Sun, 23 Aug 2009 06:33:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196443 - stable/8/share/examples/cvsup X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2009 06:33:42 -0000 Author: kensmith Date: Sun Aug 23 06:33:42 2009 New Revision: 196443 URL: http://svn.freebsd.org/changeset/base/196443 Log: Update for RELENG_8. Reminded by: dougb Approved by: re (implicit) Modified: stable/8/share/examples/cvsup/stable-supfile Modified: stable/8/share/examples/cvsup/stable-supfile ============================================================================== --- stable/8/share/examples/cvsup/stable-supfile Sun Aug 23 06:30:14 2009 (r196442) +++ stable/8/share/examples/cvsup/stable-supfile Sun Aug 23 06:33:42 2009 (r196443) @@ -69,7 +69,7 @@ # The following line is for 7-stable. If you want 6-stable, 5-stable, # 4-stable, 3-stable, or 2.2-stable, change to "RELENG_6", "RELENG_5", # "RELENG_4", "RELENG_3", or "RELENG_2_2" respectively. -*default release=cvs tag=RELENG_7 +*default release=cvs tag=RELENG_8 *default delete use-rel-suffix # If you seem to be limited by CPU rather than network or disk bandwidth, try From owner-svn-src-stable-8@FreeBSD.ORG Sun Aug 23 09:45:48 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13530106568C; Sun, 23 Aug 2009 09:45:48 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.freebsd.org (Postfix) with ESMTP id 79A138FC12; Sun, 23 Aug 2009 09:45:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.3/8.14.3) with ESMTP id n7N9SBvw032919; Sun, 23 Aug 2009 13:28:11 +0400 (MSD) (envelope-from marck@rinet.ru) Date: Sun, 23 Aug 2009 13:28:11 +0400 (MSD) From: Dmitry Morozovsky To: Ken Smith In-Reply-To: <200908230633.n7N6Xg4a049220@svn.freebsd.org> Message-ID: References: <200908230633.n7N6Xg4a049220@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (woozle.rinet.ru [0.0.0.0]); Sun, 23 Aug 2009 13:28:11 +0400 (MSD) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196443 - stable/8/share/examples/cvsup X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2009 09:45:48 -0000 Ken, another small glitch: On Sun, 23 Aug 2009, Ken Smith wrote: KS> Modified: stable/8/share/examples/cvsup/stable-supfile KS> ============================================================================== KS> --- stable/8/share/examples/cvsup/stable-supfile Sun Aug 23 06:30:14 2009 (r196442) KS> +++ stable/8/share/examples/cvsup/stable-supfile Sun Aug 23 06:33:42 2009 (r196443) KS> @@ -69,7 +69,7 @@ KS> # The following line is for 7-stable. If you want 6-stable, 5-stable, ~~~~~~~~~~~~ KS> # 4-stable, 3-stable, or 2.2-stable, change to "RELENG_6", "RELENG_5", KS> # "RELENG_4", "RELENG_3", or "RELENG_2_2" respectively. KS> -*default release=cvs tag=RELENG_7 KS> +*default release=cvs tag=RELENG_8 KS> *default delete use-rel-suffix KS> KS> # If you seem to be limited by CPU rather than network or disk bandwidth, try -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From owner-svn-src-stable-8@FreeBSD.ORG Sun Aug 23 16:21:50 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EBFC106568B; Sun, 23 Aug 2009 16:21:50 +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 3D00E8FC26; Sun, 23 Aug 2009 16:21:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7NGLo0g065987; Sun, 23 Aug 2009 16:21:50 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7NGLoKw065985; Sun, 23 Aug 2009 16:21:50 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200908231621.n7NGLoKw065985@svn.freebsd.org> From: Sam Leffler Date: Sun, 23 Aug 2009 16:21:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196473 - in stable/8/usr.sbin/wpa: . wpa_cli X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2009 16:21:50 -0000 Author: sam Date: Sun Aug 23 16:21:49 2009 New Revision: 196473 URL: http://svn.freebsd.org/changeset/base/196473 Log: MFC r196472: Enable _DIRENT_HAVE_D_TYPE so wpa_cli scans directories properly for it's unix domain socket. Before this change wpa_cli would take the first file in the directory that was not "." or "..". Approved by: re (rwatson) Modified: stable/8/usr.sbin/wpa/ (props changed) stable/8/usr.sbin/wpa/wpa_cli/Makefile Modified: stable/8/usr.sbin/wpa/wpa_cli/Makefile ============================================================================== --- stable/8/usr.sbin/wpa/wpa_cli/Makefile Sun Aug 23 16:04:10 2009 (r196472) +++ stable/8/usr.sbin/wpa/wpa_cli/Makefile Sun Aug 23 16:21:49 2009 (r196473) @@ -11,6 +11,8 @@ MAN= wpa_cli.8 CFLAGS+= -DCONFIG_CTRL_IFACE CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX +# enable use of d_type to identify unix domain sockets +CFLAGS+= -D_DIRENT_HAVE_D_TYPE #CFLAGS+= -DCONFIG_READLINE #LDADD+= -ledit -ltermcap From owner-svn-src-stable-8@FreeBSD.ORG Mon Aug 24 03:49:38 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76811106568C; Mon, 24 Aug 2009 03:49:38 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6446C8FC08; Mon, 24 Aug 2009 03:49:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7O3ncdQ080858; Mon, 24 Aug 2009 03:49:38 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7O3ncfi080857; Mon, 24 Aug 2009 03:49:38 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <200908240349.n7O3ncfi080857@svn.freebsd.org> From: Ken Smith Date: Mon, 24 Aug 2009 03:49:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196486 - stable/8/share/examples/cvsup X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2009 03:49:38 -0000 Author: kensmith Date: Mon Aug 24 03:49:37 2009 New Revision: 196486 URL: http://svn.freebsd.org/changeset/base/196486 Log: Update the comment for RELENG_8 too. Submitted by: Dmitry Morozovsky Approved by: re (implicit) Modified: stable/8/share/examples/cvsup/stable-supfile Modified: stable/8/share/examples/cvsup/stable-supfile ============================================================================== --- stable/8/share/examples/cvsup/stable-supfile Mon Aug 24 03:04:13 2009 (r196485) +++ stable/8/share/examples/cvsup/stable-supfile Mon Aug 24 03:49:37 2009 (r196486) @@ -66,9 +66,10 @@ *default host=CHANGE_THIS.FreeBSD.org *default base=/var/db *default prefix=/usr -# The following line is for 7-stable. If you want 6-stable, 5-stable, -# 4-stable, 3-stable, or 2.2-stable, change to "RELENG_6", "RELENG_5", -# "RELENG_4", "RELENG_3", or "RELENG_2_2" respectively. +# The following line is for 8-stable. If you want 7-stable, 6-stable, +# 5-stable, 4-stable, 3-stable, or 2.2-stable, change to "RELENG_7", +# "RELENG_6", "RELENG_5", "RELENG_4", "RELENG_3", or "RELENG_2_2" +# respectively. *default release=cvs tag=RELENG_8 *default delete use-rel-suffix From owner-svn-src-stable-8@FreeBSD.ORG Wed Aug 26 20:57:21 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDC491065691; Wed, 26 Aug 2009 20:57:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB3018FC2C; Wed, 26 Aug 2009 20:57:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7QKvLun073740; Wed, 26 Aug 2009 20:57:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7QKvLKP073739; Wed, 26 Aug 2009 20:57:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908262057.n7QKvLKP073739@svn.freebsd.org> From: Doug Barton Date: Wed, 26 Aug 2009 20:57:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196564 - in stable/8/release: . doc scripts X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 20:57:22 -0000 Author: dougb Date: Wed Aug 26 20:57:21 2009 New Revision: 196564 URL: http://svn.freebsd.org/changeset/base/196564 Log: MFC 196434: Add a script to create the /var/db/mergemaster.mtree file for new releases so that when users subsequently update their source trees they can make use of mergemaster's -U option. Approved by: re (kib) Added: stable/8/release/scripts/mm-mtree.sh - copied unchanged from r196434, head/release/scripts/mm-mtree.sh Modified: stable/8/release/ (props changed) stable/8/release/doc/ (props changed) Copied: stable/8/release/scripts/mm-mtree.sh (from r196434, head/release/scripts/mm-mtree.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/release/scripts/mm-mtree.sh Wed Aug 26 20:57:21 2009 (r196564, copy of r196434, head/release/scripts/mm-mtree.sh) @@ -0,0 +1,155 @@ +#!/bin/sh + +# mergemaster mtree database generator + +# This script is intended to be used as part of the release building +# process to generate the /var/db/mergemaster.mtree file relevant to +# the source tree used to create the release so that users can make +# use of mergemaster's -U option to update their files after csup'ing +# to -stable. + +# Copyright 2009 Douglas Barton +# dougb@FreeBSD.org + +# $FreeBSD$ + +PATH=/bin:/usr/bin:/usr/sbin + +display_usage () { + VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` + echo "${0##*/} version ${VERSION_NUMBER}" + echo "Usage: ${0##*/} [-m /path] [-t /path] [-A arch] [-F ] [-D /path]" + echo "Options:" + echo " -m /path/directory Specify location of source to do the make in" + echo " -t /path/directory Specify temp root directory" + echo " -A architecture Alternative architecture name to pass to make" + echo " -F Specify what to put on the make command line" + echo ' -D /path/directory Specify the destination directory to install files to' + echo '' +} + +# Set the default path for the temporary root environment +# +TEMPROOT='/var/tmp/temproot' + +# Assign the location of the mtree database +# +MTREEDB=${MTREEDB:-/var/db} +MTREEFILE="${MTREEDB}/mergemaster.mtree" + +# Check the command line options +# +while getopts "m:t:A:F:D:h" COMMAND_LINE_ARGUMENT ; do + case "${COMMAND_LINE_ARGUMENT}" in + m) + SOURCEDIR=${OPTARG} + ;; + t) + TEMPROOT=${OPTARG} + ;; + A) + ARCHSTRING='TARGET_ARCH='${OPTARG} + ;; + F) + MM_MAKE_ARGS="${OPTARG}" + ;; + D) + DESTDIR=${OPTARG} + ;; + h) + display_usage + exit 0 + ;; + *) + echo '' + display_usage + exit 1 + ;; + esac +done + +# Assign the source directory +# +SOURCEDIR=${SOURCEDIR:-/usr/src} +if [ ! -f ${SOURCEDIR}/Makefile.inc1 -a \ + -f ${SOURCEDIR}/../Makefile.inc1 ]; then + echo " *** The source directory you specified (${SOURCEDIR})" + echo " will be reset to ${SOURCEDIR}/.." + echo '' + sleep 3 + SOURCEDIR=${SOURCEDIR}/.. +fi + +# Setup make to use system files from SOURCEDIR +MM_MAKE="make ${ARCHSTRING} ${MM_MAKE_ARGS} -m ${SOURCEDIR}/share/mk" + +delete_temproot () { + rm -rf "${TEMPROOT}" 2>/dev/null + chflags -R 0 "${TEMPROOT}" 2>/dev/null + rm -rf "${TEMPROOT}" || exit 1 +} + +[ -d "${TEMPROOT}" ] && delete_temproot + +echo "*** Creating the temporary root environment in ${TEMPROOT}" + +if mkdir -p "${TEMPROOT}"; then + echo " *** ${TEMPROOT} ready for use" +fi + +if [ ! -d "${TEMPROOT}" ]; then + echo '' + echo " *** FATAL ERROR: Cannot create ${TEMPROOT}" + echo '' + exit 1 +fi + +echo " *** Creating and populating directory structure in ${TEMPROOT}" +echo '' + +{ cd ${SOURCEDIR} || { echo "*** Cannot cd to ${SOURCEDIR}" ; exit 1;} + case "${DESTDIR}" in + '') ;; + *) + ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs + ;; + esac + od=${TEMPROOT}/usr/obj + ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} DESTDIR=${TEMPROOT} distribution;} || + { echo ''; + echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to"; + echo " the temproot environment"; + echo ''; + exit 1;} + +# We really don't want to have to deal with files like login.conf.db, pwd.db, +# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. +# Prompt the user to do so below, as needed. +# +rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd + +# We only need to compare things like freebsd.cf once +find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null + +# Delete stuff we do not need to keep the mtree database small, +# and to make the actual comparison faster. +find ${TEMPROOT}/usr -type l -delete 2>/dev/null +find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null +find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null + +# Build the mtree database in a temporary location. +MTREENEW=`mktemp -t mergemaster.mtree` +mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null + +if [ -s "${MTREENEW}" ]; then + echo "*** Saving mtree database for future upgrades" + test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE} + mv ${MTREENEW} ${DESTDIR}${MTREEFILE} +fi + +delete_temproot + +exit 0 From owner-svn-src-stable-8@FreeBSD.ORG Wed Aug 26 21:08:41 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA861106568B; Wed, 26 Aug 2009 21:08:41 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EC918FC19; Wed, 26 Aug 2009 21:08:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7QL8fZ3074317; Wed, 26 Aug 2009 21:08:41 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7QL8fF7074314; Wed, 26 Aug 2009 21:08:41 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908262108.n7QL8fF7074314@svn.freebsd.org> From: Doug Barton Date: Wed, 26 Aug 2009 21:08:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196566 - in stable/8/etc: . rc.d X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 21:08:41 -0000 Author: dougb Date: Wed Aug 26 21:08:41 2009 New Revision: 196566 URL: http://svn.freebsd.org/changeset/base/196566 Log: MFC 196436; Move is_wired_interface() from rc.d/wpa_supplicant into network.subr, simplify it a bit, and make use of that method to determine if an interface is a candidate for IPv6 rtsol rather than listing all of the possible wireless interfaces that should _not_ get rtsol'ed. This change is only relevant for 8.0+ unless the "wlan mandatory" code gets ported back to RELENG_7. Approved by: re (kib) Modified: stable/8/etc/ (props changed) stable/8/etc/network.subr stable/8/etc/rc.d/wpa_supplicant Modified: stable/8/etc/network.subr ============================================================================== --- stable/8/etc/network.subr Wed Aug 26 21:05:17 2009 (r196565) +++ stable/8/etc/network.subr Wed Aug 26 21:08:41 2009 (r196566) @@ -816,6 +816,17 @@ hexprint() echo ${str} } +is_wired_interface() +{ + local media + + case `ifconfig $1 2>/dev/null` in + *media:?Ethernet*) media=Ethernet ;; + esac + + test "$media" = "Ethernet" +} + # Setup the interfaces for IPv6 network6_interface_setup() { @@ -858,14 +869,19 @@ network6_interface_setup() ifconfig $i inet6 ${ipv6_ifconfig} alias fi + # Wireless NIC cards are virtualized through the wlan interface + if ! is_wired_interface ${i}; then + case "${i}" in + wlan*) rtsol_available=yes ;; + *) rtsol_available=no ;; + esac + fi + if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ] then case ${i} in lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*|pflog[0-9]*|pfsync[0-9]*) ;; - # Wireless NIC cards are virtualized through the wlan interface - an[0-9]*|ath[0-9]*|ipw[0-9]*|iwi[0-9]*|iwn[0-9]*|ral[0-9]*|wi[0-9]*|wl[0-9]*|wpi[0-9]*) - ;; *) rtsol_interfaces="${rtsol_interfaces} ${i}" ;; Modified: stable/8/etc/rc.d/wpa_supplicant ============================================================================== --- stable/8/etc/rc.d/wpa_supplicant Wed Aug 26 21:05:17 2009 (r196565) +++ stable/8/etc/rc.d/wpa_supplicant Wed Aug 26 21:08:41 2009 (r196566) @@ -18,18 +18,6 @@ if [ -z "$ifn" ]; then return 1 fi -is_wired_interface() -{ - media=`ifconfig $1 2>/dev/null | while read line; do - case "$line" in - *media:?Ethernet*) - echo Ethernet - ;; - esac - done` - test "$media" = "Ethernet" -} - is_ndis_interface() { case `sysctl -n net.wlan.${1#wlan}.%parent 2>/dev/null` in From owner-svn-src-stable-8@FreeBSD.ORG Wed Aug 26 22:32:15 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09916106568C; Wed, 26 Aug 2009 22:32:15 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D05AC8FC22; Wed, 26 Aug 2009 22:32:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7QMWEei076782; Wed, 26 Aug 2009 22:32:14 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7QMWEEI076780; Wed, 26 Aug 2009 22:32:14 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908262232.n7QMWEEI076780@svn.freebsd.org> From: Doug Barton Date: Wed, 26 Aug 2009 22:32:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196571 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris conf contrib/dev/acpica contrib/pf dev/xen/xenpci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 22:32:15 -0000 Author: dougb Date: Wed Aug 26 22:32:14 2009 New Revision: 196571 URL: http://svn.freebsd.org/changeset/base/196571 Log: MFC r196435: The svnversion string is only relevant when newvers.sh is called during the kernel build process, the other places that call the script do not make use of that information. So restrict execution of the svnversion-related code to the kernel build context. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/conf/newvers.sh stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/conf/newvers.sh ============================================================================== --- stable/8/sys/conf/newvers.sh Wed Aug 26 21:42:16 2009 (r196570) +++ stable/8/sys/conf/newvers.sh Wed Aug 26 22:32:14 2009 (r196571) @@ -87,29 +87,25 @@ touch version v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` -for dir in /bin /usr/bin /usr/local/bin; do - if [ -x "${dir}/svnversion" ]; then - svnversion=${dir}/svnversion - SRCDIR=${d##*obj} - if [ -n "$MACHINE" ]; then - SRCDIR=${SRCDIR##/$MACHINE} +case "$d" in +*/sys/*) + for dir in /bin /usr/bin /usr/local/bin; do + if [ -x "${dir}/svnversion" ]; then + svnversion=${dir}/svnversion + SRCDIR=${d##*obj} + if [ -n "$MACHINE" ]; then + SRCDIR=${SRCDIR##/$MACHINE} + fi + SRCDIR=${SRCDIR%%/sys/*} + break fi - SRCDIR=${SRCDIR%%/sys/*} - break - fi -done + done -if [ -n "$svnversion" -a -d "${SRCDIR}/.svn" ] ; then - # If we are called from the kernel build, limit - # the scope of svnversion to sys/ . - if [ -e "${SRCDIR}/sys/conf/newvers.sh" ] ; then - svn=" r`cd $SRCDIR/sys && $svnversion`" - else - svn=" r`cd $SRCDIR && $svnversion`" + if [ -n "$svnversion" -a -d "${SRCDIR}/sys/.svn" ] ; then + svn=" r`cd ${SRCDIR}/sys && $svnversion`" fi -else - svn="" -fi + ;; +esac cat << EOF > vers.c $COPYRIGHT From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 07:05:46 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6945106568C; Thu, 27 Aug 2009 07:05:46 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A488F8FC21; Thu, 27 Aug 2009 07:05:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7R75kwm087543; Thu, 27 Aug 2009 07:05:46 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7R75kd9087542; Thu, 27 Aug 2009 07:05:46 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <200908270705.n7R75kd9087542@svn.freebsd.org> From: Brian Somers Date: Thu, 27 Aug 2009 07:05:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196575 - stable/8/usr.sbin/ppp X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 07:05:46 -0000 Author: brian Date: Thu Aug 27 07:05:46 2009 New Revision: 196575 URL: http://svn.freebsd.org/changeset/base/196575 Log: MFC: When realloc()ing device memory for transfer to another ppp process, don't continue to use the realloc()d pointer - it might have changed! Remove some stray diagnostics while I'm here. Approved by: re (kib) Modified: stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/ppp/ether.c stable/8/usr.sbin/ppp/netgraph.c stable/8/usr.sbin/ppp/tty.c Modified: stable/8/usr.sbin/ppp/ether.c ============================================================================== --- stable/8/usr.sbin/ppp/ether.c Thu Aug 27 00:45:00 2009 (r196574) +++ stable/8/usr.sbin/ppp/ether.c Thu Aug 27 07:05:46 2009 (r196575) @@ -193,17 +193,18 @@ static void ether_device2iov(struct device *d, struct iovec *iov, int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { - struct etherdevice *dev = device2ether(d); + struct etherdevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2ether(d); if (dev->cs >= 0) { *auxfd = dev->cs; (*nauxfd)++; Modified: stable/8/usr.sbin/ppp/netgraph.c ============================================================================== --- stable/8/usr.sbin/ppp/netgraph.c Thu Aug 27 00:45:00 2009 (r196574) +++ stable/8/usr.sbin/ppp/netgraph.c Thu Aug 27 07:05:46 2009 (r196575) @@ -235,7 +235,6 @@ ng_Read(struct physical *p, void *v, siz { char hook[NG_HOOKSIZ]; -log_Printf(LogDEBUG, "ng_Read\n"); switch (p->dl->state) { case DATALINK_DIAL: case DATALINK_LOGIN: @@ -282,17 +281,18 @@ static void ng_device2iov(struct device *d, struct iovec *iov, int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { - struct ngdevice *dev = device2ng(d); + struct ngdevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2ng(d); *auxfd = dev->cs; (*nauxfd)++; } Modified: stable/8/usr.sbin/ppp/tty.c ============================================================================== --- stable/8/usr.sbin/ppp/tty.c Thu Aug 27 00:45:00 2009 (r196574) +++ stable/8/usr.sbin/ppp/tty.c Thu Aug 27 07:05:46 2009 (r196575) @@ -384,7 +384,6 @@ UnloadLineDiscipline(struct physical *p) struct ttydevice *dev = device2tty(p->handler); if (isngtty(dev)) { -log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed); if (!physical_SetSpeed(p, dev->real.speed)) log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed); dev->real.speed = 0; @@ -582,17 +581,19 @@ tty_device2iov(struct device *d, struct #endif ) { - struct ttydevice *dev = device2tty(d); + struct ttydevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2tty(d); + #ifndef NONETGRAPH if (dev->cs >= 0) { *auxfd = dev->cs; From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 07:07:39 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35E73106568E; Thu, 27 Aug 2009 07:07:39 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 22FA28FC2D; Thu, 27 Aug 2009 07:07:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7R77dL6087627; Thu, 27 Aug 2009 07:07:39 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7R77drZ087622; Thu, 27 Aug 2009 07:07:39 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <200908270707.n7R77drZ087622@svn.freebsd.org> From: Brian Somers Date: Thu, 27 Aug 2009 07:07:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196576 - stable/8/usr.sbin/ppp X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 07:07:39 -0000 Author: brian Date: Thu Aug 27 07:07:38 2009 New Revision: 196576 URL: http://svn.freebsd.org/changeset/base/196576 Log: MFC: When ``ppp -direct'' is invoked by a program that uses pipe(2) to create stdin and stdout, don't blindly try to use stdin as a bi-directional channel. Instead, detect the pipe and set up a special exec handler that indirects write() calls through stdout. This fixes the problem where ``set device "!ssh -e none host ppp -direct label"'' no longer works with an openssh-5.2 server side as that version of openssh ignores the USE_PIPES config setting and *always* uses pipes (rather than socketpair) for stdin/stdout channels. Approved by: re (kib) Modified: stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/ppp/exec.c stable/8/usr.sbin/ppp/exec.h stable/8/usr.sbin/ppp/main.c stable/8/usr.sbin/ppp/physical.c Modified: stable/8/usr.sbin/ppp/exec.c ============================================================================== --- stable/8/usr.sbin/ppp/exec.c Thu Aug 27 07:05:46 2009 (r196575) +++ stable/8/usr.sbin/ppp/exec.c Thu Aug 27 07:07:38 2009 (r196576) @@ -35,7 +35,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -63,24 +65,106 @@ #include "cbcp.h" #include "datalink.h" #include "id.h" +#include "main.h" #include "exec.h" -static struct device execdevice = { + +struct execdevice { + struct device dev; /* What struct physical knows about */ + int fd_out; /* output descriptor */ +}; + +#define device2exec(d) ((d)->type == EXEC_DEVICE ? (struct execdevice *)d : NULL) + +unsigned +exec_DeviceSize(void) +{ + return sizeof(struct execdevice); +} + +static void +exec_Free(struct physical *p) +{ + struct execdevice *dev = device2exec(p->handler); + + if (dev->fd_out != -1) + close(dev->fd_out); + free(dev); +} + +static void +exec_device2iov(struct device *d, struct iovec *iov, int *niov, + int maxiov __unused, int *auxfd, int *nauxfd) +{ + struct execdevice *dev; + int sz = physical_MaxDeviceSize(); + + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { + log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); + AbortProgram(EX_OSERR); + } + iov[*niov].iov_len = sz; + (*niov)++; + + dev = device2exec(d); + if (dev->fd_out >= 0) { + *auxfd = dev->fd_out; + (*nauxfd)++; + } +} + +static int +exec_RemoveFromSet(struct physical *p, fd_set *r, fd_set *w, fd_set *e) +{ + struct execdevice *dev = device2exec(p->handler); + int sets; + + p->handler->removefromset = NULL; + sets = physical_RemoveFromSet(p, r, w, e); + p->handler->removefromset = exec_RemoveFromSet; + + if (dev->fd_out >= 0) { + if (w && FD_ISSET(dev->fd_out, w)) { + FD_CLR(dev->fd_out, w); + log_Printf(LogTIMER, "%s: fdunset(w) %d\n", p->link.name, dev->fd_out); + sets++; + } + if (e && FD_ISSET(dev->fd_out, e)) { + FD_CLR(dev->fd_out, e); + log_Printf(LogTIMER, "%s: fdunset(e) %d\n", p->link.name, dev->fd_out); + sets++; + } + } + + return sets; +} + +static ssize_t +exec_Write(struct physical *p, const void *v, size_t n) +{ + struct execdevice *dev = device2exec(p->handler); + int fd = dev->fd_out == -1 ? p->fd : dev->fd_out; + + return write(fd, v, n); +} + +static struct device baseexecdevice = { EXEC_DEVICE, "exec", 0, { CD_NOTREQUIRED, 0 }, NULL, + exec_RemoveFromSet, NULL, NULL, NULL, NULL, NULL, + exec_Free, NULL, - NULL, - NULL, - NULL, - NULL, + exec_Write, + exec_device2iov, NULL, NULL, NULL @@ -88,146 +172,238 @@ static struct device execdevice = { struct device * exec_iov2device(int type, struct physical *p, struct iovec *iov, - int *niov, int maxiov __unused, int *auxfd __unused, - int *nauxfd __unused) + int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { if (type == EXEC_DEVICE) { - free(iov[(*niov)++].iov_base); - physical_SetupStack(p, execdevice.name, PHYSICAL_NOFORCE); - return &execdevice; + struct execdevice *dev = (struct execdevice *)iov[(*niov)++].iov_base; + + dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ + if (dev == NULL) { + log_Printf(LogALERT, "Failed to allocate memory: %d\n", + (int)(sizeof *dev)); + AbortProgram(EX_OSERR); + } + + if (*nauxfd) { + dev->fd_out = *auxfd; + (*nauxfd)--; + } else + dev->fd_out = -1; + + /* Refresh function pointers etc */ + memcpy(&dev->dev, &baseexecdevice, sizeof dev->dev); + + physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); + return &dev->dev; } return NULL; } +static int +exec_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n) +{ + struct physical *p = descriptor2physical(d); + struct execdevice *dev = device2exec(p->handler); + int result = 0; + + if (w && dev->fd_out >= 0) { + FD_SET(dev->fd_out, w); + log_Printf(LogTIMER, "%s: fdset(w) %d\n", p->link.name, dev->fd_out); + result++; + w = NULL; + } + + if (e && dev->fd_out >= 0) { + FD_SET(dev->fd_out, e); + log_Printf(LogTIMER, "%s: fdset(e) %d\n", p->link.name, dev->fd_out); + result++; + } + + if (result && *n <= dev->fd_out) + *n = dev->fd_out + 1; + + return result + physical_doUpdateSet(d, r, w, e, n, 0); +} + +static int +exec_IsSet(struct fdescriptor *d, const fd_set *fdset) +{ + struct physical *p = descriptor2physical(d); + struct execdevice *dev = device2exec(p->handler); + int result = dev->fd_out >= 0 && FD_ISSET(dev->fd_out, fdset); + result += physical_IsSet(d, fdset); + + return result; +} + struct device * exec_Create(struct physical *p) { - if (p->fd < 0 && *p->name.full == '!') { - int fids[2], type; - - p->fd--; /* We own the device but maybe can't use it - change fd */ - type = physical_IsSync(p) ? SOCK_DGRAM : SOCK_STREAM; + struct execdevice *dev; - if (socketpair(AF_UNIX, type, PF_UNSPEC, fids) < 0) - log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n", - strerror(errno)); - else { - static int child_status; /* This variable is abused ! */ - int stat, argc, i, ret, wret, pidpipe[2]; - pid_t pid, realpid; - char *argv[MAXARGS]; - - stat = fcntl(fids[0], F_GETFL, 0); - if (stat > 0) { - stat |= O_NONBLOCK; - fcntl(fids[0], F_SETFL, stat); + dev = NULL; + if (p->fd < 0) { + if (*p->name.full == '!') { + int fids[2], type; + + if ((dev = malloc(sizeof *dev)) == NULL) { + log_Printf(LogWARN, "%s: Cannot allocate an exec device: %s\n", + p->link.name, strerror(errno)); + return NULL; } - realpid = getpid(); - if (pipe(pidpipe) == -1) { - log_Printf(LogPHASE, "Unable to pipe for line exec: %s\n", + dev->fd_out = -1; + + p->fd--; /* We own the device but maybe can't use it - change fd */ + type = physical_IsSync(p) ? SOCK_DGRAM : SOCK_STREAM; + + if (socketpair(AF_UNIX, type, PF_UNSPEC, fids) < 0) { + log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n", strerror(errno)); - close(fids[1]); - } else switch ((pid = fork())) { - case -1: - log_Printf(LogPHASE, "Unable to fork for line exec: %s\n", + free(dev); + dev = NULL; + } else { + static int child_status; /* This variable is abused ! */ + int stat, argc, i, ret, wret, pidpipe[2]; + pid_t pid, realpid; + char *argv[MAXARGS]; + + stat = fcntl(fids[0], F_GETFL, 0); + if (stat > 0) { + stat |= O_NONBLOCK; + fcntl(fids[0], F_SETFL, stat); + } + realpid = getpid(); + if (pipe(pidpipe) == -1) { + log_Printf(LogPHASE, "Unable to pipe for line exec: %s\n", strerror(errno)); - close(pidpipe[0]); - close(pidpipe[1]); close(fids[1]); - break; - - case 0: - close(pidpipe[0]); close(fids[0]); - timer_TermService(); -#ifndef NOSUID - setuid(ID0realuid()); -#endif - - child_status = 0; - switch ((pid = vfork())) { - case 0: - close(pidpipe[1]); - break; - - case -1: - ret = errno; - log_Printf(LogPHASE, "Unable to vfork to drop parent: %s\n", - strerror(errno)); - close(pidpipe[1]); - _exit(ret); - - default: - write(pidpipe[1], &pid, sizeof pid); - close(pidpipe[1]); - _exit(child_status); /* The error from exec() ! */ - } - - log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); - - if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), - PARSE_REDUCE|PARSE_NOHASH)) < 0) { - log_Printf(LogWARN, "Syntax error in exec command\n"); - _exit(ESRCH); - } - - command_Expand(argv, argc, (char const *const *)argv, - p->dl->bundle, 0, realpid); - - dup2(fids[1], STDIN_FILENO); - dup2(fids[1], STDOUT_FILENO); - dup2(fids[1], STDERR_FILENO); - for (i = getdtablesize(); i > STDERR_FILENO; i--) - fcntl(i, F_SETFD, 1); - - execvp(*argv, argv); - child_status = errno; /* Only works for vfork() */ - printf("execvp failed: %s: %s\r\n", *argv, strerror(child_status)); - _exit(child_status); - break; - - default: - close(pidpipe[1]); - close(fids[1]); - if (read(pidpipe[0], &p->session_owner, sizeof p->session_owner) != - sizeof p->session_owner) - p->session_owner = (pid_t)-1; - close(pidpipe[0]); - while ((wret = waitpid(pid, &stat, 0)) == -1 && errno == EINTR) - ; - if (wret == -1) { - log_Printf(LogWARN, "Waiting for child process: %s\n", + free(dev); + dev = NULL; + } else switch ((pid = fork())) { + case -1: + log_Printf(LogPHASE, "Unable to fork for line exec: %s\n", strerror(errno)); + close(pidpipe[0]); + close(pidpipe[1]); + close(fids[1]); close(fids[0]); - p->session_owner = (pid_t)-1; - break; - } else if (WIFSIGNALED(stat)) { - log_Printf(LogWARN, "Child process received sig %d !\n", - WTERMSIG(stat)); - close(fids[0]); - p->session_owner = (pid_t)-1; break; - } else if (WIFSTOPPED(stat)) { - log_Printf(LogWARN, "Child process received stop sig %d !\n", - WSTOPSIG(stat)); - /* I guess that's ok.... */ - } else if ((ret = WEXITSTATUS(stat))) { - log_Printf(LogWARN, "Cannot exec \"%s\": %s\n", p->name.base, - strerror(ret)); + + case 0: + close(pidpipe[0]); close(fids[0]); - p->session_owner = (pid_t)-1; + timer_TermService(); + #ifndef NOSUID + setuid(ID0realuid()); + #endif + + child_status = 0; + switch ((pid = vfork())) { + case 0: + close(pidpipe[1]); + break; + + case -1: + ret = errno; + log_Printf(LogPHASE, "Unable to vfork to drop parent: %s\n", + strerror(errno)); + close(pidpipe[1]); + _exit(ret); + + default: + write(pidpipe[1], &pid, sizeof pid); + close(pidpipe[1]); + _exit(child_status); /* The error from exec() ! */ + } + + log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); + + if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), + PARSE_REDUCE|PARSE_NOHASH)) < 0) { + log_Printf(LogWARN, "Syntax error in exec command\n"); + _exit(ESRCH); + } + + command_Expand(argv, argc, (char const *const *)argv, + p->dl->bundle, 0, realpid); + + dup2(fids[1], STDIN_FILENO); + dup2(fids[1], STDOUT_FILENO); + dup2(fids[1], STDERR_FILENO); + for (i = getdtablesize(); i > STDERR_FILENO; i--) + fcntl(i, F_SETFD, 1); + + execvp(*argv, argv); + child_status = errno; /* Only works for vfork() */ + printf("execvp failed: %s: %s\r\n", *argv, strerror(child_status)); + _exit(child_status); break; - } - p->fd = fids[0]; - log_Printf(LogDEBUG, "Using descriptor %d for child\n", p->fd); - physical_SetupStack(p, execdevice.name, PHYSICAL_NOFORCE); - if (p->cfg.cd.necessity != CD_DEFAULT) - log_Printf(LogWARN, "Carrier settings ignored\n"); - return &execdevice; + + default: + close(pidpipe[1]); + close(fids[1]); + if (read(pidpipe[0], &p->session_owner, sizeof p->session_owner) != + sizeof p->session_owner) + p->session_owner = (pid_t)-1; + close(pidpipe[0]); + while ((wret = waitpid(pid, &stat, 0)) == -1 && errno == EINTR) + ; + if (wret == -1) { + log_Printf(LogWARN, "Waiting for child process: %s\n", + strerror(errno)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } else if (WIFSIGNALED(stat)) { + log_Printf(LogWARN, "Child process received sig %d !\n", + WTERMSIG(stat)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } else if (WIFSTOPPED(stat)) { + log_Printf(LogWARN, "Child process received stop sig %d !\n", + WSTOPSIG(stat)); + /* I guess that's ok.... */ + } else if ((ret = WEXITSTATUS(stat))) { + log_Printf(LogWARN, "Cannot exec \"%s\": %s\n", p->name.base, + strerror(ret)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } + p->fd = fids[0]; + log_Printf(LogDEBUG, "Using descriptor %d for child\n", p->fd); + } } - close(fids[0]); } + } else { + struct stat st; + + if (fstat(p->fd, &st) != -1 && (st.st_mode & S_IFIFO)) { + if ((dev = malloc(sizeof *dev)) == NULL) + log_Printf(LogWARN, "%s: Cannot allocate an exec device: %s\n", + p->link.name, strerror(errno)); + else if (p->fd == STDIN_FILENO) { + log_Printf(LogPHASE, "%s: Using stdin/stdout to communicate with " + "parent (pipe mode)\n", p->link.name); + dev->fd_out = dup(STDOUT_FILENO); + + /* Hook things up so that we monitor dev->fd_out */ + p->desc.UpdateSet = exec_UpdateSet; + p->desc.IsSet = exec_IsSet; + } else + dev->fd_out = -1; + } + } + + if (dev) { + memcpy(&dev->dev, &baseexecdevice, sizeof dev->dev); + physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); + if (p->cfg.cd.necessity != CD_DEFAULT) + log_Printf(LogWARN, "Carrier settings ignored\n"); + return &dev->dev; } return NULL; Modified: stable/8/usr.sbin/ppp/exec.h ============================================================================== --- stable/8/usr.sbin/ppp/exec.h Thu Aug 27 07:05:46 2009 (r196575) +++ stable/8/usr.sbin/ppp/exec.h Thu Aug 27 07:07:38 2009 (r196576) @@ -32,4 +32,4 @@ struct device; extern struct device *exec_Create(struct physical *); extern struct device *exec_iov2device(int, struct physical *, struct iovec *, int *, int, int *, int *); -#define exec_DeviceSize physical_DeviceSize +extern unsigned exec_DeviceSize(void); Modified: stable/8/usr.sbin/ppp/main.c ============================================================================== --- stable/8/usr.sbin/ppp/main.c Thu Aug 27 07:05:46 2009 (r196575) +++ stable/8/usr.sbin/ppp/main.c Thu Aug 27 07:07:38 2009 (r196576) @@ -509,9 +509,11 @@ main(int argc, char **argv) if (!sw.fg) setsid(); } else { - /* -direct - STDIN_FILENO gets used by physical_Open */ + /* + * -direct - STDIN_FILENO gets used by physical_Open. STDOUT_FILENO + * *may* get used in exec/pipe mode. + */ prompt_TtyInit(NULL); - close(STDOUT_FILENO); close(STDERR_FILENO); } } else { Modified: stable/8/usr.sbin/ppp/physical.c ============================================================================== --- stable/8/usr.sbin/ppp/physical.c Thu Aug 27 07:05:46 2009 (r196575) +++ stable/8/usr.sbin/ppp/physical.c Thu Aug 27 07:07:38 2009 (r196576) @@ -1017,6 +1017,7 @@ physical_Open(struct physical *p) p->fd = STDIN_FILENO; for (h = 0; h < NDEVICES && p->handler == NULL && p->fd >= 0; h++) p->handler = (*devices[h].create)(p); + close(STDOUT_FILENO); if (p->fd >= 0) { if (p->handler == NULL) { physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE); From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 16:34:04 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB74F106568C; Thu, 27 Aug 2009 16:34:04 +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 D820A8FC3A; Thu, 27 Aug 2009 16:34:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7RGY4Rn001532; Thu, 27 Aug 2009 16:34:04 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7RGY4FV001529; Thu, 27 Aug 2009 16:34:04 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908271634.n7RGY4FV001529@svn.freebsd.org> From: John Baldwin Date: Thu, 27 Aug 2009 16:34:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196593 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/acpica dev/xen/xenpci isa X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 16:34:05 -0000 Author: jhb Date: Thu Aug 27 16:34:04 2009 New Revision: 196593 URL: http://svn.freebsd.org/changeset/base/196593 Log: MFC 196520: Tweak the way that the ACPI and ISA bus drivers match hint devices to BIOS-enumerated devices: - Assume a device is a match if the memory and I/O ports match even if the IRQ or DRQ is wrong or missing. Some BIOSes don't include an IRQ for the atrtc device for example. - Add a hack to better match floppy controller devices. Many BIOSes do not include the starting port of the floppy controller listed in the hints (0x3f0) in the resources for the device. So far, however, all the BIOS variations encountered do include the 'port + 2' resource (0x3f2), so adjust the matching for "fdc" devices to look for 'port + 2'. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/acpica/acpi.c stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/isa/isahint.c Modified: stable/8/sys/dev/acpica/acpi.c ============================================================================== --- stable/8/sys/dev/acpica/acpi.c Thu Aug 27 16:15:51 2009 (r196592) +++ stable/8/sys/dev/acpica/acpi.c Thu Aug 27 16:34:04 2009 (r196593) @@ -1014,14 +1014,27 @@ acpi_hint_device_unit(device_t acdev, de continue; /* - * Check for matching resources. We must have at least one, - * and all resources specified have to match. + * Check for matching resources. We must have at least one match. + * Since I/O and memory resources cannot be shared, if we get a + * match on either of those, ignore any mismatches in IRQs or DRQs. * * XXX: We may want to revisit this to be more lenient and wire * as long as it gets one match. */ matches = 0; if (resource_long_value(name, unit, "port", &value) == 0) { + /* + * Floppy drive controllers are notorious for having a + * wide variety of resources not all of which include the + * first port that is specified by the hint (typically + * 0x3f0) (see the comment above fdc_isa_alloc_resources() + * in fdc_isa.c). However, they do all seem to include + * port + 2 (e.g. 0x3f2) so for a floppy device, look for + * 'value + 2' in the port resources instead of the hint + * value. + */ + if (strcmp(name, "fdc") == 0) + value += 2; if (acpi_match_resource_hint(child, SYS_RES_IOPORT, value)) matches++; else @@ -1033,6 +1046,8 @@ acpi_hint_device_unit(device_t acdev, de else continue; } + if (matches > 0) + goto matched; if (resource_long_value(name, unit, "irq", &value) == 0) { if (acpi_match_resource_hint(child, SYS_RES_IRQ, value)) matches++; @@ -1046,6 +1061,7 @@ acpi_hint_device_unit(device_t acdev, de continue; } + matched: if (matches > 0) { /* We have a winner! */ *unitp = unit; Modified: stable/8/sys/isa/isahint.c ============================================================================== --- stable/8/sys/isa/isahint.c Thu Aug 27 16:15:51 2009 (r196592) +++ stable/8/sys/isa/isahint.c Thu Aug 27 16:34:04 2009 (r196593) @@ -118,14 +118,30 @@ isa_hint_device_unit(device_t bus, devic continue; /* - * Check for matching resources. We must have at least one, - * and all resources specified have to match. + * Check for matching resources. We must have at + * least one match. Since I/O and memory resources + * cannot be shared, if we get a match on either of + * those, ignore any mismatches in IRQs or DRQs. * - * XXX: We may want to revisit this to be more lenient and wire - * as long as it gets one match. + * XXX: We may want to revisit this to be more lenient + * and wire as long as it gets one match. */ matches = 0; if (resource_long_value(name, unit, "port", &value) == 0) { + /* + * Floppy drive controllers are notorious for + * having a wide variety of resources not all + * of which include the first port that is + * specified by the hint (typically 0x3f0) + * (see the comment above + * fdc_isa_alloc_resources() in fdc_isa.c). + * However, they do all seem to include port + + * 2 (e.g. 0x3f2) so for a floppy device, look + * for 'value + 2' in the port resources + * instead of the hint value. + */ + if (strcmp(name, "fdc") == 0) + value += 2; if (isa_match_resource_hint(child, SYS_RES_IOPORT, value)) matches++; @@ -139,6 +155,8 @@ isa_hint_device_unit(device_t bus, devic else continue; } + if (matches > 0) + goto matched; if (resource_long_value(name, unit, "irq", &value) == 0) { if (isa_match_resource_hint(child, SYS_RES_IRQ, value)) matches++; @@ -152,6 +170,7 @@ isa_hint_device_unit(device_t bus, devic continue; } + matched: if (matches > 0) { /* We have a winner! */ *unitp = unit; From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 17:16:24 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51D87106568D; Thu, 27 Aug 2009 17:16:24 +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 36E798FC4D; Thu, 27 Aug 2009 17:16:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7RHGOS7002503; Thu, 27 Aug 2009 17:16:24 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7RHGOXm002500; Thu, 27 Aug 2009 17:16:24 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908271716.n7RHGOXm002500@svn.freebsd.org> From: John Baldwin Date: Thu, 27 Aug 2009 17:16:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196594 - in stable/8/release: . doc scripts X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 17:16:24 -0000 Author: jhb Date: Thu Aug 27 17:16:23 2009 New Revision: 196594 URL: http://svn.freebsd.org/changeset/base/196594 Log: MFC 196521: Fix a few issues with the lib32 dist so that it includes ldd32. - Use a better find invocation to purge empty directories from all the dist trees during a release build. The previous version did not purge directories whose contents were all empty directories. - Explicitly blacklist a few files from the lib32 dist instead of using a whitelist. A better longterm solution is to fix the few offenders to not install data files during a lib32 install. Approved by: re (kib) Modified: stable/8/release/ (props changed) stable/8/release/Makefile stable/8/release/doc/ (props changed) stable/8/release/scripts/lib32-make.sh Modified: stable/8/release/Makefile ============================================================================== --- stable/8/release/Makefile Thu Aug 27 16:34:04 2009 (r196593) +++ stable/8/release/Makefile Thu Aug 27 17:16:23 2009 (r196594) @@ -696,7 +696,7 @@ release.5: # Remove all the directories we don't need. -cd ${RD}/trees && \ (find ${OTHER_DISTS} -path '*/var/empty' | xargs chflags noschg; \ - find ${OTHER_DISTS} -depth -type d -empty -print | xargs rmdir) + find ${OTHER_DISTS} -depth -type d -empty -delete) touch ${.TARGET} # Modified: stable/8/release/scripts/lib32-make.sh ============================================================================== --- stable/8/release/scripts/lib32-make.sh Thu Aug 27 16:34:04 2009 (r196593) +++ stable/8/release/scripts/lib32-make.sh Thu Aug 27 17:16:23 2009 (r196594) @@ -5,4 +5,4 @@ # Clean the dust. cd ${RD}/trees/lib32 && \ - find . ! -path '*/libexec/*' ! -path '*/usr/lib32/*' -delete + find . '(' -path '*/usr/share/*' -or -path '*/usr/lib/*' ')' -delete From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 17:25:59 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28B1710656A4; Thu, 27 Aug 2009 17:25:59 +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 179DA8FC42; Thu, 27 Aug 2009 17:25:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7RHPwTA002889; Thu, 27 Aug 2009 17:25:58 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7RHPwdM002887; Thu, 27 Aug 2009 17:25:58 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908271725.n7RHPwdM002887@svn.freebsd.org> From: John Baldwin Date: Thu, 27 Aug 2009 17:25:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196597 - in stable/8/release: . doc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 17:25:59 -0000 Author: jhb Date: Thu Aug 27 17:25:58 2009 New Revision: 196597 URL: http://svn.freebsd.org/changeset/base/196597 Log: MFC 196522: Invoke the recently added mm-mtree.sh release script to store a pre-built mergemaster mtree database in the 'base' dist. Approved by: re (kib) Modified: stable/8/release/ (props changed) stable/8/release/Makefile stable/8/release/doc/ (props changed) Modified: stable/8/release/Makefile ============================================================================== --- stable/8/release/Makefile Thu Aug 27 17:24:05 2009 (r196596) +++ stable/8/release/Makefile Thu Aug 27 17:25:58 2009 (r196597) @@ -646,6 +646,7 @@ release.2: cd ${.CURDIR}/.. && ${CROSSMAKE} distrib-dirs DESTDIR=${RD}/trees/base cd ${.CURDIR}/.. && ${CROSSMAKE} ${WORLD_FLAGS} distributeworld \ DISTDIR=${RD}/trees + sh ${.CURDIR}/scripts/mm-mtree.sh -F "${CROSSENV}" -D "${RD}/trees/base" touch ${.TARGET} # Make and install the generic kernel(s). From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 17:34:14 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05C9D106568D; Thu, 27 Aug 2009 17:34:14 +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 E4FAA8FC3F; Thu, 27 Aug 2009 17:34:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7RHYDoO003228; Thu, 27 Aug 2009 17:34:13 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7RHYDRe003218; Thu, 27 Aug 2009 17:34:13 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200908271734.n7RHYDRe003218@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 27 Aug 2009 17:34:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196601 - in stable/8/sys: . amd64/amd64 amd64/include/xen amd64/linux32 cddl/contrib/opensolaris compat/ia32 contrib/dev/acpica contrib/pf dev/xen/xenpci i386/i386 i386/linux kern sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 17:34:14 -0000 Author: bz Date: Thu Aug 27 17:34:13 2009 New Revision: 196601 URL: http://svn.freebsd.org/changeset/base/196601 Log: MFC r196512: Fix handling of .note.ABI-tag section for GNU systems [1]. Handle GNU/Linux according to LSB Core Specification 4.0, Chapter 11. Object Format, 11.8. ABI note tag. Also check the first word of desc, not only name, according to glibc abi-tags specification to distinguish between Linux and kFreeBSD. Add explicit handling for Debian GNU/kFreeBSD, which runs on our kernels as well [2]. In {amd64,i386}/trap.c, when checking osrel of the current process, also check the ABI to not change the signal behaviour for Linux binary processes, now that we save an osrel version for all three from the lists above in struct proc [2]. These changes make it possible to run FreeBSD, Debian GNU/kFreeBSD and Linux binaries on the same machine again for at least i386 and amd64, and no longer break kFreeBSD which was detected as GNU(/Linux). PR: kern/135468 Submitted by: dchagin [1] (initial patch) Suggested by: kib [2] Tested by: Petr Salinger (Petr.Salinger seznam.cz) for kFreeBSD Reviewed by: kib Approved by: re (kensmith) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/amd64/elf_machdep.c stable/8/sys/amd64/amd64/trap.c stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/amd64/linux32/linux32_sysvec.c stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/compat/ia32/ia32_sysvec.c stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/i386/i386/elf_machdep.c stable/8/sys/i386/i386/trap.c stable/8/sys/i386/linux/linux_sysvec.c stable/8/sys/kern/imgact_elf.c stable/8/sys/sys/imgact_elf.h Modified: stable/8/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/elf_machdep.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/amd64/amd64/elf_machdep.c Thu Aug 27 17:34:13 2009 (r196601) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -108,6 +109,22 @@ SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_AN (sysinit_cfunc_t) elf64_insert_brand_entry, &freebsd_brand_oinfo); +static Elf64_Brandinfo kfreebsd_brand_info = { + .brand = ELFOSABI_FREEBSD, + .machine = EM_X86_64, + .compat_3_brand = "FreeBSD", + .emul_path = NULL, + .interp_path = "/lib/ld-kfreebsd-x86-64.so.1", + .sysvec = &elf64_freebsd_sysvec, + .interp_newpath = NULL, + .brand_note = &elf64_kfreebsd_brandnote, + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE +}; + +SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY, + (sysinit_cfunc_t) elf64_insert_brand_entry, + &kfreebsd_brand_info); + void elf64_dump_thread(struct thread *td __unused, void *dst __unused, Modified: stable/8/sys/amd64/amd64/trap.c ============================================================================== --- stable/8/sys/amd64/amd64/trap.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/amd64/amd64/trap.c Thu Aug 27 17:34:13 2009 (r196601) @@ -409,7 +409,9 @@ trap(struct trapframe *frame) * This check also covers the images * without the ABI-tag ELF note. */ - if (p->p_osrel >= 700004) { + if (SV_CURPROC_ABI() == + SV_ABI_FREEBSD && + p->p_osrel >= 700004) { i = SIGSEGV; ucode = SEGV_ACCERR; } else { Modified: stable/8/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- stable/8/sys/amd64/linux32/linux32_sysvec.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/amd64/linux32/linux32_sysvec.c Thu Aug 27 17:34:13 2009 (r196601) @@ -127,6 +127,7 @@ static void linux_sendsig(sig_t catc static void exec_linux_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings); static void linux32_fixlimit(struct rlimit *rl, int which); +static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel); static eventhandler_tag linux_exit_tag; static eventhandler_tag linux_schedtail_tag; @@ -1066,14 +1067,38 @@ struct sysentvec elf_linux_sysvec = { .sv_flags = SV_ABI_LINUX | SV_ILP32 | SV_IA32 }; -static char GNULINUX_ABI_VENDOR[] = "GNU"; +static char GNU_ABI_VENDOR[] = "GNU"; +static int GNULINUX_ABI_DESC = 0; + +static boolean_t +linux32_trans_osrel(const Elf_Note *note, int32_t *osrel) +{ + const Elf32_Word *desc; + uintptr_t p; + + p = (uintptr_t)(note + 1); + p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); + + desc = (const Elf32_Word *)p; + if (desc[0] != GNULINUX_ABI_DESC) + return (FALSE); + + /* + * For linux we encode osrel as follows (see linux_mib.c): + * VVVMMMIII (version, major, minor), see linux_mib.c. + */ + *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3]; + + return (TRUE); +} static Elf_Brandnote linux32_brandnote = { - .hdr.n_namesz = sizeof(GNULINUX_ABI_VENDOR), - .hdr.n_descsz = 16, + .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), + .hdr.n_descsz = 16, /* XXX at least 16 */ .hdr.n_type = 1, - .vendor = GNULINUX_ABI_VENDOR, - .flags = 0 + .vendor = GNU_ABI_VENDOR, + .flags = BN_TRANSLATE_OSREL, + .trans_osrel = linux32_trans_osrel }; static Elf32_Brandinfo linux_brand = { Modified: stable/8/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/8/sys/compat/ia32/ia32_sysvec.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/compat/ia32/ia32_sysvec.c Thu Aug 27 17:34:13 2009 (r196601) @@ -172,6 +172,21 @@ SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY (sysinit_cfunc_t) elf32_insert_brand_entry, &ia32_brand_oinfo); +static Elf32_Brandinfo kia32_brand_info = { + .brand = ELFOSABI_FREEBSD, + .machine = EM_386, + .compat_3_brand = "FreeBSD", + .emul_path = NULL, + .interp_path = "/lib/ld.so.1", + .sysvec = &ia32_freebsd_sysvec, + .brand_note = &elf32_kfreebsd_brandnote, + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE +}; + +SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY, + (sysinit_cfunc_t) elf32_insert_brand_entry, + &kia32_brand_info); + void elf32_dump_thread(struct thread *td __unused, void *dst __unused, Modified: stable/8/sys/i386/i386/elf_machdep.c ============================================================================== --- stable/8/sys/i386/i386/elf_machdep.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/i386/i386/elf_machdep.c Thu Aug 27 17:34:13 2009 (r196601) @@ -108,6 +108,22 @@ SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_AN (sysinit_cfunc_t) elf32_insert_brand_entry, &freebsd_brand_oinfo); +static Elf32_Brandinfo kfreebsd_brand_info = { + .brand = ELFOSABI_FREEBSD, + .machine = EM_386, + .compat_3_brand = "FreeBSD", + .emul_path = NULL, + .interp_path = "/lib/ld.so.1", + .sysvec = &elf32_freebsd_sysvec, + .interp_newpath = NULL, + .brand_note = &elf32_kfreebsd_brandnote, + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE +}; + +SYSINIT(kelf32, SI_SUB_EXEC, SI_ORDER_ANY, + (sysinit_cfunc_t) elf32_insert_brand_entry, + &kfreebsd_brand_info); + void elf32_dump_thread(struct thread *td __unused, void *dst __unused, Modified: stable/8/sys/i386/i386/trap.c ============================================================================== --- stable/8/sys/i386/i386/trap.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/i386/i386/trap.c Thu Aug 27 17:34:13 2009 (r196601) @@ -423,7 +423,9 @@ trap(struct trapframe *frame) * This check also covers the images * without the ABI-tag ELF note. */ - if (p->p_osrel >= 700004) { + if (SV_CURPROC_ABI() == + SV_ABI_FREEBSD && + p->p_osrel >= 700004) { i = SIGSEGV; ucode = SEGV_ACCERR; } else { Modified: stable/8/sys/i386/linux/linux_sysvec.c ============================================================================== --- stable/8/sys/i386/linux/linux_sysvec.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/i386/linux/linux_sysvec.c Thu Aug 27 17:34:13 2009 (r196601) @@ -108,6 +108,7 @@ static void linux_sendsig(sig_t catc static void exec_linux_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings); static register_t *linux_copyout_strings(struct image_params *imgp); +static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static int linux_szplatform; const char *linux_platform; @@ -1027,14 +1028,38 @@ struct sysentvec elf_linux_sysvec = { .sv_flags = SV_ABI_LINUX | SV_IA32 | SV_ILP32 }; -static char GNULINUX_ABI_VENDOR[] = "GNU"; +static char GNU_ABI_VENDOR[] = "GNU"; +static int GNULINUX_ABI_DESC = 0; + +static boolean_t +linux_trans_osrel(const Elf_Note *note, int32_t *osrel) +{ + const Elf32_Word *desc; + uintptr_t p; + + p = (uintptr_t)(note + 1); + p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); + + desc = (const Elf32_Word *)p; + if (desc[0] != GNULINUX_ABI_DESC) + return (FALSE); + + /* + * For linux we encode osrel as follows (see linux_mib.c): + * VVVMMMIII (version, major, minor), see linux_mib.c. + */ + *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3]; + + return (TRUE); +} static Elf_Brandnote linux_brandnote = { - .hdr.n_namesz = sizeof(GNULINUX_ABI_VENDOR), - .hdr.n_descsz = 16, + .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), + .hdr.n_descsz = 16, /* XXX at least 16 */ .hdr.n_type = 1, - .vendor = GNULINUX_ABI_VENDOR, - .flags = 0 + .vendor = GNU_ABI_VENDOR, + .flags = BN_TRANSLATE_OSREL, + .trans_osrel = linux_trans_osrel }; static Elf32_Brandinfo linux_brand = { Modified: stable/8/sys/kern/imgact_elf.c ============================================================================== --- stable/8/sys/kern/imgact_elf.c Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/kern/imgact_elf.c Thu Aug 27 17:34:13 2009 (r196601) @@ -86,6 +86,9 @@ static int __elfN(load_section)(struct v vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, size_t pagesize); static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp); +static boolean_t __elfN(freebsd_trans_osrel)(const Elf_Note *note, + int32_t *osrel); +static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel); static boolean_t __elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote, int32_t *osrel); @@ -116,9 +119,56 @@ Elf_Brandnote __elfN(freebsd_brandnote) .hdr.n_descsz = sizeof(int32_t), .hdr.n_type = 1, .vendor = FREEBSD_ABI_VENDOR, - .flags = BN_CAN_FETCH_OSREL + .flags = BN_TRANSLATE_OSREL, + .trans_osrel = __elfN(freebsd_trans_osrel) }; +static boolean_t +__elfN(freebsd_trans_osrel)(const Elf_Note *note, int32_t *osrel) +{ + uintptr_t p; + + p = (uintptr_t)(note + 1); + p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); + *osrel = *(const int32_t *)(p); + + return (TRUE); +} + +static const char GNU_ABI_VENDOR[] = "GNU"; +static int GNU_KFREEBSD_ABI_DESC = 3; + +Elf_Brandnote __elfN(kfreebsd_brandnote) = { + .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), + .hdr.n_descsz = 16, /* XXX at least 16 */ + .hdr.n_type = 1, + .vendor = GNU_ABI_VENDOR, + .flags = BN_TRANSLATE_OSREL, + .trans_osrel = kfreebsd_trans_osrel +}; + +static boolean_t +kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel) +{ + const Elf32_Word *desc; + uintptr_t p; + + p = (uintptr_t)(note + 1); + p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); + + desc = (const Elf32_Word *)p; + if (desc[0] != GNU_KFREEBSD_ABI_DESC) + return (FALSE); + + /* + * Debian GNU/kFreeBSD embed the earliest compatible kernel version + * (__FreeBSD_version: Rxx) in the LSB way. + */ + *osrel = desc[1] * 100000 + desc[2] * 1000 + desc[3]; + + return (TRUE); +} + int __elfN(insert_brand_entry)(Elf_Brandinfo *entry) { @@ -1371,11 +1421,9 @@ __elfN(check_note)(struct image_params * * Fetch the osreldate for binary * from the ELF OSABI-note if necessary. */ - if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 && - osrel != NULL) - *osrel = *(const int32_t *) (note_name + - roundup2(checknote->hdr.n_namesz, - sizeof(Elf32_Addr))); + if ((checknote->flags & BN_TRANSLATE_OSREL) != 0 && + checknote->trans_osrel != NULL) + return (checknote->trans_osrel(note, osrel)); return (TRUE); nextnote: Modified: stable/8/sys/sys/imgact_elf.h ============================================================================== --- stable/8/sys/sys/imgact_elf.h Thu Aug 27 17:33:44 2009 (r196600) +++ stable/8/sys/sys/imgact_elf.h Thu Aug 27 17:34:13 2009 (r196601) @@ -58,7 +58,10 @@ typedef struct { Elf_Note hdr; const char * vendor; int flags; -#define BN_CAN_FETCH_OSREL 0x0001 + boolean_t (*trans_osrel)(const Elf_Note *, int32_t *); +#define BN_CAN_FETCH_OSREL 0x0001 /* Deprecated. */ +#define BN_TRANSLATE_OSREL 0x0002 /* Use trans_osrel fetch osrel after */ + /* checking ABI contraint if needed. */ } Elf_Brandnote; typedef struct { @@ -91,6 +94,7 @@ void __elfN(dump_thread)(struct thread * extern int __elfN(fallback_brand); extern Elf_Brandnote __elfN(freebsd_brandnote); +extern Elf_Brandnote __elfN(kfreebsd_brandnote); #endif /* _KERNEL */ #endif /* !_SYS_IMGACT_ELF_H_ */ From owner-svn-src-stable-8@FreeBSD.ORG Thu Aug 27 17:53:26 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AC2E106568D; Thu, 27 Aug 2009 17:53:26 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ED8988FC1C; Thu, 27 Aug 2009 17:53:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7RHrPRa003721; Thu, 27 Aug 2009 17:53:25 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7RHrPaK003719; Thu, 27 Aug 2009 17:53:25 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908271753.n7RHrPaK003719@svn.freebsd.org> From: Doug Barton Date: Thu, 27 Aug 2009 17:53:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196604 - stable/8/etc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2009 17:53:26 -0000 Author: dougb Date: Thu Aug 27 17:53:25 2009 New Revision: 196604 URL: http://svn.freebsd.org/changeset/base/196604 Log: MFC 196589: In the loop through the list of interfaces in network6_interface_setup() rtsol_interface gets reset to "yes" each time through the loop, but rtsol_available does not. If a user has lo0 first in their list of interfaces rtsol_available will get set to "no" the first time through the loop and subsequent interfaces will not get rtsol'ed when they should. Therefore change the conditional for the is_wired() test to _interface. Approved by: re (kib) Modified: stable/8/etc/ (props changed) stable/8/etc/network.subr Modified: stable/8/etc/network.subr ============================================================================== --- stable/8/etc/network.subr Thu Aug 27 17:42:37 2009 (r196603) +++ stable/8/etc/network.subr Thu Aug 27 17:53:25 2009 (r196604) @@ -872,8 +872,8 @@ network6_interface_setup() # Wireless NIC cards are virtualized through the wlan interface if ! is_wired_interface ${i}; then case "${i}" in - wlan*) rtsol_available=yes ;; - *) rtsol_available=no ;; + wlan*) rtsol_interface=yes ;; + *) rtsol_interface=no ;; esac fi From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 10:25:26 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B984106567D; Fri, 28 Aug 2009 10:25:26 +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 6FC8F8FC22; Fri, 28 Aug 2009 10:25:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SAPQgb022473; Fri, 28 Aug 2009 10:25:26 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SAPQXD022471; Fri, 28 Aug 2009 10:25:26 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200908281025.n7SAPQXD022471@svn.freebsd.org> From: Ed Schouten Date: Fri, 28 Aug 2009 10:25:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196614 - in stable/8/lib/libc: . stdio stdlib stdtime string X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 10:25:26 -0000 Author: ed Date: Fri Aug 28 10:25:26 2009 New Revision: 196614 URL: http://svn.freebsd.org/changeset/base/196614 Log: MFC r196508: Our implementation of granpt(3) could be valid in the future. When I wrote the pseudo-terminal driver for the MPSAFE TTY code, Robert Watson and I agreed the best way to implement this, would be to let posix_openpt() create a pseudo-terminal with proper permissions in place and let grantpt() and unlockpt() be no-ops. This isn't valid behaviour when looking at the spec. Because I thought it was an elegant solution, I filed a bug report at the Austin Group about this. In their last teleconference, they agreed on this subject. This means that future revisions of POSIX may allow grantpt() and unlockpt() to be no-ops if an open() on /dev/ptmx (if the implementation has such a device) and posix_openpt() already do the right thing. I'd rather put this in the manpage, because simply mentioning we don't comply to any standard makes it look worse than it is. Right now we don't, but at least we took care of it. Approved by: re (kib) Modified: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdio/asprintf.c (props changed) stable/8/lib/libc/stdlib/ptsname.3 stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/string/ffsll.c (props changed) stable/8/lib/libc/string/flsll.c (props changed) stable/8/lib/libc/string/wcpcpy.c (props changed) stable/8/lib/libc/string/wcpncpy.c (props changed) Modified: stable/8/lib/libc/stdlib/ptsname.3 ============================================================================== --- stable/8/lib/libc/stdlib/ptsname.3 Fri Aug 28 10:25:01 2009 (r196613) +++ stable/8/lib/libc/stdlib/ptsname.3 Fri Aug 28 10:25:26 2009 (r196614) @@ -134,14 +134,22 @@ The slave pseudo-terminal device could n The .Fn ptsname function conforms to -.St -p1003.1-2001 . +.St -p1003.1-2008 . .Pp This implementation of .Fn grantpt and .Fn unlockpt -does not comply with any standard, because these functions assume the -pseudo-terminal has the correct attributes upon creation. +does not conform to +.St -p1003.1-2008 , +because it depends on +.Xr posix_openpt 2 +to create the pseudo-terminal device with proper permissions in place. +It only validates whether +.Fa fildes +is a valid pseudo-terminal master device. +Future revisions of the specification will likely allow this behaviour, +as stated by the Austin Group. .Sh HISTORY The .Fn grantpt , @@ -150,15 +158,3 @@ and .Fn unlockpt functions appeared in .Fx 5.0 . -.Sh NOTES -The purpose of the -.Fn grantpt -and -.Fn unlockpt -functions has no meaning in -.Fx , -because pseudo-terminals obtained by -.Xr posix_openpt 2 -are created on demand. -Because these devices are created with proper permissions in place, they -are guaranteed to be unused by unprivileged processes. From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 17:34:22 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6830106564A; Fri, 28 Aug 2009 17:34:22 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99EB08FC16; Fri, 28 Aug 2009 17:34:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SHYMq2031276; Fri, 28 Aug 2009 17:34:22 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SHYMNg031273; Fri, 28 Aug 2009 17:34:22 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200908281734.n7SHYMNg031273@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 28 Aug 2009 17:34:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196618 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/re dev/xen/xenpci pci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 17:34:22 -0000 Author: yongari Date: Fri Aug 28 17:34:22 2009 New Revision: 196618 URL: http://svn.freebsd.org/changeset/base/196618 Log: MFC r196516: Add RTL8168DP/RTL8111DP device id. While I'm here append "8111D" to the description of RTL8168D as RL_HWREV_8168D can be either RTL8168D or RTL8111D. PR: kern/137672 Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/re/if_re.c stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/pci/if_rlreg.h Modified: stable/8/sys/dev/re/if_re.c ============================================================================== --- stable/8/sys/dev/re/if_re.c Fri Aug 28 16:45:34 2009 (r196617) +++ stable/8/sys/dev/re/if_re.c Fri Aug 28 17:34:22 2009 (r196618) @@ -174,8 +174,8 @@ static struct rl_type re_devs[] = { { RT_VENDORID, RT_DEVICEID_8101E, 0, "RealTek 8101E/8102E/8102EL PCIe 10/100baseTX" }, { RT_VENDORID, RT_DEVICEID_8168, 0, - "RealTek 8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP PCIe " - "Gigabit Ethernet" }, + "RealTek 8168/8168B/8168C/8168CP/8168D/8168DP/" + "8111B/8111C/8111CP/8111DP PCIe Gigabit Ethernet" }, { RT_VENDORID, RT_DEVICEID_8169, 0, "RealTek 8169/8169S/8169SB(L)/8110S/8110SB(L) Gigabit Ethernet" }, { RT_VENDORID, RT_DEVICEID_8169SC, 0, @@ -217,7 +217,8 @@ static struct rl_hwrev re_hwrevs[] = { { RL_HWREV_8168C, RL_8169, "8168C/8111C"}, { RL_HWREV_8168C_SPIN2, RL_8169, "8168C/8111C"}, { RL_HWREV_8168CP, RL_8169, "8168CP/8111CP"}, - { RL_HWREV_8168D, RL_8169, "8168D"}, + { RL_HWREV_8168D, RL_8169, "8168D/8111D"}, + { RL_HWREV_8168DP, RL_8169, "8168DP/8111DP"}, { 0, 0, NULL } }; @@ -1282,6 +1283,7 @@ re_attach(device_t dev) /* FALLTHROUGH */ case RL_HWREV_8168CP: case RL_HWREV_8168D: + case RL_HWREV_8168DP: sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD; Modified: stable/8/sys/pci/if_rlreg.h ============================================================================== --- stable/8/sys/pci/if_rlreg.h Fri Aug 28 16:45:34 2009 (r196617) +++ stable/8/sys/pci/if_rlreg.h Fri Aug 28 17:34:22 2009 (r196618) @@ -161,6 +161,7 @@ #define RL_HWREV_8102EL 0x24800000 #define RL_HWREV_8102EL_SPIN1 0x24c00000 #define RL_HWREV_8168D 0x28000000 +#define RL_HWREV_8168DP 0x28800000 #define RL_HWREV_8168_SPIN1 0x30000000 #define RL_HWREV_8100E 0x30800000 #define RL_HWREV_8101E 0x34000000 From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 18:01:37 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99D73106564A; Fri, 28 Aug 2009 18:01:37 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 874948FC18; Fri, 28 Aug 2009 18:01:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SI1bRQ031848; Fri, 28 Aug 2009 18:01:37 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SI1bpp031846; Fri, 28 Aug 2009 18:01:37 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200908281801.n7SI1bpp031846@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 28 Aug 2009 18:01:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196619 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/alc dev/xen/xenpci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 18:01:37 -0000 Author: yongari Date: Fri Aug 28 18:01:37 2009 New Revision: 196619 URL: http://svn.freebsd.org/changeset/base/196619 Log: MFC r196517: Don't try to power down PHY when alc(4) failed to map the device. This fixes system crash when mapping alc(4) device failed in device attach. Reported by: Jim < stapleton.41 <> gmail DOT com > Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/alc/if_alc.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/alc/if_alc.c ============================================================================== --- stable/8/sys/dev/alc/if_alc.c Fri Aug 28 17:34:22 2009 (r196618) +++ stable/8/sys/dev/alc/if_alc.c Fri Aug 28 18:01:37 2009 (r196619) @@ -858,7 +858,8 @@ alc_detach(device_t dev) sc->alc_intrhand[i] = NULL; } } - alc_phy_down(sc); + if (sc->alc_res[0] != NULL) + alc_phy_down(sc); bus_release_resources(dev, sc->alc_irq_spec, sc->alc_irq); if ((sc->alc_flags & (ALC_FLAG_MSI | ALC_FLAG_MSIX)) != 0) pci_release_msi(dev); From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:08:57 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50D731065670; Fri, 28 Aug 2009 19:08:57 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E2E38FC14; Fri, 28 Aug 2009 19:08:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJ8vZ2033494; Fri, 28 Aug 2009 19:08:57 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJ8uW7033493; Fri, 28 Aug 2009 19:08:56 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908281908.n7SJ8uW7033493@svn.freebsd.org> From: Marko Zec Date: Fri, 28 Aug 2009 19:08:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196620 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:08:57 -0000 Author: zec Date: Fri Aug 28 19:08:56 2009 New Revision: 196620 URL: http://svn.freebsd.org/changeset/base/196620 Log: MFC r196501: When registering a protocol to an existing protocol domain via pf_proto_register(), iterate over all existing vnets to call protosw_init() and thus the appropriate .pr_init() handler in the context of each vnet. NB in the future we probably want to separate pr_init() handlers into two, i.e. per-vnet and global, functions. This change has no impact on nooptions VIMAGE builds. Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/uipc_domain.c Modified: stable/8/sys/kern/uipc_domain.c ============================================================================== --- stable/8/sys/kern/uipc_domain.c Fri Aug 28 18:01:37 2009 (r196619) +++ stable/8/sys/kern/uipc_domain.c Fri Aug 28 19:08:56 2009 (r196620) @@ -336,6 +336,7 @@ found: int pf_proto_register(int family, struct protosw *npr) { + VNET_ITERATOR_DECL(vnet_iter); struct domain *dp; struct protosw *pr, *fpr; @@ -391,7 +392,13 @@ found: mtx_unlock(&dom_mtx); /* Initialize and activate the protocol. */ - protosw_init(fpr); + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET_QUIET(vnet_iter); + protosw_init(fpr); + CURVNET_RESTORE(); + } + VNET_LIST_RUNLOCK(); return (0); } From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:10:58 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DBB2106566B; Fri, 28 Aug 2009 19:10:58 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4AAFC8FC1B; Fri, 28 Aug 2009 19:10:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJAwJp033610; Fri, 28 Aug 2009 19:10:58 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJAwV4033607; Fri, 28 Aug 2009 19:10:58 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908281910.n7SJAwV4033607@svn.freebsd.org> From: Marko Zec Date: Fri, 28 Aug 2009 19:10:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196621 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:10:58 -0000 Author: zec Date: Fri Aug 28 19:10:58 2009 New Revision: 196621 URL: http://svn.freebsd.org/changeset/base/196621 Log: MFC r196502: Introduce a div_destroy() function which takes over per-vnet cleanup tasks from the existing modevent / MOD_UNLOAD handler, and register div_destroy() in protosw as per-vnet .pr_destroy() handler for options VIMAGE builds. In nooptions VIMAGE builds, div_destroy() will be invoked from the modevent handler, resulting in effectively identical operation as it was prior this change. div_destroy() also tears down hashtables used by ipdivert, which were previously left behind on ipdivert kldunloads. For options VIMAGE builds only, temporarily disable kldunloading of ipdivert, because without introducing additional locking logic it is impossible to atomically check whether all ipdivert instances in all vnets are idle, and proceed with cleanup without opening a race window for a vnet to open an ipdivert socket while ipdivert tear-down is in progress. While here, staticize div_init(), because it is not used outside of ip_divert.c. In cooperation with: julian Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/ip_divert.c stable/8/sys/netinet/ip_divert.h Modified: stable/8/sys/netinet/ip_divert.c ============================================================================== --- stable/8/sys/netinet/ip_divert.c Fri Aug 28 19:08:56 2009 (r196620) +++ stable/8/sys/netinet/ip_divert.c Fri Aug 28 19:10:58 2009 (r196621) @@ -125,6 +125,8 @@ static VNET_DEFINE(struct inpcbinfo, div static u_long div_sendspace = DIVSNDQ; /* XXX sysctl ? */ static u_long div_recvspace = DIVRCVQ; /* XXX sysctl ? */ +static eventhandler_tag ip_divert_event_tag; + /* * Initialize divert connection block queue. */ @@ -152,7 +154,7 @@ div_inpcb_fini(void *mem, int size) INP_LOCK_DESTROY(inp); } -void +static void div_init(void) { @@ -174,8 +176,17 @@ div_init(void) NULL, NULL, div_inpcb_init, div_inpcb_fini, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); uma_zone_set_max(V_divcbinfo.ipi_zone, maxsockets); - EVENTHANDLER_REGISTER(maxsockets_change, div_zone_change, - NULL, EVENTHANDLER_PRI_ANY); +} + +static void +div_destroy(void) +{ + + INP_INFO_LOCK_DESTROY(&V_divcbinfo); + uma_zdestroy(V_divcbinfo.ipi_zone); + hashdestroy(V_divcbinfo.ipi_hashbase, M_PCB, V_divcbinfo.ipi_hashmask); + hashdestroy(V_divcbinfo.ipi_porthashbase, M_PCB, + V_divcbinfo.ipi_porthashmask); } /* @@ -709,6 +720,9 @@ struct protosw div_protosw = { .pr_ctlinput = div_ctlinput, .pr_ctloutput = ip_ctloutput, .pr_init = div_init, +#ifdef VIMAGE + .pr_destroy = div_destroy, +#endif .pr_usrreqs = &div_usrreqs }; @@ -716,7 +730,9 @@ static int div_modevent(module_t mod, int type, void *unused) { int err = 0; +#ifndef VIMAGE int n; +#endif switch (type) { case MOD_LOAD: @@ -726,7 +742,11 @@ div_modevent(module_t mod, int type, voi * a true IP protocol that goes over the wire. */ err = pf_proto_register(PF_INET, &div_protosw); + if (err != 0) + return (err); ip_divert_ptr = divert_packet; + ip_divert_event_tag = EVENTHANDLER_REGISTER(maxsockets_change, + div_zone_change, NULL, EVENTHANDLER_PRI_ANY); break; case MOD_QUIESCE: /* @@ -737,6 +757,10 @@ div_modevent(module_t mod, int type, voi err = EPERM; break; case MOD_UNLOAD: +#ifdef VIMAGE + err = EPERM; + break; +#else /* * Forced unload. * @@ -758,9 +782,10 @@ div_modevent(module_t mod, int type, voi ip_divert_ptr = NULL; err = pf_proto_unregister(PF_INET, IPPROTO_DIVERT, SOCK_RAW); INP_INFO_WUNLOCK(&V_divcbinfo); - INP_INFO_LOCK_DESTROY(&V_divcbinfo); - uma_zdestroy(V_divcbinfo.ipi_zone); + div_destroy(); + EVENTHANDLER_DEREGISTER(maxsockets_change, ip_divert_event_tag); break; +#endif /* !VIMAGE */ default: err = EOPNOTSUPP; break; Modified: stable/8/sys/netinet/ip_divert.h ============================================================================== --- stable/8/sys/netinet/ip_divert.h Fri Aug 28 19:08:56 2009 (r196620) +++ stable/8/sys/netinet/ip_divert.h Fri Aug 28 19:10:58 2009 (r196621) @@ -83,7 +83,6 @@ divert_find_info(struct mbuf *m) typedef void ip_divert_packet_t(struct mbuf *m, int incoming); extern ip_divert_packet_t *ip_divert_ptr; -extern void div_init(void); extern void div_input(struct mbuf *, int); extern void div_ctlinput(int, struct sockaddr *, void *); #endif /* _NETINET_IP_DIVERT_H_ */ From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:12:45 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFD2A106564A; Fri, 28 Aug 2009 19:12:44 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC3148FC28; Fri, 28 Aug 2009 19:12:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJCifP033736; Fri, 28 Aug 2009 19:12:44 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJCiv0033726; Fri, 28 Aug 2009 19:12:44 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908281912.n7SJCiv0033726@svn.freebsd.org> From: Marko Zec Date: Fri, 28 Aug 2009 19:12:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196622 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci fs/nfsclient nfsclient rpc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:12:45 -0000 Author: zec Date: Fri Aug 28 19:12:44 2009 New Revision: 196622 URL: http://svn.freebsd.org/changeset/base/196622 Log: MFC r196503: Fix NFS panics with options VIMAGE kernels by apropriately setting curvnet context inside the RPC code. Temporarily set td's cred to mount's cred before calling socreate() via __rpc_nconf2socket(). Submitted by: rmacklem (in part) Reviewed by: rmacklem, rwatson Discussed with: dfr, bz Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/fs/nfsclient/nfs_clvnops.c stable/8/sys/nfsclient/nfs_vnops.c stable/8/sys/rpc/clnt_dg.c stable/8/sys/rpc/clnt_rc.c stable/8/sys/rpc/clnt_vc.c stable/8/sys/rpc/rpc_generic.c stable/8/sys/rpc/svc_dg.c stable/8/sys/rpc/svc_generic.c stable/8/sys/rpc/svc_vc.c Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 28 19:12:44 2009 (r196622) @@ -1405,8 +1405,8 @@ again: } mtx_unlock(&dnp->n_mtx); - CURVNET_SET(P_TO_VNET(&proc0)); #ifdef INET + CURVNET_SET(CRED_TO_VNET(cnp->cn_cred)); IN_IFADDR_RLOCK(); if (!TAILQ_EMPTY(&V_in_ifaddrhead)) cverf.lval[0] = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr; @@ -1415,9 +1415,9 @@ again: cverf.lval[0] = create_verf; #ifdef INET IN_IFADDR_RUNLOCK(); + CURVNET_RESTORE(); #endif cverf.lval[1] = ++create_verf; - CURVNET_RESTORE(); error = nfsrpc_create(dvp, cnp->cn_nameptr, cnp->cn_namelen, vap, cverf, fmode, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL); Modified: stable/8/sys/nfsclient/nfs_vnops.c ============================================================================== --- stable/8/sys/nfsclient/nfs_vnops.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/nfsclient/nfs_vnops.c Fri Aug 28 19:12:44 2009 (r196622) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1552,6 +1553,7 @@ again: *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE); tl = nfsm_build(u_int32_t *, NFSX_V3CREATEVERF); #ifdef INET + CURVNET_SET(CRED_TO_VNET(cnp->cn_cred)); IN_IFADDR_RLOCK(); if (!TAILQ_EMPTY(&V_in_ifaddrhead)) *tl++ = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr; @@ -1560,6 +1562,7 @@ again: *tl++ = create_verf; #ifdef INET IN_IFADDR_RUNLOCK(); + CURVNET_RESTORE(); #endif *tl = ++create_verf; } else { Modified: stable/8/sys/rpc/clnt_dg.c ============================================================================== --- stable/8/sys/rpc/clnt_dg.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/clnt_dg.c Fri Aug 28 19:12:44 2009 (r196622) @@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -197,11 +199,14 @@ clnt_dg_create( return (NULL); } + CURVNET_SET(so->so_vnet); if (!__rpc_socket2sockinfo(so, &si)) { rpc_createerr.cf_stat = RPC_TLIERROR; rpc_createerr.cf_error.re_errno = 0; + CURVNET_RESTORE(); return (NULL); } + CURVNET_RESTORE(); /* * Find the receive and the send size Modified: stable/8/sys/rpc/clnt_rc.c ============================================================================== --- stable/8/sys/rpc/clnt_rc.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/clnt_rc.c Fri Aug 28 19:12:44 2009 (r196622) @@ -175,15 +175,16 @@ clnt_reconnect_connect(CLIENT *cl) rc->rc_connecting = TRUE; mtx_unlock(&rc->rc_lock); + oldcred = td->td_ucred; + td->td_ucred = rc->rc_ucred; so = __rpc_nconf2socket(rc->rc_nconf); if (!so) { stat = rpc_createerr.cf_stat = RPC_TLIERROR; rpc_createerr.cf_error.re_errno = 0; + td->td_ucred = oldcred; goto out; } - oldcred = td->td_ucred; - td->td_ucred = rc->rc_ucred; if (rc->rc_privport) bindresvport(so, NULL); Modified: stable/8/sys/rpc/clnt_vc.c ============================================================================== --- stable/8/sys/rpc/clnt_vc.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/clnt_vc.c Fri Aug 28 19:12:44 2009 (r196622) @@ -70,6 +70,9 @@ __FBSDID("$FreeBSD$"); #include #include #include + +#include + #include #include @@ -217,8 +220,11 @@ clnt_vc_create( } } - if (!__rpc_socket2sockinfo(so, &si)) + CURVNET_SET(so->so_vnet); + if (!__rpc_socket2sockinfo(so, &si)) { + CURVNET_RESTORE(); goto err; + } if (so->so_proto->pr_flags & PR_CONNREQUIRED) { bzero(&sopt, sizeof(sopt)); @@ -239,6 +245,7 @@ clnt_vc_create( sopt.sopt_valsize = sizeof(one); sosetopt(so, &sopt); } + CURVNET_RESTORE(); ct->ct_closeit = FALSE; Modified: stable/8/sys/rpc/rpc_generic.c ============================================================================== --- stable/8/sys/rpc/rpc_generic.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/rpc_generic.c Fri Aug 28 19:12:44 2009 (r196622) @@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -822,6 +824,7 @@ bindresvport(struct socket *so, struct s sa->sa_len = salen; if (*portp == 0) { + CURVNET_SET(so->so_vnet); bzero(&opt, sizeof(opt)); opt.sopt_dir = SOPT_GET; opt.sopt_level = proto; @@ -829,12 +832,15 @@ bindresvport(struct socket *so, struct s opt.sopt_val = &old; opt.sopt_valsize = sizeof(old); error = sogetopt(so, &opt); - if (error) + if (error) { + CURVNET_RESTORE(); goto out; + } opt.sopt_dir = SOPT_SET; opt.sopt_val = &portlow; error = sosetopt(so, &opt); + CURVNET_RESTORE(); if (error) goto out; } @@ -845,7 +851,9 @@ bindresvport(struct socket *so, struct s if (error) { opt.sopt_dir = SOPT_SET; opt.sopt_val = &old; + CURVNET_SET(so->so_vnet); sosetopt(so, &opt); + CURVNET_RESTORE(); } } out: Modified: stable/8/sys/rpc/svc_dg.c ============================================================================== --- stable/8/sys/rpc/svc_dg.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/svc_dg.c Fri Aug 28 19:12:44 2009 (r196622) @@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -101,8 +103,10 @@ svc_dg_create(SVCPOOL *pool, struct sock struct sockaddr* sa; int error; + CURVNET_SET(so->so_vnet); if (!__rpc_socket2sockinfo(so, &si)) { printf(svc_dg_str, svc_dg_err1); + CURVNET_RESTORE(); return (NULL); } /* @@ -112,6 +116,7 @@ svc_dg_create(SVCPOOL *pool, struct sock recvsize = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsize); if ((sendsize == 0) || (recvsize == 0)) { printf(svc_dg_str, svc_dg_err2); + CURVNET_RESTORE(); return (NULL); } @@ -124,6 +129,7 @@ svc_dg_create(SVCPOOL *pool, struct sock xprt->xp_ops = &svc_dg_ops; error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); + CURVNET_RESTORE(); if (error) goto freedata; Modified: stable/8/sys/rpc/svc_generic.c ============================================================================== --- stable/8/sys/rpc/svc_generic.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/svc_generic.c Fri Aug 28 19:12:44 2009 (r196622) @@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -228,11 +230,14 @@ svc_tli_create( /* * It is an open socket. Get the transport info. */ + CURVNET_SET(so->so_vnet); if (!__rpc_socket2sockinfo(so, &si)) { printf( "svc_tli_create: could not get transport information\n"); + CURVNET_RESTORE(); return (NULL); } + CURVNET_RESTORE(); } /* @@ -259,7 +264,9 @@ svc_tli_create( "svc_tli_create: could not bind to requested address\n"); goto freedata; } + CURVNET_SET(so->so_vnet); solisten(so, (int)bindaddr->qlen, curthread); + CURVNET_RESTORE(); } } Modified: stable/8/sys/rpc/svc_vc.c ============================================================================== --- stable/8/sys/rpc/svc_vc.c Fri Aug 28 19:10:58 2009 (r196621) +++ stable/8/sys/rpc/svc_vc.c Fri Aug 28 19:12:44 2009 (r196622) @@ -58,6 +58,9 @@ __FBSDID("$FreeBSD$"); #include #include #include + +#include + #include #include @@ -151,9 +154,12 @@ svc_vc_create(SVCPOOL *pool, struct sock xprt->xp_p2 = NULL; xprt->xp_ops = &svc_vc_rendezvous_ops; + CURVNET_SET(so->so_vnet); error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); - if (error) + if (error) { + CURVNET_RESTORE(); goto cleanup_svc_vc_create; + } memcpy(&xprt->xp_ltaddr, sa, sa->sa_len); free(sa, M_SONAME); @@ -161,6 +167,7 @@ svc_vc_create(SVCPOOL *pool, struct sock xprt_register(xprt); solisten(so, SOMAXCONN, curthread); + CURVNET_RESTORE(); SOCKBUF_LOCK(&so->so_rcv); xprt->xp_upcallset = 1; @@ -193,9 +200,12 @@ svc_vc_create_conn(SVCPOOL *pool, struct opt.sopt_name = SO_KEEPALIVE; opt.sopt_val = &one; opt.sopt_valsize = sizeof(one); + CURVNET_SET(so->so_vnet); error = sosetopt(so, &opt); - if (error) + if (error) { + CURVNET_RESTORE(); return (NULL); + } if (so->so_proto->pr_protocol == IPPROTO_TCP) { bzero(&opt, sizeof(struct sockopt)); @@ -205,9 +215,12 @@ svc_vc_create_conn(SVCPOOL *pool, struct opt.sopt_val = &one; opt.sopt_valsize = sizeof(one); error = sosetopt(so, &opt); - if (error) + if (error) { + CURVNET_RESTORE(); return (NULL); + } } + CURVNET_RESTORE(); cd = mem_alloc(sizeof(*cd)); cd->strm_stat = XPRT_IDLE; @@ -625,8 +638,10 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms uio.uio_td = curthread; m = NULL; rcvflag = MSG_DONTWAIT; + CURVNET_SET(xprt->xp_socket->so_vnet); error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL, &rcvflag); + CURVNET_RESTORE(); if (error == EWOULDBLOCK) { /* From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:15:17 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D199F1065675; Fri, 28 Aug 2009 19:15:17 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF6DC8FC14; Fri, 28 Aug 2009 19:15:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJFH1o033858; Fri, 28 Aug 2009 19:15:17 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJFHe6033856; Fri, 28 Aug 2009 19:15:17 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908281915.n7SJFHe6033856@svn.freebsd.org> From: Marko Zec Date: Fri, 28 Aug 2009 19:15:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196623 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:15:17 -0000 Author: zec Date: Fri Aug 28 19:15:17 2009 New Revision: 196623 URL: http://svn.freebsd.org/changeset/base/196623 Log: MFC r196505: When "jail -c vnet" request fails, the current code actually creates and leaves behind an orphaned vnet. This change ensures that such vnets get released. This change affects only options VIMAGE builds. Submitted by: jamie Discussed with: bz Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/kern_jail.c Modified: stable/8/sys/kern/kern_jail.c ============================================================================== --- stable/8/sys/kern/kern_jail.c Fri Aug 28 19:12:44 2009 (r196622) +++ stable/8/sys/kern/kern_jail.c Fri Aug 28 19:15:17 2009 (r196623) @@ -2456,7 +2456,7 @@ prison_deref(struct prison *pr, int flag sx_downgrade(&allprison_lock); #ifdef VIMAGE - if (pr->pr_flags & PR_VNET) + if (pr->pr_vnet != ppr->pr_vnet) vnet_destroy(pr->pr_vnet); #endif if (pr->pr_root != NULL) { From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:18:21 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67C0B106566C; Fri, 28 Aug 2009 19:18:21 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5597C8FC18; Fri, 28 Aug 2009 19:18:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJILls033982; Fri, 28 Aug 2009 19:18:21 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJIL9I033980; Fri, 28 Aug 2009 19:18:21 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908281918.n7SJIL9I033980@svn.freebsd.org> From: Marko Zec Date: Fri, 28 Aug 2009 19:18:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196624 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:18:21 -0000 Author: zec Date: Fri Aug 28 19:18:20 2009 New Revision: 196624 URL: http://svn.freebsd.org/changeset/base/196624 Log: MFC r196504: When moving ifnets from one vnet to another, and the ifnet has ifaddresses of AF_LINK type which thus have an embedded if_index "backpointer", we must update that if_index backpointer to reflect the new if_index that our ifnet just got assigned. This change affects only options VIMAGE builds. Submitted by: bz Reviewed by: bz Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Fri Aug 28 19:15:17 2009 (r196623) +++ stable/8/sys/net/if.c Fri Aug 28 19:18:20 2009 (r196624) @@ -570,6 +570,21 @@ if_attach_internal(struct ifnet *ifp, in /* Reliably crash if used uninitialized. */ ifp->if_broadcastaddr = NULL; } +#ifdef VIMAGE + else { + /* + * Update the interface index in the link layer address + * of the interface. + */ + for (ifa = ifp->if_addr; ifa != NULL; + ifa = TAILQ_NEXT(ifa, ifa_link)) { + if (ifa->ifa_addr->sa_family == AF_LINK) { + sdl = (struct sockaddr_dl *)ifa->ifa_addr; + sdl->sdl_index = ifp->if_index; + } + } + } +#endif IFNET_WLOCK(); TAILQ_INSERT_TAIL(&V_ifnet, ifp, if_link); From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 19:48:07 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CE82106564A; Fri, 28 Aug 2009 19:48:07 +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 2B2878FC15; Fri, 28 Aug 2009 19:48:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SJm6uR034606; Fri, 28 Aug 2009 19:48:06 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SJm6PZ034604; Fri, 28 Aug 2009 19:48:06 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200908281948.n7SJm6PZ034604@svn.freebsd.org> From: Xin LI Date: Fri, 28 Aug 2009 19:48:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196625 - in stable/8/lib/libc: . db/hash X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 19:48:07 -0000 Author: delphij Date: Fri Aug 28 19:48:06 2009 New Revision: 196625 URL: http://svn.freebsd.org/changeset/base/196625 Log: MFC r196525: Consider flag == 0 as the same of flag == R_NEXT. This change will restore a historical behavior that has been changed by revision 190491, and has seen to break exim. Approved by: re (kib) Modified: stable/8/lib/libc/ (props changed) stable/8/lib/libc/db/hash/hash.c Modified: stable/8/lib/libc/db/hash/hash.c ============================================================================== --- stable/8/lib/libc/db/hash/hash.c Fri Aug 28 19:18:20 2009 (r196624) +++ stable/8/lib/libc/db/hash/hash.c Fri Aug 28 19:48:06 2009 (r196625) @@ -711,7 +711,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *d hashp->cndx = 1; hashp->cpage = NULL; } - next_bucket: +next_bucket: for (bp = NULL; !bp || !bp[0]; ) { if (!(bufp = hashp->cpage)) { for (bucket = hashp->cbucket; @@ -732,7 +732,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *d } } else { bp = (u_int16_t *)hashp->cpage->page; - if (flag == R_NEXT) { + if (flag == R_NEXT || flag == 0) { hashp->cndx += 2; if (hashp->cndx > bp[0]) { hashp->cpage = NULL; From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 20:06:02 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE61C1065670; Fri, 28 Aug 2009 20:06:02 +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 B90BE8FC15; Fri, 28 Aug 2009 20:06:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SK62ZD035098; Fri, 28 Aug 2009 20:06:02 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SK62cq035081; Fri, 28 Aug 2009 20:06:02 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282006.n7SK62cq035081@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 20:06:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196626 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris compat/linux contrib/altq/altq contrib/dev/acpica contrib/pf dev/xen/xenpci kern net netgraph netinet netinet6 ne... X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 20:06:02 -0000 Author: rwatson Date: Fri Aug 28 20:06:02 2009 New Revision: 196626 URL: http://svn.freebsd.org/changeset/base/196626 Log: Merge r196481 from head to stable/8: Rework global locks for interface list and index management, correcting several critical bugs, including race conditions and lock order issues: Replace the single rwlock, ifnet_lock, with two locks, an rwlock and an sxlock. Either can be held to stablize the lists and indexes, but both are required to write. This allows the list to be held stable in both network interrupt contexts and sleepable user threads across sleeping memory allocations or device driver interactions. As before, writes to the interface list must occur from sleepable contexts. Reviewed by: bz, julian Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/compat/linux/linux_ioctl.c stable/8/sys/contrib/altq/altq/altq_subr.c stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/kern_uuid.c stable/8/sys/net/bridgestp.c stable/8/sys/net/if.c stable/8/sys/net/if_llatbl.c stable/8/sys/net/if_var.h stable/8/sys/net/if_vlan.c stable/8/sys/netgraph/ng_gif.c stable/8/sys/netinet/in.c stable/8/sys/netinet6/icmp6.c stable/8/sys/netinet6/in6.c stable/8/sys/netinet6/in6_ifattach.c stable/8/sys/netinet6/nd6.c stable/8/sys/netipsec/xform_ipip.c stable/8/sys/nfsclient/bootp_subr.c Modified: stable/8/sys/compat/linux/linux_ioctl.c ============================================================================== --- stable/8/sys/compat/linux/linux_ioctl.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/compat/linux/linux_ioctl.c Fri Aug 28 20:06:02 2009 (r196626) @@ -2061,22 +2061,20 @@ linux_ifname(struct ifnet *ifp, char *bu struct ifnet *ifscan; int ethno; + IFNET_RLOCK_ASSERT(); + /* Short-circuit non ethernet interfaces */ if (!IFP_IS_ETH(ifp)) return (strlcpy(buffer, ifp->if_xname, buflen)); /* Determine the (relative) unit number for ethernet interfaces */ ethno = 0; - IFNET_RLOCK(); TAILQ_FOREACH(ifscan, &V_ifnet, if_link) { - if (ifscan == ifp) { - IFNET_RUNLOCK(); + if (ifscan == ifp) return (snprintf(buffer, buflen, "eth%d", ethno)); - } if (IFP_IS_ETH(ifscan)) ethno++; } - IFNET_RUNLOCK(); return (0); } @@ -2177,7 +2175,7 @@ again: valid_len = 0; /* Return all AF_INET addresses of all interfaces */ - IFNET_RLOCK(); /* could sleep XXX */ + IFNET_RLOCK(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { int addrs = 0; Modified: stable/8/sys/contrib/altq/altq/altq_subr.c ============================================================================== --- stable/8/sys/contrib/altq/altq/altq_subr.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/contrib/altq/altq/altq_subr.c Fri Aug 28 20:06:02 2009 (r196626) @@ -462,8 +462,8 @@ tbr_timeout(arg) s = splimp(); #endif #if defined(__FreeBSD__) && (__FreeBSD_version >= 500000) - IFNET_RLOCK(); - VNET_LIST_RLOCK(); + IFNET_RLOCK_NOSLEEP(); + VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); #endif @@ -480,8 +480,8 @@ tbr_timeout(arg) #if defined(__FreeBSD__) && (__FreeBSD_version >= 500000) CURVNET_RESTORE(); } - VNET_LIST_RUNLOCK(); - IFNET_RUNLOCK(); + VNET_LIST_RUNLOCK_NOSLEEP(); + IFNET_RUNLOCK_NOSLEEP(); #endif splx(s); if (active > 0) Modified: stable/8/sys/kern/kern_uuid.c ============================================================================== --- stable/8/sys/kern/kern_uuid.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/kern/kern_uuid.c Fri Aug 28 20:06:02 2009 (r196626) @@ -95,7 +95,7 @@ uuid_node(uint16_t *node) int i; CURVNET_SET(TD_TO_VNET(curthread)); - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { /* Walk the address list */ IF_ADDR_LOCK(ifp); @@ -106,14 +106,14 @@ uuid_node(uint16_t *node) /* Got a MAC address. */ bcopy(LLADDR(sdl), node, UUID_NODE_LEN); IF_ADDR_UNLOCK(ifp); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); CURVNET_RESTORE(); return; } } IF_ADDR_UNLOCK(ifp); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); for (i = 0; i < (UUID_NODE_LEN>>1); i++) node[i] = (uint16_t)arc4random(); Modified: stable/8/sys/net/bridgestp.c ============================================================================== --- stable/8/sys/net/bridgestp.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/net/bridgestp.c Fri Aug 28 20:06:02 2009 (r196626) @@ -2019,7 +2019,7 @@ bstp_reinit(struct bstp_state *bs) * not need to be part of the bridge, it just needs to be a unique * value. */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifp->if_type != IFT_ETHER) continue; @@ -2036,7 +2036,7 @@ bstp_reinit(struct bstp_state *bs) continue; } } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) { /* Set the bridge and root id (lower bits) to zero */ Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/net/if.c Fri Aug 28 20:06:02 2009 (r196626) @@ -154,14 +154,26 @@ VNET_DEFINE(struct ifgrouphead, ifg_head VNET_DEFINE(int, if_index); static VNET_DEFINE(int, if_indexlim) = 8; -/* Table of ifnet by index. Locked with ifnet_lock. */ +/* Table of ifnet by index. */ static VNET_DEFINE(struct ifindex_entry *, ifindex_table); #define V_if_indexlim VNET(if_indexlim) #define V_ifindex_table VNET(ifindex_table) int ifqmaxlen = IFQ_MAXLEN; -struct rwlock ifnet_lock; + +/* + * The global network interface list (V_ifnet) and related state (such as + * if_index, if_indexlim, and ifindex_table) are protected by an sxlock and + * an rwlock. Either may be acquired shared to stablize the list, but both + * must be acquired writable to modify the list. This model allows us to + * both stablize the interface list during interrupt thread processing, but + * also to stablize it over long-running ioctls, without introducing priority + * inversions and deadlocks. + */ +struct rwlock ifnet_rwlock; +struct sx ifnet_sxlock; + static if_com_alloc_t *if_com_alloc[256]; static if_com_free_t *if_com_free[256]; @@ -188,9 +200,9 @@ ifnet_byindex(u_short idx) { struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); ifp = ifnet_byindex_locked(idx); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifp); } @@ -199,19 +211,19 @@ ifnet_byindex_ref(u_short idx) { struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); ifp = ifnet_byindex_locked(idx); if (ifp == NULL || (ifp->if_flags & IFF_DYING)) { - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (NULL); } if_ref(ifp); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifp); } static void -ifnet_setbyindex(u_short idx, struct ifnet *ifp) +ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp) { IFNET_WLOCK_ASSERT(); @@ -219,16 +231,25 @@ ifnet_setbyindex(u_short idx, struct ifn V_ifindex_table[idx].ife_ifnet = ifp; } +static void +ifnet_setbyindex(u_short idx, struct ifnet *ifp) +{ + + IFNET_WLOCK(); + ifnet_setbyindex_locked(idx, ifp); + IFNET_WUNLOCK(); +} + struct ifaddr * ifaddr_byindex(u_short idx) { struct ifaddr *ifa; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); ifa = ifnet_byindex_locked(idx)->if_addr; if (ifa != NULL) ifa_ref(ifa); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifa); } @@ -361,9 +382,7 @@ if_alloc(u_char type) ifq_init(&ifp->if_snd, ifp); refcount_init(&ifp->if_refcount, 1); /* Index reference. */ - IFNET_WLOCK(); ifnet_setbyindex(ifp->if_index, ifp); - IFNET_WUNLOCK(); return (ifp); } @@ -383,7 +402,7 @@ if_free_internal(struct ifnet *ifp) KASSERT(ifp == ifnet_byindex_locked(ifp->if_index), ("%s: freeing unallocated ifnet", ifp->if_xname)); - ifnet_setbyindex(ifp->if_index, NULL); + ifnet_setbyindex_locked(ifp->if_index, NULL); while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL) V_if_index--; IFNET_WUNLOCK(); @@ -870,11 +889,14 @@ if_vmove(struct ifnet *ifp, struct vnet if_detach_internal(ifp, 1); /* - * Unlink the ifnet from ifindex_table[] in current vnet, - * and shrink the if_index for that vnet if possible. + * Unlink the ifnet from ifindex_table[] in current vnet, and shrink + * the if_index for that vnet if possible. + * + * NOTE: IFNET_WLOCK/IFNET_WUNLOCK() are assumed to be unvirtualized, + * or we'd lock on one vnet and unlock on another. */ IFNET_WLOCK(); - ifnet_setbyindex(ifp->if_index, NULL); + ifnet_setbyindex_locked(ifp->if_index, NULL); while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL) V_if_index--; IFNET_WUNLOCK(); @@ -901,7 +923,7 @@ if_vmove(struct ifnet *ifp, struct vnet V_if_index = ifp->if_index; if (V_if_index >= V_if_indexlim) if_grow(); - ifnet_setbyindex(ifp->if_index, ifp); + ifnet_setbyindex_locked(ifp->if_index, ifp); IFNET_WUNLOCK(); if_attach_internal(ifp, 1); @@ -1383,7 +1405,7 @@ ifa_ifwithaddr_internal(struct sockaddr struct ifnet *ifp; struct ifaddr *ifa; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { @@ -1410,7 +1432,7 @@ ifa_ifwithaddr_internal(struct sockaddr } ifa = NULL; done: - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifa); } @@ -1438,7 +1460,7 @@ ifa_ifwithbroadaddr(struct sockaddr *add struct ifnet *ifp; struct ifaddr *ifa; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { @@ -1457,7 +1479,7 @@ ifa_ifwithbroadaddr(struct sockaddr *add } ifa = NULL; done: - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifa); } @@ -1471,7 +1493,7 @@ ifa_ifwithdstaddr(struct sockaddr *addr) struct ifnet *ifp; struct ifaddr *ifa; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if ((ifp->if_flags & IFF_POINTOPOINT) == 0) continue; @@ -1490,7 +1512,7 @@ ifa_ifwithdstaddr(struct sockaddr *addr) } ifa = NULL; done: - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifa); } @@ -1523,7 +1545,7 @@ ifa_ifwithnet(struct sockaddr *addr) * we find one, as we release the IF_ADDR_LOCK() that kept it stable * when we move onto the next interface. */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { @@ -1599,7 +1621,7 @@ next: continue; ifa = ifa_maybe; ifa_maybe = NULL; done: - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); if (ifa_maybe != NULL) ifa_free(ifa_maybe); return (ifa); @@ -1878,7 +1900,7 @@ if_slowtimo(void *arg) int s = splimp(); VNET_LIST_RLOCK_NOSLEEP(); - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { @@ -1889,7 +1911,7 @@ if_slowtimo(void *arg) } CURVNET_RESTORE(); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); VNET_LIST_RUNLOCK_NOSLEEP(); splx(s); timeout(if_slowtimo, (void *)0, hz / IFNET_SLOWHZ); @@ -1904,7 +1926,7 @@ ifunit_ref(const char *name) { struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (strncmp(name, ifp->if_xname, IFNAMSIZ) == 0 && !(ifp->if_flags & IFF_DYING)) @@ -1912,7 +1934,7 @@ ifunit_ref(const char *name) } if (ifp != NULL) if_ref(ifp); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifp); } @@ -1921,12 +1943,12 @@ ifunit(const char *name) { struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (strncmp(name, ifp->if_xname, IFNAMSIZ) == 0) break; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifp); } @@ -2536,7 +2558,7 @@ again: max_len = 0; valid_len = 0; - IFNET_RLOCK(); /* could sleep XXX */ + IFNET_RLOCK(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { int addrs; @@ -2861,13 +2883,13 @@ if_delmulti(struct ifnet *ifp, struct so #ifdef INVARIANTS struct ifnet *oifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(oifp, &V_ifnet, if_link) if (ifp == oifp) break; if (ifp != oifp) ifp = NULL; - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); KASSERT(ifp != NULL, ("%s: ifnet went away", __func__)); #endif @@ -2910,7 +2932,7 @@ if_delmulti_ifma(struct ifmultiaddr *ifm } else { struct ifnet *oifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(oifp, &V_ifnet, if_link) if (ifp == oifp) break; @@ -2918,7 +2940,7 @@ if_delmulti_ifma(struct ifmultiaddr *ifm printf("%s: ifnet %p disappeared\n", __func__, ifp); ifp = NULL; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); } #endif /* Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/net/if_llatbl.c Fri Aug 28 20:06:02 2009 (r196626) @@ -200,14 +200,14 @@ lltable_prefix_free(int af, struct socka { struct lltable *llt; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, prefix, mask); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); } @@ -300,13 +300,13 @@ lla_rt_output(struct rt_msghdr *rtm, str } /* XXX linked list may be too expensive */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); if (flags && LLE_CREATE) Modified: stable/8/sys/net/if_var.h ============================================================================== --- stable/8/sys/net/if_var.h Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/net/if_var.h Fri Aug 28 20:06:02 2009 (r196626) @@ -85,6 +85,7 @@ struct vnet; #include /* XXX */ #include /* XXX */ #include /* XXX */ +#include /* XXX */ #include /* XXX */ #include @@ -754,14 +755,39 @@ struct ifmultiaddr { #ifdef _KERNEL -extern struct rwlock ifnet_lock; -#define IFNET_LOCK_INIT() \ - rw_init_flags(&ifnet_lock, "ifnet", RW_RECURSE) -#define IFNET_WLOCK() rw_wlock(&ifnet_lock) -#define IFNET_WUNLOCK() rw_wunlock(&ifnet_lock) -#define IFNET_WLOCK_ASSERT() rw_assert(&ifnet_lock, RA_LOCKED) -#define IFNET_RLOCK() rw_rlock(&ifnet_lock) -#define IFNET_RUNLOCK() rw_runlock(&ifnet_lock) +extern struct rwlock ifnet_rwlock; +extern struct sx ifnet_sxlock; + +#define IFNET_LOCK_INIT() do { \ + rw_init_flags(&ifnet_rwlock, "ifnet_rw", RW_RECURSE); \ + sx_init_flags(&ifnet_sxlock, "ifnet_sx", SX_RECURSE); \ +} while(0) + +#define IFNET_WLOCK() do { \ + sx_xlock(&ifnet_sxlock); \ + rw_wlock(&ifnet_rwlock); \ +} while (0) + +#define IFNET_WUNLOCK() do { \ + rw_wunlock(&ifnet_rwlock); \ + sx_xunlock(&ifnet_sxlock); \ +} while (0) + +/* + * To assert the ifnet lock, you must know not only whether it's for read or + * write, but also whether it was acquired with sleep support or not. + */ +#define IFNET_RLOCK_ASSERT() sx_assert(&ifnet_sxlock, SA_SLOCKED) +#define IFNET_RLOCK_NOSLEEP_ASSERT() rw_assert(&ifnet_rwlock, RA_RLOCKED) +#define IFNET_WLOCK_ASSERT() do { \ + sx_assert(&ifnet_sxlock, SA_XLOCKED); \ + rw_assert(&ifnet_rwlock, RA_WLOCKED); \ +} while (0) + +#define IFNET_RLOCK() sx_slock(&ifnet_sxlock) +#define IFNET_RLOCK_NOSLEEP() rw_rlock(&ifnet_rwlock) +#define IFNET_RUNLOCK() sx_sunlock(&ifnet_sxlock) +#define IFNET_RUNLOCK_NOSLEEP() rw_runlock(&ifnet_rwlock) /* * Look up an ifnet given its index; the _ref variant also acquires a Modified: stable/8/sys/net/if_vlan.c ============================================================================== --- stable/8/sys/net/if_vlan.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/net/if_vlan.c Fri Aug 28 20:06:02 2009 (r196626) @@ -580,7 +580,7 @@ vlan_clone_match_ethertag(struct if_clon int t = 0; /* Check for . style interface names. */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifp->if_type != IFT_ETHER) continue; @@ -598,7 +598,7 @@ vlan_clone_match_ethertag(struct if_clon *tag = t; break; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (ifp); } Modified: stable/8/sys/netgraph/ng_gif.c ============================================================================== --- stable/8/sys/netgraph/ng_gif.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netgraph/ng_gif.c Fri Aug 28 20:06:02 2009 (r196626) @@ -560,7 +560,7 @@ ng_gif_mod_event(module_t mod, int event ng_gif_input_orphan_p = ng_gif_input_orphan; /* Create nodes for any already-existing gif interfaces */ - VNET_LIST_RLOCK_NOSLEEP(); + VNET_LIST_RLOCK(); IFNET_RLOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET_QUIET(vnet_iter); /* XXX revisit quiet */ @@ -571,7 +571,7 @@ ng_gif_mod_event(module_t mod, int event CURVNET_RESTORE(); } IFNET_RUNLOCK(); - VNET_LIST_RUNLOCK_NOSLEEP(); + VNET_LIST_RUNLOCK(); break; case MOD_UNLOAD: Modified: stable/8/sys/netinet/in.c ============================================================================== --- stable/8/sys/netinet/in.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netinet/in.c Fri Aug 28 20:06:02 2009 (r196626) @@ -1407,12 +1407,7 @@ in_lltable_dump(struct lltable *llt, str } arpc; int error, i; - /* XXXXX - * current IFNET_RLOCK() is mapped to IFNET_WLOCK() - * so it is okay to use this ASSERT, change it when - * IFNET lock is finalized - */ - IFNET_WLOCK_ASSERT(); + IFNET_RLOCK_ASSERT(); error = 0; for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { Modified: stable/8/sys/netinet6/icmp6.c ============================================================================== --- stable/8/sys/netinet6/icmp6.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netinet6/icmp6.c Fri Aug 28 20:06:02 2009 (r196626) @@ -1705,7 +1705,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, st } } - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { addrsofif = 0; IF_ADDR_LOCK(ifp); @@ -1762,13 +1762,13 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, st IF_ADDR_UNLOCK(ifp); if (iffound) { *ifpp = ifp; - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (addrsofif); } addrs += addrsofif; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (addrs); } @@ -1789,7 +1789,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *n if (ifp0 == NULL && !(niflags & NI_NODEADDR_FLAG_ALL)) return (0); /* needless to copy */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); again: for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) { @@ -1854,7 +1854,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *n * Set the truncate flag and return. */ nni6->ni_flags |= NI_NODEADDR_FLAG_TRUNCATE; - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (copied); } @@ -1907,7 +1907,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *n goto again; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return (copied); } Modified: stable/8/sys/netinet6/in6.c ============================================================================== --- stable/8/sys/netinet6/in6.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netinet6/in6.c Fri Aug 28 20:06:02 2009 (r196626) @@ -2234,7 +2234,7 @@ in6_setmaxmtu(void) unsigned long maxmtu = 0; struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { /* this function can be called during ifnet initialization */ @@ -2244,7 +2244,7 @@ in6_setmaxmtu(void) IN6_LINKMTU(ifp) > maxmtu) maxmtu = IN6_LINKMTU(ifp); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); if (maxmtu) /* update only when maxmtu is positive */ V_in6_maxmtu = maxmtu; } @@ -2495,12 +2495,7 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; - /* XXXXX - * current IFNET_RLOCK() is mapped to IFNET_WLOCK() - * so it is okay to use this ASSERT, change it when - * IFNET lock is finalized - */ - IFNET_WLOCK_ASSERT(); + IFNET_RLOCK_ASSERT(); error = 0; for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { Modified: stable/8/sys/netinet6/in6_ifattach.c ============================================================================== --- stable/8/sys/netinet6/in6_ifattach.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netinet6/in6_ifattach.c Fri Aug 28 20:06:02 2009 (r196626) @@ -398,7 +398,7 @@ get_ifid(struct ifnet *ifp0, struct ifne } /* next, try to get it from some other hardware interface */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); for (ifp = V_ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) { if (ifp == ifp0) continue; @@ -413,11 +413,11 @@ get_ifid(struct ifnet *ifp0, struct ifne nd6log((LOG_DEBUG, "%s: borrow interface identifier from %s\n", if_name(ifp0), if_name(ifp))); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); goto success; } } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); /* last resort: get from random number source */ if (get_rand_ifid(ifp, in6) == 0) { Modified: stable/8/sys/netinet6/nd6.c ============================================================================== --- stable/8/sys/netinet6/nd6.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netinet6/nd6.c Fri Aug 28 20:06:02 2009 (r196626) @@ -1662,7 +1662,7 @@ nd6_slowtimo(void *arg) callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, nd6_slowtimo, curvnet); - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { nd6if = ND_IFINFO(ifp); @@ -1678,7 +1678,7 @@ nd6_slowtimo(void *arg) nd6if->reachable = ND_COMPUTE_RTIME(nd6if->basereachable); } } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); CURVNET_RESTORE(); } Modified: stable/8/sys/netipsec/xform_ipip.c ============================================================================== --- stable/8/sys/netipsec/xform_ipip.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/netipsec/xform_ipip.c Fri Aug 28 20:06:02 2009 (r196626) @@ -303,7 +303,7 @@ _ipip_input(struct mbuf *m, int iphlen, if ((m->m_pkthdr.rcvif == NULL || !(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) && V_ipip_allow != 2) { - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { #ifdef INET @@ -318,7 +318,7 @@ _ipip_input(struct mbuf *m, int iphlen, ipo->ip_src.s_addr) { V_ipipstat.ipips_spoof++; m_freem(m); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return; } } @@ -335,7 +335,7 @@ _ipip_input(struct mbuf *m, int iphlen, if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &ip6->ip6_src)) { V_ipipstat.ipips_spoof++; m_freem(m); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return; } @@ -343,7 +343,7 @@ _ipip_input(struct mbuf *m, int iphlen, #endif /* INET6 */ } } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); } /* Statistics */ Modified: stable/8/sys/nfsclient/bootp_subr.c ============================================================================== --- stable/8/sys/nfsclient/bootp_subr.c Fri Aug 28 19:48:06 2009 (r196625) +++ stable/8/sys/nfsclient/bootp_subr.c Fri Aug 28 20:06:02 2009 (r196626) @@ -389,7 +389,7 @@ bootpboot_p_iflist(void) struct ifaddr *ifa; printf("Interface list:\n"); - IFNET_RLOCK(); /* could sleep, but okay for debugging XXX */ + IFNET_RLOCK(); for (ifp = TAILQ_FIRST(&V_ifnet); ifp != NULL; ifp = TAILQ_NEXT(ifp, if_link)) { From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 20:07:39 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 060B41065670; Fri, 28 Aug 2009 20:07:39 +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 CD6D68FC16; Fri, 28 Aug 2009 20:07:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SK7cgW035168; Fri, 28 Aug 2009 20:07:38 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SK7cxk035166; Fri, 28 Aug 2009 20:07:38 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282007.n7SK7cxk035166@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 20:07:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196627 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 20:07:39 -0000 Author: rwatson Date: Fri Aug 28 20:07:38 2009 New Revision: 196627 URL: http://svn.freebsd.org/changeset/base/196627 Log: Merge r196482 from head to stable/8: Rather than using IFNET_RLOCK() when iterating over (and modifying) the ifnet list during if_ef load, directly acquire the ifnet_sxlock exclusively. That way when if_alloc() recurses the lock, it's a write recursion rather than a read->write recursion. This code structure is arguably a bug, so add a comment indicating that this is the case. Post-8.0, we should fix this, but this commit resolves panic-on-load for if_ef. Discussed with: bz, julian Reported by: phk Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_ef.c Modified: stable/8/sys/net/if_ef.c ============================================================================== --- stable/8/sys/net/if_ef.c Fri Aug 28 20:06:02 2009 (r196626) +++ stable/8/sys/net/if_ef.c Fri Aug 28 20:07:38 2009 (r196627) @@ -492,7 +492,20 @@ ef_load(void) VNET_LIST_RLOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); - IFNET_RLOCK(); + + /* + * XXXRW: The following loop walks the ifnet list while + * modifying it, something not well-supported by ifnet + * locking. To avoid lock upgrade/recursion issues, manually + * acquire a write lock of ifnet_sxlock here, rather than a + * read lock, so that when if_alloc() recurses the lock, we + * don't panic. This structure, in which if_ef automatically + * attaches to all ethernet interfaces, should be replaced + * with a model like that found in if_vlan, in which + * interfaces are explicitly configured, which would avoid + * this (and other) problems. + */ + sx_xlock(&ifnet_sxlock); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifp->if_type != IFT_ETHER) continue; EFDEBUG("Found interface %s\n", ifp->if_xname); @@ -523,7 +536,7 @@ ef_load(void) efcount++; SLIST_INSERT_HEAD(&efdev, efl, el_next); } - IFNET_RUNLOCK(); + sx_xunlock(&ifnet_sxlock); CURVNET_RESTORE(); } VNET_LIST_RUNLOCK(); From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 20:26:00 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B212F106564A; Fri, 28 Aug 2009 20:26:00 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EA8B8FC0A; Fri, 28 Aug 2009 20:26:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SKQ0lq035575; Fri, 28 Aug 2009 20:26:00 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SKQ0Oc035573; Fri, 28 Aug 2009 20:26:00 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200908282026.n7SKQ0Oc035573@svn.freebsd.org> From: Max Laier Date: Fri, 28 Aug 2009 20:26:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196628 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf contrib/pf/net dev/xen/xenpci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 20:26:00 -0000 Author: mlaier Date: Fri Aug 28 20:26:00 2009 New Revision: 196628 URL: http://svn.freebsd.org/changeset/base/196628 Log: MFC r196551: Fix argument ordering to memcpy as well as the size of the copy in the (theoretical) case that pfi_buffer_cnt should be greater than ~_max. Submitted by: pjd Reviewed by: {krw,sthen,markus}@openbsd.org Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/contrib/pf/net/pf_if.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/contrib/pf/net/pf_if.c ============================================================================== --- stable/8/sys/contrib/pf/net/pf_if.c Fri Aug 28 20:07:38 2009 (r196627) +++ stable/8/sys/contrib/pf/net/pf_if.c Fri Aug 28 20:26:00 2009 (r196628) @@ -663,7 +663,7 @@ pfi_address_add(struct sockaddr *sa, int "(%d/%d)\n", pfi_buffer_cnt, PFI_BUFFER_MAX); return; } - memcpy(pfi_buffer, p, pfi_buffer_cnt * sizeof(*pfi_buffer)); + memcpy(p, pfi_buffer, pfi_buffer_max * sizeof(*pfi_buffer)); /* no need to zero buffer */ free(pfi_buffer, PFI_MTYPE); pfi_buffer = p; From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 21:07:47 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01D731065672; Fri, 28 Aug 2009 21:07:47 +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 C8C7E8FC17; Fri, 28 Aug 2009 21:07:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SL7kBU036514; Fri, 28 Aug 2009 21:07:46 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SL7j7b036513; Fri, 28 Aug 2009 21:07:45 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282107.n7SL7j7b036513@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 21:07:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196629 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 21:07:47 -0000 Author: rwatson Date: Fri Aug 28 21:07:43 2009 New Revision: 196629 URL: http://svn.freebsd.org/changeset/base/196629 Log: Merge r196510 from head to stable/8: Make if_grow static -- it's not used outside of if.c, and with the internals destined to change, it's better if it remains that way. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c stable/8/sys/net/if_var.h Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Fri Aug 28 20:26:00 2009 (r196628) +++ stable/8/sys/net/if.c Fri Aug 28 21:07:43 2009 (r196629) @@ -124,6 +124,7 @@ static void if_attachdomain1(struct ifne static int ifconf(u_long, caddr_t); static void if_freemulti(struct ifmultiaddr *); static void if_init(void *); +static void if_grow(void); static void if_check(void *); static void if_route(struct ifnet *, int flag, int fam); static int if_setflag(struct ifnet *, int, int, int *, int); @@ -297,7 +298,7 @@ VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_IN vnet_if_uninit, NULL); #endif -void +static void if_grow(void) { u_int n; Modified: stable/8/sys/net/if_var.h ============================================================================== --- stable/8/sys/net/if_var.h Fri Aug 28 20:26:00 2009 (r196628) +++ stable/8/sys/net/if_var.h Fri Aug 28 21:07:43 2009 (r196629) @@ -826,7 +826,6 @@ int if_allmulti(struct ifnet *, int); struct ifnet* if_alloc(u_char); void if_attach(struct ifnet *); void if_dead(struct ifnet *); -void if_grow(void); int if_delmulti(struct ifnet *, struct sockaddr *); void if_delmulti_ifma(struct ifmultiaddr *); void if_detach(struct ifnet *); From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 21:10:27 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CBE61065670; Fri, 28 Aug 2009 21:10:27 +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 288E98FC08; Fri, 28 Aug 2009 21:10:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SLAR7g036623; Fri, 28 Aug 2009 21:10:27 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SLAQpi036619; Fri, 28 Aug 2009 21:10:26 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282110.n7SLAQpi036619@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 21:10:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196630 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet netinet6 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 21:10:27 -0000 Author: rwatson Date: Fri Aug 28 21:10:26 2009 New Revision: 196630 URL: http://svn.freebsd.org/changeset/base/196630 Log: Merge r196535 from head to stable/8: Use locks specific to the lltable code, rather than borrow the ifnet list/index locks, to protect link layer address tables. This avoids lock order issues during interface teardown, but maintains the bug that sysctl copy routines may be called while a non-sleepable lock is held. Reviewed by: bz, kmacy, qingli Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_llatbl.c stable/8/sys/net/if_llatbl.h stable/8/sys/netinet/in.c stable/8/sys/netinet6/in6.c Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Fri Aug 28 21:07:43 2009 (r196629) +++ stable/8/sys/net/if_llatbl.c Fri Aug 28 21:10:26 2009 (r196630) @@ -62,6 +62,9 @@ static SLIST_HEAD(, lltable) lltables = extern void arprequest(struct ifnet *, struct in_addr *, struct in_addr *, u_char *); +struct rwlock lltable_rwlock; +RW_SYSINIT(lltable_rwlock, &lltable_rwlock, "lltable_rwlock"); + /* * Dump arp state for a specific address family. */ @@ -71,7 +74,7 @@ lltable_sysctl_dumparp(int af, struct sy struct lltable *llt; int error = 0; - IFNET_RLOCK(); + LLTABLE_RLOCK(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af == af) { error = llt->llt_dump(llt, wr); @@ -80,7 +83,7 @@ lltable_sysctl_dumparp(int af, struct sy } } done: - IFNET_RUNLOCK(); + LLTABLE_RUNLOCK(); return (error); } @@ -144,8 +147,6 @@ llentry_update(struct llentry **llep, st /* * Free all entries from given table and free itself. - * Since lltables collects from all of the intefaces, - * the caller of this function must acquire IFNET_WLOCK(). */ void lltable_free(struct lltable *llt) @@ -155,9 +156,9 @@ lltable_free(struct lltable *llt) KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); - IFNET_WLOCK(); + LLTABLE_WLOCK(); SLIST_REMOVE(&lltables, llt, lltable, llt_link); - IFNET_WUNLOCK(); + LLTABLE_WUNLOCK(); for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { @@ -178,7 +179,7 @@ lltable_drain(int af) struct llentry *lle; register int i; - IFNET_RLOCK(); + LLTABLE_RLOCK(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af != af) continue; @@ -192,7 +193,7 @@ lltable_drain(int af) } } } - IFNET_RUNLOCK(); + LLTABLE_RUNLOCK(); } void @@ -200,14 +201,14 @@ lltable_prefix_free(int af, struct socka { struct lltable *llt; - IFNET_RLOCK_NOSLEEP(); + LLTABLE_RLOCK(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, prefix, mask); } - IFNET_RUNLOCK_NOSLEEP(); + LLTABLE_RUNLOCK(); } @@ -230,9 +231,9 @@ lltable_init(struct ifnet *ifp, int af) for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) LIST_INIT(&llt->lle_head[i]); - IFNET_WLOCK(); + LLTABLE_WLOCK(); SLIST_INSERT_HEAD(&lltables, llt, llt_link); - IFNET_WUNLOCK(); + LLTABLE_WUNLOCK(); return (llt); } @@ -300,13 +301,13 @@ lla_rt_output(struct rt_msghdr *rtm, str } /* XXX linked list may be too expensive */ - IFNET_RLOCK_NOSLEEP(); + LLTABLE_RLOCK(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; } - IFNET_RUNLOCK_NOSLEEP(); + LLTABLE_RUNLOCK(); KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); if (flags && LLE_CREATE) Modified: stable/8/sys/net/if_llatbl.h ============================================================================== --- stable/8/sys/net/if_llatbl.h Fri Aug 28 21:07:43 2009 (r196629) +++ stable/8/sys/net/if_llatbl.h Fri Aug 28 21:10:26 2009 (r196630) @@ -41,6 +41,13 @@ struct rt_addrinfo; struct llentry; LIST_HEAD(llentries, llentry); +extern struct rwlock lltable_rwlock; +#define LLTABLE_RLOCK() rw_rlock(&lltable_rwlock) +#define LLTABLE_RUNLOCK() rw_runlock(&lltable_rwlock) +#define LLTABLE_WLOCK() rw_wlock(&lltable_rwlock) +#define LLTABLE_WUNLOCK() rw_wunlock(&lltable_rwlock) +#define LLTABLE_LOCK_ASSERT() rw_assert(&lltable_rwlock, RA_LOCKED) + /* * Code referencing llentry must at least hold * a shared lock Modified: stable/8/sys/netinet/in.c ============================================================================== --- stable/8/sys/netinet/in.c Fri Aug 28 21:07:43 2009 (r196629) +++ stable/8/sys/netinet/in.c Fri Aug 28 21:10:26 2009 (r196630) @@ -1407,7 +1407,7 @@ in_lltable_dump(struct lltable *llt, str } arpc; int error, i; - IFNET_RLOCK_ASSERT(); + LLTABLE_LOCK_ASSERT(); error = 0; for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { Modified: stable/8/sys/netinet6/in6.c ============================================================================== --- stable/8/sys/netinet6/in6.c Fri Aug 28 21:07:43 2009 (r196629) +++ stable/8/sys/netinet6/in6.c Fri Aug 28 21:10:26 2009 (r196630) @@ -2495,7 +2495,7 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; - IFNET_RLOCK_ASSERT(); + LLTABLE_LOCK_ASSERT(); error = 0; for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 21:12:39 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51C0F106566B; Fri, 28 Aug 2009 21:12:39 +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 3987E8FC1E; Fri, 28 Aug 2009 21:12:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SLCdiJ036720; Fri, 28 Aug 2009 21:12:39 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SLCdeP036718; Fri, 28 Aug 2009 21:12:39 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282112.n7SLCdeP036718@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 21:12:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196631 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 21:12:39 -0000 Author: rwatson Date: Fri Aug 28 21:12:38 2009 New Revision: 196631 URL: http://svn.freebsd.org/changeset/base/196631 Log: Merge r196553 from head to stable/8: Break out allocation of new ifindex values from if_alloc() and if_vmove(), and centralize in a single function ifindex_alloc(). Assert the IFNET_WLOCK, and add missing IFNET_WLOCK in if_alloc(). This does not close all known races in this code. Reviewed by: bz Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Fri Aug 28 21:10:26 2009 (r196630) +++ stable/8/sys/net/if.c Fri Aug 28 21:12:38 2009 (r196631) @@ -223,6 +223,37 @@ ifnet_byindex_ref(u_short idx) return (ifp); } +/* + * Allocate an ifindex array entry; return 0 on success or an error on + * failure. + */ +static int +ifindex_alloc(u_short *idxp) +{ + u_short idx; + + IFNET_WLOCK_ASSERT(); + + /* + * Try to find an empty slot below if_index. If we fail, take the + * next slot. + */ + for (idx = 1; idx <= V_if_index; idx++) { + if (ifnet_byindex_locked(idx) == NULL) + break; + } + + /* Catch if_index overflow. */ + if (idx < 1) + return (ENOSPC); + if (idx > V_if_index) + V_if_index = idx; + if (V_if_index >= V_if_indexlim) + if_grow(); + *idxp = idx; + return (0); +} + static void ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp) { @@ -335,32 +366,19 @@ struct ifnet * if_alloc(u_char type) { struct ifnet *ifp; + u_short idx; ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); - - /* - * Try to find an empty slot below if_index. If we fail, take - * the next slot. - * - * XXX: should be locked! - */ - for (ifp->if_index = 1; ifp->if_index <= V_if_index; ifp->if_index++) { - if (ifnet_byindex(ifp->if_index) == NULL) - break; - } - /* Catch if_index overflow. */ - if (ifp->if_index < 1) { + IFNET_WLOCK(); + if (ifindex_alloc(&idx) != 0) { + IFNET_WUNLOCK(); free(ifp, M_IFNET); return (NULL); } - if (ifp->if_index > V_if_index) - V_if_index = ifp->if_index; - if (V_if_index >= V_if_indexlim) - if_grow(); - + IFNET_WUNLOCK(); + ifp->if_index = idx; ifp->if_type = type; ifp->if_alloctype = type; - if (if_com_alloc[type] != NULL) { ifp->if_l2com = if_com_alloc[type](type, ifp); if (ifp->if_l2com == NULL) { @@ -882,6 +900,7 @@ if_detach_internal(struct ifnet *ifp, in void if_vmove(struct ifnet *ifp, struct vnet *new_vnet) { + u_short idx; /* * Detach from current vnet, but preserve LLADDR info, do not @@ -907,23 +926,12 @@ if_vmove(struct ifnet *ifp, struct vnet */ CURVNET_SET_QUIET(new_vnet); - /* - * Try to find an empty slot below if_index. If we fail, take - * the next slot. - */ IFNET_WLOCK(); - for (ifp->if_index = 1; ifp->if_index <= V_if_index; ifp->if_index++) { - if (ifnet_byindex_locked(ifp->if_index) == NULL) - break; - } - /* Catch if_index overflow. */ - if (ifp->if_index < 1) + if (ifindex_alloc(&idx) != 0) { + IFNET_WUNLOCK(); panic("if_index overflow"); - - if (ifp->if_index > V_if_index) - V_if_index = ifp->if_index; - if (V_if_index >= V_if_indexlim) - if_grow(); + } + ifp->if_index = idx; ifnet_setbyindex_locked(ifp->if_index, ifp); IFNET_WUNLOCK(); From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 28 21:14:05 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 437F11065672; Fri, 28 Aug 2009 21:14:05 +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 2FF668FC1C; Fri, 28 Aug 2009 21:14:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7SLE5d6036793; Fri, 28 Aug 2009 21:14:05 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7SLE5m6036791; Fri, 28 Aug 2009 21:14:05 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200908282114.n7SLE5m6036791@svn.freebsd.org> From: Robert Watson Date: Fri, 28 Aug 2009 21:14:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196632 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 21:14:05 -0000 Author: rwatson Date: Fri Aug 28 21:14:04 2009 New Revision: 196632 URL: http://svn.freebsd.org/changeset/base/196632 Log: Merge r196559 from head to stable/8: Add IFNET_HOLD reserved pointer value for the ifindex ifnet array, which allows an index to be reserved for an ifnet without making the ifnet available for management operations. Use this in if_alloc() while the ifnet lock is released between initial index allocation and completion of ifnet initialization. Add ifindex_free() to centralize the implementation of releasing an ifindex value. Use in if_free() and if_vmove(), as well as when releasing a held index in if_alloc(). Reviewed by: bz Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Fri Aug 28 21:12:38 2009 (r196631) +++ stable/8/sys/net/if.c Fri Aug 28 21:14:04 2009 (r196632) @@ -175,6 +175,13 @@ int ifqmaxlen = IFQ_MAXLEN; struct rwlock ifnet_rwlock; struct sx ifnet_sxlock; +/* + * The allocation of network interfaces is a rather non-atomic affair; we + * need to select an index before we are ready to expose the interface for + * use, so will use this pointer value to indicate reservation. + */ +#define IFNET_HOLD (void *)(uintptr_t)(-1) + static if_com_alloc_t *if_com_alloc[256]; static if_com_free_t *if_com_free[256]; @@ -193,6 +200,8 @@ ifnet_byindex_locked(u_short idx) if (idx > V_if_index) return (NULL); + if (V_ifindex_table[idx].ife_ifnet == IFNET_HOLD) + return (NULL); return (V_ifindex_table[idx].ife_ifnet); } @@ -228,18 +237,18 @@ ifnet_byindex_ref(u_short idx) * failure. */ static int -ifindex_alloc(u_short *idxp) +ifindex_alloc_locked(u_short *idxp) { u_short idx; IFNET_WLOCK_ASSERT(); /* - * Try to find an empty slot below if_index. If we fail, take the + * Try to find an empty slot below V_if_index. If we fail, take the * next slot. */ for (idx = 1; idx <= V_if_index; idx++) { - if (ifnet_byindex_locked(idx) == NULL) + if (V_ifindex_table[idx].ife_ifnet == NULL) break; } @@ -255,6 +264,27 @@ ifindex_alloc(u_short *idxp) } static void +ifindex_free_locked(u_short idx) +{ + + IFNET_WLOCK_ASSERT(); + + V_ifindex_table[idx].ife_ifnet = NULL; + while (V_if_index > 0 && + V_ifindex_table[V_if_index].ife_ifnet == NULL) + V_if_index--; +} + +static void +ifindex_free(u_short idx) +{ + + IFNET_WLOCK(); + ifindex_free_locked(idx); + IFNET_WUNLOCK(); +} + +static void ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp) { @@ -370,11 +400,12 @@ if_alloc(u_char type) ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); IFNET_WLOCK(); - if (ifindex_alloc(&idx) != 0) { + if (ifindex_alloc_locked(&idx) != 0) { IFNET_WUNLOCK(); free(ifp, M_IFNET); return (NULL); } + ifnet_setbyindex_locked(idx, IFNET_HOLD); IFNET_WUNLOCK(); ifp->if_index = idx; ifp->if_type = type; @@ -383,6 +414,7 @@ if_alloc(u_char type) ifp->if_l2com = if_com_alloc[type](type, ifp); if (ifp->if_l2com == NULL) { free(ifp, M_IFNET); + ifindex_free(idx); return (NULL); } } @@ -421,9 +453,7 @@ if_free_internal(struct ifnet *ifp) KASSERT(ifp == ifnet_byindex_locked(ifp->if_index), ("%s: freeing unallocated ifnet", ifp->if_xname)); - ifnet_setbyindex_locked(ifp->if_index, NULL); - while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL) - V_if_index--; + ifindex_free_locked(ifp->if_index); IFNET_WUNLOCK(); if (if_com_free[ifp->if_alloctype] != NULL) @@ -916,18 +946,14 @@ if_vmove(struct ifnet *ifp, struct vnet * or we'd lock on one vnet and unlock on another. */ IFNET_WLOCK(); - ifnet_setbyindex_locked(ifp->if_index, NULL); - while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL) - V_if_index--; - IFNET_WUNLOCK(); + ifindex_free_locked(ifp->if_index); /* * Switch to the context of the target vnet. */ CURVNET_SET_QUIET(new_vnet); - IFNET_WLOCK(); - if (ifindex_alloc(&idx) != 0) { + if (ifindex_alloc_locked(&idx) != 0) { IFNET_WUNLOCK(); panic("if_index overflow"); } From owner-svn-src-stable-8@FreeBSD.ORG Sat Aug 29 04:15:37 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 755E7106564A; Sat, 29 Aug 2009 04:15:37 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 62B148FC17; Sat, 29 Aug 2009 04:15:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7T4FbJv045534; Sat, 29 Aug 2009 04:15:37 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7T4FbQK045532; Sat, 29 Aug 2009 04:15:37 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <200908290415.n7T4FbQK045532@svn.freebsd.org> From: Brian Somers Date: Sat, 29 Aug 2009 04:15:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196639 - stable/8/usr.sbin/ppp X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 04:15:37 -0000 Author: brian Date: Sat Aug 29 04:15:37 2009 New Revision: 196639 URL: http://svn.freebsd.org/changeset/base/196639 Log: MFC r196530: Document that ppp handles pipe(2) descriptors specially in -direct mode. Approved by: re (kib) Modified: stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/ppp/ppp.8.m4 Modified: stable/8/usr.sbin/ppp/ppp.8.m4 ============================================================================== --- stable/8/usr.sbin/ppp/ppp.8.m4 Sat Aug 29 03:17:24 2009 (r196638) +++ stable/8/usr.sbin/ppp/ppp.8.m4 Sat Aug 29 04:15:37 2009 (r196639) @@ -27,7 +27,7 @@ changecom(,)dnl .\" .\" $FreeBSD$ .\" -.Dd May 24, 2007 +.Dd August 25, 2009 .Dt PPP 8 .Os .Sh NAME @@ -171,6 +171,17 @@ If callback is configured, will use the .Dq set device information when dialing back. +.Pp +When run in +.Fl direct +mode, +.Nm +will behave slightly differently if descriptor 0 was created by +.Xr pipe 2 . +As pipes are not bi-directional, ppp will redirect all writes to descriptor +1 (standard output), leaving only reads acting on descriptor 0. +No special action is taken if descriptor 0 was created by +.Xr socketpair 2 . .It Fl dedicated This option is designed for machines connected with a dedicated wire. @@ -6055,6 +6066,8 @@ This socket is used to pass links betwee .Xr tcpdump 1 , .Xr telnet 1 , .Xr kldload 2 , +.Xr pipe 2 , +.Xr socketpair 2 , ifdef({LOCALNAT},{},{.Xr libalias 3 , })dnl ifdef({LOCALRAD},{},{.Xr libradius 3 , From owner-svn-src-stable-8@FreeBSD.ORG Sat Aug 29 15:21:50 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2097106566C; Sat, 29 Aug 2009 15:21:50 +0000 (UTC) (envelope-from simon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A63038FC0A; Sat, 29 Aug 2009 15:21:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7TFLo7v067796; Sat, 29 Aug 2009 15:21:50 GMT (envelope-from simon@svn.freebsd.org) Received: (from simon@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7TFLo0D067791; Sat, 29 Aug 2009 15:21:50 GMT (envelope-from simon@svn.freebsd.org) Message-Id: <200908291521.n7TFLo0D067791@svn.freebsd.org> From: "Simon L. Nielsen" Date: Sat, 29 Aug 2009 15:21:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196641 - in stable/8/crypto/openssl: . crypto/pqueue ssl X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 15:21:50 -0000 Author: simon Date: Sat Aug 29 15:21:50 2009 New Revision: 196641 URL: http://svn.freebsd.org/changeset/base/196641 Log: MFC r196474: Merge DTLS fixes from vendor-crypto/openssl/dist: - Fix memory consumption bug with "future epoch" DTLS records. - Fix fragment handling memory leak. - Do not access freed data structure. - Fix DTLS fragment bug - out-of-sequence message handling which could result in NULL pointer dereference in dtls1_process_out_of_seq_message(). Note that this will not get FreeBSD Security Advisory as DTLS is experimental in OpenSSL. Security: CVE-2009-1377 CVE-2009-1378 CVE-2009-1379 CVE-2009-1387 Approved by: re (kib) Modified: stable/8/crypto/openssl/ (props changed) stable/8/crypto/openssl/crypto/pqueue/pqueue.c stable/8/crypto/openssl/crypto/pqueue/pqueue.h stable/8/crypto/openssl/ssl/d1_both.c stable/8/crypto/openssl/ssl/d1_pkt.c Modified: stable/8/crypto/openssl/crypto/pqueue/pqueue.c ============================================================================== --- stable/8/crypto/openssl/crypto/pqueue/pqueue.c Sat Aug 29 13:28:02 2009 (r196640) +++ stable/8/crypto/openssl/crypto/pqueue/pqueue.c Sat Aug 29 15:21:50 2009 (r196641) @@ -234,3 +234,17 @@ pqueue_next(pitem **item) return ret; } + +int +pqueue_size(pqueue_s *pq) +{ + pitem *item = pq->items; + int count = 0; + + while(item != NULL) + { + count++; + item = item->next; + } + return count; +} Modified: stable/8/crypto/openssl/crypto/pqueue/pqueue.h ============================================================================== --- stable/8/crypto/openssl/crypto/pqueue/pqueue.h Sat Aug 29 13:28:02 2009 (r196640) +++ stable/8/crypto/openssl/crypto/pqueue/pqueue.h Sat Aug 29 15:21:50 2009 (r196641) @@ -91,5 +91,6 @@ pitem *pqueue_iterator(pqueue pq); pitem *pqueue_next(piterator *iter); void pqueue_print(pqueue pq); +int pqueue_size(pqueue pq); #endif /* ! HEADER_PQUEUE_H */ Modified: stable/8/crypto/openssl/ssl/d1_both.c ============================================================================== --- stable/8/crypto/openssl/ssl/d1_both.c Sat Aug 29 13:28:02 2009 (r196640) +++ stable/8/crypto/openssl/ssl/d1_both.c Sat Aug 29 15:21:50 2009 (r196641) @@ -519,6 +519,7 @@ dtls1_retrieve_buffered_fragment(SSL *s, if ( s->d1->handshake_read_seq == frag->msg_header.seq) { + unsigned long frag_len = frag->msg_header.frag_len; pqueue_pop(s->d1->buffered_messages); al=dtls1_preprocess_fragment(s,&frag->msg_header,max); @@ -536,7 +537,7 @@ dtls1_retrieve_buffered_fragment(SSL *s, if (al==0) { *ok = 1; - return frag->msg_header.frag_len; + return frag_len; } ssl3_send_alert(s,SSL3_AL_FATAL,al); @@ -561,7 +562,16 @@ dtls1_process_out_of_seq_message(SSL *s, if ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len) goto err; - if (msg_hdr->seq <= s->d1->handshake_read_seq) + /* Try to find item in queue, to prevent duplicate entries */ + pq_64bit_init(&seq64); + pq_64bit_assign_word(&seq64, msg_hdr->seq); + item = pqueue_find(s->d1->buffered_messages, seq64); + pq_64bit_free(&seq64); + + /* Discard the message if sequence number was already there, is + * too far in the future or the fragment is already in the queue */ + if (msg_hdr->seq <= s->d1->handshake_read_seq || + msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL) { unsigned char devnull [256]; @@ -575,30 +585,31 @@ dtls1_process_out_of_seq_message(SSL *s, } } - frag = dtls1_hm_fragment_new(frag_len); - if ( frag == NULL) - goto err; + if (frag_len) + { + frag = dtls1_hm_fragment_new(frag_len); + if ( frag == NULL) + goto err; - memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); + memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); - if (frag_len) - { - /* read the body of the fragment (header has already been read */ + /* read the body of the fragment (header has already been read) */ i = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE, frag->fragment,frag_len,0); if (i<=0 || (unsigned long)i!=frag_len) goto err; - } - pq_64bit_init(&seq64); - pq_64bit_assign_word(&seq64, msg_hdr->seq); + pq_64bit_init(&seq64); + pq_64bit_assign_word(&seq64, msg_hdr->seq); - item = pitem_new(seq64, frag); - pq_64bit_free(&seq64); - if ( item == NULL) - goto err; + item = pitem_new(seq64, frag); + pq_64bit_free(&seq64); + if ( item == NULL) + goto err; + + pqueue_insert(s->d1->buffered_messages, item); + } - pqueue_insert(s->d1->buffered_messages, item); return DTLS1_HM_FRAGMENT_RETRY; err: Modified: stable/8/crypto/openssl/ssl/d1_pkt.c ============================================================================== --- stable/8/crypto/openssl/ssl/d1_pkt.c Sat Aug 29 13:28:02 2009 (r196640) +++ stable/8/crypto/openssl/ssl/d1_pkt.c Sat Aug 29 15:21:50 2009 (r196641) @@ -167,6 +167,10 @@ dtls1_buffer_record(SSL *s, record_pqueu DTLS1_RECORD_DATA *rdata; pitem *item; + /* Limit the size of the queue to prevent DOS attacks */ + if (pqueue_size(queue->q) >= 100) + return 0; + rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA)); item = pitem_new(priority, rdata); if (rdata == NULL || item == NULL) From owner-svn-src-stable-8@FreeBSD.ORG Sat Aug 29 15:42:06 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7E69106564A; Sat, 29 Aug 2009 15:42:06 +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 B4B738FC22; Sat, 29 Aug 2009 15:42:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7TFg69i068240; Sat, 29 Aug 2009 15:42:06 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7TFg6On068238; Sat, 29 Aug 2009 15:42:06 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200908291542.n7TFg6On068238@svn.freebsd.org> From: Andrew Thompson Date: Sat, 29 Aug 2009 15:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196642 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/xen/xenpci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 15:42:06 -0000 Author: thompsa Date: Sat Aug 29 15:42:06 2009 New Revision: 196642 URL: http://svn.freebsd.org/changeset/base/196642 Log: MFC r196547 It is possible for all the kthreads to exit (hci modules unloaded) which in turn ends our usb process. This means the proc pointer becomes invalid and will panic if a new kthread is added. Count the number of threads and clear the proc pointer on the last one. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/usb/usb_process.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/usb_process.c ============================================================================== --- stable/8/sys/dev/usb/usb_process.c Sat Aug 29 15:21:50 2009 (r196641) +++ stable/8/sys/dev/usb/usb_process.c Sat Aug 29 15:42:06 2009 (r196642) @@ -64,6 +64,7 @@ #if (__FreeBSD_version >= 800000) static struct proc *usbproc; +static int usb_pcount; #define USB_THREAD_CREATE(f, s, p, ...) \ kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ 0, "usb", __VA_ARGS__) @@ -183,6 +184,11 @@ usb_process(void *arg) up->up_ptr = NULL; cv_signal(&up->up_cv); mtx_unlock(up->up_mtx); +#if (__FreeBSD_version >= 800000) + /* Clear the proc pointer if this is the last thread. */ + if (--usb_pcount == 0) + usbproc = NULL; +#endif USB_THREAD_EXIT(0); } @@ -218,6 +224,9 @@ usb_proc_create(struct usb_process *up, up->up_ptr = NULL; goto error; } +#if (__FreeBSD_version >= 800000) + usb_pcount++; +#endif return (0); error: From owner-svn-src-stable-8@FreeBSD.ORG Sat Aug 29 19:45:04 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07F46106564A; Sat, 29 Aug 2009 19:45:04 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EABF68FC0C; Sat, 29 Aug 2009 19:45:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7TJj31k073009; Sat, 29 Aug 2009 19:45:03 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7TJj3vT073007; Sat, 29 Aug 2009 19:45:03 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <200908291945.n7TJj3vT073007@svn.freebsd.org> From: Doug Barton Date: Sat, 29 Aug 2009 19:45:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196645 - stable/8/etc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 19:45:04 -0000 Author: dougb Date: Sat Aug 29 19:45:03 2009 New Revision: 196645 URL: http://svn.freebsd.org/changeset/base/196645 Log: MFC 196478: Prior to the dire warning about values of network_interfaces other than AUTO the biggest mistake users made was leaving lo0 off the list. Since lo0 is effectively mandatory, check for it and add it to the list if it's not there. MFC 196523: Improve the case test to detect the presence of lo0 in the list of network_interfaces. Submitted by: Christoph Mallon Approved by: re (kib) Modified: stable/8/etc/ (props changed) stable/8/etc/network.subr Modified: stable/8/etc/network.subr ============================================================================== --- stable/8/etc/network.subr Sat Aug 29 18:01:02 2009 (r196644) +++ stable/8/etc/network.subr Sat Aug 29 19:45:03 2009 (r196645) @@ -727,6 +727,13 @@ list_net_interfaces() ;; *) _tmplist="${network_interfaces} ${cloned_interfaces}" + + # lo0 is effectively mandatory, so help prevent foot-shooting + # + case "$_tmplist" in + lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing + *) _tmplist="lo0 ${_tmplist}" ;; + esac ;; esac