From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 05:12:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C73C2106564A; Mon, 19 Sep 2011 05:12:53 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B5AFC8FC0A; Mon, 19 Sep 2011 05:12:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8J5CrFq064600; Mon, 19 Sep 2011 05:12:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8J5CrX2064588; Mon, 19 Sep 2011 05:12:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201109190512.p8J5CrX2064588@svn.freebsd.org> From: Josh Paetzel Date: Mon, 19 Sep 2011 05:12:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225657 - in head/usr.sbin/pc-sysinstall: backend backend-partmanager examples X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 05:12:54 -0000 Author: jpaetzel Date: Mon Sep 19 05:12:53 2011 New Revision: 225657 URL: http://svn.freebsd.org/changeset/base/225657 Log: Fix a logic bug in pc-sysinstall creating partitions. Improve exit when an error occurs. Fix parsing to grab values which contain extra '=' signs. Fix a bug setting the timezone properly. Fix a usage bug when setting up with gmirror. Allow a uzip file from local media to be used. Allow specifying flags for "newfs" when using UFS as the file system. Run custom commands after doing final cleanup / fstab generation and such. Also fix using relative path for config file. Approved by: re (bz) Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh head/usr.sbin/pc-sysinstall/backend/functions-localize.sh head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh head/usr.sbin/pc-sysinstall/backend/functions-parse.sh head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh head/usr.sbin/pc-sysinstall/backend/functions.sh head/usr.sbin/pc-sysinstall/backend/parseconfig.sh head/usr.sbin/pc-sysinstall/examples/README Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -90,7 +90,7 @@ if [ $? -eq 0 -a "${SLICENUM}" = "1" ] ; fi # If we have a starting block, use it -if [ -z "$STARTBLOCK" ] ; then +if [ -n "$STARTBLOCK" ] ; then sBLOCK="-b $STARTBLOCK" fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -45,7 +45,6 @@ check_for_enc_pass() }; # On check on the disk-label line if we have any extra vars for this device -# Only enabled for ZFS devices now, may add other xtra options in future for other FS's get_fs_line_xvars() { ACTIVEDEV="${1}" @@ -76,6 +75,15 @@ get_fs_line_xvars() return fi # End of ZFS block + # See if we are looking for UFS specific newfs options + echo $LINE | grep -q '^UFS' 2>/dev/null + if [ $? -eq 0 ] ; then + FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" + VAR="${FSVARS}" + export VAR + return + fi + fi # End of xtra-options block # If we got here, set VAR to empty and export @@ -278,7 +286,7 @@ setup_gpart_partitions() # Check if using zfs mirror echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null - if [ $? -eq 0 ] ; then + if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -554,7 +554,7 @@ init_gmirror() local _mDisk=$3 # Create this mirror device - rc_halt "gmirror label -vb ${_mBal} gm${_mNum} /dev/${_mDisk}" + rc_halt "gmirror label -vb ${_mBal} gm${_mNum} ${_mDisk}" sleep 3 Modified: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -55,6 +55,10 @@ start_extract_uzip_tar() case ${PACKAGETYPE} in uzip) + if ! kldstat -v | grep -q "geom_uzip" ; then + exit_err "Kernel module geom_uzip not loaded" + fi + # Start by mounting the uzip image MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` mkdir -p ${FSMNT}.uzip @@ -435,6 +439,16 @@ init_extraction() rsync) start_rsync_copy ;; image) start_image_install ;; + local) + get_value_from_cfg localPath + if [ -z "$VAL" ] + then + exit_err "Install medium was set to local, but no localPath was provided!" + fi + LOCALPATH=$VAL + INSFILE="${LOCALPATH}/${INSFILE}" ; export INSFILE + start_extract_uzip_tar + ;; *) exit_err "ERROR: Unknown install medium" ;; esac Modified: head/usr.sbin/pc-sysinstall/backend/functions-localize.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-localize.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-localize.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -509,7 +509,7 @@ run_localize() # Check if we need to set a timezone - echo $line | -q grep "^timeZone=" 2>/dev/null + echo $line | grep -q "^timeZone=" 2>/dev/null if [ $? -eq 0 ] ; then get_value_from_string "$line" set_timezone "$VAL" Modified: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -138,7 +138,7 @@ setup_filesystems() UFS) echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" sleep 2 - rc_halt "newfs ${PARTDEV}${EXT}" + rc_halt "newfs ${PARTXTRAOPTS} ${PARTDEV}${EXT}" sleep 2 rc_halt "sync" rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" @@ -154,7 +154,7 @@ setup_filesystems() UFS+S) echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" sleep 2 - rc_halt "newfs -U ${PARTDEV}${EXT}" + rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}" sleep 2 rc_halt "sync" rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" @@ -169,7 +169,7 @@ setup_filesystems() UFS+SUJ) echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" sleep 2 - rc_halt "newfs -U ${PARTDEV}${EXT}" + rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}" sleep 2 rc_halt "sync" rc_halt "tunefs -j enable ${PARTDEV}${EXT}" @@ -192,7 +192,7 @@ setup_filesystems() sleep 2 rc_halt "gjournal label -f ${PARTDEV}${EXT}" sleep 2 - rc_halt "newfs -O 2 -J ${PARTDEV}${EXT}.journal" + rc_halt "newfs ${PARTXTRAOPTS} -O 2 -J ${PARTDEV}${EXT}.journal" sleep 2 rc_halt "sync" rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal" Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -33,7 +33,7 @@ get_value_from_string() { if [ -n "${1}" ] then - export VAL="`echo ${1} | cut -d '=' -f 2`" + export VAL="`echo ${1} | cut -d '=' -f 2-15`" else echo "Error: Did we forgot to supply a string to parse?" exit 1 @@ -45,7 +45,7 @@ get_value_from_cfg_with_spaces() { if [ -n "${1}" ] then - export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15` else exit_err "Error: Did we forgot to supply a setting to grab?" fi @@ -57,7 +57,7 @@ get_value_from_cfg() { if [ -n "${1}" ] then - export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15 | tr -d ' '` else exit_err "Error: Did we forgot to supply a setting to grab?" fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -176,35 +176,35 @@ unmount_all_filesystems_failure() then if [ "${PARTENC}" = "ON" ] then - rc_nohalt "swapoff ${PARTDEV}.eli" + swapoff ${PARTDEV}.eli >/dev/null 2>/dev/null else - rc_nohalt "swapoff ${PARTDEV}" + swapoff ${PARTDEV} >/dev/null 2>/dev/null fi fi # Check if we've found "/" again, don't need to mount it twice if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] then - rc_nohalt "umount -f ${PARTDEV}" - rc_nohalt "umount -f ${FSMNT}${PARTMNT}" + umount -f ${PARTDEV} >/dev/null 2>/dev/null + umount -f ${FSMNT}${PARTMNT} >/dev/null 2>/dev/null fi done # Last lets the /mnt partition ######################################################### - rc_nohalt "umount -f ${FSMNT}" + umount -f ${FSMNT} >/dev/null 2>/dev/null fi else # We are doing a upgrade, try unmounting any of these filesystems - chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT} - umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT} - umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT} - umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} - rc_nohalt "sh ${TMPDIR}/.upgrade-unmount" + chroot ${FSMNT} /sbin/umount -a >/dev/null 2>/dev/null + umount -f ${FSMNT}/usr >/dev/null 2>/dev/null + umount -f ${FSMNT}/dev >/dev/null 2>/dev/null + umount -f ${FSMNT} >/dev/null 2>/dev/null + sh ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null fi # Unmount our CDMNT - rc_nohalt "umount ${CDMNT}" + umount ${CDMNT} >/dev/null 2>/dev/null }; Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -98,10 +98,10 @@ strip_white_space() exit_err() { # Echo the message for the users benefit - echo "$1" + echo "EXITERROR: $1" # Save this error to the log file - echo "${1}" >>$LOGOUT + echo "EXITERROR: ${1}" >>$LOGOUT # Check if we need to unmount any file-systems after this failure unmount_all_filesystems_failure @@ -446,12 +446,12 @@ install_fresh() # Now add any users setup_users - # Now run any commands specified - run_commands - # Do any last cleanup / setup before unmounting run_final_cleanup + # Now run any commands specified + run_commands + # Unmount and finish up unmount_all_filesystems fi Modified: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/parseconfig.sh Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/backend/parseconfig.sh Mon Sep 19 05:12:53 2011 (r225657) @@ -58,12 +58,8 @@ fi # Set our config file variable CFGF="$1" -# Check the dirname of the provided CFGF and make sure its a full path -DIR="`dirname ${CFGF}`" -if [ "${DIR}" = "." ] -then - CFGF="`pwd`/${CFGF}" -fi +# Resolve any relative pathing +CFGF="`realpath ${CFGF}`" export CFGF # Start by doing a sanity check, which will catch any obvious mistakes in the config @@ -72,7 +68,7 @@ file_sanity_check "installMode installTy # We passed the Sanity check, lets grab some of the universal config settings and store them check_value installMode "fresh upgrade extract" check_value installType "PCBSD FreeBSD" -check_value installMedium "dvd usb ftp rsync image" +check_value installMedium "dvd usb ftp rsync image local" check_value packageType "uzip tar rsync split" if_check_value_exists partition "all s1 s2 s3 s4 free image" if_check_value_exists mirrorbal "load prefer round-robin split" Modified: head/usr.sbin/pc-sysinstall/examples/README ============================================================================== --- head/usr.sbin/pc-sysinstall/examples/README Mon Sep 19 04:08:52 2011 (r225656) +++ head/usr.sbin/pc-sysinstall/examples/README Mon Sep 19 05:12:53 2011 (r225657) @@ -184,7 +184,7 @@ the listing of any additional diskX= dir The following settings specify the partitioning / mount points to setup on the target partition -# disk0-part=UFS+S 500 / +# disk0-part=UFS+S 500 / (-n -o time) # disk0-part=SWAP 2000 none # disk0-part=UFS.eli 500 /usr # encpass=mypass @@ -219,6 +219,12 @@ All sizes are expressed in MegaBytes Specifying a size 0 instructs pc-sysinstall to use the rest of the available slice size, and should only be used for the last partition / mount +When using "UFS" and its various types, it is possible to specify custom options +for newfs using (). For examplei: +disk0-part=UFS+SUJ 1000 / (-o time) +In this case "-o time" would be passed to newfs when creating the "/" filesystem. + + When using "ZFS" specifically, it is possible to specify additional disks / partitions to include in the zpool. By using the syntax: (mirror: ad1,ad2) or (raidz: ad1,ad2), it is possible to include the disk "ad1" into the zpool for this partition, using the raidz / mirror methods. From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 08:52:07 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65A441065672; Mon, 19 Sep 2011 08:52:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53E5D8FC1A; Mon, 19 Sep 2011 08:52:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8J8q7Hx071270; Mon, 19 Sep 2011 08:52:07 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8J8q7RO071262; Mon, 19 Sep 2011 08:52:07 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201109190852.p8J8q7RO071262@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 19 Sep 2011 08:52:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225659 - head/lib/libusb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 08:52:07 -0000 Author: hselasky Date: Mon Sep 19 08:52:06 2011 New Revision: 225659 URL: http://svn.freebsd.org/changeset/base/225659 Log: Implement missing USB debug information functions. Approved by: re (kib) MFC after: 1 week Modified: head/lib/libusb/Makefile head/lib/libusb/libusb.3 head/lib/libusb/libusb.h head/lib/libusb/libusb10.c head/lib/libusb/libusb20.3 head/lib/libusb/libusb20.c head/lib/libusb/libusb20.h Modified: head/lib/libusb/Makefile ============================================================================== --- head/lib/libusb/Makefile Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/Makefile Mon Sep 19 08:52:06 2011 (r225659) @@ -40,6 +40,7 @@ CFLAGS+= -DCOMPAT_32BIT MLINKS += libusb.3 libusb_init.3 MLINKS += libusb.3 libusb_exit.3 MLINKS += libusb.3 libusb_strerror.3 +MLINKS += libusb.3 libusb_error_name.3 MLINKS += libusb.3 libusb_set_debug.3 MLINKS += libusb.3 libusb_get_device_list.3 MLINKS += libusb.3 libusb_free_device_list.3 @@ -210,3 +211,5 @@ MLINKS += libusb20.3 libusb20_me_get_2.3 MLINKS += libusb20.3 libusb20_me_encode.3 MLINKS += libusb20.3 libusb20_me_decode.3 MLINKS += libusb20.3 libusb20_desc_foreach.3 +MLINKS += libusb20.3 libusb20_strerror.3 +MLINKS += libusb20.3 libusb20_error_name.3 Modified: head/lib/libusb/libusb.3 ============================================================================== --- head/lib/libusb/libusb.3 Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb.3 Mon Sep 19 08:52:06 2011 (r225659) @@ -63,6 +63,14 @@ Other libusb routines may not be called Get the ASCII representation of the error given by the .Fa code argument. +This function does not return NULL. +.Pp +.Ft const char * +.Fn libusb_error_name "int code" +Get the ASCII representation of the error enum given by the +.Fa code +argument. +This function does not return NULL. .Pp .Ft void .Fn libusb_set_debug "libusb_context *ctx" "int level" @@ -502,7 +510,8 @@ The library is also compliant with LibUS .Sh SEE ALSO .Xr libusb20 3 , .Xr usb 4 , -.Xr usbconfig 8 +.Xr usbconfig 8 , +.Xr usbdump 8 .Pp .Pa http://libusb.sourceforge.net/ .Sh HISTORY Modified: head/lib/libusb/libusb.h ============================================================================== --- head/lib/libusb/libusb.h Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb.h Mon Sep 19 08:52:06 2011 (r225659) @@ -303,6 +303,7 @@ typedef struct libusb_transfer { void libusb_set_debug(libusb_context * ctx, int level); const char *libusb_strerror(int code); +const char *libusb_error_name(int code); int libusb_init(libusb_context ** context); void libusb_exit(struct libusb_context *ctx); Modified: head/lib/libusb/libusb10.c ============================================================================== --- head/lib/libusb/libusb10.c Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb10.c Mon Sep 19 08:52:06 2011 (r225659) @@ -1449,6 +1449,73 @@ libusb_le16_to_cpu(uint16_t x) const char * libusb_strerror(int code) { - /* TODO */ - return ("Unknown error"); + switch (code) { + case LIBUSB_SUCCESS: + return ("Success"); + case LIBUSB_ERROR_IO: + return ("I/O error"); + case LIBUSB_ERROR_INVALID_PARAM: + return ("Invalid parameter"); + case LIBUSB_ERROR_ACCESS: + return ("Permissions error"); + case LIBUSB_ERROR_NO_DEVICE: + return ("No device"); + case LIBUSB_ERROR_NOT_FOUND: + return ("Not found"); + case LIBUSB_ERROR_BUSY: + return ("Device busy"); + case LIBUSB_ERROR_TIMEOUT: + return ("Timeout"); + case LIBUSB_ERROR_OVERFLOW: + return ("Overflow"); + case LIBUSB_ERROR_PIPE: + return ("Pipe error"); + case LIBUSB_ERROR_INTERRUPTED: + return ("Interrupted"); + case LIBUSB_ERROR_NO_MEM: + return ("Out of memory"); + case LIBUSB_ERROR_NOT_SUPPORTED: + return ("Not supported"); + case LIBUSB_ERROR_OTHER: + return ("Other error"); + default: + return ("Unknown error"); + } +} + +const char * +libusb_error_name(int code) +{ + switch (code) { + case LIBUSB_SUCCESS: + return ("LIBUSB_SUCCESS"); + case LIBUSB_ERROR_IO: + return ("LIBUSB_ERROR_IO"); + case LIBUSB_ERROR_INVALID_PARAM: + return ("LIBUSB_ERROR_INVALID_PARAM"); + case LIBUSB_ERROR_ACCESS: + return ("LIBUSB_ERROR_ACCESS"); + case LIBUSB_ERROR_NO_DEVICE: + return ("LIBUSB_ERROR_NO_DEVICE"); + case LIBUSB_ERROR_NOT_FOUND: + return ("LIBUSB_ERROR_NOT_FOUND"); + case LIBUSB_ERROR_BUSY: + return ("LIBUSB_ERROR_BUSY"); + case LIBUSB_ERROR_TIMEOUT: + return ("LIBUSB_ERROR_TIMEOUT"); + case LIBUSB_ERROR_OVERFLOW: + return ("LIBUSB_ERROR_OVERFLOW"); + case LIBUSB_ERROR_PIPE: + return ("LIBUSB_ERROR_PIPE"); + case LIBUSB_ERROR_INTERRUPTED: + return ("LIBUSB_ERROR_INTERRUPTED"); + case LIBUSB_ERROR_NO_MEM: + return ("LIBUSB_ERROR_NO_MEM"); + case LIBUSB_ERROR_NOT_SUPPORTED: + return ("LIBUSB_ERROR_NOT_SUPPORTED"); + case LIBUSB_ERROR_OTHER: + return ("LIBUSB_ERROR_OTHER"); + default: + return ("LIBUSB_ERROR_UNKNOWN"); + } } Modified: head/lib/libusb/libusb20.3 ============================================================================== --- head/lib/libusb/libusb20.3 Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb20.3 Mon Sep 19 08:52:06 2011 (r225659) @@ -212,6 +212,10 @@ USB access library (libusb -lusb) .Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded" .Ft "const uint8_t *" .Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc" +.Ft "const char *" +.Fn libusb20_strerror "int code" +.Ft "const char *" +.Fn libusb20_error_name "int code" . . .Sh DESCRIPTION @@ -996,6 +1000,22 @@ The total decoded length is returned. The buffer pointer cannot be NULL. . . +.Sh USB DEBUGGING +.Pp +.Ft const char * +.Fn libusb20_strerror "int code" +Get the ASCII representation of the error given by the +.Fa code +argument. +This function does not return NULL. +.Pp +.Ft const char * +.Fn libusb20_error_name "int code" +Get the ASCII representation of the error enum given by the +.Fa code +argument. +This function does not return NULL. +. .Sh FILES . . @@ -1003,7 +1023,8 @@ The buffer pointer cannot be NULL. .Sh SEE ALSO .Xr usb 4 , .Xr libusb 3 , -.Xr usbconfig 8 +.Xr usbconfig 8 , +.Xr usbdump 8 . . .Sh HISTORY Modified: head/lib/libusb/libusb20.c ============================================================================== --- head/lib/libusb/libusb20.c Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb20.c Mon Sep 19 08:52:06 2011 (r225659) @@ -1244,3 +1244,77 @@ libusb20_be_dequeue_device(struct libusb { TAILQ_REMOVE(&(pbe->usb_devs), pdev, dev_entry); } + +const char * +libusb20_strerror(int code) +{ + switch (code) { + case LIBUSB20_SUCCESS: + return ("Success"); + case LIBUSB20_ERROR_IO: + return ("I/O error"); + case LIBUSB20_ERROR_INVALID_PARAM: + return ("Invalid parameter"); + case LIBUSB20_ERROR_ACCESS: + return ("Permissions error"); + case LIBUSB20_ERROR_NO_DEVICE: + return ("No device"); + case LIBUSB20_ERROR_NOT_FOUND: + return ("Not found"); + case LIBUSB20_ERROR_BUSY: + return ("Device busy"); + case LIBUSB20_ERROR_TIMEOUT: + return ("Timeout"); + case LIBUSB20_ERROR_OVERFLOW: + return ("Overflow"); + case LIBUSB20_ERROR_PIPE: + return ("Pipe error"); + case LIBUSB20_ERROR_INTERRUPTED: + return ("Interrupted"); + case LIBUSB20_ERROR_NO_MEM: + return ("Out of memory"); + case LIBUSB20_ERROR_NOT_SUPPORTED: + return ("Not supported"); + case LIBUSB20_ERROR_OTHER: + return ("Other error"); + default: + return ("Unknown error"); + } +} + +const char * +libusb20_error_name(int code) +{ + switch (code) { + case LIBUSB20_SUCCESS: + return ("LIBUSB20_SUCCESS"); + case LIBUSB20_ERROR_IO: + return ("LIBUSB20_ERROR_IO"); + case LIBUSB20_ERROR_INVALID_PARAM: + return ("LIBUSB20_ERROR_INVALID_PARAM"); + case LIBUSB20_ERROR_ACCESS: + return ("LIBUSB20_ERROR_ACCESS"); + case LIBUSB20_ERROR_NO_DEVICE: + return ("LIBUSB20_ERROR_NO_DEVICE"); + case LIBUSB20_ERROR_NOT_FOUND: + return ("LIBUSB20_ERROR_NOT_FOUND"); + case LIBUSB20_ERROR_BUSY: + return ("LIBUSB20_ERROR_BUSY"); + case LIBUSB20_ERROR_TIMEOUT: + return ("LIBUSB20_ERROR_TIMEOUT"); + case LIBUSB20_ERROR_OVERFLOW: + return ("LIBUSB20_ERROR_OVERFLOW"); + case LIBUSB20_ERROR_PIPE: + return ("LIBUSB20_ERROR_PIPE"); + case LIBUSB20_ERROR_INTERRUPTED: + return ("LIBUSB20_ERROR_INTERRUPTED"); + case LIBUSB20_ERROR_NO_MEM: + return ("LIBUSB20_ERROR_NO_MEM"); + case LIBUSB20_ERROR_NOT_SUPPORTED: + return ("LIBUSB20_ERROR_NOT_SUPPORTED"); + case LIBUSB20_ERROR_OTHER: + return ("LIBUSB20_ERROR_OTHER"); + default: + return ("LIBUSB20_ERROR_UNKNOWN"); + } +} Modified: head/lib/libusb/libusb20.h ============================================================================== --- head/lib/libusb/libusb20.h Mon Sep 19 08:01:21 2011 (r225658) +++ head/lib/libusb/libusb20.h Mon Sep 19 08:52:06 2011 (r225659) @@ -293,6 +293,11 @@ void libusb20_be_dequeue_device(struct l void libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev); void libusb20_be_free(struct libusb20_backend *pbe); +/* USB debugging */ + +const char *libusb20_strerror(int); +const char *libusb20_error_name(int); + #if 0 { /* style */ #endif From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 10:58:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37E99106567C; Mon, 19 Sep 2011 10:58:31 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2735C8FC17; Mon, 19 Sep 2011 10:58:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JAwVC6076947; Mon, 19 Sep 2011 10:58:31 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JAwVv2076945; Mon, 19 Sep 2011 10:58:31 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201109191058.p8JAwVv2076945@svn.freebsd.org> From: Attilio Rao Date: Mon, 19 Sep 2011 10:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225662 - head/sys/dev/coretemp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 10:58:31 -0000 Author: attilio Date: Mon Sep 19 10:58:30 2011 New Revision: 225662 URL: http://svn.freebsd.org/changeset/base/225662 Log: #PROCHOT assertion is sticky after reading the MSR (accordingly with Intel manuals) it must be cleared by writing a 0. Fix that. Sponsored by: Sandvine Incorporated Reported by: rstone Reviewed by: delphij, emaste, rstone Approved by: re (kib) MFC after: 1 week Modified: head/sys/dev/coretemp/coretemp.c Modified: head/sys/dev/coretemp/coretemp.c ============================================================================== --- head/sys/dev/coretemp/coretemp.c Mon Sep 19 10:28:59 2011 (r225661) +++ head/sys/dev/coretemp/coretemp.c Mon Sep 19 10:58:30 2011 (r225662) @@ -384,6 +384,7 @@ coretemp_get_val_sysctl(SYSCTL_HANDLER_A } if (msr & THERM_STATUS_LOG) { + coretemp_clear_thermal_msr(device_get_unit(dev)); sc->sc_throttle_log = 1; /* @@ -424,8 +425,10 @@ coretemp_throttle_log_sysctl(SYSCTL_HAND msr = coretemp_get_thermal_msr(device_get_unit(dev)); sc = device_get_softc(dev); - if (msr & THERM_STATUS_LOG) + if (msr & THERM_STATUS_LOG) { + coretemp_clear_thermal_msr(device_get_unit(dev)); sc->sc_throttle_log = 1; + } val = sc->sc_throttle_log; From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 15:55:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E2D21065672; Mon, 19 Sep 2011 15:55:53 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7EA558FC08; Mon, 19 Sep 2011 15:55:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JFtruG086398; Mon, 19 Sep 2011 15:55:53 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JFtruR086396; Mon, 19 Sep 2011 15:55:53 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109191555.p8JFtruR086396@svn.freebsd.org> From: Hiroki Sato Date: Mon, 19 Sep 2011 15:55:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225669 - head/etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 15:55:53 -0000 Author: hrs Date: Mon Sep 19 15:55:53 2011 New Revision: 225669 URL: http://svn.freebsd.org/changeset/base/225669 Log: Fix the script order to run rc.d/bridge after the initial network interface configuration and before running network daemons. Approved by: re (kib) Modified: head/etc/rc.d/bridge Modified: head/etc/rc.d/bridge ============================================================================== --- head/etc/rc.d/bridge Mon Sep 19 15:31:12 2011 (r225668) +++ head/etc/rc.d/bridge Mon Sep 19 15:55:53 2011 (r225669) @@ -26,7 +26,8 @@ # # PROVIDE: bridge -# REQUIRE: netif +# REQUIRE: netif faith ppp stf +# BEFORE: SERVERS # KEYWORD: nojail . /etc/rc.subr From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 15:56:50 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A31D31065670; Mon, 19 Sep 2011 15:56:50 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 93B008FC14; Mon, 19 Sep 2011 15:56:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JFuoVX086463; Mon, 19 Sep 2011 15:56:50 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JFuoLf086461; Mon, 19 Sep 2011 15:56:50 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109191556.p8JFuoLf086461@svn.freebsd.org> From: Hiroki Sato Date: Mon, 19 Sep 2011 15:56:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225670 - head/etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 15:56:50 -0000 Author: hrs Date: Mon Sep 19 15:56:50 2011 New Revision: 225670 URL: http://svn.freebsd.org/changeset/base/225670 Log: Use resolvconf(8) to create /etc/resolv.conf, not directly overwrite it. Approved by: re (kib) Modified: head/etc/rc.d/resolv Modified: head/etc/rc.d/resolv ============================================================================== --- head/etc/rc.d/resolv Mon Sep 19 15:55:53 2011 (r225669) +++ head/etc/rc.d/resolv Mon Sep 19 15:56:50 2011 (r225670) @@ -28,7 +28,7 @@ # # PROVIDE: resolv -# REQUIRE: netif +# REQUIRE: netif var # KEYWORD: nojail . /etc/rc.subr @@ -41,17 +41,17 @@ load_rc_config $name # if the info is available via dhcp/kenv # build the resolv.conf # -if [ ! -e /etc/resolv.conf -a \ - -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then - > /etc/resolv.conf - +if [ -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then + interface="`/bin/kenv boot.netif.name`" + ( if [ -n "`/bin/kenv dhcp.domain-name 2> /dev/null`" ]; then - echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf + echo domain `/bin/kenv dhcp.domain-name` fi set -- `/bin/kenv dhcp.domain-name-servers` for ns in `IFS=','; echo $*`; do - echo nameserver $ns >> /etc/resolv.conf; + echo nameserver $ns done + ) | /sbin/resolvconf -a ${interface}:dhcp4 fi From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 16:00:56 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 474B5106566C; Mon, 19 Sep 2011 16:00:56 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 36EC98FC12; Mon, 19 Sep 2011 16:00:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JG0u9Q086642; Mon, 19 Sep 2011 16:00:56 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JG0uK6086640; Mon, 19 Sep 2011 16:00:56 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109191600.p8JG0uK6086640@svn.freebsd.org> From: Hiroki Sato Date: Mon, 19 Sep 2011 16:00:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225671 - head/share/man/man5 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 16:00:56 -0000 Author: hrs Date: Mon Sep 19 16:00:55 2011 New Revision: 225671 URL: http://svn.freebsd.org/changeset/base/225671 Log: - Document $ipv6_cpe_wanif. - Emphasize $ipv6_enable and $ipv6_prefer are deprecated. - Add more detail descriptions about $ipv6_activate_all_interfaces. - Add some more examples of $ifconfig_IF_ipv6. - rtsold(8) and rtadvd(8) can be used even when ipv6_gateway_enable=NO now. Approved by: re (kib) Modified: head/share/man/man5/rc.conf.5 Modified: head/share/man/man5/rc.conf.5 ============================================================================== --- head/share/man/man5/rc.conf.5 Mon Sep 19 15:56:50 2011 (r225670) +++ head/share/man/man5/rc.conf.5 Mon Sep 19 16:00:55 2011 (r225671) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 19, 2011 +.Dd September 13, 2011 .Dt RC.CONF 5 .Os .Sh NAME @@ -1282,6 +1282,13 @@ ifconfig_ed0_name="net0" ifconfig_net0="inet 192.0.2.1 netmask 0xffffff00" .Ed .It Va ipv6_enable +This variable is deprecated. +Use +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +and +.Va ipv6_activate_all_interfaces +if necessary. +.Pp .Pq Vt bool If the variable is .Dq Li YES , @@ -1292,13 +1299,12 @@ and the .Va ipv6_activate_all_interfaces is defined as .Dq Li YES . -.Pp -This variable is deprecated. Use -.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 -and -.Va ipv6_activate_all_interfaces -if necessary. .It Va ipv6_prefer +This variable is deprecated. +Use +.Va ip6addrctl_policy +instead. +.Pp .Pq Vt bool If the variable is .Dq Li YES , @@ -1311,19 +1317,45 @@ If the variable is the default address selection policy table set by .Xr ip6addrctl 8 will be IPv4-preferred. -.Pp -This variable is deprecated. Use -.Va ip6addrctl_policy -instead. .It Va ipv6_activate_all_interfaces +.Pq Vt bool +This controls initial configuration on IPv6-capable +interfaces with no corresponding +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +variable. +Note that it is not always necessary to set this variable to +.Dq YES +to use IPv6 functionality on +.Fx . +In most cases, just configuring +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +variables works. +.Pp If the variable is .Dq Li NO , -all of interfaces which do not have the corrsponding +all interfaces which do not have a corresponding .Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 variable will be marked as .Dq Li IFDISABLED -for security reason. This means only IPv6 functionality on that interface -is completely disabled. For more details of +at creation. +This means that all of IPv6 functionality on that interface +is completely disabled to enforce a security policy. +If the variable is set to +.Dq YES , +the flag will be cleared on all of the interfaces. +.Pp +In most cases, just defining an +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +for an IPv6-capable interface should be sufficient. +However, if an interface is added dynamically +.Pq by some tunneling protocols such as PPP, for example , +it is often difficult to define the variable in advance. +In such a case, configuring the +.Dq Li IFDISABLED +flag can be disabled by setting this variable to +.Dq YES . +.Pp +For more details of the .Dq Li IFDISABLED flag and keywords .Dq Li inet6 ifdisabled , @@ -1344,6 +1376,47 @@ This is the IPv6 equivalent of .Va network_interfaces . Normally manual configuration of this variable is not needed. .Pp +.It Va ipv6_cpe_wanif +.Pq Vt str +If the variable is set to an interface name, +the +.Xr ifconfig 8 +options +.Dq inet6 -no_radr accept_rtadv +will be added to the specified interface automatically before evaluating +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 , +and two +.Xr sysctl 8 +variables +.Va net.inet6.ip6.rfc6204w3 +and +.Va net.inet6.ip6.no_radr +will be set to 1. +.Pp +This means the specified interface will accept ICMPv6 Router +Advertisement messages on that link and add the discovered +routers into the Default Router List. +While the other interfaces can still accept RA messages if the +.Dq inet6 accept_rtadv +option is specified, adding +routes into the Default Router List will be disabled by +.Dq inet6 no_radr +option by default. +See +.Xr ifconfig 8 +for more details. +.Pp +Note that ICMPv6 Router Advertisement messages will be +accepted even when +.Va net.inet6.ip6.forwarding +is 1 +.Pq packet fowarding is enabled +when +.Va net.inet6.ip6.rfc6204w3 +is set to 1. +.Pp +Default is +.Dq Li NO . .It Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 .Pq Vt str IPv6 functionality on an interface should be configured by @@ -1360,16 +1433,37 @@ ifconfig_ed0_ipv6="inet6 2001:db8:1::1 p ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64" .Ed .Pp +Note that a link-local address will be automatically configured in +addition to the configured global-scope addresses because the IPv6 +specifications require it on each link. +The address is calculated from the MAC address by using an algorithm +defined in +.Rs +.%T "RFC 4862" +.%O "Section 5.3" +.Re +.Pp +If only a link-local address is needed on the interface, +the following configuration can be used: +.Bd -literal +ifconfig_ed0_ipv6="inet6 auto_linklocal" +.Ed +.Pp +A link-local address can also be configured manually. +This is useful for the default router address of an IPv6 router +so that it does not change when the network interface +card is replaced. +For example: +.Bd -literal +ifconfig_ed0_ipv6="inet6 fe80::1 prefixlen 64" +.Ed +.Pp Interfaces that have an .Dq Li inet6 accept_rtadv keyword in .Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 setting will be automatically configured by .Xr rtsol 8 . -Note that this automatic configuration is disabled if the -.Va ipv6_gateway_enable -is set to -.Dq Li YES . .It Va ipv6_prefix_ Ns Aq Ar interface .Pq Vt str If one or more prefixes are defined in @@ -2628,16 +2722,12 @@ If set to run the .Xr rtadvd 8 daemon at boot time. -.Xr rtadvd 8 -will only run if -.Va ipv6_gateway_enable -is also set to -.Dq Li YES . The .Xr rtadvd 8 -utility sends router advertisement packets to the interfaces specified in -.Va rtadvd_interfaces -and should only be enabled with great care. +utility sends ICMPv6 Router Advertisement messages to +the interfaces specified in +.Va rtadvd_interfaces . +This should only be enabled with great care. You may want to fine-tune .Xr rtadvd.conf 5 . .It Va rtadvd_interfaces From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 16:01:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21912106564A; Mon, 19 Sep 2011 16:01:54 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 120168FC0C; Mon, 19 Sep 2011 16:01:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JG1rTW086707; Mon, 19 Sep 2011 16:01:53 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JG1rdd086705; Mon, 19 Sep 2011 16:01:53 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109191601.p8JG1rdd086705@svn.freebsd.org> From: Hiroki Sato Date: Mon, 19 Sep 2011 16:01:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225672 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 16:01:54 -0000 Author: hrs Date: Mon Sep 19 16:01:53 2011 New Revision: 225672 URL: http://svn.freebsd.org/changeset/base/225672 Log: - Document inet6 no_radr flag. - Add descriptions of sysctl(8) variables which can control the default configuration of the inet6 flags. Approved by: re (kib) Modified: head/sbin/ifconfig/ifconfig.8 Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Mon Sep 19 16:00:55 2011 (r225671) +++ head/sbin/ifconfig/ifconfig.8 Mon Sep 19 16:01:53 2011 (r225672) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd July 3, 2011 +.Dd September 13, 2011 .Dt IFCONFIG 8 .Os .Sh NAME @@ -626,12 +626,37 @@ is needed for them: .Bl -tag -width indent .It Cm accept_rtadv Set a flag to enable accepting ICMPv6 Router Advertisement messages. +The +.Xr sysctl 8 +variable +.Va net.inet6.ip6.accept_rtadv +controls whether this flag is set by default or not. .It Cm -accept_rtadv Clear a flag .Cm accept_rtadv . +.It Cm no_radr +Set a flag to control whether routers from which the system accepts +Router Advertisement messages will be added to the Default Router List +or not. +When the +.Cm accept_rtadv +flag is disabled, this flag has no effect. +The +.Xr sysctl 8 +variable +.Va net.inet6.ip6.no_radr +controls whether this flag is set by default or not. +.It Cm -no_radr +Clear a flag +.Cm no_radr . .It Cm auto_linklocal Set a flag to perform automatic link-local address configuration when the interface becomes available. +The +.Xr sysctl 8 +variable +.Va net.inet6.ip6.auto_linklocal +controls whether this flag is set by default or not. .It Cm -auto_linklocal Clear a flag .Cm auto_linklocal . From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 16:10:30 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id E0B72106566B; Mon, 19 Sep 2011 16:10:30 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 172-17-198-245.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id A6F1A14DEC3; Mon, 19 Sep 2011 16:10:29 +0000 (UTC) Message-ID: <4E776973.9000409@FreeBSD.org> Date: Mon, 19 Sep 2011 09:10:27 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0.2) Gecko/20110912 Thunderbird/6.0.2 MIME-Version: 1.0 To: Hiroki Sato References: <201109191555.p8JFtruR086396@svn.freebsd.org> In-Reply-To: <201109191555.p8JFtruR086396@svn.freebsd.org> X-Enigmail-Version: undefined OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, re@FreeBSD.org, svn-src-all@freebsd.org, src-committers@freebsd.org, freebsd-rc@FreeBSD.org Subject: Re: svn commit: r225669 - head/etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 16:10:31 -0000 Please don't add new instances of BEFORE in base rc.d scripts. The proper way to do this is to add bridge to REQUIRE: in SERVERS. The BEFORE method is useful for local/ports rc.d scripts, but it makes debugging of dependency issues more difficult so ideally it should be avoided in the base if it's not absolutely necessary (which it is not here). Thanks, Doug On 09/19/2011 08:55, Hiroki Sato wrote: > Author: hrs > Date: Mon Sep 19 15:55:53 2011 > New Revision: 225669 > URL: http://svn.freebsd.org/changeset/base/225669 > > Log: > Fix the script order to run rc.d/bridge after the initial network > interface configuration and before running network daemons. > > Approved by: re (kib) > > Modified: > head/etc/rc.d/bridge > > Modified: head/etc/rc.d/bridge > ============================================================================== > --- head/etc/rc.d/bridge Mon Sep 19 15:31:12 2011 (r225668) > +++ head/etc/rc.d/bridge Mon Sep 19 15:55:53 2011 (r225669) > @@ -26,7 +26,8 @@ > # > > # PROVIDE: bridge > -# REQUIRE: netif > +# REQUIRE: netif faith ppp stf > +# BEFORE: SERVERS > # KEYWORD: nojail > > . /etc/rc.subr > -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 18:29:15 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84283106564A; Mon, 19 Sep 2011 18:29:15 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 730058FC12; Mon, 19 Sep 2011 18:29:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JITFPJ091403; Mon, 19 Sep 2011 18:29:15 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JITF0Y091400; Mon, 19 Sep 2011 18:29:15 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201109191829.p8JITF0Y091400@svn.freebsd.org> From: Attilio Rao Date: Mon, 19 Sep 2011 18:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225675 - head/sys/sparc64/sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 18:29:15 -0000 Author: attilio Date: Mon Sep 19 18:29:15 2011 New Revision: 225675 URL: http://svn.freebsd.org/changeset/base/225675 Log: It is safe to initialize locks even on early boot (and it is the same thing all the other architectures already do) thus just initialize kernel_pmap in pmap_bootstrap(). Reported by: alc Reviewed by: alc, marius Tested by: flo, marius Approved by: re (kib) MFC after: 1 week Modified: head/sys/sparc64/sparc64/machdep.c head/sys/sparc64/sparc64/pmap.c Modified: head/sys/sparc64/sparc64/machdep.c ============================================================================== --- head/sys/sparc64/sparc64/machdep.c Mon Sep 19 16:28:36 2011 (r225674) +++ head/sys/sparc64/sparc64/machdep.c Mon Sep 19 18:29:15 2011 (r225675) @@ -597,11 +597,6 @@ sparc64_init(caddr_t mdp, u_long o1, u_l wrpr(pil, 0, 0); wrpr(pstate, 0, PSTATE_KERNEL); - /* - * Finish pmap initialization now that we're ready for mutexes. - */ - PMAP_LOCK_INIT(kernel_pmap); - OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1); kdb_init(); Modified: head/sys/sparc64/sparc64/pmap.c ============================================================================== --- head/sys/sparc64/sparc64/pmap.c Mon Sep 19 16:28:36 2011 (r225674) +++ head/sys/sparc64/sparc64/pmap.c Mon Sep 19 18:29:15 2011 (r225675) @@ -671,11 +671,9 @@ pmap_bootstrap(u_int cpu_impl) /* * Initialize the kernel pmap (which is statically allocated). - * NOTE: PMAP_LOCK_INIT() is needed as part of the initialization - * but sparc64 start up is not ready to initialize mutexes yet. - * It is called in machdep.c. */ pm = kernel_pmap; + PMAP_LOCK_INIT(pm); for (i = 0; i < MAXCPU; i++) pm->pm_context[i] = TLB_CTX_KERNEL; CPU_FILL(&pm->pm_active); From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 21:47:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DC6C1065678; Mon, 19 Sep 2011 21:47:21 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2CD608FC15; Mon, 19 Sep 2011 21:47:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JLlLmt097402; Mon, 19 Sep 2011 21:47:21 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JLlL0W097398; Mon, 19 Sep 2011 21:47:21 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201109192147.p8JLlL0W097398@svn.freebsd.org> From: Michael Tuexen Date: Mon, 19 Sep 2011 21:47:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225676 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 21:47:21 -0000 Author: tuexen Date: Mon Sep 19 21:47:20 2011 New Revision: 225676 URL: http://svn.freebsd.org/changeset/base/225676 Log: Cleanup the iterator code, remove code that is never executed. Approved by: re MFC after: 1 month. Modified: head/sys/netinet/sctp_bsd_addr.c head/sys/netinet/sctp_structs.h head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_bsd_addr.c ============================================================================== --- head/sys/netinet/sctp_bsd_addr.c Mon Sep 19 18:29:15 2011 (r225675) +++ head/sys/netinet/sctp_bsd_addr.c Mon Sep 19 21:47:20 2011 (r225676) @@ -74,22 +74,6 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore" /* Global NON-VNET structure that controls the iterator */ struct iterator_control sctp_it_ctl; -static int __sctp_thread_based_iterator_started = 0; - - -static void -sctp_cleanup_itqueue(void) -{ - struct sctp_iterator *it, *nit; - - TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) { - if (it->function_atend != NULL) { - (*it->function_atend) (it->pointer, it->val); - } - TAILQ_REMOVE(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr); - SCTP_FREE(it, SCTP_M_ITER); - } -} void @@ -102,17 +86,11 @@ static void sctp_iterator_thread(void *v) { SCTP_IPI_ITERATOR_WQ_LOCK(); + /* In FreeBSD this thread never terminates. */ while (1) { msleep(&sctp_it_ctl.iterator_running, &sctp_it_ctl.ipi_iterator_wq_mtx, 0, "waiting_for_work", 0); - if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { - SCTP_IPI_ITERATOR_WQ_DESTROY(); - SCTP_ITERATOR_LOCK_DESTROY(); - sctp_cleanup_itqueue(); - __sctp_thread_based_iterator_started = 0; - kthread_exit(); - } sctp_iterator_worker(); } } @@ -120,21 +98,21 @@ sctp_iterator_thread(void *v) void sctp_startup_iterator(void) { - if (__sctp_thread_based_iterator_started) { + static int called = 0; + int ret; + + if (called) { /* You only get one */ return; } /* init the iterator head */ - __sctp_thread_based_iterator_started = 1; + called = 1; sctp_it_ctl.iterator_running = 0; sctp_it_ctl.iterator_flags = 0; sctp_it_ctl.cur_it = NULL; SCTP_ITERATOR_LOCK_INIT(); SCTP_IPI_ITERATOR_WQ_INIT(); TAILQ_INIT(&sctp_it_ctl.iteratorhead); - - int ret; - ret = kproc_create(sctp_iterator_thread, (void *)NULL, &sctp_it_ctl.thread_proc, Modified: head/sys/netinet/sctp_structs.h ============================================================================== --- head/sys/netinet/sctp_structs.h Mon Sep 19 18:29:15 2011 (r225675) +++ head/sys/netinet/sctp_structs.h Mon Sep 19 21:47:20 2011 (r225676) @@ -185,9 +185,8 @@ struct iterator_control { uint32_t iterator_flags; }; -#define SCTP_ITERATOR_MUST_EXIT 0x00000001 -#define SCTP_ITERATOR_STOP_CUR_IT 0x00000002 -#define SCTP_ITERATOR_STOP_CUR_INP 0x00000004 +#define SCTP_ITERATOR_STOP_CUR_IT 0x00000004 +#define SCTP_ITERATOR_STOP_CUR_INP 0x00000008 struct sctp_net_route { sctp_rtentry_t *ro_rt; Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Mon Sep 19 18:29:15 2011 (r225675) +++ head/sys/netinet/sctputil.c Mon Sep 19 21:47:20 2011 (r225676) @@ -1293,10 +1293,6 @@ select_a_new_ep: SCTP_INP_DECR_REF(it->inp); atomic_add_int(&it->stcb->asoc.refcnt, -1); if (sctp_it_ctl.iterator_flags & - SCTP_ITERATOR_MUST_EXIT) { - goto done_with_iterator; - } - if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_STOP_CUR_IT) { sctp_it_ctl.iterator_flags &= ~SCTP_ITERATOR_STOP_CUR_IT; goto done_with_iterator; @@ -1372,9 +1368,6 @@ sctp_iterator_worker(void) sctp_it_ctl.cur_it = NULL; CURVNET_RESTORE(); SCTP_IPI_ITERATOR_WQ_LOCK(); - if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { - break; - } /* sa_ignore FREED_MEMORY */ } sctp_it_ctl.iterator_running = 0; From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 22:35:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64895106566B; Mon, 19 Sep 2011 22:35:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52EF58FC0A; Mon, 19 Sep 2011 22:35:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JMZsrH098942; Mon, 19 Sep 2011 22:35:54 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JMZsop098940; Mon, 19 Sep 2011 22:35:54 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201109192235.p8JMZsop098940@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 19 Sep 2011 22:35:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225677 - head/contrib/tzcode/stdtime X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 22:35:54 -0000 Author: kib Date: Mon Sep 19 22:35:54 2011 New Revision: 225677 URL: http://svn.freebsd.org/changeset/base/225677 Log: Do not overallocate on the stack. Threaded code might use custom stack size. Reported by: many Tested by: Jeremie Le Hen (previous version) Reviewed by: jilles Approved by: re (bz) MFC after: 2 weeks Modified: head/contrib/tzcode/stdtime/localtime.c Modified: head/contrib/tzcode/stdtime/localtime.c ============================================================================== --- head/contrib/tzcode/stdtime/localtime.c Mon Sep 19 21:47:20 2011 (r225676) +++ head/contrib/tzcode/stdtime/localtime.c Mon Sep 19 22:35:54 2011 (r225677) @@ -380,13 +380,16 @@ register const int doextend; int fid; int stored; int nread; + int res; union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + 2 * sizeof *sp + 4 * TZ_MAX_TIMES]; - } u; + } *u; + u = NULL; + res = -1; sp->goback = sp->goahead = FALSE; /* XXX The following is from OpenBSD, and I'm not sure it is correct */ @@ -406,16 +409,24 @@ register const int doextend; ** to hold the longest file name string that the implementation ** guarantees can be opened." */ - char fullname[FILENAME_MAX + 1]; + char *fullname; + + fullname = malloc(FILENAME_MAX + 1); + if (fullname == NULL) + goto out; if (name[0] == ':') ++name; doaccess = name[0] == '/'; if (!doaccess) { - if ((p = TZDIR) == NULL) + if ((p = TZDIR) == NULL) { + free(fullname); return -1; - if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname) + } + if (strlen(p) + 1 + strlen(name) >= FILENAME_MAX) { + free(fullname); return -1; + } (void) strcpy(fullname, p); (void) strcat(fullname, "/"); (void) strcat(fullname, name); @@ -426,37 +437,45 @@ register const int doextend; doaccess = TRUE; name = fullname; } - if (doaccess && access(name, R_OK) != 0) + if (doaccess && access(name, R_OK) != 0) { + free(fullname); return -1; - if ((fid = _open(name, OPEN_MODE)) == -1) + } + if ((fid = _open(name, OPEN_MODE)) == -1) { + free(fullname); return -1; + } if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) { + free(fullname); _close(fid); return -1; } } - nread = _read(fid, u.buf, sizeof u.buf); + u = malloc(sizeof(*u)); + if (u == NULL) + goto out; + nread = _read(fid, u->buf, sizeof u->buf); if (_close(fid) < 0 || nread <= 0) - return -1; + goto out; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; - ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); - ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); - sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); - sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt); - sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt); - sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt); - p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; + ttisstdcnt = (int) detzcode(u->tzhead.tzh_ttisstdcnt); + ttisgmtcnt = (int) detzcode(u->tzhead.tzh_ttisgmtcnt); + sp->leapcnt = (int) detzcode(u->tzhead.tzh_leapcnt); + sp->timecnt = (int) detzcode(u->tzhead.tzh_timecnt); + sp->typecnt = (int) detzcode(u->tzhead.tzh_typecnt); + sp->charcnt = (int) detzcode(u->tzhead.tzh_charcnt); + p = u->tzhead.tzh_charcnt + sizeof u->tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) - return -1; - if (nread - (p - u.buf) < + goto out; + if (nread - (p - u->buf) < sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ sp->typecnt * 6 + /* ttinfos */ @@ -464,7 +483,7 @@ register const int doextend; sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ - return -1; + goto out; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = (stored == 4) ? detzcode(p) : detzcode64(p); @@ -473,7 +492,7 @@ register const int doextend; for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) - return -1; + goto out; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo * ttisp; @@ -483,11 +502,11 @@ register const int doextend; p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; + goto out; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) - return -1; + goto out; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; @@ -512,7 +531,7 @@ register const int doextend; ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) - return -1; + goto out; } } for (i = 0; i < sp->typecnt; ++i) { @@ -525,7 +544,7 @@ register const int doextend; ttisp->tt_ttisgmt = *p++; if (ttisp->tt_ttisgmt != TRUE && ttisp->tt_ttisgmt != FALSE) - return -1; + goto out; } } /* @@ -558,11 +577,11 @@ register const int doextend; /* ** If this is an old file, we're done. */ - if (u.tzhead.tzh_version[0] == '\0') + if (u->tzhead.tzh_version[0] == '\0') break; - nread -= p - u.buf; + nread -= p - u->buf; for (i = 0; i < nread; ++i) - u.buf[i] = p[i]; + u->buf[i] = p[i]; /* ** If this is a narrow integer time_t system, we're done. */ @@ -570,39 +589,43 @@ register const int doextend; break; } if (doextend && nread > 2 && - u.buf[0] == '\n' && u.buf[nread - 1] == '\n' && + u->buf[0] == '\n' && u->buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { - struct state ts; + struct state *ts; register int result; - u.buf[nread - 1] = '\0'; - result = tzparse(&u.buf[1], &ts, FALSE); - if (result == 0 && ts.typecnt == 2 && - sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { + ts = malloc(sizeof(*ts)); + if (ts == NULL) + goto out; + u->buf[nread - 1] = '\0'; + result = tzparse(&u->buf[1], ts, FALSE); + if (result == 0 && ts->typecnt == 2 && + sp->charcnt + ts->charcnt <= TZ_MAX_CHARS) { for (i = 0; i < 2; ++i) - ts.ttis[i].tt_abbrind += + ts->ttis[i].tt_abbrind += sp->charcnt; - for (i = 0; i < ts.charcnt; ++i) + for (i = 0; i < ts->charcnt; ++i) sp->chars[sp->charcnt++] = - ts.chars[i]; + ts->chars[i]; i = 0; - while (i < ts.timecnt && - ts.ats[i] <= + while (i < ts->timecnt && + ts->ats[i] <= sp->ats[sp->timecnt - 1]) ++i; - while (i < ts.timecnt && + while (i < ts->timecnt && sp->timecnt < TZ_MAX_TIMES) { sp->ats[sp->timecnt] = - ts.ats[i]; + ts->ats[i]; sp->types[sp->timecnt] = sp->typecnt + - ts.types[i]; + ts->types[i]; ++sp->timecnt; ++i; } - sp->ttis[sp->typecnt++] = ts.ttis[0]; - sp->ttis[sp->typecnt++] = ts.ttis[1]; + sp->ttis[sp->typecnt++] = ts->ttis[0]; + sp->ttis[sp->typecnt++] = ts->ttis[1]; } + free(ts); } if (sp->timecnt > 1) { for (i = 1; i < sp->timecnt; ++i) @@ -620,7 +643,10 @@ register const int doextend; break; } } - return 0; + res = 0; +out: + free(u); + return (res); } static int From owner-svn-src-head@FreeBSD.ORG Mon Sep 19 22:49:36 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5905106566B; Mon, 19 Sep 2011 22:49:36 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A4B5B8FC08; Mon, 19 Sep 2011 22:49:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8JMnaMQ099384; Mon, 19 Sep 2011 22:49:36 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8JMnasC099382; Mon, 19 Sep 2011 22:49:36 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109192249.p8JMnasC099382@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 19 Sep 2011 22:49:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225678 - head/lib/libc/iconv X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 22:49:36 -0000 Author: gabor Date: Mon Sep 19 22:49:36 2011 New Revision: 225678 URL: http://svn.freebsd.org/changeset/base/225678 Log: - Fix a trivial bug in iconv. When there is no space to perform the conversion, conversion must fail and errno must be set to E2BIG. PR: standards/160673 Submitted by: Henning Petersen Reviewed by: pluknet Approved by: re (kib), delphij (mentor) Modified: head/lib/libc/iconv/citrus_none.c Modified: head/lib/libc/iconv/citrus_none.c ============================================================================== --- head/lib/libc/iconv/citrus_none.c Mon Sep 19 22:35:54 2011 (r225677) +++ head/lib/libc/iconv/citrus_none.c Mon Sep 19 22:49:36 2011 (r225678) @@ -190,7 +190,6 @@ _citrus_NONE_stdenc_wctomb(struct _citru void * __restrict pspriv __unused, size_t * __restrict nresult, struct iconv_hooks *hooks __unused) { - int ret; if ((wc & ~0xFFU) != 0) { *nresult = (size_t)-1; @@ -198,7 +197,7 @@ _citrus_NONE_stdenc_wctomb(struct _citru } if (n == 0) { *nresult = (size_t)-1; - ret = E2BIG; + return (E2BIG); } *nresult = 1; From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 00:29:17 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D1DD106564A; Tue, 20 Sep 2011 00:29:17 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6CE648FC17; Tue, 20 Sep 2011 00:29:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8K0THiU002725; Tue, 20 Sep 2011 00:29:17 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8K0THgP002723; Tue, 20 Sep 2011 00:29:17 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109200029.p8K0THgP002723@svn.freebsd.org> From: Hiroki Sato Date: Tue, 20 Sep 2011 00:29:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225682 - head/sys/netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 00:29:17 -0000 Author: hrs Date: Tue Sep 20 00:29:17 2011 New Revision: 225682 URL: http://svn.freebsd.org/changeset/base/225682 Log: Copy ip6po_minmtu and ip6po_prefer_tempaddr in ip6_copypktopts(). This fixes inconsistency when options are specified by both setsockopt() and ancillary data types. PR: kern/158307 Approved by: re (bz) Modified: head/sys/netinet6/ip6_output.c Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Tue Sep 20 00:23:59 2011 (r225681) +++ head/sys/netinet6/ip6_output.c Tue Sep 20 00:29:17 2011 (r225682) @@ -2367,6 +2367,8 @@ copypktopts(struct ip6_pktopts *dst, str dst->ip6po_hlim = src->ip6po_hlim; dst->ip6po_tclass = src->ip6po_tclass; dst->ip6po_flags = src->ip6po_flags; + dst->ip6po_minmtu = src->ip6po_minmtu; + dst->ip6po_prefer_tempaddr = src->ip6po_prefer_tempaddr; if (src->ip6po_pktinfo) { dst->ip6po_pktinfo = malloc(sizeof(*dst->ip6po_pktinfo), M_IP6OPT, canwait); From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 00:32:30 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 834ED1065675; Tue, 20 Sep 2011 00:32:30 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 72BB18FC08; Tue, 20 Sep 2011 00:32:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8K0WUVp002858; Tue, 20 Sep 2011 00:32:30 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8K0WUqk002856; Tue, 20 Sep 2011 00:32:30 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109200032.p8K0WUqk002856@svn.freebsd.org> From: Hiroki Sato Date: Tue, 20 Sep 2011 00:32:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225683 - head/usr.sbin/rtadvd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 00:32:30 -0000 Author: hrs Date: Tue Sep 20 00:32:30 2011 New Revision: 225683 URL: http://svn.freebsd.org/changeset/base/225683 Log: Remove RA timer on an interface with !IFF_UP actively after starting to send clean-up RA messages for shutting down. The RA timers could prevent the rtadvd daemon from shutting down because ra_output() just ignored !IFF_UP interfaces and TRANSITIVE->UNCONFIGURED state transition never happened due to it. Spotted by: kib Approved by: re (bz) Modified: head/usr.sbin/rtadvd/rtadvd.c Modified: head/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- head/usr.sbin/rtadvd/rtadvd.c Tue Sep 20 00:29:17 2011 (r225682) +++ head/usr.sbin/rtadvd/rtadvd.c Tue Sep 20 00:32:30 2011 (r225683) @@ -381,6 +381,21 @@ rtadvd_shutdown(void) "waiting expiration of the all RA timers."); TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + /* + * Ignore !IFF_UP interfaces in waiting for shutdown. + */ + if (!(ifi->ifi_flags & IFF_UP) && + ifi->ifi_ra_timer != NULL) { + ifi->ifi_state = IFI_STATE_UNCONFIGURED; + rtadvd_remove_timer(ifi->ifi_ra_timer); + ifi->ifi_ra_timer = NULL; + syslog(LOG_DEBUG, "<%s> %s(idx=%d) is down. " + "Timer removed and marked as UNCONFIGURED.", + __func__, ifi->ifi_ifname, + ifi->ifi_ifindex); + } + } + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { if (ifi->ifi_ra_timer != NULL) break; } From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 00:37:35 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB0B11065686; Tue, 20 Sep 2011 00:37:35 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AC868FC19; Tue, 20 Sep 2011 00:37:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8K0bZGt003046; Tue, 20 Sep 2011 00:37:35 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8K0bZ0x003043; Tue, 20 Sep 2011 00:37:35 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201109200037.p8K0bZ0x003043@svn.freebsd.org> From: Hiroki Sato Date: Tue, 20 Sep 2011 00:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225684 - head/etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 00:37:35 -0000 Author: hrs Date: Tue Sep 20 00:37:35 2011 New Revision: 225684 URL: http://svn.freebsd.org/changeset/base/225684 Log: Use REQUIRE: line to reorder rc.d/bridge instead of BEFORE: line. Pointed out by: dougb Approved by: re (bz) Modified: head/etc/rc.d/NETWORKING head/etc/rc.d/bridge Modified: head/etc/rc.d/NETWORKING ============================================================================== --- head/etc/rc.d/NETWORKING Tue Sep 20 00:32:30 2011 (r225683) +++ head/etc/rc.d/NETWORKING Tue Sep 20 00:37:35 2011 (r225684) @@ -5,7 +5,7 @@ # PROVIDE: NETWORKING NETWORK # REQUIRE: netif netoptions routing ppp ipfw stf faith -# REQUIRE: defaultroute routed mrouted route6d mroute6d resolv +# REQUIRE: defaultroute routed mrouted route6d mroute6d resolv bridge # This is a dummy dependency, for services which require networking # to be operational before starting. Modified: head/etc/rc.d/bridge ============================================================================== --- head/etc/rc.d/bridge Tue Sep 20 00:32:30 2011 (r225683) +++ head/etc/rc.d/bridge Tue Sep 20 00:37:35 2011 (r225684) @@ -27,7 +27,6 @@ # PROVIDE: bridge # REQUIRE: netif faith ppp stf -# BEFORE: SERVERS # KEYWORD: nojail . /etc/rc.subr From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 04:30:24 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54862106566C; Tue, 20 Sep 2011 04:30:24 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 450C78FC13; Tue, 20 Sep 2011 04:30:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8K4UOBT010297; Tue, 20 Sep 2011 04:30:24 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8K4UOV3010295; Tue, 20 Sep 2011 04:30:24 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109200430.p8K4UOV3010295@svn.freebsd.org> From: Adrian Chadd Date: Tue, 20 Sep 2011 04:30:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225686 - head/sys/dev/iwn X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 04:30:24 -0000 Author: adrian Date: Tue Sep 20 04:30:23 2011 New Revision: 225686 URL: http://svn.freebsd.org/changeset/base/225686 Log: Manually set the channel when using monitor mode - the firmware doesn't select it automatically. Submitted by: nox Reviewed by: bschmidt Approved by: re PR: kern/160815 Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Tue Sep 20 04:20:55 2011 (r225685) +++ head/sys/dev/iwn/if_iwn.c Tue Sep 20 04:30:23 2011 (r225686) @@ -6952,12 +6952,24 @@ iwn_set_channel(struct ieee80211com *ic) const struct ieee80211_channel *c = ic->ic_curchan; struct ifnet *ifp = ic->ic_ifp; struct iwn_softc *sc = ifp->if_softc; + int error; IWN_LOCK(sc); sc->sc_rxtap.wr_chan_freq = htole16(c->ic_freq); sc->sc_rxtap.wr_chan_flags = htole16(c->ic_flags); sc->sc_txtap.wt_chan_freq = htole16(c->ic_freq); sc->sc_txtap.wt_chan_flags = htole16(c->ic_flags); + + /* + * Only need to set the channel in Monitor mode. AP scanning and auth + * are already taken care of by their respective firmware commands. + */ + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + error = iwn_config(sc); + if (error != 0) + device_printf(sc->sc_dev, + "%s: error %d settting channel\n", __func__, error); + } IWN_UNLOCK(sc); } From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 14:17:58 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9894B1065675; Tue, 20 Sep 2011 14:17:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 887C88FC0A; Tue, 20 Sep 2011 14:17:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8KEHw57031972; Tue, 20 Sep 2011 14:17:58 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8KEHwvZ031970; Tue, 20 Sep 2011 14:17:58 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201109201417.p8KEHwvZ031970@svn.freebsd.org> From: Hans Petter Selasky Date: Tue, 20 Sep 2011 14:17:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225695 - head/sys/dev/usb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 14:17:58 -0000 Author: hselasky Date: Tue Sep 20 14:17:58 2011 New Revision: 225695 URL: http://svn.freebsd.org/changeset/base/225695 Log: Avoid starting the USB transfer if an error is already pending. This change fixes a race in device side mode during clear-stall from host, which can cause data to be sent too early on the given endpoint. Approved by: re (kib) MFC after: 1 week Modified: head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Tue Sep 20 13:04:52 2011 (r225694) +++ head/sys/dev/usb/usb_transfer.c Tue Sep 20 14:17:58 2011 (r225695) @@ -2417,8 +2417,9 @@ usbd_transfer_start_cb(void *arg) #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif - /* start the transfer */ - (ep->methods->start) (xfer); + /* start USB transfer, if no error */ + if (xfer->error == 0) + (ep->methods->start) (xfer); xfer->flags_int.can_cancel_immed = 1; @@ -2597,8 +2598,9 @@ usbd_pipe_start(struct usb_xfer_queue *p #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif - /* start USB transfer */ - (ep->methods->start) (xfer); + /* start USB transfer, if no error */ + if (xfer->error == 0) + (ep->methods->start) (xfer); xfer->flags_int.can_cancel_immed = 1; From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 20:27:26 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89B941065672; Tue, 20 Sep 2011 20:27:26 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6070B8FC15; Tue, 20 Sep 2011 20:27:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8KKRQMW043404; Tue, 20 Sep 2011 20:27:26 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8KKRQfQ043399; Tue, 20 Sep 2011 20:27:26 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201109202027.p8KKRQfQ043399@svn.freebsd.org> From: Kip Macy Date: Tue, 20 Sep 2011 20:27:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225698 - in head/sys: net netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 20:27:26 -0000 Author: kmacy Date: Tue Sep 20 20:27:26 2011 New Revision: 225698 URL: http://svn.freebsd.org/changeset/base/225698 Log: Make KBI changes required for future MFCing of inpcb rtentry / llentry caching. Reviewed by: rwatson, bz Approved by: re (kib) Modified: head/sys/net/if_llatbl.h head/sys/net/radix.h head/sys/net/route.h head/sys/netinet6/in6.h Modified: head/sys/net/if_llatbl.h ============================================================================== --- head/sys/net/if_llatbl.h Tue Sep 20 19:07:56 2011 (r225697) +++ head/sys/net/if_llatbl.h Tue Sep 20 20:27:26 2011 (r225698) @@ -59,6 +59,7 @@ struct llentry { struct rwlock lle_lock; struct lltable *lle_tbl; struct llentries *lle_head; + void (*lle_free)(struct lltable *, struct llentry *); struct mbuf *la_hold; int la_numheld; /* # of packets currently held */ time_t la_expire; Modified: head/sys/net/radix.h ============================================================================== --- head/sys/net/radix.h Tue Sep 20 19:07:56 2011 (r225697) +++ head/sys/net/radix.h Tue Sep 20 20:27:26 2011 (r225698) @@ -105,6 +105,8 @@ typedef int walktree_f_t(struct radix_no struct radix_node_head { struct radix_node *rnh_treetop; + u_int rnh_gen; /* generation counter */ + int rnh_multipath; /* multipath capable ? */ int rnh_addrsize; /* permit, but not require fixed keys */ int rnh_pktsize; /* permit, but not require fixed keys */ struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ @@ -131,8 +133,6 @@ struct radix_node_head { void (*rnh_close) /* do something when the last ref drops */ (struct radix_node *rn, struct radix_node_head *head); struct radix_node rnh_nodes[3]; /* empty tree for common case */ - int rnh_multipath; /* multipath capable ? */ - u_int rnh_spare; /* route caching */ #ifdef _KERNEL struct rwlock rnh_lock; /* locks entire radix tree */ #endif Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Tue Sep 20 19:07:56 2011 (r225697) +++ head/sys/net/route.h Tue Sep 20 20:27:26 2011 (r225698) @@ -49,9 +49,13 @@ struct route { struct rtentry *ro_rt; struct llentry *ro_lle; + struct in_ifaddr *ro_ia; + int ro_flags; struct sockaddr ro_dst; }; +#define RT_CACHING_CONTEXT 0x1 + /* * These numbers are used by reliable protocols for determining * retransmission behavior and are included in the routing structure. Modified: head/sys/netinet6/in6.h ============================================================================== --- head/sys/netinet6/in6.h Tue Sep 20 19:07:56 2011 (r225697) +++ head/sys/netinet6/in6.h Tue Sep 20 20:27:26 2011 (r225698) @@ -376,6 +376,8 @@ extern const struct in6_addr in6addr_lin struct route_in6 { struct rtentry *ro_rt; struct llentry *ro_lle; + struct in6_addr *ro_ia6; + int ro_flags; struct sockaddr_in6 ro_dst; }; #endif From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 21:49:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DC0B1065670; Tue, 20 Sep 2011 21:49:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E06F8FC13; Tue, 20 Sep 2011 21:49:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8KLnttf045998; Tue, 20 Sep 2011 21:49:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8KLnttg045996; Tue, 20 Sep 2011 21:49:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201109202149.p8KLnttg045996@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 20 Sep 2011 21:49:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225699 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 21:49:55 -0000 Author: kib Date: Tue Sep 20 21:49:54 2011 New Revision: 225699 URL: http://svn.freebsd.org/changeset/base/225699 Log: Restore the writing of the .bss sections of the dsos (not the main executable) after r190885. The whole region for the dso is mmaped with MAP_NOCORE flag, doing only mprotect(2) over .bss prevented it from writing .bss to core files. Revert the optimization of using mprotect(2) to establish .bss, overlap the section with mmap(2). Reported by: attilio Reviewed by: attilio, emaste Approved by: re (bz) MFC after: 2 weeks Modified: head/libexec/rtld-elf/map_object.c Modified: head/libexec/rtld-elf/map_object.c ============================================================================== --- head/libexec/rtld-elf/map_object.c Tue Sep 20 20:27:26 2011 (r225698) +++ head/libexec/rtld-elf/map_object.c Tue Sep 20 21:49:54 2011 (r225699) @@ -215,8 +215,9 @@ map_object(int fd, const char *path, con bss_vlimit = round_page(segs[i]->p_vaddr + segs[i]->p_memsz); bss_addr = mapbase + (bss_vaddr - base_vaddr); if (bss_vlimit > bss_vaddr) { /* There is something to do */ - if (mprotect(bss_addr, bss_vlimit - bss_vaddr, data_prot) == -1) { - _rtld_error("%s: mprotect of bss failed: %s", path, + if (mmap(bss_addr, bss_vlimit - bss_vaddr, data_prot, + data_flags | MAP_ANON, -1, 0) == (caddr_t)-1) { + _rtld_error("%s: mmap of bss failed: %s", path, strerror(errno)); return NULL; } From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 21:53:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D39A1065673; Tue, 20 Sep 2011 21:53:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DA028FC14; Tue, 20 Sep 2011 21:53:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8KLrRZI046139; Tue, 20 Sep 2011 21:53:27 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8KLrRK3046137; Tue, 20 Sep 2011 21:53:27 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201109202153.p8KLrRK3046137@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 20 Sep 2011 21:53:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225700 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 21:53:27 -0000 Author: kib Date: Tue Sep 20 21:53:26 2011 New Revision: 225700 URL: http://svn.freebsd.org/changeset/base/225700 Log: Use nowait sync request for a vnode when doing softdep cleanup. We possibly own the unrelated vnode lock, doing waiting sync causes deadlocks. Reported and tested by: pho Approved by: re (bz) Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Tue Sep 20 21:49:54 2011 (r225699) +++ head/sys/ufs/ffs/ffs_softdep.c Tue Sep 20 21:53:26 2011 (r225700) @@ -12648,7 +12648,7 @@ retry: MNT_ILOCK(mp); continue; } - (void) ffs_syncvnode(lvp, MNT_WAIT); + (void) ffs_syncvnode(lvp, MNT_NOWAIT); vput(lvp); MNT_ILOCK(mp); } From owner-svn-src-head@FreeBSD.ORG Tue Sep 20 23:44:35 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BDD1106564A; Tue, 20 Sep 2011 23:44:35 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A33A8FC08; Tue, 20 Sep 2011 23:44:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8KNiZFW049838; Tue, 20 Sep 2011 23:44:35 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8KNiZ9O049832; Tue, 20 Sep 2011 23:44:35 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109202344.p8KNiZ9O049832@svn.freebsd.org> From: "Justin T. Gibbs" Date: Tue, 20 Sep 2011 23:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225704 - in head/sys: dev/xen/control xen/xenbus xen/xenstore X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Sep 2011 23:44:35 -0000 Author: gibbs Date: Tue Sep 20 23:44:34 2011 New Revision: 225704 URL: http://svn.freebsd.org/changeset/base/225704 Log: Properly handle suspend/resume events in the Xen device framework. Sponsored by: BQ Internet sys/xen/xenbus/xenbusb.c: o In xenbusb_resume(), publish the state transition of the resuming device into XenbusStateIntiailising so that the remote peer can see it. Recording the state locally is not sufficient to trigger a re-connect sequence. o In xenbusb_resume(), defer new-bus resume processing until after the remote peer's XenStore address has been updated. The drivers may need to refer to this information during resume processing. sys/xen/xenbus/xenbusb_back.c: sys/xen/xenbus/xenbusb_front.c: Register xenbusb_resume() rather than bus_generic_resume() as the handler for device_resume events. sys/xen/xenstore/xenstore.c: o Fix grammer in a comment. o In xs_suspend(), pass suspend events on to the child devices (e.g. xenbusb_front/back, that are attached to the XenStore. Approved by: re MFC after: 1 week Modified: head/sys/dev/xen/control/control.c head/sys/xen/xenbus/xenbusb.c head/sys/xen/xenbus/xenbusb_back.c head/sys/xen/xenbus/xenbusb_front.c head/sys/xen/xenstore/xenstore.c Modified: head/sys/dev/xen/control/control.c ============================================================================== --- head/sys/dev/xen/control/control.c Tue Sep 20 23:22:58 2011 (r225703) +++ head/sys/dev/xen/control/control.c Tue Sep 20 23:44:34 2011 (r225704) @@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -201,6 +202,8 @@ xctrl_suspend() int i, j, k, fpp; unsigned long max_pfn, start_info_mfn; + EVENTHANDLER_INVOKE(power_suspend); + #ifdef SMP struct thread *td; cpuset_t map; @@ -221,7 +224,13 @@ xctrl_suspend() stop_cpus(map); #endif + /* + * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE + * drivers need this. + */ + mtx_lock(&Giant); if (DEVICE_SUSPEND(root_bus) != 0) { + mtx_unlock(&Giant); printf("xen_suspend: device_suspend failed\n"); #ifdef SMP if (!CPU_EMPTY(&map)) @@ -229,6 +238,7 @@ xctrl_suspend() #endif return; } + mtx_unlock(&Giant); local_irq_disable(); @@ -283,11 +293,14 @@ xctrl_suspend() vcpu_prepare(i); #endif + /* * Only resume xenbus /after/ we've prepared our VCPUs; otherwise * the VCPU hotplug callback can race with our vcpu_prepare */ + mtx_lock(&Giant); DEVICE_RESUME(root_bus); + mtx_unlock(&Giant); #ifdef SMP thread_lock(curthread); @@ -296,6 +309,7 @@ xctrl_suspend() if (!CPU_EMPTY(&map)) restart_cpus(map); #endif + EVENTHANDLER_INVOKE(power_resume); } static void @@ -322,39 +336,47 @@ xctrl_suspend() { int suspend_cancelled; + EVENTHANDLER_INVOKE(power_suspend); + + /* + * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE + * drivers need this. + */ + mtx_lock(&Giant); if (DEVICE_SUSPEND(root_bus)) { + mtx_unlock(&Giant); printf("xen_suspend: device_suspend failed\n"); return; } - - /* - * Make sure we don't change cpus or switch to some other - * thread. for the duration. - */ - critical_enter(); + mtx_unlock(&Giant); /* * Prevent any races with evtchn_interrupt() handler. */ - irq_suspend(); disable_intr(); + irq_suspend(); suspend_cancelled = HYPERVISOR_suspend(0); - if (!suspend_cancelled) + if (suspend_cancelled) + irq_resume(); + else xenpci_resume(); /* * Re-enable interrupts and put the scheduler back to normal. */ enable_intr(); - critical_exit(); /* * FreeBSD really needs to add DEVICE_SUSPEND_CANCEL or * similar. */ + mtx_lock(&Giant); if (!suspend_cancelled) DEVICE_RESUME(root_bus); + mtx_unlock(&Giant); + + EVENTHANDLER_INVOKE(power_resume); } #endif Modified: head/sys/xen/xenbus/xenbusb.c ============================================================================== --- head/sys/xen/xenbus/xenbusb.c Tue Sep 20 23:22:58 2011 (r225703) +++ head/sys/xen/xenbus/xenbusb.c Tue Sep 20 23:44:34 2011 (r225704) @@ -773,7 +773,7 @@ xenbusb_resume(device_t dev) ivars = device_get_ivars(kids[i]); xs_unregister_watch(&ivars->xd_otherend_watch); - ivars->xd_state = XenbusStateInitialising; + xenbus_set_state(kids[i], XenbusStateInitialising); /* * Find the new backend details and @@ -783,16 +783,16 @@ xenbusb_resume(device_t dev) if (error) return (error); - DEVICE_RESUME(kids[i]); - statepath = malloc(ivars->xd_otherend_path_len + strlen("/state") + 1, M_XENBUS, M_WAITOK); sprintf(statepath, "%s/state", ivars->xd_otherend_path); free(ivars->xd_otherend_watch.node, M_XENBUS); ivars->xd_otherend_watch.node = statepath; - xs_register_watch(&ivars->xd_otherend_watch); + DEVICE_RESUME(kids[i]); + + xs_register_watch(&ivars->xd_otherend_watch); #if 0 /* * Can't do this yet since we are running in Modified: head/sys/xen/xenbus/xenbusb_back.c ============================================================================== --- head/sys/xen/xenbus/xenbusb_back.c Tue Sep 20 23:22:58 2011 (r225703) +++ head/sys/xen/xenbus/xenbusb_back.c Tue Sep 20 23:44:34 2011 (r225704) @@ -292,7 +292,7 @@ static device_method_t xenbusb_back_meth DEVMETHOD(device_detach, bus_generic_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_resume, xenbusb_resume), /* Bus Interface */ DEVMETHOD(bus_print_child, xenbusb_print_child), Modified: head/sys/xen/xenbus/xenbusb_front.c ============================================================================== --- head/sys/xen/xenbus/xenbusb_front.c Tue Sep 20 23:22:58 2011 (r225703) +++ head/sys/xen/xenbus/xenbusb_front.c Tue Sep 20 23:44:34 2011 (r225704) @@ -171,7 +171,7 @@ static device_method_t xenbusb_front_met DEVMETHOD(device_detach, bus_generic_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_resume, xenbusb_resume), /* Bus Interface */ DEVMETHOD(bus_print_child, xenbusb_print_child), Modified: head/sys/xen/xenstore/xenstore.c ============================================================================== --- head/sys/xen/xenstore/xenstore.c Tue Sep 20 23:22:58 2011 (r225703) +++ head/sys/xen/xenstore/xenstore.c Tue Sep 20 23:44:34 2011 (r225704) @@ -721,8 +721,8 @@ xs_reply_filter(uint32_t request_msg_typ /* * The count of transactions drops if we attempted * to end a transaction (even if that attempt fails - * in error), we receive a transaction end acknowledgement - * or if our attempt to begin a transactionfails. + * in error), we receive a transaction end acknowledgement, + * or if our attempt to begin a transaction fails. */ if (request_msg_type == XS_TRANSACTION_END || (request_reply_error == 0 && reply_msg_type == XS_TRANSACTION_END) @@ -1194,8 +1194,14 @@ xs_attach(device_t dev) * all transactions and individual requests have completed. */ static int -xs_suspend(device_t dev __unused) +xs_suspend(device_t dev) { + int error; + + /* Suspend child Xen devices. */ + error = bus_generic_suspend(dev); + if (error != 0) + return (error); sx_xlock(&xs.suspend_mutex); sx_xlock(&xs.request_mutex); @@ -1227,6 +1233,9 @@ xs_resume(device_t dev __unused) sx_xunlock(&xs.suspend_mutex); + /* Resume child Xen devices. */ + bus_generic_resume(dev); + return (0); } From owner-svn-src-head@FreeBSD.ORG Wed Sep 21 00:02:45 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B6AC1065670; Wed, 21 Sep 2011 00:02:45 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49C5E8FC08; Wed, 21 Sep 2011 00:02:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8L02jtL050444; Wed, 21 Sep 2011 00:02:45 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8L02jEl050441; Wed, 21 Sep 2011 00:02:45 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109210002.p8L02jEl050441@svn.freebsd.org> From: "Justin T. Gibbs" Date: Wed, 21 Sep 2011 00:02:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225705 - head/sys/dev/xen/blkfront X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2011 00:02:45 -0000 Author: gibbs Date: Wed Sep 21 00:02:44 2011 New Revision: 225705 URL: http://svn.freebsd.org/changeset/base/225705 Log: Add suspend/resume support to the Xen blkfront driver. Sponsored by: BQ Internet sys/dev/xen/blkfront/block.h: sys/dev/xen/blkfront/blkfront.c: Remove now unused blkif_vdev_t from the blkfront soft. sys/dev/xen/blkfront/blkfront.c: o In blkfront_suspend(), indicate the desire to suspend by changing the softc connected state to SUSPENDED, and then wait for any I/O pending on the remote peer to drain. Cancel suspend processing if I/O does not drain within 30 seconds. o Enable and update blkfront_resume(). Since I/O is drained prior to the suspension of the VM, the complicated recovery process performed by other Xen blkfront implementations is avoided. We simply tear down the connection to our old peer, and then re-connect. o In blkif_initialize(), fix a resource leak and botched return if we cannot allocate shadow memory for our requests. o In blkfront_backend_changed(), correct our response to the XenbusStateInitialised state. This state indicates that our backend peer has published sufficient data for blkfront to publish ring information and other XenStore data, not that a connection can occur. Blkfront now will only perform connection processing in response to the XenbusStateConnected state. This corrects an issue where blkfront connected before the backend was ready during resume processing. Approved by: re MFC after: 1 week Modified: head/sys/dev/xen/blkfront/blkfront.c head/sys/dev/xen/blkfront/block.h Modified: head/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- head/sys/dev/xen/blkfront/blkfront.c Tue Sep 20 23:44:34 2011 (r225704) +++ head/sys/dev/xen/blkfront/blkfront.c Wed Sep 21 00:02:44 2011 (r225705) @@ -77,11 +77,8 @@ static int blkfront_detach(device_t); static int setup_blkring(struct xb_softc *); static void blkif_int(void *); static void blkfront_initialize(struct xb_softc *); -#if 0 -static void blkif_recover(struct xb_softc *); -#endif static int blkif_completion(struct xb_command *); -static void blkif_free(struct xb_softc *, int); +static void blkif_free(struct xb_softc *); static void blkif_queue_cb(void *, bus_dma_segment_t *, int, int); MALLOC_DEFINE(M_XENBLOCKFRONT, "xbd", "Xen Block Front driver data"); @@ -452,9 +449,6 @@ blkfront_attach(device_t dev) sc->vdevice = vdevice; sc->connected = BLKIF_STATE_DISCONNECTED; - /* Front end dir is a number, which is used as the id. */ - sc->handle = strtoul(strrchr(xenbus_get_node(dev),'/')+1, NULL, 0); - /* Wait for backend device to publish its protocol capabilities. */ xenbus_set_state(dev, XenbusStateInitialising); @@ -465,29 +459,40 @@ static int blkfront_suspend(device_t dev) { struct xb_softc *sc = device_get_softc(dev); + int retval; + int saved_state; /* Prevent new requests being issued until we fix things up. */ mtx_lock(&sc->xb_io_lock); + saved_state = sc->connected; sc->connected = BLKIF_STATE_SUSPENDED; + + /* Wait for outstanding I/O to drain. */ + retval = 0; + while (TAILQ_EMPTY(&sc->cm_busy) == 0) { + if (msleep(&sc->cm_busy, &sc->xb_io_lock, + PRIBIO, "blkf_susp", 30 * hz) == EWOULDBLOCK) { + retval = EBUSY; + break; + } + } mtx_unlock(&sc->xb_io_lock); - return (0); + if (retval != 0) + sc->connected = saved_state; + + return (retval); } static int blkfront_resume(device_t dev) { -#if 0 struct xb_softc *sc = device_get_softc(dev); DPRINTK("blkfront_resume: %s\n", xenbus_get_node(dev)); -/* XXX This can't work!!! */ - blkif_free(sc, 1); + blkif_free(sc); blkfront_initialize(sc); - if (sc->connected == BLKIF_STATE_SUSPENDED) - blkif_recover(sc); -#endif return (0); } @@ -499,8 +504,10 @@ blkfront_initialize(struct xb_softc *sc) int error; int i; - if (xenbus_get_state(sc->xb_dev) != XenbusStateInitialising) - return; + if (xenbus_get_state(sc->xb_dev) != XenbusStateInitialising) { + /* Initialization has already been performed. */ + return; + } /* * Protocol defaults valid even if negotiation for a @@ -593,8 +600,10 @@ blkfront_initialize(struct xb_softc *sc) sc->shadow = malloc(sizeof(*sc->shadow) * sc->max_requests, M_XENBLOCKFRONT, M_NOWAIT|M_ZERO); if (sc->shadow == NULL) { + bus_dma_tag_destroy(sc->xb_io_dmat); xenbus_dev_fatal(sc->xb_dev, error, "Cannot allocate request structures\n"); + return; } for (i = 0; i < sc->max_requests; i++) { @@ -755,10 +764,10 @@ blkfront_backend_changed(device_t dev, X break; case XenbusStateInitWait: + case XenbusStateInitialised: blkfront_initialize(sc); break; - case XenbusStateInitialised: case XenbusStateConnected: blkfront_initialize(sc); blkfront_connect(sc); @@ -775,7 +784,7 @@ blkfront_backend_changed(device_t dev, X } /* -** Invoked when the backend is finally 'ready' (and has told produced +** Invoked when the backend is finally 'ready' (and has published ** the details about the physical device - #sectors, size, etc). */ static void @@ -809,13 +818,15 @@ blkfront_connect(struct xb_softc *sc) if (!err || feature_barrier) sc->xb_flags |= XB_BARRIER; - device_printf(dev, "%juMB <%s> at %s", - (uintmax_t) sectors / (1048576 / sector_size), - device_get_desc(dev), - xenbus_get_node(dev)); - bus_print_child_footer(device_get_parent(dev), dev); + if (sc->xb_disk == NULL) { + device_printf(dev, "%juMB <%s> at %s", + (uintmax_t) sectors / (1048576 / sector_size), + device_get_desc(dev), + xenbus_get_node(dev)); + bus_print_child_footer(device_get_parent(dev), dev); - xlvbd_add(sc, sectors, sc->vdevice, binfo, sector_size); + xlvbd_add(sc, sectors, sc->vdevice, binfo, sector_size); + } (void)xenbus_set_state(dev, XenbusStateConnected); @@ -825,7 +836,6 @@ blkfront_connect(struct xb_softc *sc) xb_startio(sc); sc->xb_flags |= XB_READY; mtx_unlock(&sc->xb_io_lock); - } /** @@ -859,7 +869,7 @@ blkfront_detach(device_t dev) DPRINTK("blkfront_remove: %s removed\n", xenbus_get_node(dev)); - blkif_free(sc, 0); + blkif_free(sc); mtx_destroy(&sc->xb_io_lock); return 0; @@ -1140,6 +1150,9 @@ xb_startio(struct xb_softc *sc) mtx_assert(&sc->xb_io_lock, MA_OWNED); + if (sc->connected != BLKIF_STATE_CONNECTED) + return; + while (RING_FREE_REQUESTS(&sc->ring) >= sc->max_request_blocks) { if (sc->xb_flags & XB_FROZEN) break; @@ -1174,7 +1187,7 @@ blkif_int(void *xsc) mtx_lock(&sc->xb_io_lock); - if (unlikely(sc->connected != BLKIF_STATE_CONNECTED)) { + if (unlikely(sc->connected == BLKIF_STATE_DISCONNECTED)) { mtx_unlock(&sc->xb_io_lock); return; } @@ -1232,19 +1245,21 @@ blkif_int(void *xsc) xb_startio(sc); + if (unlikely(sc->connected == BLKIF_STATE_SUSPENDED)) + wakeup(&sc->cm_busy); + mtx_unlock(&sc->xb_io_lock); } static void -blkif_free(struct xb_softc *sc, int suspend) +blkif_free(struct xb_softc *sc) { uint8_t *sring_page_ptr; int i; /* Prevent new requests being issued until we fix things up. */ mtx_lock(&sc->xb_io_lock); - sc->connected = suspend ? - BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED; + sc->connected = BLKIF_STATE_DISCONNECTED; mtx_unlock(&sc->xb_io_lock); /* Free resources associated with old device channel. */ @@ -1276,6 +1291,12 @@ blkif_free(struct xb_softc *sc, int susp } free(sc->shadow, M_XENBLOCKFRONT); sc->shadow = NULL; + + bus_dma_tag_destroy(sc->xb_io_dmat); + + xb_initq_free(sc); + xb_initq_ready(sc); + xb_initq_complete(sc); } if (sc->irq) { @@ -1292,21 +1313,6 @@ blkif_completion(struct xb_command *s) return (BLKIF_SEGS_TO_BLOCKS(s->nseg)); } -#if 0 -static void -blkif_recover(struct xb_softc *sc) -{ - /* - * XXX The whole concept of not quiescing and completing all i/o - * during suspend, and then hoping to recover and replay the - * resulting abandoned I/O during resume, is laughable. At best, - * it invalidates the i/o ordering rules required by just about - * every filesystem, and at worst it'll corrupt data. The code - * has been removed until further notice. - */ -} -#endif - /* ** Driver registration ** */ static device_method_t blkfront_methods[] = { /* Device interface */ Modified: head/sys/dev/xen/blkfront/block.h ============================================================================== --- head/sys/dev/xen/blkfront/block.h Tue Sep 20 23:44:34 2011 (r225704) +++ head/sys/dev/xen/blkfront/block.h Wed Sep 21 00:02:44 2011 (r225705) @@ -142,7 +142,6 @@ struct xb_softc { #define XB_READY (1 << 2) /* Is ready */ #define XB_FROZEN (1 << 3) /* Waiting for resources */ int vdevice; - blkif_vdev_t handle; int connected; u_int ring_pages; uint32_t max_requests; From owner-svn-src-head@FreeBSD.ORG Wed Sep 21 00:06:02 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3924106568B; Wed, 21 Sep 2011 00:06:02 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A4FE8FC15; Wed, 21 Sep 2011 00:06:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8L0628t050574; Wed, 21 Sep 2011 00:06:02 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8L062eT050572; Wed, 21 Sep 2011 00:06:02 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109210006.p8L062eT050572@svn.freebsd.org> From: "Justin T. Gibbs" Date: Wed, 21 Sep 2011 00:06:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225706 - head/sys/dev/xen/control X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2011 00:06:02 -0000 Author: gibbs Date: Wed Sep 21 00:06:02 2011 New Revision: 225706 URL: http://svn.freebsd.org/changeset/base/225706 Log: [ Forced commit. Actual changes accidentally included in r225704 ] sys/dev/xen/control/control.c: Fix locking violations in Xen HVM suspend processing and have it perform similar actions to those performed during an ACPI triggered suspend. Sponsored by: BQ Internet Approved by: re MFC after: 1 week Modified: head/sys/dev/xen/control/control.c Modified: head/sys/dev/xen/control/control.c ============================================================================== From owner-svn-src-head@FreeBSD.ORG Wed Sep 21 00:08:25 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA1191065673; Wed, 21 Sep 2011 00:08:25 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F00F8FC1A; Wed, 21 Sep 2011 00:08:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8L08PZR050674; Wed, 21 Sep 2011 00:08:25 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8L08PDq050672; Wed, 21 Sep 2011 00:08:25 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109210008.p8L08PDq050672@svn.freebsd.org> From: "Justin T. Gibbs" Date: Wed, 21 Sep 2011 00:08:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225707 - head/sys/dev/xen/netfront X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2011 00:08:25 -0000 Author: gibbs Date: Wed Sep 21 00:08:25 2011 New Revision: 225707 URL: http://svn.freebsd.org/changeset/base/225707 Log: Correct suspend/resume support in the Netfront driver. Sponsored by: BQ Internet sys/dev/xen/netfront/netfront.c: o Implement netfront_suspend(), a specialized suspend handler for the netfront driver. This routine simply disables the carrier so the driver is idle during system suspend processing. o Fix a leak when re-initializing LRO during a link reset. o In netif_release_tx_bufs(), when cleaning up the grant references for our TX ring, use gnttab_end_foreign_access_ref instead of attempting to grant the page again. o In netif_release_tx_bufs(), we do not track mbufs associated with mbuf chains, but instead just free each mbuf directly. Use m_free(), not m_freem(), to avoid double frees of mbufs. o Refactor some code to enhance clarity. Approved by: re MFC after: 1 week Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:06:02 2011 (r225706) +++ head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:08:25 2011 (r225707) @@ -159,6 +159,7 @@ static int xn_ioctl(struct ifnet *, u_l static void xn_ifinit_locked(struct netfront_info *); static void xn_ifinit(void *); static void xn_stop(struct netfront_info *); +static int xn_configure_lro(struct netfront_info *np); #ifdef notyet static void xn_watchdog(struct ifnet *); #endif @@ -174,7 +175,7 @@ static int talk_to_backend(device_t dev, static int create_netdev(device_t dev); static void netif_disconnect_backend(struct netfront_info *info); static int setup_device(device_t dev, struct netfront_info *info); -static void end_access(int ref, void *page); +static void free_ring(int *ref, void *ring_ptr_ref); static int xn_ifmedia_upd(struct ifnet *ifp); static void xn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); @@ -463,6 +464,18 @@ netfront_attach(device_t dev) return 0; } +static int +netfront_suspend(device_t dev) +{ + struct netfront_info *info = device_get_softc(dev); + + XN_RX_LOCK(info); + XN_TX_LOCK(info); + netfront_carrier_off(info); + XN_TX_UNLOCK(info); + XN_RX_UNLOCK(info); + return (0); +} /** * We are reconnecting to the backend, due to a suspend/resume, or a backend @@ -749,10 +762,7 @@ netif_release_tx_bufs(struct netfront_in */ if (((uintptr_t)m) <= NET_TX_RING_SIZE) continue; - gnttab_grant_foreign_access_ref(np->grant_tx_ref[i], - xenbus_get_otherend_id(np->xbdev), - virt_to_mfn(mtod(m, vm_offset_t)), - GNTMAP_readonly); + gnttab_end_foreign_access_ref(np->grant_tx_ref[i]); gnttab_release_grant_reference(&np->gref_tx_head, np->grant_tx_ref[i]); np->grant_tx_ref[i] = GRANT_REF_INVALID; @@ -761,7 +771,7 @@ netif_release_tx_bufs(struct netfront_in if (np->xn_cdata.xn_tx_chain_cnt < 0) { panic("netif_release_tx_bufs: tx_chain_cnt must be >= 0"); } - m_freem(m); + m_free(m); } } @@ -1914,6 +1924,7 @@ network_connect(struct netfront_info *np netif_release_tx_bufs(np); /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ + xn_configure_lro(np); for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) { struct mbuf *m; u_long pfn; @@ -1978,6 +1989,30 @@ show_device(struct netfront_info *sc) #endif } +static int +xn_configure_lro(struct netfront_info *np) +{ + int err; + + err = 0; +#if __FreeBSD_version >= 700000 + if ((np->xn_ifp->if_capabilities & IFCAP_LRO) != 0) + tcp_lro_free(&np->xn_lro); + np->xn_ifp->if_capabilities &= ~IFCAP_LRO; + if (xn_enable_lro) { + err = tcp_lro_init(&np->xn_lro); + if (err) { + device_printf(np->xbdev, "LRO initialization failed\n"); + } else { + np->xn_lro.ifp = np->xn_ifp; + np->xn_ifp->if_capabilities |= IFCAP_LRO; + } + } + np->xn_ifp->if_capenable = np->xn_ifp->if_capabilities; +#endif + return (err); +} + /** Create a network device. * @param handle device handle */ @@ -2057,17 +2092,9 @@ create_netdev(device_t dev) ifp->if_capabilities = IFCAP_HWCSUM; #if __FreeBSD_version >= 700000 ifp->if_capabilities |= IFCAP_TSO4; - if (xn_enable_lro) { - int err = tcp_lro_init(&np->xn_lro); - if (err) { - device_printf(dev, "LRO initialization failed\n"); - goto exit; - } - np->xn_lro.ifp = ifp; - ifp->if_capabilities |= IFCAP_LRO; - } #endif ifp->if_capenable = ifp->if_capabilities; + xn_configure_lro(np); ether_ifattach(ifp, np->mac); callout_init(&np->xn_stat_ch, CALLOUT_MPSAFE); @@ -2133,12 +2160,8 @@ netif_disconnect_backend(struct netfront XN_TX_UNLOCK(info); XN_RX_UNLOCK(info); - end_access(info->tx_ring_ref, info->tx.sring); - end_access(info->rx_ring_ref, info->rx.sring); - info->tx_ring_ref = GRANT_REF_INVALID; - info->rx_ring_ref = GRANT_REF_INVALID; - info->tx.sring = NULL; - info->rx.sring = NULL; + free_ring(&info->tx_ring_ref, &info->tx.sring); + free_ring(&info->rx_ring_ref, &info->rx.sring); if (info->irq) unbind_from_irqhandler(info->irq); @@ -2146,12 +2169,17 @@ netif_disconnect_backend(struct netfront info->irq = 0; } - static void -end_access(int ref, void *page) +free_ring(int *ref, void *ring_ptr_ref) { - if (ref != GRANT_REF_INVALID) - gnttab_end_foreign_access(ref, page); + void **ring_ptr_ptr = ring_ptr_ref; + + if (*ref != GRANT_REF_INVALID) { + /* This API frees the associated storage. */ + gnttab_end_foreign_access(*ref, *ring_ptr_ptr); + *ref = GRANT_REF_INVALID; + } + *ring_ptr_ptr = NULL; } static int @@ -2174,7 +2202,7 @@ static device_method_t netfront_methods[ DEVMETHOD(device_attach, netfront_attach), DEVMETHOD(device_detach, netfront_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_suspend, netfront_suspend), DEVMETHOD(device_resume, netfront_resume), /* Xenbus interface */ From owner-svn-src-head@FreeBSD.ORG Wed Sep 21 00:13:04 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99842106566B; Wed, 21 Sep 2011 00:13:04 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7EE6F8FC0C; Wed, 21 Sep 2011 00:13:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8L0D4cE050851; Wed, 21 Sep 2011 00:13:04 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8L0D4hi050849; Wed, 21 Sep 2011 00:13:04 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109210013.p8L0D4hi050849@svn.freebsd.org> From: "Justin T. Gibbs" Date: Wed, 21 Sep 2011 00:13:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225708 - head/sys/dev/xen/netfront X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2011 00:13:04 -0000 Author: gibbs Date: Wed Sep 21 00:13:04 2011 New Revision: 225708 URL: http://svn.freebsd.org/changeset/base/225708 Log: Modify the netfront driver so it can successfully attach to PV devices with the ioemu attribute set. sys/dev/xen/netfront/netfront.c: o If a mac address for the interface cannot be found in the front-side XenStore tree, look for an entry in the back-side tree. With ioemu devices, the emulator does not populate the front side tree and neither does Xend. o Return an error rather than panic when an attach attempt fails. Reported by: Janne Snabb (fix inspired by patch provided) PR: kern/154302 Approved by: re Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:08:25 2011 (r225707) +++ head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:13:04 2011 (r225708) @@ -406,11 +406,33 @@ xen_net_read_mac(device_t dev, uint8_t m { int error, i; char *s, *e, *macstr; + const char *path; - error = xs_read(XST_NIL, xenbus_get_node(dev), "mac", NULL, - (void **) &macstr); - if (error) + path = xenbus_get_node(dev); + error = xs_read(XST_NIL, path, "mac", NULL, (void **) &macstr); + if (error == ENOENT) { + /* + * Deal with missing mac XenStore nodes on devices with + * HVM emulation (the 'ioemu' configuration attribute) + * enabled. + * + * The HVM emulator may execute in a stub device model + * domain which lacks the permission, only given to Dom0, + * to update the guest's XenStore tree. For this reason, + * the HVM emulator doesn't even attempt to write the + * front-side mac node, even when operating in Dom0. + * However, there should always be a mac listed in the + * backend tree. Fallback to this version if our query + * of the front side XenStore location doesn't find + * anything. + */ + path = xenbus_get_otherend_path(dev); + error = xs_read(XST_NIL, path, "mac", NULL, (void **) &macstr); + } + if (error != 0) { + xenbus_dev_fatal(dev, error, "parsing %s/mac", path); return (error); + } s = macstr; for (i = 0; i < ETHER_ADDR_LEN; i++) { @@ -451,7 +473,7 @@ netfront_attach(device_t dev) err = create_netdev(dev); if (err) { xenbus_dev_fatal(dev, err, "creating netdev"); - return err; + return (err); } #if __FreeBSD_version >= 700000 @@ -461,7 +483,7 @@ netfront_attach(device_t dev) &xn_enable_lro, 0, "Large Receive Offload"); #endif - return 0; + return (0); } static int @@ -2067,11 +2089,8 @@ create_netdev(device_t dev) } err = xen_net_read_mac(dev, np->mac); - if (err) { - xenbus_dev_fatal(dev, err, "parsing %s/mac", - xenbus_get_node(dev)); + if (err) goto out; - } /* Set up ifnet structure */ ifp = np->xn_ifp = if_alloc(IFT_ETHER); @@ -2105,8 +2124,7 @@ create_netdev(device_t dev) exit: gnttab_free_grant_references(np->gref_tx_head); out: - panic("do something smart"); - + return (err); } /** From owner-svn-src-head@FreeBSD.ORG Wed Sep 21 00:15:30 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03E1A106567B; Wed, 21 Sep 2011 00:15:30 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E741E8FC2D; Wed, 21 Sep 2011 00:15:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8L0FTbO050964; Wed, 21 Sep 2011 00:15:29 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8L0FTIH050962; Wed, 21 Sep 2011 00:15:29 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201109210015.p8L0FTIH050962@svn.freebsd.org> From: "Justin T. Gibbs" Date: Wed, 21 Sep 2011 00:15:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225709 - head/sys/dev/xen/netfront X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2011 00:15:30 -0000 Author: gibbs Date: Wed Sep 21 00:15:29 2011 New Revision: 225709 URL: http://svn.freebsd.org/changeset/base/225709 Log: Update netfront so that it queries and honors published back-end features. sys/dev/xen/netfront/netfront.c: o Add xn_query_features() which reads the XenStore and records the TSO, LRO, and chained ring-request support of the backend. o Rename xn_configure_lro() to xn_configure_features() and use this routine to manage the setup of TSO, LRO, and checksum offload. o In create_netdev(), initialize if_capabilities and if_hwassist to the capabilities found on all backends. Delegate configuration of if_capenable and the TSO flag if if_hwassist to xn_configure_features(). Reported by: Hugo Silva (fix inspired by patch provided) Approved by: re MFC after: 1 week Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:13:04 2011 (r225708) +++ head/sys/dev/xen/netfront/netfront.c Wed Sep 21 00:15:29 2011 (r225709) @@ -92,7 +92,8 @@ __FBSDID("$FreeBSD$"); #include "xenbus_if.h" -#define XN_CSUM_FEATURES (CSUM_TCP | CSUM_UDP | CSUM_TSO) +/* Features supported by all backends. TSO and LRO can be negotiated */ +#define XN_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) @@ -159,7 +160,8 @@ static int xn_ioctl(struct ifnet *, u_l static void xn_ifinit_locked(struct netfront_info *); static void xn_ifinit(void *); static void xn_stop(struct netfront_info *); -static int xn_configure_lro(struct netfront_info *np); +static void xn_query_features(struct netfront_info *np); +static int xn_configure_features(struct netfront_info *np); #ifdef notyet static void xn_watchdog(struct ifnet *); #endif @@ -262,6 +264,7 @@ struct netfront_info { u_int irq; u_int copying_receiver; u_int carrier; + u_int maxfrags; /* Receive-ring batched refills. */ #define RX_MIN_TARGET 32 @@ -1526,7 +1529,7 @@ xn_assemble_tx_request(struct netfront_i * deal with nfrags > MAX_TX_REQ_FRAGS, which is a quirk of * the Linux network stack. */ - if (nfrags > MAX_TX_REQ_FRAGS) { + if (nfrags > sc->maxfrags) { m = m_defrag(m_head, M_DONTWAIT); if (!m) { /* @@ -1943,10 +1946,11 @@ network_connect(struct netfront_info *np return (error); /* Step 1: Reinitialise variables. */ + xn_query_features(np); + xn_configure_features(np); netif_release_tx_bufs(np); /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ - xn_configure_lro(np); for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) { struct mbuf *m; u_long pfn; @@ -2011,26 +2015,63 @@ show_device(struct netfront_info *sc) #endif } +static void +xn_query_features(struct netfront_info *np) +{ + int val; + + device_printf(np->xbdev, "backend features:"); + + if (xs_scanf(XST_NIL, xenbus_get_otherend_path(np->xbdev), + "feature-sg", NULL, "%d", &val) < 0) + val = 0; + + np->maxfrags = 1; + if (val) { + np->maxfrags = MAX_TX_REQ_FRAGS; + printf(" feature-sg"); + } + + if (xs_scanf(XST_NIL, xenbus_get_otherend_path(np->xbdev), + "feature-gso-tcpv4", NULL, "%d", &val) < 0) + val = 0; + + np->xn_ifp->if_capabilities &= ~(IFCAP_TSO4|IFCAP_LRO); + if (val) { + np->xn_ifp->if_capabilities |= IFCAP_TSO4|IFCAP_LRO; + printf(" feature-gso-tcp4"); + } + + printf("\n"); +} + static int -xn_configure_lro(struct netfront_info *np) +xn_configure_features(struct netfront_info *np) { int err; err = 0; #if __FreeBSD_version >= 700000 - if ((np->xn_ifp->if_capabilities & IFCAP_LRO) != 0) + if ((np->xn_ifp->if_capenable & IFCAP_LRO) != 0) tcp_lro_free(&np->xn_lro); - np->xn_ifp->if_capabilities &= ~IFCAP_LRO; - if (xn_enable_lro) { +#endif + np->xn_ifp->if_capenable = + np->xn_ifp->if_capabilities & ~(IFCAP_LRO|IFCAP_TSO4); + np->xn_ifp->if_hwassist &= ~CSUM_TSO; +#if __FreeBSD_version >= 700000 + if (xn_enable_lro && (np->xn_ifp->if_capabilities & IFCAP_LRO) != 0) { err = tcp_lro_init(&np->xn_lro); if (err) { device_printf(np->xbdev, "LRO initialization failed\n"); } else { np->xn_lro.ifp = np->xn_ifp; - np->xn_ifp->if_capabilities |= IFCAP_LRO; + np->xn_ifp->if_capenable |= IFCAP_LRO; } } - np->xn_ifp->if_capenable = np->xn_ifp->if_capabilities; + if ((np->xn_ifp->if_capabilities & IFCAP_TSO4) != 0) { + np->xn_ifp->if_capenable |= IFCAP_TSO4; + np->xn_ifp->if_hwassist |= CSUM_TSO; + } #endif return (err); } @@ -2059,7 +2100,7 @@ create_netdev(device_t dev) np->rx_target = RX_MIN_TARGET; np->rx_min_target = RX_MIN_TARGET; np->rx_max_target = RX_MAX_TARGET; - + /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */ for (i = 0; i <= NET_TX_RING_SIZE; i++) { np->tx_mbufs[i] = (void *) ((u_long) i+1); @@ -2109,11 +2150,6 @@ create_netdev(device_t dev) ifp->if_hwassist = XN_CSUM_FEATURES; ifp->if_capabilities = IFCAP_HWCSUM; -#if __FreeBSD_version >= 700000 - ifp->if_capabilities |= IFCAP_TSO4; -#endif - ifp->if_capenable = ifp->if_capabilities; - xn_configure_lro(np); ether_ifattach(ifp, np->mac); callout_init(&np->xn_stat_ch, CALLOUT_MPSAFE);