From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 08:17:45 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1651C106568C; Sun, 29 Apr 2012 08:17:45 +0000 (UTC) (envelope-from jlh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0190F8FC08; Sun, 29 Apr 2012 08:17: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 q3T8Hi7O004494; Sun, 29 Apr 2012 08:17:44 GMT (envelope-from jlh@svn.freebsd.org) Received: (from jlh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T8HiUI004492; Sun, 29 Apr 2012 08:17:44 GMT (envelope-from jlh@svn.freebsd.org) Message-Id: <201204290817.q3T8HiUI004492@svn.freebsd.org> From: Jeremie Le Hen Date: Sun, 29 Apr 2012 08:17:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234779 - head/usr.bin/stdbuf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 08:17:45 -0000 Author: jlh Date: Sun Apr 29 08:17:44 2012 New Revision: 234779 URL: http://svn.freebsd.org/changeset/base/234779 Log: Use standard getopt(3) error message. Submitted by: jilles Approved by: kib (mentor) Modified: head/usr.bin/stdbuf/stdbuf.c Modified: head/usr.bin/stdbuf/stdbuf.c ============================================================================== --- head/usr.bin/stdbuf/stdbuf.c Sun Apr 29 00:59:38 2012 (r234778) +++ head/usr.bin/stdbuf/stdbuf.c Sun Apr 29 08:17:44 2012 (r234779) @@ -52,7 +52,7 @@ main(int argc, char *argv[]) int i; ibuf = obuf = ebuf = NULL; - while ((i = getopt(argc, argv, ":e:i:o:")) != -1) { + while ((i = getopt(argc, argv, "e:i:o:")) != -1) { switch (i) { case 'e': ebuf = optarg; @@ -63,13 +63,8 @@ main(int argc, char *argv[]) case 'o': obuf = optarg; break; - case ':': - warnx("Missing argument for option -%c", optopt); - usage(1); - break; case '?': default: - warnx("Unknown option: %c", optopt); usage(1); break; } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 08:50:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B820106566B; Sun, 29 Apr 2012 08:50:51 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D0ECA8FC0A; Sun, 29 Apr 2012 08:50: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 q3T8ooWA005662; Sun, 29 Apr 2012 08:50:50 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T8ooYp005659; Sun, 29 Apr 2012 08:50:50 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201204290850.q3T8ooYp005659@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 29 Apr 2012 08:50:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234780 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 08:50:51 -0000 Author: bz Date: Sun Apr 29 08:50:50 2012 New Revision: 234780 URL: http://svn.freebsd.org/changeset/base/234780 Log: MFC r233554: Export the udp_cksum sysctl for upcoming SCTP work. Rather than always, SCTP will only do IPv4 UDP checksum calculation as defined by the host policy. When tunneling SCTP always calculates the inner checksum already so not doing the outer UDP can save cycles. While here virtualize the variable. Requested by: tuexen Modified: stable/9/sys/netinet/udp_usrreq.c stable/9/sys/netinet/udp_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/udp_usrreq.c ============================================================================== --- stable/9/sys/netinet/udp_usrreq.c Sun Apr 29 08:17:44 2012 (r234779) +++ stable/9/sys/netinet/udp_usrreq.c Sun Apr 29 08:50:50 2012 (r234780) @@ -105,9 +105,9 @@ __FBSDID("$FreeBSD$"); * packets that would otherwise be discarded due to bad checksums, and may * cause problems (especially for NFS data blocks). */ -static int udp_cksum = 1; -SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, &udp_cksum, - 0, "compute udp checksum"); +VNET_DEFINE(int, udp_cksum) = 1; +SYSCTL_VNET_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, + &VNET_NAME(udp_cksum), 0, "compute udp checksum"); int udp_log_in_vain = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW, @@ -1212,7 +1212,7 @@ udp_output(struct inpcb *inp, struct mbu /* * Set up checksum and output datagram. */ - if (udp_cksum) { + if (V_udp_cksum) { if (inp->inp_flags & INP_ONESBCAST) faddr.s_addr = INADDR_BROADCAST; ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, Modified: stable/9/sys/netinet/udp_var.h ============================================================================== --- stable/9/sys/netinet/udp_var.h Sun Apr 29 08:17:44 2012 (r234779) +++ stable/9/sys/netinet/udp_var.h Sun Apr 29 08:50:50 2012 (r234780) @@ -136,8 +136,10 @@ VNET_DECLARE(struct inpcbinfo, udbinfo); extern u_long udp_sendspace; extern u_long udp_recvspace; +VNET_DECLARE(int, udp_cksum); VNET_DECLARE(struct udpstat, udpstat); VNET_DECLARE(int, udp_blackhole); +#define V_udp_cksum VNET(udp_cksum) #define V_udpstat VNET(udpstat) #define V_udp_blackhole VNET(udp_blackhole) extern int udp_log_in_vain; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 08:51:07 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38F551065673; Sun, 29 Apr 2012 08:51:07 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A1998FC16; Sun, 29 Apr 2012 08:51: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 q3T8p6X5005711; Sun, 29 Apr 2012 08:51:06 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T8p6Of005708; Sun, 29 Apr 2012 08:51:06 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201204290851.q3T8p6Of005708@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 29 Apr 2012 08:51:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234781 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 08:51:07 -0000 Author: bz Date: Sun Apr 29 08:51:06 2012 New Revision: 234781 URL: http://svn.freebsd.org/changeset/base/234781 Log: MFC r233554: Export the udp_cksum sysctl for upcoming SCTP work. Rather than always, SCTP will only do IPv4 UDP checksum calculation as defined by the host policy. When tunneling SCTP always calculates the inner checksum already so not doing the outer UDP can save cycles. While here virtualize the variable. Requested by: tuexen Modified: stable/8/sys/netinet/udp_usrreq.c stable/8/sys/netinet/udp_var.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/udp_usrreq.c ============================================================================== --- stable/8/sys/netinet/udp_usrreq.c Sun Apr 29 08:50:50 2012 (r234780) +++ stable/8/sys/netinet/udp_usrreq.c Sun Apr 29 08:51:06 2012 (r234781) @@ -100,9 +100,9 @@ __FBSDID("$FreeBSD$"); * packets that would otherwise be discarded due to bad checksums, and may * cause problems (especially for NFS data blocks). */ -static int udp_cksum = 1; -SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, &udp_cksum, - 0, "compute udp checksum"); +VNET_DEFINE(int, udp_cksum) = 1; +SYSCTL_VNET_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, + &VNET_NAME(udp_cksum), 0, "compute udp checksum"); int udp_log_in_vain = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW, @@ -1228,7 +1228,7 @@ udp_output(struct inpcb *inp, struct mbu /* * Set up checksum and output datagram. */ - if (udp_cksum) { + if (V_udp_cksum) { if (inp->inp_flags & INP_ONESBCAST) faddr.s_addr = INADDR_BROADCAST; ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, Modified: stable/8/sys/netinet/udp_var.h ============================================================================== --- stable/8/sys/netinet/udp_var.h Sun Apr 29 08:50:50 2012 (r234780) +++ stable/8/sys/netinet/udp_var.h Sun Apr 29 08:51:06 2012 (r234781) @@ -136,8 +136,10 @@ VNET_DECLARE(struct inpcbinfo, udbinfo); extern u_long udp_sendspace; extern u_long udp_recvspace; +VNET_DECLARE(int, udp_cksum); VNET_DECLARE(struct udpstat, udpstat); VNET_DECLARE(int, udp_blackhole); +#define V_udp_cksum VNET(udp_cksum) #define V_udpstat VNET(udpstat) #define V_udp_blackhole VNET(udp_blackhole) extern int udp_log_in_vain; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 09:32:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F028D106564A; Sun, 29 Apr 2012 09:32:44 +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 D7E178FC08; Sun, 29 Apr 2012 09:32:44 +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 q3T9WiLk007200; Sun, 29 Apr 2012 09:32:44 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T9Wi90007188; Sun, 29 Apr 2012 09:32:44 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204290932.q3T9Wi90007188@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 29 Apr 2012 09:32:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234782 - in head: gnu/usr.bin/binutils/ar gnu/usr.bin/binutils/as gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/ranlib gnu/usr.bin/cc/cc gnu/usr.bin/cc/cc1 gnu/usr.bin/cc/cc1plus share/... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 09:32:45 -0000 Author: kib Date: Sun Apr 29 09:32:44 2012 New Revision: 234782 URL: http://svn.freebsd.org/changeset/base/234782 Log: Add src.conf option WITH_SHARED_TOOLCHAIN to enable building the toolchain binaries as dynamically linked. Option is disabled by default. Reviewed by: ru (previous version) MFC after: 2 weeks Added: head/tools/build/options/WITH_SHARED_TOOLCHAIN (contents, props changed) Modified: head/gnu/usr.bin/binutils/ar/Makefile head/gnu/usr.bin/binutils/as/Makefile head/gnu/usr.bin/binutils/ld/Makefile head/gnu/usr.bin/binutils/ranlib/Makefile head/gnu/usr.bin/cc/cc/Makefile head/gnu/usr.bin/cc/cc1/Makefile head/gnu/usr.bin/cc/cc1plus/Makefile head/share/mk/bsd.own.mk head/usr.bin/ar/Makefile head/usr.bin/make/Makefile Modified: head/gnu/usr.bin/binutils/ar/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ar/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ar/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc @@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils CFLAGS+= -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbinutils/libbinutils.a DPADD+= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/binutils/as/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/as/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/as/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -4,6 +4,7 @@ # BINDIR .include "${.CURDIR}/../../Makefile.inc" .include "${.CURDIR}/../Makefile.inc0" +.include .PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config @@ -79,7 +80,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${SRCDIR}/gas -I${SRCDIR}/bfd -I${SRCDIR}/gas/config -I${SRCDIR} CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/binutils/ld/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ld/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ld/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/ld @@ -34,7 +35,9 @@ CFLAGS+= -DBINDIR=\"${BINDIR}\" -DTARGET CFLAGS+= -DTOOLBINDIR=\"${TOOLS_PREFIX}/${BINDIR}/libexec\" CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a LDADD= ${DPADD} Modified: head/gnu/usr.bin/binutils/ranlib/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ranlib/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ranlib/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc @@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils CFLAGS+= -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbinutils/libbinutils.a DPADD+= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/cc/cc/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -9,7 +9,9 @@ PROG= gcc MAN= gcc.1 SRCS+= gccspec.c +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif MLINKS= gcc.1 g++.1 .if ${MK_CLANG_IS_CC} == "no" Modified: head/gnu/usr.bin/cc/cc1/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc1/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc1/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,14 +1,17 @@ # $FreeBSD$ .include "../Makefile.inc" +NO_MAN= +.include .PATH: ${GCCDIR} PROG= cc1 SRCS= main.c c-parser.c c-lang.c BINDIR= /usr/libexec -NO_MAN= +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif OBJS+= ${PROG}-checksum.o DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} Modified: head/gnu/usr.bin/cc/cc1plus/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc1plus/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc1plus/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,8 @@ # $FreeBSD$ .include "../Makefile.inc" +NO_MAN= +.include .PATH: ${GCCDIR}/cp ${GCCDIR} @@ -13,8 +15,9 @@ SRCS+= main.c cp-lang.c c-opts.c call.c cp-objcp-common.c cp-gimplify.c tree-mudflap.c BINDIR= /usr/libexec -NO_MAN= +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif CFLAGS+= -I${GCCDIR}/cp -I. Modified: head/share/mk/bsd.own.mk ============================================================================== --- head/share/mk/bsd.own.mk Sun Apr 29 08:51:06 2012 (r234781) +++ head/share/mk/bsd.own.mk Sun Apr 29 09:32:44 2012 (r234782) @@ -425,7 +425,8 @@ __DEFAULT_NO_OPTIONS = \ ICONV \ IDEA \ LIBCPLUSPLUS \ - OFED + OFED \ + SHARED_TOOLCHAIN # # Default behaviour of some options depends on the architecture. Unfortunately Added: head/tools/build/options/WITH_SHARED_TOOLCHAIN ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_SHARED_TOOLCHAIN Sun Apr 29 09:32:44 2012 (r234782) @@ -0,0 +1,6 @@ +.\" $FreeBSD$ +Set to build the toolchain binaries shared. +The set includes +.Xr cc 1 , +.Xr make 1 +and neccessary utilites like assembler, linker and library archive manager. Modified: head/usr.bin/ar/Makefile ============================================================================== --- head/usr.bin/ar/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/usr.bin/ar/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG= ar SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h @@ -8,7 +10,9 @@ LDADD= -larchive -lelf CFLAGS+=-I. -I${.CURDIR} +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif LINKS= ${BINDIR}/ar ${BINDIR}/ranlib MLINKS= ar.1 ranlib.1 Modified: head/usr.bin/make/Makefile ============================================================================== --- head/usr.bin/make/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/usr.bin/make/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -2,13 +2,17 @@ # $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $ # $FreeBSD$ +.include + PROG= make CFLAGS+=-I${.CURDIR} SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \ lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \ util.c var.c +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= YES +.endif # Version has the RYYYYMMDDX format, where R is from RELENG_ CFLAGS+=-DMAKE_VERSION=\"5201111300\" From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 09:37:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E5341065679; Sun, 29 Apr 2012 09:37:03 +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 40A078FC14; Sun, 29 Apr 2012 09:37:03 +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 q3T9b3Ab007395; Sun, 29 Apr 2012 09:37:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T9b3nA007393; Sun, 29 Apr 2012 09:37:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204290937.q3T9b3nA007393@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 29 Apr 2012 09:37:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234783 - head/share/man/man5 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 09:37:03 -0000 Author: kib Date: Sun Apr 29 09:37:02 2012 New Revision: 234783 URL: http://svn.freebsd.org/changeset/base/234783 Log: Regenerate src.conf(5) Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Sun Apr 29 09:32:44 2012 (r234782) +++ head/share/man/man5/src.conf.5 Sun Apr 29 09:37:02 2012 (r234783) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 221733 2011-05-10 13:01:11Z ru .\" $FreeBSD$ -.Dd March 25, 2012 +.Dd April 29, 2012 .Dt SRC.CONF 5 .Os .Sh NAME @@ -270,7 +270,7 @@ When set, it also enforces the following Set to not build the Clang C/C++ compiler. .Pp It is a default setting on -arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64. +arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc and sparc64/sparc64. When set, it also enforces the following options: .Pp .Bl -item -compact @@ -284,7 +284,7 @@ When set, it also enforces the following Set to build the Clang C/C++ compiler. .Pp It is a default setting on -amd64/amd64, i386/i386, pc98/i386, powerpc/powerpc and powerpc/powerpc64. +amd64/amd64, i386/i386, pc98/i386 and powerpc/powerpc64. .It Va WITH_CLANG_EXTRAS .\" from FreeBSD: head/tools/build/options/WITH_CLANG_EXTRAS 231057 2012-02-05 23:56:22Z dim Set to build additional clang and llvm tools, such as bugpoint. @@ -891,6 +891,13 @@ as a set-user-ID root program. Set to not build the .Bx 4.4 legacy docs. +.It Va WITH_SHARED_TOOLCHAIN +.\" from FreeBSD: head/tools/build/options/WITH_SHARED_TOOLCHAIN 234782 2012-04-29 09:32:44Z kib +Set to build the toolchain binaries shared. +The set includes +.Xr cc 1 , +.Xr make 1 +and neccessary utilites like assembler, linker and library archive manager. .It Va WITHOUT_SOURCELESS .\" from FreeBSD: head/tools/build/options/WITHOUT_SOURCELESS 230972 2012-02-04 00:54:43Z rmh Set to not build kernel modules that include sourceless code (either microcode or native code for host CPU). From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 10:04:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE70B106564A; Sun, 29 Apr 2012 10:04:20 +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 C8B038FC16; Sun, 29 Apr 2012 10:04:20 +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 q3TA4KqX008402; Sun, 29 Apr 2012 10:04:20 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TA4KQt008400; Sun, 29 Apr 2012 10:04:20 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204291004.q3TA4KQt008400@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 29 Apr 2012 10:04:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234784 - stable/8/sys/vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 10:04:21 -0000 Author: kib Date: Sun Apr 29 10:04:20 2012 New Revision: 234784 URL: http://svn.freebsd.org/changeset/base/234784 Log: MFC r234556: When MAP_STACK mapping is created, the map entry is created only to cover the initial stack size. For MCL_WIREFUTURE maps, the subsequent call to vm_map_wire() to wire the whole stack region fails due to VM_MAP_WIRE_NOHOLES flag. Use the VM_MAP_WIRE_HOLESOK to only wire mapped part of the stack. Modified: stable/8/sys/vm/vm_mmap.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/vm/vm_mmap.c ============================================================================== --- stable/8/sys/vm/vm_mmap.c Sun Apr 29 09:37:02 2012 (r234783) +++ stable/8/sys/vm/vm_mmap.c Sun Apr 29 10:04:20 2012 (r234784) @@ -1435,7 +1435,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, */ if ((rv == KERN_SUCCESS) && (map->flags & MAP_WIREFUTURE)) vm_map_wire(map, *addr, *addr + size, - VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); + VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? + VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); return (vm_mmap_to_errno(rv)); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 11:04:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 46703106564A; Sun, 29 Apr 2012 11:04:32 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EAB68FC0A; Sun, 29 Apr 2012 11:04:32 +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 q3TB4W1T011293; Sun, 29 Apr 2012 11:04:32 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TB4VbQ011280; Sun, 29 Apr 2012 11:04:31 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201204291104.q3TB4VbQ011280@svn.freebsd.org> From: Dimitry Andric Date: Sun, 29 Apr 2012 11:04: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: r234785 - in head: include sys/amd64/include sys/arm/include sys/i386/include sys/ia64/include sys/mips/include sys/powerpc/include sys/sparc64/include sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 11:04:32 -0000 Author: dim Date: Sun Apr 29 11:04:31 2012 New Revision: 234785 URL: http://svn.freebsd.org/changeset/base/234785 Log: Add a convenience macro for the returns_twice attribute, and apply it to the prototypes of the appropriate functions (getcontext, savectx, setjmp, sigsetjmp and vfork). MFC after: 2 weeks Modified: head/include/setjmp.h head/include/unistd.h head/sys/amd64/include/pcb.h head/sys/arm/include/pcb.h head/sys/i386/include/pcb.h head/sys/ia64/include/pcb.h head/sys/mips/include/pcb.h head/sys/powerpc/include/cpu.h head/sys/sparc64/include/pcb.h head/sys/sys/cdefs.h head/sys/sys/systm.h head/sys/sys/ucontext.h Modified: head/include/setjmp.h ============================================================================== --- head/include/setjmp.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/include/setjmp.h Sun Apr 29 11:04:31 2012 (r234785) @@ -46,16 +46,16 @@ __BEGIN_DECLS #if __BSD_VISIBLE || __XSI_VISIBLE >= 600 void _longjmp(jmp_buf, int) __dead2; -int _setjmp(jmp_buf); +int _setjmp(jmp_buf) __returns_twice; #endif void longjmp(jmp_buf, int) __dead2; #if __BSD_VISIBLE void longjmperror(void); #endif -int setjmp(jmp_buf); +int setjmp(jmp_buf) __returns_twice; #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE void siglongjmp(sigjmp_buf, int) __dead2; -int sigsetjmp(sigjmp_buf, int); +int sigsetjmp(sigjmp_buf, int) __returns_twice; #endif __END_DECLS Modified: head/include/unistd.h ============================================================================== --- head/include/unistd.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/include/unistd.h Sun Apr 29 11:04:31 2012 (r234785) @@ -479,7 +479,7 @@ char *getwd(char *); /* obsoleted by g useconds_t ualarm(useconds_t, useconds_t); int usleep(useconds_t); -pid_t vfork(void); +pid_t vfork(void) __returns_twice; #endif #if __BSD_VISIBLE Modified: head/sys/amd64/include/pcb.h ============================================================================== --- head/sys/amd64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/amd64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -130,7 +130,7 @@ clear_pcb_flags(struct pcb *pcb, const u } void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif Modified: head/sys/arm/include/pcb.h ============================================================================== --- head/sys/arm/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/arm/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -94,7 +94,7 @@ void makectx(struct trapframe *tf, struc #ifdef _KERNEL -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _KERNEL */ #endif /* !_MACHINE_PCB_H_ */ Modified: head/sys/i386/include/pcb.h ============================================================================== --- head/sys/i386/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/i386/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -84,7 +84,7 @@ struct pcb { struct trapframe; void makectx(struct trapframe *, struct pcb *); -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif #endif /* _I386_PCB_H_ */ Modified: head/sys/ia64/include/pcb.h ============================================================================== --- head/sys/ia64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/ia64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -65,10 +65,10 @@ struct trapframe; void makectx(struct trapframe *, struct pcb *); void restorectx(struct pcb *) __dead2; -int swapctx(struct pcb *old, struct pcb *new); +int swapctx(struct pcb *old, struct pcb *new) __returns_twice; void ia32_restorectx(struct pcb *); -void ia32_savectx(struct pcb *); +void ia32_savectx(struct pcb *) __returns_twice; #endif Modified: head/sys/mips/include/pcb.h ============================================================================== --- head/sys/mips/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/mips/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -78,7 +78,7 @@ struct pcb extern struct pcb *curpcb; /* the current running pcb */ void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif #endif /* !_MACHINE_PCB_H_ */ Modified: head/sys/powerpc/include/cpu.h ============================================================================== --- head/sys/powerpc/include/cpu.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/powerpc/include/cpu.h Sun Apr 29 11:04:31 2012 (r234785) @@ -99,6 +99,6 @@ void fork_trampoline(void); void swi_vm(void *); /* XXX the following should not be here. */ -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _MACHINE_CPU_H_ */ Modified: head/sys/sparc64/include/pcb.h ============================================================================== --- head/sys/sparc64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sparc64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -55,7 +55,7 @@ struct pcb { #ifdef _KERNEL void makectx(struct trapframe *tf, struct pcb *pcb); -int savectx(struct pcb *pcb); +int savectx(struct pcb *pcb) __returns_twice; #endif #endif /* !LOCORE */ Modified: head/sys/sys/cdefs.h ============================================================================== --- head/sys/sys/cdefs.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/cdefs.h Sun Apr 29 11:04:31 2012 (r234785) @@ -293,6 +293,12 @@ #define __nonnull(x) #endif +#if __GNUC_PREREQ__(4, 1) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice +#endif + /* XXX: should use `#if __STDC_VERSION__ < 199901'. */ #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) #define __func__ NULL Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/systm.h Sun Apr 29 11:04:31 2012 (r234785) @@ -153,7 +153,7 @@ struct uio; struct _jmp_buf; struct trapframe; -int setjmp(struct _jmp_buf *); +int setjmp(struct _jmp_buf *) __returns_twice; void longjmp(struct _jmp_buf *, int) __dead2; int dumpstatus(vm_offset_t addr, off_t count); int nullop(void); Modified: head/sys/sys/ucontext.h ============================================================================== --- head/sys/sys/ucontext.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/ucontext.h Sun Apr 29 11:04:31 2012 (r234785) @@ -71,7 +71,7 @@ struct ucontext4 { __BEGIN_DECLS -int getcontext(ucontext_t *); +int getcontext(ucontext_t *) __returns_twice; ucontext_t *getcontextx(void); int setcontext(const ucontext_t *); void makecontext(ucontext_t *, void (*)(void), int, ...); From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 12:48:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE0F5106566C; Sun, 29 Apr 2012 12:48:52 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C8C508FC15; Sun, 29 Apr 2012 12:48:52 +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 q3TCmqVV014786; Sun, 29 Apr 2012 12:48:52 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TCmqGk014783; Sun, 29 Apr 2012 12:48:52 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201204291248.q3TCmqGk014783@svn.freebsd.org> From: Bernhard Schmidt Date: Sun, 29 Apr 2012 12:48:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234786 - in head/usr.sbin/wpa: hostapd wpa_supplicant X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 12:48:53 -0000 Author: bschmidt Date: Sun Apr 29 12:48:52 2012 New Revision: 234786 URL: http://svn.freebsd.org/changeset/base/234786 Log: Fix WITHOUT_EXAMPLES build: While removing unnecessary entries from .PATH.c I missed that for the examples WPA_SUPPLICANT_DISTDIR/HOSTAPD_DISTDIR is explicitly added to .PATH. Tested by: lev MFC after: 2 weeks Modified: head/usr.sbin/wpa/hostapd/Makefile head/usr.sbin/wpa/wpa_supplicant/Makefile Modified: head/usr.sbin/wpa/hostapd/Makefile ============================================================================== --- head/usr.sbin/wpa/hostapd/Makefile Sun Apr 29 11:04:31 2012 (r234785) +++ head/usr.sbin/wpa/hostapd/Makefile Sun Apr 29 12:48:52 2012 (r234786) @@ -2,7 +2,8 @@ .include "${.CURDIR}/../Makefile.inc" -.PATH.c:${WPA_DISTDIR}/src/drivers +.PATH.c:${HOSTAPD_DISTDIR} \ + ${WPA_DISTDIR}/src/drivers PROG= hostapd SRCS= accounting.c \ Modified: head/usr.sbin/wpa/wpa_supplicant/Makefile ============================================================================== --- head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Apr 29 11:04:31 2012 (r234785) +++ head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Apr 29 12:48:52 2012 (r234786) @@ -2,7 +2,8 @@ .include "${.CURDIR}/../Makefile.inc" -.PATH.c:${WPA_DISTDIR}/src/drivers +.PATH.c:${WPA_SUPPLICANT_DISTDIR} \ + ${WPA_DISTDIR}/src/drivers PROG= wpa_supplicant SRCS= aes-unwrap.c \ From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 13:34:38 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F38C106564A; Sun, 29 Apr 2012 13:34:38 +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 D4A538FC12; Sun, 29 Apr 2012 13:34:37 +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 q3TDYbvu016239; Sun, 29 Apr 2012 13:34:37 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TDYbbU016237; Sun, 29 Apr 2012 13:34:37 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291334.q3TDYbbU016237@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 13:34:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234787 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 13:34:38 -0000 Author: tuexen Date: Sun Apr 29 13:34:37 2012 New Revision: 234787 URL: http://svn.freebsd.org/changeset/base/234787 Log: MFC r233311: Small cleanup of the code. No functional change (in FreeBSD kernel). Modified: stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Apr 29 12:48:52 2012 (r234786) +++ stable/9/sys/netinet/sctputil.c Sun Apr 29 13:34:37 2012 (r234787) @@ -5443,28 +5443,31 @@ found_one: } #endif if (fromlen && from) { - struct sockaddr *to; - + cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sa.sa_len); + switch (control->whoFrom->ro._l_addr.sa.sa_family) { +#ifdef INET6 + case AF_INET6: + ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + break; +#endif #ifdef INET - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin.sin_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in *)from)->sin_port = control->port_from; -#else - /* No AF_INET use AF_INET6 */ - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin6.sin6_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + case AF_INET: + ((struct sockaddr_in *)from)->sin_port = control->port_from; + break; #endif + default: + break; + } + memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - to = from; #if defined(INET) && defined(INET6) if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) && - (to->sa_family == AF_INET) && + (from->sa_family == AF_INET) && ((size_t)fromlen >= sizeof(struct sockaddr_in6))) { struct sockaddr_in *sin; struct sockaddr_in6 sin6; - sin = (struct sockaddr_in *)to; + sin = (struct sockaddr_in *)from; bzero(&sin6, sizeof(sin6)); sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); @@ -5473,15 +5476,15 @@ found_one: &sin6.sin6_addr.s6_addr32[3], sizeof(sin6.sin6_addr.s6_addr32[3])); sin6.sin6_port = sin->sin_port; - memcpy(from, (caddr_t)&sin6, sizeof(sin6)); + memcpy(from, &sin6, sizeof(struct sockaddr_in6)); } #endif #if defined(INET6) { - struct sockaddr_in6 lsa6, *to6; + struct sockaddr_in6 lsa6, *from6; - to6 = (struct sockaddr_in6 *)to; - sctp_recover_scope_mac(to6, (&lsa6)); + from6 = (struct sockaddr_in6 *)from; + sctp_recover_scope_mac(from6, (&lsa6)); } #endif } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 13:37:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C643B1065670; Sun, 29 Apr 2012 13:37:32 +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 B0BCE8FC15; Sun, 29 Apr 2012 13:37:32 +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 q3TDbWKE016385; Sun, 29 Apr 2012 13:37:32 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TDbWak016383; Sun, 29 Apr 2012 13:37:32 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291337.q3TDbWak016383@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 13:37:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234788 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 13:37:32 -0000 Author: tuexen Date: Sun Apr 29 13:37:32 2012 New Revision: 234788 URL: http://svn.freebsd.org/changeset/base/234788 Log: MFC r233597: Honor the net.inet.udp.checksum sysctl when using SCTP/UDP/IPv4 encapsulation. Modified: stable/9/sys/netinet/sctp_output.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Apr 29 13:34:37 2012 (r234787) +++ stable/9/sys/netinet/sctp_output.c Sun Apr 29 13:37:32 2012 (r234788) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -4064,7 +4065,11 @@ sctp_lowlevel_chunk_output(struct sctp_i udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons(packet_length - sizeof(struct ip)); - udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); } else { sctphdr = (struct sctphdr *)((caddr_t)ip + sizeof(struct ip)); @@ -4127,7 +4132,9 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_STAT_INCR(sctps_sendnocrc); } #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -11007,8 +11014,13 @@ sctp_send_shutdown_complete2(struct mbuf udp->uh_dport = port; udp->uh_ulen = htons(sizeof(struct sctp_shutdown_complete_msg) + sizeof(struct udphdr)); #ifdef INET - if (iph_out) - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (iph_out) { + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } + } #endif offset_out += sizeof(struct udphdr); comp_cp = (struct sctp_shutdown_complete_msg *)((caddr_t)comp_cp + sizeof(struct udphdr)); @@ -11047,7 +11059,9 @@ sctp_send_shutdown_complete2(struct mbuf comp_cp->sh.checksum = sctp_calculate_cksum(mout, offset_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(mout); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(mout); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12024,7 +12038,11 @@ sctp_send_abort(struct mbuf *m, int iphl bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } SCTPDBG(SCTP_DEBUG_OUTPUT2, "sctp_send_abort calling ip_output:\n"); SCTPDBG_PKT(SCTP_DEBUG_OUTPUT2, iph_out, &abm->sh); @@ -12043,7 +12061,9 @@ sctp_send_abort(struct mbuf *m, int iphl abm->sh.checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12286,7 +12306,11 @@ sctp_send_operr_to(struct mbuf *m, int i bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } /* set IPv4 length */ iph_out->ip_len = len; @@ -12303,7 +12327,9 @@ sctp_send_operr_to(struct mbuf *m, int i sh_out->checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 15:54:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13DE0106566B; Sun, 29 Apr 2012 15:54:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F324B8FC14; Sun, 29 Apr 2012 15:54:40 +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 q3TFseAo020639; Sun, 29 Apr 2012 15:54:40 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TFsemi020637; Sun, 29 Apr 2012 15:54:40 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291554.q3TFsemi020637@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 15:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234789 - head/sys/boot/common X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 15:54:41 -0000 Author: marius Date: Sun Apr 29 15:54:40 2012 New Revision: 234789 URL: http://svn.freebsd.org/changeset/base/234789 Log: Add multiple inclusion protection. PR: 165025 Submitted by: Gavin Mu MFC after: 1 week Modified: head/sys/boot/common/bootstrap.h Modified: head/sys/boot/common/bootstrap.h ============================================================================== --- head/sys/boot/common/bootstrap.h Sun Apr 29 13:37:32 2012 (r234788) +++ head/sys/boot/common/bootstrap.h Sun Apr 29 15:54:40 2012 (r234789) @@ -26,6 +26,9 @@ * $FreeBSD$ */ +#ifndef _BOOTSTRAP_H_ +#define _BOOTSTRAP_H_ + #include #include #include @@ -323,3 +326,5 @@ void delay(int delay); void dev_cleanup(void); time_t time(time_t *tloc); + +#endif /* !_BOOTSTRAP_H_ */ From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:10:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 824E1106566C; Sun, 29 Apr 2012 16:10:25 +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 696238FC12; Sun, 29 Apr 2012 16:10: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 q3TGAPom021177; Sun, 29 Apr 2012 16:10:25 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGAP4r021164; Sun, 29 Apr 2012 16:10:25 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291610.q3TGAP4r021164@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:10:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234790 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:10:25 -0000 Author: tuexen Date: Sun Apr 29 16:10:24 2012 New Revision: 234790 URL: http://svn.freebsd.org/changeset/base/234790 Log: MFC r233660: Make stream our stream reset implementation compliant to RFC6525. From rrs@. Modified: stable/9/sys/netinet/sctp.h stable/9/sys/netinet/sctp_constants.h stable/9/sys/netinet/sctp_header.h stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_output.h stable/9/sys/netinet/sctp_pcb.h stable/9/sys/netinet/sctp_peeloff.c stable/9/sys/netinet/sctp_structs.h stable/9/sys/netinet/sctp_uio.h stable/9/sys/netinet/sctp_usrreq.c stable/9/sys/netinet/sctputil.c stable/9/sys/netinet/sctputil.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp.h ============================================================================== --- stable/9/sys/netinet/sctp.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp.h Sun Apr 29 16:10:24 2012 (r234790) @@ -155,8 +155,22 @@ struct sctp_paramhdr { * field. */ -/* these should probably go into sockets API */ -#define SCTP_RESET_STREAMS 0x00001004 /* wo */ +#define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct + * sctp_assoc_value */ +#define SCTP_RESET_STREAMS 0x00000901 /* struct + * sctp_reset_streams */ +#define SCTP_RESET_ASSOC 0x00000902 /* sctp_assoc_t */ +#define SCTP_ADD_STREAMS 0x00000903 /* struct + * sctp_add_streams */ + +/* For enable stream reset */ +#define SCTP_ENABLE_RESET_STREAM_REQ 0x00000001 +#define SCTP_ENABLE_RESET_ASSOC_REQ 0x00000002 +#define SCTP_ENABLE_CHANGE_ASSOC_REQ 0x00000004 +#define SCTP_ENABLE_VALUE_MASK 0x00000007 +/* For reset streams */ +#define SCTP_STREAM_RESET_INCOMING 0x00000001 +#define SCTP_STREAM_RESET_OUTGOING 0x00000002 /* here on down are more implementation specific */ Modified: stable/9/sys/netinet/sctp_constants.h ============================================================================== --- stable/9/sys/netinet/sctp_constants.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_constants.h Sun Apr 29 16:10:24 2012 (r234790) @@ -418,7 +418,8 @@ __FBSDID("$FreeBSD$"); #define SCTP_STR_RESET_IN_REQUEST 0x000e #define SCTP_STR_RESET_TSN_REQUEST 0x000f #define SCTP_STR_RESET_RESPONSE 0x0010 -#define SCTP_STR_RESET_ADD_STREAMS 0x0011 +#define SCTP_STR_RESET_ADD_OUT_STREAMS 0x0011 +#define SCTP_STR_RESET_ADD_IN_STREAMS 0x0012 #define SCTP_MAX_RESET_PARAMS 2 #define SCTP_STREAM_RESET_TSN_DELTA 0x1000 Modified: stable/9/sys/netinet/sctp_header.h ============================================================================== --- stable/9/sys/netinet/sctp_header.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_header.h Sun Apr 29 16:10:24 2012 (r234790) @@ -501,7 +501,7 @@ struct sctp_stream_reset_add_strm { #define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ #define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ -#define SCTP_STREAM_RESET_DENIED 0x00000002 /* refused to do it */ +#define SCTP_STREAM_RESET_REJECT 0x00000002 /* refused to do it */ #define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ #define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ #define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_input.c Sun Apr 29 16:10:24 2012 (r234790) @@ -2790,6 +2790,7 @@ sctp_handle_cookie_echo(struct mbuf *m, inp->sctp_ecn_enable = (*inp_p)->sctp_ecn_enable; inp->partial_delivery_point = (*inp_p)->partial_delivery_point; inp->sctp_context = (*inp_p)->sctp_context; + inp->local_strreset_support = (*inp_p)->local_strreset_support; inp->inp_starting_point_for_iterator = NULL; /* * copy in the authentication parameters from the @@ -3612,20 +3613,35 @@ sctp_handle_stream_reset_response(struct if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action != SCTP_STREAM_RESET_PERFORMED) { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, + number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } - } else if (type == SCTP_STR_RESET_ADD_STREAMS) { + } else if (type == SCTP_STR_RESET_ADD_OUT_STREAMS) { /* Ok we now may have more streams */ + int num_stream; + + num_stream = stcb->asoc.strm_pending_add_size; + if (num_stream > (stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt)) { + /* TSNH */ + num_stream = stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt; + } + stcb->asoc.strm_pending_add_size = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action == SCTP_STREAM_RESET_PERFORMED) { /* Put the new streams into effect */ - stcb->asoc.streamoutcnt = stcb->asoc.strm_realoutsize; - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD_OK, stcb, - (uint32_t) stcb->asoc.streamoutcnt, NULL, SCTP_SO_NOT_LOCKED); + stcb->asoc.streamoutcnt += num_stream; + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } else { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD_FAIL, stcb, - (uint32_t) stcb->asoc.streamoutcnt, NULL, SCTP_SO_NOT_LOCKED); + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGED_DENIED); + } + } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { + if (asoc->stream_reset_outstanding) + asoc->stream_reset_outstanding--; + if (action != SCTP_STREAM_RESET_PERFORMED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGED_DENIED); } } else if (type == SCTP_STR_RESET_TSN_REQUEST) { /** @@ -3667,7 +3683,10 @@ sctp_handle_stream_reset_response(struct sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); - + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + } else { + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), + SCTP_STREAM_RESET_FAILED); } } /* get rid of the request and get the request flags */ @@ -3700,8 +3719,7 @@ sctp_handle_str_reset_request_in(struct if (trunc) { /* Can't do it, since they exceeded our buffer size */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; - sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else if (stcb->asoc.stream_reset_out_is_outstanding == 0) { len = ntohs(req->ph.param_length); number_entries = ((len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t)); @@ -3723,8 +3741,8 @@ sctp_handle_str_reset_request_in(struct /* Can't do it, since we have sent one out */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; asoc->last_reset_action[0] = SCTP_STREAM_RESET_TRY_LATER; - sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); @@ -3786,7 +3804,7 @@ sctp_handle_str_reset_request_tsn(struct sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[0], @@ -3831,12 +3849,10 @@ sctp_handle_str_reset_request_out(struct /* move the reset action back one */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; if (trunc) { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* we can do it now */ sctp_reset_in_stream(stcb, number_entries, req->list_of_streams); - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; } else { /* @@ -3851,8 +3867,8 @@ sctp_handle_str_reset_request_out(struct siz, SCTP_M_STRESET); if (liste == NULL) { /* gak out of memory */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_REJECT); + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; return; } liste->tsn = tsn; @@ -3860,9 +3876,9 @@ sctp_handle_str_reset_request_out(struct memcpy(&liste->req, req, (sizeof(struct sctp_stream_reset_out_request) + (number_entries * sizeof(uint16_t)))); TAILQ_INSERT_TAIL(&asoc->resetHead, liste, next_resp); - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; } else if ((asoc->str_reset_seq_in - 1) == seq) { /* @@ -3889,7 +3905,7 @@ sctp_handle_str_reset_add_strm(struct sc * Peer is requesting to add more streams. If its within our * max-streams we will allow it. */ - uint16_t num_stream, i; + uint32_t num_stream, i; uint32_t seq; struct sctp_association *asoc = &stcb->asoc; struct sctp_queued_to_read *ctl, *nctl; @@ -3900,12 +3916,12 @@ sctp_handle_str_reset_add_strm(struct sc /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { num_stream += stcb->asoc.streamincnt; - if (num_stream > stcb->asoc.max_inbound_streams) { + if ((num_stream > stcb->asoc.max_inbound_streams) || + (num_stream > 0xffff)) { /* We must reject it they ask for to many */ denied: - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else { /* Ok, we can do that :-) */ struct sctp_stream_in *oldstrm; @@ -3941,13 +3957,12 @@ sctp_handle_str_reset_add_strm(struct sc SCTP_FREE(oldstrm, SCTP_M_STRMI); /* update the size */ stcb->asoc.streamincnt = num_stream; - /* Send the ack */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_INSTREAM_ADD_OK, stcb, - (uint32_t) stcb->asoc.streamincnt, NULL, SCTP_SO_NOT_LOCKED); + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + asoc->str_reset_seq_in++; } else if ((asoc->str_reset_seq_in - 1) == seq) { /* * one seq back, just echo back last action since my @@ -3966,6 +3981,63 @@ sctp_handle_str_reset_add_strm(struct sc } } +static void +sctp_handle_str_reset_add_out_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk, + struct sctp_stream_reset_add_strm *str_add) +{ + /* + * Peer is requesting to add more streams. If its within our + * max-streams we will allow it. + */ + uint16_t num_stream; + uint32_t seq; + struct sctp_association *asoc = &stcb->asoc; + + /* Get the number. */ + seq = ntohl(str_add->request_seq); + num_stream = ntohs(str_add->number_of_streams); + /* Now what would be the new total? */ + if (asoc->str_reset_seq_in == seq) { + if (stcb->asoc.stream_reset_outstanding) { + /* We must reject it we have something pending */ + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } else { + /* Ok, we can do that :-) */ + int mychk; + + mychk = stcb->asoc.streamoutcnt; + mychk += num_stream; + if (mychk < 0x10000) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + if (sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, 1, num_stream, 0, 1)) { + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } + } else { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } + } + sctp_add_stream_reset_result(chk, seq, stcb->asoc.last_reset_action[0]); + asoc->str_reset_seq_in++; + } else if ((asoc->str_reset_seq_in - 1) == seq) { + /* + * one seq back, just echo back last action since my + * response was lost. + */ + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + } else if ((asoc->str_reset_seq_in - 2) == seq) { + /* + * two seq back, just echo back last action since my + * response was lost. + */ + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); + } else { + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + } +} + #ifdef __GNUC__ __attribute__((noinline)) #endif @@ -3977,7 +4049,7 @@ __attribute__((noinline)) struct sctp_paramhdr pstore; uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE]; - uint32_t seq; + uint32_t seq = 0; int num_req = 0; int trunc = 0; struct sctp_tmit_chunk *chk; @@ -4041,7 +4113,6 @@ strres_nochunk: } else { trunc = 0; } - if (num_param > SCTP_MAX_RESET_PARAMS) { /* hit the max of parameters already sorry.. */ break; @@ -4059,26 +4130,29 @@ strres_nochunk: } } sctp_handle_str_reset_request_out(stcb, chk, req_out, trunc); - } else if (ptype == SCTP_STR_RESET_ADD_STREAMS) { + } else if (ptype == SCTP_STR_RESET_ADD_OUT_STREAMS) { struct sctp_stream_reset_add_strm *str_add; str_add = (struct sctp_stream_reset_add_strm *)ph; num_req++; sctp_handle_str_reset_add_strm(stcb, chk, str_add); + } else if (ptype == SCTP_STR_RESET_ADD_IN_STREAMS) { + struct sctp_stream_reset_add_strm *str_add; + + str_add = (struct sctp_stream_reset_add_strm *)ph; + num_req++; + sctp_handle_str_reset_add_out_strm(stcb, chk, str_add); } else if (ptype == SCTP_STR_RESET_IN_REQUEST) { struct sctp_stream_reset_in_request *req_in; num_req++; - req_in = (struct sctp_stream_reset_in_request *)ph; - sctp_handle_str_reset_request_in(stcb, chk, req_in, trunc); } else if (ptype == SCTP_STR_RESET_TSN_REQUEST) { struct sctp_stream_reset_tsn_request *req_tsn; num_req++; req_tsn = (struct sctp_stream_reset_tsn_request *)ph; - if (sctp_handle_str_reset_request_tsn(stcb, chk, req_tsn)) { ret_code = 1; goto strres_nochunk; Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_output.c Sun Apr 29 16:10:24 2012 (r234790) @@ -11716,7 +11716,7 @@ sctp_add_stream_reset_result_tsn(struct } static void -sctp_add_a_stream(struct sctp_tmit_chunk *chk, +sctp_add_an_out_stream(struct sctp_tmit_chunk *chk, uint32_t seq, uint16_t adding) { @@ -11733,7 +11733,7 @@ sctp_add_a_stream(struct sctp_tmit_chunk len = sizeof(struct sctp_stream_reset_add_strm); /* Fill it out. */ - addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_STREAMS); + addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_OUT_STREAMS); addstr->ph.param_length = htons(len); addstr->request_seq = htonl(seq); addstr->number_of_streams = htons(adding); @@ -11748,15 +11748,49 @@ sctp_add_a_stream(struct sctp_tmit_chunk return; } +static void +sctp_add_an_in_stream(struct sctp_tmit_chunk *chk, + uint32_t seq, + uint16_t adding) +{ + int len, old_len; + struct sctp_chunkhdr *ch; + struct sctp_stream_reset_add_strm *addstr; + + ch = mtod(chk->data, struct sctp_chunkhdr *); + old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); + + /* get to new offset for the param. */ + addstr = (struct sctp_stream_reset_add_strm *)((caddr_t)ch + len); + /* now how long will this param be? */ + len = sizeof(struct sctp_stream_reset_add_strm); + /* Fill it out. */ + addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_IN_STREAMS); + addstr->ph.param_length = htons(len); + addstr->request_seq = htonl(seq); + addstr->number_of_streams = htons(adding); + addstr->reserved = 0; + + /* now fix the chunk length */ + ch->chunk_length = htons(len + old_len); + chk->send_size = len + old_len; + chk->book_size = SCTP_SIZE32(chk->send_size); + chk->book_size_scale = 0; + SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); + return; +} + + + int sctp_send_str_reset_req(struct sctp_tcb *stcb, int number_entries, uint16_t * list, uint8_t send_out_req, - uint32_t resp_seq, uint8_t send_in_req, uint8_t send_tsn_req, uint8_t add_stream, - uint16_t adding + uint16_t adding_o, + uint16_t adding_i, uint8_t peer_asked ) { @@ -11823,18 +11857,86 @@ sctp_send_str_reset_req(struct sctp_tcb seq = stcb->asoc.str_reset_seq_out; if (send_out_req) { sctp_add_stream_reset_out(chk, number_entries, list, - seq, resp_seq, (stcb->asoc.sending_seq - 1)); + seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1)); asoc->stream_reset_out_is_outstanding = 1; seq++; asoc->stream_reset_outstanding++; } - if (add_stream) { - sctp_add_a_stream(chk, seq, adding); + if ((add_stream & 1) && + ((stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt) < adding_o)) { + /* Need to allocate more */ + struct sctp_stream_out *oldstream; + struct sctp_stream_queue_pending *sp, *nsp; + int i; + + oldstream = stcb->asoc.strmout; + /* get some more */ + SCTP_MALLOC(stcb->asoc.strmout, struct sctp_stream_out *, + ((stcb->asoc.streamoutcnt + adding_o) * sizeof(struct sctp_stream_out)), + SCTP_M_STRMO); + if (stcb->asoc.strmout == NULL) { + uint8_t x; + + stcb->asoc.strmout = oldstream; + /* Turn off the bit */ + x = add_stream & 0xfe; + add_stream = x; + goto skip_stuff; + } + /* + * Ok now we proceed with copying the old out stuff and + * initializing the new stuff. + */ + SCTP_TCB_SEND_LOCK(stcb); + stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 0, 1); + for (i = 0; i < stcb->asoc.streamoutcnt; i++) { + TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].next_sequence_sent = oldstream[i].next_sequence_sent; + stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; + stcb->asoc.strmout[i].stream_no = i; + stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], &oldstream[i]); + /* now anything on those queues? */ + TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) { + TAILQ_REMOVE(&oldstream[i].outqueue, sp, next); + TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); + } + /* Now move assoc pointers too */ + if (stcb->asoc.last_out_stream == &oldstream[i]) { + stcb->asoc.last_out_stream = &stcb->asoc.strmout[i]; + } + if (stcb->asoc.locked_on_sending == &oldstream[i]) { + stcb->asoc.locked_on_sending = &stcb->asoc.strmout[i]; + } + } + /* now the new streams */ + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); + for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + adding_o); i++) { + stcb->asoc.strmout[i].next_sequence_sent = 0x0; + TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].stream_no = i; + stcb->asoc.strmout[i].last_msg_incomplete = 0; + stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL); + } + stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt + adding_o; + SCTP_FREE(oldstream, SCTP_M_STRMO); + SCTP_TCB_SEND_UNLOCK(stcb); + } +skip_stuff: + if ((add_stream & 1) && (adding_o > 0)) { + asoc->strm_pending_add_size = adding_o; + asoc->peer_req_out = peer_asked; + sctp_add_an_out_stream(chk, seq, adding_o); + seq++; + asoc->stream_reset_outstanding++; + } + if ((add_stream & 2) && (adding_i > 0)) { + sctp_add_an_in_stream(chk, seq, adding_i); seq++; asoc->stream_reset_outstanding++; } if (send_in_req) { sctp_add_stream_reset_in(chk, number_entries, list, seq); + seq++; asoc->stream_reset_outstanding++; } if (send_tsn_req) { @@ -11842,7 +11944,6 @@ sctp_send_str_reset_req(struct sctp_tcb asoc->stream_reset_outstanding++; } asoc->str_reset = chk; - /* insert the chunk for sending */ TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_output.h Sun Apr 29 16:10:24 2012 (r234790) @@ -194,15 +194,13 @@ sctp_add_stream_reset_result_tsn(struct int sctp_send_str_reset_req(struct sctp_tcb *stcb, - int number_entries, - uint16_t * list, + int number_entries, uint16_t * list, uint8_t send_out_req, - uint32_t resp_seq, uint8_t send_in_req, uint8_t send_tsn_req, - uint8_t add_str, - uint16_t adding); - + uint8_t add_stream, + uint16_t adding_o, + uint16_t adding_i, uint8_t from_peer); void sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t, Modified: stable/9/sys/netinet/sctp_pcb.h ============================================================================== --- stable/9/sys/netinet/sctp_pcb.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_pcb.h Sun Apr 29 16:10:24 2012 (r234790) @@ -399,6 +399,7 @@ struct sctp_inpcb { uint32_t sctp_frag_point; uint32_t partial_delivery_point; uint32_t sctp_context; + uint8_t local_strreset_support; uint32_t sctp_cmt_on_off; uint32_t sctp_ecn_enable; struct sctp_nonpad_sndrcvinfo def_send; Modified: stable/9/sys/netinet/sctp_peeloff.c ============================================================================== --- stable/9/sys/netinet/sctp_peeloff.c Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_peeloff.c Sun Apr 29 16:10:24 2012 (r234790) @@ -127,6 +127,7 @@ sctp_do_peeloff(struct socket *head, str n_inp->sctp_ecn_enable = inp->sctp_ecn_enable; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ if (n_inp->sctp_ep.local_hmacs) @@ -202,6 +203,7 @@ sctp_get_peeloff(struct socket *head, sc n_inp->sctp_ecn_enable = inp->sctp_ecn_enable; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ Modified: stable/9/sys/netinet/sctp_structs.h ============================================================================== --- stable/9/sys/netinet/sctp_structs.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_structs.h Sun Apr 29 16:10:24 2012 (r234790) @@ -1095,6 +1095,7 @@ struct sctp_association { uint16_t streamincnt; uint16_t streamoutcnt; uint16_t strm_realoutsize; + uint16_t strm_pending_add_size; /* my maximum number of retrans of INIT and SEND */ /* copied from SCTP but should be individually setable */ uint16_t max_init_times; @@ -1156,6 +1157,9 @@ struct sctp_association { /* Flag to tell if ECN is allowed */ uint8_t ecn_allowed; + /* Did the peer make the stream config (add out) request */ + uint8_t peer_req_out; + /* flag to indicate if peer can do asconf */ uint8_t peer_supports_asconf; /* EY - flag to indicate if peer can do nr_sack */ @@ -1166,6 +1170,7 @@ struct sctp_association { uint8_t peer_supports_auth; /* stream resets are supported by the peer */ uint8_t peer_supports_strreset; + uint8_t local_strreset_support; uint8_t peer_supports_nat; /* Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_uio.h Sun Apr 29 16:10:24 2012 (r234790) @@ -438,23 +438,51 @@ struct sctp_sender_dry_event { /* - * stream reset event + * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT */ struct sctp_stream_reset_event { uint16_t strreset_type; uint16_t strreset_flags; uint32_t strreset_length; sctp_assoc_t strreset_assoc_id; - uint16_t strreset_list[]; + uint16_t strreset_stream_list[]; }; -/* flags in strreset_flags field */ -#define SCTP_STRRESET_INBOUND_STR 0x0001 -#define SCTP_STRRESET_OUTBOUND_STR 0x0002 -#define SCTP_STRRESET_ALL_STREAMS 0x0004 -#define SCTP_STRRESET_STREAM_LIST 0x0008 -#define SCTP_STRRESET_FAILED 0x0010 -#define SCTP_STRRESET_ADD_STREAM 0x0020 +/* flags in stream_reset_event (strreset_flags) */ +#define SCTP_STREAM_RESET_DENIED 0x0004 /* SCTP_STRRESET_FAILED */ +#define SCTP_STREAM_RESET_FAILED 0x0008 /* SCTP_STRRESET_FAILED */ +#define SCTP_STREAM_CHANGED_DENIED 0x0010 + +/* + * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT + */ +struct sctp_assoc_reset_event { + uint16_t assocreset_type; + uint16_t assocreset_flags; + uint32_t assocreset_length; + sctp_assoc_t assocreset_assoc_id; + uint32_t assocreset_local_tsn; + uint32_t assocreset_remote_tsn; +}; + +#define SCTP_ASSOC_RESET_DENIED 0x0004 +#define SCTP_ASSOC_RESET_FAILED 0x0008 + +/* + * Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT + */ +struct sctp_stream_change_event { + uint16_t strchange_type; + uint16_t strchange_flags; + uint32_t strchange_length; + sctp_assoc_t strchange_assoc_id; + uint16_t strchange_instrms; + uint16_t strchange_outstrms; +}; + +#define SCTP_STREAM_CHANGE_DENIED 0x0004 +#define SCTP_STREAM_CHANGE_FAILED 0x0008 + /* SCTP notification event */ struct sctp_tlv { @@ -477,6 +505,9 @@ union sctp_notification { struct sctp_authkey_event sn_auth_event; struct sctp_sender_dry_event sn_sender_dry_event; struct sctp_stream_reset_event sn_strreset_event; + struct sctp_assoc_reset_event sn_assocreset_event; + struct sctp_stream_change_event sn_strchange_event; + }; /* notification types */ @@ -493,6 +524,9 @@ union sctp_notification { #define SCTP_STREAM_RESET_EVENT 0x0009 #define SCTP_SENDER_DRY_EVENT 0x000a #define SCTP_NOTIFICATIONS_STOPPED_EVENT 0x000b /* we don't send this */ +#define SCTP_ASSOC_RESET_EVENT 0x000c +#define SCTP_STREAM_CHANGE_EVENT 0x000d + /* * socket option structs */ @@ -707,19 +741,18 @@ struct sctp_blk_args { */ #define SCTP_MAX_EXPLICT_STR_RESET 1000 -#define SCTP_RESET_LOCAL_RECV 0x0001 -#define SCTP_RESET_LOCAL_SEND 0x0002 -#define SCTP_RESET_BOTH 0x0003 -#define SCTP_RESET_TSN 0x0004 -#define SCTP_RESET_ADD_STREAMS 0x0005 - -struct sctp_stream_reset { - sctp_assoc_t strrst_assoc_id; - uint16_t strrst_flags; - uint16_t strrst_num_streams; /* 0 == ALL */ - uint16_t strrst_list[]; /* list if strrst_num_streams is not 0 */ +struct sctp_reset_streams { + sctp_assoc_t srs_assoc_id; + uint16_t srs_flags; + uint16_t srs_number_streams; /* 0 == ALL */ + uint16_t srs_stream_list[]; /* list if strrst_num_streams is not 0 */ }; +struct sctp_add_streams { + sctp_assoc_t sas_assoc_id; + uint16_t sas_instrms; + uint16_t sas_outstrms; +}; struct sctp_get_nonce_values { sctp_assoc_t gn_assoc_id; Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 15:54:40 2012 (r234789) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 16:10:24 2012 (r234790) @@ -4088,17 +4088,52 @@ sctp_setopt(struct socket *so, int optna } break; } + case SCTP_ENABLE_STREAM_RESET: + { + struct sctp_assoc_value *av; + uint8_t set_value = 0; + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); + if (av->assoc_value & (~SCTP_ENABLE_VALUE_MASK)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; + } + set_value = av->assoc_value & SCTP_ENABLE_VALUE_MASK; + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + if (stcb) { + stcb->asoc.local_strreset_support = set_value; + SCTP_TCB_UNLOCK(stcb); + } else { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || + (av->assoc_id == SCTP_FUTURE_ASSOC) || + (av->assoc_id == SCTP_ALL_ASSOC)) { + SCTP_INP_WLOCK(inp); + inp->local_strreset_support = set_value; + SCTP_INP_WUNLOCK(inp); + } + if ((av->assoc_id == SCTP_CURRENT_ASSOC) || + (av->assoc_id == SCTP_ALL_ASSOC)) { + SCTP_INP_RLOCK(inp); + LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { + SCTP_TCB_LOCK(stcb); + stcb->asoc.local_strreset_support = set_value; + SCTP_TCB_UNLOCK(stcb); + } + SCTP_INP_RUNLOCK(inp); + } + } + break; + } case SCTP_RESET_STREAMS: { - struct sctp_stream_reset *strrst; - uint8_t send_in = 0, send_tsn = 0, send_out = 0, - addstream = 0; - uint16_t addstrmcnt = 0; - int i; + struct sctp_reset_streams *strrst; + int i, send_out = 0; + int send_in = 0; - SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_stream_reset, optsize); - SCTP_FIND_STCB(inp, stcb, strrst->strrst_assoc_id); + SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_reset_streams, optsize); + SCTP_FIND_STCB(inp, stcb, strrst->srs_assoc_id); if (stcb == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); @@ -4107,13 +4142,19 @@ sctp_setopt(struct socket *so, int optna } if (stcb->asoc.peer_supports_strreset == 0) { /* - * Peer does not support it, we return - * protocol not supported since this is true - * for this feature and this peer, not the - * socket request in general. + * Peer does not support the chunk type. */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPROTONOSUPPORT); - error = EPROTONOSUPPORT; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; + SCTP_TCB_UNLOCK(stcb); + break; + } + if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + /* + * User did not enable the operation. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); + error = EPERM; SCTP_TCB_UNLOCK(stcb); break; } @@ -4123,129 +4164,137 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (strrst->strrst_flags == SCTP_RESET_LOCAL_RECV) { - send_in = 1; - } else if (strrst->strrst_flags == SCTP_RESET_LOCAL_SEND) { - send_out = 1; - } else if (strrst->strrst_flags == SCTP_RESET_BOTH) { + if (strrst->srs_flags & SCTP_STREAM_RESET_INCOMING) { send_in = 1; + } + if (strrst->srs_flags & SCTP_STREAM_RESET_OUTGOING) { send_out = 1; - } else if (strrst->strrst_flags == SCTP_RESET_TSN) { - send_tsn = 1; - } else if (strrst->strrst_flags == SCTP_RESET_ADD_STREAMS) { - if (send_tsn || - send_in || - send_out) { - /* We can't do that and add streams */ + } + if ((send_in == 0) && (send_out == 0)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + SCTP_TCB_UNLOCK(stcb); + break; + } + for (i = 0; i < strrst->srs_number_streams; i++) { + if ((send_in) && + (strrst->srs_stream_list[i] > stcb->asoc.streamincnt)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; - goto skip_stuff; + break; } - if (stcb->asoc.stream_reset_outstanding) { - error = EBUSY; - goto skip_stuff; + if ((send_out) && + (strrst->srs_stream_list[i] > stcb->asoc.streamoutcnt)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; } + } + if (error) { + SCTP_TCB_UNLOCK(stcb); + break; + } + error = sctp_send_str_reset_req(stcb, strrst->srs_number_streams, + strrst->srs_stream_list, + send_out, send_in, 0, 0, 0, 0, 0); + + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_REQ, SCTP_SO_LOCKED); + SCTP_TCB_UNLOCK(stcb); + break; + } + case SCTP_ADD_STREAMS: + { + struct sctp_add_streams *stradd; + uint8_t addstream = 0; + uint16_t add_o_strmcnt = 0; + uint16_t add_i_strmcnt = 0; + + SCTP_CHECK_AND_CAST(stradd, optval, struct sctp_add_streams, optsize); + SCTP_FIND_STCB(inp, stcb, stradd->sas_assoc_id); + if (stcb == NULL) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); + error = ENOENT; + break; + } + if ((stradd->sas_outstrms == 0) && + (stradd->sas_instrms == 0)) { + error = EINVAL; + goto skip_stuff; + } + if (stradd->sas_outstrms) { addstream = 1; /* We allocate here */ - addstrmcnt = strrst->strrst_num_streams; - if ((int)(addstrmcnt + stcb->asoc.streamoutcnt) > 0xffff) { + add_o_strmcnt = stradd->sas_outstrms; + if ((((int)add_o_strmcnt) + ((int)stcb->asoc.streamoutcnt)) > 0x0000ffff) { /* You can't have more than 64k */ error = EINVAL; goto skip_stuff; } - if ((stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt) < addstrmcnt) { - /* Need to allocate more */ - struct sctp_stream_out *oldstream; - struct sctp_stream_queue_pending *sp, - *nsp; - - oldstream = stcb->asoc.strmout; - /* get some more */ - SCTP_MALLOC(stcb->asoc.strmout, struct sctp_stream_out *, - ((stcb->asoc.streamoutcnt + addstrmcnt) * sizeof(struct sctp_stream_out)), - SCTP_M_STRMO); - if (stcb->asoc.strmout == NULL) { - stcb->asoc.strmout = oldstream; - error = ENOMEM; - goto skip_stuff; - } - /* - * Ok now we proceed with copying - * the old out stuff and - * initializing the new stuff. - */ - SCTP_TCB_SEND_LOCK(stcb); - stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 0, 1); - for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); - stcb->asoc.strmout[i].next_sequence_sent = oldstream[i].next_sequence_sent; - stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; - stcb->asoc.strmout[i].stream_no = i; - stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], &oldstream[i]); - /* - * now anything on those - * queues? - */ - TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) { - TAILQ_REMOVE(&oldstream[i].outqueue, sp, next); - TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); - } - /* - * Now move assoc pointers - * too - */ - if (stcb->asoc.last_out_stream == &oldstream[i]) { - stcb->asoc.last_out_stream = &stcb->asoc.strmout[i]; - } - if (stcb->asoc.locked_on_sending == &oldstream[i]) { - stcb->asoc.locked_on_sending = &stcb->asoc.strmout[i]; - } - } - /* now the new streams */ - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); - for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + addstrmcnt); i++) { - stcb->asoc.strmout[i].next_sequence_sent = 0x0; - TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); - stcb->asoc.strmout[i].stream_no = i; - stcb->asoc.strmout[i].last_msg_incomplete = 0; - stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL); - } - stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt + addstrmcnt; - SCTP_FREE(oldstream, SCTP_M_STRMO); - } - SCTP_TCB_SEND_UNLOCK(stcb); - goto skip_stuff; - } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - error = EINVAL; - SCTP_TCB_UNLOCK(stcb); - break; } - for (i = 0; i < strrst->strrst_num_streams; i++) { - if ((send_in) && + if (stradd->sas_instrms) { + int cnt; - (strrst->strrst_list[i] > stcb->asoc.streamincnt)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + addstream |= 2; + /* + * We allocate inside + * sctp_send_str_reset_req() + */ + add_i_strmcnt = stradd->sas_instrms; + cnt = add_i_strmcnt; + cnt += stcb->asoc.streamincnt; + if (cnt > 0x0000ffff) { + /* You can't have more than 64k */ error = EINVAL; - goto get_out; + goto skip_stuff; } - if ((send_out) && - (strrst->strrst_list[i] > stcb->asoc.streamoutcnt)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + if (cnt > (int)stcb->asoc.max_inbound_streams) { + /* More than you are allowed */ error = EINVAL; - goto get_out; + goto skip_stuff; } } + error = sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, addstream, add_o_strmcnt, add_i_strmcnt, 0); + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_REQ, SCTP_SO_LOCKED); skip_stuff: - if (error) { - get_out: + SCTP_TCB_UNLOCK(stcb); + break; + } + case SCTP_RESET_ASSOC: + { + uint32_t *value; + + SCTP_CHECK_AND_CAST(value, optval, uint32_t, optsize); + SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value); + if (stcb == NULL) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); + error = ENOENT; + break; + } + if (stcb->asoc.peer_supports_strreset == 0) { + /* + * Peer does not support the chunk type. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; SCTP_TCB_UNLOCK(stcb); break; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:12:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CE611065670; Sun, 29 Apr 2012 16:12:32 +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 EB7B48FC08; Sun, 29 Apr 2012 16:12: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 q3TGCVH1021298; Sun, 29 Apr 2012 16:12:31 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGCVl0021296; Sun, 29 Apr 2012 16:12:31 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291612.q3TGCVl0021296@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:12:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234791 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:12:32 -0000 Author: tuexen Date: Sun Apr 29 16:12:31 2012 New Revision: 234791 URL: http://svn.freebsd.org/changeset/base/234791 Log: MFC r233940: Remove duplicate condition in if statement. Modified: stable/9/sys/netinet/sctp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 16:10:24 2012 (r234790) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 16:12:31 2012 (r234791) @@ -3581,7 +3581,6 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); if ((av->assoc_value != SCTP_SS_DEFAULT) && - (av->assoc_value != SCTP_SS_DEFAULT) && (av->assoc_value != SCTP_SS_ROUND_ROBIN) && (av->assoc_value != SCTP_SS_ROUND_ROBIN_PACKET) && (av->assoc_value != SCTP_SS_PRIORITY) && From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:14:09 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C974E106566B; Sun, 29 Apr 2012 16:14:09 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4B938FC0C; Sun, 29 Apr 2012 16:14:09 +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 q3TGE9RX021401; Sun, 29 Apr 2012 16:14:09 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGE9Ws021398; Sun, 29 Apr 2012 16:14:09 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291614.q3TGE9Ws021398@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 16:14:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234792 - head/sys/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:14:09 -0000 Author: marius Date: Sun Apr 29 16:14:09 2012 New Revision: 234792 URL: http://svn.freebsd.org/changeset/base/234792 Log: Drag in subr_acl_nfs4.c for ZFS automatically, otherwise it's unintuitive that "options zfs" requires "options ufs_acl". Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Apr 29 16:12:31 2012 (r234791) +++ head/sys/conf/files Sun Apr 29 16:14:09 2012 (r234792) @@ -2553,7 +2553,7 @@ kern/sched_ule.c optional sched_ule kern/serdev_if.m standard kern/stack_protector.c standard \ compile-with "${NORMAL_C:N-fstack-protector*}" -kern/subr_acl_nfs4.c optional ufs_acl +kern/subr_acl_nfs4.c optional ufs_acl | zfs kern/subr_acl_posix1e.c optional ufs_acl kern/subr_autoconf.c standard kern/subr_blist.c standard From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:16:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A48E9106566C; Sun, 29 Apr 2012 16:16:31 +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 8F6AF8FC08; Sun, 29 Apr 2012 16:16: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 q3TGGVuP021529; Sun, 29 Apr 2012 16:16:31 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGGVsA021527; Sun, 29 Apr 2012 16:16:31 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291616.q3TGGVsA021527@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:16:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234793 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:16:31 -0000 Author: tuexen Date: Sun Apr 29 16:16:31 2012 New Revision: 234793 URL: http://svn.freebsd.org/changeset/base/234793 Log: MFC r234296,r234297: Bugfix: Don't send HBs on path which are not idle. Send always HBs when in PF state. Modified: stable/9/sys/netinet/sctp_timer.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_timer.c ============================================================================== --- stable/9/sys/netinet/sctp_timer.c Sun Apr 29 16:14:09 2012 (r234792) +++ stable/9/sys/netinet/sctp_timer.c Sun Apr 29 16:16:31 2012 (r234793) @@ -1438,7 +1438,23 @@ sctp_heartbeat_timer(struct sctp_inpcb * * when move to PF during threshold mangement, a HB has been * queued in that routine */ - sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); + uint32_t ms_gone_by; + + if ((net->last_sent_time.tv_sec > 0) || + (net->last_sent_time.tv_usec > 0)) { + struct timeval diff; + + SCTP_GETTIME_TIMEVAL(&diff); + timevalsub(&diff, &net->last_sent_time); + ms_gone_by = (uint32_t) (diff.tv_sec * 1000) + + (uint32_t) (diff.tv_usec / 1000); + } else { + ms_gone_by = 0xffffffff; + } + if ((ms_gone_by >= net->heart_beat_delay) || + (net->dest_state & SCTP_ADDR_PF)) { + sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); + } } return (0); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:20:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17D57106566B; Sun, 29 Apr 2012 16:20:30 +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 EE2A48FC08; Sun, 29 Apr 2012 16:20: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 q3TGKTRu021697; Sun, 29 Apr 2012 16:20:29 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGKTb5021694; Sun, 29 Apr 2012 16:20:29 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291620.q3TGKTb5021694@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:20:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234794 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:20:30 -0000 Author: tuexen Date: Sun Apr 29 16:20:29 2012 New Revision: 234794 URL: http://svn.freebsd.org/changeset/base/234794 Log: MFC r234459: Fix a bug where we copy out more data from a mbuf chain that are actually in it. This happens when SCTP receives an unknown chunk, which requires the sending of an ERROR chunk, and there is no final padding but the chunk is not 4-byte aligned. Reported by yueting via rwatson@ Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Apr 29 16:16:31 2012 (r234793) +++ stable/9/sys/netinet/sctp_indata.c Sun Apr 29 16:20:29 2012 (r234794) @@ -2746,11 +2746,13 @@ sctp_process_data(struct mbuf **mm, int phd->param_length = htons(chk_length + sizeof(*phd)); SCTP_BUF_LEN(merr) = sizeof(*phd); - SCTP_BUF_NEXT(merr) = SCTP_M_COPYM(m, *offset, - SCTP_SIZE32(chk_length), - M_DONTWAIT); + SCTP_BUF_NEXT(merr) = SCTP_M_COPYM(m, *offset, chk_length, M_DONTWAIT); if (SCTP_BUF_NEXT(merr)) { - sctp_queue_op_err(stcb, merr); + if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(merr), SCTP_SIZE32(chk_length) - chk_length, NULL)) { + sctp_m_freem(merr); + } else { + sctp_queue_op_err(stcb, merr); + } } else { sctp_m_freem(merr); } Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Apr 29 16:16:31 2012 (r234793) +++ stable/9/sys/netinet/sctp_input.c Sun Apr 29 16:20:29 2012 (r234794) @@ -5461,23 +5461,26 @@ process_control_chunks: phd->param_type = htons(SCTP_CAUSE_UNRECOG_CHUNK); phd->param_length = htons(chk_length + sizeof(*phd)); SCTP_BUF_LEN(mm) = sizeof(*phd); - SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, SCTP_SIZE32(chk_length), - M_DONTWAIT); + SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, chk_length, M_DONTWAIT); if (SCTP_BUF_NEXT(mm)) { + if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(mm), SCTP_SIZE32(chk_length) - chk_length, NULL)) { + sctp_m_freem(mm); + } else { #ifdef SCTP_MBUF_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { + struct mbuf *mat; - mat = SCTP_BUF_NEXT(mm); - while (mat) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); + mat = SCTP_BUF_NEXT(mm); + while (mat) { + if (SCTP_BUF_IS_EXTENDED(mat)) { + sctp_log_mb(mat, SCTP_MBUF_ICOPY); + } + mat = SCTP_BUF_NEXT(mat); } - mat = SCTP_BUF_NEXT(mat); } - } #endif - sctp_queue_op_err(stcb, mm); + sctp_queue_op_err(stcb, mm); + } } else { sctp_m_freem(mm); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:21:47 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE045106566B; Sun, 29 Apr 2012 16:21:47 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A8E328FC20; Sun, 29 Apr 2012 16:21:47 +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 q3TGLla6021779; Sun, 29 Apr 2012 16:21:47 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGLl18021777; Sun, 29 Apr 2012 16:21:47 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291621.q3TGLl18021777@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 16:21:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234795 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:21:47 -0000 Author: marius Date: Sun Apr 29 16:21:47 2012 New Revision: 234795 URL: http://svn.freebsd.org/changeset/base/234795 Log: Partially revert r232938; ZFS only requires nfs4 but not posix1e. Submitted by: jhb Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Apr 29 16:20:29 2012 (r234794) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Apr 29 16:21:47 2012 (r234795) @@ -5424,4 +5424,3 @@ DECLARE_MODULE(zfsctrl, zfs_mod, SI_SUB_ MODULE_DEPEND(zfsctrl, opensolaris, 1, 1, 1); MODULE_DEPEND(zfsctrl, krpc, 1, 1, 1); MODULE_DEPEND(zfsctrl, acl_nfs4, 1, 1, 1); -MODULE_DEPEND(zfsctrl, acl_posix1e, 1, 1, 1); From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:22:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D6DB71065670; Sun, 29 Apr 2012 16:22:55 +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 C23048FC15; Sun, 29 Apr 2012 16:22: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 q3TGMt9d021866; Sun, 29 Apr 2012 16:22:55 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGMtDH021864; Sun, 29 Apr 2012 16:22:55 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291622.q3TGMtDH021864@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234796 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:22:56 -0000 Author: tuexen Date: Sun Apr 29 16:22:55 2012 New Revision: 234796 URL: http://svn.freebsd.org/changeset/base/234796 Log: MFC r234460: Fix reported errno. Modified: stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Apr 29 16:21:47 2012 (r234795) +++ stable/9/sys/netinet/sctputil.c Sun Apr 29 16:22:55 2012 (r234796) @@ -2553,8 +2553,8 @@ sctp_add_pad_tombuf(struct mbuf *m, int tmp = sctp_get_mbuf_for_msg(padlen, 0, M_DONTWAIT, 1, MT_DATA); if (tmp == NULL) { /* Out of space GAK! we are in big trouble. */ - SCTP_LTRACE_ERR_RET_PKT(m, NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); - return (ENOSPC); + SCTP_LTRACE_ERR_RET_PKT(m, NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, ENOBUFS); + return (ENOBUFS); } /* setup and insert in middle */ SCTP_BUF_LEN(tmp) = padlen; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:25:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AF19E106566C; Sun, 29 Apr 2012 16:25:01 +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 8980F8FC18; Sun, 29 Apr 2012 16:25:01 +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 q3TGP1mS021982; Sun, 29 Apr 2012 16:25:01 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGP1a5021978; Sun, 29 Apr 2012 16:25:01 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291625.q3TGP1a5021978@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:25:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234797 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:25:01 -0000 Author: tuexen Date: Sun Apr 29 16:25:01 2012 New Revision: 234797 URL: http://svn.freebsd.org/changeset/base/234797 Log: MFC r234461: Use the same pattern for mbuf logging everywhere. Modified: stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Apr 29 16:22:55 2012 (r234796) +++ stable/9/sys/netinet/sctp_input.c Sun Apr 29 16:25:01 2012 (r234797) @@ -2463,12 +2463,10 @@ sctp_handle_cookie_echo(struct mbuf *m, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m_sig; - while (mat) { + for (mat = m_sig; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_SPLIT); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -5470,12 +5468,10 @@ process_control_chunks: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = SCTP_BUF_NEXT(mm); - while (mat) { + for (mat = SCTP_BUF_NEXT(mm); mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -5808,10 +5804,6 @@ sctp_print_mbuf_chain(struct mbuf *m) void sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port) { -#ifdef SCTP_MBUF_LOGGING - struct mbuf *mat; - -#endif struct mbuf *m; int iphlen; uint32_t vrf_id = 0; @@ -5846,6 +5838,8 @@ sctp_input_with_port(struct mbuf *i_pak, #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { + struct mbuf *mat; + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_INPUT); Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Apr 29 16:22:55 2012 (r234796) +++ stable/9/sys/netinet/sctp_output.c Sun Apr 29 16:25:01 2012 (r234797) @@ -3714,12 +3714,10 @@ sctp_add_cookie(struct mbuf *init, int i if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = copy_init; - while (mat) { + for (mat = copy_init; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -3734,12 +3732,10 @@ sctp_add_cookie(struct mbuf *init, int i if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = copy_initack; - while (mat) { + for (mat = copy_initack; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -6446,12 +6442,10 @@ error_out: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = appendchain; - while (mat) { + for (mat = appendchain; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -6547,12 +6541,10 @@ sctp_sendall_iterator(struct sctp_inpcb if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m; - while (mat) { + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -7350,12 +7342,10 @@ dont_do_it: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = chk->data; - while (mat) { + for (mat = chk->data; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -8953,12 +8943,10 @@ sctp_send_cookie_echo(struct mbuf *m, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = cookie; - while (mat) { + for (mat = cookie; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -9027,12 +9015,10 @@ sctp_send_heartbeat_ack(struct sctp_tcb if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = outchain; - while (mat) { + for (mat = outchain; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -9313,12 +9299,10 @@ sctp_send_asconf_ack(struct sctp_tcb *st if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m_ack; - while (mat) { + for (mat = m_ack; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:26:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B4DC51065670; Sun, 29 Apr 2012 16:26:55 +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 9FC998FC18; Sun, 29 Apr 2012 16:26: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 q3TGQtvi022096; Sun, 29 Apr 2012 16:26:55 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGQtXV022093; Sun, 29 Apr 2012 16:26:55 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291626.q3TGQtXV022093@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:26:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234798 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:26:55 -0000 Author: tuexen Date: Sun Apr 29 16:26:55 2012 New Revision: 234798 URL: http://svn.freebsd.org/changeset/base/234798 Log: MFC r234464: Whitespace changes. Modified: stable/9/sys/netinet/sctp_usrreq.c stable/9/sys/netinet/sctp_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 16:25:01 2012 (r234797) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Apr 29 16:26:55 2012 (r234798) @@ -1616,7 +1616,7 @@ out_now: } -#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\ +#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\ if (size < sizeof(type)) { \ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); \ error = EINVAL; \ Modified: stable/9/sys/netinet/sctp_var.h ============================================================================== --- stable/9/sys/netinet/sctp_var.h Sun Apr 29 16:25:01 2012 (r234797) +++ stable/9/sys/netinet/sctp_var.h Sun Apr 29 16:26:55 2012 (r234798) @@ -157,7 +157,7 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_alloc_a_chunk(_stcb, _chk) { \ - if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ + if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ (_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \ if ((_chk)) { \ SCTP_INCR_CHK_COUNT(); \ From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:28:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 448B1106564A; Sun, 29 Apr 2012 16:28:40 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E76A8FC0C; Sun, 29 Apr 2012 16:28:40 +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 q3TGSeOm022205; Sun, 29 Apr 2012 16:28:40 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGSdlr022201; Sun, 29 Apr 2012 16:28:39 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204291628.q3TGSdlr022201@svn.freebsd.org> From: David Schultz Date: Sun, 29 Apr 2012 16:28:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234799 - head/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:28:40 -0000 Author: das Date: Sun Apr 29 16:28:39 2012 New Revision: 234799 URL: http://svn.freebsd.org/changeset/base/234799 Log: Previously, vfscanf()'s wide character processing functions were reading wide characters manually. With this change, they now use fgetwc(). To make this work, we use an internal version of fgetwc() with a few extensions: it takes an mbstate * because non-wide streams don't have a built-in mbstate, and it indicates the number of bytes read. vfscanf() now resembles vfwscanf() more closely. Minor functional improvements include working xlocale support in vfscanf(), setting the stream error indicator on encoding errors, and proper handling of shift-based encodings. (Actually, making shift-based encodings work with non-wide streams is hopeless, but the implementation now matches the broken specification.) Modified: head/lib/libc/stdio/fgetwc.c head/lib/libc/stdio/local.h head/lib/libc/stdio/vfscanf.c Modified: head/lib/libc/stdio/fgetwc.c ============================================================================== --- head/lib/libc/stdio/fgetwc.c Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/fgetwc.c Sun Apr 29 16:28:39 2012 (r234799) @@ -59,6 +59,7 @@ fgetwc_l(FILE *fp, locale_t locale) return (r); } + wint_t fgetwc(FILE *fp) { @@ -66,40 +67,45 @@ fgetwc(FILE *fp) } /* - * Non-MT-safe version. + * Internal (non-MPSAFE) version of fgetwc(). This version takes an + * mbstate_t argument specifying the initial conversion state. For + * wide streams, this should always be fp->_mbstate. On return, *nread + * is set to the number of bytes read. */ -wint_t -__fgetwc(FILE *fp, locale_t locale) +wint_t +__fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale) { wchar_t wc; size_t nconv; struct xlocale_ctype *l = XLOCALE_CTYPE(locale); - if (fp->_r <= 0 && __srefill(fp)) + if (fp->_r <= 0 && __srefill(fp)) { + *nread = 0; return (WEOF); + } if (MB_CUR_MAX == 1) { /* Fast path for single-byte encodings. */ wc = *fp->_p++; fp->_r--; + *nread = 1; return (wc); } + *nread = 0; do { - nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, &fp->_mbstate); + nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); if (nconv == (size_t)-1) break; else if (nconv == (size_t)-2) continue; else if (nconv == 0) { - /* - * Assume that the only valid representation of - * the null wide character is a single null byte. - */ fp->_p++; fp->_r--; + (*nread)++; return (L'\0'); } else { fp->_p += nconv; fp->_r -= nconv; + *nread += nconv; return (wc); } } while (__srefill(fp) == 0); Modified: head/lib/libc/stdio/local.h ============================================================================== --- head/lib/libc/stdio/local.h Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/local.h Sun Apr 29 16:28:39 2012 (r234799) @@ -56,7 +56,7 @@ extern int _ftello(FILE *, fpos_t *); extern int _fseeko(FILE *, off_t, int, int); extern int __fflush(FILE *fp); extern void __fcloseall(void); -extern wint_t __fgetwc(FILE *, locale_t); +extern wint_t __fgetwc_mbs(FILE *, mbstate_t *, int *, locale_t); extern wint_t __fputwc(wchar_t, FILE *, locale_t); extern int __sflush(FILE *); extern FILE *__sfp(void); @@ -85,6 +85,13 @@ extern size_t __fread(void * __restrict FILE * __restrict fp); extern int __sdidinit; +static inline wint_t +__fgetwc(FILE *fp, locale_t locale) +{ + int nread; + + return (__fgetwc_mbs(fp, &fp->_mbstate, &nread, locale)); +} /* * Prepare the given FILE for writing, and return 0 iff it Modified: head/lib/libc/stdio/vfscanf.c ============================================================================== --- head/lib/libc/stdio/vfscanf.c Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/vfscanf.c Sun Apr 29 16:28:39 2012 (r234799) @@ -127,9 +127,8 @@ static const mbstate_t initial_mbs; static __inline int convert_char(FILE *fp, char * __restrict p, int width) { - int n, nread; + int n; - nread = 0; if (p == SUPPRESS_PTR) { size_t sum = 0; for (;;) { @@ -149,59 +148,34 @@ convert_char(FILE *fp, char * __restrict break; } } - nread += sum; + return (sum); } else { size_t r = __fread(p, 1, width, fp); if (r == 0) return (-1); - nread += r; + return (r); } - return (nread); } static __inline int -convert_wchar(FILE *fp, wchar_t *wcp, int width) +convert_wchar(FILE *fp, wchar_t *wcp, int width, locale_t locale) { mbstate_t mbs; - size_t nconv; int n, nread; - char buf[MB_CUR_MAX]; + wint_t wi; - nread = 0; + mbs = initial_mbs; n = 0; - while (width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0 && wcp != SUPPRESS_PTR) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - nread += n; - width--; - if (wcp != SUPPRESS_PTR) - wcp++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; - } + while (width-- != 0 && + (wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF) { + if (wcp != SUPPRESS_PTR) + *wcp++ = (wchar_t)wi; + n += nread; } - return (nread); + if (n == 0) + return (-1); + return (n); } static __inline int @@ -244,63 +218,34 @@ convert_ccl(FILE *fp, char * __restrict } static __inline int -convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab) +convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab, + locale_t locale) { mbstate_t mbs; - wchar_t twc; - int n, nchars, nconv; - char buf[MB_CUR_MAX]; + wint_t wi; + int n, nread; - if (wcp == SUPPRESS_PTR) - wcp = &twc; + mbs = initial_mbs; n = 0; - nchars = 0; - while (width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - if (wctob(*wcp) != EOF && !ccltab[wctob(*wcp)]) { - while (n != 0) { - n--; - __ungetc(buf[n], fp); - } - break; - } - width--; - if (wcp != &twc) - wcp++; - nchars++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; + if (wcp == SUPPRESS_PTR) { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && ccltab[wctob(wi)]) + n += nread; + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + } else { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && ccltab[wctob(wi)]) { + *wcp++ = (wchar_t)wi; + n += nread; } + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + if (n == 0) + return (0); + *wcp = 0; } - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - if (nchars == 0) - return (0); - *wcp = L'\0'; - return (nchars); + return (n); } static __inline int @@ -335,56 +280,31 @@ convert_string(FILE *fp, char * __restri } static __inline int -convert_wstring(FILE *fp, wchar_t *wcp, int width) +convert_wstring(FILE *fp, wchar_t *wcp, int width, locale_t locale) { mbstate_t mbs; - wchar_t twc; - int n, nconv, nread; - char buf[MB_CUR_MAX]; - - if (wcp == SUPPRESS_PTR) - wcp = &twc; - n = nread = 0; - while (!isspace(*fp->_p) && width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - if (iswspace(*wcp)) { - while (n != 0) { - n--; - __ungetc(buf[n], fp); - } - break; - } - nread += n; - width--; - if (wcp != &twc) - wcp++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; - } + wint_t wi; + int n, nread; + + mbs = initial_mbs; + n = 0; + if (wcp == SUPPRESS_PTR) { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && !iswspace(wi)) + n += nread; + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + } else { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && !iswspace(wi)) { + *wcp++ = (wchar_t)wi; + n += nread; + } + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + *wcp = '\0'; } - *wcp = L'\0'; - return (nread); + return (n); } /* @@ -766,7 +686,7 @@ literal: width = 1; if (flags & LONG) { nr = convert_wchar(fp, GETARG(wchar_t *), - width); + width, locale); } else { nr = convert_char(fp, GETARG(char *), width); } @@ -780,7 +700,7 @@ literal: width = (size_t)~0; /* `infinity' */ if (flags & LONG) { nr = convert_wccl(fp, GETARG(wchar_t *), width, - ccltab); + ccltab, locale); } else { nr = convert_ccl(fp, GETARG(char *), width, ccltab); @@ -799,7 +719,7 @@ literal: width = (size_t)~0; if (flags & LONG) { nr = convert_wstring(fp, GETARG(wchar_t *), - width); + width, locale); } else { nr = convert_string(fp, GETARG(char *), width); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:29:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6B2A1065673; Sun, 29 Apr 2012 16:29:39 +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 A1CE98FC1B; Sun, 29 Apr 2012 16:29:39 +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 q3TGTdJt022327; Sun, 29 Apr 2012 16:29:39 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGTd42022325; Sun, 29 Apr 2012 16:29:39 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291629.q3TGTd42022325@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:29:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234800 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:29:39 -0000 Author: tuexen Date: Sun Apr 29 16:29:39 2012 New Revision: 234800 URL: http://svn.freebsd.org/changeset/base/234800 Log: MFC r234539: Fix check used by stream reset related events. Modified: stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Apr 29 16:28:39 2012 (r234799) +++ stable/9/sys/netinet/sctputil.c Sun Apr 29 16:29:39 2012 (r234800) @@ -3214,7 +3214,7 @@ sctp_notify_stream_reset_add(struct sctp struct sctp_stream_change_event *stradd; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } @@ -3275,7 +3275,7 @@ sctp_notify_stream_reset_tsn(struct sctp struct sctp_assoc_reset_event *strasoc; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } @@ -3333,7 +3333,7 @@ sctp_notify_stream_reset(struct sctp_tcb struct sctp_stream_reset_event *strreset; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:33:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DCED3106564A; Sun, 29 Apr 2012 16:33:30 +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 AF42E8FC12; Sun, 29 Apr 2012 16:33: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 q3TGXUuK022516; Sun, 29 Apr 2012 16:33:30 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGXUDN022513; Sun, 29 Apr 2012 16:33:30 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291633.q3TGXUDN022513@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:33:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234801 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:33:31 -0000 Author: tuexen Date: Sun Apr 29 16:33:30 2012 New Revision: 234801 URL: http://svn.freebsd.org/changeset/base/234801 Log: MFC r234614: Use the flags defined in RFC 6525 in the stream reset event. Modified: stable/9/sys/netinet/sctp_uio.h stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Sun Apr 29 16:29:39 2012 (r234800) +++ stable/9/sys/netinet/sctp_uio.h Sun Apr 29 16:33:30 2012 (r234801) @@ -449,9 +449,11 @@ struct sctp_stream_reset_event { }; /* flags in stream_reset_event (strreset_flags) */ -#define SCTP_STREAM_RESET_DENIED 0x0004 /* SCTP_STRRESET_FAILED */ -#define SCTP_STREAM_RESET_FAILED 0x0008 /* SCTP_STRRESET_FAILED */ -#define SCTP_STREAM_CHANGED_DENIED 0x0010 +#define SCTP_STREAM_RESET_INCOMING_SSN 0x0001 +#define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002 +#define SCTP_STREAM_RESET_DENIED 0x0004 +#define SCTP_STREAM_RESET_FAILED 0x0008 +#define SCTP_STREAM_CHANGED_DENIED 0x0010 /* * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Apr 29 16:29:39 2012 (r234800) +++ stable/9/sys/netinet/sctputil.c Sun Apr 29 16:33:30 2012 (r234801) @@ -3498,18 +3498,18 @@ sctp_ulp_notify(uint32_t notification, s case SCTP_NOTIFY_HB_RESP: break; case SCTP_NOTIFY_STR_RESET_SEND: - sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING); + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING_SSN); break; case SCTP_NOTIFY_STR_RESET_RECV: - sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING); + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING); break; case SCTP_NOTIFY_STR_RESET_FAILED_OUT: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), - (SCTP_STREAM_RESET_OUTGOING | SCTP_STREAM_RESET_INCOMING)); + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED)); break; case SCTP_NOTIFY_STR_RESET_FAILED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), - (SCTP_STREAM_RESET_OUTGOING | SCTP_STREAM_RESET_INCOMING)); + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED)); break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 16:35:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EB08A1065676; Sun, 29 Apr 2012 16:35:55 +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 BCDE88FC26; Sun, 29 Apr 2012 16:35: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 q3TGZtGS022642; Sun, 29 Apr 2012 16:35:55 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGZtDW022638; Sun, 29 Apr 2012 16:35:55 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291635.q3TGZtDW022638@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 16:35:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234802 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:35:56 -0000 Author: tuexen Date: Sun Apr 29 16:35:55 2012 New Revision: 234802 URL: http://svn.freebsd.org/changeset/base/234802 Log: MFC r234699: Fix a type in an SCTP AUTH related notification. Keep the old name for backwards compatibility. Spotted by Irene Ruengeler. Modified: stable/9/sys/netinet/sctp_auth.c stable/9/sys/netinet/sctp_uio.h stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_auth.c ============================================================================== --- stable/9/sys/netinet/sctp_auth.c Sun Apr 29 16:33:30 2012 (r234801) +++ stable/9/sys/netinet/sctp_auth.c Sun Apr 29 16:35:55 2012 (r234802) @@ -1801,7 +1801,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, * shared_key_id, (void * *)stcb->asoc.authinfo.recv_keyid); */ - sctp_notify_authentication(stcb, SCTP_AUTH_NEWKEY, + sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, shared_key_id, stcb->asoc.authinfo.recv_keyid, SCTP_SO_NOT_LOCKED); /* compute a new recv assoc key and cache it */ Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Sun Apr 29 16:33:30 2012 (r234801) +++ stable/9/sys/netinet/sctp_uio.h Sun Apr 29 16:35:55 2012 (r234802) @@ -424,7 +424,8 @@ struct sctp_authkey_event { }; /* indication values */ -#define SCTP_AUTH_NEWKEY 0x0001 +#define SCTP_AUTH_NEW_KEY 0x0001 +#define SCTP_AUTH_NEWKEY SCTP_AUTH_NEW_KEY #define SCTP_AUTH_NO_AUTH 0x0002 #define SCTP_AUTH_FREE_KEY 0x0003 Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Apr 29 16:33:30 2012 (r234801) +++ stable/9/sys/netinet/sctputil.c Sun Apr 29 16:35:55 2012 (r234802) @@ -3531,7 +3531,7 @@ sctp_ulp_notify(uint32_t notification, s sctp_notify_shutdown_event(stcb); break; case SCTP_NOTIFY_AUTH_NEW_KEY: - sctp_notify_authentication(stcb, SCTP_AUTH_NEWKEY, error, + sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, error, (uint16_t) (uintptr_t) data, so_locked); break; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 17:12:34 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 71095106566C; Sun, 29 Apr 2012 17:12:34 +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 598F28FC08; Sun, 29 Apr 2012 17:12:34 +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 q3THCYcK023920; Sun, 29 Apr 2012 17:12:34 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3THCY5C023914; Sun, 29 Apr 2012 17:12:34 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201204291712.q3THCY5C023914@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 29 Apr 2012 17:12:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234803 - in head/sys/dev/usb: . controller X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 17:12:34 -0000 Author: hselasky Date: Sun Apr 29 17:12:33 2012 New Revision: 234803 URL: http://svn.freebsd.org/changeset/base/234803 Log: Add support for Multi-TT mode of modern USB HUBs. This will give you more bandwidth for isochronous FULL speed applications connected through a High Speed HUB. This patch has been tested with XHCI and EHCI. MFC after: 1 week Modified: head/sys/dev/usb/controller/ehci.c head/sys/dev/usb/controller/xhci.c head/sys/dev/usb/usb_controller.h head/sys/dev/usb/usb_hub.c head/sys/dev/usb/usb_hub.h Modified: head/sys/dev/usb/controller/ehci.c ============================================================================== --- head/sys/dev/usb/controller/ehci.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/controller/ehci.c Sun Apr 29 17:12:33 2012 (r234803) @@ -2398,9 +2398,9 @@ ehci_device_isoc_fs_open(struct usb_xfer EHCI_SITD_SET_HUBA(xfer->xroot->udev->hs_hub_addr) | EHCI_SITD_SET_PORT(xfer->xroot->udev->hs_port_no); - if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) { + if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) sitd_portaddr |= EHCI_SITD_SET_DIR_IN; - } + sitd_portaddr = htohc32(sc, sitd_portaddr); /* initialize all TD's */ @@ -2436,9 +2436,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe { struct usb_page_search buf_res; ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); - struct usb_fs_isoc_schedule *fss_start; - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss; ehci_sitd_t *td; ehci_sitd_t *td_last = NULL; ehci_sitd_t **pp_last; @@ -2450,7 +2447,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe uint16_t tlen; uint8_t sa; uint8_t sb; - uint8_t error; #ifdef USB_DEBUG uint8_t once = 1; @@ -2495,9 +2491,8 @@ ehci_device_isoc_fs_enter(struct usb_xfe * pre-compute when the isochronous transfer will be finished: */ xfer->isoc_time_complete = - usbd_fs_isoc_schedule_isoc_time_expand - (xfer->xroot->udev, &fss_start, &fss_end, nframes) + buf_offset + - xfer->nframes; + usb_isoc_time_expand(&sc->sc_bus, nframes) + + buf_offset + xfer->nframes; /* get the real number of frames */ @@ -2520,19 +2515,14 @@ ehci_device_isoc_fs_enter(struct usb_xfe xfer->qh_pos = xfer->endpoint->isoc_next; - fss = fss_start + (xfer->qh_pos % USB_ISOC_TIME_MAX); - while (nframes--) { if (td == NULL) { panic("%s:%d: out of TD's\n", __FUNCTION__, __LINE__); } - if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) { + if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) pp_last = &sc->sc_isoc_fs_p_last[0]; - } - if (fss >= fss_end) { - fss = fss_start; - } + /* reuse sitd_portaddr and sitd_back from last transfer */ if (*plen > xfer->max_frame_size) { @@ -2547,17 +2537,19 @@ ehci_device_isoc_fs_enter(struct usb_xfe #endif *plen = xfer->max_frame_size; } - /* - * We currently don't care if the ISOCHRONOUS schedule is - * full! - */ - error = usbd_fs_isoc_schedule_alloc(fss, &sa, *plen); - if (error) { + + /* allocate a slot */ + + sa = usbd_fs_isoc_schedule_alloc_slot(xfer, + xfer->isoc_time_complete - nframes - 1); + + if (sa == 255) { /* - * The FULL speed schedule is FULL! Set length - * to zero. + * Schedule is FULL, set length to zero: */ + *plen = 0; + sa = USB_FS_ISOC_UFRAME_MAX - 1; } if (*plen) { /* @@ -2637,7 +2629,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe pp_last++; plen++; - fss++; td_last = td; td = td->obj_next; } Modified: head/sys/dev/usb/controller/xhci.c ============================================================================== --- head/sys/dev/usb/controller/xhci.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/controller/xhci.c Sun Apr 29 17:12:33 2012 (r234803) @@ -115,6 +115,7 @@ struct xhci_std_temp { uint8_t tbc; uint8_t tlbpc; uint8_t step_td; + uint8_t do_isoc_sync; }; static void xhci_do_poll(struct usb_bus *); @@ -1657,11 +1658,15 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(temp->trb_type) | - XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) | + XHCI_TRB_3_TYPE_SET(temp->trb_type) | + (temp->do_isoc_sync ? + XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) : + XHCI_TRB_3_ISO_SIA_BIT) | XHCI_TRB_3_TBC_SET(temp->tbc) | XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + temp->do_isoc_sync = 0; + if (temp->direction == UE_DIR_IN) { dword |= XHCI_TRB_3_DIR_IN; @@ -1764,6 +1769,7 @@ xhci_setup_generic_chain(struct usb_xfer uint32_t y; uint8_t mult; + temp.do_isoc_sync = 0; temp.step_td = 0; temp.tbc = 0; temp.tlbpc = 0; @@ -1841,6 +1847,8 @@ xhci_setup_generic_chain(struct usb_xfer */ xfer->endpoint->isoc_next = XHCI_MFINDEX_GET(x + (3 * 8)); xfer->endpoint->is_synced = 1; + temp.do_isoc_sync = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); } @@ -1931,7 +1939,10 @@ xhci_setup_generic_chain(struct usb_xfer uint8_t tdpc; - /* isochronous transfers don't have short packet termination */ + /* + * Isochronous transfers don't have short + * packet termination: + */ temp.shortpkt = 1; @@ -2271,12 +2282,29 @@ xhci_configure_device(struct usb_device switch (udev->speed) { case USB_SPEED_LOW: temp |= XHCI_SCTX_0_SPEED_SET(2); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_HIGH: temp |= XHCI_SCTX_0_SPEED_SET(3); + if (sc->sc_hw.devs[index].nports != 0 && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { + DPRINTF("HUB supports MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_FULL: temp |= XHCI_SCTX_0_SPEED_SET(1); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; default: temp |= XHCI_SCTX_0_SPEED_SET(4); @@ -2287,15 +2315,8 @@ xhci_configure_device(struct usb_device (udev->speed == USB_SPEED_SUPER || udev->speed == USB_SPEED_HIGH); - if (is_hub) { + if (is_hub) temp |= XHCI_SCTX_0_HUB_SET(1); -#if 0 - if (udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { - DPRINTF("HUB supports MTT\n"); - temp |= XHCI_SCTX_0_MTT_SET(1); - } -#endif - } xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); @@ -2327,8 +2348,10 @@ xhci_configure_device(struct usb_device temp = XHCI_SCTX_2_IRQ_TARGET_SET(0); - if (is_hub) - temp |= XHCI_SCTX_2_TT_THINK_TIME_SET(sc->sc_hw.devs[index].tt); + if (is_hub) { + temp |= XHCI_SCTX_2_TT_THINK_TIME_SET( + sc->sc_hw.devs[index].tt); + } hubdev = udev->parent_hs_hub; Modified: head/sys/dev/usb/usb_controller.h ============================================================================== --- head/sys/dev/usb/usb_controller.h Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_controller.h Sun Apr 29 17:12:33 2012 (r234803) @@ -231,7 +231,8 @@ void usb_bus_mem_flush_all(struct usb_bu uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb); void usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb); uint16_t usb_isoc_time_expand(struct usb_bus *bus, uint16_t isoc_time_curr); -uint16_t usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, struct usb_fs_isoc_schedule **pp_start, struct usb_fs_isoc_schedule **pp_end, uint16_t isoc_time); -uint8_t usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len); +#if USB_HAVE_TT_SUPPORT +uint8_t usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time); +#endif #endif /* _USB_CONTROLLER_H_ */ Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_hub.c Sun Apr 29 17:12:33 2012 (r234803) @@ -109,6 +109,7 @@ struct uhub_softc { #define UHUB_PROTO(sc) ((sc)->sc_udev->ddesc.bDeviceProtocol) #define UHUB_IS_HIGH_SPEED(sc) (UHUB_PROTO(sc) != UDPROTO_FSHUB) #define UHUB_IS_SINGLE_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBSTT) +#define UHUB_IS_MULTI_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBMTT) #define UHUB_IS_SUPER_SPEED(sc) (UHUB_PROTO(sc) == UDPROTO_SSHUB) /* prototypes for type checking: */ @@ -948,6 +949,16 @@ uhub_attach(device_t dev) "bus powered HUB. HUB ignored\n"); goto error; } + + if (UHUB_IS_MULTI_TT(sc)) { + err = usbd_set_alt_interface_index(udev, 0, 1); + if (err) { + device_printf(dev, "MTT could not be enabled\n"); + goto error; + } + device_printf(dev, "MTT enabled\n"); + } + /* get HUB descriptor */ DPRINTFN(2, "Getting HUB descriptor\n"); @@ -1057,10 +1068,6 @@ uhub_attach(device_t dev) } udev->hub = hub; -#if USB_HAVE_TT_SUPPORT - /* init FULL-speed ISOCHRONOUS schedule */ - usbd_fs_isoc_schedule_init_all(hub->fs_isoc_schedule); -#endif /* initialize HUB structure */ hub->hubsoftc = sc; hub->explore = &uhub_explore; @@ -1656,42 +1663,6 @@ usb_hs_bandwidth_free(struct usb_xfer *x } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_sub - * - * This function initialises an USB FULL speed isochronous schedule - * entry. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -static void -usbd_fs_isoc_schedule_init_sub(struct usb_fs_isoc_schedule *fss) -{ - fss->total_bytes = (USB_FS_ISOC_UFRAME_MAX * - USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_bytes = (USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_slot = 0; -} -#endif - -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_all - * - * This function will reset the complete USB FULL speed isochronous - * bandwidth schedule. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -void -usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss) -{ - struct usb_fs_isoc_schedule *fss_end = fss + USB_ISOC_TIME_MAX; - - while (fss != fss_end) { - usbd_fs_isoc_schedule_init_sub(fss); - fss++; - } -} -#endif - -/*------------------------------------------------------------------------* * usb_isoc_time_expand * * This function will expand the time counter from 7-bit to 16-bit. @@ -1723,114 +1694,130 @@ usb_isoc_time_expand(struct usb_bus *bus } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_isoc_time_expand + * usbd_fs_isoc_schedule_alloc_slot * - * This function does multiple things. First of all it will expand the - * passed isochronous time, which is the return value. Then it will - * store where the current FULL speed isochronous schedule is - * positioned in time and where the end is. See "pp_start" and - * "pp_end" arguments. + * This function will allocate bandwidth for an isochronous FULL speed + * transaction in the FULL speed schedule. * * Returns: - * Expanded version of "isoc_time". - * - * NOTE: This function depends on being called regularly with - * intervals less than "USB_ISOC_TIME_MAX". + * <8: Success + * Else: Error *------------------------------------------------------------------------*/ #if USB_HAVE_TT_SUPPORT -uint16_t -usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, - struct usb_fs_isoc_schedule **pp_start, - struct usb_fs_isoc_schedule **pp_end, - uint16_t isoc_time) +uint8_t +usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time) { - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss_a; - struct usb_fs_isoc_schedule *fss_b; - struct usb_hub *hs_hub; + struct usb_xfer *xfer; + struct usb_xfer *pipe_xfer; + struct usb_bus *bus; + usb_frlength_t len; + usb_frlength_t data_len; + uint16_t delta; + uint16_t slot; + uint8_t retval; - isoc_time = usb_isoc_time_expand(udev->bus, isoc_time); + data_len = 0; + slot = 0; - hs_hub = udev->parent_hs_hub->hub; + bus = isoc_xfer->xroot->bus; - if (hs_hub != NULL) { + TAILQ_FOREACH(xfer, &bus->intr_q.head, wait_entry) { - fss_a = hs_hub->fs_isoc_schedule + - (hs_hub->isoc_last_time % USB_ISOC_TIME_MAX); + /* skip self, if any */ - hs_hub->isoc_last_time = isoc_time; + if (xfer == isoc_xfer) + continue; - fss_b = hs_hub->fs_isoc_schedule + - (isoc_time % USB_ISOC_TIME_MAX); + /* check if this USB transfer is going through the same TT */ - fss_end = hs_hub->fs_isoc_schedule + USB_ISOC_TIME_MAX; + if (xfer->xroot->udev->parent_hs_hub != + isoc_xfer->xroot->udev->parent_hs_hub) { + continue; + } + if ((isoc_xfer->xroot->udev->parent_hs_hub-> + ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) && + (xfer->xroot->udev->hs_port_no != + isoc_xfer->xroot->udev->hs_port_no)) { + continue; + } + if (xfer->endpoint->methods != isoc_xfer->endpoint->methods) + continue; + + /* check if isoc_time is part of this transfer */ + + delta = xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= xfer->nframes) { + delta = xfer->nframes - delta; + + len = xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; + } + + /* check double buffered transfers */ - *pp_start = hs_hub->fs_isoc_schedule; - *pp_end = fss_end; + TAILQ_FOREACH(pipe_xfer, &xfer->endpoint->endpoint_q.head, + wait_entry) { - while (fss_a != fss_b) { - if (fss_a == fss_end) { - fss_a = hs_hub->fs_isoc_schedule; + /* skip self, if any */ + + if (pipe_xfer == isoc_xfer) continue; + + /* check if isoc_time is part of this transfer */ + + delta = pipe_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= pipe_xfer->nframes) { + delta = pipe_xfer->nframes - delta; + + len = pipe_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - usbd_fs_isoc_schedule_init_sub(fss_a); - fss_a++; } + } - } else { - - *pp_start = NULL; - *pp_end = NULL; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; } - return (isoc_time); -} -#endif -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_alloc - * - * This function will allocate bandwidth for an isochronous FULL speed - * transaction in the FULL speed schedule. The microframe slot where - * the transaction should be started is stored in the byte pointed to - * by "pstart". The "len" argument specifies the length of the - * transaction in bytes. - * - * Returns: - * 0: Success - * Else: Error - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -uint8_t -usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, - uint8_t *pstart, uint16_t len) -{ - uint8_t slot = fss->frame_slot; + /* check for overflow */ - /* Compute overhead and bit-stuffing */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); - len += 8; + retval = slot; - len *= 7; - len /= 6; + delta = isoc_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= isoc_xfer->nframes) { + delta = isoc_xfer->nframes - delta; - if (len > fss->total_bytes) { - *pstart = 0; /* set some dummy value */ - return (1); /* error */ + len = isoc_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - if (len > 0) { - fss->total_bytes -= len; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; + } - while (len >= fss->frame_bytes) { - len -= fss->frame_bytes; - fss->frame_bytes = USB_FS_BYTES_PER_HS_UFRAME; - fss->frame_slot++; - } + /* check for overflow */ - fss->frame_bytes -= len; - } - *pstart = slot; - return (0); /* success */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); + + return (retval); } #endif Modified: head/sys/dev/usb/usb_hub.h ============================================================================== --- head/sys/dev/usb/usb_hub.h Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_hub.h Sun Apr 29 17:12:33 2012 (r234803) @@ -38,22 +38,9 @@ struct usb_port { }; /* - * The following structure defines how many bytes are - * left in an 1ms USB time slot. - */ -struct usb_fs_isoc_schedule { - uint16_t total_bytes; - uint8_t frame_bytes; - uint8_t frame_slot; -}; - -/* * The following structure defines an USB HUB. */ struct usb_hub { -#if USB_HAVE_TT_SUPPORT - struct usb_fs_isoc_schedule fs_isoc_schedule[USB_ISOC_TIME_MAX]; -#endif struct usb_device *hubudev; /* the HUB device */ usb_error_t (*explore) (struct usb_device *hub); void *hubsoftc; @@ -68,7 +55,6 @@ struct usb_hub { void usb_hs_bandwidth_alloc(struct usb_xfer *xfer); void usb_hs_bandwidth_free(struct usb_xfer *xfer); -void usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss); void usb_bus_port_set_device(struct usb_bus *bus, struct usb_port *up, struct usb_device *udev, uint8_t device_index); struct usb_device *usb_bus_port_get_device(struct usb_bus *bus, From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:28:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9FC39106566B; Sun, 29 Apr 2012 18:28:59 +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 705918FC08; Sun, 29 Apr 2012 18:28:59 +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 q3TISxjO026412; Sun, 29 Apr 2012 18:28:59 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TISxxx026410; Sun, 29 Apr 2012 18:28:59 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291828.q3TISxxx026410@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:28:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234804 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:28:59 -0000 Author: tuexen Date: Sun Apr 29 18:28:58 2012 New Revision: 234804 URL: http://svn.freebsd.org/changeset/base/234804 Log: MFC r233311: Small cleanup of the code. No functional change (in FreeBSD kernel). Modified: stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 17:12:33 2012 (r234803) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:28:58 2012 (r234804) @@ -5443,28 +5443,31 @@ found_one: } #endif if (fromlen && from) { - struct sockaddr *to; - + cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sa.sa_len); + switch (control->whoFrom->ro._l_addr.sa.sa_family) { +#ifdef INET6 + case AF_INET6: + ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + break; +#endif #ifdef INET - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin.sin_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in *)from)->sin_port = control->port_from; -#else - /* No AF_INET use AF_INET6 */ - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin6.sin6_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + case AF_INET: + ((struct sockaddr_in *)from)->sin_port = control->port_from; + break; #endif + default: + break; + } + memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - to = from; #if defined(INET) && defined(INET6) if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) && - (to->sa_family == AF_INET) && + (from->sa_family == AF_INET) && ((size_t)fromlen >= sizeof(struct sockaddr_in6))) { struct sockaddr_in *sin; struct sockaddr_in6 sin6; - sin = (struct sockaddr_in *)to; + sin = (struct sockaddr_in *)from; bzero(&sin6, sizeof(sin6)); sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); @@ -5473,15 +5476,15 @@ found_one: &sin6.sin6_addr.s6_addr32[3], sizeof(sin6.sin6_addr.s6_addr32[3])); sin6.sin6_port = sin->sin_port; - memcpy(from, (caddr_t)&sin6, sizeof(sin6)); + memcpy(from, &sin6, sizeof(struct sockaddr_in6)); } #endif #if defined(INET6) { - struct sockaddr_in6 lsa6, *to6; + struct sockaddr_in6 lsa6, *from6; - to6 = (struct sockaddr_in6 *)to; - sctp_recover_scope_mac(to6, (&lsa6)); + from6 = (struct sockaddr_in6 *)from; + sctp_recover_scope_mac(from6, (&lsa6)); } #endif } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:31:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 22FFB106566B; Sun, 29 Apr 2012 18:31:30 +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 0D2848FC17; Sun, 29 Apr 2012 18:31: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 q3TIVT3q026548; Sun, 29 Apr 2012 18:31:29 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIVTMa026546; Sun, 29 Apr 2012 18:31:29 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291831.q3TIVTMa026546@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:31:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234805 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:31:30 -0000 Author: tuexen Date: Sun Apr 29 18:31:29 2012 New Revision: 234805 URL: http://svn.freebsd.org/changeset/base/234805 Log: MFC r233597: Honor the net.inet.udp.checksum sysctl when using SCTP/UDP/IPv4 encapsulation. Modified: stable/8/sys/netinet/sctp_output.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_output.c ============================================================================== --- stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:28:58 2012 (r234804) +++ stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:31:29 2012 (r234805) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -4064,7 +4065,11 @@ sctp_lowlevel_chunk_output(struct sctp_i udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons(packet_length - sizeof(struct ip)); - udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); } else { sctphdr = (struct sctphdr *)((caddr_t)ip + sizeof(struct ip)); @@ -4127,7 +4132,9 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_STAT_INCR(sctps_sendnocrc); } #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -11007,8 +11014,13 @@ sctp_send_shutdown_complete2(struct mbuf udp->uh_dport = port; udp->uh_ulen = htons(sizeof(struct sctp_shutdown_complete_msg) + sizeof(struct udphdr)); #ifdef INET - if (iph_out) - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (iph_out) { + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } + } #endif offset_out += sizeof(struct udphdr); comp_cp = (struct sctp_shutdown_complete_msg *)((caddr_t)comp_cp + sizeof(struct udphdr)); @@ -11047,7 +11059,9 @@ sctp_send_shutdown_complete2(struct mbuf comp_cp->sh.checksum = sctp_calculate_cksum(mout, offset_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(mout); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(mout); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12024,7 +12038,11 @@ sctp_send_abort(struct mbuf *m, int iphl bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } SCTPDBG(SCTP_DEBUG_OUTPUT2, "sctp_send_abort calling ip_output:\n"); SCTPDBG_PKT(SCTP_DEBUG_OUTPUT2, iph_out, &abm->sh); @@ -12043,7 +12061,9 @@ sctp_send_abort(struct mbuf *m, int iphl abm->sh.checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12286,7 +12306,11 @@ sctp_send_operr_to(struct mbuf *m, int i bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } /* set IPv4 length */ iph_out->ip_len = len; @@ -12303,7 +12327,9 @@ sctp_send_operr_to(struct mbuf *m, int i sh_out->checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:35:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 515DE106566C; Sun, 29 Apr 2012 18:35:20 +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 3AF108FC0C; Sun, 29 Apr 2012 18:35:20 +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 q3TIZKL4026735; Sun, 29 Apr 2012 18:35:20 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIZJd8026722; Sun, 29 Apr 2012 18:35:19 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291835.q3TIZJd8026722@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:35:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234806 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:35:20 -0000 Author: tuexen Date: Sun Apr 29 18:35:19 2012 New Revision: 234806 URL: http://svn.freebsd.org/changeset/base/234806 Log: MFC r233660: Make stream our stream reset implementation compliant to RFC6525. From rrs@. Modified: stable/8/sys/netinet/sctp.h stable/8/sys/netinet/sctp_constants.h stable/8/sys/netinet/sctp_header.h stable/8/sys/netinet/sctp_input.c stable/8/sys/netinet/sctp_output.c stable/8/sys/netinet/sctp_output.h stable/8/sys/netinet/sctp_pcb.h stable/8/sys/netinet/sctp_peeloff.c stable/8/sys/netinet/sctp_structs.h stable/8/sys/netinet/sctp_uio.h stable/8/sys/netinet/sctp_usrreq.c stable/8/sys/netinet/sctputil.c stable/8/sys/netinet/sctputil.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp.h ============================================================================== --- stable/8/sys/netinet/sctp.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp.h Sun Apr 29 18:35:19 2012 (r234806) @@ -155,8 +155,22 @@ struct sctp_paramhdr { * field. */ -/* these should probably go into sockets API */ -#define SCTP_RESET_STREAMS 0x00001004 /* wo */ +#define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct + * sctp_assoc_value */ +#define SCTP_RESET_STREAMS 0x00000901 /* struct + * sctp_reset_streams */ +#define SCTP_RESET_ASSOC 0x00000902 /* sctp_assoc_t */ +#define SCTP_ADD_STREAMS 0x00000903 /* struct + * sctp_add_streams */ + +/* For enable stream reset */ +#define SCTP_ENABLE_RESET_STREAM_REQ 0x00000001 +#define SCTP_ENABLE_RESET_ASSOC_REQ 0x00000002 +#define SCTP_ENABLE_CHANGE_ASSOC_REQ 0x00000004 +#define SCTP_ENABLE_VALUE_MASK 0x00000007 +/* For reset streams */ +#define SCTP_STREAM_RESET_INCOMING 0x00000001 +#define SCTP_STREAM_RESET_OUTGOING 0x00000002 /* here on down are more implementation specific */ Modified: stable/8/sys/netinet/sctp_constants.h ============================================================================== --- stable/8/sys/netinet/sctp_constants.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_constants.h Sun Apr 29 18:35:19 2012 (r234806) @@ -418,7 +418,8 @@ __FBSDID("$FreeBSD$"); #define SCTP_STR_RESET_IN_REQUEST 0x000e #define SCTP_STR_RESET_TSN_REQUEST 0x000f #define SCTP_STR_RESET_RESPONSE 0x0010 -#define SCTP_STR_RESET_ADD_STREAMS 0x0011 +#define SCTP_STR_RESET_ADD_OUT_STREAMS 0x0011 +#define SCTP_STR_RESET_ADD_IN_STREAMS 0x0012 #define SCTP_MAX_RESET_PARAMS 2 #define SCTP_STREAM_RESET_TSN_DELTA 0x1000 Modified: stable/8/sys/netinet/sctp_header.h ============================================================================== --- stable/8/sys/netinet/sctp_header.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_header.h Sun Apr 29 18:35:19 2012 (r234806) @@ -501,7 +501,7 @@ struct sctp_stream_reset_add_strm { #define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ #define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ -#define SCTP_STREAM_RESET_DENIED 0x00000002 /* refused to do it */ +#define SCTP_STREAM_RESET_REJECT 0x00000002 /* refused to do it */ #define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ #define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ #define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ Modified: stable/8/sys/netinet/sctp_input.c ============================================================================== --- stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:35:19 2012 (r234806) @@ -2790,6 +2790,7 @@ sctp_handle_cookie_echo(struct mbuf *m, inp->sctp_ecn_enable = (*inp_p)->sctp_ecn_enable; inp->partial_delivery_point = (*inp_p)->partial_delivery_point; inp->sctp_context = (*inp_p)->sctp_context; + inp->local_strreset_support = (*inp_p)->local_strreset_support; inp->inp_starting_point_for_iterator = NULL; /* * copy in the authentication parameters from the @@ -3612,20 +3613,35 @@ sctp_handle_stream_reset_response(struct if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action != SCTP_STREAM_RESET_PERFORMED) { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, + number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } - } else if (type == SCTP_STR_RESET_ADD_STREAMS) { + } else if (type == SCTP_STR_RESET_ADD_OUT_STREAMS) { /* Ok we now may have more streams */ + int num_stream; + + num_stream = stcb->asoc.strm_pending_add_size; + if (num_stream > (stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt)) { + /* TSNH */ + num_stream = stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt; + } + stcb->asoc.strm_pending_add_size = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action == SCTP_STREAM_RESET_PERFORMED) { /* Put the new streams into effect */ - stcb->asoc.streamoutcnt = stcb->asoc.strm_realoutsize; - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD_OK, stcb, - (uint32_t) stcb->asoc.streamoutcnt, NULL, SCTP_SO_NOT_LOCKED); + stcb->asoc.streamoutcnt += num_stream; + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } else { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD_FAIL, stcb, - (uint32_t) stcb->asoc.streamoutcnt, NULL, SCTP_SO_NOT_LOCKED); + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGED_DENIED); + } + } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { + if (asoc->stream_reset_outstanding) + asoc->stream_reset_outstanding--; + if (action != SCTP_STREAM_RESET_PERFORMED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGED_DENIED); } } else if (type == SCTP_STR_RESET_TSN_REQUEST) { /** @@ -3667,7 +3683,10 @@ sctp_handle_stream_reset_response(struct sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); - + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + } else { + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), + SCTP_STREAM_RESET_FAILED); } } /* get rid of the request and get the request flags */ @@ -3700,8 +3719,7 @@ sctp_handle_str_reset_request_in(struct if (trunc) { /* Can't do it, since they exceeded our buffer size */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; - sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else if (stcb->asoc.stream_reset_out_is_outstanding == 0) { len = ntohs(req->ph.param_length); number_entries = ((len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t)); @@ -3723,8 +3741,8 @@ sctp_handle_str_reset_request_in(struct /* Can't do it, since we have sent one out */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; asoc->last_reset_action[0] = SCTP_STREAM_RESET_TRY_LATER; - sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); @@ -3786,7 +3804,7 @@ sctp_handle_str_reset_request_tsn(struct sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[0], @@ -3831,12 +3849,10 @@ sctp_handle_str_reset_request_out(struct /* move the reset action back one */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; if (trunc) { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* we can do it now */ sctp_reset_in_stream(stcb, number_entries, req->list_of_streams); - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; } else { /* @@ -3851,8 +3867,8 @@ sctp_handle_str_reset_request_out(struct siz, SCTP_M_STRESET); if (liste == NULL) { /* gak out of memory */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_REJECT); + asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; return; } liste->tsn = tsn; @@ -3860,9 +3876,9 @@ sctp_handle_str_reset_request_out(struct memcpy(&liste->req, req, (sizeof(struct sctp_stream_reset_out_request) + (number_entries * sizeof(uint16_t)))); TAILQ_INSERT_TAIL(&asoc->resetHead, liste, next_resp); - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; } else if ((asoc->str_reset_seq_in - 1) == seq) { /* @@ -3889,7 +3905,7 @@ sctp_handle_str_reset_add_strm(struct sc * Peer is requesting to add more streams. If its within our * max-streams we will allow it. */ - uint16_t num_stream, i; + uint32_t num_stream, i; uint32_t seq; struct sctp_association *asoc = &stcb->asoc; struct sctp_queued_to_read *ctl, *nctl; @@ -3900,12 +3916,12 @@ sctp_handle_str_reset_add_strm(struct sc /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { num_stream += stcb->asoc.streamincnt; - if (num_stream > stcb->asoc.max_inbound_streams) { + if ((num_stream > stcb->asoc.max_inbound_streams) || + (num_stream > 0xffff)) { /* We must reject it they ask for to many */ denied: - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_DENIED); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_DENIED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; } else { /* Ok, we can do that :-) */ struct sctp_stream_in *oldstrm; @@ -3941,13 +3957,12 @@ sctp_handle_str_reset_add_strm(struct sc SCTP_FREE(oldstrm, SCTP_M_STRMI); /* update the size */ stcb->asoc.streamincnt = num_stream; - /* Send the ack */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_PERFORMED); stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_INSTREAM_ADD_OK, stcb, - (uint32_t) stcb->asoc.streamincnt, NULL, SCTP_SO_NOT_LOCKED); + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + asoc->str_reset_seq_in++; } else if ((asoc->str_reset_seq_in - 1) == seq) { /* * one seq back, just echo back last action since my @@ -3966,6 +3981,63 @@ sctp_handle_str_reset_add_strm(struct sc } } +static void +sctp_handle_str_reset_add_out_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk, + struct sctp_stream_reset_add_strm *str_add) +{ + /* + * Peer is requesting to add more streams. If its within our + * max-streams we will allow it. + */ + uint16_t num_stream; + uint32_t seq; + struct sctp_association *asoc = &stcb->asoc; + + /* Get the number. */ + seq = ntohl(str_add->request_seq); + num_stream = ntohs(str_add->number_of_streams); + /* Now what would be the new total? */ + if (asoc->str_reset_seq_in == seq) { + if (stcb->asoc.stream_reset_outstanding) { + /* We must reject it we have something pending */ + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } else { + /* Ok, we can do that :-) */ + int mychk; + + mychk = stcb->asoc.streamoutcnt; + mychk += num_stream; + if (mychk < 0x10000) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + if (sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, 1, num_stream, 0, 1)) { + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } + } else { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + } + } + sctp_add_stream_reset_result(chk, seq, stcb->asoc.last_reset_action[0]); + asoc->str_reset_seq_in++; + } else if ((asoc->str_reset_seq_in - 1) == seq) { + /* + * one seq back, just echo back last action since my + * response was lost. + */ + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); + } else if ((asoc->str_reset_seq_in - 2) == seq) { + /* + * two seq back, just echo back last action since my + * response was lost. + */ + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); + } else { + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + } +} + #ifdef __GNUC__ __attribute__((noinline)) #endif @@ -3977,7 +4049,7 @@ __attribute__((noinline)) struct sctp_paramhdr pstore; uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE]; - uint32_t seq; + uint32_t seq = 0; int num_req = 0; int trunc = 0; struct sctp_tmit_chunk *chk; @@ -4041,7 +4113,6 @@ strres_nochunk: } else { trunc = 0; } - if (num_param > SCTP_MAX_RESET_PARAMS) { /* hit the max of parameters already sorry.. */ break; @@ -4059,26 +4130,29 @@ strres_nochunk: } } sctp_handle_str_reset_request_out(stcb, chk, req_out, trunc); - } else if (ptype == SCTP_STR_RESET_ADD_STREAMS) { + } else if (ptype == SCTP_STR_RESET_ADD_OUT_STREAMS) { struct sctp_stream_reset_add_strm *str_add; str_add = (struct sctp_stream_reset_add_strm *)ph; num_req++; sctp_handle_str_reset_add_strm(stcb, chk, str_add); + } else if (ptype == SCTP_STR_RESET_ADD_IN_STREAMS) { + struct sctp_stream_reset_add_strm *str_add; + + str_add = (struct sctp_stream_reset_add_strm *)ph; + num_req++; + sctp_handle_str_reset_add_out_strm(stcb, chk, str_add); } else if (ptype == SCTP_STR_RESET_IN_REQUEST) { struct sctp_stream_reset_in_request *req_in; num_req++; - req_in = (struct sctp_stream_reset_in_request *)ph; - sctp_handle_str_reset_request_in(stcb, chk, req_in, trunc); } else if (ptype == SCTP_STR_RESET_TSN_REQUEST) { struct sctp_stream_reset_tsn_request *req_tsn; num_req++; req_tsn = (struct sctp_stream_reset_tsn_request *)ph; - if (sctp_handle_str_reset_request_tsn(stcb, chk, req_tsn)) { ret_code = 1; goto strres_nochunk; Modified: stable/8/sys/netinet/sctp_output.c ============================================================================== --- stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:35:19 2012 (r234806) @@ -11716,7 +11716,7 @@ sctp_add_stream_reset_result_tsn(struct } static void -sctp_add_a_stream(struct sctp_tmit_chunk *chk, +sctp_add_an_out_stream(struct sctp_tmit_chunk *chk, uint32_t seq, uint16_t adding) { @@ -11733,7 +11733,7 @@ sctp_add_a_stream(struct sctp_tmit_chunk len = sizeof(struct sctp_stream_reset_add_strm); /* Fill it out. */ - addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_STREAMS); + addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_OUT_STREAMS); addstr->ph.param_length = htons(len); addstr->request_seq = htonl(seq); addstr->number_of_streams = htons(adding); @@ -11748,15 +11748,49 @@ sctp_add_a_stream(struct sctp_tmit_chunk return; } +static void +sctp_add_an_in_stream(struct sctp_tmit_chunk *chk, + uint32_t seq, + uint16_t adding) +{ + int len, old_len; + struct sctp_chunkhdr *ch; + struct sctp_stream_reset_add_strm *addstr; + + ch = mtod(chk->data, struct sctp_chunkhdr *); + old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); + + /* get to new offset for the param. */ + addstr = (struct sctp_stream_reset_add_strm *)((caddr_t)ch + len); + /* now how long will this param be? */ + len = sizeof(struct sctp_stream_reset_add_strm); + /* Fill it out. */ + addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_IN_STREAMS); + addstr->ph.param_length = htons(len); + addstr->request_seq = htonl(seq); + addstr->number_of_streams = htons(adding); + addstr->reserved = 0; + + /* now fix the chunk length */ + ch->chunk_length = htons(len + old_len); + chk->send_size = len + old_len; + chk->book_size = SCTP_SIZE32(chk->send_size); + chk->book_size_scale = 0; + SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); + return; +} + + + int sctp_send_str_reset_req(struct sctp_tcb *stcb, int number_entries, uint16_t * list, uint8_t send_out_req, - uint32_t resp_seq, uint8_t send_in_req, uint8_t send_tsn_req, uint8_t add_stream, - uint16_t adding + uint16_t adding_o, + uint16_t adding_i, uint8_t peer_asked ) { @@ -11823,18 +11857,86 @@ sctp_send_str_reset_req(struct sctp_tcb seq = stcb->asoc.str_reset_seq_out; if (send_out_req) { sctp_add_stream_reset_out(chk, number_entries, list, - seq, resp_seq, (stcb->asoc.sending_seq - 1)); + seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1)); asoc->stream_reset_out_is_outstanding = 1; seq++; asoc->stream_reset_outstanding++; } - if (add_stream) { - sctp_add_a_stream(chk, seq, adding); + if ((add_stream & 1) && + ((stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt) < adding_o)) { + /* Need to allocate more */ + struct sctp_stream_out *oldstream; + struct sctp_stream_queue_pending *sp, *nsp; + int i; + + oldstream = stcb->asoc.strmout; + /* get some more */ + SCTP_MALLOC(stcb->asoc.strmout, struct sctp_stream_out *, + ((stcb->asoc.streamoutcnt + adding_o) * sizeof(struct sctp_stream_out)), + SCTP_M_STRMO); + if (stcb->asoc.strmout == NULL) { + uint8_t x; + + stcb->asoc.strmout = oldstream; + /* Turn off the bit */ + x = add_stream & 0xfe; + add_stream = x; + goto skip_stuff; + } + /* + * Ok now we proceed with copying the old out stuff and + * initializing the new stuff. + */ + SCTP_TCB_SEND_LOCK(stcb); + stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 0, 1); + for (i = 0; i < stcb->asoc.streamoutcnt; i++) { + TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].next_sequence_sent = oldstream[i].next_sequence_sent; + stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; + stcb->asoc.strmout[i].stream_no = i; + stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], &oldstream[i]); + /* now anything on those queues? */ + TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) { + TAILQ_REMOVE(&oldstream[i].outqueue, sp, next); + TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); + } + /* Now move assoc pointers too */ + if (stcb->asoc.last_out_stream == &oldstream[i]) { + stcb->asoc.last_out_stream = &stcb->asoc.strmout[i]; + } + if (stcb->asoc.locked_on_sending == &oldstream[i]) { + stcb->asoc.locked_on_sending = &stcb->asoc.strmout[i]; + } + } + /* now the new streams */ + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); + for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + adding_o); i++) { + stcb->asoc.strmout[i].next_sequence_sent = 0x0; + TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].stream_no = i; + stcb->asoc.strmout[i].last_msg_incomplete = 0; + stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL); + } + stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt + adding_o; + SCTP_FREE(oldstream, SCTP_M_STRMO); + SCTP_TCB_SEND_UNLOCK(stcb); + } +skip_stuff: + if ((add_stream & 1) && (adding_o > 0)) { + asoc->strm_pending_add_size = adding_o; + asoc->peer_req_out = peer_asked; + sctp_add_an_out_stream(chk, seq, adding_o); + seq++; + asoc->stream_reset_outstanding++; + } + if ((add_stream & 2) && (adding_i > 0)) { + sctp_add_an_in_stream(chk, seq, adding_i); seq++; asoc->stream_reset_outstanding++; } if (send_in_req) { sctp_add_stream_reset_in(chk, number_entries, list, seq); + seq++; asoc->stream_reset_outstanding++; } if (send_tsn_req) { @@ -11842,7 +11944,6 @@ sctp_send_str_reset_req(struct sctp_tcb asoc->stream_reset_outstanding++; } asoc->str_reset = chk; - /* insert the chunk for sending */ TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, Modified: stable/8/sys/netinet/sctp_output.h ============================================================================== --- stable/8/sys/netinet/sctp_output.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_output.h Sun Apr 29 18:35:19 2012 (r234806) @@ -194,15 +194,13 @@ sctp_add_stream_reset_result_tsn(struct int sctp_send_str_reset_req(struct sctp_tcb *stcb, - int number_entries, - uint16_t * list, + int number_entries, uint16_t * list, uint8_t send_out_req, - uint32_t resp_seq, uint8_t send_in_req, uint8_t send_tsn_req, - uint8_t add_str, - uint16_t adding); - + uint8_t add_stream, + uint16_t adding_o, + uint16_t adding_i, uint8_t from_peer); void sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t, Modified: stable/8/sys/netinet/sctp_pcb.h ============================================================================== --- stable/8/sys/netinet/sctp_pcb.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_pcb.h Sun Apr 29 18:35:19 2012 (r234806) @@ -399,6 +399,7 @@ struct sctp_inpcb { uint32_t sctp_frag_point; uint32_t partial_delivery_point; uint32_t sctp_context; + uint8_t local_strreset_support; uint32_t sctp_cmt_on_off; uint32_t sctp_ecn_enable; struct sctp_nonpad_sndrcvinfo def_send; Modified: stable/8/sys/netinet/sctp_peeloff.c ============================================================================== --- stable/8/sys/netinet/sctp_peeloff.c Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_peeloff.c Sun Apr 29 18:35:19 2012 (r234806) @@ -127,6 +127,7 @@ sctp_do_peeloff(struct socket *head, str n_inp->sctp_ecn_enable = inp->sctp_ecn_enable; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ if (n_inp->sctp_ep.local_hmacs) @@ -202,6 +203,7 @@ sctp_get_peeloff(struct socket *head, sc n_inp->sctp_ecn_enable = inp->sctp_ecn_enable; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ Modified: stable/8/sys/netinet/sctp_structs.h ============================================================================== --- stable/8/sys/netinet/sctp_structs.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_structs.h Sun Apr 29 18:35:19 2012 (r234806) @@ -1093,6 +1093,7 @@ struct sctp_association { uint16_t streamincnt; uint16_t streamoutcnt; uint16_t strm_realoutsize; + uint16_t strm_pending_add_size; /* my maximum number of retrans of INIT and SEND */ /* copied from SCTP but should be individually setable */ uint16_t max_init_times; @@ -1154,6 +1155,9 @@ struct sctp_association { /* Flag to tell if ECN is allowed */ uint8_t ecn_allowed; + /* Did the peer make the stream config (add out) request */ + uint8_t peer_req_out; + /* flag to indicate if peer can do asconf */ uint8_t peer_supports_asconf; /* EY - flag to indicate if peer can do nr_sack */ @@ -1164,6 +1168,7 @@ struct sctp_association { uint8_t peer_supports_auth; /* stream resets are supported by the peer */ uint8_t peer_supports_strreset; + uint8_t local_strreset_support; uint8_t peer_supports_nat; /* Modified: stable/8/sys/netinet/sctp_uio.h ============================================================================== --- stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:35:19 2012 (r234806) @@ -438,23 +438,51 @@ struct sctp_sender_dry_event { /* - * stream reset event + * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT */ struct sctp_stream_reset_event { uint16_t strreset_type; uint16_t strreset_flags; uint32_t strreset_length; sctp_assoc_t strreset_assoc_id; - uint16_t strreset_list[]; + uint16_t strreset_stream_list[]; }; -/* flags in strreset_flags field */ -#define SCTP_STRRESET_INBOUND_STR 0x0001 -#define SCTP_STRRESET_OUTBOUND_STR 0x0002 -#define SCTP_STRRESET_ALL_STREAMS 0x0004 -#define SCTP_STRRESET_STREAM_LIST 0x0008 -#define SCTP_STRRESET_FAILED 0x0010 -#define SCTP_STRRESET_ADD_STREAM 0x0020 +/* flags in stream_reset_event (strreset_flags) */ +#define SCTP_STREAM_RESET_DENIED 0x0004 /* SCTP_STRRESET_FAILED */ +#define SCTP_STREAM_RESET_FAILED 0x0008 /* SCTP_STRRESET_FAILED */ +#define SCTP_STREAM_CHANGED_DENIED 0x0010 + +/* + * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT + */ +struct sctp_assoc_reset_event { + uint16_t assocreset_type; + uint16_t assocreset_flags; + uint32_t assocreset_length; + sctp_assoc_t assocreset_assoc_id; + uint32_t assocreset_local_tsn; + uint32_t assocreset_remote_tsn; +}; + +#define SCTP_ASSOC_RESET_DENIED 0x0004 +#define SCTP_ASSOC_RESET_FAILED 0x0008 + +/* + * Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT + */ +struct sctp_stream_change_event { + uint16_t strchange_type; + uint16_t strchange_flags; + uint32_t strchange_length; + sctp_assoc_t strchange_assoc_id; + uint16_t strchange_instrms; + uint16_t strchange_outstrms; +}; + +#define SCTP_STREAM_CHANGE_DENIED 0x0004 +#define SCTP_STREAM_CHANGE_FAILED 0x0008 + /* SCTP notification event */ struct sctp_tlv { @@ -477,6 +505,9 @@ union sctp_notification { struct sctp_authkey_event sn_auth_event; struct sctp_sender_dry_event sn_sender_dry_event; struct sctp_stream_reset_event sn_strreset_event; + struct sctp_assoc_reset_event sn_assocreset_event; + struct sctp_stream_change_event sn_strchange_event; + }; /* notification types */ @@ -493,6 +524,9 @@ union sctp_notification { #define SCTP_STREAM_RESET_EVENT 0x0009 #define SCTP_SENDER_DRY_EVENT 0x000a #define SCTP_NOTIFICATIONS_STOPPED_EVENT 0x000b /* we don't send this */ +#define SCTP_ASSOC_RESET_EVENT 0x000c +#define SCTP_STREAM_CHANGE_EVENT 0x000d + /* * socket option structs */ @@ -707,19 +741,18 @@ struct sctp_blk_args { */ #define SCTP_MAX_EXPLICT_STR_RESET 1000 -#define SCTP_RESET_LOCAL_RECV 0x0001 -#define SCTP_RESET_LOCAL_SEND 0x0002 -#define SCTP_RESET_BOTH 0x0003 -#define SCTP_RESET_TSN 0x0004 -#define SCTP_RESET_ADD_STREAMS 0x0005 - -struct sctp_stream_reset { - sctp_assoc_t strrst_assoc_id; - uint16_t strrst_flags; - uint16_t strrst_num_streams; /* 0 == ALL */ - uint16_t strrst_list[]; /* list if strrst_num_streams is not 0 */ +struct sctp_reset_streams { + sctp_assoc_t srs_assoc_id; + uint16_t srs_flags; + uint16_t srs_number_streams; /* 0 == ALL */ + uint16_t srs_stream_list[]; /* list if strrst_num_streams is not 0 */ }; +struct sctp_add_streams { + sctp_assoc_t sas_assoc_id; + uint16_t sas_instrms; + uint16_t sas_outstrms; +}; struct sctp_get_nonce_values { sctp_assoc_t gn_assoc_id; Modified: stable/8/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:31:29 2012 (r234805) +++ stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:35:19 2012 (r234806) @@ -4077,17 +4077,52 @@ sctp_setopt(struct socket *so, int optna } break; } + case SCTP_ENABLE_STREAM_RESET: + { + struct sctp_assoc_value *av; + uint8_t set_value = 0; + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); + if (av->assoc_value & (~SCTP_ENABLE_VALUE_MASK)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; + } + set_value = av->assoc_value & SCTP_ENABLE_VALUE_MASK; + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + if (stcb) { + stcb->asoc.local_strreset_support = set_value; + SCTP_TCB_UNLOCK(stcb); + } else { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || + (av->assoc_id == SCTP_FUTURE_ASSOC) || + (av->assoc_id == SCTP_ALL_ASSOC)) { + SCTP_INP_WLOCK(inp); + inp->local_strreset_support = set_value; + SCTP_INP_WUNLOCK(inp); + } + if ((av->assoc_id == SCTP_CURRENT_ASSOC) || + (av->assoc_id == SCTP_ALL_ASSOC)) { + SCTP_INP_RLOCK(inp); + LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { + SCTP_TCB_LOCK(stcb); + stcb->asoc.local_strreset_support = set_value; + SCTP_TCB_UNLOCK(stcb); + } + SCTP_INP_RUNLOCK(inp); + } + } + break; + } case SCTP_RESET_STREAMS: { - struct sctp_stream_reset *strrst; - uint8_t send_in = 0, send_tsn = 0, send_out = 0, - addstream = 0; - uint16_t addstrmcnt = 0; - int i; + struct sctp_reset_streams *strrst; + int i, send_out = 0; + int send_in = 0; - SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_stream_reset, optsize); - SCTP_FIND_STCB(inp, stcb, strrst->strrst_assoc_id); + SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_reset_streams, optsize); + SCTP_FIND_STCB(inp, stcb, strrst->srs_assoc_id); if (stcb == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); @@ -4096,13 +4131,19 @@ sctp_setopt(struct socket *so, int optna } if (stcb->asoc.peer_supports_strreset == 0) { /* - * Peer does not support it, we return - * protocol not supported since this is true - * for this feature and this peer, not the - * socket request in general. + * Peer does not support the chunk type. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; + SCTP_TCB_UNLOCK(stcb); + break; + } + if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + /* + * User did not enable the operation. */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPROTONOSUPPORT); - error = EPROTONOSUPPORT; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); + error = EPERM; SCTP_TCB_UNLOCK(stcb); break; } @@ -4112,129 +4153,137 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (strrst->strrst_flags == SCTP_RESET_LOCAL_RECV) { - send_in = 1; - } else if (strrst->strrst_flags == SCTP_RESET_LOCAL_SEND) { - send_out = 1; - } else if (strrst->strrst_flags == SCTP_RESET_BOTH) { + if (strrst->srs_flags & SCTP_STREAM_RESET_INCOMING) { send_in = 1; + } + if (strrst->srs_flags & SCTP_STREAM_RESET_OUTGOING) { send_out = 1; - } else if (strrst->strrst_flags == SCTP_RESET_TSN) { - send_tsn = 1; - } else if (strrst->strrst_flags == SCTP_RESET_ADD_STREAMS) { - if (send_tsn || - send_in || - send_out) { - /* We can't do that and add streams */ + } + if ((send_in == 0) && (send_out == 0)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + SCTP_TCB_UNLOCK(stcb); + break; + } + for (i = 0; i < strrst->srs_number_streams; i++) { + if ((send_in) && + (strrst->srs_stream_list[i] > stcb->asoc.streamincnt)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; - goto skip_stuff; + break; } - if (stcb->asoc.stream_reset_outstanding) { - error = EBUSY; - goto skip_stuff; + if ((send_out) && + (strrst->srs_stream_list[i] > stcb->asoc.streamoutcnt)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; } + } + if (error) { + SCTP_TCB_UNLOCK(stcb); + break; + } + error = sctp_send_str_reset_req(stcb, strrst->srs_number_streams, + strrst->srs_stream_list, + send_out, send_in, 0, 0, 0, 0, 0); + + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_REQ, SCTP_SO_LOCKED); + SCTP_TCB_UNLOCK(stcb); + break; + } + case SCTP_ADD_STREAMS: + { + struct sctp_add_streams *stradd; + uint8_t addstream = 0; + uint16_t add_o_strmcnt = 0; + uint16_t add_i_strmcnt = 0; + + SCTP_CHECK_AND_CAST(stradd, optval, struct sctp_add_streams, optsize); + SCTP_FIND_STCB(inp, stcb, stradd->sas_assoc_id); + if (stcb == NULL) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); + error = ENOENT; + break; + } + if ((stradd->sas_outstrms == 0) && + (stradd->sas_instrms == 0)) { + error = EINVAL; + goto skip_stuff; + } + if (stradd->sas_outstrms) { addstream = 1; /* We allocate here */ - addstrmcnt = strrst->strrst_num_streams; - if ((int)(addstrmcnt + stcb->asoc.streamoutcnt) > 0xffff) { + add_o_strmcnt = stradd->sas_outstrms; + if ((((int)add_o_strmcnt) + ((int)stcb->asoc.streamoutcnt)) > 0x0000ffff) { /* You can't have more than 64k */ error = EINVAL; goto skip_stuff; } - if ((stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt) < addstrmcnt) { - /* Need to allocate more */ - struct sctp_stream_out *oldstream; - struct sctp_stream_queue_pending *sp, - *nsp; - - oldstream = stcb->asoc.strmout; - /* get some more */ - SCTP_MALLOC(stcb->asoc.strmout, struct sctp_stream_out *, - ((stcb->asoc.streamoutcnt + addstrmcnt) * sizeof(struct sctp_stream_out)), - SCTP_M_STRMO); - if (stcb->asoc.strmout == NULL) { - stcb->asoc.strmout = oldstream; - error = ENOMEM; - goto skip_stuff; - } - /* - * Ok now we proceed with copying - * the old out stuff and - * initializing the new stuff. - */ - SCTP_TCB_SEND_LOCK(stcb); - stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 0, 1); - for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); - stcb->asoc.strmout[i].next_sequence_sent = oldstream[i].next_sequence_sent; - stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; - stcb->asoc.strmout[i].stream_no = i; - stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], &oldstream[i]); - /* - * now anything on those - * queues? - */ - TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) { - TAILQ_REMOVE(&oldstream[i].outqueue, sp, next); - TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); - } - /* - * Now move assoc pointers - * too - */ - if (stcb->asoc.last_out_stream == &oldstream[i]) { - stcb->asoc.last_out_stream = &stcb->asoc.strmout[i]; - } - if (stcb->asoc.locked_on_sending == &oldstream[i]) { - stcb->asoc.locked_on_sending = &stcb->asoc.strmout[i]; - } - } - /* now the new streams */ - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); - for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + addstrmcnt); i++) { - stcb->asoc.strmout[i].next_sequence_sent = 0x0; - TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); - stcb->asoc.strmout[i].stream_no = i; - stcb->asoc.strmout[i].last_msg_incomplete = 0; - stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL); - } - stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt + addstrmcnt; - SCTP_FREE(oldstream, SCTP_M_STRMO); - } - SCTP_TCB_SEND_UNLOCK(stcb); - goto skip_stuff; - } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - error = EINVAL; - SCTP_TCB_UNLOCK(stcb); - break; } - for (i = 0; i < strrst->strrst_num_streams; i++) { - if ((send_in) && + if (stradd->sas_instrms) { + int cnt; - (strrst->strrst_list[i] > stcb->asoc.streamincnt)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + addstream |= 2; + /* + * We allocate inside + * sctp_send_str_reset_req() + */ + add_i_strmcnt = stradd->sas_instrms; + cnt = add_i_strmcnt; + cnt += stcb->asoc.streamincnt; + if (cnt > 0x0000ffff) { + /* You can't have more than 64k */ error = EINVAL; - goto get_out; + goto skip_stuff; } - if ((send_out) && - (strrst->strrst_list[i] > stcb->asoc.streamoutcnt)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + if (cnt > (int)stcb->asoc.max_inbound_streams) { + /* More than you are allowed */ error = EINVAL; - goto get_out; + goto skip_stuff; } } + error = sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, addstream, add_o_strmcnt, add_i_strmcnt, 0); + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_REQ, SCTP_SO_LOCKED); skip_stuff: - if (error) { - get_out: + SCTP_TCB_UNLOCK(stcb); + break; + } + case SCTP_RESET_ASSOC: + { + uint32_t *value; + + SCTP_CHECK_AND_CAST(value, optval, uint32_t, optsize); + SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value); + if (stcb == NULL) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); + error = ENOENT; + break; + } + if (stcb->asoc.peer_supports_strreset == 0) { + /* + * Peer does not support the chunk type. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; SCTP_TCB_UNLOCK(stcb); break; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:37:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6C7D71065672; Sun, 29 Apr 2012 18:37:27 +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 573838FC0C; Sun, 29 Apr 2012 18:37: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 q3TIbRmg026852; Sun, 29 Apr 2012 18:37:27 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIbRJ4026850; Sun, 29 Apr 2012 18:37:27 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291837.q3TIbRJ4026850@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:37:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234807 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:37:27 -0000 Author: tuexen Date: Sun Apr 29 18:37:26 2012 New Revision: 234807 URL: http://svn.freebsd.org/changeset/base/234807 Log: MFC r233940: Remove duplicate condition in if statement. Modified: stable/8/sys/netinet/sctp_usrreq.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:35:19 2012 (r234806) +++ stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:37:26 2012 (r234807) @@ -3570,7 +3570,6 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); if ((av->assoc_value != SCTP_SS_DEFAULT) && - (av->assoc_value != SCTP_SS_DEFAULT) && (av->assoc_value != SCTP_SS_ROUND_ROBIN) && (av->assoc_value != SCTP_SS_ROUND_ROBIN_PACKET) && (av->assoc_value != SCTP_SS_PRIORITY) && From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:40:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CD01106566B; Sun, 29 Apr 2012 18:40:41 +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 87F028FC1A; Sun, 29 Apr 2012 18:40:41 +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 q3TIefKj027075; Sun, 29 Apr 2012 18:40:41 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIefes027073; Sun, 29 Apr 2012 18:40:41 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291840.q3TIefes027073@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:40:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234808 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:40:41 -0000 Author: tuexen Date: Sun Apr 29 18:40:41 2012 New Revision: 234808 URL: http://svn.freebsd.org/changeset/base/234808 Log: MFC r234296,r234297: Bugfix: Don't send HBs on path which are not idle. Send always HBs when in PF state. Modified: stable/8/sys/netinet/sctp_timer.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_timer.c ============================================================================== --- stable/8/sys/netinet/sctp_timer.c Sun Apr 29 18:37:26 2012 (r234807) +++ stable/8/sys/netinet/sctp_timer.c Sun Apr 29 18:40:41 2012 (r234808) @@ -1438,7 +1438,23 @@ sctp_heartbeat_timer(struct sctp_inpcb * * when move to PF during threshold mangement, a HB has been * queued in that routine */ - sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); + uint32_t ms_gone_by; + + if ((net->last_sent_time.tv_sec > 0) || + (net->last_sent_time.tv_usec > 0)) { + struct timeval diff; + + SCTP_GETTIME_TIMEVAL(&diff); + timevalsub(&diff, &net->last_sent_time); + ms_gone_by = (uint32_t) (diff.tv_sec * 1000) + + (uint32_t) (diff.tv_usec / 1000); + } else { + ms_gone_by = 0xffffffff; + } + if ((ms_gone_by >= net->heart_beat_delay) || + (net->dest_state & SCTP_ADDR_PF)) { + sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); + } } return (0); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:42:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 377F7106564A; Sun, 29 Apr 2012 18:42:50 +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 181AD8FC08; Sun, 29 Apr 2012 18:42: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 q3TIgnSS027190; Sun, 29 Apr 2012 18:42:49 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIgnc7027187; Sun, 29 Apr 2012 18:42:49 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291842.q3TIgnc7027187@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:42:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234809 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:42:50 -0000 Author: tuexen Date: Sun Apr 29 18:42:49 2012 New Revision: 234809 URL: http://svn.freebsd.org/changeset/base/234809 Log: MFC r234459: Fix a bug where we copy out more data from a mbuf chain that are ctually in it. This happens when SCTP receives an unknown chunk, which requires the sending of an ERROR chunk, and there is no final padding but the chunk is not 4-byte aligned. Reported by yueting via rwatson@ Modified: stable/8/sys/netinet/sctp_indata.c stable/8/sys/netinet/sctp_input.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_indata.c ============================================================================== --- stable/8/sys/netinet/sctp_indata.c Sun Apr 29 18:40:41 2012 (r234808) +++ stable/8/sys/netinet/sctp_indata.c Sun Apr 29 18:42:49 2012 (r234809) @@ -2746,11 +2746,13 @@ sctp_process_data(struct mbuf **mm, int phd->param_length = htons(chk_length + sizeof(*phd)); SCTP_BUF_LEN(merr) = sizeof(*phd); - SCTP_BUF_NEXT(merr) = SCTP_M_COPYM(m, *offset, - SCTP_SIZE32(chk_length), - M_DONTWAIT); + SCTP_BUF_NEXT(merr) = SCTP_M_COPYM(m, *offset, chk_length, M_DONTWAIT); if (SCTP_BUF_NEXT(merr)) { - sctp_queue_op_err(stcb, merr); + if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(merr), SCTP_SIZE32(chk_length) - chk_length, NULL)) { + sctp_m_freem(merr); + } else { + sctp_queue_op_err(stcb, merr); + } } else { sctp_m_freem(merr); } Modified: stable/8/sys/netinet/sctp_input.c ============================================================================== --- stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:40:41 2012 (r234808) +++ stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:42:49 2012 (r234809) @@ -5461,23 +5461,26 @@ process_control_chunks: phd->param_type = htons(SCTP_CAUSE_UNRECOG_CHUNK); phd->param_length = htons(chk_length + sizeof(*phd)); SCTP_BUF_LEN(mm) = sizeof(*phd); - SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, SCTP_SIZE32(chk_length), - M_DONTWAIT); + SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, chk_length, M_DONTWAIT); if (SCTP_BUF_NEXT(mm)) { + if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(mm), SCTP_SIZE32(chk_length) - chk_length, NULL)) { + sctp_m_freem(mm); + } else { #ifdef SCTP_MBUF_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { + struct mbuf *mat; - mat = SCTP_BUF_NEXT(mm); - while (mat) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); + mat = SCTP_BUF_NEXT(mm); + while (mat) { + if (SCTP_BUF_IS_EXTENDED(mat)) { + sctp_log_mb(mat, SCTP_MBUF_ICOPY); + } + mat = SCTP_BUF_NEXT(mat); } - mat = SCTP_BUF_NEXT(mat); } - } #endif - sctp_queue_op_err(stcb, mm); + sctp_queue_op_err(stcb, mm); + } } else { sctp_m_freem(mm); } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:44:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6BE5F106566B; Sun, 29 Apr 2012 18:44:25 +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 569118FC14; Sun, 29 Apr 2012 18:44: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 q3TIiPKq027303; Sun, 29 Apr 2012 18:44:25 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIiPHn027301; Sun, 29 Apr 2012 18:44:25 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291844.q3TIiPHn027301@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:44:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234810 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:44:25 -0000 Author: tuexen Date: Sun Apr 29 18:44:24 2012 New Revision: 234810 URL: http://svn.freebsd.org/changeset/base/234810 Log: MFC r234460: Fix reported errno. Modified: stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 18:42:49 2012 (r234809) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:44:24 2012 (r234810) @@ -2553,8 +2553,8 @@ sctp_add_pad_tombuf(struct mbuf *m, int tmp = sctp_get_mbuf_for_msg(padlen, 0, M_DONTWAIT, 1, MT_DATA); if (tmp == NULL) { /* Out of space GAK! we are in big trouble. */ - SCTP_LTRACE_ERR_RET_PKT(m, NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); - return (ENOSPC); + SCTP_LTRACE_ERR_RET_PKT(m, NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, ENOBUFS); + return (ENOBUFS); } /* setup and insert in middle */ SCTP_BUF_LEN(tmp) = padlen; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:46:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F2EA106564A; Sun, 29 Apr 2012 18:46:20 +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 600CC8FC0C; Sun, 29 Apr 2012 18:46:20 +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 q3TIkKdg027419; Sun, 29 Apr 2012 18:46:20 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIkK9k027416; Sun, 29 Apr 2012 18:46:20 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291846.q3TIkK9k027416@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:46:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234811 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:46:20 -0000 Author: tuexen Date: Sun Apr 29 18:46:19 2012 New Revision: 234811 URL: http://svn.freebsd.org/changeset/base/234811 Log: MFC r234461: Use the same pattern for mbuf logging everywhere. Modified: stable/8/sys/netinet/sctp_input.c stable/8/sys/netinet/sctp_output.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_input.c ============================================================================== --- stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:44:24 2012 (r234810) +++ stable/8/sys/netinet/sctp_input.c Sun Apr 29 18:46:19 2012 (r234811) @@ -2463,12 +2463,10 @@ sctp_handle_cookie_echo(struct mbuf *m, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m_sig; - while (mat) { + for (mat = m_sig; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_SPLIT); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -5470,12 +5468,10 @@ process_control_chunks: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = SCTP_BUF_NEXT(mm); - while (mat) { + for (mat = SCTP_BUF_NEXT(mm); mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -5808,10 +5804,6 @@ sctp_print_mbuf_chain(struct mbuf *m) void sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port) { -#ifdef SCTP_MBUF_LOGGING - struct mbuf *mat; - -#endif struct mbuf *m; int iphlen; uint32_t vrf_id = 0; @@ -5846,6 +5838,8 @@ sctp_input_with_port(struct mbuf *i_pak, #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { + struct mbuf *mat; + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_INPUT); Modified: stable/8/sys/netinet/sctp_output.c ============================================================================== --- stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:44:24 2012 (r234810) +++ stable/8/sys/netinet/sctp_output.c Sun Apr 29 18:46:19 2012 (r234811) @@ -3714,12 +3714,10 @@ sctp_add_cookie(struct mbuf *init, int i if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = copy_init; - while (mat) { + for (mat = copy_init; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -3734,12 +3732,10 @@ sctp_add_cookie(struct mbuf *init, int i if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = copy_initack; - while (mat) { + for (mat = copy_initack; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -6446,12 +6442,10 @@ error_out: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = appendchain; - while (mat) { + for (mat = appendchain; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -6547,12 +6541,10 @@ sctp_sendall_iterator(struct sctp_inpcb if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m; - while (mat) { + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -7350,12 +7342,10 @@ dont_do_it: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = chk->data; - while (mat) { + for (mat = chk->data; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -8953,12 +8943,10 @@ sctp_send_cookie_echo(struct mbuf *m, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = cookie; - while (mat) { + for (mat = cookie; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -9027,12 +9015,10 @@ sctp_send_heartbeat_ack(struct sctp_tcb if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = outchain; - while (mat) { + for (mat = outchain; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif @@ -9313,12 +9299,10 @@ sctp_send_asconf_ack(struct sctp_tcb *st if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { struct mbuf *mat; - mat = m_ack; - while (mat) { + for (mat = m_ack; mat; mat = SCTP_BUF_NEXT(mat)) { if (SCTP_BUF_IS_EXTENDED(mat)) { sctp_log_mb(mat, SCTP_MBUF_ICOPY); } - mat = SCTP_BUF_NEXT(mat); } } #endif From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:48:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F49B1065673; Sun, 29 Apr 2012 18:48:01 +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 EE40F8FC1A; Sun, 29 Apr 2012 18:48:00 +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 q3TIm0a6027517; Sun, 29 Apr 2012 18:48:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIm0E8027514; Sun, 29 Apr 2012 18:48:00 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291848.q3TIm0E8027514@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:48:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234812 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:48:01 -0000 Author: tuexen Date: Sun Apr 29 18:48:00 2012 New Revision: 234812 URL: http://svn.freebsd.org/changeset/base/234812 Log: MFC r234464: Whitespace changes. Modified: stable/8/sys/netinet/sctp_usrreq.c stable/8/sys/netinet/sctp_var.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:46:19 2012 (r234811) +++ stable/8/sys/netinet/sctp_usrreq.c Sun Apr 29 18:48:00 2012 (r234812) @@ -1616,7 +1616,7 @@ out_now: } -#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\ +#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\ if (size < sizeof(type)) { \ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); \ error = EINVAL; \ Modified: stable/8/sys/netinet/sctp_var.h ============================================================================== --- stable/8/sys/netinet/sctp_var.h Sun Apr 29 18:46:19 2012 (r234811) +++ stable/8/sys/netinet/sctp_var.h Sun Apr 29 18:48:00 2012 (r234812) @@ -157,7 +157,7 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_alloc_a_chunk(_stcb, _chk) { \ - if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ + if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ (_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \ if ((_chk)) { \ SCTP_INCR_CHK_COUNT(); \ From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:50:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D22941065670; Sun, 29 Apr 2012 18:50:16 +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 BC3C48FC0A; Sun, 29 Apr 2012 18:50:16 +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 q3TIoGHL027648; Sun, 29 Apr 2012 18:50:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIoG5g027646; Sun, 29 Apr 2012 18:50:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291850.q3TIoG5g027646@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234813 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:50:16 -0000 Author: tuexen Date: Sun Apr 29 18:50:16 2012 New Revision: 234813 URL: http://svn.freebsd.org/changeset/base/234813 Log: MFC r234539: Fix check used by stream reset related events. Modified: stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 18:48:00 2012 (r234812) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:50:16 2012 (r234813) @@ -3214,7 +3214,7 @@ sctp_notify_stream_reset_add(struct sctp struct sctp_stream_change_event *stradd; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } @@ -3275,7 +3275,7 @@ sctp_notify_stream_reset_tsn(struct sctp struct sctp_assoc_reset_event *strasoc; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } @@ -3333,7 +3333,7 @@ sctp_notify_stream_reset(struct sctp_tcb struct sctp_stream_reset_event *strreset; int len; - if (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { /* event not enabled */ return; } From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:52:23 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 48FEA106566C; Sun, 29 Apr 2012 18:52:23 +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 1B17F8FC0C; Sun, 29 Apr 2012 18:52:23 +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 q3TIqMWF027769; Sun, 29 Apr 2012 18:52:22 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TIqM4A027766; Sun, 29 Apr 2012 18:52:22 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291852.q3TIqM4A027766@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:52:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234814 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:52:23 -0000 Author: tuexen Date: Sun Apr 29 18:52:22 2012 New Revision: 234814 URL: http://svn.freebsd.org/changeset/base/234814 Log: MFC r234614: Use the flags defined in RFC 6525 in the stream reset event. Modified: stable/8/sys/netinet/sctp_uio.h stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_uio.h ============================================================================== --- stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:50:16 2012 (r234813) +++ stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:52:22 2012 (r234814) @@ -449,9 +449,11 @@ struct sctp_stream_reset_event { }; /* flags in stream_reset_event (strreset_flags) */ -#define SCTP_STREAM_RESET_DENIED 0x0004 /* SCTP_STRRESET_FAILED */ -#define SCTP_STREAM_RESET_FAILED 0x0008 /* SCTP_STRRESET_FAILED */ -#define SCTP_STREAM_CHANGED_DENIED 0x0010 +#define SCTP_STREAM_RESET_INCOMING_SSN 0x0001 +#define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002 +#define SCTP_STREAM_RESET_DENIED 0x0004 +#define SCTP_STREAM_RESET_FAILED 0x0008 +#define SCTP_STREAM_CHANGED_DENIED 0x0010 /* * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 18:50:16 2012 (r234813) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:52:22 2012 (r234814) @@ -3498,18 +3498,18 @@ sctp_ulp_notify(uint32_t notification, s case SCTP_NOTIFY_HB_RESP: break; case SCTP_NOTIFY_STR_RESET_SEND: - sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING); + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING_SSN); break; case SCTP_NOTIFY_STR_RESET_RECV: - sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING); + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING); break; case SCTP_NOTIFY_STR_RESET_FAILED_OUT: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), - (SCTP_STREAM_RESET_OUTGOING | SCTP_STREAM_RESET_INCOMING)); + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED)); break; case SCTP_NOTIFY_STR_RESET_FAILED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), - (SCTP_STREAM_RESET_OUTGOING | SCTP_STREAM_RESET_INCOMING)); + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED)); break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 18:55:53 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D6FF106564A; Sun, 29 Apr 2012 18:55:53 +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 E3A6D8FC0C; Sun, 29 Apr 2012 18:55:52 +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 q3TItqs0027939; Sun, 29 Apr 2012 18:55:52 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TItqd3027935; Sun, 29 Apr 2012 18:55:52 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204291855.q3TItqd3027935@svn.freebsd.org> From: Michael Tuexen Date: Sun, 29 Apr 2012 18:55:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234815 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 18:55:53 -0000 Author: tuexen Date: Sun Apr 29 18:55:52 2012 New Revision: 234815 URL: http://svn.freebsd.org/changeset/base/234815 Log: MFC r234699: Fix a type in an SCTP AUTH related notification. Keep the old name for backwards compatibility. Spotted by Irene Ruengeler. Modified: stable/8/sys/netinet/sctp_auth.c stable/8/sys/netinet/sctp_uio.h stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_auth.c ============================================================================== --- stable/8/sys/netinet/sctp_auth.c Sun Apr 29 18:52:22 2012 (r234814) +++ stable/8/sys/netinet/sctp_auth.c Sun Apr 29 18:55:52 2012 (r234815) @@ -1801,7 +1801,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, * shared_key_id, (void * *)stcb->asoc.authinfo.recv_keyid); */ - sctp_notify_authentication(stcb, SCTP_AUTH_NEWKEY, + sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, shared_key_id, stcb->asoc.authinfo.recv_keyid, SCTP_SO_NOT_LOCKED); /* compute a new recv assoc key and cache it */ Modified: stable/8/sys/netinet/sctp_uio.h ============================================================================== --- stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:52:22 2012 (r234814) +++ stable/8/sys/netinet/sctp_uio.h Sun Apr 29 18:55:52 2012 (r234815) @@ -424,7 +424,8 @@ struct sctp_authkey_event { }; /* indication values */ -#define SCTP_AUTH_NEWKEY 0x0001 +#define SCTP_AUTH_NEW_KEY 0x0001 +#define SCTP_AUTH_NEWKEY SCTP_AUTH_NEW_KEY #define SCTP_AUTH_NO_AUTH 0x0002 #define SCTP_AUTH_FREE_KEY 0x0003 Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 18:52:22 2012 (r234814) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:55:52 2012 (r234815) @@ -3531,7 +3531,7 @@ sctp_ulp_notify(uint32_t notification, s sctp_notify_shutdown_event(stcb); break; case SCTP_NOTIFY_AUTH_NEW_KEY: - sctp_notify_authentication(stcb, SCTP_AUTH_NEWKEY, error, + sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, error, (uint16_t) (uintptr_t) data, so_locked); break; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 19:40:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 89B28106564A; Sun, 29 Apr 2012 19:40:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 756FE8FC16; Sun, 29 Apr 2012 19:40:51 +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 q3TJep4g029436; Sun, 29 Apr 2012 19:40:51 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TJepJs029434; Sun, 29 Apr 2012 19:40:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201204291940.q3TJepJs029434@svn.freebsd.org> From: Alexander Motin Date: Sun, 29 Apr 2012 19:40:51 +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: r234816 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 19:40:51 -0000 Author: mav Date: Sun Apr 29 19:40:50 2012 New Revision: 234816 URL: http://svn.freebsd.org/changeset/base/234816 Log: s/gmirror/graid/ Modified: head/sys/geom/raid/g_raid.c Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Sun Apr 29 18:55:52 2012 (r234815) +++ head/sys/geom/raid/g_raid.c Sun Apr 29 19:40:50 2012 (r234816) @@ -1823,8 +1823,8 @@ g_raid_create_node(struct g_class *mp, sc->sc_flags = 0; TAILQ_INIT(&sc->sc_volumes); TAILQ_INIT(&sc->sc_disks); - sx_init(&sc->sc_lock, "gmirror:lock"); - mtx_init(&sc->sc_queue_mtx, "gmirror:queue", NULL, MTX_DEF); + sx_init(&sc->sc_lock, "graid:lock"); + mtx_init(&sc->sc_queue_mtx, "graid:queue", NULL, MTX_DEF); TAILQ_INIT(&sc->sc_events); bioq_init(&sc->sc_queue); gp->softc = sc; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 22:19:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30DB1106564A; Sun, 29 Apr 2012 22:19:59 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C3998FC1A; Sun, 29 Apr 2012 22:19:59 +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 q3TMJwOu035081; Sun, 29 Apr 2012 22:19:58 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMJwkw035078; Sun, 29 Apr 2012 22:19:58 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292219.q3TMJwkw035078@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:19: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: r234819 - head/lib/libc/gmon X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:19:59 -0000 Author: eadler Date: Sun Apr 29 22:19:58 2012 New Revision: 234819 URL: http://svn.freebsd.org/changeset/base/234819 Log: Allow users of gprof to get per run output files (using the pid) PR: bin/99800 Submitted by: Peter Jeremy Reviewed by: jilles (code) Reviewed by: dwhite (doc) Approved by: cperciva MFC after: 1 week Modified: head/lib/libc/gmon/gmon.c head/lib/libc/gmon/moncontrol.3 Modified: head/lib/libc/gmon/gmon.c ============================================================================== --- head/lib/libc/gmon/gmon.c Sun Apr 29 22:01:23 2012 (r234818) +++ head/lib/libc/gmon/gmon.c Sun Apr 29 22:19:58 2012 (r234819) @@ -157,7 +157,12 @@ _mcleanup(void) } moncontrol(0); - snprintf(outname, sizeof(outname), "%s.gmon", _getprogname()); + if (getenv("PROFIL_USE_PID")) + snprintf(outname, sizeof(outname), "%s.%d.gmon", + _getprogname(), getpid()); + else + snprintf(outname, sizeof(outname), "%s.gmon", _getprogname()); + fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) { _warn("_mcleanup: %s", outname); Modified: head/lib/libc/gmon/moncontrol.3 ============================================================================== --- head/lib/libc/gmon/moncontrol.3 Sun Apr 29 22:01:23 2012 (r234818) +++ head/lib/libc/gmon/moncontrol.3 Sun Apr 29 22:19:58 2012 (r234819) @@ -98,6 +98,12 @@ however, all functions in that address r have their execution time measured. Profiling begins on return from .Fn monstartup . +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm : +.Bl -tag -width ".Ev PROFIL_USE_PID" +.It PROFIL_USE_PID +If set, the pid of the process is inserted into the filename. .Sh FILES .Bl -tag -width progname.gmon -compact .It Pa progname.gmon From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 22:23:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BBC2106566C; Sun, 29 Apr 2012 22:23:01 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EABE68FC08; Sun, 29 Apr 2012 22:23:00 +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 q3TMN00T035220; Sun, 29 Apr 2012 22:23:00 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMN0BJ035218; Sun, 29 Apr 2012 22:23:00 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292223.q3TMN0BJ035218@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234820 - head/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:23:01 -0000 Author: eadler Date: Sun Apr 29 22:23:00 2012 New Revision: 234820 URL: http://svn.freebsd.org/changeset/base/234820 Log: pread(2) might fail with EBUSY, so document it PR: docs/167201 Submitted by: Kurt Jaeger Approved by: cperciva MFC after: 3 days Modified: head/lib/libc/sys/read.2 Modified: head/lib/libc/sys/read.2 ============================================================================== --- head/lib/libc/sys/read.2 Sun Apr 29 22:19:58 2012 (r234819) +++ head/lib/libc/sys/read.2 Sun Apr 29 22:23:00 2012 (r234820) @@ -164,6 +164,8 @@ argument points outside the allocated address space. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EBUSY +Failed to read from a file, e.g. /proc//regs while is not stopped .It Bq Er EINTR A read from a slow device (i.e.\& one that might block for an arbitrary amount of time) From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 22:28:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0DBA01065670; Sun, 29 Apr 2012 22:28:16 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECAF58FC0A; Sun, 29 Apr 2012 22:28: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 q3TMSFSb035426; Sun, 29 Apr 2012 22:28:15 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMSFrC035424; Sun, 29 Apr 2012 22:28:15 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292228.q3TMSFrC035424@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:28: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: r234821 - head/sys/cam/scsi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:28:16 -0000 Author: eadler Date: Sun Apr 29 22:28:15 2012 New Revision: 234821 URL: http://svn.freebsd.org/changeset/base/234821 Log: Add support for: Olympus FE-210 camera LG UP3S MP3 player Laser MP3-2GA13 MP3 PR: usb/119201 Submitted by: Peter Jeremy Approved by: cperciva MFC after: 1 week Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Sun Apr 29 22:23:00 2012 (r234820) +++ head/sys/cam/scsi/scsi_da.c Sun Apr 29 22:28:15 2012 (r234821) @@ -811,6 +811,27 @@ static struct da_quirk_entry da_quirk_ta { T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "???PVT*", "*" }, /*quirks*/DA_Q_4K }, + { + /* + * Olympus FE-210 camera + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "OLYMPUS", "FE210*", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, + { + /* + * LG UP3S MP3 player + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "LG", "UP3S", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, + { + /* + * Laser MP3-2GA13 MP3 player + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "USB 2.0", "(HS) Flash Disk", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, }; static disk_strategy_t dastrategy; From owner-svn-src-all@FreeBSD.ORG Sun Apr 29 22:29:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A11B7106564A; Sun, 29 Apr 2012 22:29:48 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C4708FC15; Sun, 29 Apr 2012 22:29:48 +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 q3TMTmDs035551; Sun, 29 Apr 2012 22:29:48 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMTm9p035549; Sun, 29 Apr 2012 22:29:48 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292229.q3TMTm9p035549@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:29:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234823 - head/share/skel X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:29:48 -0000 Author: eadler Date: Sun Apr 29 22:29:48 2012 New Revision: 234823 URL: http://svn.freebsd.org/changeset/base/234823 Log: Copy recent changes from etc/root/dot.cshrc that make the defaults more user friendly Approved by: cperciva MFC after: 3 days Modified: head/share/skel/dot.cshrc Modified: head/share/skel/dot.cshrc ============================================================================== --- head/share/skel/dot.cshrc Sun Apr 29 22:29:28 2012 (r234822) +++ head/share/skel/dot.cshrc Sun Apr 29 22:29:48 2012 (r234823) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,18 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 00:54:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EECBF106566C; Mon, 30 Apr 2012 00:54:10 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DAC0D8FC0C; Mon, 30 Apr 2012 00:54:10 +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 q3U0sAAs040518; Mon, 30 Apr 2012 00:54:10 GMT (envelope-from gad@svn.freebsd.org) Received: (from gad@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U0sAND040516; Mon, 30 Apr 2012 00:54:10 GMT (envelope-from gad@svn.freebsd.org) Message-Id: <201204300054.q3U0sAND040516@svn.freebsd.org> From: Garance A Drosehn Date: Mon, 30 Apr 2012 00:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234824 - head/usr.sbin/lpr/lpc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 00:54:11 -0000 Author: gad Date: Mon Apr 30 00:54:10 2012 New Revision: 234824 URL: http://svn.freebsd.org/changeset/base/234824 Log: Catch the user-error when no queue name was specified on an lpc-command which supports '-msg' (e.g.: setstatus). Print out a helpful error message instead hitting a seg-fault. MFC after: 3 weeks Modified: head/usr.sbin/lpr/lpc/cmds.c Modified: head/usr.sbin/lpr/lpc/cmds.c ============================================================================== --- head/usr.sbin/lpr/lpc/cmds.c Sun Apr 29 22:29:48 2012 (r234823) +++ head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 00:54:10 2012 (r234824) @@ -163,6 +163,14 @@ generic(void (*specificrtn)(struct print break; } } + if (argc < 1) { + printf("error: No printer name(s) specified before" + " '-msg'.\n"); + printf("usage: %s {all | printer ...}", + generic_cmdname); + printf(" [-msg ...]\n"); + return; + } } /* call initialization routine, if there is one for this cmd */ From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 01:08:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1498E106566B; Mon, 30 Apr 2012 01:08:19 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA69E8FC08; Mon, 30 Apr 2012 01:08:18 +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 q3U18Ifc041046; Mon, 30 Apr 2012 01:08:18 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U18IKb041043; Mon, 30 Apr 2012 01:08:18 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204300108.q3U18IKb041043@svn.freebsd.org> From: David Schultz Date: Mon, 30 Apr 2012 01:08:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234825 - head/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 01:08:19 -0000 Author: das Date: Mon Apr 30 01:08:18 2012 New Revision: 234825 URL: http://svn.freebsd.org/changeset/base/234825 Log: Fix a bug in *wscanf's handling of non-wide %s, %c, and %[ conversions. Both the specification and the documentation say the width is interpreted as the max number of wide characters to read, but the implementation was interpreting it as the number of bytes to convert. (See also r105317.) This change has security implications for any applications that depend on the buggy behavior, but the impact in practice is probably nil. Any such application would already be buggy on other platforms that get the semantics right. Also, these conversions are rarely used; %ls, %lc, and %l[ are more appropriate. Modified: head/lib/libc/stdio/vfwscanf.c Modified: head/lib/libc/stdio/vfwscanf.c ============================================================================== --- head/lib/libc/stdio/vfwscanf.c Mon Apr 30 00:54:10 2012 (r234824) +++ head/lib/libc/stdio/vfwscanf.c Mon Apr 30 01:08:18 2012 (r234825) @@ -144,29 +144,16 @@ convert_char(FILE *fp, char * __restrict size_t nconv; wint_t wi; int n; - char mbbuf[MB_LEN_MAX]; n = 0; mbs = initial_mbs; - while (width != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + while (width-- != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) { - __ungetwc(wi, fp, locale); - break; - } - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } n++; } if (n == 0) @@ -199,28 +186,17 @@ convert_ccl(FILE *fp, char * __restrict size_t nconv; wint_t wi; int n; - char mbbuf[MB_LEN_MAX]; n = 0; mbs = initial_mbs; while ((wi = __fgetwc(fp, locale)) != WEOF && - width != 0 && inccl(ccl, wi)) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + width-- != 0 && inccl(ccl, wi)) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) - break; - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } n++; } if (wi != WEOF) @@ -267,28 +243,17 @@ convert_string(FILE *fp, char * __restri size_t nconv; wint_t wi; int nread; - char mbbuf[MB_LEN_MAX]; mbs = initial_mbs; nread = 0; - while ((wi = __fgetwc(fp, locale)) != WEOF && width != 0 && + while ((wi = __fgetwc(fp, locale)) != WEOF && width-- != 0 && !iswspace(wi)) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) - break; - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } nread++; } if (wi != WEOF) From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 01:10:14 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E0AE1065670; Mon, 30 Apr 2012 01:10:14 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0945A8FC08; Mon, 30 Apr 2012 01:10:14 +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 q3U1ADo0041143; Mon, 30 Apr 2012 01:10:13 GMT (envelope-from gad@svn.freebsd.org) Received: (from gad@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U1ADTT041141; Mon, 30 Apr 2012 01:10:13 GMT (envelope-from gad@svn.freebsd.org) Message-Id: <201204300110.q3U1ADTT041141@svn.freebsd.org> From: Garance A Drosehn Date: Mon, 30 Apr 2012 01:10:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234826 - head/usr.sbin/lpr/lpc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 01:10:14 -0000 Author: gad Date: Mon Apr 30 01:10:13 2012 New Revision: 234826 URL: http://svn.freebsd.org/changeset/base/234826 Log: Print out a warning message if a `lpc setstatus' is done when the queue is not 'lpc stop'-ed. In that situation `lpq' will not display the status message to the user, and the operator may think the queue is already stopped when it is not. MFC after: 3 weeks Modified: head/usr.sbin/lpr/lpc/cmds.c Modified: head/usr.sbin/lpr/lpc/cmds.c ============================================================================== --- head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 01:08:18 2012 (r234825) +++ head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 01:10:13 2012 (r234826) @@ -1009,12 +1009,30 @@ setstatus_gi(int argc __unused, char *ar void setstatus_q(struct printer *pp) { + struct stat stbuf; + int not_shown; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); upstat(pp, generic_msg, 1); + + /* + * Warn the user if 'lpq' will not display this new status-message. + * Note that if lock file does not exist, then the queue is enabled + * for both queuing and printing. + */ + not_shown = 1; + if (stat(lf, &stbuf) >= 0) { + if (stbuf.st_mode & LFM_PRINT_DIS) + not_shown = 0; + } + if (not_shown) { + printf("\tnote: This queue currently has printing enabled,\n"); + printf("\t so this -msg will only be shown by 'lpq' if\n"); + printf("\t a job is actively printing on it.\n"); + } } /* From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 06:48:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 134331065670; Mon, 30 Apr 2012 06:48:19 +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 F195A8FC08; Mon, 30 Apr 2012 06:48:18 +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 q3U6mIXa052862; Mon, 30 Apr 2012 06:48:18 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U6mIVu052860; Mon, 30 Apr 2012 06:48:18 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204300648.q3U6mIVu052860@svn.freebsd.org> From: Michael Tuexen Date: Mon, 30 Apr 2012 06:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234827 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 06:48:19 -0000 Author: tuexen Date: Mon Apr 30 06:48:18 2012 New Revision: 234827 URL: http://svn.freebsd.org/changeset/base/234827 Log: MFC r234731: Remove unused structure. Reported by Irene Ruengeler. Modified: stable/9/sys/netinet/sctp_uio.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Mon Apr 30 01:10:13 2012 (r234826) +++ stable/9/sys/netinet/sctp_uio.h Mon Apr 30 06:48:18 2012 (r234827) @@ -608,13 +608,6 @@ struct sctp_getaddresses { struct sockaddr addr[1]; }; -struct sctp_setstrm_timeout { - sctp_assoc_t ssto_assoc_id; - uint32_t ssto_timeout; - uint32_t ssto_streamid_start; - uint32_t ssto_streamid_end; -}; - struct sctp_status { sctp_assoc_t sstat_assoc_id; int32_t sstat_state; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 06:54:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D3F2C1065672; Mon, 30 Apr 2012 06:54:44 +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 BE80F8FC08; Mon, 30 Apr 2012 06:54:44 +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 q3U6sijM053201; Mon, 30 Apr 2012 06:54:44 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U6siQT053199; Mon, 30 Apr 2012 06:54:44 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204300654.q3U6siQT053199@svn.freebsd.org> From: Michael Tuexen Date: Mon, 30 Apr 2012 06:54:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234828 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 06:54:44 -0000 Author: tuexen Date: Mon Apr 30 06:54:44 2012 New Revision: 234828 URL: http://svn.freebsd.org/changeset/base/234828 Log: MFC r234731: Remove unused structure. Reported by Irene Ruengeler. Modified: stable/8/sys/netinet/sctp_uio.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_uio.h ============================================================================== --- stable/8/sys/netinet/sctp_uio.h Mon Apr 30 06:48:18 2012 (r234827) +++ stable/8/sys/netinet/sctp_uio.h Mon Apr 30 06:54:44 2012 (r234828) @@ -608,13 +608,6 @@ struct sctp_getaddresses { struct sockaddr addr[1]; }; -struct sctp_setstrm_timeout { - sctp_assoc_t ssto_assoc_id; - uint32_t ssto_timeout; - uint32_t ssto_streamid_start; - uint32_t ssto_streamid_end; -}; - struct sctp_status { sctp_assoc_t sstat_assoc_id; int32_t sstat_state; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 07:32:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B6FB106566B; Mon, 30 Apr 2012 07:32:40 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 861A68FC08; Mon, 30 Apr 2012 07:32:40 +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 q3U7WeZr054578; Mon, 30 Apr 2012 07:32:40 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U7Wem5054576; Mon, 30 Apr 2012 07:32:40 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201204300732.q3U7Wem5054576@svn.freebsd.org> From: Robert Watson Date: Mon, 30 Apr 2012 07:32:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234829 - head/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 07:32:40 -0000 Author: rwatson Date: Mon Apr 30 07:32:39 2012 New Revision: 234829 URL: http://svn.freebsd.org/changeset/base/234829 Log: The returned file descriptor from pdfork(2) is via fdp, not pidp. Submitted by: Norman Hardy MFC after: 3 days Modified: head/lib/libc/sys/pdfork.2 Modified: head/lib/libc/sys/pdfork.2 ============================================================================== --- head/lib/libc/sys/pdfork.2 Mon Apr 30 06:54:44 2012 (r234828) +++ head/lib/libc/sys/pdfork.2 Mon Apr 30 07:32:39 2012 (r234829) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2009-2010 Robert N. M. Watson +.\" Copyright (c) 2009-2010, 2012 Robert N. M. Watson .\" All rights reserved. .\" .\" This software was developed at the University of Cambridge Computer @@ -57,7 +57,7 @@ a variant of .Xr fork 2 , which, if successful, returns a process descriptor in the integer pointed to by -.Fa pidp . +.Fa fdp . Processes created via .Fn pdfork will not cause From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 08:00:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B795E1065670; Mon, 30 Apr 2012 08:00:52 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A3A328FC15; Mon, 30 Apr 2012 08:00:52 +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 q3U80qFm055531; Mon, 30 Apr 2012 08:00:52 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U80qvd055529; Mon, 30 Apr 2012 08:00:52 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201204300800.q3U80qvd055529@svn.freebsd.org> From: Robert Watson Date: Mon, 30 Apr 2012 08:00:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234830 - head/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:00:52 -0000 Author: rwatson Date: Mon Apr 30 08:00:52 2012 New Revision: 234830 URL: http://svn.freebsd.org/changeset/base/234830 Log: fix a further typo in the pdfork(2) man page. Submitted by: Norman Hardy MFC after: 3 days Modified: head/lib/libc/sys/pdfork.2 Modified: head/lib/libc/sys/pdfork.2 ============================================================================== --- head/lib/libc/sys/pdfork.2 Mon Apr 30 07:32:39 2012 (r234829) +++ head/lib/libc/sys/pdfork.2 Mon Apr 30 08:00:52 2012 (r234830) @@ -76,7 +76,7 @@ This option is not permitted in Capsicum .El .Pp .Fn pdgetpid -queries the process ID (PID) if the process descriptor +queries the process ID (PID) in the process descriptor .Fa fd . .Pp .Fn pdkill From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 08:44:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17DCA106566B; Mon, 30 Apr 2012 08:44:11 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 035488FC0A; Mon, 30 Apr 2012 08:44:11 +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 q3U8iAlh056906; Mon, 30 Apr 2012 08:44:10 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U8iAEj056904; Mon, 30 Apr 2012 08:44:10 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201204300844.q3U8iAEj056904@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 30 Apr 2012 08:44:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234831 - head/sys/dev/cxgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:44:11 -0000 Author: np Date: Mon Apr 30 08:44:10 2012 New Revision: 234831 URL: http://svn.freebsd.org/changeset/base/234831 Log: Make sure that the firmware version is available in dev.t4nex.X.firmware_version even if the driver fails to attach properly. At least it'll be easy to tell what we're dealing with. MFC after: 1 week Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:00:52 2012 (r234830) +++ head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:44:10 2012 (r234831) @@ -1449,6 +1449,11 @@ prep_firmware(struct adapter *sc) /* Check firmware version and install a different one if necessary */ rc = t4_check_fw_version(sc); + snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", + G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), + G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); if (rc != 0) { uint32_t v = 0; @@ -1505,6 +1510,12 @@ prep_firmware(struct adapter *sc) } else { /* refresh */ (void) t4_check_fw_version(sc); + snprintf(sc->fw_version, + sizeof(sc->fw_version), "%u.%u.%u.%u", + G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), + G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); } } } @@ -1548,11 +1559,6 @@ prep_firmware(struct adapter *sc) goto done; /* error message displayed already */ } - snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", - G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), - G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), - G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), - G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); sc->flags |= FW_OK; done: From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 08:44:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CFF810657C1; Mon, 30 Apr 2012 08:44:22 +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 878D18FC15; Mon, 30 Apr 2012 08:44:22 +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 q3U8iMED056948; Mon, 30 Apr 2012 08:44:22 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U8iMQt056945; Mon, 30 Apr 2012 08:44:22 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204300844.q3U8iMQt056945@svn.freebsd.org> From: Michael Tuexen Date: Mon, 30 Apr 2012 08:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234832 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:44:22 -0000 Author: tuexen Date: Mon Apr 30 08:44:21 2012 New Revision: 234832 URL: http://svn.freebsd.org/changeset/base/234832 Log: Add support for missing gauth_number_of_chunks field. This Bug was found by Irene Ruengeler. MFC after: 1 week Modified: head/sys/netinet/sctp_uio.h head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Mon Apr 30 08:44:10 2012 (r234831) +++ head/sys/netinet/sctp_uio.h Mon Apr 30 08:44:21 2012 (r234832) @@ -660,6 +660,7 @@ struct sctp_authkeyid { /* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */ struct sctp_authchunks { sctp_assoc_t gauth_assoc_id; + uint32_t gauth_number_of_chunks; uint8_t gauth_chunks[]; }; Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Mon Apr 30 08:44:10 2012 (r234831) +++ head/sys/netinet/sctp_usrreq.c Mon Apr 30 08:44:21 2012 (r234832) @@ -2879,6 +2879,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); @@ -2897,6 +2898,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_INP_RUNLOCK(inp); @@ -2927,6 +2929,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 08:55:23 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78EBA106564A; Mon, 30 Apr 2012 08:55:23 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC768FC17; Mon, 30 Apr 2012 08:55:23 +0000 (UTC) Received: from v6.mpls.in ([2a02:978:2::5] helo=ws.su29.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1SOmOH-0001ME-QR; Mon, 30 Apr 2012 12:55:29 +0400 Message-ID: <4F9E531B.6020203@FreeBSD.org> Date: Mon, 30 Apr 2012 12:53:47 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120121 Thunderbird/9.0 MIME-Version: 1.0 To: Adrian Chadd References: <201204060653.q366rwLa096182@svn.freebsd.org> <4F7E9413.20602@FreeBSD.org> <4F8BBD4E.1040106@FreeBSD.org> <4F91240C.3050703@ipfw.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, freebsd-net@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r233937 - in head/sys: kern net security/mac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:55:23 -0000 On 28.04.2012 00:42, Adrian Chadd wrote: > Hi Alex, Hello! > > I don't want to be demanding, but would you please consider committing > your fixes? I've asked glebius@ for the review for a while ago, but it seems it is a bit staled.. > > And if you could, would you please do it as a set of commits, one per > 'thing', rather than one big monolithic commit that does half a dozen > different things? That way if there are any further regressions, > I/others could test things out. Ok, I'll try to commit fixes today. > > This is breaking bpf for a few people - ladv causes a crash, wifi also > causes a crash. > > Thanks! > > > Adrian > From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 09:46:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB684106564A; Mon, 30 Apr 2012 09:46:06 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C6338FC08; Mon, 30 Apr 2012 09:46:06 +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 q3U9k61C058805; Mon, 30 Apr 2012 09:46:06 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U9k62T058801; Mon, 30 Apr 2012 09:46:06 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201204300946.q3U9k62T058801@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 30 Apr 2012 09:46:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234833 - in head: share/man/man4 sys/dev/cxgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 09:46:06 -0000 Author: np Date: Mon Apr 30 09:46:05 2012 New Revision: 234833 URL: http://svn.freebsd.org/changeset/base/234833 Log: Change the default to not use packet counters to generate rx interrupts. Rely solely on the timer based mechanism. Update man page to reflect this change. MFC after: 1 week Modified: head/share/man/man4/cxgbe.4 head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c Modified: head/share/man/man4/cxgbe.4 ============================================================================== --- head/share/man/man4/cxgbe.4 Mon Apr 30 08:44:21 2012 (r234832) +++ head/share/man/man4/cxgbe.4 Mon Apr 30 09:46:05 2012 (r234833) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2011, Chelsio Inc +.\" Copyright (c) 2011-2012, Chelsio Inc .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -145,10 +145,9 @@ dev.cxgbe.X.holdoff_tmr_idx sysctl. The packet-count index value to use to delay interrupts. The packet-count list has the values 1, 8, 16, and 32 by default and the index selects a value from this list. -The default value is 2 for both 10Gb and 1Gb ports, which means 16 -packets (or the holdoff timer going off) before an interrupt is -generated. --1 disables packet counting. +The default value is -1 for both 10Gb and 1Gb ports, which means packet +counting is disabled and interrupts are generated based solely on the +holdoff timer value. Different cxgbe interfaces can be assigned different values via the dev.cxgbe.X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:44:21 2012 (r234832) +++ head/sys/dev/cxgbe/t4_main.c Mon Apr 30 09:46:05 2012 (r234833) @@ -174,7 +174,7 @@ TUNABLE_INT("hw.cxgbe.nofldrxq1g", &t4_n static int t4_tmr_idx_10g = TMR_IDX_10G; TUNABLE_INT("hw.cxgbe.holdoff_timer_idx_10G", &t4_tmr_idx_10g); -#define PKTC_IDX_10G 2 +#define PKTC_IDX_10G (-1) static int t4_pktc_idx_10g = PKTC_IDX_10G; TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_10G", &t4_pktc_idx_10g); @@ -182,7 +182,7 @@ TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_1 static int t4_tmr_idx_1g = TMR_IDX_1G; TUNABLE_INT("hw.cxgbe.holdoff_timer_idx_1G", &t4_tmr_idx_1g); -#define PKTC_IDX_1G 2 +#define PKTC_IDX_1G (-1) static int t4_pktc_idx_1g = PKTC_IDX_1G; TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_1G", &t4_pktc_idx_1g); Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Mon Apr 30 08:44:21 2012 (r234832) +++ head/sys/dev/cxgbe/t4_sge.c Mon Apr 30 09:46:05 2012 (r234833) @@ -1420,9 +1420,12 @@ init_iq(struct sge_iq *iq, struct adapte iq->flags = 0; iq->adapter = sc; - iq->intr_params = V_QINTR_TIMER_IDX(tmr_idx) | - V_QINTR_CNT_EN(pktc_idx >= 0); - iq->intr_pktc_idx = pktc_idx; + iq->intr_params = V_QINTR_TIMER_IDX(tmr_idx); + iq->intr_pktc_idx = SGE_NCOUNTERS - 1; + if (pktc_idx >= 0) { + iq->intr_params |= F_QINTR_CNT_EN; + iq->intr_pktc_idx = pktc_idx; + } iq->qsize = roundup(qsize, 16); /* See FW_IQ_CMD/iqsize */ iq->esize = max(esize, 16); /* See FW_IQ_CMD/iqesize */ strlcpy(iq->lockname, name, sizeof(iq->lockname)); From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 10:22:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 122BC106566B; Mon, 30 Apr 2012 10:22:24 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE7BA8FC18; Mon, 30 Apr 2012 10:22:23 +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 q3UAMNbR060056; Mon, 30 Apr 2012 10:22:23 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UAMNcq060049; Mon, 30 Apr 2012 10:22:23 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201204301022.q3UAMNcq060049@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 30 Apr 2012 10:22:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 10:22:24 -0000 Author: melifaro Date: Mon Apr 30 10:22:23 2012 New Revision: 234834 URL: http://svn.freebsd.org/changeset/base/234834 Log: Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. Remove ipfw/ip_fw_private.h header from non-ipfw code. Approved by: ae(mentor) MFC after: 2 weeks Modified: head/sys/contrib/pf/net/pf.c head/sys/net/if_bridge.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_fw.h head/sys/netinet/ipfw/ip_fw_private.h head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Modified: head/sys/contrib/pf/net/pf.c ============================================================================== --- head/sys/contrib/pf/net/pf.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/contrib/pf/net/pf.c Mon Apr 30 10:22:23 2012 (r234834) @@ -122,7 +122,6 @@ __FBSDID("$FreeBSD$"); #include #ifdef __FreeBSD__ #include -#include /* XXX: only for DIR_IN/DIR_OUT */ #endif #ifndef __FreeBSD__ Modified: head/sys/net/if_bridge.c ============================================================================== --- head/sys/net/if_bridge.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/net/if_bridge.c Mon Apr 30 10:22:23 2012 (r234834) @@ -132,7 +132,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include /* * Size of the route hash table. Must be a power of two. Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/net/if_ethersubr.c Mon Apr 30 10:22:23 2012 (r234834) @@ -72,7 +72,6 @@ #include #include #include -#include #endif #ifdef INET6 #include Modified: head/sys/netinet/ip_fw.h ============================================================================== --- head/sys/netinet/ip_fw.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/netinet/ip_fw.h Mon Apr 30 10:22:23 2012 (r234834) @@ -545,6 +545,88 @@ struct ipfw_flow_id { #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) +#ifdef _KERNEL +/* Return values from ipfw_[ether_]chk() */ +enum { + IP_FW_PASS = 0, + IP_FW_DENY, + IP_FW_DIVERT, + IP_FW_TEE, + IP_FW_DUMMYNET, + IP_FW_NETGRAPH, + IP_FW_NGTEE, + IP_FW_NAT, + IP_FW_REASS, +}; + +/* + * Hooks sometime need to know the direction of the packet + * (divert, dummynet, netgraph, ...) + * We use a generic definition here, with bit0-1 indicating the + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the + * specific protocol (if necessary) + */ +enum { + DIR_MASK = 0x3, + DIR_OUT = 0, + DIR_IN = 1, + DIR_FWD = 2, + DIR_DROP = 3, + PROTO_LAYER2 = 0x4, /* set for layer 2 */ + /* PROTO_DEFAULT = 0, */ + PROTO_IPV4 = 0x08, + PROTO_IPV6 = 0x10, + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ + /* PROTO_OLDBDG = 0x14, unused, old bridge */ +}; + +/* + * Structure for collecting parameters to dummynet for ip6_output forwarding + */ +struct _ip6dn_args { + struct ip6_pktopts *opt_or; + struct route_in6 ro_or; + int flags_or; + struct ip6_moptions *im6o_or; + struct ifnet *origifp_or; + struct ifnet *ifp_or; + struct sockaddr_in6 dst_or; + u_long mtu_or; + struct route_in6 ro_pmtu_or; +}; + +/* + * Arguments for calling ipfw_chk() and dummynet_io(). We put them + * all into a structure because this way it is easier and more + * efficient to pass variables around and extend the interface. + */ +struct ip_fw_args { + struct mbuf *m; /* the mbuf chain */ + struct ifnet *oif; /* output interface */ + struct sockaddr_in *next_hop; /* forward address */ + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ + + /* + * On return, it points to the matching rule. + * On entry, rule.slot > 0 means the info is valid and + * contains the starting rule for an ipfw search. + * If chain_id == chain->id && slot >0 then jump to that slot. + * Otherwise, we locate the first rule >= rulenum:rule_id + */ + struct ipfw_rule_ref rule; /* match/restart info */ + + struct ether_header *eh; /* for bridged packets */ + + struct ipfw_flow_id f_id; /* grabbed from IP header */ + //uint32_t cookie; /* a cookie depending on rule action */ + struct inpcb *inp; + + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ +}; + +#endif /* _KERNEL */ + /* * Dynamic ipfw rule. */ Modified: head/sys/netinet/ipfw/ip_fw_private.h ============================================================================== --- head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 10:22:23 2012 (r234834) @@ -48,89 +48,8 @@ #define SYSEND #endif -/* Return values from ipfw_chk() */ -enum { - IP_FW_PASS = 0, - IP_FW_DENY, - IP_FW_DIVERT, - IP_FW_TEE, - IP_FW_DUMMYNET, - IP_FW_NETGRAPH, - IP_FW_NGTEE, - IP_FW_NAT, - IP_FW_REASS, -}; - -/* - * Structure for collecting parameters to dummynet for ip6_output forwarding - */ -struct _ip6dn_args { - struct ip6_pktopts *opt_or; - struct route_in6 ro_or; - int flags_or; - struct ip6_moptions *im6o_or; - struct ifnet *origifp_or; - struct ifnet *ifp_or; - struct sockaddr_in6 dst_or; - u_long mtu_or; - struct route_in6 ro_pmtu_or; -}; - - -/* - * Arguments for calling ipfw_chk() and dummynet_io(). We put them - * all into a structure because this way it is easier and more - * efficient to pass variables around and extend the interface. - */ -struct ip_fw_args { - struct mbuf *m; /* the mbuf chain */ - struct ifnet *oif; /* output interface */ - struct sockaddr_in *next_hop; /* forward address */ - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ - - /* - * On return, it points to the matching rule. - * On entry, rule.slot > 0 means the info is valid and - * contains the starting rule for an ipfw search. - * If chain_id == chain->id && slot >0 then jump to that slot. - * Otherwise, we locate the first rule >= rulenum:rule_id - */ - struct ipfw_rule_ref rule; /* match/restart info */ - - struct ether_header *eh; /* for bridged packets */ - - struct ipfw_flow_id f_id; /* grabbed from IP header */ - //uint32_t cookie; /* a cookie depending on rule action */ - struct inpcb *inp; - - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ -}; - MALLOC_DECLARE(M_IPFW); -/* - * Hooks sometime need to know the direction of the packet - * (divert, dummynet, netgraph, ...) - * We use a generic definition here, with bit0-1 indicating the - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the - * specific protocol - * indicating the protocol (if necessary) - */ -enum { - DIR_MASK = 0x3, - DIR_OUT = 0, - DIR_IN = 1, - DIR_FWD = 2, - DIR_DROP = 3, - PROTO_LAYER2 = 0x4, /* set for layer 2 */ - /* PROTO_DEFAULT = 0, */ - PROTO_IPV4 = 0x08, - PROTO_IPV6 = 0x10, - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ - /* PROTO_OLDBDG = 0x14, unused, old bridge */ -}; - /* wrapper for freeing a packet, in case we need to do more work */ #ifndef FREE_PKT #if defined(__linux__) || defined(_WIN32) Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 10:22:23 2012 (r234834) @@ -68,7 +68,6 @@ #include #include #include -#include #endif #ifdef INET6 #include From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 11:28:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C8D31065670; Mon, 30 Apr 2012 11:28:18 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB4218FC18; Mon, 30 Apr 2012 11:28: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 q3UBSHi5063819; Mon, 30 Apr 2012 11:28:17 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UBSHlb063816; Mon, 30 Apr 2012 11:28:17 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301128.q3UBSHlb063816@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 11:28: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: r234836 - head/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:28:18 -0000 Author: dumbbell Date: Mon Apr 30 11:28:17 2012 New Revision: 234836 URL: http://svn.freebsd.org/changeset/base/234836 Log: Remove incorrect __restrict qualifier on several pointers The typical case was: static __inline int convert_ccl(FILE *fp, char * __restrict p, [...]) { [...] if (p == SUPPRESS_PTR) { [...] } else { [...] } [...] } This qualifier says that the pointer is the only one at that time pointing to the resource. Here, clang considers that "p" will never match "SUPPRESS_PTR" and optimize the if{} block out. This leads to segfaults in programs calling vfscanf(3) and vfwscanf(3) with just the format string (no arguments following it). The following softwares were reported to abort with segmentation fault and this patch fixes it: o cmake o smartd o devel/ORBit2 dim@ opened an LLVM PR to discuss this clang optimization: http://llvm.org/bugs/show_bug.cgi?id=12656 Tested by: bsam@ Modified: head/lib/libc/stdio/vfscanf.c head/lib/libc/stdio/vfwscanf.c Modified: head/lib/libc/stdio/vfscanf.c ============================================================================== --- head/lib/libc/stdio/vfscanf.c Mon Apr 30 11:14:46 2012 (r234835) +++ head/lib/libc/stdio/vfscanf.c Mon Apr 30 11:28:17 2012 (r234836) @@ -125,7 +125,7 @@ static const mbstate_t initial_mbs; */ static __inline int -convert_char(FILE *fp, char * __restrict p, int width) +convert_char(FILE *fp, char * p, int width) { int n; @@ -151,7 +151,7 @@ convert_char(FILE *fp, char * __restrict return (sum); } else { size_t r = __fread(p, 1, width, fp); - + if (r == 0) return (-1); return (r); @@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, in } static __inline int -convert_ccl(FILE *fp, char * __restrict p, int width, const char *ccltab) +convert_ccl(FILE *fp, char * p, int width, const char *ccltab) { char *p0; int n; @@ -249,7 +249,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int } static __inline int -convert_string(FILE *fp, char * __restrict p, int width) +convert_string(FILE *fp, char * p, int width) { char *p0; int n; @@ -387,7 +387,7 @@ parseint(FILE *fp, char * __restrict buf goto ok; } break; - + /* * x ok iff flag still set & 2nd char (or 3rd char if * we have a sign). Modified: head/lib/libc/stdio/vfwscanf.c ============================================================================== --- head/lib/libc/stdio/vfwscanf.c Mon Apr 30 11:14:46 2012 (r234835) +++ head/lib/libc/stdio/vfwscanf.c Mon Apr 30 11:28:17 2012 (r234836) @@ -138,7 +138,7 @@ static const mbstate_t initial_mbs; */ static __inline int -convert_char(FILE *fp, char * __restrict mbp, int width, locale_t locale) +convert_char(FILE *fp, char * mbp, int width, locale_t locale) { mbstate_t mbs; size_t nconv; @@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, in } static __inline int -convert_ccl(FILE *fp, char * __restrict mbp, int width, const struct ccl *ccl, +convert_ccl(FILE *fp, char * mbp, int width, const struct ccl *ccl, locale_t locale) { mbstate_t mbs; @@ -237,7 +237,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int } static __inline int -convert_string(FILE *fp, char * __restrict mbp, int width, locale_t locale) +convert_string(FILE *fp, char * mbp, int width, locale_t locale) { mbstate_t mbs; size_t nconv; @@ -372,7 +372,7 @@ parseint(FILE *fp, wchar_t *buf, int wid goto ok; } break; - + /* * x ok iff flag still set & 2nd char (or 3rd char if * we have a sign). From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 11:28:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72EFA106566C; Mon, 30 Apr 2012 11:28:55 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id C1C0C8FC16; Mon, 30 Apr 2012 11:28:54 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 405727300A; Mon, 30 Apr 2012 13:48:36 +0200 (CEST) Date: Mon, 30 Apr 2012 13:48:36 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" , ae@freebsd.org Message-ID: <20120430114836.GA62284@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201204301022.q3UAMNcq060049@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:28:55 -0000 On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > Author: melifaro > Date: Mon Apr 30 10:22:23 2012 > New Revision: 234834 > URL: http://svn.freebsd.org/changeset/base/234834 > > Log: > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. I would be really grateful if you could revert this back and discuss what you wanted to achieve with this change other than saving one entry in the list of includes. As clearly mentioned in the commit logs http://svnweb.freebsd.org/base?view=revision&revision=200580 when i did the last revision of the ipfw+dummynet code i tried to put a strong separation between what is visible in userland (ip_fw.h and ip_dummynet.h) and kernel specific stuff. This way changes in the kernel code do not need to affect userland, modify installed headers and so on. This is why kernel-specific definitions were put in private files. We may discuss on the filename, ip_fw_kernel.h may be a better fit, but merging back kernel and userland defs is a bad design decision. 20-30 years ago there were good reasons to use a single header for all sorts of definitions: user-only, kernel-only, and kernel-userland API. Machines were slow, disks were small, portability was not a big deal. These days none of these conditions apply and keeping things separate helps maintainance and avoid accidental pollution of definitions and their misuse. Besides, keep in mind that ipfw and dummynet are meant to work on multiple platforms so this change is causing portability troubles. cheers luigi > Approved by: ae(mentor) > MFC after: 2 weeks > > Modified: > head/sys/contrib/pf/net/pf.c > head/sys/net/if_bridge.c > head/sys/net/if_ethersubr.c > head/sys/netinet/ip_fw.h > head/sys/netinet/ipfw/ip_fw_private.h > head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h > > Modified: head/sys/contrib/pf/net/pf.c > ============================================================================== > --- head/sys/contrib/pf/net/pf.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/contrib/pf/net/pf.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -122,7 +122,6 @@ __FBSDID("$FreeBSD$"); > #include > #ifdef __FreeBSD__ > #include > -#include /* XXX: only for DIR_IN/DIR_OUT */ > #endif > > #ifndef __FreeBSD__ > > Modified: head/sys/net/if_bridge.c > ============================================================================== > --- head/sys/net/if_bridge.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/net/if_bridge.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -132,7 +132,6 @@ __FBSDID("$FreeBSD$"); > > #include > #include > -#include > > /* > * Size of the route hash table. Must be a power of two. > > Modified: head/sys/net/if_ethersubr.c > ============================================================================== > --- head/sys/net/if_ethersubr.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/net/if_ethersubr.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -72,7 +72,6 @@ > #include > #include > #include > -#include > #endif > #ifdef INET6 > #include > > Modified: head/sys/netinet/ip_fw.h > ============================================================================== > --- head/sys/netinet/ip_fw.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/netinet/ip_fw.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -545,6 +545,88 @@ struct ipfw_flow_id { > > #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) > > +#ifdef _KERNEL > +/* Return values from ipfw_[ether_]chk() */ > +enum { > + IP_FW_PASS = 0, > + IP_FW_DENY, > + IP_FW_DIVERT, > + IP_FW_TEE, > + IP_FW_DUMMYNET, > + IP_FW_NETGRAPH, > + IP_FW_NGTEE, > + IP_FW_NAT, > + IP_FW_REASS, > +}; > + > +/* > + * Hooks sometime need to know the direction of the packet > + * (divert, dummynet, netgraph, ...) > + * We use a generic definition here, with bit0-1 indicating the > + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the > + * specific protocol (if necessary) > + */ > +enum { > + DIR_MASK = 0x3, > + DIR_OUT = 0, > + DIR_IN = 1, > + DIR_FWD = 2, > + DIR_DROP = 3, > + PROTO_LAYER2 = 0x4, /* set for layer 2 */ > + /* PROTO_DEFAULT = 0, */ > + PROTO_IPV4 = 0x08, > + PROTO_IPV6 = 0x10, > + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ > + /* PROTO_OLDBDG = 0x14, unused, old bridge */ > +}; > + > +/* > + * Structure for collecting parameters to dummynet for ip6_output forwarding > + */ > +struct _ip6dn_args { > + struct ip6_pktopts *opt_or; > + struct route_in6 ro_or; > + int flags_or; > + struct ip6_moptions *im6o_or; > + struct ifnet *origifp_or; > + struct ifnet *ifp_or; > + struct sockaddr_in6 dst_or; > + u_long mtu_or; > + struct route_in6 ro_pmtu_or; > +}; > + > +/* > + * Arguments for calling ipfw_chk() and dummynet_io(). We put them > + * all into a structure because this way it is easier and more > + * efficient to pass variables around and extend the interface. > + */ > +struct ip_fw_args { > + struct mbuf *m; /* the mbuf chain */ > + struct ifnet *oif; /* output interface */ > + struct sockaddr_in *next_hop; /* forward address */ > + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ > + > + /* > + * On return, it points to the matching rule. > + * On entry, rule.slot > 0 means the info is valid and > + * contains the starting rule for an ipfw search. > + * If chain_id == chain->id && slot >0 then jump to that slot. > + * Otherwise, we locate the first rule >= rulenum:rule_id > + */ > + struct ipfw_rule_ref rule; /* match/restart info */ > + > + struct ether_header *eh; /* for bridged packets */ > + > + struct ipfw_flow_id f_id; /* grabbed from IP header */ > + //uint32_t cookie; /* a cookie depending on rule action */ > + struct inpcb *inp; > + > + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ > + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ > +}; > + > +#endif /* _KERNEL */ > + > /* > * Dynamic ipfw rule. > */ > > Modified: head/sys/netinet/ipfw/ip_fw_private.h > ============================================================================== > --- head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -48,89 +48,8 @@ > #define SYSEND > #endif > > -/* Return values from ipfw_chk() */ > -enum { > - IP_FW_PASS = 0, > - IP_FW_DENY, > - IP_FW_DIVERT, > - IP_FW_TEE, > - IP_FW_DUMMYNET, > - IP_FW_NETGRAPH, > - IP_FW_NGTEE, > - IP_FW_NAT, > - IP_FW_REASS, > -}; > - > -/* > - * Structure for collecting parameters to dummynet for ip6_output forwarding > - */ > -struct _ip6dn_args { > - struct ip6_pktopts *opt_or; > - struct route_in6 ro_or; > - int flags_or; > - struct ip6_moptions *im6o_or; > - struct ifnet *origifp_or; > - struct ifnet *ifp_or; > - struct sockaddr_in6 dst_or; > - u_long mtu_or; > - struct route_in6 ro_pmtu_or; > -}; > - > - > -/* > - * Arguments for calling ipfw_chk() and dummynet_io(). We put them > - * all into a structure because this way it is easier and more > - * efficient to pass variables around and extend the interface. > - */ > -struct ip_fw_args { > - struct mbuf *m; /* the mbuf chain */ > - struct ifnet *oif; /* output interface */ > - struct sockaddr_in *next_hop; /* forward address */ > - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ > - > - /* > - * On return, it points to the matching rule. > - * On entry, rule.slot > 0 means the info is valid and > - * contains the starting rule for an ipfw search. > - * If chain_id == chain->id && slot >0 then jump to that slot. > - * Otherwise, we locate the first rule >= rulenum:rule_id > - */ > - struct ipfw_rule_ref rule; /* match/restart info */ > - > - struct ether_header *eh; /* for bridged packets */ > - > - struct ipfw_flow_id f_id; /* grabbed from IP header */ > - //uint32_t cookie; /* a cookie depending on rule action */ > - struct inpcb *inp; > - > - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ > - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ > -}; > - > MALLOC_DECLARE(M_IPFW); > > -/* > - * Hooks sometime need to know the direction of the packet > - * (divert, dummynet, netgraph, ...) > - * We use a generic definition here, with bit0-1 indicating the > - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the > - * specific protocol > - * indicating the protocol (if necessary) > - */ > -enum { > - DIR_MASK = 0x3, > - DIR_OUT = 0, > - DIR_IN = 1, > - DIR_FWD = 2, > - DIR_DROP = 3, > - PROTO_LAYER2 = 0x4, /* set for layer 2 */ > - /* PROTO_DEFAULT = 0, */ > - PROTO_IPV4 = 0x08, > - PROTO_IPV6 = 0x10, > - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ > - /* PROTO_OLDBDG = 0x14, unused, old bridge */ > -}; > - > /* wrapper for freeing a packet, in case we need to do more work */ > #ifndef FREE_PKT > #if defined(__linux__) || defined(_WIN32) > > Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h > ============================================================================== > --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -68,7 +68,6 @@ > #include > #include > #include > -#include > #endif > #ifdef INET6 > #include From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 11:36:18 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 88F05106564A; Mon, 30 Apr 2012 11:36:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id E9F2A8FC14; Mon, 30 Apr 2012 11:36:17 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id q3UBaB42019409; Mon, 30 Apr 2012 15:36:11 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id q3UBaA5C019408; Mon, 30 Apr 2012 15:36:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 30 Apr 2012 15:36:10 +0400 From: Gleb Smirnoff To: Luigi Rizzo Message-ID: <20120430113610.GC18777@FreeBSD.org> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20120430114836.GA62284@onelab2.iet.unipi.it> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, "Alexander V. Chernikov" Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:36:18 -0000 On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: L> > Author: melifaro L> > Date: Mon Apr 30 10:22:23 2012 L> > New Revision: 234834 L> > URL: http://svn.freebsd.org/changeset/base/234834 L> > L> > Log: L> > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. L> L> I would be really grateful if you could revert this back and discuss L> what you wanted to achieve with this change other than saving one L> entry in the list of includes. L> L> As clearly mentioned in the commit logs L> L> http://svnweb.freebsd.org/base?view=revision&revision=200580 L> L> when i did the last revision of the ipfw+dummynet code i tried L> to put a strong separation between what is visible in userland L> (ip_fw.h and ip_dummynet.h) and kernel specific stuff. L> This way changes in the kernel code do not need to affect userland, L> modify installed headers and so on. L> L> This is why kernel-specific definitions were put in private files. L> We may discuss on the filename, ip_fw_kernel.h may be a better fit, L> but merging back kernel and userland defs is a bad design decision. L> L> 20-30 years ago there were good reasons to use a single header L> for all sorts of definitions: user-only, kernel-only, and kernel-userland API. L> Machines were slow, disks were small, portability was not a big deal. L> L> These days none of these conditions apply and keeping things L> separate helps maintainance and avoid accidental pollution of L> definitions and their misuse. L> L> Besides, keep in mind that ipfw and dummynet are meant to work L> on multiple platforms so this change is causing portability troubles. Can we split ip_fw_private.h to ip_fw_private.h, and ip_fw_var.h? The former is really private, and the latter is for other kernel modules. -- Totus tuus, Glebius. From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 12:11:45 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDCD81065673; Mon, 30 Apr 2012 12:11:45 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEF968FC1A; Mon, 30 Apr 2012 12:11: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 q3UCBjnb065201; Mon, 30 Apr 2012 12:11:45 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UCBjna065199; Mon, 30 Apr 2012 12:11:45 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201204301211.q3UCBjna065199@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 30 Apr 2012 12:11: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: r234837 - head/lib/libfetch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:11:46 -0000 Author: des Date: Mon Apr 30 12:11:45 2012 New Revision: 234837 URL: http://svn.freebsd.org/changeset/base/234837 Log: Since the socket is non-blocking, it is necessary to use select(2) even when there is no timeout, because read(2) will return immediately if there is no data waiting in the TCP buffer, causing fetch_read() to busy-loop on slow connections. MFC after: 3 weeks Noticed by: Yanhui Shen Modified: head/lib/libfetch/common.c Modified: head/lib/libfetch/common.c ============================================================================== --- head/lib/libfetch/common.c Mon Apr 30 11:28:17 2012 (r234836) +++ head/lib/libfetch/common.c Mon Apr 30 12:11:45 2012 (r234837) @@ -455,11 +455,9 @@ fetch_read(conn_t *conn, char *buf, size struct timeval now, timeout, delta; fd_set readfds; ssize_t rlen, total; - int r; char *start; - if (fetchTimeout) { - FD_ZERO(&readfds); + if (fetchTimeout > 0) { gettimeofday(&timeout, NULL); timeout.tv_sec += fetchTimeout; } @@ -523,23 +521,21 @@ fetch_read(conn_t *conn, char *buf, size return (-1); } // assert(rlen == FETCH_READ_WAIT); - while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) { + FD_ZERO(&readfds); + while (!FD_ISSET(conn->sd, &readfds)) { FD_SET(conn->sd, &readfds); - gettimeofday(&now, NULL); - delta.tv_sec = timeout.tv_sec - now.tv_sec; - delta.tv_usec = timeout.tv_usec - now.tv_usec; - if (delta.tv_usec < 0) { - delta.tv_usec += 1000000; - delta.tv_sec--; - } - if (delta.tv_sec < 0) { - errno = ETIMEDOUT; - fetch_syserr(); - return (-1); + if (fetchTimeout > 0) { + gettimeofday(&now, NULL); + if (!timercmp(&timeout, &now, >)) { + errno = ETIMEDOUT; + fetch_syserr(); + return (-1); + } + timersub(&timeout, &now, &delta); } errno = 0; - r = select(conn->sd + 1, &readfds, NULL, NULL, &delta); - if (r == -1) { + if (select(conn->sd + 1, &readfds, NULL, NULL, + fetchTimeout > 0 ? &delta : NULL) < 0) { if (errno == EINTR) { if (fetchRestartCalls) continue; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 12:12:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F33A71065675; Mon, 30 Apr 2012 12:12:48 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DEE678FC22; Mon, 30 Apr 2012 12:12:48 +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 q3UCCmuc065272; Mon, 30 Apr 2012 12:12:48 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UCCmXc065270; Mon, 30 Apr 2012 12:12:48 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201204301212.q3UCCmXc065270@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 30 Apr 2012 12:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234838 - head/lib/libfetch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:12:49 -0000 Author: des Date: Mon Apr 30 12:12:48 2012 New Revision: 234838 URL: http://svn.freebsd.org/changeset/base/234838 Log: Don't reuse credentials if redirected to a different host. Submitted by: Niels Heinen MFC after: 3 weeks Modified: head/lib/libfetch/http.c Modified: head/lib/libfetch/http.c ============================================================================== --- head/lib/libfetch/http.c Mon Apr 30 12:11:45 2012 (r234837) +++ head/lib/libfetch/http.c Mon Apr 30 12:12:48 2012 (r234838) @@ -1779,7 +1779,9 @@ http_request(struct url *URL, const char DEBUG(fprintf(stderr, "failed to parse new URL\n")); goto ouch; } - if (!*new->user && !*new->pwd) { + + /* Only copy credentials if the host matches */ + if (!strcmp(new->host, url->host) && !*new->user && !*new->pwd) { strcpy(new->user, url->user); strcpy(new->pwd, url->pwd); } From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 12:19:07 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED7DA106566B; Mon, 30 Apr 2012 12:19:07 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 7EBCA8FC12; Mon, 30 Apr 2012 12:19:07 +0000 (UTC) Received: from v6.mpls.in ([2a02:978:2::5] helo=ws.su29.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1SOpZR-0002ZB-FE; Mon, 30 Apr 2012 16:19:13 +0400 Message-ID: <4F9E82DA.4030406@FreeBSD.org> Date: Mon, 30 Apr 2012 16:17:30 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120121 Thunderbird/9.0 MIME-Version: 1.0 To: Gleb Smirnoff References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> In-Reply-To: <20120430113610.GC18777@FreeBSD.org> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Luigi Rizzo Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:19:08 -0000 On 30.04.2012 15:36, Gleb Smirnoff wrote: > On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: > L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > L> > Author: melifaro > L> > Date: Mon Apr 30 10:22:23 2012 > L> > New Revision: 234834 > L> > URL: http://svn.freebsd.org/changeset/base/234834 > L> > > L> > Log: > L> > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. > L> > L> I would be really grateful if you could revert this back and discuss > L> what you wanted to achieve with this change other than saving one > L> entry in the list of includes. Changing something inside ip_fw_private.h (for example, locking change) requires changes in several totally unrelated subsystems, which is clearly bad. > L> > L> As clearly mentioned in the commit logs > L> > L> http://svnweb.freebsd.org/base?view=revision&revision=200580 Maybe there are some other possibilities documenting preferred layout other than commit log? Searching 2+yrs commit history is not the best way of finding information. > L> > L> when i did the last revision of the ipfw+dummynet code i tried > L> to put a strong separation between what is visible in userland > L> (ip_fw.h and ip_dummynet.h) and kernel specific stuff. > L> This way changes in the kernel code do not need to affect userland, > L> modify installed headers and so on. > L> > L> This is why kernel-specific definitions were put in private files. Unfortunately, it is not so obvious (at least for me "ip_fw_ _private__.h" looks much like "ipfw private headers, used by ipfw subsystem only", not "kernel ipfw specific stuff"). > L> We may discuss on the filename, ip_fw_kernel.h may be a better fit, Personally I prefer glebius@ suggestion with ip_fw_var.h for such common headers. > L> but merging back kernel and userland defs is a bad design decision. So should style(9) be updated with "_KERNEL define is bad" line to make newcomers aware of this "easy" way ? :) > L> > L> 20-30 years ago there were good reasons to use a single header > L> for all sorts of definitions: user-only, kernel-only, and kernel-userland API. > L> Machines were slow, disks were small, portability was not a big deal. > L> > L> These days none of these conditions apply and keeping things > L> separate helps maintainance and avoid accidental pollution of > L> definitions and their misuse. > L> > L> Besides, keep in mind that ipfw and dummynet are meant to work > L> on multiple platforms so this change is causing portability troubles. > > Can we split ip_fw_private.h to ip_fw_private.h, and ip_fw_var.h? The > former is really private, and the latter is for other kernel modules. From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:07:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C66B1065740; Mon, 30 Apr 2012 13:07:22 +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 E115B8FC17; Mon, 30 Apr 2012 13:07: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 q3UD7LNl066976; Mon, 30 Apr 2012 13:07:21 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UD7Lf0066973; Mon, 30 Apr 2012 13:07:21 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301307.q3UD7Lf0066973@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:07:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234839 - in stable/9/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:07:22 -0000 Author: kib Date: Mon Apr 30 13:07:21 2012 New Revision: 234839 URL: http://svn.freebsd.org/changeset/base/234839 Log: MFC r234616: Allow for the process information sysctls to accept a thread id in addition to the process id. Modified: stable/9/sys/kern/kern_proc.c stable/9/sys/sys/proc.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/kern_proc.c ============================================================================== --- stable/9/sys/kern/kern_proc.c Mon Apr 30 12:12:48 2012 (r234838) +++ stable/9/sys/kern/kern_proc.c Mon Apr 30 13:07:21 2012 (r234839) @@ -309,6 +309,30 @@ pfind(pid) return (p); } +static struct proc * +pfind_tid(pid_t tid) +{ + struct proc *p; + struct thread *td; + + sx_slock(&allproc_lock); + FOREACH_PROC_IN_SYSTEM(p) { + PROC_LOCK(p); + if (p->p_state == PRS_NEW) { + PROC_UNLOCK(p); + continue; + } + FOREACH_THREAD_IN_PROC(p, td) { + if (td->td_tid == tid) + goto found; + } + PROC_UNLOCK(p); + } +found: + sx_sunlock(&allproc_lock); + return (p); +} + /* * Locate a process group by number. * The caller must hold proctree_lock. @@ -339,7 +363,12 @@ pget(pid_t pid, int flags, struct proc * struct proc *p; int error; - p = pfind(pid); + if (pid <= PID_MAX) + p = pfind(pid); + else if ((flags & PGET_NOTID) == 0) + p = pfind_tid(pid); + else + p = NULL; if (p == NULL) return (ESRCH); if ((flags & PGET_CANSEE) != 0) { Modified: stable/9/sys/sys/proc.h ============================================================================== --- stable/9/sys/sys/proc.h Mon Apr 30 12:12:48 2012 (r234838) +++ stable/9/sys/sys/proc.h Mon Apr 30 13:07:21 2012 (r234839) @@ -840,6 +840,7 @@ struct proc *zpfind(pid_t); /* Find zom #define PGET_ISCURRENT 0x00008 /* Check that the found process is current. */ #define PGET_NOTWEXIT 0x00010 /* Check that the process is not in P_WEXIT. */ #define PGET_NOTINEXEC 0x00020 /* Check that the process is not in P_INEXEC. */ +#define PGET_NOTID 0x00040 /* Do not assume tid if pid > PID_MAX. */ #define PGET_WANTREAD (PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT) From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:19:17 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E419B106564A; Mon, 30 Apr 2012 13:19:17 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 631B68FC14; Mon, 30 Apr 2012 13:19:17 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id A0D627300A; Mon, 30 Apr 2012 15:39:04 +0200 (CEST) Date: Mon, 30 Apr 2012 15:39:04 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" Message-ID: <20120430133904.GA65792@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F9E82DA.4030406@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:19:18 -0000 On Mon, Apr 30, 2012 at 04:17:30PM +0400, Alexander V. Chernikov wrote: > On 30.04.2012 15:36, Gleb Smirnoff wrote: > >On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: > >L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > >L> > Author: melifaro > >L> > Date: Mon Apr 30 10:22:23 2012 > >L> > New Revision: 234834 > >L> > URL: http://svn.freebsd.org/changeset/base/234834 > >L> > > >L> > Log: > >L> > Move several enums and structures required for L2 filtering from > >ip_fw_private.h to ip_fw.h. > >L> > >L> I would be really grateful if you could revert this back and discuss > >L> what you wanted to achieve with this change other than saving one > >L> entry in the list of includes. > Changing something inside ip_fw_private.h (for example, locking change) > requires changes in several totally unrelated subsystems, which is > clearly bad. There are certainly good reasons to split things even further (as Gleb suggested) so if you want to follow that route and have patches for review i will be glad to discuss that. I am the first one to say that the name ip_fw_private.h is confusing, but at the time i did not feel brave enough to move from a single header (ip_fw.h) to the four (ip_fw.h, ip_fw_user.h, ip_fw_kernel.h, ip_fw_kernel_private.h) that would be needed for proper confinement of information. This said, the change you have made introduce a worse form of header pollution and this is why i am requesting a backout. > >L> > >L> As clearly mentioned in the commit logs > >L> > >L> http://svnweb.freebsd.org/base?view=revision&revision=200580 > Maybe there are some other possibilities documenting preferred layout > other than commit log? Searching 2+yrs commit history is not the best > way of finding information. sure, you could have asked people involved with ipfw development to review this change. Also don't expect a single policy in style(9) to hold for all possible situations: the kernel is huge, it has parts that come from multiple origins in time and space, and sometimes is shared with other OSs as well. Refactoring (such as your changes) should keep that in mind. Let's not make a big deal of this thing: we all make mistakes or have different opinions on how things should be done, and the only way to avoid them is to discuss thing in advance, or be open to resolve things when problems arise. No hard feelings. cheers luigi From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:29:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 270D2106566B; Mon, 30 Apr 2012 13:29:22 +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 111A48FC17; Mon, 30 Apr 2012 13:29:22 +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 q3UDTLBZ067726; Mon, 30 Apr 2012 13:29:21 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDTLH3067723; Mon, 30 Apr 2012 13:29:21 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301329.q3UDTLH3067723@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:29: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: r234840 - head/libexec/rtld-elf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:29:22 -0000 Author: kib Date: Mon Apr 30 13:29:21 2012 New Revision: 234840 URL: http://svn.freebsd.org/changeset/base/234840 Log: Split the symlook_obj1 into a loop iterating over the ELF object symbol hash elements, and a helper matched_symbol() which match the given hash entry and request, performing needed type and version checks. Based on dragonflybsd support for GNU hash by John Marino Reviewed by: kan Tested by: bapt MFC after: 2 weeks Modified: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Apr 30 13:07:21 2012 (r234839) +++ head/libexec/rtld-elf/rtld.c Mon Apr 30 13:29:21 2012 (r234840) @@ -1,7 +1,8 @@ /*- * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra. * Copyright 2003 Alexander Kabaev . - * Copyright 2009, 2010, 2011 Konstantin Belousov . + * Copyright 2009-2012 Konstantin Belousov . + * Copyright 2012 John Marino . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,6 +150,8 @@ static int object_match_name(const Obj_ static void ld_utrace_log(int, void *, void *, size_t, int, const char *); static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info); +static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, + const unsigned long); void r_debug_state(struct r_debug *, struct link_map *) __noinline; @@ -3439,28 +3442,15 @@ symlook_obj(SymLook *req, const Obj_Entr return (mres); } -static int -symlook_obj1(SymLook *req, const Obj_Entry *obj) +/* Symbol match routine common to both hash functions */ +static bool +matched_symbol(SymLook *req, const Obj_Entry *obj, Sym_Match_Result *result, + const unsigned long symnum) { - unsigned long symnum; - const Elf_Sym *vsymp; - Elf_Versym verndx; - int vcount; - - if (obj->buckets == NULL) - return (ESRCH); - - vsymp = NULL; - vcount = 0; - symnum = obj->buckets[req->hash % obj->nbuckets]; - - for (; symnum != STN_UNDEF; symnum = obj->chains[symnum]) { + Elf_Versym verndx; const Elf_Sym *symp; const char *strp; - if (symnum >= obj->nchains) - return (ESRCH); /* Bad object */ - symp = obj->symtab + symnum; strp = obj->strtab + symp->st_name; @@ -3468,103 +3458,128 @@ symlook_obj1(SymLook *req, const Obj_Ent case STT_FUNC: case STT_NOTYPE: case STT_OBJECT: + case STT_COMMON: case STT_GNU_IFUNC: - if (symp->st_value == 0) - continue; + if (symp->st_value == 0) + return (false); /* fallthrough */ case STT_TLS: - if (symp->st_shndx != SHN_UNDEF) - break; + if (symp->st_shndx != SHN_UNDEF) + break; #ifndef __mips__ - else if (((req->flags & SYMLOOK_IN_PLT) == 0) && - (ELF_ST_TYPE(symp->st_info) == STT_FUNC)) - break; + else if (((req->flags & SYMLOOK_IN_PLT) == 0) && + (ELF_ST_TYPE(symp->st_info) == STT_FUNC)) + break; /* fallthrough */ #endif default: - continue; + return (false); } if (req->name[0] != strp[0] || strcmp(req->name, strp) != 0) - continue; + return (false); if (req->ventry == NULL) { - if (obj->versyms != NULL) { - verndx = VER_NDX(obj->versyms[symnum]); - if (verndx > obj->vernum) { - _rtld_error("%s: symbol %s references wrong version %d", - obj->path, obj->strtab + symnum, verndx); - continue; - } - /* - * If we are not called from dlsym (i.e. this is a normal - * relocation from unversioned binary), accept the symbol - * immediately if it happens to have first version after - * this shared object became versioned. Otherwise, if - * symbol is versioned and not hidden, remember it. If it - * is the only symbol with this name exported by the - * shared object, it will be returned as a match at the - * end of the function. If symbol is global (verndx < 2) - * accept it unconditionally. - */ - if ((req->flags & SYMLOOK_DLSYM) == 0 && - verndx == VER_NDX_GIVEN) { - req->sym_out = symp; - req->defobj_out = obj; - return (0); - } - else if (verndx >= VER_NDX_GIVEN) { - if ((obj->versyms[symnum] & VER_NDX_HIDDEN) == 0) { - if (vsymp == NULL) - vsymp = symp; - vcount ++; - } - continue; + if (obj->versyms != NULL) { + verndx = VER_NDX(obj->versyms[symnum]); + if (verndx > obj->vernum) { + _rtld_error( + "%s: symbol %s references wrong version %d", + obj->path, obj->strtab + symnum, verndx); + return (false); + } + /* + * If we are not called from dlsym (i.e. this + * is a normal relocation from unversioned + * binary), accept the symbol immediately if + * it happens to have first version after this + * shared object became versioned. Otherwise, + * if symbol is versioned and not hidden, + * remember it. If it is the only symbol with + * this name exported by the shared object, it + * will be returned as a match by the calling + * function. If symbol is global (verndx < 2) + * accept it unconditionally. + */ + if ((req->flags & SYMLOOK_DLSYM) == 0 && + verndx == VER_NDX_GIVEN) { + result->sym_out = symp; + return (true); + } + else if (verndx >= VER_NDX_GIVEN) { + if ((obj->versyms[symnum] & VER_NDX_HIDDEN) + == 0) { + if (result->vsymp == NULL) + result->vsymp = symp; + result->vcount++; + } + return (false); + } } - } - req->sym_out = symp; - req->defobj_out = obj; - return (0); - } else { - if (obj->versyms == NULL) { + result->sym_out = symp; + return (true); + } + if (obj->versyms == NULL) { if (object_match_name(obj, req->ventry->name)) { - _rtld_error("%s: object %s should provide version %s for " - "symbol %s", obj_rtld.path, obj->path, - req->ventry->name, obj->strtab + symnum); - continue; + _rtld_error("%s: object %s should provide version %s " + "for symbol %s", obj_rtld.path, obj->path, + req->ventry->name, obj->strtab + symnum); + return (false); } - } else { + } else { verndx = VER_NDX(obj->versyms[symnum]); if (verndx > obj->vernum) { - _rtld_error("%s: symbol %s references wrong version %d", - obj->path, obj->strtab + symnum, verndx); - continue; + _rtld_error("%s: symbol %s references wrong version %d", + obj->path, obj->strtab + symnum, verndx); + return (false); } if (obj->vertab[verndx].hash != req->ventry->hash || strcmp(obj->vertab[verndx].name, req->ventry->name)) { - /* - * Version does not match. Look if this is a global symbol - * and if it is not hidden. If global symbol (verndx < 2) - * is available, use it. Do not return symbol if we are - * called by dlvsym, because dlvsym looks for a specific - * version and default one is not what dlvsym wants. - */ - if ((req->flags & SYMLOOK_DLSYM) || - (obj->versyms[symnum] & VER_NDX_HIDDEN) || - (verndx >= VER_NDX_GIVEN)) - continue; + /* + * Version does not match. Look if this is a + * global symbol and if it is not hidden. If + * global symbol (verndx < 2) is available, + * use it. Do not return symbol if we are + * called by dlvsym, because dlvsym looks for + * a specific version and default one is not + * what dlvsym wants. + */ + if ((req->flags & SYMLOOK_DLSYM) || + (verndx >= VER_NDX_GIVEN) || + (obj->versyms[symnum] & VER_NDX_HIDDEN)) + return (false); } - } - req->sym_out = symp; - req->defobj_out = obj; - return (0); } - } - if (vcount == 1) { - req->sym_out = vsymp; - req->defobj_out = obj; - return (0); - } - return (ESRCH); + result->sym_out = symp; + return (true); +} + +static int +symlook_obj1(SymLook *req, const Obj_Entry *obj) +{ + unsigned long symnum; + Sym_Match_Result matchres; + + matchres.sym_out = NULL; + matchres.vsymp = NULL; + matchres.vcount = 0; + + for (symnum = obj->buckets[req->hash % obj->nbuckets]; + symnum != STN_UNDEF; symnum = obj->chains[symnum]) { + if (symnum >= obj->nchains) + return (ESRCH); /* Bad object */ + + if (matched_symbol(req, obj, &matchres, symnum)) { + req->sym_out = matchres.sym_out; + req->defobj_out = obj; + return (0); + } + } + if (matchres.vcount == 1) { + req->sym_out = matchres.vsymp; + req->defobj_out = obj; + return (0); + } + return (ESRCH); } static void Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Mon Apr 30 13:07:21 2012 (r234839) +++ head/libexec/rtld-elf/rtld.h Mon Apr 30 13:29:21 2012 (r234840) @@ -126,6 +126,12 @@ typedef struct Struct_Ver_Entry { const char *file; } Ver_Entry; +typedef struct Struct_Sym_Match_Result { + const Elf_Sym *sym_out; + const Elf_Sym *vsymp; + int vcount; +} Sym_Match_Result; + #define VER_INFO_HIDDEN 0x01 /* From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:31:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7182A1065672; Mon, 30 Apr 2012 13:31:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A3208FC14; Mon, 30 Apr 2012 13:31:11 +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 q3UDVBxp067842; Mon, 30 Apr 2012 13:31:11 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDVBAB067832; Mon, 30 Apr 2012 13:31:11 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301331.q3UDVBAB067832@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:31:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234841 - in head/libexec/rtld-elf: . amd64 arm i386 ia64 powerpc powerpc64 sparc64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:31:11 -0000 Author: kib Date: Mon Apr 30 13:31:10 2012 New Revision: 234841 URL: http://svn.freebsd.org/changeset/base/234841 Log: Add GNU hash support for rtld. Based on dragonflybsd support for GNU hash by John Marino Reviewed by: kan Tested by: bapt MFC after: 2 weeks Modified: head/libexec/rtld-elf/amd64/reloc.c head/libexec/rtld-elf/arm/reloc.c head/libexec/rtld-elf/i386/reloc.c head/libexec/rtld-elf/ia64/reloc.c head/libexec/rtld-elf/powerpc/reloc.c head/libexec/rtld-elf/powerpc64/reloc.c head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h head/libexec/rtld-elf/sparc64/reloc.c Modified: head/libexec/rtld-elf/amd64/reloc.c ============================================================================== --- head/libexec/rtld-elf/amd64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/amd64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -132,7 +132,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/arm/reloc.c ============================================================================== --- head/libexec/rtld-elf/arm/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/arm/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -328,7 +328,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * The dynamic loader may be called from a thread, we have * limited amounts of stack available so we cannot use alloca(). */ - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize); Modified: head/libexec/rtld-elf/i386/reloc.c ============================================================================== --- head/libexec/rtld-elf/i386/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/i386/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -133,7 +133,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/ia64/reloc.c ============================================================================== --- head/libexec/rtld-elf/ia64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/ia64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -104,7 +104,7 @@ alloc_fptrs(Obj_Entry *obj, bool mapped) struct fptr **fptrs; size_t fbytes; - fbytes = obj->nchains * sizeof(struct fptr *); + fbytes = obj->dynsymcount * sizeof(struct fptr *); /* * Avoid malloc, if requested. Happens when relocating @@ -138,7 +138,7 @@ free_fptrs(Obj_Entry *obj, bool mapped) if (fptrs == NULL) return; - fbytes = obj->nchains * sizeof(struct fptr *); + fbytes = obj->dynsymcount * sizeof(struct fptr *); if (mapped) munmap(fptrs, fbytes); else @@ -348,7 +348,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Elf_Rela *relalim; const Elf_Rela *rela; SymCache *cache; - int bytes = obj->nchains * sizeof(SymCache); + int bytes = obj->dynsymcount * sizeof(SymCache); int r = -1; /* Modified: head/libexec/rtld-elf/powerpc/reloc.c ============================================================================== --- head/libexec/rtld-elf/powerpc/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/powerpc/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -299,7 +299,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/powerpc64/reloc.c ============================================================================== --- head/libexec/rtld-elf/powerpc64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/powerpc64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -287,7 +287,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Elf_Rela *relalim; const Elf_Rela *rela; SymCache *cache; - int bytes = obj->nchains * sizeof(SymCache); + int bytes = obj->dynsymcount * sizeof(SymCache); int r = -1; /* Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/rtld.c Mon Apr 30 13:31:10 2012 (r234841) @@ -133,7 +133,8 @@ static int symlook_global(SymLook *, Don static void symlook_init_from_req(SymLook *, const SymLook *); static int symlook_list(SymLook *, const Objlist *, DoneList *); static int symlook_needed(SymLook *, const Needed_Entry *, DoneList *); -static int symlook_obj1(SymLook *, const Obj_Entry *); +static int symlook_obj1_sysv(SymLook *, const Obj_Entry *); +static int symlook_obj1_gnu(SymLook *, const Obj_Entry *); static void trace_loaded_objects(Obj_Entry *); static void unlink_object(Obj_Entry *); static void unload_object(Obj_Entry *); @@ -150,6 +151,7 @@ static int object_match_name(const Obj_ static void ld_utrace_log(int, void *, void *, size_t, int, const char *); static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info); +static uint32_t gnu_hash(const char *); static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, const unsigned long); @@ -488,6 +490,9 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_ } digest_dynamic(obj_main, 0); + dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", + obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu, + obj_main->dynsymcount); linkmap_add(obj_main); linkmap_add(&obj_rtld); @@ -825,6 +830,11 @@ digest_dynamic1(Obj_Entry *obj, int earl Needed_Entry **needed_tail = &obj->needed; Needed_Entry **needed_filtees_tail = &obj->needed_filtees; Needed_Entry **needed_aux_filtees_tail = &obj->needed_aux_filtees; + const Elf_Hashelt *hashtab; + const Elf32_Word *hashval; + Elf32_Word bkt, nmaskwords; + int bloom_size32; + bool nmw_power2; int plttype = DT_REL; *dyn_rpath = NULL; @@ -914,12 +924,35 @@ digest_dynamic1(Obj_Entry *obj, int earl case DT_HASH: { - const Elf_Hashelt *hashtab = (const Elf_Hashelt *) - (obj->relocbase + dynp->d_un.d_ptr); + hashtab = (const Elf_Hashelt *)(obj->relocbase + + dynp->d_un.d_ptr); obj->nbuckets = hashtab[0]; obj->nchains = hashtab[1]; obj->buckets = hashtab + 2; obj->chains = obj->buckets + obj->nbuckets; + obj->valid_hash_sysv = obj->nbuckets > 0 && obj->nchains > 0 && + obj->buckets != NULL; + } + break; + + case DT_GNU_HASH: + { + hashtab = (const Elf_Hashelt *)(obj->relocbase + + dynp->d_un.d_ptr); + obj->nbuckets_gnu = hashtab[0]; + obj->symndx_gnu = hashtab[1]; + nmaskwords = hashtab[2]; + bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords; + /* Number of bitmask words is required to be power of 2 */ + nmw_power2 = ((nmaskwords & (nmaskwords - 1)) == 0); + obj->maskwords_bm_gnu = nmaskwords - 1; + obj->shift2_gnu = hashtab[3]; + obj->bloom_gnu = (Elf_Addr *) (hashtab + 4); + obj->buckets_gnu = hashtab + 4 + bloom_size32; + obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu - + obj->symndx_gnu; + obj->valid_hash_gnu = nmw_power2 && obj->nbuckets_gnu > 0 && + obj->buckets_gnu != NULL; } break; @@ -1096,6 +1129,22 @@ digest_dynamic1(Obj_Entry *obj, int earl obj->pltrelasize = obj->pltrelsize; obj->pltrelsize = 0; } + + /* Determine size of dynsym table (equal to nchains of sysv hash) */ + if (obj->valid_hash_sysv) + obj->dynsymcount = obj->nchains; + else if (obj->valid_hash_gnu) { + obj->dynsymcount = 0; + for (bkt = 0; bkt < obj->nbuckets_gnu; bkt++) { + if (obj->buckets_gnu[bkt] == 0) + continue; + hashval = &obj->chain_zero_gnu[obj->buckets_gnu[bkt]]; + do + obj->dynsymcount++; + while ((*hashval++ & 1u) == 0); + } + obj->dynsymcount += obj->symndx_gnu; + } } static void @@ -1312,6 +1361,22 @@ elf_hash(const char *name) } /* + * The GNU hash function is the Daniel J. Bernstein hash clipped to 32 bits + * unsigned in case it's implemented with a wider type. + */ +static uint32_t +gnu_hash(const char *s) +{ + uint32_t h; + unsigned char c; + + h = 5381; + for (c = *s; c != '\0'; c = *++s) + h = h * 33 + c; + return (h & 0xffffffff); +} + +/* * Find the library with the given name, and return its full pathname. * The returned string is dynamically allocated. Generates an error * message and returns NULL if the library cannot be found. @@ -1387,7 +1452,7 @@ find_symdef(unsigned long symnum, const * If we have already found this symbol, get the information from * the cache. */ - if (symnum >= refobj->nchains) + if (symnum >= refobj->dynsymcount) return NULL; /* Bad object */ if (cache != NULL && cache[symnum].sym != NULL) { *defobj_out = cache[symnum].obj; @@ -1885,6 +1950,8 @@ do_load_object(int fd, const char *name, object_add_name(obj, name); obj->path = path; digest_dynamic(obj, 0); + dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", obj->path, + obj->valid_hash_sysv, obj->valid_hash_gnu, obj->dynsymcount); if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) == RTLD_LO_DLOPEN) { dbg("refusing to load non-loadable \"%s\"", obj->path); @@ -2168,8 +2235,8 @@ relocate_objects(Obj_Entry *first, bool if (obj != rtldobj) dbg("relocating \"%s\"", obj->path); - if (obj->nbuckets == 0 || obj->nchains == 0 || obj->buckets == NULL || - obj->symtab == NULL || obj->strtab == NULL) { + if (obj->symtab == NULL || obj->strtab == NULL || + !(obj->valid_hash_sysv || obj->valid_hash_gnu)) { _rtld_error("%s: Shared object has no run-time symbol table", obj->path); return -1; @@ -2841,7 +2908,7 @@ dladdr(const void *addr, Dl_info *info) * Walk the symbol list looking for the symbol whose address is * closest to the address sent in. */ - for (symoffset = 0; symoffset < obj->nchains; symoffset++) { + for (symoffset = 0; symoffset < obj->dynsymcount; symoffset++) { def = obj->symtab + symoffset; /* @@ -3412,7 +3479,15 @@ symlook_obj(SymLook *req, const Obj_Entr SymLook req1; int flags, res, mres; - mres = symlook_obj1(req, obj); + /* + * There is at least one valid hash at this point, and we prefer to use + * the faster GNU version if available. + */ + if (obj->valid_hash_gnu) + mres = symlook_obj1_gnu(req, obj); + else + mres = symlook_obj1_sysv(req, obj); + if (mres == 0) { if (obj->needed_filtees != NULL) { flags = (req->flags & SYMLOOK_EARLY) ? RTLD_LO_EARLY : 0; @@ -3553,8 +3628,13 @@ matched_symbol(SymLook *req, const Obj_E return (true); } +/* + * Search for symbol using SysV hash function. + * obj->buckets is known not to be NULL at this point; the test for this was + * performed with the obj->valid_hash_sysv assignment. + */ static int -symlook_obj1(SymLook *req, const Obj_Entry *obj) +symlook_obj1_sysv(SymLook *req, const Obj_Entry *obj) { unsigned long symnum; Sym_Match_Result matchres; @@ -3582,6 +3662,56 @@ symlook_obj1(SymLook *req, const Obj_Ent return (ESRCH); } +/* Search for symbol using GNU hash function */ +static int +symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj) +{ + Elf_Addr bloom_word; + const Elf32_Word *hashval; + Elf32_Word bucket; + Sym_Match_Result matchres; + unsigned int h1, h2; + unsigned long symnum; + + matchres.sym_out = NULL; + matchres.vsymp = NULL; + matchres.vcount = 0; + + /* Pick right bitmask word from Bloom filter array */ + bloom_word = obj->bloom_gnu[(req->hash_gnu / __ELF_WORD_SIZE) & + obj->maskwords_bm_gnu]; + + /* Calculate modulus word size of gnu hash and its derivative */ + h1 = req->hash_gnu & (__ELF_WORD_SIZE - 1); + h2 = ((req->hash_gnu >> obj->shift2_gnu) & (__ELF_WORD_SIZE - 1)); + + /* Filter out the "definitely not in set" queries */ + if (((bloom_word >> h1) & (bloom_word >> h2) & 1) == 0) + return (ESRCH); + + /* Locate hash chain and corresponding value element*/ + bucket = obj->buckets_gnu[req->hash_gnu % obj->nbuckets_gnu]; + if (bucket == 0) + return (ESRCH); + hashval = &obj->chain_zero_gnu[bucket]; + do { + if (((*hashval ^ req->hash_gnu) >> 1) == 0) { + symnum = hashval - obj->chain_zero_gnu; + if (matched_symbol(req, obj, &matchres, symnum)) { + req->sym_out = matchres.sym_out; + req->defobj_out = obj; + return (0); + } + } + } while ((*hashval++ & 1) == 0); + if (matchres.vcount == 1) { + req->sym_out = matchres.vsymp; + req->defobj_out = obj; + return (0); + } + return (ESRCH); +} + static void trace_loaded_objects(Obj_Entry *obj) { @@ -4365,6 +4495,7 @@ symlook_init(SymLook *dst, const char *n bzero(dst, sizeof(*dst)); dst->name = name; dst->hash = elf_hash(name); + dst->hash_gnu = gnu_hash(name); } static void @@ -4373,6 +4504,7 @@ symlook_init_from_req(SymLook *dst, cons dst->name = src->name; dst->hash = src->hash; + dst->hash_gnu = src->hash_gnu; dst->ventry = src->ventry; dst->flags = src->flags; dst->defobj_out = NULL; Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/rtld.h Mon Apr 30 13:31:10 2012 (r234841) @@ -210,7 +210,16 @@ typedef struct Struct_Obj_Entry { const Elf_Hashelt *buckets; /* Hash table buckets array */ unsigned long nbuckets; /* Number of buckets */ const Elf_Hashelt *chains; /* Hash table chain array */ - unsigned long nchains; /* Number of chains */ + unsigned long nchains; /* Number of entries in chain array */ + + Elf32_Word nbuckets_gnu; /* Number of GNU hash buckets*/ + Elf32_Word symndx_gnu; /* 1st accessible symbol on dynsym table */ + Elf32_Word maskwords_bm_gnu; /* Bloom filter words - 1 (bitmask) */ + Elf32_Word shift2_gnu; /* Bloom filter shift count */ + Elf32_Word dynsymcount; /* Total entries in dynsym table */ + Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */ + const Elf_Hashelt *buckets_gnu; /* GNU hash table bucket array */ + const Elf_Hashelt *chain_zero_gnu; /* GNU hash table value array (Zeroed) */ char *rpath; /* Search path specified in object */ Needed_Entry *needed; /* Shared objects needed by this one (%) */ @@ -257,6 +266,8 @@ typedef struct Struct_Obj_Entry { bool irelative : 1; /* Object has R_MACHDEP_IRELATIVE relocs */ bool gnu_ifunc : 1; /* Object has references to STT_GNU_IFUNC */ bool crt_no_init : 1; /* Object' crt does not call _init/_fini */ + bool valid_hash_sysv : 1; /* A valid System V hash hash tag is available */ + bool valid_hash_gnu : 1; /* A valid GNU hash tag is available */ struct link_map linkmap; /* For GDB and dlinfo() */ Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ @@ -316,6 +327,7 @@ struct Struct_RtldLockState { typedef struct Struct_SymLook { const char *name; unsigned long hash; + uint32_t hash_gnu; const Ver_Entry *ventry; int flags; const Obj_Entry *defobj_out; Modified: head/libexec/rtld-elf/sparc64/reloc.c ============================================================================== --- head/libexec/rtld-elf/sparc64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/sparc64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -305,7 +305,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:34:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 01921106566B; Mon, 30 Apr 2012 13:34:16 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D58B08FC08; Mon, 30 Apr 2012 13:34: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 q3UDYFft067983; Mon, 30 Apr 2012 13:34:15 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDYFtS067981; Mon, 30 Apr 2012 13:34:15 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301334.q3UDYFtS067981@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 13:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234842 - stable/9/lib/libpam/modules/pam_exec X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:34:16 -0000 Author: dumbbell Date: Mon Apr 30 13:34:15 2012 New Revision: 234842 URL: http://svn.freebsd.org/changeset/base/234842 Log: MFC r233507: Use program exit status as pam_exec return code (optional) pam_exec(8) now accepts a new option "return_prog_exit_status". When set, the program exit status is used as the pam_exec return code. It allows the program to tell why the step failed (eg. user unknown). However, if it exits with a code not allowed by the calling PAM service module function (see $PAM_SM_FUNC below), a warning is logged and PAM_SERVICE_ERR is returned. The following changes are related to this new feature but they apply no matter if the "return_prog_exit_status" option is set or not. The environment passed to the program is extended: o $PAM_SM_FUNC contains the name of the PAM service module function (eg. pam_sm_authenticate). o All valid PAM return codes' numerical values are available through variables named after the return code name. For instance, $PAM_SUCCESS, $PAM_USER_UNKNOWN or $PAM_PERM_DENIED. pam_exec return code better reflects what went on: o If the program exits with !0, the return code is now PAM_PERM_DENIED, not PAM_SYSTEM_ERR. o If the program fails because of a signal (WIFSIGNALED) or doesn't terminate normally (!WIFEXITED), the return code is now PAM_SERVICE_ERR, not PAM_SYSTEM_ERR. o If a syscall in pam_exec fails, the return code remains PAM_SYSTEM_ERR. waitpid(2) is called in a loop. If it returns because of EINTR, do it again. Before, it would return PAM_SYSTEM_ERR without waiting for the child to exit. Several log messages now include the PAM service module function name. The man page is updated accordingly. Reviewed by: des@ Sponsored by: Yakaz (http://www.yakaz.com) MFC r234184: Fix error messages containing the executed command name Before, we took the first argument to pam_exec(8). With the addition of options in front of the command, this could be wrong. Now, options are parsed before calling _pam_exec() and messages contain the proper command name. While here, fix a warning. Sponsored by: Yakaz (http://www.yakaz.com) Modified: stable/9/lib/libpam/modules/pam_exec/pam_exec.8 stable/9/lib/libpam/modules/pam_exec/pam_exec.c Directory Properties: stable/9/lib/libpam/ (props changed) Modified: stable/9/lib/libpam/modules/pam_exec/pam_exec.8 ============================================================================== --- stable/9/lib/libpam/modules/pam_exec/pam_exec.8 Mon Apr 30 13:31:10 2012 (r234841) +++ stable/9/lib/libpam/modules/pam_exec/pam_exec.8 Mon Apr 30 13:34:15 2012 (r234842) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2005 +.Dd February 8, 2012 .Dt PAM_EXEC 8 .Os .Sh NAME @@ -45,9 +45,25 @@ .Pa pam_exec .Op Ar arguments .Sh DESCRIPTION -The exec service module for PAM executes the program designated by its -first argument, with its remaining arguments as command-line -arguments. +The exec service module for PAM executes the program designated by +its first argument if no options are specified, with its remaining +arguments as command-line arguments. +If options are specified, the program and its arguments follow the last +option or +.Cm -- +if the program name conflicts with an option name. +.Pp +The following options may be passed before the program and its +arguments: +.Bl -tag -width ".Cm return_prog_exit_status" +.It Cm return_prog_exit_status +Use the program exit status as the return code of the pam_sm_* function. +It must be a valid return value for this function. +.It Cm -- +Stop options parsing; +program and its arguments follow. +.El +.Pp The child's environment is set to the current PAM environment list, as returned by .Xr pam_getenvlist 3 . @@ -56,13 +72,69 @@ variables: .Ev PAM_RHOST , .Ev PAM_RUSER , .Ev PAM_SERVICE , -.Ev PAM_TTY , +.Ev PAM_SM_FUNC , +.Ev PAM_TTY and .Ev PAM_USER . +.Pp +The +.Ev PAM_SM_FUNC +variable contains the name of the PAM service module function being +called. +It may be: +.Bl -dash -offset indent -compact +.It +pam_sm_acct_mgmt +.It +pam_sm_authenticate +.It +pam_sm_chauthtok +.It +pam_sm_close_session +.It +pam_sm_open_session +.It +pam_sm_setcred +.El +.Pp +If +.Cm return_prog_exit_status +is not set (default), the +.Ev PAM_SM_FUNC +function returns +.Er PAM_SUCCESS +if the program exit status is 0, +.Er PAM_PERM_DENIED +otherwise. +.Pp +If +.Cm return_prog_exit_status +is set, the program exit status is used. +It should be +.Er PAM_SUCCESS +or one of the error codes allowed by the calling +.Ev PAM_SM_FUNC +function. +The valid codes are documented in each function man page. +If the exit status is not a valid return code, +.Er PAM_SERVICE_ERR +is returned. +Each valid codes numerical value is available as an environment variable +(eg.\& +.Ev PAM_SUCESS , +.Ev PAM_USER_UNKNOWN , +etc). +This is useful in shell scripts for instance. .Sh SEE ALSO .Xr pam_get_item 3 , .Xr pam.conf 5 , -.Xr pam 8 +.Xr pam 8 , +.Xr pam_sm_acct_mgmt 8 , +.Xr pam_sm_authenticate 8 , +.Xr pam_sm_chauthtok 8, +.Xr pam_sm_close_session 8 , +.Xr pam_sm_open_session 8 , +.Xr pam_sm_setcred 8 . .Sh AUTHORS The .Nm Modified: stable/9/lib/libpam/modules/pam_exec/pam_exec.c ============================================================================== --- stable/9/lib/libpam/modules/pam_exec/pam_exec.c Mon Apr 30 13:31:10 2012 (r234841) +++ stable/9/lib/libpam/modules/pam_exec/pam_exec.c Mon Apr 30 13:34:15 2012 (r234842) @@ -60,32 +60,86 @@ static struct { ENV_ITEM(PAM_RUSER), }; +struct pe_opts { + int return_prog_exit_status; +}; + +#define PAM_RV_COUNT 24 + static int -_pam_exec(pam_handle_t *pamh __unused, int flags __unused, - int argc, const char *argv[]) +parse_options(const char *func, int *argc, const char **argv[], + struct pe_opts *options) +{ + int i; + + /* + * Parse options: + * return_prog_exit_status: + * use the program exit status as the return code of pam_exec + * --: + * stop options parsing; what follows is the command to execute + */ + options->return_prog_exit_status = 0; + + for (i = 0; i < *argc; ++i) { + if (strcmp((*argv)[i], "return_prog_exit_status") == 0) { + openpam_log(PAM_LOG_DEBUG, + "%s: Option \"return_prog_exit_status\" enabled", + func); + options->return_prog_exit_status = 1; + } else { + if (strcmp((*argv)[i], "--") == 0) { + (*argc)--; + (*argv)++; + } + + break; + } + } + + (*argc) -= i; + (*argv) += i; + + return (0); +} + +static int +_pam_exec(pam_handle_t *pamh __unused, + const char *func, int flags __unused, int argc, const char *argv[], + struct pe_opts *options) { int envlen, i, nitems, pam_err, status; - char *env, **envlist, **tmp; + int nitems_rv; + char **envlist, **tmp, *envstr; volatile int childerr; pid_t pid; - if (argc < 1) - return (PAM_SERVICE_ERR); - /* * XXX For additional credit, divert child's stdin/stdout/stderr * to the conversation function. */ + /* Check there's a program name left after parsing options. */ + if (argc < 1) { + openpam_log(PAM_LOG_ERROR, "%s: No program specified: aborting", + func); + return (PAM_SERVICE_ERR); + } + /* - * Set up the child's environment list. It consists of the PAM - * environment, plus a few hand-picked PAM items. + * Set up the child's environment list. It consists of the PAM + * environment, plus a few hand-picked PAM items, the pam_sm_* + * function name calling it and, if return_prog_exit_status is + * set, the valid return codes numerical values. */ envlist = pam_getenvlist(pamh); for (envlen = 0; envlist[envlen] != NULL; ++envlen) /* nothing */ ; nitems = sizeof(env_items) / sizeof(*env_items); - tmp = realloc(envlist, (envlen + nitems + 1) * sizeof(*envlist)); + /* Count PAM return values put in the environment. */ + nitems_rv = options->return_prog_exit_status ? PAM_RV_COUNT : 0; + tmp = realloc(envlist, (envlen + nitems + 1 + nitems_rv + 1) * + sizeof(*envlist)); if (tmp == NULL) { openpam_free_envlist(envlist); return (PAM_BUF_ERR); @@ -93,12 +147,12 @@ _pam_exec(pam_handle_t *pamh __unused, i envlist = tmp; for (i = 0; i < nitems; ++i) { const void *item; - char *envstr; pam_err = pam_get_item(pamh, env_items[i].item, &item); if (pam_err != PAM_SUCCESS || item == NULL) continue; - asprintf(&envstr, "%s=%s", env_items[i].name, item); + asprintf(&envstr, "%s=%s", env_items[i].name, + (const char *)item); if (envstr == NULL) { openpam_free_envlist(envlist); return (PAM_BUF_ERR); @@ -107,10 +161,59 @@ _pam_exec(pam_handle_t *pamh __unused, i envlist[envlen] = NULL; } + /* Add the pam_sm_* function name to the environment. */ + asprintf(&envstr, "PAM_SM_FUNC=%s", func); + if (envstr == NULL) { + openpam_free_envlist(envlist); + return (PAM_BUF_ERR); + } + envlist[envlen++] = envstr; + + /* Add the PAM return values to the environment. */ + if (options->return_prog_exit_status) { +#define ADD_PAM_RV_TO_ENV(name) \ + asprintf(&envstr, #name "=%d", name); \ + if (envstr == NULL) { \ + openpam_free_envlist(envlist); \ + return (PAM_BUF_ERR); \ + } \ + envlist[envlen++] = envstr + /* + * CAUTION: When adding/removing an item in the list + * below, be sure to update the value of PAM_RV_COUNT. + */ + ADD_PAM_RV_TO_ENV(PAM_ABORT); + ADD_PAM_RV_TO_ENV(PAM_ACCT_EXPIRED); + ADD_PAM_RV_TO_ENV(PAM_AUTHINFO_UNAVAIL); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_DISABLE_AGING); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_ERR); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_LOCK_BUSY); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_RECOVERY_ERR); + ADD_PAM_RV_TO_ENV(PAM_AUTH_ERR); + ADD_PAM_RV_TO_ENV(PAM_BUF_ERR); + ADD_PAM_RV_TO_ENV(PAM_CONV_ERR); + ADD_PAM_RV_TO_ENV(PAM_CRED_ERR); + ADD_PAM_RV_TO_ENV(PAM_CRED_EXPIRED); + ADD_PAM_RV_TO_ENV(PAM_CRED_INSUFFICIENT); + ADD_PAM_RV_TO_ENV(PAM_CRED_UNAVAIL); + ADD_PAM_RV_TO_ENV(PAM_IGNORE); + ADD_PAM_RV_TO_ENV(PAM_MAXTRIES); + ADD_PAM_RV_TO_ENV(PAM_NEW_AUTHTOK_REQD); + ADD_PAM_RV_TO_ENV(PAM_PERM_DENIED); + ADD_PAM_RV_TO_ENV(PAM_SERVICE_ERR); + ADD_PAM_RV_TO_ENV(PAM_SESSION_ERR); + ADD_PAM_RV_TO_ENV(PAM_SUCCESS); + ADD_PAM_RV_TO_ENV(PAM_SYSTEM_ERR); + ADD_PAM_RV_TO_ENV(PAM_TRY_AGAIN); + ADD_PAM_RV_TO_ENV(PAM_USER_UNKNOWN); + } + + envlist[envlen] = NULL; + /* * Fork and run the command. By using vfork() instead of fork(), * we can distinguish between an execve() failure and a non-zero - * exit code from the command. + * exit status from the command. */ childerr = 0; if ((pid = vfork()) == 0) { @@ -120,81 +223,276 @@ _pam_exec(pam_handle_t *pamh __unused, i } openpam_free_envlist(envlist); if (pid == -1) { - openpam_log(PAM_LOG_ERROR, "vfork(): %m"); + openpam_log(PAM_LOG_ERROR, "%s: vfork(): %m", func); return (PAM_SYSTEM_ERR); } - if (waitpid(pid, &status, 0) == -1) { - openpam_log(PAM_LOG_ERROR, "waitpid(): %m"); + while (waitpid(pid, &status, 0) == -1) { + if (errno == EINTR) + continue; + openpam_log(PAM_LOG_ERROR, "%s: waitpid(): %m", func); return (PAM_SYSTEM_ERR); } if (childerr != 0) { - openpam_log(PAM_LOG_ERROR, "execve(): %m"); + openpam_log(PAM_LOG_ERROR, "%s: execve(): %m", func); return (PAM_SYSTEM_ERR); } if (WIFSIGNALED(status)) { - openpam_log(PAM_LOG_ERROR, "%s caught signal %d%s", - argv[0], WTERMSIG(status), + openpam_log(PAM_LOG_ERROR, "%s: %s caught signal %d%s", + func, argv[0], WTERMSIG(status), WCOREDUMP(status) ? " (core dumped)" : ""); - return (PAM_SYSTEM_ERR); + return (PAM_SERVICE_ERR); } if (!WIFEXITED(status)) { - openpam_log(PAM_LOG_ERROR, "unknown status 0x%x", status); - return (PAM_SYSTEM_ERR); + openpam_log(PAM_LOG_ERROR, "%s: unknown status 0x%x", + func, status); + return (PAM_SERVICE_ERR); } - if (WEXITSTATUS(status) != 0) { - openpam_log(PAM_LOG_ERROR, "%s returned code %d", - argv[0], WEXITSTATUS(status)); - return (PAM_SYSTEM_ERR); + + if (options->return_prog_exit_status) { + openpam_log(PAM_LOG_DEBUG, + "%s: Use program exit status as return value: %d", + func, WEXITSTATUS(status)); + return (WEXITSTATUS(status)); + } else { + return (WEXITSTATUS(status) == 0 ? + PAM_SUCCESS : PAM_PERM_DENIED); } - return (PAM_SUCCESS); } PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); - return (_pam_exec(pamh, flags, argc, argv)); + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_AUTHINFO_UNAVAIL: + case PAM_AUTH_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_CRED_INSUFFICIENT: + case PAM_IGNORE: + case PAM_MAXTRIES: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_CRED_ERR: + case PAM_CRED_EXPIRED: + case PAM_CRED_UNAVAIL: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_ACCT_EXPIRED: + case PAM_AUTH_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_NEW_AUTHTOK_REQD: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); - return (_pam_exec(pamh, flags, argc, argv)); + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SESSION_ERR: + case PAM_SYSTEM_ERR: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; - return (_pam_exec(pamh, flags, argc, argv)); + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SESSION_ERR: + case PAM_SYSTEM_ERR: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_AUTHTOK_DISABLE_AGING: + case PAM_AUTHTOK_ERR: + case PAM_AUTHTOK_LOCK_BUSY: + case PAM_AUTHTOK_RECOVERY_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_TRY_AGAIN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_MODULE_ENTRY("pam_exec"); From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:37:08 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 428B8106566C; Mon, 30 Apr 2012 13:37:08 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A2658FC15; Mon, 30 Apr 2012 13:37:08 +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 q3UDb85Z068114; Mon, 30 Apr 2012 13:37:08 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDb81V068111; Mon, 30 Apr 2012 13:37:08 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301337.q3UDb81V068111@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 13:37:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234843 - stable/8/lib/libpam/modules/pam_exec X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:37:08 -0000 Author: dumbbell Date: Mon Apr 30 13:37:07 2012 New Revision: 234843 URL: http://svn.freebsd.org/changeset/base/234843 Log: MFC r233507: Use program exit status as pam_exec return code (optional) pam_exec(8) now accepts a new option "return_prog_exit_status". When set, the program exit status is used as the pam_exec return code. It allows the program to tell why the step failed (eg. user unknown). However, if it exits with a code not allowed by the calling PAM service module function (see $PAM_SM_FUNC below), a warning is logged and PAM_SERVICE_ERR is returned. The following changes are related to this new feature but they apply no matter if the "return_prog_exit_status" option is set or not. The environment passed to the program is extended: o $PAM_SM_FUNC contains the name of the PAM service module function (eg. pam_sm_authenticate). o All valid PAM return codes' numerical values are available through variables named after the return code name. For instance, $PAM_SUCCESS, $PAM_USER_UNKNOWN or $PAM_PERM_DENIED. pam_exec return code better reflects what went on: o If the program exits with !0, the return code is now PAM_PERM_DENIED, not PAM_SYSTEM_ERR. o If the program fails because of a signal (WIFSIGNALED) or doesn't terminate normally (!WIFEXITED), the return code is now PAM_SERVICE_ERR, not PAM_SYSTEM_ERR. o If a syscall in pam_exec fails, the return code remains PAM_SYSTEM_ERR. waitpid(2) is called in a loop. If it returns because of EINTR, do it again. Before, it would return PAM_SYSTEM_ERR without waiting for the child to exit. Several log messages now include the PAM service module function name. The man page is updated accordingly. Reviewed by: des@ Sponsored by: Yakaz (http://www.yakaz.com) MFC r234184: Fix error messages containing the executed command name Before, we took the first argument to pam_exec(8). With the addition of options in front of the command, this could be wrong. Now, options are parsed before calling _pam_exec() and messages contain the proper command name. While here, fix a warning. Modified: stable/8/lib/libpam/modules/pam_exec/pam_exec.8 stable/8/lib/libpam/modules/pam_exec/pam_exec.c Directory Properties: stable/8/lib/libpam/ (props changed) Modified: stable/8/lib/libpam/modules/pam_exec/pam_exec.8 ============================================================================== --- stable/8/lib/libpam/modules/pam_exec/pam_exec.8 Mon Apr 30 13:34:15 2012 (r234842) +++ stable/8/lib/libpam/modules/pam_exec/pam_exec.8 Mon Apr 30 13:37:07 2012 (r234843) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2005 +.Dd February 8, 2012 .Dt PAM_EXEC 8 .Os .Sh NAME @@ -45,9 +45,25 @@ .Pa pam_exec .Op Ar arguments .Sh DESCRIPTION -The exec service module for PAM executes the program designated by its -first argument, with its remaining arguments as command-line -arguments. +The exec service module for PAM executes the program designated by +its first argument if no options are specified, with its remaining +arguments as command-line arguments. +If options are specified, the program and its arguments follow the last +option or +.Cm -- +if the program name conflicts with an option name. +.Pp +The following options may be passed before the program and its +arguments: +.Bl -tag -width ".Cm return_prog_exit_status" +.It Cm return_prog_exit_status +Use the program exit status as the return code of the pam_sm_* function. +It must be a valid return value for this function. +.It Cm -- +Stop options parsing; +program and its arguments follow. +.El +.Pp The child's environment is set to the current PAM environment list, as returned by .Xr pam_getenvlist 3 . @@ -56,13 +72,69 @@ variables: .Ev PAM_RHOST , .Ev PAM_RUSER , .Ev PAM_SERVICE , -.Ev PAM_TTY , +.Ev PAM_SM_FUNC , +.Ev PAM_TTY and .Ev PAM_USER . +.Pp +The +.Ev PAM_SM_FUNC +variable contains the name of the PAM service module function being +called. +It may be: +.Bl -dash -offset indent -compact +.It +pam_sm_acct_mgmt +.It +pam_sm_authenticate +.It +pam_sm_chauthtok +.It +pam_sm_close_session +.It +pam_sm_open_session +.It +pam_sm_setcred +.El +.Pp +If +.Cm return_prog_exit_status +is not set (default), the +.Ev PAM_SM_FUNC +function returns +.Er PAM_SUCCESS +if the program exit status is 0, +.Er PAM_PERM_DENIED +otherwise. +.Pp +If +.Cm return_prog_exit_status +is set, the program exit status is used. +It should be +.Er PAM_SUCCESS +or one of the error codes allowed by the calling +.Ev PAM_SM_FUNC +function. +The valid codes are documented in each function man page. +If the exit status is not a valid return code, +.Er PAM_SERVICE_ERR +is returned. +Each valid codes numerical value is available as an environment variable +(eg.\& +.Ev PAM_SUCESS , +.Ev PAM_USER_UNKNOWN , +etc). +This is useful in shell scripts for instance. .Sh SEE ALSO .Xr pam_get_item 3 , .Xr pam.conf 5 , -.Xr pam 8 +.Xr pam 8 , +.Xr pam_sm_acct_mgmt 8 , +.Xr pam_sm_authenticate 8 , +.Xr pam_sm_chauthtok 8, +.Xr pam_sm_close_session 8 , +.Xr pam_sm_open_session 8 , +.Xr pam_sm_setcred 8 . .Sh AUTHORS The .Nm Modified: stable/8/lib/libpam/modules/pam_exec/pam_exec.c ============================================================================== --- stable/8/lib/libpam/modules/pam_exec/pam_exec.c Mon Apr 30 13:34:15 2012 (r234842) +++ stable/8/lib/libpam/modules/pam_exec/pam_exec.c Mon Apr 30 13:37:07 2012 (r234843) @@ -60,32 +60,86 @@ static struct { ENV_ITEM(PAM_RUSER), }; +struct pe_opts { + int return_prog_exit_status; +}; + +#define PAM_RV_COUNT 24 + static int -_pam_exec(pam_handle_t *pamh __unused, int flags __unused, - int argc, const char *argv[]) +parse_options(const char *func, int *argc, const char **argv[], + struct pe_opts *options) +{ + int i; + + /* + * Parse options: + * return_prog_exit_status: + * use the program exit status as the return code of pam_exec + * --: + * stop options parsing; what follows is the command to execute + */ + options->return_prog_exit_status = 0; + + for (i = 0; i < *argc; ++i) { + if (strcmp((*argv)[i], "return_prog_exit_status") == 0) { + openpam_log(PAM_LOG_DEBUG, + "%s: Option \"return_prog_exit_status\" enabled", + func); + options->return_prog_exit_status = 1; + } else { + if (strcmp((*argv)[i], "--") == 0) { + (*argc)--; + (*argv)++; + } + + break; + } + } + + (*argc) -= i; + (*argv) += i; + + return (0); +} + +static int +_pam_exec(pam_handle_t *pamh __unused, + const char *func, int flags __unused, int argc, const char *argv[], + struct pe_opts *options) { int envlen, i, nitems, pam_err, status; - char *env, **envlist, **tmp; + int nitems_rv; + char **envlist, **tmp, *envstr; volatile int childerr; pid_t pid; - if (argc < 1) - return (PAM_SERVICE_ERR); - /* * XXX For additional credit, divert child's stdin/stdout/stderr * to the conversation function. */ + /* Check there's a program name left after parsing options. */ + if (argc < 1) { + openpam_log(PAM_LOG_ERROR, "%s: No program specified: aborting", + func); + return (PAM_SERVICE_ERR); + } + /* - * Set up the child's environment list. It consists of the PAM - * environment, plus a few hand-picked PAM items. + * Set up the child's environment list. It consists of the PAM + * environment, plus a few hand-picked PAM items, the pam_sm_* + * function name calling it and, if return_prog_exit_status is + * set, the valid return codes numerical values. */ envlist = pam_getenvlist(pamh); for (envlen = 0; envlist[envlen] != NULL; ++envlen) /* nothing */ ; nitems = sizeof(env_items) / sizeof(*env_items); - tmp = realloc(envlist, (envlen + nitems + 1) * sizeof(*envlist)); + /* Count PAM return values put in the environment. */ + nitems_rv = options->return_prog_exit_status ? PAM_RV_COUNT : 0; + tmp = realloc(envlist, (envlen + nitems + 1 + nitems_rv + 1) * + sizeof(*envlist)); if (tmp == NULL) { openpam_free_envlist(envlist); return (PAM_BUF_ERR); @@ -93,12 +147,12 @@ _pam_exec(pam_handle_t *pamh __unused, i envlist = tmp; for (i = 0; i < nitems; ++i) { const void *item; - char *envstr; pam_err = pam_get_item(pamh, env_items[i].item, &item); if (pam_err != PAM_SUCCESS || item == NULL) continue; - asprintf(&envstr, "%s=%s", env_items[i].name, item); + asprintf(&envstr, "%s=%s", env_items[i].name, + (const char *)item); if (envstr == NULL) { openpam_free_envlist(envlist); return (PAM_BUF_ERR); @@ -107,10 +161,59 @@ _pam_exec(pam_handle_t *pamh __unused, i envlist[envlen] = NULL; } + /* Add the pam_sm_* function name to the environment. */ + asprintf(&envstr, "PAM_SM_FUNC=%s", func); + if (envstr == NULL) { + openpam_free_envlist(envlist); + return (PAM_BUF_ERR); + } + envlist[envlen++] = envstr; + + /* Add the PAM return values to the environment. */ + if (options->return_prog_exit_status) { +#define ADD_PAM_RV_TO_ENV(name) \ + asprintf(&envstr, #name "=%d", name); \ + if (envstr == NULL) { \ + openpam_free_envlist(envlist); \ + return (PAM_BUF_ERR); \ + } \ + envlist[envlen++] = envstr + /* + * CAUTION: When adding/removing an item in the list + * below, be sure to update the value of PAM_RV_COUNT. + */ + ADD_PAM_RV_TO_ENV(PAM_ABORT); + ADD_PAM_RV_TO_ENV(PAM_ACCT_EXPIRED); + ADD_PAM_RV_TO_ENV(PAM_AUTHINFO_UNAVAIL); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_DISABLE_AGING); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_ERR); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_LOCK_BUSY); + ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_RECOVERY_ERR); + ADD_PAM_RV_TO_ENV(PAM_AUTH_ERR); + ADD_PAM_RV_TO_ENV(PAM_BUF_ERR); + ADD_PAM_RV_TO_ENV(PAM_CONV_ERR); + ADD_PAM_RV_TO_ENV(PAM_CRED_ERR); + ADD_PAM_RV_TO_ENV(PAM_CRED_EXPIRED); + ADD_PAM_RV_TO_ENV(PAM_CRED_INSUFFICIENT); + ADD_PAM_RV_TO_ENV(PAM_CRED_UNAVAIL); + ADD_PAM_RV_TO_ENV(PAM_IGNORE); + ADD_PAM_RV_TO_ENV(PAM_MAXTRIES); + ADD_PAM_RV_TO_ENV(PAM_NEW_AUTHTOK_REQD); + ADD_PAM_RV_TO_ENV(PAM_PERM_DENIED); + ADD_PAM_RV_TO_ENV(PAM_SERVICE_ERR); + ADD_PAM_RV_TO_ENV(PAM_SESSION_ERR); + ADD_PAM_RV_TO_ENV(PAM_SUCCESS); + ADD_PAM_RV_TO_ENV(PAM_SYSTEM_ERR); + ADD_PAM_RV_TO_ENV(PAM_TRY_AGAIN); + ADD_PAM_RV_TO_ENV(PAM_USER_UNKNOWN); + } + + envlist[envlen] = NULL; + /* * Fork and run the command. By using vfork() instead of fork(), * we can distinguish between an execve() failure and a non-zero - * exit code from the command. + * exit status from the command. */ childerr = 0; if ((pid = vfork()) == 0) { @@ -120,81 +223,276 @@ _pam_exec(pam_handle_t *pamh __unused, i } openpam_free_envlist(envlist); if (pid == -1) { - openpam_log(PAM_LOG_ERROR, "vfork(): %m"); + openpam_log(PAM_LOG_ERROR, "%s: vfork(): %m", func); return (PAM_SYSTEM_ERR); } - if (waitpid(pid, &status, 0) == -1) { - openpam_log(PAM_LOG_ERROR, "waitpid(): %m"); + while (waitpid(pid, &status, 0) == -1) { + if (errno == EINTR) + continue; + openpam_log(PAM_LOG_ERROR, "%s: waitpid(): %m", func); return (PAM_SYSTEM_ERR); } if (childerr != 0) { - openpam_log(PAM_LOG_ERROR, "execve(): %m"); + openpam_log(PAM_LOG_ERROR, "%s: execve(): %m", func); return (PAM_SYSTEM_ERR); } if (WIFSIGNALED(status)) { - openpam_log(PAM_LOG_ERROR, "%s caught signal %d%s", - argv[0], WTERMSIG(status), + openpam_log(PAM_LOG_ERROR, "%s: %s caught signal %d%s", + func, argv[0], WTERMSIG(status), WCOREDUMP(status) ? " (core dumped)" : ""); - return (PAM_SYSTEM_ERR); + return (PAM_SERVICE_ERR); } if (!WIFEXITED(status)) { - openpam_log(PAM_LOG_ERROR, "unknown status 0x%x", status); - return (PAM_SYSTEM_ERR); + openpam_log(PAM_LOG_ERROR, "%s: unknown status 0x%x", + func, status); + return (PAM_SERVICE_ERR); } - if (WEXITSTATUS(status) != 0) { - openpam_log(PAM_LOG_ERROR, "%s returned code %d", - argv[0], WEXITSTATUS(status)); - return (PAM_SYSTEM_ERR); + + if (options->return_prog_exit_status) { + openpam_log(PAM_LOG_DEBUG, + "%s: Use program exit status as return value: %d", + func, WEXITSTATUS(status)); + return (WEXITSTATUS(status)); + } else { + return (WEXITSTATUS(status) == 0 ? + PAM_SUCCESS : PAM_PERM_DENIED); } - return (PAM_SUCCESS); } PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); - return (_pam_exec(pamh, flags, argc, argv)); + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_AUTHINFO_UNAVAIL: + case PAM_AUTH_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_CRED_INSUFFICIENT: + case PAM_IGNORE: + case PAM_MAXTRIES: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_CRED_ERR: + case PAM_CRED_EXPIRED: + case PAM_CRED_UNAVAIL: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_ACCT_EXPIRED: + case PAM_AUTH_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_NEW_AUTHTOK_REQD: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_USER_UNKNOWN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); - return (_pam_exec(pamh, flags, argc, argv)); + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SESSION_ERR: + case PAM_SYSTEM_ERR: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; - return (_pam_exec(pamh, flags, argc, argv)); + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SESSION_ERR: + case PAM_SYSTEM_ERR: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } + + return (ret); } PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int ret; + struct pe_opts options; + + ret = parse_options(__func__, &argc, &argv, &options); + if (ret != 0) + return (PAM_SERVICE_ERR); + + ret = _pam_exec(pamh, __func__, flags, argc, argv, &options); + + /* + * We must check that the program returned a valid code for this + * function. + */ + switch (ret) { + case PAM_SUCCESS: + case PAM_ABORT: + case PAM_AUTHTOK_DISABLE_AGING: + case PAM_AUTHTOK_ERR: + case PAM_AUTHTOK_LOCK_BUSY: + case PAM_AUTHTOK_RECOVERY_ERR: + case PAM_BUF_ERR: + case PAM_CONV_ERR: + case PAM_IGNORE: + case PAM_PERM_DENIED: + case PAM_SERVICE_ERR: + case PAM_SYSTEM_ERR: + case PAM_TRY_AGAIN: + break; + default: + openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d", + argv[0], ret); + ret = PAM_SERVICE_ERR; + } - return (_pam_exec(pamh, flags, argc, argv)); + return (ret); } PAM_MODULE_ENTRY("pam_exec"); From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 13:44:04 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C2FA11065672; Mon, 30 Apr 2012 13:44:04 +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 938328FC16; Mon, 30 Apr 2012 13:44: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 q3UDi44X068395; Mon, 30 Apr 2012 13:44:04 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDi4Sx068392; Mon, 30 Apr 2012 13:44:04 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301344.q3UDi4Sx068392@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:44:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234844 - in stable/8/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:44:04 -0000 Author: kib Date: Mon Apr 30 13:44:04 2012 New Revision: 234844 URL: http://svn.freebsd.org/changeset/base/234844 Log: MFC r234616: Allow for the process information sysctls to accept a thread id in addition to the process id. Modified: stable/8/sys/kern/kern_proc.c stable/8/sys/sys/proc.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/kern/kern_proc.c ============================================================================== --- stable/8/sys/kern/kern_proc.c Mon Apr 30 13:37:07 2012 (r234843) +++ stable/8/sys/kern/kern_proc.c Mon Apr 30 13:44:04 2012 (r234844) @@ -301,6 +301,30 @@ pfind(pid) return (p); } +static struct proc * +pfind_tid(pid_t tid) +{ + struct proc *p; + struct thread *td; + + sx_slock(&allproc_lock); + FOREACH_PROC_IN_SYSTEM(p) { + PROC_LOCK(p); + if (p->p_state == PRS_NEW) { + PROC_UNLOCK(p); + continue; + } + FOREACH_THREAD_IN_PROC(p, td) { + if (td->td_tid == tid) + goto found; + } + PROC_UNLOCK(p); + } +found: + sx_sunlock(&allproc_lock); + return (p); +} + /* * Locate a process group by number. * The caller must hold proctree_lock. @@ -331,7 +355,12 @@ pget(pid_t pid, int flags, struct proc * struct proc *p; int error; - p = pfind(pid); + if (pid <= PID_MAX) + p = pfind(pid); + else if ((flags & PGET_NOTID) == 0) + p = pfind_tid(pid); + else + p = NULL; if (p == NULL) return (ESRCH); if ((flags & PGET_CANSEE) != 0) { Modified: stable/8/sys/sys/proc.h ============================================================================== --- stable/8/sys/sys/proc.h Mon Apr 30 13:37:07 2012 (r234843) +++ stable/8/sys/sys/proc.h Mon Apr 30 13:44:04 2012 (r234844) @@ -816,6 +816,7 @@ struct proc *zpfind(pid_t); /* Find zom #define PGET_ISCURRENT 0x00008 /* Check that the found process is current. */ #define PGET_NOTWEXIT 0x00010 /* Check that the process is not in P_WEXIT. */ #define PGET_NOTINEXEC 0x00020 /* Check that the process is not in P_INEXEC. */ +#define PGET_NOTID 0x00040 /* Do not assume tid if pid > PID_MAX. */ #define PGET_WANTREAD (PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT) From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 15:46:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB313106564A; Mon, 30 Apr 2012 15:46:42 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7BF1D8FC14; Mon, 30 Apr 2012 15:46:42 +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 q3UFkgVY072433; Mon, 30 Apr 2012 15:46:42 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UFkgVP072431; Mon, 30 Apr 2012 15:46:42 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301546.q3UFkgVP072431@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 15:46:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234845 - stable/9/sys/gnu/fs/reiserfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 15:46:42 -0000 Author: dumbbell Date: Mon Apr 30 15:46:41 2012 New Revision: 234845 URL: http://svn.freebsd.org/changeset/base/234845 Log: MFC r233575: Make ReiserFS MPSAFE Most functions seemed to be already fine w.r.t. what's done in msdosfs. Modified: stable/9/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/gnu/fs/reiserfs/reiserfs_vfsops.c ============================================================================== --- stable/9/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Mon Apr 30 13:44:04 2012 (r234844) +++ stable/9/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Mon Apr 30 15:46:41 2012 (r234845) @@ -231,6 +231,7 @@ reiserfs_unmount(struct mount *mp, int m g_topology_unlock(); PICKUP_GIANT(); vrele(rmp->rm_devvp); + dev_rel(rmp->rm_dev); if (sbi) { reiserfs_log(LOG_DEBUG, "free sbi\n"); @@ -430,21 +431,25 @@ reiserfs_mountfs(struct vnode *devvp, st struct reiserfs_mount *rmp; struct reiserfs_sb_info *sbi; struct reiserfs_super_block *rs; - struct cdev *dev = devvp->v_rdev; + struct cdev *dev; struct g_consumer *cp; struct bufobj *bo; //ronly = (mp->mnt_flag & MNT_RDONLY) != 0; + dev = devvp->v_rdev; + dev_ref(dev); DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "reiserfs", /* read-only */ 0); g_topology_unlock(); PICKUP_GIANT(); VOP_UNLOCK(devvp, 0); - if (error) + if (error) { + dev_rel(dev); return (error); + } bo = &devvp->v_bufobj; bo->bo_private = cp; @@ -575,6 +580,7 @@ reiserfs_mountfs(struct vnode *devvp, st mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_MPSAFE; MNT_IUNLOCK(mp); #if defined(si_mountpoint) devvp->v_rdev->si_mountpoint = mp; @@ -590,7 +596,8 @@ out: for (i = 0; i < SB_BMAP_NR(sbi); i++) { if (!SB_AP_BITMAP(sbi)[i].bp_data) break; - free(SB_AP_BITMAP(sbi)[i].bp_data, M_REISERFSMNT); + free(SB_AP_BITMAP(sbi)[i].bp_data, + M_REISERFSMNT); } free(SB_AP_BITMAP(sbi), M_REISERFSMNT); } @@ -613,6 +620,7 @@ out: free(sbi, M_REISERFSMNT); if (rmp) free(rmp, M_REISERFSMNT); + dev_rel(dev); return (error); } From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 16:08:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8A945106566B; Mon, 30 Apr 2012 16:08:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C2CD8FC15; Mon, 30 Apr 2012 16:08:03 +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 q3UG83hO073345; Mon, 30 Apr 2012 16:08:03 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UG83YP073341; Mon, 30 Apr 2012 16:08:03 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201204301608.q3UG83YP073341@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 30 Apr 2012 16:08:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234846 - head/sbin/growfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 16:08:03 -0000 Author: trasz Date: Mon Apr 30 16:08:02 2012 New Revision: 234846 URL: http://svn.freebsd.org/changeset/base/234846 Log: Improve growfs(8) in a few ways; unfortunately, it's somewhat hard to untangle them and commit separately. 1. Rewrite the way growfs(8) finds the device and mount point. This makes it possible to use e.g. "growfs /mnt"; it's also used to display more helpful messages. 2. Be more user-friendly, using descriptive messages, like this: OK to grow filesystem on /dev/md0, mounted on /mnt, from 9.8GB to 20GB? [Yes/No]" 3. Allow to specify the size (-s option) just like with mdconfig(8), i.e. with postfixes ("mdconfig -s 10g"). 4. Reload read-only filesystem after growing. Reviewed by: kib, mckusick (earlier version) Sponsored by: The FreeBSD Foundation Modified: head/sbin/growfs/Makefile head/sbin/growfs/growfs.8 head/sbin/growfs/growfs.c Modified: head/sbin/growfs/Makefile ============================================================================== --- head/sbin/growfs/Makefile Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/Makefile Mon Apr 30 16:08:02 2012 (r234846) @@ -6,12 +6,18 @@ #GFSDBG= +.PATH: ${.CURDIR}/../mount + PROG= growfs -SRCS= growfs.c +SRCS= growfs.c getmntopts.c MAN= growfs.8 +CFLAGS+=-I${.CURDIR}/../mount .if defined(GFSDBG) SRCS+= debug.c .endif +DPADD= ${LIBUTIL} +LDADD= -lutil + .include Modified: head/sbin/growfs/growfs.8 ============================================================================== --- head/sbin/growfs/growfs.8 Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/growfs.8 Mon Apr 30 16:08:02 2012 (r234846) @@ -37,7 +37,7 @@ .\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ .\" $FreeBSD$ .\" -.Dd June 29, 2011 +.Dd April 30, 2012 .Dt GROWFS 8 .Os .Sh NAME @@ -47,41 +47,20 @@ .Nm .Op Fl Ny .Op Fl s Ar size -.Ar special +.Ar special | filesystem .Sh DESCRIPTION The .Nm -utility extends the -.Xr newfs 8 -program. -Before starting -.Nm -the disk must be labeled to a bigger size using -.Xr bsdlabel 8 . -If you wish to grow a file system beyond the boundary of -the slice it resides in, you must re-size the slice using -.Xr gpart 8 -before running -.Nm . +utility makes it possible to expand an UFS file system. +Before running +.Nm +the partition or slice containing the file system must be extended using +.Xr gpart 8 . If you are using volumes you must enlarge them by using .Xr gvinum 8 . The .Nm utility extends the size of the file system on the specified special file. -Currently -.Nm -can only enlarge unmounted file systems. -Do not try enlarging a mounted file system, your system may panic and you will -not be able to use the file system any longer. -Most of the -.Xr newfs 8 -options cannot be changed by -.Nm . -In fact, you can only increase the size of the file system. -Use -.Xr tunefs 8 -for other changes. -.Pp The following options are available: .Bl -tag -width indent .It Fl N @@ -103,6 +82,13 @@ So use this option with great care! Determines the .Ar size of the file system after enlarging in sectors. +.Ar Size +is the number of 512 byte sectors unless suffixed with a +.Cm b , k , m , g , +or +.Cm t +which +denotes byte, kilobyte, megabyte, gigabyte and terabyte respectively. This value defaults to the size of the raw partition specified in .Ar special (in other words, @@ -110,19 +96,18 @@ This value defaults to the size of the r will enlarge the file system to the size of the entire partition). .El .Sh EXAMPLES -.Dl growfs -s 4194304 /dev/vinum/testvol +.Dl growfs -s 2G /dev/ada0p1 .Pp will enlarge -.Pa /dev/vinum/testvol +.Pa /dev/ada0p1 up to 2GB if there is enough space in -.Pa /dev/vinum/testvol . +.Pa /dev/ada0p1 . .Sh SEE ALSO -.Xr bsdlabel 8 , .Xr dumpfs 8 , .Xr ffsinfo 8 , .Xr fsck 8 , +.Xr fsdb 8 , .Xr gpart 8 , -.Xr gvinum 8 , .Xr newfs 8 , .Xr tunefs 8 .Sh HISTORY @@ -134,61 +119,12 @@ utility first appeared in .An Christoph Herrmann Aq chm@FreeBSD.org .An Thomas-Henning von Kamptz Aq tomsoft@FreeBSD.org .An The GROWFS team Aq growfs@Tomsoft.COM +.An Edward Tomasz Napierala Aq trasz@FreeBSD.org .Sh BUGS -The -.Nm -utility works starting with -.Fx -3.x. -There may be cases on -.Fx -3.x only, when -.Nm -does not recognize properly whether or not the file system is mounted and -exits with an error message. -Then please use -.Nm -.Fl y -if you are sure that the file system is not mounted. -It is also recommended to always use -.Xr fsck 8 -after enlarging (just to be on the safe side). -.Pp -For enlarging beyond certain limits, it is essential to have some free blocks -available in the first cylinder group. -If that space is not available in the first cylinder group, a critical data -structure has to be relocated into one of the new available cylinder groups. -On -.Fx -3.x this will cause problems with -.Xr fsck 8 -afterwards. -So -.Xr fsck 8 -needs to be patched if you want to use -.Nm -for -.Fx -3.x. -This patch is already integrated in -.Fx -starting with -.Fx 4.4 . -To avoid an unexpected relocation of that structure it is possible to use -.Nm ffsinfo -.Fl g Ar 0 -.Fl l Ar 4 -on the first cylinder group to verify that -.Em nbfree -in the CYLINDER SUMMARY (internal cs) of the CYLINDER GROUP -.Em cgr0 -has enough blocks. -As a rule of thumb for default file system parameters one block is needed for -every 2 GB of total file system size. .Pp Normally .Nm -writes this critical structure to disk and reads it again later for doing more +writes cylinder group summary to disk and reads it again later for doing more updates. This read operation will provide unexpected data when using .Fl N . Modified: head/sbin/growfs/growfs.c ============================================================================== --- head/sbin/growfs/growfs.c Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/growfs.c Mon Apr 30 16:08:02 2012 (r234846) @@ -1,11 +1,15 @@ /* - * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. + * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * * This code is derived from software contributed to Berkeley by * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. * + * Portions of this software were developed by Edward Tomasz Napierala + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -53,13 +57,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include #include #include +#include +#include #include +#include #include #include #include @@ -67,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "debug.h" @@ -109,7 +119,7 @@ static void updjcg(int, time_t, int, int static void updcsloc(time_t, int, int, unsigned int); static void frag_adjust(ufs2_daddr_t, int); static void updclst(int); -static void get_dev_size(int, int *); +static void mount_reload(const struct statfs *stfs); /* * Here we actually start growing the file system. We basically read the @@ -177,6 +187,7 @@ growfs(int fsi, int fso, unsigned int Nf /* * Dump out summary information about file system. */ +#ifdef FS_DEBUG #define B2MBFACTOR (1 / (1024.0 * 1024.0)) printf("growfs: %.1fMB (%jd sectors) block size %d, fragment size %d\n", (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, @@ -188,6 +199,7 @@ growfs(int fsi, int fso, unsigned int Nf if (sblock.fs_flags & FS_DOSOFTDEP) printf("\twith soft updates\n"); #undef B2MBFACTOR +#endif /* FS_DEBUG */ /* * Now build the cylinders group blocks and @@ -774,7 +786,7 @@ updjcg(int cylno, time_t modtime, int fs /* * Here we update the location of the cylinder summary. We have two possible - * ways of growing the cylinder summary. + * ways of growing the cylinder summary: * (1) We can try to grow the summary in the current location, and relocate * possibly used blocks within the current cylinder group. * (2) Alternatively we can relocate the whole cylinder summary to the first @@ -1238,24 +1250,104 @@ charsperline(void) return (columns); } +static int +is_dev(const char *name) +{ + struct stat devstat; + + if (stat(name, &devstat) != 0) + return (0); + if (!S_ISCHR(devstat.st_mode)) + return (0); + return (1); +} + /* - * Get the size of the partition. - */ -static void -get_dev_size(int fd, int *size) + * Return mountpoint on which the device is currently mounted. + */ +static const struct statfs * +dev_to_statfs(const char *dev) { - int sectorsize; - off_t mediasize; + struct stat devstat, mntdevstat; + struct statfs *mntbuf, *statfsp; + char device[MAXPATHLEN]; + char *mntdevname; + int i, mntsize; + + /* + * First check the mounted filesystems. + */ + if (stat(dev, &devstat) != 0) + return (NULL); + if (!S_ISCHR(devstat.st_mode) && !S_ISBLK(devstat.st_mode)) + return (NULL); + + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + for (i = 0; i < mntsize; i++) { + statfsp = &mntbuf[i]; + mntdevname = statfsp->f_mntfromname; + if (*mntdevname != '/') { + strcpy(device, _PATH_DEV); + strcat(device, mntdevname); + mntdevname = device; + } + if (stat(mntdevname, &mntdevstat) == 0 && + mntdevstat.st_rdev == devstat.st_rdev) + return (statfsp); + } - if (ioctl(fd, DIOCGSECTORSIZE, §orsize) == -1) - err(1,"DIOCGSECTORSIZE"); - if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) == -1) - err(1,"DIOCGMEDIASIZE"); + return (NULL); +} - if (sectorsize <= 0) - errx(1, "bogus sectorsize: %d", sectorsize); +static const char * +mountpoint_to_dev(const char *mountpoint) +{ + struct statfs *mntbuf, *statfsp; + struct fstab *fs; + int i, mntsize; - *size = mediasize / sectorsize; + /* + * First check the mounted filesystems. + */ + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + for (i = 0; i < mntsize; i++) { + statfsp = &mntbuf[i]; + + if (strcmp(statfsp->f_mntonname, mountpoint) == 0) + return (statfsp->f_mntfromname); + } + + /* + * Check the fstab. + */ + fs = getfsfile(mountpoint); + if (fs != NULL) + return (fs->fs_spec); + + return (NULL); +} + +static const char * +getdev(const char *name) +{ + static char device[MAXPATHLEN]; + const char *cp, *dev; + + if (is_dev(name)) + return (name); + + cp = strrchr(name, '/'); + if (cp == 0) { + snprintf(device, sizeof(device), "%s%s", _PATH_DEV, name); + if (is_dev(device)) + return (device); + } + + dev = mountpoint_to_dev(name); + if (dev != NULL && is_dev(dev)) + return (dev); + + return (NULL); } /* @@ -1283,17 +1375,13 @@ int main(int argc, char **argv) { DBG_FUNC("main") - char *device, *special; - int ch; - unsigned int size = 0; - size_t len; - unsigned int Nflag = 0; - int ExpertFlag = 0; - struct stat st; - int i, fsi, fso; - u_int32_t p_size; - char reply[5]; - int j; + const char *device; + const struct statfs *statfsp; + uint64_t size = 0; + off_t mediasize; + int error, i, j, fsi, fso, ch, Nflag = 0, yflag = 0; + char *p, reply[5], oldsizebuf[6], newsizebuf[6]; + void *testbuf; DBG_ENTER; @@ -1303,14 +1391,27 @@ main(int argc, char **argv) Nflag = 1; break; case 's': - size = (size_t)atol(optarg); - if (size < 1) - usage(); + size = (off_t)strtoumax(optarg, &p, 0); + if (p == NULL || *p == '\0') + size *= DEV_BSIZE; + else if (*p == 'b' || *p == 'B') + ; /* do nothing */ + else if (*p == 'k' || *p == 'K') + size <<= 10; + else if (*p == 'm' || *p == 'M') + size <<= 20; + else if (*p == 'g' || *p == 'G') + size <<= 30; + else if (*p == 't' || *p == 'T') { + size <<= 30; + size <<= 10; + } else + errx(1, "unknown suffix on -s argument"); break; case 'v': /* for compatibility to newfs */ break; case 'y': - ExpertFlag = 1; + yflag = 1; break; case '?': /* FALLTHROUGH */ @@ -1324,71 +1425,29 @@ main(int argc, char **argv) if (argc != 1) usage(); - device = *argv; - /* - * Now try to guess the (raw)device name. + * Now try to guess the device name. */ - if (0 == strrchr(device, '/')) { - /* - * No path prefix was given, so try in that order: - * /dev/r%s - * /dev/%s - * /dev/vinum/r%s - * /dev/vinum/%s. - * - * FreeBSD now doesn't distinguish between raw and block - * devices any longer, but it should still work this way. - */ - len = strlen(device) + strlen(_PATH_DEV) + 2 + strlen("vinum/"); - special = (char *)malloc(len); - if (special == NULL) - errx(1, "malloc failed"); - snprintf(special, len, "%sr%s", _PATH_DEV, device); - if (stat(special, &st) == -1) { - snprintf(special, len, "%s%s", _PATH_DEV, device); - if (stat(special, &st) == -1) { - snprintf(special, len, "%svinum/r%s", - _PATH_DEV, device); - if (stat(special, &st) == -1) { - /* For now this is the 'last resort' */ - snprintf(special, len, "%svinum/%s", - _PATH_DEV, device); - } - } - } - device = special; - } + device = getdev(*argv); + if (device == NULL) + errx(1, "cannot find special device for %s", *argv); - /* - * Try to access our devices for writing ... - */ - if (Nflag) { - fso = -1; - } else { - fso = open(device, O_WRONLY); - if (fso < 0) - err(1, "%s", device); - } + statfsp = dev_to_statfs(device); - /* - * ... and reading. - */ fsi = open(device, O_RDONLY); if (fsi < 0) err(1, "%s", device); /* - * Try to guess the slice if not specified. This code should guess - * the right thing and avoid to bother the user with the task - * of specifying the option -v on vinum volumes. + * Try to guess the slice size if not specified. */ - get_dev_size(fsi, &p_size); + if (ioctl(fsi, DIOCGMEDIASIZE, &mediasize) == -1) + err(1,"DIOCGMEDIASIZE"); /* * Check if that partition is suitable for growing a file system. */ - if (p_size < 1) + if (mediasize < 1) errx(1, "partition is unavailable"); /* @@ -1414,16 +1473,36 @@ main(int argc, char **argv) /* * Determine size to grow to. Default to the device size. */ - sblock.fs_size = dbtofsb(&osblock, p_size); - if (size != 0) { - if (size > p_size) - errx(1, "there is not enough space (%d < %d)", - p_size, size); - sblock.fs_size = dbtofsb(&osblock, size); + if (size == 0) + size = mediasize; + else { + if (size > (uint64_t)mediasize) { + humanize_number(oldsizebuf, sizeof(oldsizebuf), size, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), + mediasize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + + errx(1, "requested size %s is larger " + "than the available %s", oldsizebuf, newsizebuf); + } + } + + if (size <= (uint64_t)(osblock.fs_size * osblock.fs_fsize)) { + humanize_number(oldsizebuf, sizeof(oldsizebuf), + osblock.fs_size * osblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), size, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + + errx(1, "requested size %s is not larger than the current " + "filesystem size %s", newsizebuf, oldsizebuf); } + sblock.fs_size = dbtofsb(&osblock, size / DEV_BSIZE); + /* - * Are we really growing ? + * Are we really growing? */ if (osblock.fs_size >= sblock.fs_size) { errx(1, "we are not growing (%jd->%jd)", @@ -1433,7 +1512,7 @@ main(int argc, char **argv) /* * Check if we find an active snapshot. */ - if (ExpertFlag == 0) { + if (yflag == 0) { for (j = 0; j < FSMAXSNAP; j++) { if (sblock.fs_snapinum[j]) { errx(1, "active snapshot found in file system; " @@ -1445,10 +1524,23 @@ main(int argc, char **argv) } } - if (ExpertFlag == 0 && Nflag == 0) { - printf("We strongly recommend you to make a backup " + if (yflag == 0 && Nflag == 0) { + if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) + errx(1, "%s is mounted read-write on %s", + statfsp->f_mntfromname, statfsp->f_mntonname); + printf("It's strongly recommended to make a backup " "before growing the file system.\n" - "Did you backup your data (Yes/No)? "); + "OK to grow filesystem on %s", device); + if (statfsp != NULL) + printf(", mounted on %s,", statfsp->f_mntonname); + humanize_number(oldsizebuf, sizeof(oldsizebuf), + osblock.fs_size * osblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), + sblock.fs_size * sblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + printf(" from %s to %s? [Yes/No] ", oldsizebuf, newsizebuf); + fflush(stdout); fgets(reply, (int)sizeof(reply), stdin); if (strcmp(reply, "Yes\n")){ printf("\nNothing done\n"); @@ -1456,15 +1548,30 @@ main(int argc, char **argv) } } - printf("New file system size is %jd frags\n", (intmax_t)sblock.fs_size); + /* + * Try to access our device for writing. If it's not mounted, + * or mounted read-only, simply open it; otherwise, use UFS + * suspension mechanism. + */ + if (Nflag) { + fso = -1; + } else { + fso = open(device, O_WRONLY); + if (fso < 0) + err(1, "%s", device); + } /* - * Try to access our new last block in the file system. Even if we - * later on realize we have to abort our operation, on that block - * there should be no data, so we can't destroy something yet. + * Try to access our new last block in the file system. */ - wtfs((ufs2_daddr_t)p_size - 1, (size_t)DEV_BSIZE, (void *)&sblock, - fso, Nflag); + testbuf = malloc(sblock.fs_fsize); + if (testbuf == NULL) + err(1, "malloc"); + rdfs((ufs2_daddr_t)((size / DEV_BSIZE) - sblock.fs_fsize), + sblock.fs_fsize, testbuf, fsi); + wtfs((ufs2_daddr_t)((size / DEV_BSIZE) - sblock.fs_fsize), + sblock.fs_fsize, testbuf, fso, Nflag); + free(testbuf); /* * Now calculate new superblock values and check for reasonable @@ -1520,8 +1627,13 @@ main(int argc, char **argv) growfs(fsi, fso, Nflag); close(fsi); - if (fso > -1) - close(fso); + if (fso > -1) { + error = close(fso); + if (error != 0) + err(1, "close"); + } + if (statfsp != NULL) + mount_reload(statfsp); DBG_CLOSE; @@ -1539,7 +1651,7 @@ usage(void) DBG_ENTER; - fprintf(stderr, "usage: growfs [-Ny] [-s size] special\n"); + fprintf(stderr, "usage: growfs [-Ny] [-s size] special | filesystem\n"); DBG_LEAVE; exit(1); @@ -1586,3 +1698,26 @@ updclst(int block) DBG_LEAVE; return; } + +static void +mount_reload(const struct statfs *stfs) +{ + char errmsg[255]; + struct iovec *iov; + int iovlen; + + iov = NULL; + iovlen = 0; + *errmsg = '\0'; + build_iovec(&iov, &iovlen, "fstype", __DECONST(char *, "ffs"), 4); + build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, stfs->f_mntonname), (size_t)-1); + build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); + build_iovec(&iov, &iovlen, "update", NULL, 0); + build_iovec(&iov, &iovlen, "reload", NULL, 0); + + if (nmount(iov, iovlen, stfs->f_flags) < 0) { + errmsg[sizeof(errmsg) - 1] = '\0'; + err(9, "%s: cannot reload filesystem%s%s", stfs->f_mntonname, + *errmsg != '\0' ? ": " : "", errmsg); + } +} From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 16:16:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C367C1065676; Mon, 30 Apr 2012 16:16:37 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEDBD8FC08; Mon, 30 Apr 2012 16:16:37 +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 q3UGGbFL073688; Mon, 30 Apr 2012 16:16:37 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UGGbPb073686; Mon, 30 Apr 2012 16:16:37 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301616.q3UGGbPb073686@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 16:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234847 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 16:16:37 -0000 Author: dumbbell Date: Mon Apr 30 16:16:37 2012 New Revision: 234847 URL: http://svn.freebsd.org/changeset/base/234847 Log: Add myself. Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Mon Apr 30 16:08:02 2012 (r234846) +++ head/share/misc/committers-src.dot Mon Apr 30 16:16:37 2012 (r234847) @@ -128,6 +128,7 @@ dg [label="David Greenman\ndg@FreeBSD.or dim [label="Dimitry Andric\ndim@FreeBSD.org\n2010/08/30"] dougb [label="Doug Barton\ndougb@FreeBSD.org\n2000/10/26"] dteske [label="Devin Teske\ndteske@FreeBSD.org\n2012/04/10"] +dumbbell [label="Jean-Sebastien Pedron\ndumbbell@FreeBSD.org\n2004/11/29"] dwmalone [label="David Malone\ndwmalone@FreeBSD.org\n2000/07/11"] ed [label="Ed Schouten\ned@FreeBSD.org\n2008/05/22"] edwin [label="Edwin Groothuis\nedwin@FreeBSD.org\n2007/06/25"] @@ -506,6 +507,7 @@ msmith -> scottl murray -> delphij mux -> cognet +mux -> dumbbell netchild -> ariff From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 17:53:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4109E1065744; Mon, 30 Apr 2012 17:53:03 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B06208FC1E; Mon, 30 Apr 2012 17:53: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 q3UHr2Ht077131; Mon, 30 Apr 2012 17:53:02 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UHr2XI077126; Mon, 30 Apr 2012 17:53:02 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201204301753.q3UHr2XI077126@svn.freebsd.org> From: Alexander Motin Date: Mon, 30 Apr 2012 17:53: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: r234848 - in head: sbin/geom/class/raid sys/conf sys/geom/raid sys/modules/geom/geom_raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 17:53:03 -0000 Author: mav Date: Mon Apr 30 17:53:02 2012 New Revision: 234848 URL: http://svn.freebsd.org/changeset/base/234848 Log: Add to GEOM RAID class module, supporting the DDF metadata format, as defined by the SNIA Common RAID Disk Data Format Specification v2.0. Supports multiple volumes per array and multiple partitions per disk. Supports standard big-endian and Adaptec's little-endian byte ordering. Supports all single-layer RAID levels. Dual-layer RAID levels except RAID10 are not supported now because of GEOM RAID design limitations. Some work is still to be done, but the present code already manages basic interoperation with RAID BIOS of the Adaptec 1430SA SATA RAID controller. MFC after: 1 month Sponsored by: iXsystems, Inc. Added: head/sys/geom/raid/md_ddf.c (contents, props changed) head/sys/geom/raid/md_ddf.h (contents, props changed) Modified: head/sbin/geom/class/raid/graid.8 head/sys/conf/files head/sys/modules/geom/geom_raid/Makefile Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Mon Apr 30 16:16:37 2012 (r234847) +++ head/sbin/geom/class/raid/graid.8 Mon Apr 30 17:53:02 2012 (r234848) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 19, 2012 +.Dd April 30, 2012 .Dt GRAID 8 .Os .Sh NAME @@ -200,6 +200,19 @@ The GEOM RAID class follows a modular de formats to be used. Support is currently implemented for the following formats: .Bl -tag -width "Intel" +.It DDF +The format defined by the SNIA Common RAID Disk Data Format v2.0 specification. +Used by some Adaptec RAID BIOSes and some hardware RAID controllers. +Because of high format flexibility different implementations support +different set of features and have different on-disk metadata layouts. +To provide compatibility, the GEOM RAID class mimics capabilities and +metadata layout of the first detected DDF array. +Respecting that, it may support different number of disks per volume, +volumes per array, partitions per disk, etc. +The following configurations are supported: RAID0 (2+ disks), RAID1 (2+ disks), +RAID1E (3+ disks), RAID3 (3+ disks), RAID4 (3+ disks), RAID5 (3+ disks), +RAID5E (4+ disks), RAID5EE (4+ disks), RAID5R (3+ disks), RAID6 (4+ disks), +RAIDMDF (5+ disks), RAID10 (4+ disks), SINGLE (1 disk), CONCAT (2+ disks). .It Intel The format used by Intel RAID BIOS. Supports up to two volumes per array. Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Apr 30 16:16:37 2012 (r234847) +++ head/sys/conf/files Mon Apr 30 17:53:02 2012 (r234848) @@ -2396,6 +2396,7 @@ geom/raid/g_raid.c optional geom_raid geom/raid/g_raid_ctl.c optional geom_raid geom/raid/g_raid_md_if.m optional geom_raid geom/raid/g_raid_tr_if.m optional geom_raid +geom/raid/md_ddf.c optional geom_raid geom/raid/md_intel.c optional geom_raid geom/raid/md_jmicron.c optional geom_raid geom/raid/md_nvidia.c optional geom_raid Added: head/sys/geom/raid/md_ddf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/geom/raid/md_ddf.c Mon Apr 30 17:53:02 2012 (r234848) @@ -0,0 +1,2900 @@ +/*- + * Copyright (c) 2012 Alexander Motin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "geom/raid/g_raid.h" +#include "geom/raid/md_ddf.h" +#include "g_raid_md_if.h" + +static MALLOC_DEFINE(M_MD_DDF, "md_ddf_data", "GEOM_RAID DDF metadata"); + +#define DDF_MAX_DISKS_HARD 128 + +#define DDF_MAX_DISKS 16 +#define DDF_MAX_VDISKS 7 +#define DDF_MAX_PARTITIONS 1 + +#define DECADE (3600*24*(365*10+2)) /* 10 years in seconds. */ + +struct ddf_meta { + u_int sectorsize; + u_int bigendian; + struct ddf_header *hdr; + struct ddf_cd_record *cdr; + struct ddf_pd_record *pdr; + struct ddf_vd_record *vdr; + void *cr; + struct ddf_pdd_record *pdd; + struct ddf_bbm_log *bbm; +}; + +struct ddf_vol_meta { + u_int sectorsize; + u_int bigendian; + struct ddf_header *hdr; + struct ddf_cd_record *cdr; + struct ddf_vd_entry *vde; + struct ddf_vdc_record *vdc; + struct ddf_vdc_record *bvdc[DDF_MAX_DISKS_HARD]; +}; + +struct g_raid_md_ddf_perdisk { + struct ddf_meta pd_meta; +}; + +struct g_raid_md_ddf_pervolume { + struct ddf_vol_meta pv_meta; + int pv_started; + struct callout pv_start_co; /* STARTING state timer. */ +}; + +struct g_raid_md_ddf_object { + struct g_raid_md_object mdio_base; + struct ddf_meta mdio_meta; + struct callout mdio_start_co; /* STARTING state timer. */ + int mdio_started; + int mdio_incomplete; + struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ +}; + +static g_raid_md_create_t g_raid_md_create_ddf; +static g_raid_md_taste_t g_raid_md_taste_ddf; +static g_raid_md_event_t g_raid_md_event_ddf; +static g_raid_md_volume_event_t g_raid_md_volume_event_ddf; +static g_raid_md_ctl_t g_raid_md_ctl_ddf; +static g_raid_md_write_t g_raid_md_write_ddf; +static g_raid_md_fail_disk_t g_raid_md_fail_disk_ddf; +static g_raid_md_free_disk_t g_raid_md_free_disk_ddf; +static g_raid_md_free_volume_t g_raid_md_free_volume_ddf; +static g_raid_md_free_t g_raid_md_free_ddf; + +static kobj_method_t g_raid_md_ddf_methods[] = { + KOBJMETHOD(g_raid_md_create, g_raid_md_create_ddf), + KOBJMETHOD(g_raid_md_taste, g_raid_md_taste_ddf), + KOBJMETHOD(g_raid_md_event, g_raid_md_event_ddf), + KOBJMETHOD(g_raid_md_volume_event, g_raid_md_volume_event_ddf), + KOBJMETHOD(g_raid_md_ctl, g_raid_md_ctl_ddf), + KOBJMETHOD(g_raid_md_write, g_raid_md_write_ddf), + KOBJMETHOD(g_raid_md_fail_disk, g_raid_md_fail_disk_ddf), + KOBJMETHOD(g_raid_md_free_disk, g_raid_md_free_disk_ddf), + KOBJMETHOD(g_raid_md_free_volume, g_raid_md_free_volume_ddf), + KOBJMETHOD(g_raid_md_free, g_raid_md_free_ddf), + { 0, 0 } +}; + +static struct g_raid_md_class g_raid_md_ddf_class = { + "DDF", + g_raid_md_ddf_methods, + sizeof(struct g_raid_md_ddf_object), + .mdc_priority = 100 +}; + +#define GET8(m, f) ((m)->f) +#define GET16(m, f) ((m)->bigendian ? be16dec(&(m)->f) : le16dec(&(m)->f)) +#define GET32(m, f) ((m)->bigendian ? be32dec(&(m)->f) : le32dec(&(m)->f)) +#define GET64(m, f) ((m)->bigendian ? be64dec(&(m)->f) : le64dec(&(m)->f)) +#define GET8D(m, f) (f) +#define GET16D(m, f) ((m)->bigendian ? be16dec(&f) : le16dec(&f)) +#define GET32D(m, f) ((m)->bigendian ? be32dec(&f) : le32dec(&f)) +#define GET64D(m, f) ((m)->bigendian ? be64dec(&f) : le64dec(&f)) +#define GET8P(m, f) (*(f)) +#define GET16P(m, f) ((m)->bigendian ? be16dec(f) : le16dec(f)) +#define GET32P(m, f) ((m)->bigendian ? be32dec(f) : le32dec(f)) +#define GET64P(m, f) ((m)->bigendian ? be64dec(f) : le64dec(f)) + +#define SET8P(m, f, v) \ + (*(f) = (v)) +#define SET16P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be16enc((f), (v)); \ + else \ + le16enc((f), (v)); \ + } while (0) +#define SET32P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be32enc((f), (v)); \ + else \ + le32enc((f), (v)); \ + } while (0) +#define SET64P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be64enc((f), (v)); \ + else \ + le64enc((f), (v)); \ + } while (0) +#define SET8(m, f, v) SET8P((m), &((m)->f), (v)) +#define SET16(m, f, v) SET16P((m), &((m)->f), (v)) +#define SET32(m, f, v) SET32P((m), &((m)->f), (v)) +#define SET64(m, f, v) SET64P((m), &((m)->f), (v)) +#define SET8D(m, f, v) SET8P((m), &(f), (v)) +#define SET16D(m, f, v) SET16P((m), &(f), (v)) +#define SET32D(m, f, v) SET32P((m), &(f), (v)) +#define SET64D(m, f, v) SET64P((m), &(f), (v)) + +static int +isff(uint8_t *buf, int size) +{ + int i; + + for (i = 0; i < size; i++) + if (buf[i] != 0xff) + return (0); + return (1); +} + +static void +print_guid(uint8_t *buf) +{ + int i, ascii; + + ascii = 1; + for (i = 0; i < 24; i++) { + if (buf[i] != 0 && (buf[i] < ' ' || buf[i] > 127)) { + ascii = 0; + break; + } + } + if (ascii) { + printf("'%.24s'", buf); + } else { + for (i = 0; i < 24; i++) + printf("%02x", buf[i]); + } +} + +static void +g_raid_md_ddf_print(struct ddf_meta *meta) +{ + struct ddf_vdc_record *vdc; + struct ddf_vuc_record *vuc; + struct ddf_sa_record *sa; + uint64_t *val2; + uint32_t val; + int i, j, k, num, num2; + + if (g_raid_debug < 1) + return; + + printf("********* DDF Metadata *********\n"); + printf("**** Header ****\n"); + printf("DDF_Header_GUID "); + print_guid(meta->hdr->DDF_Header_GUID); + printf("\n"); + printf("DDF_rev %8.8s\n", (char *)&meta->hdr->DDF_rev[0]); + printf("Sequence_Number 0x%08x\n", GET32(meta, hdr->Sequence_Number)); + printf("TimeStamp 0x%08x\n", GET32(meta, hdr->TimeStamp)); + printf("Open_Flag 0x%02x\n", GET16(meta, hdr->Open_Flag)); + printf("Foreign_Flag 0x%02x\n", GET16(meta, hdr->Foreign_Flag)); + printf("Diskgrouping 0x%02x\n", GET16(meta, hdr->Diskgrouping)); + printf("Primary_Header_LBA %ju\n", GET64(meta, hdr->Primary_Header_LBA)); + printf("Secondary_Header_LBA %ju\n", GET64(meta, hdr->Secondary_Header_LBA)); + printf("WorkSpace_Length %u\n", GET32(meta, hdr->WorkSpace_Length)); + printf("WorkSpace_LBA %ju\n", GET64(meta, hdr->WorkSpace_LBA)); + printf("Max_PD_Entries %u\n", GET16(meta, hdr->Max_PD_Entries)); + printf("Max_VD_Entries %u\n", GET16(meta, hdr->Max_VD_Entries)); + printf("Max_Partitions %u\n", GET16(meta, hdr->Max_Partitions)); + printf("Configuration_Record_Length %u\n", GET16(meta, hdr->Configuration_Record_Length)); + printf("Max_Primary_Element_Entries %u\n", GET16(meta, hdr->Max_Primary_Element_Entries)); + printf("Controller Data %u:%u\n", GET32(meta, hdr->cd_section), GET32(meta, hdr->cd_length)); + printf("Physical Disk %u:%u\n", GET32(meta, hdr->pdr_section), GET32(meta, hdr->pdr_length)); + printf("Virtual Disk %u:%u\n", GET32(meta, hdr->vdr_section), GET32(meta, hdr->vdr_length)); + printf("Configuration Recs %u:%u\n", GET32(meta, hdr->cr_section), GET32(meta, hdr->cr_length)); + printf("Physical Disk Recs %u:%u\n", GET32(meta, hdr->pdd_section), GET32(meta, hdr->pdd_length)); + printf("BBM Log %u:%u\n", GET32(meta, hdr->bbmlog_section), GET32(meta, hdr->bbmlog_length)); + printf("Diagnostic Space %u:%u\n", GET32(meta, hdr->Diagnostic_Space), GET32(meta, hdr->Diagnostic_Space_Length)); + printf("Vendor_Specific_Logs %u:%u\n", GET32(meta, hdr->Vendor_Specific_Logs), GET32(meta, hdr->Vendor_Specific_Logs_Length)); + printf("**** Controler Data ****\n"); + printf("Controller_GUID "); + print_guid(meta->cdr->Controller_GUID); + printf("\n"); + printf("Controller_Type 0x%04x%04x 0x%04x%04x\n", + GET16(meta, cdr->Controller_Type.Vendor_ID), + GET16(meta, cdr->Controller_Type.Device_ID), + GET16(meta, cdr->Controller_Type.SubVendor_ID), + GET16(meta, cdr->Controller_Type.SubDevice_ID)); + printf("Product_ID '%.16s'\n", (char *)&meta->cdr->Product_ID[0]); + printf("**** Physical Disk Data ****\n"); + printf("Populated_PDEs %u\n", GET16(meta, pdr->Populated_PDEs)); + printf("Max_PDE_Supported %u\n", GET16(meta, pdr->Max_PDE_Supported)); + for (j = 0; j < GET16(meta, pdr->Populated_PDEs); j++) { + if (isff(meta->pdr->entry[j].PD_GUID, 24)) + continue; + if (GET32(meta, pdr->entry[j].PD_Reference) == 0xffffffff) + continue; + printf("PD_GUID "); + print_guid(meta->pdr->entry[j].PD_GUID); + printf("\n"); + printf("PD_Reference 0x%08x\n", + GET32(meta, pdr->entry[j].PD_Reference)); + printf("PD_Type 0x%04x\n", + GET16(meta, pdr->entry[j].PD_Type)); + printf("PD_State 0x%04x\n", + GET16(meta, pdr->entry[j].PD_State)); + printf("Configured_Size %ju\n", + GET64(meta, pdr->entry[j].Configured_Size)); + printf("Block_Size %u\n", + GET16(meta, pdr->entry[j].Block_Size)); + } + printf("**** Virtual Disk Data ****\n"); + printf("Populated_VDEs %u\n", GET16(meta, vdr->Populated_VDEs)); + printf("Max_VDE_Supported %u\n", GET16(meta, vdr->Max_VDE_Supported)); + for (j = 0; j < GET16(meta, vdr->Populated_VDEs); j++) { + if (isff(meta->vdr->entry[j].VD_GUID, 24)) + continue; + printf("VD_GUID "); + print_guid(meta->vdr->entry[j].VD_GUID); + printf("\n"); + printf("VD_Number 0x%04x\n", + GET16(meta, vdr->entry[j].VD_Number)); + printf("VD_Type 0x%02x\n", + GET8(meta, vdr->entry[j].VD_Type)); + printf("VD_State 0x%02x\n", + GET8(meta, vdr->entry[j].VD_State)); + printf("Init_State 0x%02x\n", + GET8(meta, vdr->entry[j].Init_State)); + printf("Drive_Failures_Remaining %u\n", + GET8(meta, vdr->entry[j].Drive_Failures_Remaining)); + printf("VD_Name '%.16s'\n", + (char *)&meta->vdr->entry[j].VD_Name); + } + printf("**** Configuration Records ****\n"); + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (j = 0; j < num; j++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + j * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + val = GET32D(meta, vdc->Signature); + switch (val) { + case DDF_VDCR_SIGNATURE: + printf("** Virtual Disk Configuration **\n"); + printf("VD_GUID "); + print_guid(vdc->VD_GUID); + printf("\n"); + printf("Timestamp 0x%08x\n", + GET32D(meta, vdc->Timestamp)); + printf("Sequence_Number 0x%08x\n", + GET32D(meta, vdc->Sequence_Number)); + printf("Primary_Element_Count %u\n", + GET16D(meta, vdc->Primary_Element_Count)); + printf("Stripe_Size %u\n", + GET8D(meta, vdc->Stripe_Size)); + printf("Primary_RAID_Level 0x%02x\n", + GET8D(meta, vdc->Primary_RAID_Level)); + printf("RLQ 0x%02x\n", + GET8D(meta, vdc->RLQ)); + printf("Secondary_Element_Count %u\n", + GET8D(meta, vdc->Secondary_Element_Count)); + printf("Secondary_Element_Seq %u\n", + GET8D(meta, vdc->Secondary_Element_Seq)); + printf("Secondary_RAID_Level 0x%02x\n", + GET8D(meta, vdc->Secondary_RAID_Level)); + printf("Block_Count %ju\n", + GET64D(meta, vdc->Block_Count)); + printf("VD_Size %ju\n", + GET64D(meta, vdc->VD_Size)); + printf("Block_Size %u\n", + GET16D(meta, vdc->Block_Size)); + printf("Rotate_Parity_count %u\n", + GET8D(meta, vdc->Rotate_Parity_count)); + printf("Associated_Spare_Disks"); + for (i = 0; i < 8; i++) { + if (GET32D(meta, vdc->Associated_Spares[i]) != 0xffffffff) + printf(" 0x%08x", GET32D(meta, vdc->Associated_Spares[i])); + } + printf("\n"); + printf("Cache_Flags %016jx\n", + GET64D(meta, vdc->Cache_Flags)); + printf("BG_Rate %u\n", + GET8D(meta, vdc->BG_Rate)); + printf("MDF_Parity_Disks %u\n", + GET8D(meta, vdc->MDF_Parity_Disks)); + printf("MDF_Parity_Generator_Polynomial 0x%04x\n", + GET16D(meta, vdc->MDF_Parity_Generator_Polynomial)); + printf("MDF_Constant_Generation_Method 0x%02x\n", + GET8D(meta, vdc->MDF_Constant_Generation_Method)); + printf("Physical_Disks "); + num2 = GET16D(meta, vdc->Primary_Element_Count); + val2 = (uint64_t *)&(vdc->Physical_Disk_Sequence[GET16(meta, hdr->Max_Primary_Element_Entries)]); + for (i = 0; i < num2; i++) + printf(" 0x%08x @ %ju", + GET32D(meta, vdc->Physical_Disk_Sequence[i]), + GET64P(meta, val2 + i)); + printf("\n"); + break; + case DDF_VUCR_SIGNATURE: + printf("** Vendor Unique Configuration **\n"); + vuc = (struct ddf_vuc_record *)vdc; + printf("VD_GUID "); + print_guid(vuc->VD_GUID); + printf("\n"); + break; + case DDF_SA_SIGNATURE: + printf("** Spare Assignment Configuration **\n"); + sa = (struct ddf_sa_record *)vdc; + printf("Timestamp 0x%08x\n", + GET32D(meta, sa->Timestamp)); + printf("Spare_Type 0x%02x\n", + GET8D(meta, sa->Spare_Type)); + printf("Populated_SAEs %u\n", + GET16D(meta, sa->Populated_SAEs)); + printf("MAX_SAE_Supported %u\n", + GET16D(meta, sa->MAX_SAE_Supported)); + for (i = 0; i < GET16D(meta, sa->Populated_SAEs); i++) { + if (isff(sa->entry[i].VD_GUID, 24)) + continue; + printf("VD_GUID "); + for (k = 0; k < 24; k++) + printf("%02x", sa->entry[i].VD_GUID[k]); + printf("\n"); + printf("Secondary_Element %u\n", + GET16D(meta, sa->entry[i].Secondary_Element)); + } + break; + case 0xFFFFFFFF: + break; + default: + printf("Unknown configuration signature %08x\n", val); + break; + } + } + printf("**** Physical Disk Data ****\n"); + printf("PD_GUID "); + print_guid(meta->pdd->PD_GUID); + printf("\n"); + printf("PD_Reference 0x%08x\n", + GET32(meta, pdd->PD_Reference)); + printf("Forced_Ref_Flag 0x%02x\n", + GET8(meta, pdd->Forced_Ref_Flag)); + printf("Forced_PD_GUID_Flag 0x%02x\n", + GET8(meta, pdd->Forced_PD_GUID_Flag)); +} + +static int +ddf_meta_find_pd(struct ddf_meta *meta, uint8_t *GUID, uint32_t PD_Reference) +{ + int i; + + for (i = 0; i < GET16(meta, pdr->Populated_PDEs); i++) { + if (GUID != NULL) { + if (memcmp(meta->pdr->entry[i].PD_GUID, GUID, 24) == 0) + return (i); + } else if (PD_Reference != 0xffffffff) { + if (GET32(meta, pdr->entry[i].PD_Reference) == PD_Reference) + return (i); + } else + if (isff(meta->pdr->entry[i].PD_GUID, 24)) + return (i); + } + if (GUID == NULL && PD_Reference == 0xffffffff) { + if (i >= GET16(meta, pdr->Max_PDE_Supported)) + return (-1); + SET16(meta, pdr->Populated_PDEs, i + 1); + return (i); + } + return (-1); +} + +static int +ddf_meta_find_vd(struct ddf_meta *meta, uint8_t *GUID) +{ + int i; + + for (i = 0; i < GET16(meta, vdr->Populated_VDEs); i++) { + if (GUID != NULL) { + if (memcmp(meta->vdr->entry[i].VD_GUID, GUID, 24) == 0) + return (i); + } else + if (isff(meta->vdr->entry[i].VD_GUID, 24)) + return (i); + } + if (GUID == NULL) { + if (i >= GET16(meta, vdr->Max_VDE_Supported)) + return (-1); + SET16(meta, vdr->Populated_VDEs, i + 1); + return (i); + } + return (-1); +} + +static struct ddf_vdc_record * +ddf_meta_find_vdc(struct ddf_meta *meta, uint8_t *GUID) +{ + struct ddf_vdc_record *vdc; + int i, num; + + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GUID != NULL) { + if (GET32D(meta, vdc->Signature) == DDF_VDCR_SIGNATURE && + memcmp(vdc->VD_GUID, GUID, 24) == 0) + return (vdc); + } else + if (GET32D(meta, vdc->Signature) == 0xffffffff) + return (vdc); + } + return (NULL); +} + +static int +ddf_meta_count_vdc(struct ddf_meta *meta, uint8_t *GUID) +{ + struct ddf_vdc_record *vdc; + int i, num, cnt; + + cnt = 0; + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) + continue; + if (GUID == NULL || memcmp(vdc->VD_GUID, GUID, 24) == 0) + cnt++; + } + return (cnt); +} + +static int +ddf_meta_find_disk(struct ddf_vol_meta *vmeta, uint32_t PD_Reference, + int *bvdp, int *posp) +{ + int i, bvd, pos; + + i = 0; + for (bvd = 0; bvd < GET16(vmeta, vdc->Secondary_Element_Count); bvd++) { + if (vmeta->bvdc[bvd] == NULL) { + i += GET16(vmeta, vdc->Primary_Element_Count); // XXX + continue; + } + for (pos = 0; pos < GET16(vmeta, bvdc[bvd]->Primary_Element_Count); + pos++, i++) { + if (GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos]) == + PD_Reference) { + if (bvdp != NULL) + *bvdp = bvd; + if (posp != NULL) + *posp = pos; + return (i); + } + } + } + return (-1); +} + +static void +ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) +{ + struct timespec ts; + struct clocktime ct; + struct g_raid_md_ddf_perdisk *pd; + struct ddf_meta *meta; + struct ddf_pd_entry *pde; + off_t anchorlba; + u_int ss, pos, size; + int len, error; + char serial_buffer[24]; + + if (sample->hdr == NULL) + sample = NULL; + + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + meta = &pd->pd_meta; + ss = disk->d_consumer->provider->sectorsize; + anchorlba = disk->d_consumer->provider->mediasize / ss - 1; + + meta->sectorsize = ss; + meta->bigendian = sample ? sample->bigendian : 0; + getnanotime(&ts); + clock_ts_to_ct(&ts, &ct); + + /* Header */ + meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memset(meta->hdr, 0xff, ss); + if (sample) { + memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header)); + if (ss != sample->sectorsize) { + SET32(meta, hdr->WorkSpace_Length, + (GET32(sample, hdr->WorkSpace_Length) * + sample->sectorsize + ss - 1) / ss); + SET16(meta, hdr->Configuration_Record_Length, + (GET16(sample, hdr->Configuration_Record_Length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->cd_length, + (GET32(sample, hdr->cd_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->pdr_length, + (GET32(sample, hdr->pdr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->vdr_length, + (GET32(sample, hdr->vdr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->cr_length, + (GET32(sample, hdr->cr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->pdd_length, + (GET32(sample, hdr->pdd_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->bbmlog_length, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->Diagnostic_Space, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->Vendor_Specific_Logs, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + } + } else { + SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE); + snprintf(meta->hdr->DDF_Header_GUID, 25, "FreeBSD %08x%08x", + (u_int)(ts.tv_sec - DECADE), arc4random()); + memcpy(meta->hdr->DDF_rev, "02.00.00", 8); + SET32(meta, hdr->TimeStamp, (ts.tv_sec - DECADE)); + SET32(meta, hdr->WorkSpace_Length, 16 * 1024 * 1024 / ss); + SET16(meta, hdr->Max_PD_Entries, DDF_MAX_DISKS - 1); + SET16(meta, hdr->Max_VD_Entries, DDF_MAX_VDISKS); + SET16(meta, hdr->Max_Partitions, DDF_MAX_PARTITIONS); + SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS); + SET16(meta, hdr->Configuration_Record_Length, + (sizeof(struct ddf_vdc_record) + + (4 + 8) * GET16(meta, hdr->Max_Primary_Element_Entries) + + ss - 1) / ss); + SET32(meta, hdr->cd_length, + (sizeof(struct ddf_cd_record) + ss - 1) / ss); + SET32(meta, hdr->pdr_length, + (sizeof(struct ddf_pd_record) + + sizeof(struct ddf_pd_entry) * + GET16(meta, hdr->Max_PD_Entries) + ss - 1) / ss); + SET32(meta, hdr->vdr_length, + (sizeof(struct ddf_vd_record) + + sizeof(struct ddf_vd_entry) * + GET16(meta, hdr->Max_VD_Entries) + ss - 1) / ss); + SET32(meta, hdr->cr_length, + GET16(meta, hdr->Configuration_Record_Length) * + (GET16(meta, hdr->Max_Partitions) + 1)); + SET32(meta, hdr->pdd_length, + (sizeof(struct ddf_pdd_record) + ss - 1) / ss); + SET32(meta, hdr->bbmlog_length, 0); + SET32(meta, hdr->Diagnostic_Space_Length, 0); + SET32(meta, hdr->Vendor_Specific_Logs_Length, 0); + } + pos = 1; + SET32(meta, hdr->cd_section, pos); + pos += GET32(meta, hdr->cd_length); + SET32(meta, hdr->pdr_section, pos); + pos += GET32(meta, hdr->pdr_length); + SET32(meta, hdr->vdr_section, pos); + pos += GET32(meta, hdr->vdr_length); + SET32(meta, hdr->cr_section, pos); + pos += GET32(meta, hdr->cr_length); + SET32(meta, hdr->pdd_section, pos); + pos += GET32(meta, hdr->pdd_length); + SET32(meta, hdr->bbmlog_section, + GET32(meta, hdr->bbmlog_length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->bbmlog_length); + SET32(meta, hdr->Diagnostic_Space, + GET32(meta, hdr->Diagnostic_Space_Length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->Diagnostic_Space_Length); + SET32(meta, hdr->Vendor_Specific_Logs, + GET32(meta, hdr->Vendor_Specific_Logs_Length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->Vendor_Specific_Logs_Length); + SET64(meta, hdr->Primary_Header_LBA, + anchorlba - pos - 16); + SET64(meta, hdr->Secondary_Header_LBA, + 0xffffffffffffffffULL); + SET64(meta, hdr->WorkSpace_LBA, + anchorlba + 1 - 32 * 1024 * 1024 / ss); + + /* Controller Data */ + size = GET32(meta, hdr->cd_length) * ss; + meta->cdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->cdr, 0xff, size); + SET32(meta, cdr->Signature, DDF_CONTROLLER_DATA_SIGNATURE); + memcpy(meta->cdr->Controller_GUID, "FreeBSD GEOM RAID SERIAL", 24); + memcpy(meta->cdr->Product_ID, "FreeBSD GEOMRAID", 16); + + /* Physical Drive Records. */ + size = GET32(meta, hdr->pdr_length) * ss; + meta->pdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->pdr, 0xff, size); + SET32(meta, pdr->Signature, DDF_PDR_SIGNATURE); + SET16(meta, pdr->Populated_PDEs, 1); + SET16(meta, pdr->Max_PDE_Supported, + GET16(meta, hdr->Max_PD_Entries)); + + pde = &meta->pdr->entry[0]; + len = sizeof(serial_buffer); + error = g_io_getattr("GEOM::ident", disk->d_consumer, &len, serial_buffer); + if (error == 0 && (len = strlen (serial_buffer)) >= 6 && len <= 20) + snprintf(pde->PD_GUID, 25, "DISK%20s", serial_buffer); + else + snprintf(pde->PD_GUID, 25, "DISK%04d%02d%02d%08x%04x", + ct.year, ct.mon, ct.day, + arc4random(), arc4random() & 0xffff); + SET32D(meta, pde->PD_Reference, arc4random()); + SET16D(meta, pde->PD_Type, DDF_PDE_GUID_FORCE); + SET16D(meta, pde->PD_State, 0); + SET64D(meta, pde->Configured_Size, + anchorlba + 1 - 32 * 1024 * 1024 / ss); + SET16D(meta, pde->Block_Size, ss); + + /* Virtual Drive Records. */ + size = GET32(meta, hdr->vdr_length) * ss; + meta->vdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->vdr, 0xff, size); + SET32(meta, vdr->Signature, DDF_VD_RECORD_SIGNATURE); + SET32(meta, vdr->Populated_VDEs, 0); + SET16(meta, vdr->Max_VDE_Supported, + GET16(meta, hdr->Max_VD_Entries)); + + /* Configuration Records. */ + size = GET32(meta, hdr->cr_length) * ss; + meta->cr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->cr, 0xff, size); + + /* Physical Disk Data. */ + size = GET32(meta, hdr->pdd_length) * ss; + meta->pdd = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->pdd, 0xff, size); + SET32(meta, pdd->Signature, DDF_PDD_SIGNATURE); + memcpy(meta->pdd->PD_GUID, pde->PD_GUID, 24); + SET32(meta, pdd->PD_Reference, GET32D(meta, pde->PD_Reference)); + SET8(meta, pdd->Forced_Ref_Flag, DDF_PDD_FORCED_REF); + SET8(meta, pdd->Forced_PD_GUID_Flag, DDF_PDD_FORCED_GUID); + + /* Bad Block Management Log. */ + if (GET32(meta, hdr->bbmlog_length) != 0) { + size = GET32(meta, hdr->bbmlog_length) * ss; + meta->bbm = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->bbm, 0xff, size); + SET32(meta, bbm->Signature, DDF_BBML_SIGNATURE); + SET32(meta, bbm->Entry_Count, 0); + SET32(meta, bbm->Spare_Block_Count, 0); + } +} + +static void +ddf_meta_copy(struct ddf_meta *dst, struct ddf_meta *src) +{ + struct ddf_header *hdr; + u_int ss; + + hdr = src->hdr; + dst->bigendian = src->bigendian; + ss = dst->sectorsize = src->sectorsize; + dst->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(dst->hdr, src->hdr, ss); + dst->cdr = malloc(GET32(src, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cdr, src->cdr, GET32(src, hdr->cd_length) * ss); + dst->pdr = malloc(GET32(src, hdr->pdr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->pdr, src->pdr, GET32(src, hdr->pdr_length) * ss); + dst->vdr = malloc(GET32(src, hdr->vdr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->vdr, src->vdr, GET32(src, hdr->vdr_length) * ss); + dst->cr = malloc(GET32(src, hdr->cr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cr, src->cr, GET32(src, hdr->cr_length) * ss); + dst->pdd = malloc(GET32(src, hdr->pdd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->pdd, src->pdd, GET32(src, hdr->pdd_length) * ss); + if (src->bbm != NULL) { + dst->bbm = malloc(GET32(src, hdr->bbmlog_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->bbm, src->bbm, GET32(src, hdr->bbmlog_length) * ss); + } +} + +static void +ddf_meta_update(struct ddf_meta *meta, struct ddf_meta *src) +{ + struct ddf_pd_entry *pde, *spde; + int i, j; + + for (i = 0; i < GET16(src, pdr->Populated_PDEs); i++) { + spde = &src->pdr->entry[i]; + if (isff(spde->PD_GUID, 24)) + continue; + j = ddf_meta_find_pd(meta, NULL, + src->pdr->entry[i].PD_Reference); + if (j < 0) { + j = ddf_meta_find_pd(meta, NULL, 0xffffffff); + pde = &meta->pdr->entry[j]; + memcpy(pde, spde, sizeof(*pde)); + } else { + pde = &meta->pdr->entry[j]; + SET16D(meta, pde->PD_State, + GET16D(meta, pde->PD_State) | + GET16D(src, pde->PD_State)); + } + } +} + +static void +ddf_meta_free(struct ddf_meta *meta) +{ + + if (meta->hdr != NULL) { + free(meta->hdr, M_MD_DDF); + meta->hdr = NULL; + } + if (meta->cdr != NULL) { + free(meta->cdr, M_MD_DDF); + meta->cdr = NULL; + } + if (meta->pdr != NULL) { + free(meta->pdr, M_MD_DDF); + meta->pdr = NULL; + } + if (meta->vdr != NULL) { + free(meta->vdr, M_MD_DDF); + meta->vdr = NULL; + } + if (meta->cr != NULL) { + free(meta->cr, M_MD_DDF); + meta->cr = NULL; + } + if (meta->pdd != NULL) { + free(meta->pdd, M_MD_DDF); + meta->pdd = NULL; + } + if (meta->bbm != NULL) { + free(meta->bbm, M_MD_DDF); + meta->bbm = NULL; + } +} + +static void +ddf_vol_meta_create(struct ddf_vol_meta *meta, struct ddf_meta *sample) +{ + struct timespec ts; + struct clocktime ct; + struct ddf_header *hdr; + u_int ss, size; + + hdr = sample->hdr; + meta->bigendian = sample->bigendian; + ss = meta->sectorsize = sample->sectorsize; + meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(meta->hdr, sample->hdr, ss); + meta->cdr = malloc(GET32(sample, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(meta->cdr, sample->cdr, GET32(sample, hdr->cd_length) * ss); + meta->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); + memset(meta->vde, 0xff, sizeof(struct ddf_vd_entry)); + getnanotime(&ts); + clock_ts_to_ct(&ts, &ct); + snprintf(meta->vde->VD_GUID, 25, "FreeBSD%04d%02d%02d%08x%01x", + ct.year, ct.mon, ct.day, + arc4random(), arc4random() & 0xf); + size = GET16(sample, hdr->Configuration_Record_Length) * ss; + meta->vdc = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->vdc, 0xff, size); + SET32(meta, vdc->Signature, DDF_VDCR_SIGNATURE); + memcpy(meta->vdc->VD_GUID, meta->vde->VD_GUID, 24); + SET32(meta, vdc->Sequence_Number, 0); +} + +static void +ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, uint8_t *GUID) +{ + struct ddf_header *hdr; + struct ddf_vd_entry *vde; + struct ddf_vdc_record *vdc; + int vnew, bvnew, bvd, size; + u_int ss; + + hdr = src->hdr; + vde = &src->vdr->entry[ddf_meta_find_vd(src, GUID)]; + vdc = ddf_meta_find_vdc(src, GUID); + bvd = GET8D(src, vdc->Secondary_Element_Seq); + size = GET16(src, hdr->Configuration_Record_Length) * src->sectorsize; + + if (dst->vdc == NULL || + ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, vdc->Sequence_Number))) > 0) + vnew = 1; + else + vnew = 0; + + if (dst->bvdc[bvd] == NULL || + ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, bvdc[bvd]->Sequence_Number))) > 0) + bvnew = 1; + else + bvnew = 0; + + if (vnew) { + dst->bigendian = src->bigendian; + ss = dst->sectorsize = src->sectorsize; + if (dst->hdr != NULL) + free(dst->hdr, M_MD_DDF); + dst->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(dst->hdr, src->hdr, ss); + if (dst->cdr != NULL) + free(dst->cdr, M_MD_DDF); + dst->cdr = malloc(GET32(src, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cdr, src->cdr, GET32(src, hdr->cd_length) * ss); + if (dst->vde != NULL) + free(dst->vde, M_MD_DDF); + dst->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); + memcpy(dst->vde, vde, sizeof(struct ddf_vd_entry)); + if (dst->vdc != NULL) + free(dst->vdc, M_MD_DDF); + dst->vdc = malloc(size, M_MD_DDF, M_WAITOK); + memcpy(dst->vdc, vdc, size); + } + if (bvnew) { + if (dst->bvdc[bvd] != NULL) + free(dst->bvdc[bvd], M_MD_DDF); + dst->bvdc[bvd] = malloc(size, M_MD_DDF, M_WAITOK); + memcpy(dst->bvdc[bvd], vdc, size); + } +} + +static void +ddf_vol_meta_free(struct ddf_vol_meta *meta) +{ + int i; + + if (meta->hdr != NULL) { + free(meta->hdr, M_MD_DDF); + meta->hdr = NULL; + } + if (meta->cdr != NULL) { + free(meta->cdr, M_MD_DDF); + meta->cdr = NULL; + } + if (meta->vde != NULL) { + free(meta->vde, M_MD_DDF); + meta->vde = NULL; + } + if (meta->vdc != NULL) { + free(meta->vdc, M_MD_DDF); + meta->vdc = NULL; + } + for (i = 0; i < DDF_MAX_DISKS_HARD; i++) { + if (meta->bvdc[i] != NULL) { + free(meta->bvdc[i], M_MD_DDF); + meta->bvdc[i] = NULL; + } + } +} + +static int +ddf_meta_unused_range(struct ddf_meta *meta, off_t *off, off_t *size) +{ + struct ddf_vdc_record *vdc; + off_t beg[32], end[32], beg1, end1; + uint64_t *offp; + int i, j, n, num, pos; + uint32_t ref; + + *off = 0; + *size = 0; + ref = GET32(meta, pdd->PD_Reference); + pos = ddf_meta_find_pd(meta, NULL, ref); + beg[0] = 0; + end[0] = GET64(meta, pdr->entry[pos].Configured_Size); + n = 1; + num = GET32(meta, hdr->cr_length) / + GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) + continue; + for (pos = 0; pos < GET16D(meta, vdc->Primary_Element_Count); pos++) + if (GET32D(meta, vdc->Physical_Disk_Sequence[pos]) == ref) + break; + if (pos == GET16D(meta, vdc->Primary_Element_Count)) + continue; + offp = (uint64_t *)&(vdc->Physical_Disk_Sequence[ + GET16(meta, hdr->Max_Primary_Element_Entries)]); + beg1 = GET64P(meta, offp + pos); + end1 = beg1 + GET64D(meta, vdc->Block_Count); + for (j = 0; j < n; j++) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 17:56:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FEB0106566B; Mon, 30 Apr 2012 17:56:50 +0000 (UTC) (envelope-from gleb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 296178FC1B; Mon, 30 Apr 2012 17: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 q3UHuovr077309; Mon, 30 Apr 2012 17:56:50 GMT (envelope-from gleb@svn.freebsd.org) Received: (from gleb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UHun8G077305; Mon, 30 Apr 2012 17:56:49 GMT (envelope-from gleb@svn.freebsd.org) Message-Id: <201204301756.q3UHun8G077305@svn.freebsd.org> From: Gleb Kurtsou Date: Mon, 30 Apr 2012 17:56:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234849 - stable/9/sys/fs/tmpfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 17:56:50 -0000 Author: gleb Date: Mon Apr 30 17:56:49 2012 New Revision: 234849 URL: http://svn.freebsd.org/changeset/base/234849 Log: MFC r233998-r234000 and r234325: r233998: Add reserved memory limit sysctl to tmpfs. Cleanup availble and used memory functions. Check if free pages available before allocating new node. r233999 (partial): Add vfs_getopt_size. Support human readable file system options in tmpfs. Increase maximum tmpfs file system size to 4GB*PAGE_SIZE on 32 bit archs. NOTE: To preserve KBI add tmpfs_getopt_size function instead of global vfs_getopt_size. r234000: tmpfs supports only INT_MAX nodes due to limitations of unit number allocator. Replace UINT32_MAX checks with INT_MAX. Keeping more than 2^31 nodes in memory is not likely to become possible in foreseeable feature and would require new unit number allocator. r234325: Provide better description for vfs.tmpfs.memory_reserved sysctl. Modified: stable/9/sys/fs/tmpfs/tmpfs.h stable/9/sys/fs/tmpfs/tmpfs_subr.c stable/9/sys/fs/tmpfs/tmpfs_vfsops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/tmpfs/tmpfs.h ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs.h Mon Apr 30 17:53:02 2012 (r234848) +++ stable/9/sys/fs/tmpfs/tmpfs.h Mon Apr 30 17:56:49 2012 (r234849) @@ -337,11 +337,10 @@ struct tmpfs_mount { * system, set during mount time. This variable must never be * used directly as it may be bigger than the current amount of * free memory; in the extreme case, it will hold the SIZE_MAX - * value. Instead, use the TMPFS_PAGES_MAX macro. */ + * value. */ size_t tm_pages_max; - /* Number of pages in use by the file system. Cannot be bigger - * than the value returned by TMPFS_PAGES_MAX in any case. */ + /* Number of pages in use by the file system. */ size_t tm_pages_used; /* Pointer to the node representing the root directory of this @@ -486,57 +485,15 @@ int tmpfs_truncate(struct vnode *, off_t * Memory management stuff. */ -/* Amount of memory pages to reserve for the system (e.g., to not use by - * tmpfs). - * XXX: Should this be tunable through sysctl, for instance? */ -#define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE) - /* - * Returns information about the number of available memory pages, - * including physical and virtual ones. - * - * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid - * excessive memory usage. - * + * Amount of memory pages to reserve for the system (e.g., to not use by + * tmpfs). */ -static __inline size_t -tmpfs_mem_info(void) -{ - - return (swap_pager_avail + cnt.v_free_count + cnt.v_cache_count); -} - -/* Returns the maximum size allowed for a tmpfs file system. This macro - * must be used instead of directly retrieving the value from tm_pages_max. - * The reason is that the size of a tmpfs file system is dynamic: it lets - * the user store files as long as there is enough free memory (including - * physical memory and swap space). Therefore, the amount of memory to be - * used is either the limit imposed by the user during mount time or the - * amount of available memory, whichever is lower. To avoid consuming all - * the memory for a given mount point, the system will always reserve a - * minimum of TMPFS_PAGES_RESERVED pages, which is also taken into account - * by this macro (see above). */ -static __inline size_t -TMPFS_PAGES_MAX(struct tmpfs_mount *tmp) -{ - size_t freepages; +#define TMPFS_PAGES_MINRESERVED (4 * 1024 * 1024 / PAGE_SIZE) - freepages = tmpfs_mem_info(); - freepages -= freepages < TMPFS_PAGES_RESERVED ? - freepages : TMPFS_PAGES_RESERVED; - - return MIN(tmp->tm_pages_max, freepages + tmp->tm_pages_used); -} +size_t tmpfs_mem_avail(void); -/* Returns the available space for the given file system. */ -#define TMPFS_META_PAGES(tmp) (howmany((tmp)->tm_nodes_inuse * (sizeof(struct tmpfs_node) \ - + sizeof(struct tmpfs_dirent)), PAGE_SIZE)) -#define TMPFS_FILE_PAGES(tmp) ((tmp)->tm_pages_used) - -#define TMPFS_PAGES_AVAIL(tmp) (TMPFS_PAGES_MAX(tmp) > \ - TMPFS_META_PAGES(tmp)+TMPFS_FILE_PAGES(tmp)? \ - TMPFS_PAGES_MAX(tmp) - TMPFS_META_PAGES(tmp) \ - - TMPFS_FILE_PAGES(tmp):0) +size_t tmpfs_pages_used(struct tmpfs_mount *tmp); #endif Modified: stable/9/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs_subr.c Mon Apr 30 17:53:02 2012 (r234848) +++ stable/9/sys/fs/tmpfs/tmpfs_subr.c Mon Apr 30 17:56:49 2012 (r234849) @@ -58,6 +58,70 @@ __FBSDID("$FreeBSD$"); SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, "tmpfs file system"); +static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED; + +static int +sysctl_mem_reserved(SYSCTL_HANDLER_ARGS) +{ + int error; + long pages, bytes; + + pages = *(long *)arg1; + bytes = pages * PAGE_SIZE; + + error = sysctl_handle_long(oidp, &bytes, 0, req); + if (error || !req->newptr) + return (error); + + pages = bytes / PAGE_SIZE; + if (pages < TMPFS_PAGES_MINRESERVED) + return (EINVAL); + + *(long *)arg1 = pages; + return (0); +} + +SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW, + &tmpfs_pages_reserved, 0, sysctl_mem_reserved, "L", + "Amount of available memory and swap below which tmpfs growth stops"); + +size_t +tmpfs_mem_avail(void) +{ + vm_ooffset_t avail; + + avail = swap_pager_avail + cnt.v_free_count + cnt.v_cache_count - + tmpfs_pages_reserved; + if (__predict_false(avail < 0)) + avail = 0; + return (avail); +} + +size_t +tmpfs_pages_used(struct tmpfs_mount *tmp) +{ + const size_t node_size = sizeof(struct tmpfs_node) + + sizeof(struct tmpfs_dirent); + size_t meta_pages; + + meta_pages = howmany((uintmax_t)tmp->tm_nodes_inuse * node_size, + PAGE_SIZE); + return (meta_pages + tmp->tm_pages_used); +} + +static size_t +tmpfs_pages_check_avail(struct tmpfs_mount *tmp, size_t req_pages) +{ + if (tmpfs_mem_avail() < req_pages) + return (0); + + if (tmp->tm_pages_max != SIZE_MAX && + tmp->tm_pages_max < req_pages + tmpfs_pages_used(tmp)) + return (0); + + return (1); +} + /* --------------------------------------------------------------------- */ /* @@ -98,6 +162,8 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp if (tmp->tm_nodes_inuse >= tmp->tm_nodes_max) return (ENOSPC); + if (tmpfs_pages_check_avail(tmp, 1) == 0) + return (ENOSPC); nnode = (struct tmpfs_node *)uma_zalloc_arg( tmp->tm_node_pool, tmp, M_WAITOK); @@ -916,7 +982,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t MPASS(oldpages == uobj->size); newpages = OFF_TO_IDX(newsize + PAGE_MASK); if (newpages > oldpages && - newpages - oldpages > TMPFS_PAGES_AVAIL(tmp)) + tmpfs_pages_check_avail(tmp, newpages - oldpages) == 0) return (ENOSPC); TMPFS_LOCK(tmp); Modified: stable/9/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs_vfsops.c Mon Apr 30 17:53:02 2012 (r234848) +++ stable/9/sys/fs/tmpfs/tmpfs_vfsops.c Mon Apr 30 17:56:49 2012 (r234849) @@ -85,6 +85,49 @@ static const char *tmpfs_opts[] = { /* --------------------------------------------------------------------- */ static int +tmpfs_getopt_size(struct vfsoptlist *opts, const char *name, off_t *value) +{ + char *opt_value, *vtp; + quad_t iv; + int error, opt_len; + + error = vfs_getopt(opts, name, (void **)&opt_value, &opt_len); + if (error != 0) + return (error); + if (opt_len == 0 || opt_value == NULL) + return (EINVAL); + if (opt_value[0] == '\0' || opt_value[opt_len - 1] != '\0') + return (EINVAL); + iv = strtoq(opt_value, &vtp, 0); + if (vtp == opt_value || (vtp[0] != '\0' && vtp[1] != '\0')) + return (EINVAL); + if (iv < 0) + return (EINVAL); + switch (vtp[0]) { + case 't': + case 'T': + iv *= 1024; + case 'g': + case 'G': + iv *= 1024; + case 'm': + case 'M': + iv *= 1024; + case 'k': + case 'K': + iv *= 1024; + case '\0': + break; + default: + return (EINVAL); + } + *value = iv; + + return (0); +} + + +static int tmpfs_node_ctor(void *mem, int size, void *arg, int flags) { struct tmpfs_node *node = (struct tmpfs_node *)mem; @@ -130,14 +173,14 @@ tmpfs_node_fini(void *mem, int size) static int tmpfs_mount(struct mount *mp) { + const size_t nodes_per_page = howmany(PAGE_SIZE, + sizeof(struct tmpfs_dirent) + sizeof(struct tmpfs_node)); struct tmpfs_mount *tmp; struct tmpfs_node *root; - size_t pages; - uint32_t nodes; int error; /* Size counters. */ - u_int nodes_max; - u_quad_t size_max, maxfilesize; + u_quad_t pages; + off_t nodes_max, size_max, maxfilesize; /* Root node attributes. */ uid_t root_uid; @@ -171,46 +214,47 @@ tmpfs_mount(struct mount *mp) if (mp->mnt_cred->cr_ruid != 0 || vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1) root_mode = va.va_mode; - if (vfs_scanopt(mp->mnt_optnew, "inodes", "%u", &nodes_max) != 1) + if (tmpfs_getopt_size(mp->mnt_optnew, "inodes", &nodes_max) != 0) nodes_max = 0; - if (vfs_scanopt(mp->mnt_optnew, "size", "%qu", &size_max) != 1) + if (tmpfs_getopt_size(mp->mnt_optnew, "size", &size_max) != 0) size_max = 0; - if (vfs_scanopt(mp->mnt_optnew, "maxfilesize", "%qu", - &maxfilesize) != 1) + if (tmpfs_getopt_size(mp->mnt_optnew, "maxfilesize", &maxfilesize) != 0) maxfilesize = 0; /* Do not allow mounts if we do not have enough memory to preserve * the minimum reserved pages. */ - if (tmpfs_mem_info() < TMPFS_PAGES_RESERVED) + if (tmpfs_mem_avail() < TMPFS_PAGES_MINRESERVED) return ENOSPC; /* Get the maximum number of memory pages this file system is * allowed to use, based on the maximum size the user passed in * the mount structure. A value of zero is treated as if the * maximum available space was requested. */ - if (size_max < PAGE_SIZE || size_max > SIZE_MAX - PAGE_SIZE) + if (size_max < PAGE_SIZE || size_max > OFF_MAX - PAGE_SIZE || + (SIZE_MAX < OFF_MAX && size_max / PAGE_SIZE >= SIZE_MAX)) pages = SIZE_MAX; else pages = howmany(size_max, PAGE_SIZE); MPASS(pages > 0); if (nodes_max <= 3) { - if (pages > UINT32_MAX - 3) - nodes = UINT32_MAX; + if (pages < INT_MAX / nodes_per_page) + nodes_max = pages * nodes_per_page; else - nodes = pages + 3; - } else - nodes = nodes_max; - MPASS(nodes >= 3); + nodes_max = INT_MAX; + } + if (nodes_max > INT_MAX) + nodes_max = INT_MAX; + MPASS(nodes_max >= 3); /* Allocate the tmpfs mount structure and fill it. */ tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount), M_TMPFSMNT, M_WAITOK | M_ZERO); mtx_init(&tmp->allnode_lock, "tmpfs allnode lock", NULL, MTX_DEF); - tmp->tm_nodes_max = nodes; + tmp->tm_nodes_max = nodes_max; tmp->tm_nodes_inuse = 0; - tmp->tm_maxfilesize = maxfilesize > 0 ? maxfilesize : UINT64_MAX; + tmp->tm_maxfilesize = maxfilesize > 0 ? maxfilesize : OFF_MAX; LIST_INIT(&tmp->tm_nodes_used); tmp->tm_pages_max = pages; @@ -380,22 +424,30 @@ tmpfs_fhtovp(struct mount *mp, struct fi static int tmpfs_statfs(struct mount *mp, struct statfs *sbp) { - fsfilcnt_t freenodes; struct tmpfs_mount *tmp; + size_t used; tmp = VFS_TO_TMPFS(mp); sbp->f_iosize = PAGE_SIZE; sbp->f_bsize = PAGE_SIZE; - sbp->f_blocks = TMPFS_PAGES_MAX(tmp); - sbp->f_bavail = sbp->f_bfree = TMPFS_PAGES_AVAIL(tmp); - - freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_inuse, - TMPFS_PAGES_AVAIL(tmp) * PAGE_SIZE / sizeof(struct tmpfs_node)); - - sbp->f_files = freenodes + tmp->tm_nodes_inuse; - sbp->f_ffree = freenodes; + used = tmpfs_pages_used(tmp); + if (tmp->tm_pages_max != SIZE_MAX) + sbp->f_blocks = tmp->tm_pages_max; + else + sbp->f_blocks = used + tmpfs_mem_avail(); + if (sbp->f_blocks <= used) + sbp->f_bavail = 0; + else + sbp->f_bavail = sbp->f_blocks - used; + sbp->f_bfree = sbp->f_bavail; + used = tmp->tm_nodes_inuse; + sbp->f_files = tmp->tm_nodes_max; + if (sbp->f_files <= used) + sbp->f_ffree = 0; + else + sbp->f_ffree = sbp->f_files - used; /* sbp->f_owner = tmp->tn_uid; */ return 0; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 21:02:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7F93B106564A; Mon, 30 Apr 2012 21:02:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3C08FC0A; Mon, 30 Apr 2012 21:02: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 q3UL2wT3085000; Mon, 30 Apr 2012 21:02:58 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UL2wnD084998; Mon, 30 Apr 2012 21:02:58 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302102.q3UL2wnD084998@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 21:02: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: r234850 - head/usr.bin/m4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 21:02:58 -0000 Author: bapt Date: Mon Apr 30 21:02:57 2012 New Revision: 234850 URL: http://svn.freebsd.org/changeset/base/234850 Log: Respect mathematical operation order piority with the exponent gnu extension Obtained from: OpenBSD Approved by: des (mentor) Modified: head/usr.bin/m4/parser.y Modified: head/usr.bin/m4/parser.y ============================================================================== --- head/usr.bin/m4/parser.y Mon Apr 30 17:56:49 2012 (r234849) +++ head/usr.bin/m4/parser.y Mon Apr 30 21:02:57 2012 (r234850) @@ -17,8 +17,8 @@ * * $FreeBSD$ */ -#include #include +#include #define YYSTYPE int32_t extern int32_t end_result; extern int yylex(void); @@ -35,9 +35,9 @@ extern int yyparse(void); %left EQ NE %left '<' LE '>' GE %left LSHIFT RSHIFT -%right EXPONENT %left '+' '-' %left '*' '/' '%' +%right EXPONENT %right UMINUS UPLUS '!' '~' %% From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 21:26:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EDBB106564A; Mon, 30 Apr 2012 21:26:36 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 486CB8FC0C; Mon, 30 Apr 2012 21:26: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 q3ULQaHf085889; Mon, 30 Apr 2012 21:26:36 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3ULQac3085886; Mon, 30 Apr 2012 21:26:36 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302126.q3ULQac3085886@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 21:26: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: r234851 - in head: libexec/rtld-elf share/man/man5 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 21:26:36 -0000 Author: bapt Date: Mon Apr 30 21:26:35 2012 New Revision: 234851 URL: http://svn.freebsd.org/changeset/base/234851 Log: Add two special directives to libmap.conf: include : Parse the contents of file before continuing with the current file. includedir : Parse the contents of every file in dir that ends in .conf before continuing with the current file. Any file or directory encountered while processing include or includedir directives will be parsed exactly once, even if it is encountered multiple times. Reviewed by: kib, des Approved by: des (mentor) MFC after: 1 month Modified: head/libexec/rtld-elf/libmap.c head/share/man/man5/libmap.conf.5 Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Mon Apr 30 21:02:57 2012 (r234850) +++ head/libexec/rtld-elf/libmap.c Mon Apr 30 21:26:35 2012 (r234851) @@ -2,11 +2,13 @@ * $FreeBSD$ */ +#include #include #include #include #include #include +#include #include #include #include @@ -39,9 +41,17 @@ struct lmp { TAILQ_ENTRY(lmp) lmp_link; }; +static TAILQ_HEAD(lmc_list, lmc) lmc_head = TAILQ_HEAD_INITIALIZER(lmc_head); +struct lmc { + char *path; + TAILQ_ENTRY(lmc) next; +}; + static int lm_count; static void lmc_parse(char *, size_t); +static void lmc_parse_file(char *); +static void lmc_parse_dir(char *); static void lm_add(const char *, const char *, const char *); static void lm_free(struct lm_list *); static char *lml_find(struct lm_list *, const char *); @@ -61,37 +71,13 @@ static const char *quickbasename(const c int lm_init(char *libmap_override) { - struct stat st; - char *lm_map, *p; - int fd; + char *p; dbg("lm_init(\"%s\")", libmap_override); TAILQ_INIT(&lmp_head); - fd = open(_PATH_LIBMAP_CONF, O_RDONLY); - if (fd == -1) { - dbg("lm_init: open(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - if (fstat(fd, &st) == -1) { - close(fd); - dbg("lm_init: fstat(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (lm_map == (const char *)MAP_FAILED) { - close(fd); - dbg("lm_init: mmap(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - close(fd); - lmc_parse(lm_map, st.st_size); - munmap(lm_map, st.st_size); + lmc_parse_file(_PATH_LIBMAP_CONF); -override: if (libmap_override) { /* * Do some character replacement to make $LIBMAP look @@ -116,14 +102,116 @@ override: } static void +lmc_parse_file(char *path) +{ + struct lmc *p; + struct stat st; + int fd; + char *rpath; + char *lm_map; + + rpath = realpath(path, NULL); + if (rpath == NULL) + return; + + TAILQ_FOREACH(p, &lmc_head, next) { + if (strcmp(p->path, rpath) == 0) { + free(rpath); + return; + } + } + + fd = open(path, O_RDONLY); + if (fd == -1) { + dbg("lm_init: open(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + if (fstat(fd, &st) == -1) { + close(fd); + dbg("lm_init: fstat(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (lm_map == (const char *)MAP_FAILED) { + close(fd); + dbg("lm_init: mmap(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + close(fd); + p = xmalloc(sizeof(struct lmc)); + p->path = rpath; + TAILQ_INSERT_HEAD(&lmc_head, p, next); + lmc_parse(lm_map, st.st_size); + munmap(lm_map, st.st_size); +} + +static void +lmc_parse_dir(char *idir) +{ + DIR *d; + struct dirent *dp; + struct lmc *p; + char conffile[MAXPATHLEN]; + char *ext; + char *rpath; + + rpath = realpath(idir, NULL); + if (rpath == NULL) + return; + + TAILQ_FOREACH(p, &lmc_head, next) { + if (strcmp(p->path, rpath) == 0) { + free(rpath); + return; + } + } + d = opendir(idir); + if (d == NULL) { + free(rpath); + return; + } + + p = xmalloc(sizeof(struct lmc)); + p->path = rpath; + TAILQ_INSERT_HEAD(&lmc_head, p, next); + + while ((dp = readdir(d)) != NULL) { + if (dp->d_ino == 0) + continue; + if (dp->d_type != DT_REG) + continue; + ext = strrchr(dp->d_name, '.'); + if (ext == NULL) + continue; + if (strcmp(ext, ".conf") != 0) + continue; + if (strlcpy(conffile, idir, MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + if (strlcat(conffile, "/", MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + if (strlcat(conffile, dp->d_name, MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + lmc_parse_file(conffile); + } + closedir(d); +} + +static void lmc_parse(char *lm_p, size_t lm_len) { char *cp, *f, *t, *c, *p; char prog[MAXPATHLEN]; - char line[MAXPATHLEN + 2]; + /* allow includedir + full length path */ + char line[MAXPATHLEN + 13]; size_t cnt; int i; - + cnt = 0; p = NULL; while (cnt < lm_len) { @@ -181,7 +269,8 @@ lmc_parse(char *lm_p, size_t lm_len) while(rtld_isspace(*cp)) cp++; if (!iseol(*cp)) continue; - strcpy(prog, c); + if (strlcpy(prog, c, sizeof prog) >= sizeof prog) + continue; p = prog; continue; } @@ -207,7 +296,12 @@ lmc_parse(char *lm_p, size_t lm_len) if (!iseol(*cp)) continue; *cp = '\0'; - lm_add(p, f, t); + if (strcmp(f, "includedir") == 0) + lmc_parse_dir(t); + else if (strcmp(f, "include") == 0) + lmc_parse_file(t); + else + lm_add(p, f, t); } } @@ -232,9 +326,17 @@ void lm_fini (void) { struct lmp *lmp; + struct lmc *p; dbg("%s()", __func__); + while (!TAILQ_EMPTY(&lmc_head)) { + p = TAILQ_FIRST(&lmc_head); + TAILQ_REMOVE(&lmc_head, p, next); + free(p->path); + free(p); + } + while (!TAILQ_EMPTY(&lmp_head)) { lmp = TAILQ_FIRST(&lmp_head); TAILQ_REMOVE(&lmp_head, lmp, lmp_link); Modified: head/share/man/man5/libmap.conf.5 ============================================================================== --- head/share/man/man5/libmap.conf.5 Mon Apr 30 21:02:57 2012 (r234850) +++ head/share/man/man5/libmap.conf.5 Mon Apr 30 21:26:35 2012 (r234851) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 31, 2004 +.Dd April 28, 2012 .Dt LIBMAP.CONF 5 .Os .Sh NAME @@ -43,6 +43,27 @@ left hand side containing the mapping ca side containing the mapping. Dependencies are matched against candidates and replaced with the mappings. .Pp +Two special directives are available: +.Bl -tag -width indent +.It Cm include Ar file +Parse the contents of +.Ar file +before continuing with the current file. +.It Cm includedir Ar dir +Parse the contents of every file in +.Ar dir +that ends in +.Pa .conf +before continuing with the current file. +.El +.Pp +Any file or directory encountered while processing +.Cm include +or +.Cm includedir +directives will be parsed exactly once, even if it is encountered +multiple times. +.Pp Constrained mappings may be specified by enclosing the name of the executable or library in brackets. All mappings following a constraint will only be evaluated for that constraint. From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 22:00:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EC20E1065676; Mon, 30 Apr 2012 22:00:35 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5CF98FC15; Mon, 30 Apr 2012 22:00: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 q3UM0Z8l087252; Mon, 30 Apr 2012 22:00:35 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UM0Zwm087217; Mon, 30 Apr 2012 22:00:35 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302200.q3UM0Zwm087217@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 22:00: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: r234852 - head/tools/regression/usr.bin/m4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:00:36 -0000 Author: bapt Date: Mon Apr 30 22:00:34 2012 New Revision: 234852 URL: http://svn.freebsd.org/changeset/base/234852 Log: Import m4 regression tests from OpenBSD Obtained from: OpenBSD Approved by: des (mentor) Added: head/tools/regression/usr.bin/m4/args.m4 (contents, props changed) head/tools/regression/usr.bin/m4/args2.m4 (contents, props changed) head/tools/regression/usr.bin/m4/comments.m4 (contents, props changed) head/tools/regression/usr.bin/m4/esyscmd.m4 (contents, props changed) head/tools/regression/usr.bin/m4/eval.m4 (contents, props changed) head/tools/regression/usr.bin/m4/ff_after_dnl.m4.uu (contents, props changed) head/tools/regression/usr.bin/m4/gnueval.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnuformat.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnupatterns.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnupatterns2.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnuprefix.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnusofterror.m4 (contents, props changed) head/tools/regression/usr.bin/m4/includes.aux (contents, props changed) head/tools/regression/usr.bin/m4/includes.m4 (contents, props changed) head/tools/regression/usr.bin/m4/m4wrap3.m4 (contents, props changed) head/tools/regression/usr.bin/m4/patterns.m4 (contents, props changed) head/tools/regression/usr.bin/m4/quotes.m4 (contents, props changed) head/tools/regression/usr.bin/m4/redef.m4 (contents, props changed) head/tools/regression/usr.bin/m4/regress.args.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.args2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.comments.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.esyscmd.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.eval.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnueval.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnuformat.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnupatterns.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnupatterns2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnuprefix.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnusofterror.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnutranslit2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.includes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.m4wrap3.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.patterns.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.quotes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.redef.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.strangequotes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.translit.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.translit2.out (contents, props changed) head/tools/regression/usr.bin/m4/strangequotes.m4.uu (contents, props changed) head/tools/regression/usr.bin/m4/translit.m4 (contents, props changed) head/tools/regression/usr.bin/m4/translit2.m4 (contents, props changed) Deleted: head/tools/regression/usr.bin/m4/regress.changecom.in head/tools/regression/usr.bin/m4/regress.changecom.out head/tools/regression/usr.bin/m4/regress.gchangecom.out Modified: head/tools/regression/usr.bin/m4/Makefile head/tools/regression/usr.bin/m4/regress.sh Modified: head/tools/regression/usr.bin/m4/Makefile ============================================================================== --- head/tools/regression/usr.bin/m4/Makefile Mon Apr 30 21:26:35 2012 (r234851) +++ head/tools/regression/usr.bin/m4/Makefile Mon Apr 30 22:00:34 2012 (r234852) @@ -1,4 +1,4 @@ # $FreeBSD$ all: - @sh ${.CURDIR}/regress.sh ${.CURDIR} + @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR} Added: head/tools/regression/usr.bin/m4/args.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/args.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,9 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/args.m4,v 1.1 2001/10/10 23:23:59 espie Exp $ +dnl Expanding all arguments +define(`A', `first form: $@, second form $*')dnl +define(`B', `C')dnl +A(1,2,`B') +dnl indirection means macro can get called with argc == 2 ! +indir(`A',1,2,`B') +indir(`A') Added: head/tools/regression/usr.bin/m4/args2.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/args2.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,5 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/args2.m4,v 1.1 2008/08/16 09:57:12 espie Exp $ +dnl Preserving spaces within nested parentheses +define(`foo',`$1')dnl +foo(( check for embedded spaces)) Added: head/tools/regression/usr.bin/m4/comments.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/comments.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,59 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/comments.m4,v 1.1 2005/09/06 15:33:21 espie Exp $ +dnl checking the way changecom works. +1: normal +define(`comment', `COMMENT')dnl +define(`p', 'XXX')dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +2: `changecom(>>)dnl' +changecom(>>)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +3: `changecom dnl' +changecom dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +4: `changecom()dnl' +changecom()dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +5: `changecom(,)dnl' +changecom(,)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +6: `changecom(`p',q)dnl' +changecom(`p',q)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +7: `changecom(`p')dnl' +changecom(`p')dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +8: `changecom(#)dnl' +changecom(#)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too Added: head/tools/regression/usr.bin/m4/esyscmd.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/esyscmd.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,43 @@ +dnl $FreeBSD$ +changequote(`{',`}')dnl +dnl +esyscmd({sh -c "m4<>>') +patsubst(`# This is a line to zap +# and a second line +keep this one', `^ *#.* +') +dnl Special case: empty regexp +patsubst(`empty regexp',`',`a ') Added: head/tools/regression/usr.bin/m4/quotes.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/quotes.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,58 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/quotes.m4,v 1.2 2005/09/06 15:33:21 espie Exp $ +dnl Checking the way changequote() is supposed to work +define(`string',`STRING')dnl +1: normal +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +2: kill quotes +changequote()dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +3: normal changed quote +changequote([,])dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +4: empty quotes, kill them too +changequote(,)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +5: start quote only +changequote(`)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +6: normal quotes are back +changequote +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +7: start quote+empty end quote +changequote([,)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' Added: head/tools/regression/usr.bin/m4/redef.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/redef.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,17 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/redef.m4,v 1.2 2001/09/27 22:40:58 espie Exp $ +dnl check all properties of builtin are passed on, including args behavior +define(`mybuiltin',defn(`builtin'))dnl +builtin mybuiltin +define(`mydefine',defn(`define'))dnl +mydefine(`mydefn',defn(`defn'))dnl +mydefine(`myundefine',mydefn(`undefine'))dnl +myundefine(`defn')dnl +myundefine(`define')dnl +myundefine(`undefine')dnl +mydefine(`mydef2',mydefn(`mydefine'))dnl +mydefine(`mydef', mydefn(`define'))dnl +myundefine(`mydefine')dnl +mydef2(`A',`B')dnl +mydef(`C',`D')dnl +A C Added: head/tools/regression/usr.bin/m4/regress.args.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.args.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +first form: 1,2,B, second form 1,2,C +first form: 1,2,B, second form 1,2,C +first form: , second form Added: head/tools/regression/usr.bin/m4/regress.args2.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.args2.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +( check for embedded spaces) Added: head/tools/regression/usr.bin/m4/regress.comments.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.comments.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,47 @@ +1: normal +# this is a comment +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +2: changecom(>>)dnl +# this is a COMMENT +>> this is a comment +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +3: changecom dnl + # this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +4: changecom()dnl +# this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +5: changecom(,)dnl +# this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +6: changecom(`p',q)dnl +# this is a COMMENT +>> this is a COMMENT +p this is a comment +p this is a comment q COMMENT too + +7: changecom(`p')dnl +# this is a COMMENT +>> this is a COMMENT +p this is a comment +p this is a comment q comment too + +8: changecom(#)dnl +# this is a comment +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too Added: head/tools/regression/usr.bin/m4/regress.esyscmd.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.esyscmd.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,578 @@ + + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + Added: head/tools/regression/usr.bin/m4/regress.eval.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.eval.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +96 +255 +1 Added: head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,2 @@ + THIS SHOULD SHOW UP (LINE 1) + THIS SHOULD SHOW UP (LINE 5) Added: head/tools/regression/usr.bin/m4/regress.gnueval.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnueval.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +65536 +48 +-64 Added: head/tools/regression/usr.bin/m4/regress.gnuformat.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnuformat.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +a stringa%bpouet bctoolongcdtoolong2d Added: head/tools/regression/usr.bin/m4/regress.gnupatterns.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnupatterns.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +string with a minus to replace with a minus +string with b to replbce with b b +minusstring with a starting + to replace with a minus Added: head/tools/regression/usr.bin/m4/regress.gnupatterns2.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnupatterns2.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +acosl asinl atanl cosl sinl tanl coshl sinhl tanhl Added: head/tools/regression/usr.bin/m4/regress.gnuprefix.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 22:03:43 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE7E5106566B; Mon, 30 Apr 2012 22:03:43 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D98698FC0C; Mon, 30 Apr 2012 22:03:43 +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 q3UM3hAf087397; Mon, 30 Apr 2012 22:03:43 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UM3hBg087395; Mon, 30 Apr 2012 22:03:43 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201204302203.q3UM3hBg087395@svn.freebsd.org> From: Dmitry Morozovsky Date: Mon, 30 Apr 2012 22:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234853 - stable/9/sbin/fdisk X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:03:44 -0000 Author: marck (doc committer) Date: Mon Apr 30 22:03:43 2012 New Revision: 234853 URL: http://svn.freebsd.org/changeset/base/234853 Log: MFC r234345: VMware environment is frequent nowadays. Add VMFS id. Modified: stable/9/sbin/fdisk/fdisk.c Directory Properties: stable/9/sbin/fdisk/ (props changed) Modified: stable/9/sbin/fdisk/fdisk.c ============================================================================== --- stable/9/sbin/fdisk/fdisk.c Mon Apr 30 22:00:34 2012 (r234852) +++ stable/9/sbin/fdisk/fdisk.c Mon Apr 30 22:03:43 2012 (r234853) @@ -218,6 +218,7 @@ static const char *const part_types[256] [0xF1] = "SpeedStor", [0xF2] = "DOS 3.3+ Secondary", [0xF4] = "SpeedStor large partition", + [0xFB] = "VMware VMFS", [0xFE] = "SpeedStor >1024 cyl. or LANstep", [0xFF] = "Xenix bad blocks table", }; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 22:06:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 76361106566C; Mon, 30 Apr 2012 22:06:48 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 611678FC1A; Mon, 30 Apr 2012 22:06:48 +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 q3UM6m7g087552; Mon, 30 Apr 2012 22:06:48 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UM6mxA087550; Mon, 30 Apr 2012 22:06:48 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201204302206.q3UM6mxA087550@svn.freebsd.org> From: Dmitry Morozovsky Date: Mon, 30 Apr 2012 22:06:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234854 - stable/8/sbin/fdisk X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:06:48 -0000 Author: marck (doc committer) Date: Mon Apr 30 22:06:47 2012 New Revision: 234854 URL: http://svn.freebsd.org/changeset/base/234854 Log: MFC r234345: VMware environment is frequent nowadays. Add VMFS id. Modified: stable/8/sbin/fdisk/fdisk.c Directory Properties: stable/8/sbin/fdisk/ (props changed) Modified: stable/8/sbin/fdisk/fdisk.c ============================================================================== --- stable/8/sbin/fdisk/fdisk.c Mon Apr 30 22:03:43 2012 (r234853) +++ stable/8/sbin/fdisk/fdisk.c Mon Apr 30 22:06:47 2012 (r234854) @@ -215,6 +215,7 @@ static const char *const part_types[256] [0xF1] = "SpeedStor", [0xF2] = "DOS 3.3+ Secondary", [0xF4] = "SpeedStor large partition", + [0xFB] = "VMware VMFS", [0xFE] = "SpeedStor >1024 cyl. or LANstep", [0xFF] = "Xenix bad blocks table", }; From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 22:46:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 415B4106566C; Mon, 30 Apr 2012 22:46:10 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 133658FC08; Mon, 30 Apr 2012 22:46:10 +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 q3UMk9TL089027; Mon, 30 Apr 2012 22:46:09 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UMk9L5089025; Mon, 30 Apr 2012 22:46:09 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201204302246.q3UMk9L5089025@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Mon, 30 Apr 2012 22:46:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234855 - head/contrib/gcc/config/mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:46:10 -0000 Author: gonzo Date: Mon Apr 30 22:46:09 2012 New Revision: 234855 URL: http://svn.freebsd.org/changeset/base/234855 Log: Unbreak jemalloc build with MALLOC_PRODUCTION set. New jemalloc version uncovered MIPS-related gcc bug described in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33256 The patch was obtained from r128198 in gcc-4_1-branch, which is GPLv2, so it's OK to merge it. Modified: head/contrib/gcc/config/mips/mips.c Modified: head/contrib/gcc/config/mips/mips.c ============================================================================== --- head/contrib/gcc/config/mips/mips.c Mon Apr 30 22:06:47 2012 (r234854) +++ head/contrib/gcc/config/mips/mips.c Mon Apr 30 22:46:09 2012 (r234855) @@ -1297,6 +1297,20 @@ mips_split_const (rtx x, rtx *base, HOST *base = x; } +/* Classify symbolic expression X, given that it appears in context + CONTEXT. */ + +static enum mips_symbol_type +mips_classify_symbolic_expression (rtx x) +{ + HOST_WIDE_INT offset; + + mips_split_const (x, &x, &offset); + if (UNSPEC_ADDRESS_P (x)) + return UNSPEC_ADDRESS_TYPE (x); + + return mips_classify_symbol (x); +} /* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points to the same object as SYMBOL, or to the same object_block. */ @@ -1534,8 +1548,17 @@ mips_classify_address (struct mips_addre info->type = ADDRESS_LO_SUM; info->reg = XEXP (x, 0); info->offset = XEXP (x, 1); + /* We have to trust the creator of the LO_SUM to do something vaguely + sane. Target-independent code that creates a LO_SUM should also + create and verify the matching HIGH. Target-independent code that + adds an offset to a LO_SUM must prove that the offset will not + induce a carry. Failure to do either of these things would be + a bug, and we are not required to check for it here. The MIPS + backend itself should only create LO_SUMs for valid symbolic + constants, with the high part being either a HIGH or a copy + of _gp. */ + info->symbol_type = mips_classify_symbolic_expression (info->offset); return (mips_valid_base_register_p (info->reg, mode, strict) - && mips_symbolic_constant_p (info->offset, &info->symbol_type) && mips_symbolic_address_p (info->symbol_type, mode) && mips_lo_relocs[info->symbol_type] != 0); @@ -5671,7 +5694,8 @@ print_operand_reloc (FILE *file, rtx op, rtx base; HOST_WIDE_INT offset; - if (!mips_symbolic_constant_p (op, &symbol_type) || relocs[symbol_type] == 0) + symbol_type = mips_classify_symbolic_expression (op); + if (relocs[symbol_type] == 0) fatal_insn ("PRINT_OPERAND, invalid operand for relocation", op); /* If OP uses an UNSPEC address, we want to print the inner symbol. */ From owner-svn-src-all@FreeBSD.ORG Mon Apr 30 23:12:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1B93106564A; Mon, 30 Apr 2012 23:12:16 +0000 (UTC) (envelope-from rmh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D0758FC15; Mon, 30 Apr 2012 23:12:16 +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 q3UNCGQd089974; Mon, 30 Apr 2012 23:12:16 GMT (envelope-from rmh@svn.freebsd.org) Received: (from rmh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UNCG8p089972; Mon, 30 Apr 2012 23:12:16 GMT (envelope-from rmh@svn.freebsd.org) Message-Id: <201204302312.q3UNCG8p089972@svn.freebsd.org> From: Robert Millan Date: Mon, 30 Apr 2012 23:12:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234856 - head/cddl/compat/opensolaris/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 23:12:16 -0000 Author: rmh Date: Mon Apr 30 23:12:16 2012 New Revision: 234856 URL: http://svn.freebsd.org/changeset/base/234856 Log: GNU/kFreeBSD portability fix. This glue overrides header protection in the system-wide version of by wrapping the #include_next within the scope of its own header protection. On FreeBSD this has no effect, since both header protections are equivalent. However the GNU version of implements a special header protection mechanism which allows it to be included multiple times (in different modes). Simply by moving the #include_next off the header protection, we allow system-wide to implement its own protection policy, whichever that may be. Modified: head/cddl/compat/opensolaris/include/stdlib.h Modified: head/cddl/compat/opensolaris/include/stdlib.h ============================================================================== --- head/cddl/compat/opensolaris/include/stdlib.h Mon Apr 30 22:46:09 2012 (r234855) +++ head/cddl/compat/opensolaris/include/stdlib.h Mon Apr 30 23:12:16 2012 (r234856) @@ -27,11 +27,11 @@ * */ +#include_next + #ifndef _COMPAT_OPENSOLARIS_STDLIB_H_ #define _COMPAT_OPENSOLARIS_STDLIB_H_ -#include_next - #define getexecname getprogname #endif From owner-svn-src-all@FreeBSD.ORG Tue May 1 01:19:56 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6A2A106566B; Tue, 1 May 2012 01:19:56 +0000 (UTC) (envelope-from jwd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2CD18FC08; Tue, 1 May 2012 01:19: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 q411JuRA094603; Tue, 1 May 2012 01:19:56 GMT (envelope-from jwd@svn.freebsd.org) Received: (from jwd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q411JuVC094601; Tue, 1 May 2012 01:19:56 GMT (envelope-from jwd@svn.freebsd.org) Message-Id: <201205010119.q411JuVC094601@svn.freebsd.org> From: "John W. De Boskey" Date: Tue, 1 May 2012 01:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234857 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 01:19:56 -0000 Author: jwd Date: Tue May 1 01:19:56 2012 New Revision: 234857 URL: http://svn.freebsd.org/changeset/base/234857 Log: Add myself to this file - it didn't exist last time. Approved by: rmacklem (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Mon Apr 30 23:12:16 2012 (r234856) +++ head/share/misc/committers-src.dot Tue May 1 01:19:56 2012 (r234857) @@ -177,6 +177,7 @@ jon [label="Jonathan Chen\njon@FreeBSD.o jonathan [label="Jonathan Anderson\njonathan@FreeBSD.org\n2010/10/07"] jpaetzel [label="Josh Paetzel\njpaetzel@FreeBSD.org\n2011/01/21"] julian [label="Julian Elischer\njulian@FreeBSD.org\n1993/??/??"] +jwd [label="John De Boskey\njwd@FreeBSD.org\n2000/05/19"] kaiw [label="Kai Wang\nkaiw@FreeBSD.org\n2007/09/26"] kan [label="Alexander Kabaev\nkan@FreeBSD.org\n2002/07/21"] kargl [label="Steven G. Kargl\nkargl@FreeBSD.org\n2011/01/17"] @@ -438,6 +439,7 @@ jhb -> rnoland jkh -> imp jkh -> jlemon jkh -> joerg +jkh -> jwd jkh -> phk jkh -> wes jkh -> yar @@ -541,6 +543,8 @@ pjd -> trociny rgrimes -> markm +rmacklem -> jwd + rpaulo -> avg rpaulo -> bschmidt rpaulo -> dim From owner-svn-src-all@FreeBSD.ORG Tue May 1 04:35:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CE12106566B; Tue, 1 May 2012 04:35:54 +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 EBE858FC08; Tue, 1 May 2012 04:35: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 q414ZrYB001847; Tue, 1 May 2012 04:35:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q414Zr6H001844; Tue, 1 May 2012 04:35:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010435.q414Zr6H001844@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 04:35: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: r234859 - in head/sys: conf mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 04:35:54 -0000 Author: adrian Date: Tue May 1 04:35:53 2012 New Revision: 234859 URL: http://svn.freebsd.org/changeset/base/234859 Log: Migrate ARGE_DEBUG to opt_arge.h. Submitted by: Stefan Bethke Modified: head/sys/conf/options.mips head/sys/mips/atheros/if_arge.c Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Tue May 1 04:01:22 2012 (r234858) +++ head/sys/conf/options.mips Tue May 1 04:35:53 2012 (r234859) @@ -65,7 +65,7 @@ OCTEON_BOARD_CAPK_0100ND opt_cvmx.h # # Options that control the Atheros SoC peripherals # -ARGE_DEBUG opt_global.h +ARGE_DEBUG opt_arge.h # # Options that control the Ralink RT305xF Etherenet MAC. Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Tue May 1 04:01:22 2012 (r234858) +++ head/sys/mips/atheros/if_arge.c Tue May 1 04:35:53 2012 (r234859) @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); #include "opt_device_polling.h" #endif +#include "opt_arge.h" + #include #include #include From owner-svn-src-all@FreeBSD.ORG Tue May 1 05:05:09 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9438710682B3; Tue, 1 May 2012 05:04:50 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B5EB8FC1A; Tue, 1 May 2012 05:04: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 q4154o2b002890; Tue, 1 May 2012 05:04:50 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4154niY002886; Tue, 1 May 2012 05:04:50 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201205010504.q4154niY002886@svn.freebsd.org> From: Tim Kientzle Date: Tue, 1 May 2012 05:04:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234860 - head/sys/boot/uboot/lib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 05:05:09 -0000 Author: kientzle Date: Tue May 1 05:04:49 2012 New Revision: 234860 URL: http://svn.freebsd.org/changeset/base/234860 Log: Teach ubldr(8) about simple MBR partitioning. Modified: head/sys/boot/uboot/lib/devicename.c head/sys/boot/uboot/lib/disk.c head/sys/boot/uboot/lib/libuboot.h Modified: head/sys/boot/uboot/lib/devicename.c ============================================================================== --- head/sys/boot/uboot/lib/devicename.c Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/devicename.c Tue May 1 05:04:49 2012 (r234860) @@ -131,6 +131,10 @@ uboot_parsedev(struct uboot_devdesc **de *(cp + 1) != ':') { pnum = strtol(cp + 1, &cp, 10); ptype = PTYPE_GPT; + } else if (*cp == 's' && *(cp + 1) && + *(cp + 1) != ':') { + pnum = strtol(cp + 1, &cp, 10); + ptype = PTYPE_MBR; } else { pnum = *cp - 'a'; ptype = PTYPE_BSDLABEL; @@ -218,6 +222,9 @@ uboot_fmtdev(void *vdev) else if (dev->d_kind.disk.ptype == PTYPE_GPT) cp += sprintf(cp, "p%i", dev->d_kind.disk.pnum); + else if (dev->d_kind.disk.ptype == PTYPE_MBR) + cp += sprintf(cp, "s%i", + dev->d_kind.disk.pnum); } strcat(cp, ":"); Modified: head/sys/boot/uboot/lib/disk.c ============================================================================== --- head/sys/boot/uboot/lib/disk.c Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/disk.c Tue May 1 05:04:49 2012 (r234860) @@ -398,6 +398,94 @@ out: } static int +stor_open_mbr(struct open_dev *od, struct uboot_devdesc *dev) +{ + char *buf = NULL; + struct dos_partition *dp; + int err, i, part; + + od->od_nparts = 0; + od->od_partitions = NULL; + + /* Block size must be at least 512 bytes. */ + if (od->od_bsize < 512) + return (ENXIO); + + /* Read MBR */ + buf = malloc(od->od_bsize); + if (!buf) { + stor_printf("could not allocate memory for MBR\n"); + return (ENOMEM); + } + err = stor_readdev(dev, 0, 1, buf); + if (err) { + stor_printf("MBR read error=%d\n", err); + err = EIO; + goto out; + } + + /* Check the slice table magic. */ + if (le16toh(*((uint16_t *)(buf + DOSMAGICOFFSET))) != DOSMAGIC) { + err = ENXIO; + goto out; + } + + /* Save information about partitions. */ + dp = (struct dos_partition *)(buf + DOSPARTOFF); + od->od_partitions = calloc(NDOSPART, sizeof(struct gpt_part)); + if (!od->od_partitions) { + stor_printf("could not allocate memory for MBR partitions\n"); + err = ENOMEM; + goto out; + } + + part = 0; + for (i = 0; i < NDOSPART; i++) { + u_int32_t start = le32dec(&dp[i].dp_start); + u_int32_t size = le32dec(&dp[i].dp_size); + uuid_t *u = NULL; + + /* Map MBR partition types to GPT partition types. */ + switch (dp[i].dp_typ) { + case DOSPTYP_386BSD: + u = &freebsd_ufs; + break; + /* XXX Other types XXX */ + } + + if (u) { + od->od_partitions[part].gp_type = *u; + od->od_partitions[part].gp_index = i + 1; + od->od_partitions[part].gp_start = start; + od->od_partitions[part].gp_end = start + size; + part += 1; + } + } + od->od_nparts = part; + + if (od->od_nparts == 0) { + err = EINVAL; + goto out; + } + + dev->d_disk.ptype = PTYPE_MBR; + + /* XXX Be smarter here? XXX */ + if (dev->d_disk.pnum == 0) + dev->d_disk.pnum = od->od_partitions[0].gp_index; + + for (i = 0; i < od->od_nparts; i++) + if (od->od_partitions[i].gp_index == dev->d_disk.pnum) + od->od_bstart = od->od_partitions[i].gp_start; + +out: + if (err && od->od_partitions) + free(od->od_partitions); + free(buf); + return (err); +} + +static int stor_open_bsdlabel(struct open_dev *od, struct uboot_devdesc *dev) { char *buf; @@ -443,7 +531,7 @@ stor_readdev(struct uboot_devdesc *dev, lbasize_t real_size; int err, handle; - debugf("reading size=%d @ 0x%08x\n", size, (uint32_t)buf); + debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf); handle = stor_info[dev->d_unit]; err = ub_dev_read(handle, buf, size, blk, &real_size); @@ -495,7 +583,10 @@ stor_opendev(struct open_dev **odp, stru od->od_bsize = di->di_stor.block_size; od->od_bstart = 0; - if ((err = stor_open_gpt(od, dev)) != 0) + err = stor_open_gpt(od, dev); + if (err != 0) + err = stor_open_mbr(od, dev); + if (err != 0) err = stor_open_bsdlabel(od, dev); if (err != 0) @@ -517,6 +608,8 @@ stor_closedev(struct uboot_devdesc *dev) od = (struct open_dev *)dev->d_disk.data; if (dev->d_disk.ptype == PTYPE_GPT && od->od_nparts != 0) free(od->od_partitions); + if (dev->d_disk.ptype == PTYPE_MBR && od->od_nparts != 0) + free(od->od_partitions); free(od); dev->d_disk.data = NULL; Modified: head/sys/boot/uboot/lib/libuboot.h ============================================================================== --- head/sys/boot/uboot/lib/libuboot.h Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/libuboot.h Tue May 1 05:04:49 2012 (r234860) @@ -45,6 +45,7 @@ struct uboot_devdesc #define PTYPE_BSDLABEL 1 #define PTYPE_GPT 2 +#define PTYPE_MBR 3 /* * Default network packet alignment in memory From owner-svn-src-all@FreeBSD.ORG Tue May 1 06:11:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A4D51065670; Tue, 1 May 2012 06:11:39 +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 E80F78FC19; Tue, 1 May 2012 06:11:38 +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 q416BcBc005219; Tue, 1 May 2012 06:11:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416BcYW005211; Tue, 1 May 2012 06:11:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010611.q416BcYW005211@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:11:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234861 - in head/sys: conf dev/etherswitch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:11:39 -0000 Author: adrian Date: Tue May 1 06:11:38 2012 New Revision: 234861 URL: http://svn.freebsd.org/changeset/base/234861 Log: Bring over the first part of the etherswitch framework - an MDIO bus and MDIO/MII rendezvous proxy. * Add an 'mdio' bus, which is the "IO" side of an MII bus (but by design can be anything which implements the underlying register access API.) * Add 'miiproxy' and 'mdioproxy', which provides a rendezvous mechanism for MII busses to appear hanging off arbitrary busses (ie, that aren't necessarily a traditional looking MII bus.) MII busses can now hang off anything that implements an mdiobus. For the AR71xx SoC, there's one MDIO bus but two MII busses. So to properly support two or more real PHYs, this can be done: # arge0 MDIO bus - there's no arge1 MDIO bus for AR71xx hint.argemdio.0.at="nexus0" hint.argemdio.0.maddr=0x19000000 hint.argemdio.0.msize=0x1000 hint.argemdio.0.order=0 # Create two mdioproxy instances hint.mdioproxy.0.at="mdio0" hint.mdioproxy.1.at="mdio0" # .. and with a follow-up patch hint.arge.0.mdio=mdioproxy0 hint.arge.1.mdio=mdioproxy0 TODO: * Do a sweep or two and add appropriate locking in mdio/mdioproxy/miiproxy. Submitted by: Stefan Bethke Reviewed by: ray Added: head/sys/dev/etherswitch/ head/sys/dev/etherswitch/mdio.c (contents, props changed) head/sys/dev/etherswitch/mdio.h (contents, props changed) head/sys/dev/etherswitch/mdio_if.m (contents, props changed) head/sys/dev/etherswitch/miiproxy.c (contents, props changed) head/sys/dev/etherswitch/miiproxy.h (contents, props changed) Modified: head/sys/conf/files head/sys/conf/kmod.mk Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue May 1 05:04:49 2012 (r234860) +++ head/sys/conf/files Tue May 1 06:11:38 2012 (r234861) @@ -3683,3 +3683,7 @@ dev/xen/netback/netback.c optional xen | dev/xen/netfront/netfront.c optional xen | xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/xenpci/evtchn.c optional xenpci + +dev/etherswitch/mdio_if.m optional miiproxy +dev/etherswitch/mdio.c optional miiproxy +dev/etherswitch/miiproxy.c optional miiproxy Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Tue May 1 05:04:49 2012 (r234860) +++ head/sys/conf/kmod.mk Tue May 1 06:11:38 2012 (r234861) @@ -354,7 +354,7 @@ MFILES?= dev/acpica/acpi_if.m dev/acpi_s kern/bus_if.m kern/clock_if.m \ kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \ libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \ - pc98/pc98/canbus_if.m + pc98/pc98/canbus_if.m dev/etherswitch/mdio_if.m .for _srcsrc in ${MFILES} .for _ext in c h Added: head/sys/dev/etherswitch/mdio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio.c Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,117 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include + +#include "mdio_if.h" + +static void +mdio_identify(driver_t *driver, device_t parent) +{ + + if (device_find_child(parent, mdio_driver.name, -1) == NULL) + BUS_ADD_CHILD(parent, 0, mdio_driver.name, -1); +} + +static int +mdio_probe(device_t dev) +{ + + device_set_desc(dev, "MDIO"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +mdio_attach(device_t dev) +{ + + bus_generic_probe(dev); + bus_enumerate_hinted_children(dev); + return (bus_generic_attach(dev)); +} + +static int +mdio_detach(device_t dev) +{ + + bus_generic_detach(dev); + return (0); +} + +static int +mdio_readreg(device_t dev, int phy, int reg) +{ + + return (MDIO_READREG(device_get_parent(dev), phy, reg)); +} + +static int +mdio_writereg(device_t dev, int phy, int reg, int val) +{ + + return (MDIO_WRITEREG(device_get_parent(dev), phy, reg, val)); +} + +static void +mdio_hinted_child(device_t dev, const char *name, int unit) +{ + + device_add_child(dev, name, unit); +} + +static device_method_t mdio_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, mdio_identify), + DEVMETHOD(device_probe, mdio_probe), + DEVMETHOD(device_attach, mdio_attach), + DEVMETHOD(device_detach, mdio_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + DEVMETHOD(bus_hinted_child, mdio_hinted_child), + + /* MDIO access */ + DEVMETHOD(mdio_readreg, mdio_readreg), + DEVMETHOD(mdio_writereg, mdio_writereg), + + DEVMETHOD_END +}; + +driver_t mdio_driver = { + "mdio", + mdio_methods, + 0 +}; + +devclass_t mdio_devclass; Added: head/sys/dev/etherswitch/mdio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio.h Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __DEV_ETHERSWITCH_MDIO_H__ +#define __DEV_ETHERSWITCH_MDIO_H__ + +extern driver_t mdio_driver; +extern devclass_t mdio_devclass; + +#endif /* __DEV_ETHERSWITCH_MDIO_H__ */ Added: head/sys/dev/etherswitch/mdio_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio_if.m Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,24 @@ +# $FreeBSD$ + +#include + +INTERFACE mdio; + +# +# Read register from device on MDIO bus +# +METHOD int readreg { + device_t dev; + int phy; + int reg; +}; + +# +# Write register to device on MDIO bus +# +METHOD int writereg { + device_t dev; + int phy; + int reg; + int val; +}; Added: head/sys/dev/etherswitch/miiproxy.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/miiproxy.c Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,444 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "mdio_if.h" +#include "miibus_if.h" + + +MALLOC_DECLARE(M_MIIPROXY); +MALLOC_DEFINE(M_MIIPROXY, "miiproxy", "miiproxy data structures"); + +driver_t miiproxy_driver; +driver_t mdioproxy_driver; + +struct miiproxy_softc { + device_t parent; + device_t proxy; + device_t mdio; +}; + +struct mdioproxy_softc { +}; + +/* + * The rendevous data structures and functions allow two device endpoints to + * match up, so that the proxy endpoint can be associated with a target + * endpoint. The proxy has to know the device name of the target that it + * wants to associate with, for example through a hint. The rendevous code + * makes no assumptions about the devices that want to meet. + */ +struct rendevous_entry; + +enum rendevous_op { + RENDEVOUS_ATTACH, + RENDEVOUS_DETACH +}; + +typedef int (*rendevous_callback_t)(enum rendevous_op, + struct rendevous_entry *); + +static SLIST_HEAD(rendevoushead, rendevous_entry) rendevoushead = + SLIST_HEAD_INITIALIZER(rendevoushead); + +struct rendevous_endpoint { + device_t device; + const char *name; + rendevous_callback_t callback; +}; + +struct rendevous_entry { + SLIST_ENTRY(rendevous_entry) entries; + struct rendevous_endpoint proxy; + struct rendevous_endpoint target; +}; + +/* + * Call the callback routines for both the proxy and the target. If either + * returns an error, undo the attachment. + */ +static int +rendevous_attach(struct rendevous_entry *e, struct rendevous_endpoint *ep) +{ + int error; + + error = e->proxy.callback(RENDEVOUS_ATTACH, e); + if (error == 0) { + error = e->target.callback(RENDEVOUS_ATTACH, e); + if (error != 0) { + e->proxy.callback(RENDEVOUS_DETACH, e); + ep->device = NULL; + ep->callback = NULL; + } + } + return (error); +} + +/* + * Create an entry for the proxy in the rendevous list. The name parameter + * indicates the name of the device that is the target endpoint for this + * rendevous. The callback will be invoked as soon as the target is + * registered: either immediately if the target registered itself earlier, + * or once the target registers. Returns ENXIO if the target has not yet + * registered. + */ +static int +rendevous_register_proxy(device_t dev, const char *name, + rendevous_callback_t callback) +{ + struct rendevous_entry *e; + + KASSERT(callback != NULL, ("callback must be set")); + SLIST_FOREACH(e, &rendevoushead, entries) { + if (strcmp(name, e->target.name) == 0) { + /* the target is already attached */ + e->proxy.name = device_get_nameunit(dev); + e->proxy.device = dev; + e->proxy.callback = callback; + return (rendevous_attach(e, &e->proxy)); + } + } + e = malloc(sizeof(*e), M_MIIPROXY, M_WAITOK | M_ZERO); + e->proxy.name = device_get_nameunit(dev); + e->proxy.device = dev; + e->proxy.callback = callback; + e->target.name = name; + SLIST_INSERT_HEAD(&rendevoushead, e, entries); + return (ENXIO); +} + +/* + * Create an entry in the rendevous list for the target. + * Returns ENXIO if the proxy has not yet registered. + */ +static int +rendevous_register_target(device_t dev, rendevous_callback_t callback) +{ + struct rendevous_entry *e; + const char *name; + + KASSERT(callback != NULL, ("callback must be set")); + name = device_get_nameunit(dev); + SLIST_FOREACH(e, &rendevoushead, entries) { + if (strcmp(name, e->target.name) == 0) { + e->target.device = dev; + e->target.callback = callback; + return (rendevous_attach(e, &e->target)); + } + } + e = malloc(sizeof(*e), M_MIIPROXY, M_WAITOK | M_ZERO); + e->target.name = name; + e->target.device = dev; + e->target.callback = callback; + SLIST_INSERT_HEAD(&rendevoushead, e, entries); + return (ENXIO); +} + +/* + * Remove the registration for the proxy. + */ +static int +rendevous_unregister_proxy(device_t dev) +{ + struct rendevous_entry *e; + int error = 0; + + SLIST_FOREACH(e, &rendevoushead, entries) { + if (e->proxy.device == dev) { + if (e->target.device == NULL) { + SLIST_REMOVE(&rendevoushead, e, rendevous_entry, entries); + free(e, M_MIIPROXY); + return (0); + } else { + e->proxy.callback(RENDEVOUS_DETACH, e); + e->target.callback(RENDEVOUS_DETACH, e); + } + e->proxy.device = NULL; + e->proxy.callback = NULL; + return (error); + } + } + return (ENOENT); +} + +/* + * Remove the registration for the target. + */ +static int +rendevous_unregister_target(device_t dev) +{ + struct rendevous_entry *e; + int error = 0; + + SLIST_FOREACH(e, &rendevoushead, entries) { + if (e->target.device == dev) { + if (e->proxy.device == NULL) { + SLIST_REMOVE(&rendevoushead, e, rendevous_entry, entries); + free(e, M_MIIPROXY); + return (0); + } else { + e->proxy.callback(RENDEVOUS_DETACH, e); + e->target.callback(RENDEVOUS_DETACH, e); + } + e->target.device = NULL; + e->target.callback = NULL; + return (error); + } + } + return (ENOENT); +} + +/* + * Functions of the proxy that is interposed between the ethernet interface + * driver and the miibus device. + */ + +static int +miiproxy_rendevous_callback(enum rendevous_op op, struct rendevous_entry *rendevous) +{ + struct miiproxy_softc *sc = device_get_softc(rendevous->proxy.device); + + switch (op) { + case RENDEVOUS_ATTACH: + sc->mdio = device_get_parent(rendevous->target.device); + break; + case RENDEVOUS_DETACH: + sc->mdio = NULL; + break; + } + return (0); +} + +static int +miiproxy_probe(device_t dev) +{ + device_set_desc(dev, "MII/MDIO proxy, MII side"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +miiproxy_attach(device_t dev) +{ + + /* + * The ethernet interface needs to call mii_attach_proxy() to pass + * the relevant parameters for rendevous with the MDIO target. + */ + return (bus_generic_attach(dev)); +} + +static int +miiproxy_detach(device_t dev) +{ + + rendevous_unregister_proxy(dev); + bus_generic_detach(dev); + return (0); +} + +static int +miiproxy_readreg(device_t dev, int phy, int reg) +{ + struct miiproxy_softc *sc = device_get_softc(dev); + + if (sc->mdio != NULL) + return (MDIO_READREG(sc->mdio, phy, reg)); + return (-1); +} + +static int +miiproxy_writereg(device_t dev, int phy, int reg, int val) +{ + struct miiproxy_softc *sc = device_get_softc(dev); + + if (sc->mdio != NULL) + return (MDIO_WRITEREG(sc->mdio, phy, reg, val)); + return (-1); +} + +static void +miiproxy_statchg(device_t dev) +{ + + MIIBUS_STATCHG(device_get_parent(dev)); +} + +static void +miiproxy_linkchg(device_t dev) +{ + + MIIBUS_LINKCHG(device_get_parent(dev)); +} + +static void +miiproxy_mediainit(device_t dev) +{ + + MIIBUS_MEDIAINIT(device_get_parent(dev)); +} + +/* + * Functions for the MDIO target device driver. + */ +static int +mdioproxy_rendevous_callback(enum rendevous_op op, struct rendevous_entry *rendevous) +{ + return (0); +} + +static void +mdioproxy_identify(driver_t *driver, device_t parent) +{ + device_t child; + + if (device_find_child(parent, driver->name, -1) == NULL) { + child = BUS_ADD_CHILD(parent, 0, driver->name, -1); + } +} + +static int +mdioproxy_probe(device_t dev) +{ + device_set_desc(dev, "MII/MDIO proxy, MDIO side"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +mdioproxy_attach(device_t dev) +{ + + rendevous_register_target(dev, mdioproxy_rendevous_callback); + return (bus_generic_attach(dev)); +} + +static int +mdioproxy_detach(device_t dev) +{ + + rendevous_unregister_target(dev); + bus_generic_detach(dev); + return (0); +} + +/* + * Attach this proxy in place of miibus. The target MDIO must be attached + * already. Returns NULL on error. + */ +device_t +mii_attach_proxy(device_t dev) +{ + struct miiproxy_softc *sc; + int error; + const char *name; + device_t miiproxy; + + if (resource_string_value(device_get_name(dev), + device_get_unit(dev), "mdio", &name) != 0) { + if (bootverbose) + printf("mii_attach_proxy: not attaching, no mdio" + " device hint for %s\n", device_get_nameunit(dev)); + return (NULL); + } + + miiproxy = device_add_child(dev, miiproxy_driver.name, -1); + error = bus_generic_attach(dev); + if (error != 0) { + device_printf(dev, "can't attach miiproxy\n"); + return (NULL); + } + sc = device_get_softc(miiproxy); + sc->parent = dev; + sc->proxy = miiproxy; + if (rendevous_register_proxy(miiproxy, name, miiproxy_rendevous_callback) != 0) { + device_printf(dev, "can't attach proxy\n"); + return (NULL); + } + device_printf(miiproxy, "attached to target %s\n", device_get_nameunit(sc->mdio)); + return (miiproxy); +} + +static device_method_t miiproxy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, miiproxy_probe), + DEVMETHOD(device_attach, miiproxy_attach), + DEVMETHOD(device_detach, miiproxy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* MII interface */ + DEVMETHOD(miibus_readreg, miiproxy_readreg), + DEVMETHOD(miibus_writereg, miiproxy_writereg), + DEVMETHOD(miibus_statchg, miiproxy_statchg), + DEVMETHOD(miibus_linkchg, miiproxy_linkchg), + DEVMETHOD(miibus_mediainit, miiproxy_mediainit), + + DEVMETHOD_END +}; + +static device_method_t mdioproxy_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, mdioproxy_identify), + DEVMETHOD(device_probe, mdioproxy_probe), + DEVMETHOD(device_attach, mdioproxy_attach), + DEVMETHOD(device_detach, mdioproxy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(miiproxy, miiproxy_driver, miiproxy_methods, + sizeof(struct miiproxy_softc)); +DEFINE_CLASS_0(mdioproxy, mdioproxy_driver, mdioproxy_methods, + sizeof(struct mdioproxy_softc)); + +devclass_t miiproxy_devclass; +static devclass_t mdioproxy_devclass; + +DRIVER_MODULE(mdioproxy, mdio, mdioproxy_driver, mdioproxy_devclass, 0, 0); +DRIVER_MODULE(miibus, miiproxy, miibus_driver, miibus_devclass, 0, 0); +MODULE_VERSION(miiproxy, 1); +MODULE_DEPEND(miiproxy, miibus, 1, 1, 1); Added: head/sys/dev/etherswitch/miiproxy.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/miiproxy.h Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __DEV_ETHERSWITCH_MIIPROXY_H__ +#define __DEV_ETHERSWITCH_MIIPROXY_H__ + +extern devclass_t miiproxy_devclass; +extern driver_t miiproxy_driver; + +device_t mii_attach_proxy(device_t dev); + +#endif /* __DEV_ETHERSWITCH_MIIPROXY_H__ */ From owner-svn-src-all@FreeBSD.ORG Tue May 1 06:18:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2A711065673; Tue, 1 May 2012 06:18:30 +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 9C7078FC18; Tue, 1 May 2012 06:18: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 q416IUNl005486; Tue, 1 May 2012 06:18:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416IU9V005481; Tue, 1 May 2012 06:18:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010618.q416IU9V005481@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:18: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: r234862 - in head/sys: conf mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:18:30 -0000 Author: adrian Date: Tue May 1 06:18:30 2012 New Revision: 234862 URL: http://svn.freebsd.org/changeset/base/234862 Log: Break out the arge MDIO bus code into an optional argemdio device. This is only done if the ARGE_MDIO option is included. * Shuffle the arge MDIO bus into a separate device, that needs to be probed early (use hint.argemdio.X.order=0) * hint.arge.X.mdio now specifies which miiproxy to rendezvous with. * Call MAC/MDIO bus init during MDIO attach, not arge attach. This is done regardless: * Shift the arge MAC and MDIO bus reset code into separate functions and call it early during MDIO bus attach. It's required for correct MDIO bus IO to occur on AR71xx/AR91xx devices. * Remove the AR71xx/AR91xx centric assumption that there's only one MDIO bus. The initial code mapped miibus0(arge0) and miibus1(arge1) MII register operations to the MII0 (arge0) register space. The AR724x (and later, upcoming chipsets) have two MDIO busses and the second is very much in use. TODO: * since the multiphy behaviour has changed (where now a phymask of >1 PHY will still be enumerated), multiphy setups may be quite wrong. I'll go and fix these so they still have a chance of working, at least. until the switch PHY support appears in -HEAD. Submitted by: Stefan Bethke Modified: head/sys/conf/options.mips head/sys/mips/atheros/ar71xxreg.h head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Tue May 1 06:11:38 2012 (r234861) +++ head/sys/conf/options.mips Tue May 1 06:18:30 2012 (r234862) @@ -66,6 +66,7 @@ OCTEON_BOARD_CAPK_0100ND opt_cvmx.h # Options that control the Atheros SoC peripherals # ARGE_DEBUG opt_arge.h +ARGE_MDIO opt_arge.h # # Options that control the Ralink RT305xF Etherenet MAC. Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/ar71xxreg.h Tue May 1 06:18:30 2012 (r234862) @@ -283,10 +283,6 @@ */ #define AR71XX_MAC0_BASE 0x19000000 #define AR71XX_MAC1_BASE 0x1A000000 -/* - * All 5 PHYs accessible only through MAC0 register space - */ -#define AR71XX_MII_BASE 0x19000000 #define AR71XX_MAC_CFG1 0x00 #define MAC_CFG1_SOFT_RESET (1 << 31) Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/if_arge.c Tue May 1 06:18:30 2012 (r234862) @@ -74,8 +74,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include "opt_arge.h" + +#if defined(ARGE_MDIO) +#include +#include +#include "mdio_if.h" +#endif + + MODULE_DEPEND(arge, ether, 1, 1, 1); MODULE_DEPEND(arge, miibus, 1, 1, 1); +MODULE_VERSION(arge, 1); #include "miibus_if.h" @@ -138,6 +148,8 @@ static void arge_intr(void *); static int arge_intr_filter(void *); static void arge_tick(void *); +static void arge_hinted_child(device_t bus, const char *dname, int dunit); + /* * ifmedia callbacks for multiPHY MAC */ @@ -164,6 +176,10 @@ static device_method_t arge_methods[] = DEVMETHOD(miibus_writereg, arge_miibus_writereg), DEVMETHOD(miibus_statchg, arge_miibus_statchg), + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + DEVMETHOD(bus_hinted_child, arge_hinted_child), + DEVMETHOD_END }; @@ -178,6 +194,37 @@ static devclass_t arge_devclass; DRIVER_MODULE(arge, nexus, arge_driver, arge_devclass, 0, 0); DRIVER_MODULE(miibus, arge, miibus_driver, miibus_devclass, 0, 0); +#if defined(ARGE_MDIO) +static int argemdio_probe(device_t); +static int argemdio_attach(device_t); +static int argemdio_detach(device_t); + +/* + * Declare an additional, separate driver for accessing the MDIO bus. + */ +static device_method_t argemdio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, argemdio_probe), + DEVMETHOD(device_attach, argemdio_attach), + DEVMETHOD(device_detach, argemdio_detach), + + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + + /* MDIO access */ + DEVMETHOD(mdio_readreg, arge_miibus_readreg), + DEVMETHOD(mdio_writereg, arge_miibus_writereg), +}; + +DEFINE_CLASS_0(argemdio, argemdio_driver, argemdio_methods, + sizeof(struct arge_softc)); +static devclass_t argemdio_devclass; + +DRIVER_MODULE(miiproxy, arge, miiproxy_driver, miiproxy_devclass, 0, 0); +DRIVER_MODULE(argemdio, nexus, argemdio_driver, argemdio_devclass, 0, 0); +DRIVER_MODULE(mdio, argemdio, mdio_driver, mdio_devclass, 0, 0); +#endif + /* * RedBoot passes MAC address to entry point as environment * variable. platfrom_start parses it and stores in this variable @@ -237,15 +284,53 @@ arge_attach_sysctl(device_t dev) #endif } +static void +arge_reset_mac(struct arge_softc *sc) +{ + uint32_t reg; + + /* Step 1. Soft-reset MAC */ + ARGE_SET_BITS(sc, AR71XX_MAC_CFG1, MAC_CFG1_SOFT_RESET); + DELAY(20); + + /* Step 2. Punt the MAC core from the central reset register */ + ar71xx_device_stop(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : + RST_RESET_GE1_MAC); + DELAY(100); + ar71xx_device_start(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : + RST_RESET_GE1_MAC); + + /* Step 3. Reconfigure MAC block */ + ARGE_WRITE(sc, AR71XX_MAC_CFG1, + MAC_CFG1_SYNC_RX | MAC_CFG1_RX_ENABLE | + MAC_CFG1_SYNC_TX | MAC_CFG1_TX_ENABLE); + + reg = ARGE_READ(sc, AR71XX_MAC_CFG2); + reg |= MAC_CFG2_ENABLE_PADCRC | MAC_CFG2_LENGTH_FIELD ; + ARGE_WRITE(sc, AR71XX_MAC_CFG2, reg); + + ARGE_WRITE(sc, AR71XX_MAC_MAX_FRAME_LEN, 1536); +} + +static void +arge_reset_miibus(struct arge_softc *sc) +{ + + /* Reset MII bus */ + ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_RESET); + DELAY(100); + ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_CLOCK_DIV_28); + DELAY(100); +} + static int arge_attach(device_t dev) { - uint8_t eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp; struct arge_softc *sc; - int error = 0, rid, phymask; - uint32_t reg, rnd; - int is_base_mac_empty, i, phys_total; + int error = 0, rid; + uint32_t rnd; + int is_base_mac_empty, i; uint32_t hint; long eeprom_mac_addr = 0; @@ -280,20 +365,19 @@ arge_attach(device_t dev) /* * Get which PHY of 5 available we should use for this unit */ - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "phymask", &phymask) != 0) { + if (resource_int_value(device_get_name(dev), device_get_unit(dev), + "phymask", &sc->arge_phymask) != 0) { /* * Use port 4 (WAN) for GE0. For any other port use * its PHY the same as its unit number */ if (sc->arge_mac_unit == 0) - phymask = (1 << 4); + sc->arge_phymask = (1 << 4); else /* Use all phys up to 4 */ - phymask = (1 << 4) - 1; + sc->arge_phymask = (1 << 4) - 1; - device_printf(dev, "No PHY specified, using mask %d\n", - phymask); + device_printf(dev, "No PHY specified, using mask %d\n", sc->arge_phymask); } /* @@ -318,8 +402,6 @@ arge_attach(device_t dev) else sc->arge_duplex_mode = 0; - sc->arge_phymask = phymask; - mtx_init(&sc->arge_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); callout_init_mtx(&sc->arge_stat_callout, &sc->arge_mtx, 0); @@ -327,8 +409,8 @@ arge_attach(device_t dev) /* Map control/status registers. */ sc->arge_rid = 0; - sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &sc->arge_rid, RF_ACTIVE); + sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->arge_rid, RF_ACTIVE | RF_SHAREABLE); if (sc->arge_res == NULL) { device_printf(dev, "couldn't map memory\n"); @@ -376,8 +458,8 @@ arge_attach(device_t dev) is_base_mac_empty = 1; for (i = 0; i < ETHER_ADDR_LEN; i++) { - eaddr[i] = ar711_base_mac[i] & 0xff; - if (eaddr[i] != 0) + sc->arge_eaddr[i] = ar711_base_mac[i] & 0xff; + if (sc->arge_eaddr[i] != 0) is_base_mac_empty = 0; } @@ -390,59 +472,40 @@ arge_attach(device_t dev) "Generating random ethernet address.\n"); rnd = arc4random(); - eaddr[0] = 'b'; - eaddr[1] = 's'; - eaddr[2] = 'd'; - eaddr[3] = (rnd >> 24) & 0xff; - eaddr[4] = (rnd >> 16) & 0xff; - eaddr[5] = (rnd >> 8) & 0xff; + sc->arge_eaddr[0] = 'b'; + sc->arge_eaddr[1] = 's'; + sc->arge_eaddr[2] = 'd'; + sc->arge_eaddr[3] = (rnd >> 24) & 0xff; + sc->arge_eaddr[4] = (rnd >> 16) & 0xff; + sc->arge_eaddr[5] = (rnd >> 8) & 0xff; } - if (sc->arge_mac_unit != 0) - eaddr[5] += sc->arge_mac_unit; + sc->arge_eaddr[5] += sc->arge_mac_unit; if (arge_dma_alloc(sc) != 0) { error = ENXIO; goto fail; } + /* + * Don't do this for the MDIO bus case - it's already done + * as part of the MDIO bus attachment. + */ +#if !defined(ARGE_MDIO) /* Initialize the MAC block */ - - /* Step 1. Soft-reset MAC */ - ARGE_SET_BITS(sc, AR71XX_MAC_CFG1, MAC_CFG1_SOFT_RESET); - DELAY(20); - - /* Step 2. Punt the MAC core from the central reset register */ - ar71xx_device_stop(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : - RST_RESET_GE1_MAC); - DELAY(100); - ar71xx_device_start(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : - RST_RESET_GE1_MAC); - - /* Step 3. Reconfigure MAC block */ - ARGE_WRITE(sc, AR71XX_MAC_CFG1, - MAC_CFG1_SYNC_RX | MAC_CFG1_RX_ENABLE | - MAC_CFG1_SYNC_TX | MAC_CFG1_TX_ENABLE); - - reg = ARGE_READ(sc, AR71XX_MAC_CFG2); - reg |= MAC_CFG2_ENABLE_PADCRC | MAC_CFG2_LENGTH_FIELD ; - ARGE_WRITE(sc, AR71XX_MAC_CFG2, reg); - - ARGE_WRITE(sc, AR71XX_MAC_MAX_FRAME_LEN, 1536); - - /* Reset MII bus */ - ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_RESET); - DELAY(100); - ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_CLOCK_DIV_28); - DELAY(100); + arge_reset_mac(sc); + arge_reset_miibus(sc); +#endif /* * Set all Ethernet address registers to the same initial values * set all four addresses to 66-88-aa-cc-dd-ee */ - ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR1, - (eaddr[2] << 24) | (eaddr[3] << 16) | (eaddr[4] << 8) | eaddr[5]); - ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR2, (eaddr[0] << 8) | eaddr[1]); + ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR1, (sc->arge_eaddr[2] << 24) + | (sc->arge_eaddr[3] << 16) | (sc->arge_eaddr[4] << 8) + | sc->arge_eaddr[5]); + ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR2, (sc->arge_eaddr[0] << 8) + | sc->arge_eaddr[1]); ARGE_WRITE(sc, AR71XX_MAC_FIFO_CFG0, FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT); @@ -465,31 +528,30 @@ arge_attach(device_t dev) ARGE_WRITE(sc, AR71XX_MAC_FIFO_RX_FILTMASK, FIFO_RX_FILTMASK_DEFAULT); - /* - * Check if we have single-PHY MAC or multi-PHY - */ - phys_total = 0; - for (i = 0; i < ARGE_NPHY; i++) - if (phymask & (1 << i)) - phys_total ++; - - if (phys_total == 0) { - error = EINVAL; - goto fail; - } +#if defined(ARGE_MDIO) + sc->arge_miiproxy = mii_attach_proxy(sc->arge_dev); +#endif - if (phys_total == 1) { - /* Do MII setup. */ - error = mii_attach(dev, &sc->arge_miibus, ifp, - arge_ifmedia_upd, arge_ifmedia_sts, BMSR_DEFCAPMASK, - MII_PHY_ANY, MII_OFFSET_ANY, 0); - if (error != 0) { - device_printf(dev, "attaching PHYs failed\n"); - goto fail; + device_printf(sc->arge_dev, "finishing attachment, phymask %04x" + ", proxy %s \n", sc->arge_phymask, sc->arge_miiproxy == NULL ? + "null" : "set"); + for (i = 0; i < ARGE_NPHY; i++) { + if (((1 << i) & sc->arge_phymask) != 0) { + error = mii_attach(sc->arge_miiproxy != NULL ? + sc->arge_miiproxy : sc->arge_dev, + &sc->arge_miibus, sc->arge_ifp, + arge_ifmedia_upd, arge_ifmedia_sts, + BMSR_DEFCAPMASK, i, MII_OFFSET_ANY, 0); + if (error != 0) { + device_printf(sc->arge_dev, "unable to attach" + " PHY %d: %d\n", i, error); + goto fail; + } } } - else { - ifmedia_init(&sc->arge_ifmedia, 0, + if (sc->arge_miibus == NULL) { + /* no PHY, so use hard-coded values */ + ifmedia_init(&sc->arge_ifmedia, 0, arge_multiphy_mediachange, arge_multiphy_mediastatus); ifmedia_add(&sc->arge_ifmedia, @@ -501,23 +563,23 @@ arge_attach(device_t dev) } /* Call MI attach routine. */ - ether_ifattach(ifp, eaddr); + ether_ifattach(sc->arge_ifp, sc->arge_eaddr); /* Hook interrupt last to avoid having to lock softc */ - error = bus_setup_intr(dev, sc->arge_irq, INTR_TYPE_NET | INTR_MPSAFE, + error = bus_setup_intr(sc->arge_dev, sc->arge_irq, INTR_TYPE_NET | INTR_MPSAFE, arge_intr_filter, arge_intr, sc, &sc->arge_intrhand); if (error) { - device_printf(dev, "couldn't set up irq\n"); - ether_ifdetach(ifp); + device_printf(sc->arge_dev, "couldn't set up irq\n"); + ether_ifdetach(sc->arge_ifp); goto fail; } /* setup sysctl variables */ - arge_attach_sysctl(dev); + arge_attach_sysctl(sc->arge_dev); fail: - if (error) + if (error) arge_detach(dev); return (error); @@ -550,6 +612,9 @@ arge_detach(device_t dev) if (sc->arge_miibus) device_delete_child(dev, sc->arge_miibus); + if (sc->arge_miiproxy) + device_delete_child(dev, sc->arge_miiproxy); + bus_generic_detach(dev); if (sc->arge_intrhand) @@ -600,6 +665,13 @@ arge_shutdown(device_t dev) return (0); } +static void +arge_hinted_child(device_t bus, const char *dname, int dunit) +{ + BUS_ADD_CHILD(bus, 0, dname, dunit); + device_printf(bus, "hinted child %s%d\n", dname, dunit); +} + static int arge_miibus_readreg(device_t dev, int phy, int reg) { @@ -608,16 +680,13 @@ arge_miibus_readreg(device_t dev, int ph uint32_t addr = (phy << MAC_MII_PHY_ADDR_SHIFT) | (reg & MAC_MII_REG_MASK); - if ((sc->arge_phymask & (1 << phy)) == 0) - return (0); - mtx_lock(&miibus_mtx); - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); - ARGE_MII_WRITE(AR71XX_MAC_MII_ADDR, addr); - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_READ); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_ADDR, addr); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_READ); i = ARGE_MII_TIMEOUT; - while ((ARGE_MII_READ(AR71XX_MAC_MII_INDICATOR) & + while ((ARGE_MDIO_READ(sc, AR71XX_MAC_MII_INDICATOR) & MAC_MII_INDICATOR_BUSY) && (i--)) DELAY(5); @@ -628,8 +697,8 @@ arge_miibus_readreg(device_t dev, int ph return (-1); } - result = ARGE_MII_READ(AR71XX_MAC_MII_STATUS) & MAC_MII_STATUS_MASK; - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); + result = ARGE_MDIO_READ(sc, AR71XX_MAC_MII_STATUS) & MAC_MII_STATUS_MASK; + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); mtx_unlock(&miibus_mtx); ARGEDEBUG(sc, ARGE_DBG_MII, @@ -647,19 +716,15 @@ arge_miibus_writereg(device_t dev, int p uint32_t addr = (phy << MAC_MII_PHY_ADDR_SHIFT) | (reg & MAC_MII_REG_MASK); - - if ((sc->arge_phymask & (1 << phy)) == 0) - return (-1); - - ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value=%04x\n", - __func__, phy, reg, data); + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value=%04x\n", __func__, + phy, reg, data); mtx_lock(&miibus_mtx); - ARGE_MII_WRITE(AR71XX_MAC_MII_ADDR, addr); - ARGE_MII_WRITE(AR71XX_MAC_MII_CONTROL, data); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_ADDR, addr); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CONTROL, data); i = ARGE_MII_TIMEOUT; - while ((ARGE_MII_READ(AR71XX_MAC_MII_INDICATOR) & + while ((ARGE_MDIO_READ(sc, AR71XX_MAC_MII_INDICATOR) & MAC_MII_INDICATOR_BUSY) && (i--)) DELAY(5); @@ -729,6 +794,8 @@ arge_set_pll(struct arge_softc *sc, int uint32_t fifo_tx; int if_speed; + ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, + duplex == IFM_FDX ? "full" : "half"); cfg = ARGE_READ(sc, AR71XX_MAC_CFG2); cfg &= ~(MAC_CFG2_IFACE_MODE_1000 | MAC_CFG2_IFACE_MODE_10_100 @@ -1992,3 +2059,48 @@ arge_multiphy_mediastatus(struct ifnet * sc->arge_duplex_mode; } +#if defined(ARGE_MDIO) +static int +argemdio_probe(device_t dev) +{ + device_set_desc(dev, "Atheros AR71xx built-in ethernet interface, MDIO controller"); + return (0); +} + +static int +argemdio_attach(device_t dev) +{ + struct arge_softc *sc; + int error = 0; + + sc = device_get_softc(dev); + sc->arge_dev = dev; + sc->arge_mac_unit = device_get_unit(dev); + sc->arge_rid = 0; + sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->arge_rid, RF_ACTIVE | RF_SHAREABLE); + if (sc->arge_res == NULL) { + device_printf(dev, "couldn't map memory\n"); + error = ENXIO; + goto fail; + } + + /* Reset MAC - required for AR71xx MDIO to successfully occur */ + arge_reset_mac(sc); + /* Reset MII bus */ + arge_reset_miibus(sc); + + bus_generic_probe(dev); + bus_enumerate_hinted_children(dev); + error = bus_generic_attach(dev); +fail: + return (error); +} + +static int +argemdio_detach(device_t dev) +{ + return (0); +} + +#endif Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/if_argevar.h Tue May 1 06:18:30 2012 (r234862) @@ -67,15 +67,10 @@ #define ARGE_CLEAR_BITS(sc, reg, bits) \ ARGE_WRITE(sc, reg, ARGE_READ(sc, (reg)) & ~(bits)) -/* - * MII registers access macros - */ -#define ARGE_MII_READ(reg) \ - *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1((AR71XX_MII_BASE + reg))) - -#define ARGE_MII_WRITE(reg, val) \ - *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1((AR71XX_MII_BASE + reg))) = (val) - +#define ARGE_MDIO_WRITE(_sc, _reg, _val) \ + ARGE_WRITE((_sc), (_reg), (_val)) +#define ARGE_MDIO_READ(_sc, _reg) \ + ARGE_READ((_sc), (_reg)) #define ARGE_DESC_EMPTY (1 << 31) #define ARGE_DESC_MORE (1 << 24) @@ -132,11 +127,14 @@ struct arge_softc { */ uint32_t arge_media_type; uint32_t arge_duplex_mode; + uint32_t arge_phymask; + uint8_t arge_eaddr[ETHER_ADDR_LEN]; struct resource *arge_res; int arge_rid; struct resource *arge_irq; void *arge_intrhand; device_t arge_miibus; + device_t arge_miiproxy; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; @@ -148,7 +146,6 @@ struct arge_softc { int arge_detach; uint32_t arge_intr_status; int arge_mac_unit; - int arge_phymask; int arge_if_flags; uint32_t arge_debug; struct { From owner-svn-src-all@FreeBSD.ORG Tue May 1 06:21:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43960106564A; Tue, 1 May 2012 06:21:03 +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 CFADC8FC0C; Tue, 1 May 2012 06:21: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 q416L2Jw005604; Tue, 1 May 2012 06:21:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416L20c005601; Tue, 1 May 2012 06:21:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010621.q416L20c005601@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:21: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: r234863 - head/sys/mips/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:21:03 -0000 Author: adrian Date: Tue May 1 06:21:02 2012 New Revision: 234863 URL: http://svn.freebsd.org/changeset/base/234863 Log: Convert AP96 to use the mdioproxy and ARGE_MDIO option. arge1 still works (it's the standalone PHY) but arge0 and the other switch ports don't work. They're enumerated though, demonstrating that the mdiobus abstraction is correctly working. Modified: head/sys/mips/conf/AP96 head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96 ============================================================================== --- head/sys/mips/conf/AP96 Tue May 1 06:18:30 2012 (r234862) +++ head/sys/mips/conf/AP96 Tue May 1 06:21:02 2012 (r234863) @@ -40,3 +40,7 @@ options ROOTDEVNAME=\"ufs:map/ro options AR71XX_ATH_EEPROM # Fetch EEPROM/PCI config from flash options ATH_EEPROM_FIRMWARE # Use EEPROM from flash device firmware # Used by the above + +# Options required for miiproxy and mdiobus +options ARGE_MDIO # Export an MDIO bus separate from arge +device miiproxy # MDIO bus <-> MII PHY rendezvous Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Tue May 1 06:18:30 2012 (r234862) +++ head/sys/mips/conf/AP96.hints Tue May 1 06:21:02 2012 (r234863) @@ -1,15 +1,33 @@ # $FreeBSD$ +# arge0 MDIO bus - there's no arge1 MDIO bus for AR71xx +hint.argemdio.0.at="nexus0" +hint.argemdio.0.maddr=0x19000000 +hint.argemdio.0.msize=0x1000 +hint.argemdio.0.order=0 + +# Create two mdioproxy instances - by default only one is created +# per mdiobus above. +hint.mdioproxy.0.at="mdio0" +hint.mdioproxy.1.at="mdio0" + # TODO: RGMII +# XXX this port currently doesn't work with the current configuration. hint.arge.0.phymask=0x0f hint.arge.0.media=1000 hint.arge.0.fduplex=1 +# For now, rendezouvs this on the arge0 mdiobus. +# Later, this will rendezvous via the AR8316 switch. +hint.arge.0.mdio=mdioproxy0 # TODO: RGMII # TODO: pll_1000 = 0x1f000000 hint.arge.1.phymask=0x10 # hint.arge.1.media=1000 # hint.arge.1.fduplex=1 +# For now, rendezouvs this on the arge0 mdiobus. +# Later, this will rendezvous via the AR8316 switch. +hint.arge.1.mdio=mdioproxy1 # ath0 - slot 17 hint.pcib.0.bus.0.17.0.ath_fixup_addr=0x1fff1000 From owner-svn-src-all@FreeBSD.ORG Tue May 1 07:15:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F698106567A; Tue, 1 May 2012 07:15:18 +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 89C558FC12; Tue, 1 May 2012 07:15:18 +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 q417FIth007528; Tue, 1 May 2012 07:15:18 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417FIeh007526; Tue, 1 May 2012 07:15:18 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205010715.q417FIeh007526@svn.freebsd.org> From: Michael Tuexen Date: Tue, 1 May 2012 07:15:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234864 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:15:18 -0000 Author: tuexen Date: Tue May 1 07:15:18 2012 New Revision: 234864 URL: http://svn.freebsd.org/changeset/base/234864 Log: MFC r234762: Whitespace changes. Modified: stable/9/sys/netinet/sctp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Tue May 1 06:21:02 2012 (r234863) +++ stable/9/sys/netinet/sctp_usrreq.c Tue May 1 07:15:18 2012 (r234864) @@ -79,7 +79,6 @@ sctp_init(void) * now I will just copy. */ SCTP_BASE_SYSCTL(sctp_recvspace) = SCTP_BASE_SYSCTL(sctp_sendspace); - SCTP_BASE_VAR(first_time) = 0; SCTP_BASE_VAR(sctp_pcb_initialized) = 0; sctp_pcb_init(); @@ -88,8 +87,6 @@ sctp_init(void) SCTP_BASE_VAR(packet_log_end) = 0; bzero(&SCTP_BASE_VAR(packet_log_buffer), SCTP_PACKET_LOG_SIZE); #endif - - } void From owner-svn-src-all@FreeBSD.ORG Tue May 1 07:27:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2113A1065672; Tue, 1 May 2012 07:27:24 +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 0B5C28FC15; Tue, 1 May 2012 07:27: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 q417RNDO007986; Tue, 1 May 2012 07:27:23 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417RNiG007984; Tue, 1 May 2012 07:27:23 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205010727.q417RNiG007984@svn.freebsd.org> From: Michael Tuexen Date: Tue, 1 May 2012 07:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234865 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:27:24 -0000 Author: tuexen Date: Tue May 1 07:27:23 2012 New Revision: 234865 URL: http://svn.freebsd.org/changeset/base/234865 Log: MFC r234762: Whitespace changes. Modified: stable/8/sys/netinet/sctp_usrreq.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/8/sys/netinet/sctp_usrreq.c Tue May 1 07:15:18 2012 (r234864) +++ stable/8/sys/netinet/sctp_usrreq.c Tue May 1 07:27:23 2012 (r234865) @@ -79,7 +79,6 @@ sctp_init(void) * now I will just copy. */ SCTP_BASE_SYSCTL(sctp_recvspace) = SCTP_BASE_SYSCTL(sctp_sendspace); - SCTP_BASE_VAR(first_time) = 0; SCTP_BASE_VAR(sctp_pcb_initialized) = 0; sctp_pcb_init(); @@ -88,8 +87,6 @@ sctp_init(void) SCTP_BASE_VAR(packet_log_end) = 0; bzero(&SCTP_BASE_VAR(packet_log_buffer), SCTP_PACKET_LOG_SIZE); #endif - - } void From owner-svn-src-all@FreeBSD.ORG Tue May 1 07:38:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8024106566B; Tue, 1 May 2012 07:38:40 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C33368FC14; Tue, 1 May 2012 07:38:40 +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 q417ce2S008433; Tue, 1 May 2012 07:38:40 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417cewW008431; Tue, 1 May 2012 07:38:40 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201205010738.q417cewW008431@svn.freebsd.org> From: Ulrich Spoerlein Date: Tue, 1 May 2012 07:38:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234866 - head/sys/modules/mwl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:38:40 -0000 Author: uqs Date: Tue May 1 07:38:40 2012 New Revision: 234866 URL: http://svn.freebsd.org/changeset/base/234866 Log: Fix make depend. Modified: head/sys/modules/mwl/Makefile Modified: head/sys/modules/mwl/Makefile ============================================================================== --- head/sys/modules/mwl/Makefile Tue May 1 07:27:23 2012 (r234865) +++ head/sys/modules/mwl/Makefile Tue May 1 07:38:40 2012 (r234866) @@ -33,7 +33,7 @@ KMOD= if_mwl SRCS= if_mwl.c if_mwl_pci.c mwlhal.c -SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_mwl.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_mwl.h opt_wlan.h opt_mwl.h: echo '#define MWL_DEBUG 1'> $@ From owner-svn-src-all@FreeBSD.ORG Tue May 1 07:46:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8A6A1065675; Tue, 1 May 2012 07:46:30 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2D498FC08; Tue, 1 May 2012 07:46: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 q417kU5N008752; Tue, 1 May 2012 07:46:30 GMT (envelope-from daichi@svn.freebsd.org) Received: (from daichi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417kUSs008748; Tue, 1 May 2012 07:46:30 GMT (envelope-from daichi@svn.freebsd.org) Message-Id: <201205010746.q417kUSs008748@svn.freebsd.org> From: Daichi GOTO Date: Tue, 1 May 2012 07:46: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: r234867 - head/sys/fs/unionfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:46:30 -0000 Author: daichi Date: Tue May 1 07:46:30 2012 New Revision: 234867 URL: http://svn.freebsd.org/changeset/base/234867 Log: - fixed a vnode lock hang-up issue. - fixed an incorrect lock status issue. - fixed an incorrect lock issue of unionfs root vnode removed. (pointed out by keith) - fixed an infinity loop issue. (pointed out by dumbbell) - changed to do LK_RELEASE expressly when unlocked. Submitted by: ozawa@ongs.co.jp Modified: head/sys/fs/unionfs/union_subr.c head/sys/fs/unionfs/union_vfsops.c head/sys/fs/unionfs/union_vnops.c Modified: head/sys/fs/unionfs/union_subr.c ============================================================================== --- head/sys/fs/unionfs/union_subr.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_subr.c Tue May 1 07:46:30 2012 (r234867) @@ -2,8 +2,8 @@ * Copyright (c) 1994 Jan-Simon Pendry * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * * This code is derived from software contributed to Berkeley by * Jan-Simon Pendry. @@ -350,19 +350,22 @@ unionfs_noderem(struct vnode *vp, struct uvp = unp->un_uppervp; dvp = unp->un_dvp; unp->un_lowervp = unp->un_uppervp = NULLVP; - vp->v_vnlock = &(vp->v_lock); vp->v_data = NULL; - lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_INTERLOCK, VI_MTX(vp)); + vp->v_object = NULL; + VI_UNLOCK(vp); + if (lvp != NULLVP) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); if (uvp != NULLVP) - VOP_UNLOCK(uvp, 0); - vp->v_object = NULL; + VOP_UNLOCK(uvp, LK_RELEASE); if (dvp != NULLVP && unp->un_hash.le_prev != NULL) unionfs_rem_cached_vnode(unp, dvp); + if (lockmgr(vp->v_vnlock, LK_EXCLUSIVE, VI_MTX(vp)) != 0) + panic("the lock for deletion is unacquirable."); + if (lvp != NULLVP) { vfslocked = VFS_LOCK_GIANT(lvp->v_mount); vrele(lvp); @@ -550,7 +553,7 @@ unionfs_relookup(struct vnode *dvp, stru cn->cn_flags |= (cnp->cn_flags & SAVESTART); vref(dvp); - VOP_UNLOCK(dvp, 0); + VOP_UNLOCK(dvp, LK_RELEASE); if ((error = relookup(dvp, vpp, cn))) { uma_zfree(namei_zone, cn->cn_pnbuf); @@ -957,7 +960,7 @@ unionfs_vn_create_on_upper(struct vnode *vpp = vp; unionfs_vn_create_on_upper_free_out1: - VOP_UNLOCK(udvp, 0); + VOP_UNLOCK(udvp, LK_RELEASE); unionfs_vn_create_on_upper_free_out2: if (cn.cn_flags & HASBUF) { Modified: head/sys/fs/unionfs/union_vfsops.c ============================================================================== --- head/sys/fs/unionfs/union_vfsops.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_vfsops.c Tue May 1 07:46:30 2012 (r234867) @@ -1,8 +1,8 @@ /*- * Copyright (c) 1994, 1995 The Regents of the University of California. * Copyright (c) 1994, 1995 Jan-Simon Pendry. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * All rights reserved. * * This code is derived from software donated to Berkeley by @@ -165,7 +165,7 @@ unionfs_domount(struct mount *mp) uid = va.va_uid; gid = va.va_gid; } - VOP_UNLOCK(mp->mnt_vnodecovered, 0); + VOP_UNLOCK(mp->mnt_vnodecovered, LK_RELEASE); if (error) return (error); @@ -250,7 +250,7 @@ unionfs_domount(struct mount *mp) * Save reference */ if (below) { - VOP_UNLOCK(upperrootvp, 0); + VOP_UNLOCK(upperrootvp, LK_RELEASE); vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY); ump->um_lowervp = upperrootvp; ump->um_uppervp = lowerrootvp; @@ -281,7 +281,7 @@ unionfs_domount(struct mount *mp) /* * Unlock the node */ - VOP_UNLOCK(ump->um_uppervp, 0); + VOP_UNLOCK(ump->um_uppervp, LK_RELEASE); /* * Get the unionfs root vnode. Modified: head/sys/fs/unionfs/union_vnops.c ============================================================================== --- head/sys/fs/unionfs/union_vnops.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_vnops.c Tue May 1 07:46:30 2012 (r234867) @@ -2,8 +2,8 @@ * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry. * Copyright (c) 1992, 1993, 1994, 1995 * The Regents of the University of California. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -75,21 +75,6 @@ KASSERT(((vp)->v_op == &unionfs_vnodeops), \ ("unionfs: it is not unionfs-vnode")) -/* lockmgr lock <-> reverse table */ -struct lk_lr_table { - int lock; - int revlock; -}; - -static struct lk_lr_table un_llt[] = { - {LK_SHARED, LK_RELEASE}, - {LK_EXCLUSIVE, LK_RELEASE}, - {LK_UPGRADE, LK_DOWNGRADE}, - {LK_DOWNGRADE, LK_UPGRADE}, - {0, 0} -}; - - static int unionfs_lookup(struct vop_cachedlookup_args *ap) { @@ -141,7 +126,7 @@ unionfs_lookup(struct vop_cachedlookup_a if (udvp != NULLVP) { dtmpvp = udvp; if (ldvp != NULLVP) - VOP_UNLOCK(ldvp, 0); + VOP_UNLOCK(ldvp, LK_RELEASE); } else dtmpvp = ldvp; @@ -149,7 +134,7 @@ unionfs_lookup(struct vop_cachedlookup_a error = VOP_LOOKUP(dtmpvp, &vp, cnp); if (dtmpvp == udvp && ldvp != NULLVP) { - VOP_UNLOCK(udvp, 0); + VOP_UNLOCK(udvp, LK_RELEASE); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); } @@ -161,10 +146,10 @@ unionfs_lookup(struct vop_cachedlookup_a */ if (nameiop == DELETE || nameiop == RENAME || (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); vrele(vp); - VOP_UNLOCK(dvp, 0); + VOP_UNLOCK(dvp, LK_RELEASE); *(ap->a_vpp) = dunp->un_dvp; vref(dunp->un_dvp); @@ -202,7 +187,7 @@ unionfs_lookup(struct vop_cachedlookup_a } if (nameiop == DELETE || nameiop == RENAME || (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); } /* check whiteout */ @@ -246,7 +231,7 @@ unionfs_lookup(struct vop_cachedlookup_a return (lerror); } if (cnp->cn_lkflags & LK_TYPE_MASK) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); } } @@ -281,7 +266,7 @@ unionfs_lookup(struct vop_cachedlookup_a goto unionfs_lookup_out; if (LK_SHARED == (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); if (LK_EXCLUSIVE != VOP_ISLOCKED(vp)) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); lockflag = 1; @@ -289,7 +274,7 @@ unionfs_lookup(struct vop_cachedlookup_a error = unionfs_mkshadowdir(MOUNTTOUNIONFSMOUNT(dvp->v_mount), udvp, VTOUNIONFS(vp), cnp, td); if (lockflag != 0) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); if (error != 0) { UNIONFSDEBUG("unionfs_lookup: Unable to create shadow dir."); if ((cnp->cn_lkflags & LK_TYPE_MASK) == LK_EXCLUSIVE) @@ -386,7 +371,7 @@ unionfs_create(struct vop_create_args *a if (vp->v_type == VSOCK) *(ap->a_vpp) = vp; else { - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, curthread); vrele(vp); @@ -460,7 +445,7 @@ unionfs_mknod(struct vop_mknod_args *ap) if (vp->v_type == VSOCK) *(ap->a_vpp) = vp; else { - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, curthread); vrele(vp); @@ -564,6 +549,7 @@ unionfs_close(struct vop_close_args *ap) struct unionfs_node_status *unsp; struct ucred *cred; struct thread *td; + struct vnode *vp; struct vnode *ovp; UNIONFS_INTERNAL_DEBUG("unionfs_close: enter\n"); @@ -571,12 +557,14 @@ unionfs_close(struct vop_close_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); locked = 0; - unp = VTOUNIONFS(ap->a_vp); + vp = ap->a_vp; + unp = VTOUNIONFS(vp); cred = ap->a_cred; td = ap->a_td; - if (VOP_ISLOCKED(ap->a_vp) != LK_EXCLUSIVE) { - vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); + if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) { + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); locked = 1; } unionfs_get_node_status(unp, td, &unsp); @@ -599,7 +587,7 @@ unionfs_close(struct vop_close_args *ap) if (error != 0) goto unionfs_close_abort; - ap->a_vp->v_object = ovp->v_object; + vp->v_object = ovp->v_object; if (ovp == unp->un_uppervp) { unsp->uns_upper_opencnt--; @@ -610,7 +598,7 @@ unionfs_close(struct vop_close_args *ap) unsp->uns_lower_opencnt--; } if (unsp->uns_lower_opencnt > 0) - ap->a_vp->v_object = unp->un_lowervp->v_object; + vp->v_object = unp->un_lowervp->v_object; } } else unsp->uns_lower_opencnt--; @@ -619,7 +607,7 @@ unionfs_close_abort: unionfs_tryrem_node_status(unp, unsp); if (locked != 0) - VOP_UNLOCK(ap->a_vp, 0); + vn_lock(vp, LK_DOWNGRADE | LK_RETRY); UNIONFS_INTERNAL_DEBUG("unionfs_close: leave (%d)\n", error); @@ -914,7 +902,7 @@ unionfs_ioctl(struct vop_ioctl_args *ap) unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); unionfs_tryrem_node_status(unp, unsp); - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); if (ovp == NULLVP) return (EBADF); @@ -941,7 +929,7 @@ unionfs_poll(struct vop_poll_args *ap) unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); unionfs_tryrem_node_status(unp, unsp); - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); if (ovp == NULLVP) return (EBADF); @@ -1001,7 +989,7 @@ unionfs_remove(struct vop_remove_args *a ump = NULL; vp = uvp = lvp = NULLVP; /* search vnode */ - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); error = unionfs_relookup(udvp, &vp, cnp, &cn, td, cnp->cn_nameptr, strlen(cnp->cn_nameptr), DELETE); if (error != 0 && error != ENOENT) { @@ -1204,7 +1192,7 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_copyfile(unp, 1, fcnp->cn_cred, td); - VOP_UNLOCK(fvp, 0); + VOP_UNLOCK(fvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; break; @@ -1212,7 +1200,7 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_mkshadowdir(ump, rfdvp, unp, fcnp, td); - VOP_UNLOCK(fvp, 0); + VOP_UNLOCK(fvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; break; @@ -1269,13 +1257,13 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fdvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_relookup_for_delete(fdvp, fcnp, td); - VOP_UNLOCK(fdvp, 0); + VOP_UNLOCK(fdvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; /* Locke of tvp is canceled in order to avoid recursive lock. */ if (tvp != NULLVP && tvp != tdvp) - VOP_UNLOCK(tvp, 0); + VOP_UNLOCK(tvp, LK_RELEASE); error = unionfs_relookup_for_rename(tdvp, tcnp, td); if (tvp != NULLVP && tvp != tdvp) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); @@ -1293,11 +1281,11 @@ unionfs_rename(struct vop_rename_args *a } if (ltdvp != NULLVP) - VOP_UNLOCK(ltdvp, 0); + VOP_UNLOCK(ltdvp, LK_RELEASE); if (tdvp != rtdvp) vrele(tdvp); if (ltvp != NULLVP) - VOP_UNLOCK(ltvp, 0); + VOP_UNLOCK(ltvp, LK_RELEASE); if (tvp != rtvp && tvp != NULLVP) { if (rtvp == NULLVP) vput(tvp); @@ -1371,7 +1359,7 @@ unionfs_mkdir(struct vop_mkdir_args *ap) } if ((error = VOP_MKDIR(udvp, &uvp, cnp, ap->a_vap)) == 0) { - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); cnp->cn_lkflags = LK_EXCLUSIVE; error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, td); @@ -1427,7 +1415,9 @@ unionfs_rmdir(struct vop_rmdir_args *ap) ump = MOUNTTOUNIONFSMOUNT(ap->a_vp->v_mount); if (ump->um_whitemode == UNIONFS_WHITE_ALWAYS || lvp != NULLVP) cnp->cn_flags |= DOWHITEOUT; - error = VOP_RMDIR(udvp, uvp, cnp); + error = unionfs_relookup_for_delete(ap->a_dvp, cnp, td); + if (!error) + error = VOP_RMDIR(udvp, uvp, cnp); } else if (lvp != NULLVP) error = unionfs_mkwhiteout(udvp, cnp, td, unp->un_path); @@ -1467,7 +1457,7 @@ unionfs_symlink(struct vop_symlink_args if (udvp != NULLVP) { error = VOP_SYMLINK(udvp, &uvp, cnp, ap->a_vap, ap->a_target); if (error == 0) { - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); cnp->cn_lkflags = LK_EXCLUSIVE; error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, td); @@ -1487,9 +1477,11 @@ unionfs_readdir(struct vop_readdir_args int error; int eofflag; int locked; + int uio_offset_bk; struct unionfs_node *unp; struct unionfs_node_status *unsp; struct uio *uio; + struct vnode *vp; struct vnode *uvp; struct vnode *lvp; struct thread *td; @@ -1505,41 +1497,50 @@ unionfs_readdir(struct vop_readdir_args error = 0; eofflag = 0; locked = 0; - unp = VTOUNIONFS(ap->a_vp); + uio_offset_bk = 0; uio = ap->a_uio; - uvp = unp->un_uppervp; - lvp = unp->un_lowervp; + uvp = NULLVP; + lvp = NULLVP; td = uio->uio_td; ncookies_bk = 0; cookies_bk = NULL; - if (ap->a_vp->v_type != VDIR) + vp = ap->a_vp; + if (vp->v_type != VDIR) return (ENOTDIR); - /* check opaque */ - if (uvp != NULLVP && lvp != NULLVP) { - if ((error = VOP_GETATTR(uvp, &va, ap->a_cred)) != 0) - goto unionfs_readdir_exit; - if (va.va_flags & OPAQUE) - lvp = NULLVP; - } - /* check the open count. unionfs needs to open before readdir. */ - if (VOP_ISLOCKED(ap->a_vp) != LK_EXCLUSIVE) { - vn_lock(ap->a_vp, LK_UPGRADE | LK_RETRY); + if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) { + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); locked = 1; } - unionfs_get_node_status(unp, td, &unsp); - if ((uvp != NULLVP && unsp->uns_upper_opencnt <= 0) || - (lvp != NULLVP && unsp->uns_lower_opencnt <= 0)) { - unionfs_tryrem_node_status(unp, unsp); + unp = VTOUNIONFS(vp); + if (unp == NULL) error = EBADF; + else { + uvp = unp->un_uppervp; + lvp = unp->un_lowervp; + unionfs_get_node_status(unp, td, &unsp); + if ((uvp != NULLVP && unsp->uns_upper_opencnt <= 0) || + (lvp != NULLVP && unsp->uns_lower_opencnt <= 0)) { + unionfs_tryrem_node_status(unp, unsp); + error = EBADF; + } } - if (locked == 1) - vn_lock(ap->a_vp, LK_DOWNGRADE | LK_RETRY); + if (locked) + vn_lock(vp, LK_DOWNGRADE | LK_RETRY); if (error != 0) goto unionfs_readdir_exit; + /* check opaque */ + if (uvp != NULLVP && lvp != NULLVP) { + if ((error = VOP_GETATTR(uvp, &va, ap->a_cred)) != 0) + goto unionfs_readdir_exit; + if (va.va_flags & OPAQUE) + lvp = NULLVP; + } + /* upper only */ if (uvp != NULLVP && lvp == NULLVP) { error = VOP_READDIR(uvp, uio, ap->a_cred, ap->a_eofflag, @@ -1576,7 +1577,7 @@ unionfs_readdir(struct vop_readdir_args unsp->uns_readdir_status = 1; /* - * ufs(and other fs) needs size of uio_resid larger than + * UFS(and other FS) needs size of uio_resid larger than * DIRBLKSIZ. * size of DIRBLKSIZ equals DEV_BSIZE. * (see: ufs/ufs/ufs_vnops.c ufs_readdir func , ufs/ufs/dir.h) @@ -1585,7 +1586,7 @@ unionfs_readdir(struct vop_readdir_args goto unionfs_readdir_exit; /* - * backup cookies + * Backup cookies. * It prepares to readdir in lower. */ if (ap->a_ncookies != NULL) { @@ -1601,6 +1602,11 @@ unionfs_readdir(struct vop_readdir_args /* initialize for readdir in lower */ if (unsp->uns_readdir_status == 1) { unsp->uns_readdir_status = 2; + /* + * Backup uio_offset. See the comment after the + * VOP_READDIR call on the lower layer. + */ + uio_offset_bk = uio->uio_offset; uio->uio_offset = 0; } @@ -1612,6 +1618,19 @@ unionfs_readdir(struct vop_readdir_args error = VOP_READDIR(lvp, uio, ap->a_cred, ap->a_eofflag, ap->a_ncookies, ap->a_cookies); + /* + * We can't return an uio_offset of 0: this would trigger an + * infinite loop, because the next call to unionfs_readdir would + * always restart with the upper layer (uio_offset == 0) and + * always return some data. + * + * This happens when the lower layer root directory is removed. + * (A root directory deleting of unionfs should not be permitted. + * But current VFS can not do it.) + */ + if (uio->uio_offset == 0) + uio->uio_offset = uio_offset_bk; + if (cookies_bk != NULL) { /* merge cookies */ int size; @@ -1743,18 +1762,66 @@ unionfs_print(struct vop_print_args *ap) } static int -unionfs_get_llt_revlock(int flags) +unionfs_islocked(struct vop_islocked_args *ap) { - int count; + struct unionfs_node *unp; - flags &= LK_TYPE_MASK; - for (count = 0; un_llt[count].lock != 0; count++) { - if (flags == un_llt[count].lock) { - return un_llt[count].revlock; - } + KASSERT_UNIONFS_VNODE(ap->a_vp); + + unp = VTOUNIONFS(ap->a_vp); + if (unp == NULL) + return (vop_stdislocked(ap)); + + if (unp->un_uppervp != NULLVP) + return (VOP_ISLOCKED(unp->un_uppervp)); + if (unp->un_lowervp != NULLVP) + return (VOP_ISLOCKED(unp->un_lowervp)); + return (vop_stdislocked(ap)); +} + +static int +unionfs_get_llt_revlock(struct vnode *vp, int flags) +{ + int revlock; + + revlock = 0; + + switch (flags & LK_TYPE_MASK) { + case LK_SHARED: + if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) + revlock = LK_UPGRADE; + else + revlock = LK_RELEASE; + break; + case LK_EXCLUSIVE: + case LK_UPGRADE: + revlock = LK_RELEASE; + break; + case LK_DOWNGRADE: + revlock = LK_UPGRADE; + break; + default: + break; } - return 0; + return (revlock); +} + +/* + * The state of an acquired lock is adjusted similarly to + * the time of error generating. + * flags: LK_RELEASE or LK_UPGRADE + */ +static void +unionfs_revlock(struct vnode *vp, int flags) +{ + if (flags & LK_RELEASE) + VOP_UNLOCK(vp, flags); + else { + /* UPGRADE */ + if (vn_lock(vp, flags) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + } } static int @@ -1763,6 +1830,7 @@ unionfs_lock(struct vop_lock1_args *ap) int error; int flags; int revlock; + int interlock; int uhold; struct mount *mp; struct unionfs_mount *ump; @@ -1774,15 +1842,13 @@ unionfs_lock(struct vop_lock1_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); error = 0; + interlock = 1; uhold = 0; flags = ap->a_flags; vp = ap->a_vp; if (LK_RELEASE == (flags & LK_TYPE_MASK) || !(flags & LK_TYPE_MASK)) - return (VOP_UNLOCK(vp, flags)); - - if ((revlock = unionfs_get_llt_revlock(flags)) == 0) - panic("unknown lock type: 0x%x", flags & LK_TYPE_MASK); + return (VOP_UNLOCK(vp, flags | LK_RELEASE)); if ((flags & LK_INTERLOCK) == 0) VI_LOCK(vp); @@ -1798,6 +1864,9 @@ unionfs_lock(struct vop_lock1_args *ap) lvp = unp->un_lowervp; uvp = unp->un_uppervp; + if ((revlock = unionfs_get_llt_revlock(vp, flags)) == 0) + panic("unknown lock type: 0x%x", flags & LK_TYPE_MASK); + if ((mp->mnt_kern_flag & MNTK_MPSAFE) != 0 && (vp->v_iflag & VI_OWEINACT) != 0) flags |= LK_NOWAIT; @@ -1811,6 +1880,23 @@ unionfs_lock(struct vop_lock1_args *ap) flags |= LK_CANRECURSE; if (lvp != NULLVP) { + if (uvp != NULLVP && flags & LK_UPGRADE) { + /* Share Lock is once released and a deadlock is avoided. */ + VI_LOCK_FLAGS(uvp, MTX_DUPOK); + vholdl(uvp); + uhold = 1; + VI_UNLOCK(vp); + VOP_UNLOCK(uvp, LK_RELEASE | LK_INTERLOCK); + VI_LOCK(vp); + unp = VTOUNIONFS(vp); + if (unp == NULL) { + /* vnode is released. */ + VI_UNLOCK(vp); + VOP_UNLOCK(lvp, LK_RELEASE); + vdrop(uvp); + return (EBUSY); + } + } VI_LOCK_FLAGS(lvp, MTX_DUPOK); flags |= LK_INTERLOCK; vholdl(lvp); @@ -1823,19 +1909,28 @@ unionfs_lock(struct vop_lock1_args *ap) VI_LOCK(vp); unp = VTOUNIONFS(vp); if (unp == NULL) { + /* vnode is released. */ VI_UNLOCK(vp); if (error == 0) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); vdrop(lvp); + if (uhold != 0) + vdrop(uvp); return (vop_stdlock(ap)); } } if (error == 0 && uvp != NULLVP) { + if (uhold && flags & LK_UPGRADE) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } VI_LOCK_FLAGS(uvp, MTX_DUPOK); flags |= LK_INTERLOCK; - vholdl(uvp); - uhold = 1; + if (uhold == 0) { + vholdl(uvp); + uhold = 1; + } VI_UNLOCK(vp); ap->a_flags &= ~LK_INTERLOCK; @@ -1845,30 +1940,27 @@ unionfs_lock(struct vop_lock1_args *ap) VI_LOCK(vp); unp = VTOUNIONFS(vp); if (unp == NULL) { + /* vnode is released. */ VI_UNLOCK(vp); - if (error == 0) { - VOP_UNLOCK(uvp, 0); - if (lvp != NULLVP) - VOP_UNLOCK(lvp, 0); - } - if (lvp != NULLVP) - vdrop(lvp); + if (error == 0) + VOP_UNLOCK(uvp, LK_RELEASE); vdrop(uvp); + if (lvp != NULLVP) { + VOP_UNLOCK(lvp, LK_RELEASE); + vdrop(lvp); + } return (vop_stdlock(ap)); } - if (error != 0 && lvp != NULLVP) { + /* rollback */ VI_UNLOCK(vp); - if ((revlock & LK_TYPE_MASK) == LK_RELEASE) - VOP_UNLOCK(lvp, revlock); - else - vn_lock(lvp, revlock | LK_RETRY); - goto unionfs_lock_abort; + unionfs_revlock(lvp, revlock); + interlock = 0; } } - VI_UNLOCK(vp); -unionfs_lock_abort: + if (interlock) + VI_UNLOCK(vp); if (lvp != NULLVP) vdrop(lvp); if (uhold != 0) @@ -2013,7 +2105,7 @@ unionfs_advlock(struct vop_advlock_args unionfs_tryrem_node_status(unp, unsp); } - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = VOP_ADVLOCK(uvp, ap->a_id, ap->a_op, ap->a_fl, ap->a_flags); @@ -2022,7 +2114,7 @@ unionfs_advlock(struct vop_advlock_args return error; unionfs_advlock_abort: - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); UNIONFS_INTERNAL_DEBUG("unionfs_advlock: leave (%d)\n", error); @@ -2150,7 +2242,8 @@ unionfs_openextattr(struct vop_openextat error = VOP_OPENEXTATTR(tvp, ap->a_cred, ap->a_td); if (error == 0) { - vn_lock(vp, LK_UPGRADE | LK_RETRY); + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (tvp == unp->un_uppervp) unp->un_flag |= UNIONFS_OPENEXTU; else @@ -2186,7 +2279,8 @@ unionfs_closeextattr(struct vop_closeext error = VOP_CLOSEEXTATTR(tvp, ap->a_commit, ap->a_cred, ap->a_td); if (error == 0) { - vn_lock(vp, LK_UPGRADE | LK_RETRY); + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (tvp == unp->un_uppervp) unp->un_flag &= ~UNIONFS_OPENEXTU; else @@ -2435,6 +2529,7 @@ struct vop_vector unionfs_vnodeops = { .vop_getextattr = unionfs_getextattr, .vop_getwritemount = unionfs_getwritemount, .vop_inactive = unionfs_inactive, + .vop_islocked = unionfs_islocked, .vop_ioctl = unionfs_ioctl, .vop_link = unionfs_link, .vop_listextattr = unionfs_listextattr, From owner-svn-src-all@FreeBSD.ORG Tue May 1 08:19:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9A0E106566B; Tue, 1 May 2012 08:19:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3B088FC14; Tue, 1 May 2012 08:19: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 q418JTAq009950; Tue, 1 May 2012 08:19:29 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q418JT7k009948; Tue, 1 May 2012 08:19:29 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205010819.q418JT7k009948@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 08:19: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: r234868 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 08:19:30 -0000 Author: mav Date: Tue May 1 08:19:29 2012 New Revision: 234868 URL: http://svn.freebsd.org/changeset/base/234868 Log: Improve DDF metadata writing. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 07:46:30 2012 (r234867) +++ head/sys/geom/raid/md_ddf.c Tue May 1 08:19:29 2012 (r234868) @@ -89,9 +89,9 @@ struct g_raid_md_ddf_pervolume { struct g_raid_md_ddf_object { struct g_raid_md_object mdio_base; struct ddf_meta mdio_meta; + int mdio_starting; struct callout mdio_start_co; /* STARTING state timer. */ int mdio_started; - int mdio_incomplete; struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ }; @@ -835,7 +835,8 @@ ddf_vol_meta_create(struct ddf_vol_meta } static void -ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, uint8_t *GUID) +ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, + uint8_t *GUID, int started) { struct ddf_header *hdr; struct ddf_vd_entry *vde; @@ -850,15 +851,15 @@ ddf_vol_meta_update(struct ddf_vol_meta size = GET16(src, hdr->Configuration_Record_Length) * src->sectorsize; if (dst->vdc == NULL || - ((int32_t)(GET32D(src, vdc->Sequence_Number) - - GET32(dst, vdc->Sequence_Number))) > 0) + (!started && ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, vdc->Sequence_Number))) > 0)) vnew = 1; else vnew = 0; if (dst->bvdc[bvd] == NULL || - ((int32_t)(GET32D(src, vdc->Sequence_Number) - - GET32(dst, bvdc[bvd]->Sequence_Number))) > 0) + (!started && ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, bvdc[bvd]->Sequence_Number))) > 0)) bvnew = 1; else bvnew = 0; @@ -1803,6 +1804,7 @@ g_raid_md_ddf_start(struct g_raid_volume struct g_raid_disk *disk; struct g_raid_md_object *md; struct g_raid_md_ddf_pervolume *pv; + struct g_raid_md_ddf_object *mdi; struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; uint64_t *val2; @@ -1810,6 +1812,7 @@ g_raid_md_ddf_start(struct g_raid_volume sc = vol->v_softc; md = sc->sc_md; + mdi = (struct g_raid_md_ddf_object *)md; pv = vol->v_md_data; vmeta = &pv->pv_meta; vdc = vmeta->vdc; @@ -1862,6 +1865,7 @@ g_raid_md_ddf_start(struct g_raid_volume } pv->pv_started = 1; + mdi->mdio_starting--; callout_stop(&pv->pv_start_co); G_RAID_DEBUG1(0, sc, "Volume started."); g_raid_md_write_ddf(md, vol, NULL, NULL); @@ -1948,13 +1952,13 @@ g_raid_md_ddf_new_disk(struct g_raid_dis callout_reset(&pv->pv_start_co, g_raid_start_timeout * hz, g_raid_ddf_go, vol); + mdi->mdio_starting++; } else pv = vol->v_md_data; /* If we haven't started yet - check metadata freshness. */ vmeta = &pv->pv_meta; - if (vmeta->hdr == NULL || !pv->pv_started) - ddf_vol_meta_update(vmeta, pdmeta, vdc->VD_GUID); + ddf_vol_meta_update(vmeta, pdmeta, vdc->VD_GUID, pv->pv_started); } if (spare == 1) { @@ -2649,26 +2653,29 @@ g_raid_md_write_ddf(struct g_raid_md_obj if (sc->sc_stopping == G_RAID_DESTROY_HARD) return (0); - /* Generate new per-volume metadata for affected volumes. */ - TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { - if (vol->v_stopping) - continue; - - /* Skip volumes not related to specified targets. */ - if (tvol != NULL && vol != tvol) - continue; - if (tsd != NULL && vol != tsd->sd_volume) - continue; - if (tdisk != NULL) { - for (i = 0; i < vol->v_disks_count; i++) { - if (vol->v_subdisks[i].sd_disk == tdisk) - break; - } - if (i >= vol->v_disks_count) + /* + * Clear disk flags to let only really needed ones to be reset. + * Do it only if there are no volumes in starting state now, + * as they can update disk statuses yet and we may kill innocent. + */ + if (mdi->mdio_starting == 0) { + for (i = 0; i < GET16(gmeta, pdr->Populated_PDEs); i++) { + if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) continue; + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) & + ~DDF_PDE_PARTICIPATING); + if ((GET16(gmeta, pdr->entry[i].PD_State) & + DDF_PDE_PFA) == 0) + SET16(gmeta, pdr->entry[i].PD_State, 0); } + } + /* Generate/update new per-volume metadata. */ + TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; + if (vol->v_stopping || !pv->pv_started) + continue; vmeta = &pv->pv_meta; SET32(vmeta, vdc->Sequence_Number, @@ -2711,7 +2718,9 @@ g_raid_md_write_ddf(struct g_raid_md_obj SET8(vmeta, vde->VD_State, DDF_VDE_PARTIAL); else SET8(vmeta, vde->VD_State, DDF_VDE_OPTIMAL); - if (vol->v_dirty) + if (vol->v_dirty || + g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_STALE) > 0 || + g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_RESYNC) > 0) SET8(vmeta, vde->VD_State, GET8(vmeta, vde->VD_State) | DDF_VDE_DIRTY); SET8(vmeta, vde->Init_State, DDF_VDE_INIT_FULL); // XXX @@ -2719,45 +2728,50 @@ g_raid_md_write_ddf(struct g_raid_md_obj for (i = 0; i < vol->v_disks_count; i++) { sd = &vol->v_subdisks[i]; - disk = sd->sd_disk; - if (disk == NULL) - continue; - pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; bvd = i / GET16(vmeta, vdc->Primary_Element_Count); pos = i % GET16(vmeta, vdc->Primary_Element_Count); - if (vmeta->bvdc[bvd] == NULL) { - size = GET16(vmeta, - hdr->Configuration_Record_Length) * - vmeta->sectorsize; - vmeta->bvdc[bvd] = malloc(size, M_MD_DDF, M_WAITOK); - memcpy(vmeta->bvdc[bvd], vmeta->vdc, size); + disk = sd->sd_disk; + if (disk != NULL) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + if (vmeta->bvdc[bvd] == NULL) { + size = GET16(vmeta, + hdr->Configuration_Record_Length) * + vmeta->sectorsize; + vmeta->bvdc[bvd] = malloc(size, + M_MD_DDF, M_WAITOK); + memset(vmeta->bvdc[bvd], 0xff, size); + } + memcpy(vmeta->bvdc[bvd], vmeta->vdc, + sizeof(struct ddf_vdc_record)); SET8(vmeta, bvdc[bvd]->Secondary_Element_Seq, bvd); + SET64(vmeta, bvdc[bvd]->Block_Count, + sd->sd_size / vol->v_sectorsize); + SET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos], + GET32(&pd->pd_meta, pdd->PD_Reference)); + val2 = (uint64_t *)&(vmeta->bvdc[bvd]->Physical_Disk_Sequence[ + GET16(vmeta, hdr->Max_Primary_Element_Entries)]); + SET64P(vmeta, val2 + pos, + sd->sd_offset / vol->v_sectorsize); } - SET64(vmeta, bvdc[bvd]->Block_Count, - sd->sd_size / vol->v_sectorsize); - SET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos], - GET32(&pd->pd_meta, pdd->PD_Reference)); - val2 = (uint64_t *)&(vmeta->bvdc[bvd]->Physical_Disk_Sequence[ - GET16(vmeta, hdr->Max_Primary_Element_Entries)]); - SET64P(vmeta, val2 + pos, - sd->sd_offset / vol->v_sectorsize); + if (vmeta->bvdc[bvd] == NULL) + continue; j = ddf_meta_find_pd(gmeta, NULL, - GET32(&pd->pd_meta, pdd->PD_Reference)); + GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos])); if (j < 0) continue; SET32(gmeta, pdr->entry[j].PD_Type, GET32(gmeta, pdr->entry[j].PD_Type) | DDF_PDE_PARTICIPATING); - if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) + if (sd->sd_state == G_RAID_SUBDISK_S_NONE) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_PFA); - else if (sd->sd_state <= G_RAID_SUBDISK_S_UNINITIALIZED) + DDF_PDE_FAILED | DDF_PDE_MISSING); + else if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED); - else if (sd->sd_state < G_RAID_SUBDISK_S_ACTIVE) + DDF_PDE_FAILED | DDF_PDE_PFA); + else if (sd->sd_state <= G_RAID_SUBDISK_S_REBUILD) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | DDF_PDE_FAILED); @@ -2768,17 +2782,33 @@ g_raid_md_write_ddf(struct g_raid_md_obj } } + /* Remove disks without "participating" flag (unused). */ + for (i = 0, j = -1; i < GET16(gmeta, pdr->Populated_PDEs); i++) { + if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) + continue; + if (GET16(gmeta, pdr->entry[i].PD_Type) & DDF_PDE_PARTICIPATING) + j = i; + else + memset(&gmeta->pdr->entry[i], 0xff, + sizeof(struct ddf_pd_entry)); + } + SET16(gmeta, pdr->Populated_PDEs, j + 1); + + /* Update per-disk metadata and write them. */ TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE) continue; + /* Update PDR. */ memcpy(pd->pd_meta.pdr, gmeta->pdr, GET32(&pd->pd_meta, hdr->pdr_length) * pd->pd_meta.sectorsize); - TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { - vol = sd->sd_volume; + /* Update VDR. */ + SET16(&pd->pd_meta, vdr->Populated_VDEs, 0); + TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { + if (vol->v_stopping) + continue; pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; - vmeta = &pv->pv_meta; i = ddf_meta_find_vd(&pd->pd_meta, pv->pv_meta.vde->VD_GUID); if (i < 0) @@ -2787,14 +2817,22 @@ g_raid_md_write_ddf(struct g_raid_md_obj memcpy(&pd->pd_meta.vdr->entry[i], pv->pv_meta.vde, sizeof(struct ddf_vd_entry)); + } + /* Update VDC. */ + TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { + vol = sd->sd_volume; + if (vol->v_stopping) + continue; + pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; + vmeta = &pv->pv_meta; vdc = ddf_meta_find_vdc(&pd->pd_meta, - pv->pv_meta.vde->VD_GUID); + vmeta->vde->VD_GUID); if (vdc == NULL) vdc = ddf_meta_find_vdc(&pd->pd_meta, NULL); if (vdc != NULL) { bvd = sd->sd_pos / GET16(vmeta, vdc->Primary_Element_Count); - memcpy(vdc, pv->pv_meta.bvdc[bvd], + memcpy(vdc, vmeta->bvdc[bvd], GET16(&pd->pd_meta, hdr->Configuration_Record_Length) * pd->pd_meta.sectorsize); From owner-svn-src-all@FreeBSD.ORG Tue May 1 09:21:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 679EE106564A; Tue, 1 May 2012 09:21:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 520B48FC08; Tue, 1 May 2012 09:21:22 +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 q419LM2K012018; Tue, 1 May 2012 09:21:22 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q419LMGY012016; Tue, 1 May 2012 09:21:22 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205010921.q419LMGY012016@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 09:21:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234869 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 09:21:22 -0000 Author: mav Date: Tue May 1 09:21:21 2012 New Revision: 234869 URL: http://svn.freebsd.org/changeset/base/234869 Log: Implement volume deletion if disk has more then one partition. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 08:19:29 2012 (r234868) +++ head/sys/geom/raid/md_ddf.c Tue May 1 09:21:21 2012 (r234869) @@ -172,6 +172,13 @@ static struct g_raid_md_class g_raid_md_ #define SET32D(m, f, v) SET32P((m), &(f), (v)) #define SET64D(m, f, v) SET64P((m), &(f), (v)) +#define GETCRNUM(m) (GET32((m), hdr->cr_length) / \ + GET16((m), hdr->Configuration_Record_Length)) + +#define GETVDCPTR(m, n) ((struct ddf_vdc_record *)((uint8_t *)(m)->cr + \ + (n) * GET16((m), hdr->Configuration_Record_Length) * \ + (m)->sectorsize)) + static int isff(uint8_t *buf, int size) { @@ -254,7 +261,7 @@ g_raid_md_ddf_print(struct ddf_meta *met GET16(meta, cdr->Controller_Type.SubVendor_ID), GET16(meta, cdr->Controller_Type.SubDevice_ID)); printf("Product_ID '%.16s'\n", (char *)&meta->cdr->Product_ID[0]); - printf("**** Physical Disk Data ****\n"); + printf("**** Physical Disk Records ****\n"); printf("Populated_PDEs %u\n", GET16(meta, pdr->Populated_PDEs)); printf("Max_PDE_Supported %u\n", GET16(meta, pdr->Max_PDE_Supported)); for (j = 0; j < GET16(meta, pdr->Populated_PDEs); j++) { @@ -276,7 +283,7 @@ g_raid_md_ddf_print(struct ddf_meta *met printf("Block_Size %u\n", GET16(meta, pdr->entry[j].Block_Size)); } - printf("**** Virtual Disk Data ****\n"); + printf("**** Virtual Disk Records ****\n"); printf("Populated_VDEs %u\n", GET16(meta, vdr->Populated_VDEs)); printf("Max_VDE_Supported %u\n", GET16(meta, vdr->Max_VDE_Supported)); for (j = 0; j < GET16(meta, vdr->Populated_VDEs); j++) { @@ -299,11 +306,9 @@ g_raid_md_ddf_print(struct ddf_meta *met (char *)&meta->vdr->entry[j].VD_Name); } printf("**** Configuration Records ****\n"); - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (j = 0; j < num; j++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - j * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, j); val = GET32D(meta, vdc->Signature); switch (val) { case DDF_VDCR_SIGNATURE: @@ -463,11 +468,9 @@ ddf_meta_find_vdc(struct ddf_meta *meta, struct ddf_vdc_record *vdc; int i, num; - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GUID != NULL) { if (GET32D(meta, vdc->Signature) == DDF_VDCR_SIGNATURE && memcmp(vdc->VD_GUID, GUID, 24) == 0) @@ -486,11 +489,9 @@ ddf_meta_count_vdc(struct ddf_meta *meta int i, num, cnt; cnt = 0; - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) continue; if (GUID == NULL || memcmp(vdc->VD_GUID, GUID, 24) == 0) @@ -937,12 +938,9 @@ ddf_meta_unused_range(struct ddf_meta *m beg[0] = 0; end[0] = GET64(meta, pdr->entry[pos].Configured_Size); n = 1; - num = GET32(meta, hdr->cr_length) / - GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) continue; for (pos = 0; pos < GET16D(meta, vdc->Primary_Element_Count); pos++) @@ -1261,11 +1259,10 @@ err: if (error != 0) goto err; - size = GET16(meta, hdr->Configuration_Record_Length); - num = GET32(meta, hdr->cr_length) / size; - size *= ss; + size = GET16(meta, hdr->Configuration_Record_Length) * ss; + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + i * size); + vdc = GETVDCPTR(meta, i); SET32D(meta, vdc->CRC, 0xffffffff); SET32D(meta, vdc->CRC, crc32(vdc, size)); } @@ -1518,9 +1515,7 @@ g_raid_md_ddf_supported(int level, int q if (qual != G_RAID_VOLUME_RLQ_R1EA && qual != G_RAID_VOLUME_RLQ_R1EO) return (0); - if (disks < 2) - return (0); - if (disks % 2 != 0) + if (disks < 3) return (0); break; case G_RAID_VOLUME_RL_SINGLE: @@ -1922,11 +1917,9 @@ g_raid_md_ddf_new_disk(struct g_raid_dis else ddf_meta_update(&mdi->mdio_meta, pdmeta); - num = GET32(pdmeta, hdr->cr_length) / GET16(pdmeta, hdr->Configuration_Record_Length); + num = GETCRNUM(pdmeta); for (j = 0; j < num; j++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)pdmeta->cr + - j * GET16(pdmeta, hdr->Configuration_Record_Length) * - pdmeta->sectorsize); + vdc = GETVDCPTR(pdmeta, j); val = GET32D(pdmeta, vdc->Signature); if (val == DDF_SA_SIGNATURE && spare == -1) @@ -2819,6 +2812,17 @@ g_raid_md_write_ddf(struct g_raid_md_obj sizeof(struct ddf_vd_entry)); } /* Update VDC. */ + if (mdi->mdio_starting == 0) { + /* Remove all VDCs to restore needed later. */ + j = GETCRNUM(&pd->pd_meta); + for (i = 0; i < j; i++) { + vdc = GETVDCPTR(&pd->pd_meta, i); + if (GET32D(&pd->pd_meta, vdc->Signature) != + DDF_VDCR_SIGNATURE) + continue; + SET32D(&pd->pd_meta, vdc->Signature, 0xffffffff); + } + } TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { vol = sd->sd_volume; if (vol->v_stopping) @@ -2906,12 +2910,15 @@ static int g_raid_md_free_volume_ddf(struct g_raid_md_object *md, struct g_raid_volume *vol) { + struct g_raid_md_ddf_object *mdi; struct g_raid_md_ddf_pervolume *pv; + mdi = (struct g_raid_md_ddf_object *)md; pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; ddf_vol_meta_free(&pv->pv_meta); if (!pv->pv_started) { pv->pv_started = 1; + mdi->mdio_starting--; callout_stop(&pv->pv_start_co); } return (0); From owner-svn-src-all@FreeBSD.ORG Tue May 1 10:16:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE70B106564A; Tue, 1 May 2012 10:16:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FE108FC0C; Tue, 1 May 2012 10:16:13 +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 q41AGD2J020223; Tue, 1 May 2012 10:16:13 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41AGDMw020221; Tue, 1 May 2012 10:16:13 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205011016.q41AGDMw020221@svn.freebsd.org> From: Baptiste Daroussin Date: Tue, 1 May 2012 10:16:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234870 - head/usr.sbin/pkg X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 10:16:13 -0000 Author: bapt Date: Tue May 1 10:16:12 2012 New Revision: 234870 URL: http://svn.freebsd.org/changeset/base/234870 Log: - close the open file after fetching - create a default /usr/local/etc/pkg.conf Approved by: des (mentor) Modified: head/usr.sbin/pkg/pkg.c Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Tue May 1 09:21:21 2012 (r234869) +++ head/usr.sbin/pkg/pkg.c Tue May 1 10:16:12 2012 (r234870) @@ -282,7 +282,10 @@ static int bootstrap_pkg(void) { FILE *remote; + FILE *config; + char *site; char url[MAXPATHLEN]; + char conf[MAXPATHLEN]; char abi[BUFSIZ]; char tmppkg[MAXPATHLEN]; char buf[10240]; @@ -290,7 +293,6 @@ bootstrap_pkg(void) int fd, retry, ret; struct url_stat st; off_t done, r; - time_t begin_dl; time_t now; time_t last; @@ -298,6 +300,7 @@ bootstrap_pkg(void) last = 0; ret = -1; remote = NULL; + config = NULL; printf("Bootstrapping pkg please wait\n"); @@ -307,7 +310,7 @@ bootstrap_pkg(void) } if (getenv("PACKAGESITE") != NULL) - snprintf(url, MAXPATHLEN, "%s/pkg.txz", getenv("PACKAGESITE")); + snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz", getenv("PACKAGESITE")); else snprintf(url, MAXPATHLEN, "%s/%s/latest/Latest/pkg.txz", getenv("PACKAGEROOT") ? getenv("PACKAGEROOT") : _PKGS_URL, @@ -331,7 +334,6 @@ bootstrap_pkg(void) if (remote == NULL) goto fetchfail; - begin_dl = time(NULL); while (done < st.size) { if ((r = fread(buf, 1, sizeof(buf), remote)) < 1) break; @@ -353,12 +355,34 @@ bootstrap_pkg(void) if ((ret = extract_pkg_static(fd, pkgstatic, MAXPATHLEN)) == 0) ret = install_pkg_static(pkgstatic, tmppkg); + snprintf(conf, MAXPATHLEN, "%s/etc/pkg.conf", + getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE); + + if (access(conf, R_OK) == -1) { + site = strrchr(url, '/'); + if (site == NULL) + goto cleanup; + site[0] = '\0'; + site = strrchr(url, '/'); + if (site == NULL) + goto cleanup; + site[0] = '\0'; + + config = fopen(conf, "w+"); + if (config == NULL) + goto cleanup; + fprintf(config, "packagesite: %s", url); + fclose(config); + } + goto cleanup; fetchfail: warnx("Error fetching %s: %s", url, fetchLastErrString); cleanup: + if (remote != NULL) + fclose(remote); close(fd); unlink(tmppkg); From owner-svn-src-all@FreeBSD.ORG Tue May 1 10:49:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D283106564A; Tue, 1 May 2012 10:49:20 +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 868C58FC0C; Tue, 1 May 2012 10:49:20 +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 q41AnKqj021375; Tue, 1 May 2012 10:49:20 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41AnKsd021371; Tue, 1 May 2012 10:49:20 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205011049.q41AnKsd021371@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 1 May 2012 10:49:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234871 - in stable/9/lib/libc: include stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 10:49:20 -0000 Author: kib Date: Tue May 1 10:49:20 2012 New Revision: 234871 URL: http://svn.freebsd.org/changeset/base/234871 Log: MFC r234657: Take the spinlock around clearing of the fp->_flags in fclose(3), which indicates the avaliability of FILE, to prevent possible reordering of the writes as seen by other CPUs. Modified: stable/9/lib/libc/include/libc_private.h stable/9/lib/libc/stdio/fclose.c stable/9/lib/libc/stdio/findfp.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/include/libc_private.h ============================================================================== --- stable/9/lib/libc/include/libc_private.h Tue May 1 10:16:12 2012 (r234870) +++ stable/9/lib/libc/include/libc_private.h Tue May 1 10:49:20 2012 (r234871) @@ -81,6 +81,19 @@ void _rtld_error(const char *fmt, ...); #define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) #define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) +struct _spinlock; +extern struct _spinlock __stdio_thread_lock; +#define STDIO_THREAD_LOCK() \ +do { \ + if (__isthreaded) \ + _SPINLOCK(&__stdio_thread_lock); \ +} while (0) +#define STDIO_THREAD_UNLOCK() \ +do { \ + if (__isthreaded) \ + _SPINUNLOCK(&__stdio_thread_lock); \ +} while (0) + /* * Indexes into the pthread jump table. * Modified: stable/9/lib/libc/stdio/fclose.c ============================================================================== --- stable/9/lib/libc/stdio/fclose.c Tue May 1 10:16:12 2012 (r234870) +++ stable/9/lib/libc/stdio/fclose.c Tue May 1 10:49:20 2012 (r234871) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "un-namespace.h" +#include #include "libc_private.h" #include "local.h" @@ -65,7 +66,20 @@ fclose(FILE *fp) FREELB(fp); fp->_file = -1; fp->_r = fp->_w = 0; /* Mess up if reaccessed. */ + + /* + * Lock the spinlock used to protect __sglue list walk in + * __sfp(). The __sfp() uses fp->_flags == 0 test as an + * indication of the unused FILE. + * + * Taking the lock prevents possible compiler or processor + * reordering of the writes performed before the final _flags + * cleanup, making sure that we are done with the FILE before + * it is considered available. + */ + STDIO_THREAD_LOCK(); fp->_flags = 0; /* Release this FILE for reuse. */ + STDIO_THREAD_UNLOCK(); FUNLOCKFILE(fp); return (r); } Modified: stable/9/lib/libc/stdio/findfp.c ============================================================================== --- stable/9/lib/libc/stdio/findfp.c Tue May 1 10:16:12 2012 (r234870) +++ stable/9/lib/libc/stdio/findfp.c Tue May 1 10:49:20 2012 (r234871) @@ -82,9 +82,7 @@ static struct glue *lastglue = &uglue; static struct glue * moreglue(int); -static spinlock_t thread_lock = _SPINLOCK_INITIALIZER; -#define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock) -#define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock) +spinlock_t __stdio_thread_lock = _SPINLOCK_INITIALIZER; #if NOT_YET #define SET_GLUE_PTR(ptr, val) atomic_set_rel_ptr(&(ptr), (uintptr_t)(val)) @@ -127,22 +125,22 @@ __sfp() /* * The list must be locked because a FILE may be updated. */ - THREAD_LOCK(); + STDIO_THREAD_LOCK(); for (g = &__sglue; g != NULL; g = g->next) { for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) if (fp->_flags == 0) goto found; } - THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */ + STDIO_THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */ if ((g = moreglue(NDYNAMIC)) == NULL) return (NULL); - THREAD_LOCK(); /* reacquire the lock */ + STDIO_THREAD_LOCK(); /* reacquire the lock */ SET_GLUE_PTR(lastglue->next, g); /* atomically append glue to list */ lastglue = g; /* not atomic; only accessed when locked */ fp = g->iobs; found: fp->_flags = 1; /* reserve this slot; caller sets real flags */ - THREAD_UNLOCK(); + STDIO_THREAD_UNLOCK(); fp->_p = NULL; /* no current pointer */ fp->_w = 0; /* nothing to read or write */ fp->_r = 0; @@ -183,10 +181,10 @@ f_prealloc(void) for (g = &__sglue; (n -= g->niobs) > 0 && g->next; g = g->next) /* void */; if ((n > 0) && ((g = moreglue(n)) != NULL)) { - THREAD_LOCK(); + STDIO_THREAD_LOCK(); SET_GLUE_PTR(lastglue->next, g); lastglue = g; - THREAD_UNLOCK(); + STDIO_THREAD_UNLOCK(); } } From owner-svn-src-all@FreeBSD.ORG Tue May 1 11:45:17 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FF0C1065674; Tue, 1 May 2012 11:45:17 +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 296358FC14; Tue, 1 May 2012 11:45: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 q41BjH4i023366; Tue, 1 May 2012 11:45:17 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41BjGuo023362; Tue, 1 May 2012 11:45:16 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205011145.q41BjGuo023362@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 1 May 2012 11:45:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234872 - in stable/8/lib/libc: include stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 11:45:17 -0000 Author: kib Date: Tue May 1 11:45:16 2012 New Revision: 234872 URL: http://svn.freebsd.org/changeset/base/234872 Log: MFC r234657: Take the spinlock around clearing of the fp->_flags in fclose(3), which indicates the avaliability of FILE, to prevent possible reordering of the writes as seen by other CPUs. Modified: stable/8/lib/libc/include/libc_private.h stable/8/lib/libc/stdio/fclose.c stable/8/lib/libc/stdio/findfp.c Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/include/libc_private.h ============================================================================== --- stable/8/lib/libc/include/libc_private.h Tue May 1 10:49:20 2012 (r234871) +++ stable/8/lib/libc/include/libc_private.h Tue May 1 11:45:16 2012 (r234872) @@ -72,6 +72,19 @@ void _rtld_error(const char *fmt, ...); #define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) #define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) +struct _spinlock; +extern struct _spinlock __stdio_thread_lock; +#define STDIO_THREAD_LOCK() \ +do { \ + if (__isthreaded) \ + _SPINLOCK(&__stdio_thread_lock); \ +} while (0) +#define STDIO_THREAD_UNLOCK() \ +do { \ + if (__isthreaded) \ + _SPINUNLOCK(&__stdio_thread_lock); \ +} while (0) + /* * Indexes into the pthread jump table. * Modified: stable/8/lib/libc/stdio/fclose.c ============================================================================== --- stable/8/lib/libc/stdio/fclose.c Tue May 1 10:49:20 2012 (r234871) +++ stable/8/lib/libc/stdio/fclose.c Tue May 1 11:45:16 2012 (r234872) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "un-namespace.h" +#include #include "libc_private.h" #include "local.h" @@ -65,7 +66,20 @@ fclose(FILE *fp) FREELB(fp); fp->_file = -1; fp->_r = fp->_w = 0; /* Mess up if reaccessed. */ + + /* + * Lock the spinlock used to protect __sglue list walk in + * __sfp(). The __sfp() uses fp->_flags == 0 test as an + * indication of the unused FILE. + * + * Taking the lock prevents possible compiler or processor + * reordering of the writes performed before the final _flags + * cleanup, making sure that we are done with the FILE before + * it is considered available. + */ + STDIO_THREAD_LOCK(); fp->_flags = 0; /* Release this FILE for reuse. */ + STDIO_THREAD_UNLOCK(); FUNLOCKFILE(fp); return (r); } Modified: stable/8/lib/libc/stdio/findfp.c ============================================================================== --- stable/8/lib/libc/stdio/findfp.c Tue May 1 10:49:20 2012 (r234871) +++ stable/8/lib/libc/stdio/findfp.c Tue May 1 11:45:16 2012 (r234872) @@ -82,9 +82,7 @@ static struct glue *lastglue = &uglue; static struct glue * moreglue(int); -static spinlock_t thread_lock = _SPINLOCK_INITIALIZER; -#define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock) -#define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock) +spinlock_t __stdio_thread_lock = _SPINLOCK_INITIALIZER; #if NOT_YET #define SET_GLUE_PTR(ptr, val) atomic_set_rel_ptr(&(ptr), (uintptr_t)(val)) @@ -127,22 +125,22 @@ __sfp() /* * The list must be locked because a FILE may be updated. */ - THREAD_LOCK(); + STDIO_THREAD_LOCK(); for (g = &__sglue; g != NULL; g = g->next) { for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) if (fp->_flags == 0) goto found; } - THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */ + STDIO_THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */ if ((g = moreglue(NDYNAMIC)) == NULL) return (NULL); - THREAD_LOCK(); /* reacquire the lock */ + STDIO_THREAD_LOCK(); /* reacquire the lock */ SET_GLUE_PTR(lastglue->next, g); /* atomically append glue to list */ lastglue = g; /* not atomic; only accessed when locked */ fp = g->iobs; found: fp->_flags = 1; /* reserve this slot; caller sets real flags */ - THREAD_UNLOCK(); + STDIO_THREAD_UNLOCK(); fp->_p = NULL; /* no current pointer */ fp->_w = 0; /* nothing to read or write */ fp->_r = 0; @@ -183,10 +181,10 @@ f_prealloc() for (g = &__sglue; (n -= g->niobs) > 0 && g->next; g = g->next) /* void */; if ((n > 0) && ((g = moreglue(n)) != NULL)) { - THREAD_LOCK(); + STDIO_THREAD_LOCK(); SET_GLUE_PTR(lastglue->next, g); lastglue = g; - THREAD_UNLOCK(); + STDIO_THREAD_UNLOCK(); } } From owner-svn-src-all@FreeBSD.ORG Tue May 1 14:48:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DF8C106566C; Tue, 1 May 2012 14:48:52 +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 76AB88FC15; Tue, 1 May 2012 14:48:52 +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 q41EmqVZ029839; Tue, 1 May 2012 14:48:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Emp5t029823; Tue, 1 May 2012 14:48:51 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205011448.q41Emp5t029823@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 14:48:51 +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: r234873 - in head/sys/dev/ath: . ath_hal ath_hal/ar5210 ath_hal/ar5211 ath_hal/ar5212 ath_hal/ar5416 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 14:48:52 -0000 Author: adrian Date: Tue May 1 14:48:51 2012 New Revision: 234873 URL: http://svn.freebsd.org/changeset/base/234873 Log: Change the MIB cycle count API to return HAL_BOOL, rather than uint32_t, to return whether it was successful. Add placeholder (blank) methods for previous chips, for both it and the 11n extension channel busy call. Modified: head/sys/dev/ath/ath_hal/ah.h head/sys/dev/ath/ath_hal/ar5210/ar5210.h head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c head/sys/dev/ath/ath_hal/ar5211/ar5211.h head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c head/sys/dev/ath/ath_hal/ar5212/ar5212.h head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c head/sys/dev/ath/ath_hal/ar5416/ar5416.h head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/ath_hal/ah.h ============================================================================== --- head/sys/dev/ath/ath_hal/ah.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ah.h Tue May 1 14:48:51 2012 (r234873) @@ -1034,8 +1034,8 @@ struct ath_hal { struct ath_desc *); void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *, struct ath_desc *, u_int); - uint32_t __ahdecl(*ah_get_mib_cycle_counts_pct) (struct ath_hal *, - uint32_t *, uint32_t *, uint32_t *, uint32_t *); + HAL_BOOL __ahdecl(*ah_getMibCycleCounts) (struct ath_hal *, + HAL_SURVEY_SAMPLE *); uint32_t __ahdecl(*ah_get11nExtBusy)(struct ath_hal *); void __ahdecl(*ah_set11nMac2040)(struct ath_hal *, Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210.h Tue May 1 14:48:51 2012 (r234873) @@ -249,6 +249,9 @@ extern HAL_BOOL ar5210SetCapability(stru extern HAL_BOOL ar5210GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize); +extern uint32_t ar5210Get11nExtBusy(struct ath_hal *); +extern HAL_BOOL ar5210GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern u_int ar5210GetKeyCacheSize(struct ath_hal *); extern HAL_BOOL ar5210IsKeyCacheEntryValid(struct ath_hal *, uint16_t); Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -129,8 +129,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5210GetAckCTSRate, .ah_setCTSTimeout = ar5210SetCTSTimeout, .ah_getCTSTimeout = ar5210GetCTSTimeout, - .ah_setDecompMask = ar5210SetDecompMask, - .ah_setCoverageClass = ar5210SetCoverageClass, + .ah_setDecompMask = ar5210SetDecompMask, + .ah_setCoverageClass = ar5210SetCoverageClass, + .ah_get11nExtBusy = ar5210Get11nExtBusy, + .ah_getMibCycleCounts = ar5210GetMibCycleCounts, /* Key Cache Functions */ .ah_getKeyCacheSize = ar5210GetKeyCacheSize, Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -646,3 +646,24 @@ ar5210GetDiagState(struct ath_hal *ah, i return ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize); } + +/* + * Return what percentage of the extension channel is busy. + * This is always disabled for AR5210 series NICs. + */ +uint32_t +ar5210Get11nExtBusy(struct ath_hal *ah) +{ + + return (0); +} + +/* + * There's no channel survey support for the AR5210. + */ +HAL_BOOL +ar5210GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211.h Tue May 1 14:48:51 2012 (r234873) @@ -276,6 +276,9 @@ extern HAL_BOOL ar5211SetCapability(stru extern HAL_BOOL ar5211GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize); +extern uint32_t ar5211Get11nExtBusy(struct ath_hal *); +extern HAL_BOOL ar5211GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern u_int ar5211GetKeyCacheSize(struct ath_hal *); extern HAL_BOOL ar5211IsKeyCacheEntryValid(struct ath_hal *, uint16_t); Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -129,8 +129,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5211GetAckCTSRate, .ah_setCTSTimeout = ar5211SetCTSTimeout, .ah_getCTSTimeout = ar5211GetCTSTimeout, - .ah_setDecompMask = ar5211SetDecompMask, - .ah_setCoverageClass = ar5211SetCoverageClass, + .ah_setDecompMask = ar5211SetDecompMask, + .ah_setCoverageClass = ar5211SetCoverageClass, + .ah_get11nExtBusy = ar5211Get11nExtBusy, + .ah_getMibCycleCounts = ar5211GetMibCycleCounts, /* Key Cache Functions */ .ah_getKeyCacheSize = ar5211GetKeyCacheSize, Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -688,3 +688,24 @@ ar5211GetDiagState(struct ath_hal *ah, i } return AH_FALSE; } + +/* + * Return what percentage of the extension channel is busy. + * This is always disabled for AR5211 series NICs. + */ +uint32_t +ar5211Get11nExtBusy(struct ath_hal *ah) +{ + return (0); +} + + +/* + * There's no channel survey support for the AR5211. + */ +HAL_BOOL +ar5211GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h Tue May 1 14:48:51 2012 (r234873) @@ -511,6 +511,8 @@ extern HAL_BOOL ar5212GetDiagState(struc void **result, uint32_t *resultsize); extern HAL_STATUS ar5212SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration, uint32_t nextStart, HAL_QUIET_FLAG flag); +extern HAL_BOOL ar5212GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern HAL_BOOL ar5212SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip); Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -125,9 +125,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5212GetAckCTSRate, .ah_setCTSTimeout = ar5212SetCTSTimeout, .ah_getCTSTimeout = ar5212GetCTSTimeout, - .ah_setDecompMask = ar5212SetDecompMask, - .ah_setCoverageClass = ar5212SetCoverageClass, + .ah_setDecompMask = ar5212SetDecompMask, + .ah_setCoverageClass = ar5212SetCoverageClass, .ah_setQuiet = ar5212SetQuiet, + .ah_getMibCycleCounts = ar5212GetMibCycleCounts, /* DFS Functions */ .ah_enableDfs = ar5212EnableDfs, Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -1248,3 +1248,13 @@ ar5212Get11nExtBusy(struct ath_hal *ah) { return 0; } + +/* + * There's no channel survey support for the AR5211. + */ +HAL_BOOL +ar5212GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h Tue May 1 14:48:51 2012 (r234873) @@ -196,8 +196,8 @@ extern uint32_t ar5416GetCurRssi(struct extern HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING); extern HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int); extern void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int); -extern uint32_t ar5416GetMibCycleCounts(struct ath_hal *ah, - HAL_SURVEY_SAMPLE *hsample); +extern HAL_BOOL ar5416GetMibCycleCounts(struct ath_hal *ah, + HAL_SURVEY_SAMPLE *hsample); extern uint32_t ar5416Get11nExtBusy(struct ath_hal *ah); extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode); extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah); Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Tue May 1 14:48:51 2012 (r234873) @@ -847,7 +847,7 @@ ar5416AniGetListenTime(struct ath_hal *a if (ANI_ENA(ah)) aniState = ahp->ah_curani; - if (good == 0) { + if (good == AH_FALSE) { /* * Cycle counter wrap (or initial call); it's not possible * to accurately calculate a value because the registers Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -145,6 +145,7 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_setDecompMask = ar5416SetDecompMask; ah->ah_setCoverageClass = ar5416SetCoverageClass; ah->ah_setQuiet = ar5416SetQuiet; + ah->ah_getMibCycleCounts = ar5416GetMibCycleCounts; ah->ah_resetKeyCacheEntry = ar5416ResetKeyCacheEntry; ah->ah_setKeyCacheEntry = ar5416SetKeyCacheEntry; Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -184,11 +184,11 @@ ar5416SetCoverageClass(struct ath_hal *a /* * Return the busy for rx_frame, rx_clear, and tx_frame */ -uint32_t +HAL_BOOL ar5416GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) { struct ath_hal_5416 *ahp = AH5416(ah); - u_int32_t good = 1; + u_int32_t good = AH_TRUE; /* XXX freeze/unfreeze mib counters */ uint32_t rc = OS_REG_READ(ah, AR_RCCNT); @@ -205,7 +205,7 @@ ar5416GetMibCycleCounts(struct ath_hal * */ HALDEBUG(ah, HAL_DEBUG_ANY, "%s: cycle counter wrap. ExtBusy = 0\n", __func__); - good = 0; + good = AH_FALSE; } else { hsample->cycle_count = cc - ahp->ah_cycleCount; hsample->chan_busy = rc - ahp->ah_ctlBusy; @@ -224,7 +224,7 @@ ar5416GetMibCycleCounts(struct ath_hal * ahp->ah_txBusy = tf; ahp->ah_extBusy = ec; - return good; + return (good); } /* Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/if_athvar.h Tue May 1 14:48:51 2012 (r234873) @@ -1011,6 +1011,8 @@ void ath_intr(void *); ((*(_ah)->ah_isFastClockEnabled)((_ah))) #define ath_hal_radar_wait(_ah, _chan) \ ((*(_ah)->ah_radarWait)((_ah), (_chan))) +#define ath_hal_get_mib_cycle_counts(_ah, _sample) \ + ((*(_ah)->ah_getMibCycleCounts)((_ah), (_sample))) #define ath_hal_get_chan_ext_busy(_ah) \ ((*(_ah)->ah_get11nExtBusy)((_ah))) From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:35:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA25B106566B; Tue, 1 May 2012 15:35:10 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C36C28FC08; Tue, 1 May 2012 15:35:10 +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 q41FZA87032085; Tue, 1 May 2012 15:35:10 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FZAH1032079; Tue, 1 May 2012 15:35:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011535.q41FZAH1032079@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:35:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234874 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:35:10 -0000 Author: monthadar Date: Tue May 1 15:35:10 2012 New Revision: 234874 URL: http://svn.freebsd.org/changeset/base/234874 Log: Added Self-protected action category (including MPM). * Added new action category IEEE80211_ACTION_CAT_SELF_PROT which is used by 11s for Mesh Peering Management; * Updated Self protected enum Action codes to start from 1 instead of 0 according to the standard spec; * Removed old and wrong action categories IEEE80211_ACTION_CAT_MESHPEERING; * Modified ieee80211_mesh.c and ieee80211_action.c to use the new action category code; * Added earlier verification code in ieee80211_input; Approved by: adrian Modified: head/sys/net80211/ieee80211.h head/sys/net80211/ieee80211_action.c head/sys/net80211/ieee80211_input.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211.h ============================================================================== --- head/sys/net80211/ieee80211.h Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211.h Tue May 1 15:35:10 2012 (r234874) @@ -333,6 +333,8 @@ struct ieee80211_action { #define IEEE80211_ACTION_CAT_BA 3 /* BA */ #define IEEE80211_ACTION_CAT_HT 7 /* HT */ #define IEEE80211_ACTION_CAT_MESH 13 /* Mesh */ +#define IEEE80211_ACTION_CAT_SELF_PROT 15 /* Self-protected */ +/* 16 - 125 reserved */ #define IEEE80211_ACTION_CAT_VENDOR 127 /* Vendor Specific */ #define IEEE80211_ACTION_HT_TXCHWIDTH 0 /* recommended xmit chan width*/ Modified: head/sys/net80211/ieee80211_action.c ============================================================================== --- head/sys/net80211/ieee80211_action.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_action.c Tue May 1 15:35:10 2012 (r234874) @@ -94,7 +94,7 @@ ieee80211_send_action_register(int cat, break; ht_send_action[act] = f; return 0; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act >= N(meshpl_send_action)) break; meshpl_send_action[act] = f; @@ -144,7 +144,7 @@ ieee80211_send_action(struct ieee80211_n if (act < N(ht_send_action)) f = ht_send_action[act]; break; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act < N(meshpl_send_action)) f = meshpl_send_action[act]; break; @@ -215,7 +215,7 @@ ieee80211_recv_action_register(int cat, break; ht_recv_action[act] = f; return 0; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act >= N(meshpl_recv_action)) break; meshpl_recv_action[act] = f; @@ -269,7 +269,7 @@ ieee80211_recv_action(struct ieee80211_n if (ia->ia_action < N(ht_recv_action)) f = ht_recv_action[ia->ia_action]; break; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (ia->ia_action < N(meshpl_recv_action)) f = meshpl_recv_action[ia->ia_action]; break; Modified: head/sys/net80211/ieee80211_input.c ============================================================================== --- head/sys/net80211/ieee80211_input.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_input.c Tue May 1 15:35:10 2012 (r234874) @@ -792,6 +792,24 @@ ieee80211_parse_action(struct ieee80211_ return EINVAL; } break; + case IEEE80211_ACTION_CAT_SELF_PROT: + /* If TA or RA group address discard silently */ + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || + IEEE80211_IS_MULTICAST(wh->i_addr2)) + return EINVAL; + /* + * XXX: Should we verify complete length now or it is + * to varying in sizes? + */ + switch (ia->ia_action) { + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CLOSE: + /* is not a peering candidate (yet) */ + if (ni == vap->iv_bss) + return EINVAL; + break; + } + break; #endif } return 0; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:35:10 2012 (r234874) @@ -430,25 +430,25 @@ ieee80211_mesh_init(void) /* * Register action frame handlers. */ - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, mesh_recv_action_meshpeering_open); - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, mesh_recv_action_meshpeering_confirm); - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, mesh_recv_action_meshpeering_close); ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESH, IEEE80211_ACTION_MESH_LMETRIC, mesh_recv_action_meshlmetric); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, mesh_send_action_meshpeering_open); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, mesh_send_action_meshpeering_confirm); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, mesh_send_action_meshpeering_close); ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESH, @@ -485,7 +485,7 @@ mesh_vdetach_peers(void *arg, struct iee args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); } @@ -1440,7 +1440,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); args[0] = ni->ni_mlpid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); ni->ni_mlrcnt = 0; mesh_peer_timeout_setup(ni); @@ -1602,7 +1602,7 @@ mesh_parse_meshpeering_action(struct iee memset(mp, 0, sizeof(*mp)); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); /* NB: peer link ID is optional on these frames */ - if (subtype == IEEE80211_MESH_PEER_LINK_CLOSE && + if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE && mpie->peer_len == 8) { mp->peer_linkid = 0; mp->peer_rcode = LE_READ_2(&mpie->peer_linkid); @@ -1646,7 +1646,7 @@ mesh_parse_meshpeering_action(struct iee args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1689,13 +1689,13 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; /* Announce we're open too... */ ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); /* ...and confirm the link. */ args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); mesh_peer_timeout_setup(ni); @@ -1707,7 +1707,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mlpid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1718,7 +1718,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); break; @@ -1728,7 +1728,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); /* NB: don't setup/clear any timeout */ @@ -1740,7 +1740,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, @@ -1753,7 +1753,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); mesh_peer_timeout_stop(ni); @@ -1764,7 +1764,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mlpid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1774,7 +1774,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); break; @@ -1783,7 +1783,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = meshpeer->peer_llinkid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); break; @@ -1825,7 +1825,7 @@ mesh_recv_action_meshpeering_confirm(str args[1] = meshpeer->peer_llinkid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); break; @@ -1835,7 +1835,7 @@ mesh_recv_action_meshpeering_confirm(str args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1875,7 +1875,7 @@ mesh_recv_action_meshpeering_close(struc args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_MESH_CLOSE_RCVD; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1991,7 +1991,7 @@ mesh_send_action_meshpeering_open(struct frm = ieee80211_add_xrates(frm, rs); frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshconf(frm, vap); - frm = ieee80211_add_meshpeer(frm, IEEE80211_MESH_PEER_LINK_OPEN, + frm = ieee80211_add_meshpeer(frm, IEEE80211_ACTION_MESHPEERING_OPEN, args[0], 0, 0); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2059,7 +2059,7 @@ mesh_send_action_meshpeering_confirm(str frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshconf(frm, vap); frm = ieee80211_add_meshpeer(frm, - IEEE80211_MESH_PEER_LINK_CONFIRM, + IEEE80211_ACTION_MESHPEERING_CONFIRM, args[0], args[1], 0); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2110,7 +2110,7 @@ mesh_send_action_meshpeering_close(struc ADDSHORT(frm, args[2]); /* reason code */ frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshpeer(frm, - IEEE80211_MESH_PEER_LINK_CLOSE, + IEEE80211_ACTION_MESHPEERING_CLOSE, args[0], args[1], args[2]); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2234,7 +2234,7 @@ mesh_peer_timeout_cb(void *arg) args[0] = ni->ni_mlpid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); ni->ni_mlrcnt = 0; mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -2242,7 +2242,7 @@ mesh_peer_timeout_cb(void *arg) } else { args[0] = ni->ni_mlpid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); ni->ni_mlrcnt++; mesh_peer_timeout_backoff(ni); @@ -2253,7 +2253,7 @@ mesh_peer_timeout_cb(void *arg) args[0] = ni->ni_mlpid; args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); ni->ni_mlrcnt = 0; mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -2341,15 +2341,15 @@ mesh_verify_meshpeer(struct ieee80211vap meshpeer->peer_len > 10) return 1; switch (subtype) { - case IEEE80211_MESH_PEER_LINK_OPEN: + case IEEE80211_ACTION_MESHPEERING_OPEN: if (meshpeer->peer_len != 6) return 1; break; - case IEEE80211_MESH_PEER_LINK_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CONFIRM: if (meshpeer->peer_len != 8) return 1; break; - case IEEE80211_MESH_PEER_LINK_CLOSE: + case IEEE80211_ACTION_MESHPEERING_CLOSE: if (meshpeer->peer_len < 8) return 1; if (meshpeer->peer_len == 8 && meshpeer->peer_linkid != 0) @@ -2425,13 +2425,13 @@ ieee80211_add_meshpeer(uint8_t *frm, uin *frm++ = IEEE80211_ELEMID_MESHPEER; switch (subtype) { - case IEEE80211_MESH_PEER_LINK_OPEN: + case IEEE80211_ACTION_MESHPEERING_OPEN: *frm++ = 6; /* length */ memcpy(frm, meshpeerproto, 4); frm += 4; ADDSHORT(frm, localid); /* local ID */ break; - case IEEE80211_MESH_PEER_LINK_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CONFIRM: KASSERT(peerid != 0, ("sending peer confirm without peer id")); *frm++ = 8; /* length */ memcpy(frm, meshpeerproto, 4); @@ -2439,7 +2439,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin ADDSHORT(frm, localid); /* local ID */ ADDSHORT(frm, peerid); /* peer ID */ break; - case IEEE80211_MESH_PEER_LINK_CLOSE: + case IEEE80211_ACTION_MESHPEERING_CLOSE: if (peerid) *frm++ = 10; /* length */ else Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:35:10 2012 (r234874) @@ -149,13 +149,6 @@ struct ieee80211_meshpeer_ie { uint16_t peer_rcode; } __packed; -enum { - IEEE80211_MESH_PEER_LINK_OPEN = 0, - IEEE80211_MESH_PEER_LINK_CONFIRM = 1, - IEEE80211_MESH_PEER_LINK_CLOSE = 2, - /* values 3-255 are reserved */ -}; - /* Mesh Peering Management Protocol */ #define IEEE80211_MESH_PEER_PROTO_OUI 0x00, 0x0f, 0xac #define IEEE80211_MESH_PEER_PROTO_VALUE 0x2a @@ -331,9 +324,9 @@ struct ieee80211_meshpuc_ie { /* * 802.11s Action Frames + * XXX: these are wrong, and some of them should be + * under MESH category while PROXY is under MULTIHOP category. */ -#define IEEE80211_ACTION_CAT_MESHPEERING 30 /* XXX Linux */ -/* XXX: these need to be looked into */ #define IEEE80211_ACTION_CAT_INTERWORK 15 #define IEEE80211_ACTION_CAT_RESOURCE 16 #define IEEE80211_ACTION_CAT_PROXY 17 @@ -342,10 +335,11 @@ struct ieee80211_meshpuc_ie { * Mesh Peering Action codes. */ enum { - IEEE80211_ACTION_MESHPEERING_OPEN = 0, - IEEE80211_ACTION_MESHPEERING_CONFIRM = 1, - IEEE80211_ACTION_MESHPEERING_CLOSE = 2, - /* 3-255 reserved */ + /* 0 reserved */ + IEEE80211_ACTION_MESHPEERING_OPEN = 1, + IEEE80211_ACTION_MESHPEERING_CONFIRM = 2, + IEEE80211_ACTION_MESHPEERING_CLOSE = 3, + /* 4-255 reserved */ }; /* From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:39:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B407F106566B; Tue, 1 May 2012 15:39:16 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EE2A8FC15; Tue, 1 May 2012 15:39:16 +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 q41FdG8V032267; Tue, 1 May 2012 15:39:16 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FdG1A032264; Tue, 1 May 2012 15:39:16 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011539.q41FdG1A032264@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:39:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234875 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:39:16 -0000 Author: monthadar Date: Tue May 1 15:39:16 2012 New Revision: 234875 URL: http://svn.freebsd.org/changeset/base/234875 Log: Modified structure and code that handles Mesh peering management. * Old struct ieee80211_meshpeer_ie had wrong peer_proto field size; * Added IEEE80211_MPM_* size macros; * Created an enum for the Mesh Peering Protocol Identifier field according to the standard spec and removed old defines; * Abbreviated Handshake Protocol is not used by the standard anymore; * Modified mesh_verify_meshpeer to use IEEE80211_MPM_* macros for verification; * Modified mesh_parse_meshpeering_action to parse complete frame, also to parse it according to the standard spec; * Modified ieee80211_add_meshpeer to construct correct MPM frames according to the standard spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:35:10 2012 (r234874) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:39:16 2012 (r234875) @@ -1573,8 +1573,7 @@ mesh_recv_ctl(struct ieee80211_node *ni, } /* - * Parse meshpeering action ie's for open+confirm frames; the - * important bits are returned in the supplied structure. + * Parse meshpeering action ie's for open+confirm frames */ static const struct ieee80211_meshpeer_ie * mesh_parse_meshpeering_action(struct ieee80211_node *ni, @@ -1600,15 +1599,27 @@ mesh_parse_meshpeering_action(struct iee meshpeer = frm; mpie = (const struct ieee80211_meshpeer_ie *) frm; memset(mp, 0, sizeof(*mp)); + mp->peer_proto = LE_READ_2(&mpie->peer_proto); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); - /* NB: peer link ID is optional on these frames */ - if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE && - mpie->peer_len == 8) { - mp->peer_linkid = 0; - mp->peer_rcode = LE_READ_2(&mpie->peer_linkid); - } else { - mp->peer_linkid = LE_READ_2(&mpie->peer_linkid); - mp->peer_rcode = LE_READ_2(&mpie->peer_rcode); + switch (subtype) { + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + mp->peer_linkid = + LE_READ_2(&mpie->peer_linkid); + break; + case IEEE80211_ACTION_MESHPEERING_CLOSE: + /* NB: peer link ID is optional */ + if (mpie->peer_len == + (IEEE80211_MPM_BASE_SZ + 2)) { + mp->peer_linkid = 0; + mp->peer_rcode = + LE_READ_2(&mpie->peer_linkid); + } else { + mp->peer_linkid = + LE_READ_2(&mpie->peer_linkid); + mp->peer_rcode = + LE_READ_2(&mpie->peer_rcode); + } + break; } break; } @@ -2337,22 +2348,31 @@ mesh_verify_meshpeer(struct ieee80211vap const struct ieee80211_meshpeer_ie *meshpeer = (const struct ieee80211_meshpeer_ie *) ie; - if (meshpeer == NULL || meshpeer->peer_len < 6 || - meshpeer->peer_len > 10) + if (meshpeer == NULL || + meshpeer->peer_len < IEEE80211_MPM_BASE_SZ || + meshpeer->peer_len > IEEE80211_MPM_MAX_SZ) return 1; + if (meshpeer->peer_proto != IEEE80211_MPPID_MPM) { + IEEE80211_DPRINTF(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + "Only MPM protocol is supported (proto: 0x%02X)", + meshpeer->peer_proto); + return 1; + } switch (subtype) { case IEEE80211_ACTION_MESHPEERING_OPEN: - if (meshpeer->peer_len != 6) + if (meshpeer->peer_len != IEEE80211_MPM_BASE_SZ) return 1; break; case IEEE80211_ACTION_MESHPEERING_CONFIRM: - if (meshpeer->peer_len != 8) + if (meshpeer->peer_len != IEEE80211_MPM_BASE_SZ + 2) return 1; break; case IEEE80211_ACTION_MESHPEERING_CLOSE: - if (meshpeer->peer_len < 8) + if (meshpeer->peer_len < IEEE80211_MPM_BASE_SZ + 2) return 1; - if (meshpeer->peer_len == 8 && meshpeer->peer_linkid != 0) + if (meshpeer->peer_len == (IEEE80211_MPM_BASE_SZ + 2) && + meshpeer->peer_linkid != 0) return 1; if (meshpeer->peer_rcode == 0) return 1; @@ -2418,34 +2438,29 @@ uint8_t * ieee80211_add_meshpeer(uint8_t *frm, uint8_t subtype, uint16_t localid, uint16_t peerid, uint16_t reason) { - /* XXX change for AH */ - static const uint8_t meshpeerproto[4] = IEEE80211_MESH_PEER_PROTO; KASSERT(localid != 0, ("localid == 0")); *frm++ = IEEE80211_ELEMID_MESHPEER; switch (subtype) { case IEEE80211_ACTION_MESHPEERING_OPEN: - *frm++ = 6; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; - ADDSHORT(frm, localid); /* local ID */ + *frm++ = IEEE80211_MPM_BASE_SZ; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ + ADDSHORT(frm, localid); /* local ID */ break; case IEEE80211_ACTION_MESHPEERING_CONFIRM: KASSERT(peerid != 0, ("sending peer confirm without peer id")); - *frm++ = 8; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; - ADDSHORT(frm, localid); /* local ID */ - ADDSHORT(frm, peerid); /* peer ID */ + *frm++ = IEEE80211_MPM_BASE_SZ + 2; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ + ADDSHORT(frm, localid); /* local ID */ + ADDSHORT(frm, peerid); /* peer ID */ break; case IEEE80211_ACTION_MESHPEERING_CLOSE: if (peerid) - *frm++ = 10; /* length */ + *frm++ = IEEE80211_MPM_MAX_SZ; /* length */ else - *frm++ = 8; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; + *frm++ = IEEE80211_MPM_BASE_SZ + 2; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ ADDSHORT(frm, localid); /* local ID */ if (peerid) ADDSHORT(frm, peerid); /* peer ID */ Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:35:10 2012 (r234874) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:39:16 2012 (r234875) @@ -140,25 +140,24 @@ struct ieee80211_meshcngst_ie { } __packed; /* Peer Link Management */ +#define IEEE80211_MPM_BASE_SZ (4) +#define IEEE80211_MPM_MAX_SZ (8) struct ieee80211_meshpeer_ie { uint8_t peer_ie; /* IEEE80211_ELEMID_MESHPEER */ uint8_t peer_len; - uint8_t peer_proto[4]; /* Peer Management Protocol */ + uint16_t peer_proto; /* Peer Management Protocol */ uint16_t peer_llinkid; /* Local Link ID */ uint16_t peer_linkid; /* Peer Link ID */ uint16_t peer_rcode; } __packed; -/* Mesh Peering Management Protocol */ -#define IEEE80211_MESH_PEER_PROTO_OUI 0x00, 0x0f, 0xac -#define IEEE80211_MESH_PEER_PROTO_VALUE 0x2a -#define IEEE80211_MESH_PEER_PROTO { IEEE80211_MESH_PEER_PROTO_OUI, \ - IEEE80211_MESH_PEER_PROTO_VALUE } -/* Abbreviated Handshake Protocol */ -#define IEEE80211_MESH_PEER_PROTO_AH_OUI 0x00, 0x0f, 0xac -#define IEEE80211_MESH_PEER_PROTO_AH_VALUE 0x2b -#define IEEE80211_MESH_PEER_PROTO_AH { IEEE80211_MESH_PEER_PROTO_AH_OUI, \ - IEEE80211_MESH_PEER_PROTO_AH_VALUE } +/* Mesh Peering Protocol Identifier field value */ +enum { + IEEE80211_MPPID_MPM = 0, /* Mesh peering management */ + IEEE80211_MPPID_AUTH_MPM = 1, /* Auth. mesh peering exchange */ + /* 2-65535 reserved */ +}; + #ifdef notyet /* Mesh Channel Switch Annoucement */ struct ieee80211_meshcsa_ie { From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:42:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB1691065672; Tue, 1 May 2012 15:42:41 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B50248FC15; Tue, 1 May 2012 15:42:41 +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 q41FgfTS032425; Tue, 1 May 2012 15:42:41 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Fgf4P032422; Tue, 1 May 2012 15:42:41 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011542.q41Fgf4P032422@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:42:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234876 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:42:41 -0000 Author: monthadar Date: Tue May 1 15:42:41 2012 New Revision: 234876 URL: http://svn.freebsd.org/changeset/base/234876 Log: Fixed some MPM reason codes and max number of neighbors check * Added IEEE80211_MESH_MAX_NEIGHBORS and it is set to 15, same as before; * Modified mesh_parse_meshpeering_action to verify MPM frame and send correct reason code for when a frame is rejected according to standard spec; * Modified mesh_recv_action_meshpeering_* according to the standard spec; * Modified mesh_peer_timeout_cb to always send CLOSE frame when in CONFIRMRCV state according to the standard spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:39:16 2012 (r234875) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:42:41 2012 (r234876) @@ -1573,7 +1573,7 @@ mesh_recv_ctl(struct ieee80211_node *ni, } /* - * Parse meshpeering action ie's for open+confirm frames + * Parse meshpeering action ie's for MPM frames */ static const struct ieee80211_meshpeer_ie * mesh_parse_meshpeering_action(struct ieee80211_node *ni, @@ -1583,7 +1583,9 @@ mesh_parse_meshpeering_action(struct iee { struct ieee80211vap *vap = ni->ni_vap; const struct ieee80211_meshpeer_ie *mpie; + uint16_t args[3]; const uint8_t *meshid, *meshconf, *meshpeer; + uint8_t sendclose = 0; /* 1 = MPM frame rejected, close will be sent */ meshid = meshconf = meshpeer = NULL; while (efrm - frm > 1) { @@ -1599,6 +1601,7 @@ mesh_parse_meshpeering_action(struct iee meshpeer = frm; mpie = (const struct ieee80211_meshpeer_ie *) frm; memset(mp, 0, sizeof(*mp)); + mp->peer_len = mpie->peer_len; mp->peer_proto = LE_READ_2(&mpie->peer_proto); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); switch (subtype) { @@ -1627,22 +1630,46 @@ mesh_parse_meshpeering_action(struct iee } /* - * Verify the contents of the frame. Action frames with - * close subtype don't have a Mesh Configuration IE. - * If if fails validation, close the peer link. + * Verify the contents of the frame. + * If it fails validation, close the peer link. */ - KASSERT(meshpeer != NULL && - subtype != IEEE80211_ACTION_MESHPEERING_CLOSE, - ("parsing close action")); - - if (mesh_verify_meshid(vap, meshid) || - mesh_verify_meshpeer(vap, subtype, meshpeer) || - mesh_verify_meshconf(vap, meshconf)) { - uint16_t args[3]; + if (mesh_verify_meshpeer(vap, subtype, (const uint8_t *)mp)) { + sendclose = 1; + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "MPM validation failed"); + } + /* If meshid is not the same reject any frames type. */ + if (sendclose == 0 && mesh_verify_meshid(vap, meshid)) { + sendclose = 1; IEEE80211_DISCARD(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, wh, NULL, "%s", "not for our mesh"); + if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE) { + /* + * Standard not clear about this, if we dont ignore + * there will be an endless loop between nodes sending + * CLOSE frames between each other with wrong meshid. + * Discard and timers will bring FSM to IDLE state. + */ + return NULL; + } + } + + /* + * Close frames are accepted if meshid is the same. + * Verify the other two types. + */ + if (sendclose == 0 && subtype != IEEE80211_ACTION_MESHPEERING_CLOSE && + mesh_verify_meshconf(vap, meshconf)) { + sendclose = 1; + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "configuration missmatch"); + } + + if (sendclose) { vap->iv_stats.is_rx_mgtdiscard++; switch (ni->ni_mlstate) { case IEEE80211_NODE_MESH_IDLE: @@ -1655,7 +1682,15 @@ mesh_parse_meshpeering_action(struct iee case IEEE80211_NODE_MESH_CONFIRMRCV: args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; - args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; + /* Reason codes for rejection */ + switch (subtype) { + case IEEE80211_ACTION_MESHPEERING_OPEN: + args[2] = IEEE80211_REASON_MESH_CPVIOLATION; + break; + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + args[2] = IEEE80211_REASON_MESH_INCONS_PARAMS; + break; + } ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1666,6 +1701,7 @@ mesh_parse_meshpeering_action(struct iee } return NULL; } + return (const struct ieee80211_meshpeer_ie *) mp; } @@ -1675,6 +1711,7 @@ mesh_recv_action_meshpeering_open(struct const uint8_t *frm, const uint8_t *efrm) { struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_meshpeer_ie ie; const struct ieee80211_meshpeer_ie *meshpeer; uint16_t args[3]; @@ -1692,6 +1729,19 @@ mesh_recv_action_meshpeering_open(struct switch (ni->ni_mlstate) { case IEEE80211_NODE_MESH_IDLE: + /* Reject open request if reached our maximum neighbor count */ + if (ms->ms_neighbors >= IEEE80211_MESH_MAX_NEIGHBORS) { + args[0] = meshpeer->peer_llinkid; + args[1] = 0; + args[2] = IEEE80211_REASON_MESH_MAX_PEERS; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_CLOSE, + args); + /* stay in IDLE state */ + return (0); + } + /* Open frame accepted */ mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENRCV); ni->ni_mllid = meshpeer->peer_llinkid; ni->ni_mlpid = mesh_generateid(vap); @@ -1792,7 +1842,8 @@ mesh_recv_action_meshpeering_open(struct case IEEE80211_NODE_MESH_HOLDING: args[0] = ni->ni_mlpid; args[1] = meshpeer->peer_llinkid; - args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; + /* Standard not clear about what the reaason code should be */ + args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1830,11 +1881,13 @@ mesh_recv_action_meshpeering_confirm(str break; case IEEE80211_NODE_MESH_OPENSNT: mesh_linkchange(ni, IEEE80211_NODE_MESH_CONFIRMRCV); + mesh_peer_timeout_setup(ni); break; case IEEE80211_NODE_MESH_HOLDING: args[0] = ni->ni_mlpid; args[1] = meshpeer->peer_llinkid; - args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; + /* Standard not clear about what the reaason code should be */ + args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1869,8 +1922,23 @@ mesh_recv_action_meshpeering_close(struc const struct ieee80211_frame *wh, const uint8_t *frm, const uint8_t *efrm) { + struct ieee80211_meshpeer_ie ie; + const struct ieee80211_meshpeer_ie *meshpeer; uint16_t args[3]; + /* +2 for action + code */ + meshpeer = mesh_parse_meshpeering_action(ni, wh, frm+2, efrm, &ie, + IEEE80211_ACTION_MESHPEERING_CLOSE); + if (meshpeer == NULL) { + return 0; + } + + /* + * XXX: check reason code, for example we could receive + * IEEE80211_REASON_MESH_MAX_PEERS then we should not attempt + * to peer again. + */ + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, ni, "%s", "recv PEER CLOSE"); @@ -1894,7 +1962,7 @@ mesh_recv_action_meshpeering_close(struc break; case IEEE80211_NODE_MESH_HOLDING: mesh_linkchange(ni, IEEE80211_NODE_MESH_IDLE); - mesh_peer_timeout_setup(ni); + mesh_peer_timeout_stop(ni); break; } return 0; @@ -2112,13 +2180,11 @@ mesh_send_action_meshpeering_close(struc * mesh peer close action frame format: * [1] category * [1] action - * [2] reason code * [tlv] mesh id * [tlv] mesh peer link mgmt */ *frm++ = category; *frm++ = action; - ADDSHORT(frm, args[2]); /* reason code */ frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshpeer(frm, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -2260,19 +2326,13 @@ mesh_peer_timeout_cb(void *arg) } break; case IEEE80211_NODE_MESH_CONFIRMRCV: - if (ni->ni_mlrcnt == ieee80211_mesh_maxretries) { - args[0] = ni->ni_mlpid; - args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_SELF_PROT, - IEEE80211_ACTION_MESHPEERING_CLOSE, args); - ni->ni_mlrcnt = 0; - mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); - mesh_peer_timeout_setup(ni); - } else { - ni->ni_mlrcnt++; - mesh_peer_timeout_setup(ni); - } + args[0] = ni->ni_mlpid; + args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_CLOSE, args); + mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); + mesh_peer_timeout_setup(ni); break; case IEEE80211_NODE_MESH_HOLDING: mesh_linkchange(ni, IEEE80211_NODE_MESH_IDLE); @@ -2418,7 +2478,8 @@ ieee80211_add_meshconf(uint8_t *frm, str *frm++ = IEEE80211_MESHCONF_SYNC_NEIGHOFF; *frm++ = IEEE80211_MESHCONF_AUTH_DISABLED; /* NB: set the number of neighbors before the rest */ - *frm = (ms->ms_neighbors > 15 ? 15 : ms->ms_neighbors) << 1; + *frm = (ms->ms_neighbors > IEEE80211_MESH_MAX_NEIGHBORS ? + IEEE80211_MESH_MAX_NEIGHBORS : ms->ms_neighbors) << 1; if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) *frm |= IEEE80211_MESHCONF_FORM_MP; frm += 1; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:39:16 2012 (r234875) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:42:41 2012 (r234876) @@ -32,6 +32,7 @@ #define _NET80211_IEEE80211_MESH_H_ #define IEEE80211_MESH_DEFAULT_TTL 31 +#define IEEE80211_MESH_MAX_NEIGHBORS 15 /* * NB: all structures are __packed so sizeof works on arm, et. al. From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:47:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6EAC8106564A; Tue, 1 May 2012 15:47:31 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 589DC8FC0A; Tue, 1 May 2012 15:47: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 q41FlVbA032644; Tue, 1 May 2012 15:47:31 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FlVbJ032639; Tue, 1 May 2012 15:47:31 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011547.q41FlVbJ032639@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:47: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: r234877 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:47:31 -0000 Author: monthadar Date: Tue May 1 15:47:30 2012 New Revision: 234877 URL: http://svn.freebsd.org/changeset/base/234877 Log: Implemented so that Mesh forwarding information lifetime is dynamic. * Introduced ieee80211_mesh_rt_update that updates a route with the maximum(lifetime left, new lifetime); * Modified ieee80211_mesh_route struct by adding a lock that will be used by both ieee80211_mesh_rt_update and precursor code (added in future commit); * Modified in ieee80211_hwmp.c HWMP code to use new ieee80211_mesh_rt_update; * Modified mesh_rt_flush_invalid to use new ieee80211_mesh_rt_update; * mesh_rt_flush also checks that lifetime == 0, this gives route discovery a change to complete; * Modified mesh_recv_mgmt case IEEE80211_FC0_SUBTYPE_BEACON: when ever we received a beacon from a neighbor we update route lifetime; Approved by: adrian Modified: head/sys/net80211/ieee80211_ddb.c head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_ddb.c Tue May 1 15:47:30 2012 (r234877) @@ -870,8 +870,10 @@ _db_show_mesh(const struct ieee80211_mes TAILQ_FOREACH(rt, &ms->ms_routes, rt_next) { db_printf("entry %d:\tdest: %6D nexthop: %6D metric: %u", i, rt->rt_dest, ":", rt->rt_nexthop, ":", rt->rt_metric); + db_printf("\tlifetime: %u lastseq: %u priv: %p\n", - rt->rt_lifetime, rt->rt_lastmseq, rt->rt_priv); + ieee80211_mesh_rt_update(rt, 0), + rt->rt_lastmseq, rt->rt_priv); i++; } } Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:47:30 2012 (r234877) @@ -143,9 +143,6 @@ typedef uint32_t ieee80211_hwmp_seq; #define HWMP_SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) #define HWMP_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) -/* The longer one of the lifetime should be stored as new lifetime */ -#define MESH_ROUTE_LIFETIME_MAX(a, b) (a > b ? a : b) - /* * Private extension of ieee80211_mesh_route. */ @@ -938,7 +935,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* Data creation and update of forwarding information * according to Table 11C-8 for originator mesh STA. */ - if(HWMP_SEQ_GT(preq->preq_origseq, hrorig->hr_seq) || + if (HWMP_SEQ_GT(preq->preq_origseq, hrorig->hr_seq) || (HWMP_SEQ_EQ(preq->preq_origseq, hrorig->hr_seq) && preq->preq_metric < rtorig->rt_metric)) { hrorig->hr_seq = preq->preq_origseq; @@ -946,8 +943,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, rtorig->rt_metric = preq->preq_metric + ms->ms_pmetric->mpm_metric(ni); rtorig->rt_nhops = preq->preq_hopcount + 1; - rtorig->rt_lifetime = MESH_ROUTE_LIFETIME_MAX( - preq->preq_lifetime, rtorig->rt_lifetime); + ieee80211_mesh_rt_update(rtorig, preq->preq_lifetime); /* path to orig is valid now */ rtorig->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; }else if(hrtarg != NULL && @@ -1124,7 +1120,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, } } rt->rt_metric = preq->preq_metric; - rt->rt_lifetime = preq->preq_lifetime; + ieee80211_mesh_rt_update(rt, preq->preq_lifetime); hrorig = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); hrorig->hr_seq = preq->preq_origseq; @@ -1221,7 +1217,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, } IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); rt->rt_nhops = prep->prep_hopcount; - rt->rt_lifetime = prep->prep_lifetime; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); rt->rt_metric = prep->prep_metric; rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1300,7 +1296,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric, prep->prep_metric); IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); rt->rt_nhops = prep->prep_hopcount + 1; - rt->rt_lifetime = prep->prep_lifetime; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); rt->rt_metric = metric; rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; } else { @@ -1594,8 +1590,9 @@ hwmp_discover(struct ieee80211vap *vap, if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; - rt->rt_lifetime = - ticks_to_msecs(ieee80211_hwmp_pathtimeout); + /* XXX: special discovery timeout, larger lifetime? */ + ieee80211_mesh_rt_update(rt, + ticks_to_msecs(ieee80211_hwmp_pathtimeout)); /* XXX check preq retries */ sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, @@ -1613,7 +1610,8 @@ hwmp_discover(struct ieee80211vap *vap, preq.preq_id = ++hs->hs_preqid; IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); preq.preq_origseq = hr->hr_origseq; - preq.preq_lifetime = rt->rt_lifetime; + preq.preq_lifetime = + ticks_to_msecs(ieee80211_hwmp_pathtimeout); preq.preq_metric = rt->rt_metric; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest); Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:47:30 2012 (r234877) @@ -138,6 +138,10 @@ static const struct ieee80211_mesh_proto static struct ieee80211_mesh_proto_path mesh_proto_paths[4]; static struct ieee80211_mesh_proto_metric mesh_proto_metrics[4]; +#define RT_ENTRY_LOCK(rt) mtx_lock(&(rt)->rt_lock) +#define RT_ENTRY_LOCK_ASSERT(rt) mtx_assert(&(rt)->rt_lock, MA_OWNED) +#define RT_ENTRY_UNLOCK(rt) mtx_unlock(&(rt)->rt_lock) + #define MESH_RT_LOCK(ms) mtx_lock(&(ms)->ms_rt_lock) #define MESH_RT_LOCK_ASSERT(ms) mtx_assert(&(ms)->ms_rt_lock, MA_OWNED) #define MESH_RT_UNLOCK(ms) mtx_unlock(&(ms)->ms_rt_lock) @@ -146,6 +150,9 @@ MALLOC_DEFINE(M_80211_MESH_PREQ, "80211p MALLOC_DEFINE(M_80211_MESH_PREP, "80211prep", "802.11 MESH Path Reply frame"); MALLOC_DEFINE(M_80211_MESH_PERR, "80211perr", "802.11 MESH Path Error frame"); +/* The longer one of the lifetime should be stored as new lifetime */ +#define MESH_ROUTE_LIFETIME_MAX(a, b) (a > b ? a : b) + MALLOC_DEFINE(M_80211_MESH_RT, "80211mesh", "802.11s routing table"); /* @@ -183,7 +190,8 @@ mesh_rt_add_locked(struct ieee80211_mesh if (rt != NULL) { IEEE80211_ADDR_COPY(rt->rt_dest, dest); rt->rt_priv = (void *)ALIGN(&rt[1]); - rt->rt_crtime = ticks; + mtx_init(&rt->rt_lock, "MBSS_RT", "802.11s route entry", MTX_DEF); + rt->rt_updtime = ticks; /* create time */ TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next); } return rt; @@ -221,6 +229,41 @@ ieee80211_mesh_rt_add(struct ieee80211va } /* + * Update the route lifetime and returns the updated lifetime. + * If new_lifetime is zero and route is timedout it will be invalidated. + * new_lifetime is in msec + */ +int +ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int new_lifetime) +{ + int timesince, now; + uint32_t lifetime = 0; + + now = ticks; + RT_ENTRY_LOCK(rt); + timesince = ticks_to_msecs(now - rt->rt_updtime); + rt->rt_updtime = now; + if (timesince >= rt->rt_lifetime) { + if (new_lifetime != 0) { + rt->rt_lifetime = new_lifetime; + } + else { + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + rt->rt_lifetime = 0; + } + } else { + /* update what is left of lifetime */ + rt->rt_lifetime = rt->rt_lifetime - timesince; + rt->rt_lifetime = MESH_ROUTE_LIFETIME_MAX( + new_lifetime, rt->rt_lifetime); + } + lifetime = rt->rt_lifetime; + RT_ENTRY_UNLOCK(rt); + + return lifetime; +} + +/* * Add a proxy route (as needed) for the specified destination. */ void @@ -271,6 +314,12 @@ static __inline void mesh_rt_del(struct ieee80211_mesh_state *ms, struct ieee80211_mesh_route *rt) { TAILQ_REMOVE(&ms->ms_routes, rt, rt_next); + /* + * Grab the lock before destroying it, to be sure no one else + * is holding the route. + */ + RT_ENTRY_LOCK(rt); + mtx_destroy(&rt->rt_lock); free(rt, M_80211_MESH_RT); } @@ -335,8 +384,13 @@ mesh_rt_flush_invalid(struct ieee80211va return; MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { + ieee80211_mesh_rt_update(rt, 0); + /* + * NB: we check for lifetime == 0 so that we give a chance + * for route discovery to complete. + */ if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 && - ticks - rt->rt_crtime >= ms->ms_ppath->mpp_inact) + rt->rt_lifetime == 0) mesh_rt_del(ms, rt); } MESH_RT_UNLOCK(ms); @@ -1338,6 +1392,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211com *ic = ni->ni_ic; struct ieee80211_frame *wh; + struct ieee80211_mesh_route *rt; uint8_t *frm, *efrm; wh = mtod(m0, struct ieee80211_frame *); @@ -1430,20 +1485,40 @@ mesh_recv_mgmt(struct ieee80211_node *ni * XXX backoff on repeated failure */ if (ni != vap->iv_bss && - (ms->ms_flags & IEEE80211_MESHFLAGS_AP) && - ni->ni_mlstate == IEEE80211_NODE_MESH_IDLE) { - uint16_t args[1]; - - ni->ni_mlpid = mesh_generateid(vap); - if (ni->ni_mlpid == 0) - return; - mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); - args[0] = ni->ni_mlpid; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_SELF_PROT, - IEEE80211_ACTION_MESHPEERING_OPEN, args); - ni->ni_mlrcnt = 0; - mesh_peer_timeout_setup(ni); + (ms->ms_flags & IEEE80211_MESHFLAGS_AP)) { + switch (ni->ni_mlstate) { + case IEEE80211_NODE_MESH_IDLE: + { + uint16_t args[1]; + + ni->ni_mlpid = mesh_generateid(vap); + if (ni->ni_mlpid == 0) + return; + mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); + args[0] = ni->ni_mlpid; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_OPEN, args); + ni->ni_mlrcnt = 0; + mesh_peer_timeout_setup(ni); + break; + } + case IEEE80211_NODE_MESH_ESTABLISHED: + { + /* + * Valid beacon from a peer mesh STA + * bump TA lifetime + */ + rt = ieee80211_mesh_rt_find(vap, wh->i_addr2); + if(rt != NULL) { + ieee80211_mesh_rt_update(rt, + ms->ms_ppath->mpp_inact); + } + break; + } + default: + break; /* ignore */ + } } break; } @@ -2701,15 +2776,16 @@ mesh_ioctl_get80211(struct ieee80211vap break; imr = (struct ieee80211req_mesh_route *) (p + off); - imr->imr_flags = rt->rt_flags; IEEE80211_ADDR_COPY(imr->imr_dest, rt->rt_dest); IEEE80211_ADDR_COPY(imr->imr_nexthop, rt->rt_nexthop); imr->imr_metric = rt->rt_metric; imr->imr_nhops = rt->rt_nhops; - imr->imr_lifetime = rt->rt_lifetime; + imr->imr_lifetime = + ieee80211_mesh_rt_update(rt, 0); imr->imr_lastmseq = rt->rt_lastmseq; + imr->imr_flags = rt->rt_flags; /* last */ off += sizeof(*imr); } MESH_RT_UNLOCK(ms); Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:47:30 2012 (r234877) @@ -409,9 +409,19 @@ MALLOC_DECLARE(M_80211_MESH_PREP); MALLOC_DECLARE(M_80211_MESH_PERR); MALLOC_DECLARE(M_80211_MESH_RT); +/* + * Basic forwarding information: + * o Destination MAC + * o Next-hop MAC + * o Precursor list (not implemented yet) + * o Path timeout + * The rest is part of the active Mesh path selection protocol. + * XXX: to be moved out later. + */ struct ieee80211_mesh_route { TAILQ_ENTRY(ieee80211_mesh_route) rt_next; - int rt_crtime; /* creation time */ + struct mtx rt_lock; /* fine grained route lock */ + int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; uint32_t rt_metric; /* path metric */ @@ -419,7 +429,7 @@ struct ieee80211_mesh_route { uint16_t rt_flags; #define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* patch discovery complete */ #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ - uint32_t rt_lifetime; + uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ void *rt_priv; /* private data */ }; @@ -508,6 +518,7 @@ void ieee80211_mesh_rt_del(struct ieee8 void ieee80211_mesh_rt_flush(struct ieee80211vap *); void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); +int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int); void ieee80211_mesh_proxy_check(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:56:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31C79106566C; Tue, 1 May 2012 15:56:27 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1BB528FC16; Tue, 1 May 2012 15:56: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 q41FuRQC032998; Tue, 1 May 2012 15:56:27 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FuQP5032993; Tue, 1 May 2012 15:56:26 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011556.q41FuQP5032993@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:56: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: r234878 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:56:27 -0000 Author: monthadar Date: Tue May 1 15:56:26 2012 New Revision: 234878 URL: http://svn.freebsd.org/changeset/base/234878 Log: Mesh forwarding with proxy support. * Modified HWMP PREP/PREQ to contain a proxy entry and also changed PREP frame processing according to amendment as following: o Fixed PREP to always update/create if acceptance criteria is meet; o PREQ processing to reply if request is for a proxy entry that is proxied by us; o Removed hwmp_discover call from PREQ, because sending a PREP will build the forward path, and by receving and accepting a PREQ we have already built the reverse path (non-proactive code); * Disabled code for pro-active in PREP for now (will make a separate patch for pro-active HWMP routing later) * Added proxy information for a Mesh route, mesh gate to use and proxy seqno; * Modified ieee80211_encap according to amendment; * Introduced Mesh control address extension enum and removed unused struct, also rename some structure element names. * Modified mesh_input and added mesh_recv_* that should verify and process mesh data frames according to 9.32 Mesh forwarding framework in amendment; * Modified mesh_decap accordingly to changes done in mesh control AE struct; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:56:26 2012 (r234878) @@ -143,6 +143,8 @@ typedef uint32_t ieee80211_hwmp_seq; #define HWMP_SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) #define HWMP_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) +#define HWMP_SEQ_MAX(a, b) (a > b ? a : b) + /* * Private extension of ieee80211_mesh_route. */ @@ -866,7 +868,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { struct ieee80211_mesh_state *ms = vap->iv_mesh; - struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; struct ieee80211_mesh_route *rttarg = NULL; struct ieee80211_hwmp_route *hrorig = NULL; @@ -963,31 +965,44 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * Check if the PREQ is addressed to us. + * or a Proxy currently supplied by us. */ - if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0))) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "reply to %6D", preq->preq_origaddr, ":"); + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || + (rttarg != NULL && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { /* - * Build and send a PREP frame. + * When we are the target we shall update our own HWMP seq + * number with max of (current and preq->seq) + 1 */ + hs->hs_seq = HWMP_SEQ_MAX(hs->hs_seq, PREQ_TSEQ(0)) + 1; + prep.prep_flags = 0; + if (rttarg != NULL && /* if NULL it means we are the target */ + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply for proxy %6D", rttarg->rt_dest, ":"); + prep.prep_flags |= IEEE80211_MESHPREP_FLAGS_AE; + IEEE80211_ADDR_COPY(prep.prep_target_ext_addr, + rttarg->rt_dest); + /* update proxy seqno to HWMP seqno */ + rttarg->rt_ext_seq = hs->hs_seq; + } + /* + * Build and send a PREP frame. + */ prep.prep_hopcount = 0; prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(prep.prep_targetaddr, vap->iv_myaddr); - prep.prep_targetseq = ++hs->hs_seq; + prep.prep_targetseq = hs->hs_seq; prep.prep_lifetime = preq->preq_lifetime; prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL; IEEE80211_ADDR_COPY(prep.prep_origaddr, preq->preq_origaddr); prep.prep_origseq = preq->preq_origseq; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply to %6D", preq->preq_origaddr, ":"); hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep); - /* - * Build the reverse path, if we don't have it already. - */ - rt = ieee80211_mesh_rt_find(vap, preq->preq_origaddr); - if (rt == NULL) - hwmp_discover(vap, preq->preq_origaddr, NULL); - else if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) - hwmp_discover(vap, rt->rt_dest, NULL); return; } /* @@ -1179,15 +1194,19 @@ hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rtorig = NULL; + struct ieee80211_mesh_route *rtext = NULL; struct ieee80211_hwmp_route *hr; struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; struct mbuf *m, *next; uint32_t metric = 0; + const uint8_t *addr; /* - * Acceptance criteria: if the corresponding PREQ was not generated - * by us and forwarding is disabled, discard this PREP. + * Acceptance criteria: If the corresponding PREP was not generated + * by us or generated by an external mac that is proxied by us + * and forwarding is disabled, discard this PREP. */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) @@ -1195,10 +1214,21 @@ hwmp_recv_prep(struct ieee80211vap *vap, if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) return; + rtorig = ieee80211_mesh_rt_find(vap, prep->prep_origaddr); + if (rtorig != NULL && + !(rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP(%u) for an orig(%6D) not proxied by us", + prep->prep_origseq, prep->prep_origaddr, ":"); + return; + } + + /* PREP ACCEPTED */ IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PREP from %6D", prep->prep_targetaddr, ":"); +#if 0 rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); if (rt == NULL) { /* @@ -1228,10 +1258,30 @@ hwmp_recv_prep(struct ieee80211vap *vap, } return; } +#endif + /* - * Sequence number validation. + * If accepted shall create or update the active forwarding information + * it maintains for the target mesh STA of the PREP (according to the + * rules defined in 13.10.8.4). If the conditions for creating or + * updating the forwarding information have not been met in those + * rules, no further steps are applied to the PREP. + * [OPTIONAL]: update forwarding information to TA if metric improves. */ + rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); + if (rt == NULL) { + rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr); + if (rt == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to %6D", + prep->prep_targetaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } + } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + /* update path metric */ + metric = prep->prep_metric + ms->ms_pmetric->mpm_metric(ni); if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { if (HWMP_SEQ_LT(prep->prep_targetseq, hr->hr_seq)) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1240,7 +1290,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, prep->prep_targetseq, hr->hr_seq); return; } else if (HWMP_SEQ_LEQ(prep->prep_targetseq, hr->hr_seq) && - prep->prep_metric > rt->rt_metric) { + metric > rt->rt_metric) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREP from %6D, new metric %u > %u", prep->prep_targetaddr, ":", @@ -1249,7 +1299,21 @@ hwmp_recv_prep(struct ieee80211vap *vap, } } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "%s path to %6D, hopcount %d:%d metric %d:%d", + rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + prep->prep_targetaddr, ":", + rt->rt_nhops, prep->prep_hopcount, + rt->rt_metric, metric); + hr->hr_seq = prep->prep_targetseq; + IEEE80211_ADDR_COPY(rt->rt_nexthop, ni->ni_macaddr); + rt->rt_metric = metric; + rt->rt_nhops = prep->prep_hopcount + 1; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); + rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + /* * If it's NOT for us, propagate the PREP. */ @@ -1265,53 +1329,45 @@ hwmp_recv_prep(struct ieee80211vap *vap, pprep.prep_ttl -= 1; pprep.prep_metric += ms->ms_pmetric->mpm_metric(ni); hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep); + + /* may store target external address if recevied PREP w/ AE */ + /* precursor list for the Target Mesh STA Address is updated */ } - hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { - /* NB: never clobber a proxy entry */; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREP for %6D, route is marked PROXY", - prep->prep_targetaddr, ":"); - vap->iv_stats.is_hwmp_proxy++; - /* NB: first path discovery always fails */ - } else if (hr->hr_origseq == 0 || - prep->prep_origseq == hr->hr_origseq) { - /* - * Check if we already have a path to this node. - * If we do, check if this path reply contains a - * better route. - */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || - (prep->prep_hopcount < rt->rt_nhops || - prep->prep_metric < rt->rt_metric)) { - hr->hr_origseq = prep->prep_origseq; - metric = prep->prep_metric + - ms->ms_pmetric->mpm_metric(ni); - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "%s path to %6D, hopcount %d:%d metric %d:%d", - rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? - "prefer" : "update", - prep->prep_origaddr, ":", - rt->rt_nhops, prep->prep_hopcount, - rt->rt_metric, prep->prep_metric); - IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); - rt->rt_nhops = prep->prep_hopcount + 1; - ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_metric = metric; - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - } else { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "ignore PREP for %6D, hopcount %d:%d metric %d:%d", - prep->prep_targetaddr, ":", - rt->rt_nhops, prep->prep_hopcount, - rt->rt_metric, prep->prep_metric); + /* check if we received a PREP for a proxy address */ + else if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { + rtext = ieee80211_mesh_rt_find(vap, + prep->prep_target_ext_addr); + if (rtext == NULL) { + rtext = ieee80211_mesh_rt_add(vap, + prep->prep_target_ext_addr); + if (rtext == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to proxy %6D", + prep->prep_targetaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } } - } else { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREP for %6D, wrong orig seqno %u != %u", - prep->prep_targetaddr, ":", prep->prep_origseq, - hr->hr_origseq); - vap->iv_stats.is_hwmp_wrongseq++; + "%s path to %6D, hopcount %d:%d metric %d:%d", + rtext->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + prep->prep_target_ext_addr, ":", + rtext->rt_nhops, prep->prep_hopcount, + rtext->rt_metric, metric); + + rtext->rt_flags = IEEE80211_MESHRT_FLAGS_PROXY | + IEEE80211_MESHRT_FLAGS_VALID; + IEEE80211_ADDR_COPY(rtext->rt_dest, + prep->prep_target_ext_addr); + IEEE80211_ADDR_COPY(rtext->rt_mesh_gate, + prep->prep_targetaddr); + IEEE80211_ADDR_COPY(rtext->rt_nexthop, wh->i_addr2); + rtext->rt_metric = metric; + rtext->rt_lifetime = prep->prep_lifetime; + rtext->rt_nhops = prep->prep_hopcount + 1; + rtext->rt_ext_seq = prep->prep_origseq; /* proxy seq */ + /* proxy entries have no HWMP priv data, nullify them to be sure? */ } /* * Check for frames queued awaiting path discovery. @@ -1320,9 +1376,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, * stuck back on the stageq because there won't be * a path. */ + addr = prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE ? + prep->prep_target_ext_addr : prep->prep_targetaddr; m = ieee80211_ageq_remove(&ic->ic_stageq, (struct ieee80211_node *)(uintptr_t) - ieee80211_mac_hash(ic, rt->rt_dest)); + ieee80211_mac_hash(ic, addr)); /* either dest or ext_dest */ for (; m != NULL; m = next) { next = m->m_nextpkt; m->m_nextpkt = NULL; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:56:26 2012 (r234878) @@ -284,12 +284,14 @@ ieee80211_mesh_proxy_check(struct ieee80 } else { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, "%s", "add proxy entry"); + IEEE80211_ADDR_COPY(rt->rt_mesh_gate, vap->iv_myaddr); IEEE80211_ADDR_COPY(rt->rt_nexthop, vap->iv_myaddr); rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID | IEEE80211_MESHRT_FLAGS_PROXY; } - /* XXX assert PROXY? */ } else if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + KASSERT(rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY, + ("no proxy flag for poxy entry")); struct ieee80211com *ic = vap->iv_ic; /* * Fix existing entry created by received frames from @@ -910,9 +912,14 @@ mesh_forward(struct ieee80211vap *vap, s struct ieee80211_node *ni; int err; - if (mc->mc_ttl == 0) { + /* + * mesh ttl of 1 means we are the last one receving it, + * according to amendment we decrement and then check if + * 0, if so we dont forward. + */ + if (mc->mc_ttl < 1) { IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, - "%s", "frame not fwd'd, ttl 0"); + "%s", "frame not fwd'd, ttl 1"); vap->iv_stats.is_mesh_fwd_ttl++; return; } @@ -952,6 +959,12 @@ mesh_forward(struct ieee80211vap *vap, s } else { ni = mesh_find_txnode(vap, whcopy->i_addr3); if (ni == NULL) { + /* + * [Optional] any of the following three actions: + * o silently discard + * o trigger a path discovery + * o inform TA that meshDA is unreachable. + */ IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, no path"); vap->iv_stats.is_mesh_fwd_nopath++; @@ -980,9 +993,10 @@ mesh_forward(struct ieee80211vap *vap, s static struct mbuf * mesh_decap(struct ieee80211vap *vap, struct mbuf *m, int hdrlen, int meshdrlen) { -#define WHDIR(wh) ((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) +#define WHDIR(wh) ((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) uint8_t b[sizeof(struct ieee80211_qosframe_addr4) + - sizeof(struct ieee80211_meshcntl_ae11)]; + sizeof(struct ieee80211_meshcntl_ae10)]; const struct ieee80211_qosframe_addr4 *wh; const struct ieee80211_meshcntl_ae10 *mc; struct ether_header *eh; @@ -1016,13 +1030,14 @@ mesh_decap(struct ieee80211vap *vap, str m_adj(m, hdrlen - sizeof(*eh)); } eh = mtod(m, struct ether_header *); - ae = mc->mc_flags & 3; + ae = mc->mc_flags & IEEE80211_MESH_AE_MASK; if (WHDIR(wh) == IEEE80211_FC1_DIR_FROMDS) { IEEE80211_ADDR_COPY(eh->ether_dhost, wh->i_addr1); - if (ae == 0) { + if (ae == IEEE80211_MESH_AE_00) { IEEE80211_ADDR_COPY(eh->ether_shost, wh->i_addr3); - } else if (ae == 1) { - IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr4); + } else if (ae == IEEE80211_MESH_AE_01) { + IEEE80211_ADDR_COPY(eh->ether_shost, + MC01(mc)->mc_addr4); } else { IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, (const struct ieee80211_frame *)wh, NULL, @@ -1032,12 +1047,12 @@ mesh_decap(struct ieee80211vap *vap, str return NULL; } } else { - if (ae == 0) { + if (ae == IEEE80211_MESH_AE_00) { IEEE80211_ADDR_COPY(eh->ether_dhost, wh->i_addr3); IEEE80211_ADDR_COPY(eh->ether_shost, wh->i_addr4); - } else if (ae == 2) { - IEEE80211_ADDR_COPY(eh->ether_dhost, mc->mc_addr4); - IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr5); + } else if (ae == IEEE80211_MESH_AE_10) { + IEEE80211_ADDR_COPY(eh->ether_dhost, mc->mc_addr5); + IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr6); } else { IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, (const struct ieee80211_frame *)wh, NULL, @@ -1059,7 +1074,8 @@ mesh_decap(struct ieee80211vap *vap, str eh->ether_type = htons(m->m_pkthdr.len - sizeof(*eh)); } return m; -#undef WDIR +#undef WDIR +#undef MC01 } /* @@ -1075,12 +1091,13 @@ mesh_isucastforme(struct ieee80211vap *v KASSERT((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS, ("bad dir 0x%x:0x%x", wh->i_fc[0], wh->i_fc[1])); - KASSERT(ae == 0 || ae == 2, ("bad AE %d", ae)); - if (ae == 2) { /* ucast w/ proxy */ + KASSERT(ae == IEEE80211_MESH_AE_00 || ae == IEEE80211_MESH_AE_10, + ("bad AE %d", ae)); + if (ae == IEEE80211_MESH_AE_10) { /* ucast w/ proxy */ const struct ieee80211_meshcntl_ae10 *mc10 = (const struct ieee80211_meshcntl_ae10 *) mc; struct ieee80211_mesh_route *rt = - ieee80211_mesh_rt_find(vap, mc10->mc_addr4); + ieee80211_mesh_rt_find(vap, mc10->mc_addr5); /* check for proxy route to ourself */ return (rt != NULL && (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)); @@ -1088,19 +1105,139 @@ mesh_isucastforme(struct ieee80211vap *v return IEEE80211_ADDR_EQ(wh->i_addr3, vap->iv_myaddr); } +/* + * Verifies transmitter, updates lifetime, precursor list and forwards data. + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_indiv_data_to_fwrd(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ + + /* + * TODO: + * o verify addr2 is a legitimate transmitter + * o set lifetime of addr3 to initial value + * o set lifetime of addr4 to initial value + * o lifetime of precursor of addr3 (addr2) is max(init, curr) + * o lifetime of precursor of addr4 (nexthop) is max(init, curr) + */ + + mesh_forward(vap, m, mc); + return (1); /* dont process locally */ +} + +/* + * Verifies transmitter, updates lifetime, precursor list and process data + * locally, if data is is proxy with AE = 10 it could mean data should go + * on another mesh path or data should be forwarded to the DS. + * + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_indiv_data_to_me(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ + struct ieee80211_qosframe_addr4 *qwh; + const struct ieee80211_meshcntl_ae10 *mc10; + struct ieee80211_mesh_route *rt; + int ae; + + qwh = (struct ieee80211_qosframe_addr4 *)wh; + mc10 = (const struct ieee80211_meshcntl_ae10 *)mc; + + /* + * TODO: + * o verify addr2 is a legitimate transmitter + * o set lifetime of addr4 to initial value + * o lifetime of precursor entry is max(init, curr) + */ + + ae = mc10->mc_flags & IEEE80211_MESH_AE_MASK; + KASSERT(ae == IEEE80211_MESH_AE_00 || + ae == IEEE80211_MESH_AE_10, ("bad AE %d", ae)); + if (ae == IEEE80211_MESH_AE_10) { + if (IEEE80211_ADDR_EQ(mc10->mc_addr5, qwh->i_addr3)) { + return (0); /* process locally */ + } + + rt = ieee80211_mesh_rt_find(vap, mc10->mc_addr5); + if (rt != NULL && + (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) && + (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) == 0) { + /* + * Forward on another mesh-path, according to + * amendment as specified in 9.32.4.1 + */ + IEEE80211_ADDR_COPY(qwh->i_addr3, mc10->mc_addr5); + mesh_forward(vap, m, + (const struct ieee80211_meshcntl *)mc10); + return (1); /* dont process locally */ + } + /* + * All other cases: forward of MSDUs from the MBSS to DS indiv. + * addressed according to 13.11.3.2. + */ + } + return (0); /* process locally */ +} + +/* + * Try to forward the group addressed data on to other mesh STAs, and + * also to the DS. + * + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_group_data(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) + struct ieee80211_mesh_state *ms = vap->iv_mesh; + + mesh_forward(vap, m, mc); + + if(mc->mc_ttl > 0) { + if (mc->mc_flags & IEEE80211_MESH_AE_01) { + /* + * Forward of MSDUs from the MBSS to DS group addressed + * (according to 13.11.3.2) + * This happens by delivering the packet, and a bridge + * will sent it on another port member. + */ + if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL && + ms->ms_flags & IEEE80211_MESHFLAGS_FWD) + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, + MC01(mc)->mc_addr4, "%s", + "forward from MBSS to the DS"); + } + } + return (0); /* process locally */ +#undef MC01 +} + static int mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) { #define HAS_SEQ(type) ((type & 0x4) == 0) +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) +#define MC10(mc) ((const struct ieee80211_meshcntl_ae10 *)mc) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; struct ifnet *ifp = vap->iv_ifp; struct ieee80211_frame *wh; const struct ieee80211_meshcntl *mc; - int hdrspace, meshdrlen, need_tap; - uint8_t dir, type, subtype; + int hdrspace, meshdrlen, need_tap, error; + uint8_t dir, type, subtype, ae; uint32_t seq; - uint8_t *addr, qos[2]; + const uint8_t *addr; + uint8_t qos[2]; ieee80211_seq rxseq; KASSERT(ni != NULL, ("null node")); @@ -1189,7 +1326,7 @@ mesh_input(struct ieee80211_node *ni, st ni->ni_mlstate); vap->iv_stats.is_mesh_nolink++; goto out; - } + } if (dir != IEEE80211_FC1_DIR_FROMDS && dir != IEEE80211_FC1_DIR_DSTODS) { IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, @@ -1271,12 +1408,28 @@ mesh_input(struct ieee80211_node *ni, st */ mc = (const struct ieee80211_meshcntl *) (mtod(m, const uint8_t *) + hdrspace); + ae = mc->mc_flags & IEEE80211_MESH_AE_MASK; meshdrlen = sizeof(struct ieee80211_meshcntl) + - (mc->mc_flags & 3) * IEEE80211_ADDR_LEN; + ae * IEEE80211_ADDR_LEN; hdrspace += meshdrlen; + + /* pull complete hdrspace = ieee80211_hdrspace + meshcontrol */ + if ((meshdrlen > sizeof(struct ieee80211_meshcntl)) && + (m->m_len < hdrspace) && + ((m = m_pullup(m, hdrspace)) == NULL)) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + ni->ni_macaddr, NULL, + "data too short: expecting %u", hdrspace); + vap->iv_stats.is_rx_tooshort++; + goto out; /* XXX */ + } + /* XXX: are we sure there is no reallocating after m_pullup? */ + seq = LE_READ_4(mc->mc_seq); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) addr = wh->i_addr3; + else if (ae == IEEE80211_MESH_AE_01) + addr = MC01(mc)->mc_addr4; else addr = ((struct ieee80211_qosframe_addr4 *)wh)->i_addr4; if (IEEE80211_ADDR_EQ(vap->iv_myaddr, addr)) { @@ -1290,17 +1443,22 @@ mesh_input(struct ieee80211_node *ni, st goto out; } - /* - * Potentially forward packet. See table s36 (p140) - * for the rules. XXX tap fwd'd packets not for us? - */ - if (dir == IEEE80211_FC1_DIR_FROMDS || - !mesh_isucastforme(vap, wh, mc)) { - mesh_forward(vap, m, mc); - if (dir == IEEE80211_FC1_DIR_DSTODS) - goto out; - /* NB: fall thru to deliver mcast frames locally */ - } + /* This code "routes" the frame to the right control path */ + if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr3)) + error = + mesh_recv_indiv_data_to_me(vap, m, wh, mc); + else if (IEEE80211_IS_MULTICAST(wh->i_addr3)) + error = mesh_recv_group_data(vap, m, wh, mc); + else + error = mesh_recv_indiv_data_to_fwrd(vap, m, + wh, mc); + } else + error = mesh_recv_group_data(vap, m, wh, mc); + if (error < 0) + goto err; + else if (error > 0) + goto out; if (ieee80211_radiotap_active_vap(vap)) ieee80211_radiotap_rx(vap, m); @@ -1382,6 +1540,9 @@ out: m_freem(m); } return type; +#undef HAS_SEQ +#undef MC01 +#undef MC10 } static void @@ -2616,7 +2777,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin */ #define IEEE80211_MESH_MAXOVERHEAD \ (sizeof(struct ieee80211_qosframe_addr4) \ - + sizeof(struct ieee80211_meshcntl_ae11) \ + + sizeof(struct ieee80211_meshcntl_ae10) \ + sizeof(struct llc) \ + IEEE80211_ADDR_LEN \ + IEEE80211_WEP_IVLEN \ Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:56:26 2012 (r234878) @@ -390,19 +390,18 @@ struct ieee80211_meshcntl_ae10 { uint8_t mc_flags; /* Address Extension 10 */ uint8_t mc_ttl; /* TTL */ uint8_t mc_seq[4]; /* Sequence No. */ - uint8_t mc_addr4[IEEE80211_ADDR_LEN]; - uint8_t mc_addr5[IEEE80211_ADDR_LEN]; -} __packed; - -struct ieee80211_meshcntl_ae11 { - uint8_t mc_flags; /* Address Extension 11 */ - uint8_t mc_ttl; /* TTL */ - uint8_t mc_seq[4]; /* Sequence No. */ - uint8_t mc_addr4[IEEE80211_ADDR_LEN]; uint8_t mc_addr5[IEEE80211_ADDR_LEN]; uint8_t mc_addr6[IEEE80211_ADDR_LEN]; } __packed; +#define IEEE80211_MESH_AE_MASK 0x03 +enum { + IEEE80211_MESH_AE_00 = 0, /* MC has no AE subfield */ + IEEE80211_MESH_AE_01 = 1, /* MC contain addr4 */ + IEEE80211_MESH_AE_10 = 2, /* MC contain addr5 & addr6 */ + IEEE80211_MESH_AE_11 = 3, /* RESERVED */ +}; + #ifdef _KERNEL MALLOC_DECLARE(M_80211_MESH_PREQ); MALLOC_DECLARE(M_80211_MESH_PREP); @@ -423,6 +422,7 @@ struct ieee80211_mesh_route { struct mtx rt_lock; /* fine grained route lock */ int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; + uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ @@ -431,6 +431,7 @@ struct ieee80211_mesh_route { #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ + uint32_t rt_ext_seq; /* proxy seq number */ void *rt_priv; /* private data */ }; #define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv) Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_output.c Tue May 1 15:56:26 2012 (r234878) @@ -254,7 +254,7 @@ ieee80211_start(struct ifnet *ifp) if (!ieee80211_mesh_isproxyena(vap)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_OUTPUT | - IEEE80211_MSG_MESH, + IEEE80211_MSG_MESH, eh->ether_dhost, NULL, "%s", "proxy not enabled"); vap->iv_stats.is_mesh_notproxy++; @@ -363,7 +363,6 @@ ieee80211_start(struct ifnet *ifp) continue; } } - error = parent->if_transmit(parent, m); if (error != 0) { /* NB: IFQ_HANDOFF reclaims mbuf */ @@ -556,7 +555,6 @@ ieee80211_send_setup( break; case IEEE80211_M_MBSS: #ifdef IEEE80211_SUPPORT_MESH - /* XXX add support for proxied addresses */ if (IEEE80211_IS_MULTICAST(da)) { wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; /* XXX next hop */ @@ -1016,10 +1014,13 @@ ieee80211_encap(struct ieee80211vap *vap struct mbuf *m) { #define WH4(wh) ((struct ieee80211_frame_addr4 *)(wh)) +#define MC01(mc) ((struct ieee80211_meshcntl_ae01 *)mc) struct ieee80211com *ic = ni->ni_ic; #ifdef IEEE80211_SUPPORT_MESH struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_meshcntl_ae10 *mc; + struct ieee80211_mesh_route *rt = NULL; + int dir = -1; #endif struct ether_header eh; struct ieee80211_frame *wh; @@ -1100,21 +1101,40 @@ ieee80211_encap(struct ieee80211vap *vap * w/ 4-address format and address extension mode 10 */ is4addr = 0; /* NB: don't use, disable */ - if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) - hdrsize += IEEE80211_ADDR_LEN; /* unicast are 4-addr */ - meshhdrsize = sizeof(struct ieee80211_meshcntl); - /* XXX defines for AE modes */ - if (IEEE80211_ADDR_EQ(eh.ether_shost, vap->iv_myaddr)) { - if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) - meshae = 0; - else - meshae = 4; /* NB: pseudo */ - } else if (IEEE80211_IS_MULTICAST(eh.ether_dhost)) { - meshae = 1; - meshhdrsize += 1*IEEE80211_ADDR_LEN; + if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) { + rt = ieee80211_mesh_rt_find(vap, eh.ether_dhost); + KASSERT(rt != NULL, ("route is NULL")); + dir = IEEE80211_FC1_DIR_DSTODS; + hdrsize += IEEE80211_ADDR_LEN; + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + if (IEEE80211_ADDR_EQ(rt->rt_mesh_gate, + vap->iv_myaddr)) { + IEEE80211_NOTE_MAC(vap, + IEEE80211_MSG_MESH, + eh.ether_dhost, + "%s", "trying to send to ourself"); + goto bad; + } + meshae = IEEE80211_MESH_AE_10; + meshhdrsize = + sizeof(struct ieee80211_meshcntl_ae10); + } else { + meshae = IEEE80211_MESH_AE_00; + meshhdrsize = + sizeof(struct ieee80211_meshcntl); + } } else { - meshae = 2; - meshhdrsize += 2*IEEE80211_ADDR_LEN; + dir = IEEE80211_FC1_DIR_FROMDS; + if (!IEEE80211_ADDR_EQ(eh.ether_shost, vap->iv_myaddr)) { + /* proxy group */ + meshae = IEEE80211_MESH_AE_01; + meshhdrsize = + sizeof(struct ieee80211_meshcntl_ae01); + } else { + /* group */ + meshae = IEEE80211_MESH_AE_00; + meshhdrsize = sizeof(struct ieee80211_meshcntl); + } } } else { #endif @@ -1215,44 +1235,52 @@ ieee80211_encap(struct ieee80211vap *vap /* NB: offset by hdrspace to deal with DATAPAD */ mc = (struct ieee80211_meshcntl_ae10 *) (mtod(m, uint8_t *) + hdrspace); + wh->i_fc[1] = dir; switch (meshae) { - case 0: /* ucast, no proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS; - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr); - IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost); - IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, eh.ether_shost); + case IEEE80211_MESH_AE_00: /* no proxy */ mc->mc_flags = 0; - qos = ((struct ieee80211_qosframe_addr4 *) wh)->i_qos; - break; - case 4: /* mcast, no proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; - IEEE80211_ADDR_COPY(wh->i_addr1, eh.ether_dhost); - IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_shost); - mc->mc_flags = 0; /* NB: AE is really 0 */ - qos = ((struct ieee80211_qosframe *) wh)->i_qos; + if (dir == IEEE80211_FC1_DIR_DSTODS) { /* ucast */ + IEEE80211_ADDR_COPY(wh->i_addr1, + ni->ni_macaddr); + IEEE80211_ADDR_COPY(wh->i_addr2, + vap->iv_myaddr); + IEEE80211_ADDR_COPY(wh->i_addr3, + eh.ether_dhost); + IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, + eh.ether_shost); + qos =((struct ieee80211_qosframe_addr4 *) + wh)->i_qos; + } else if (dir == IEEE80211_FC1_DIR_FROMDS) { + /* mcast */ + IEEE80211_ADDR_COPY(wh->i_addr1, + eh.ether_dhost); + IEEE80211_ADDR_COPY(wh->i_addr2, + vap->iv_myaddr); + IEEE80211_ADDR_COPY(wh->i_addr3, + eh.ether_shost); + qos = ((struct ieee80211_qosframe *) + wh)->i_qos; + } break; - case 1: /* mcast, proxy */ + case IEEE80211_MESH_AE_01: /* mcast, proxy */ wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; IEEE80211_ADDR_COPY(wh->i_addr1, eh.ether_dhost); IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); IEEE80211_ADDR_COPY(wh->i_addr3, vap->iv_myaddr); mc->mc_flags = 1; - IEEE80211_ADDR_COPY(mc->mc_addr4, eh.ether_shost); + IEEE80211_ADDR_COPY(MC01(mc)->mc_addr4, + eh.ether_shost); qos = ((struct ieee80211_qosframe *) wh)->i_qos; break; - case 2: /* ucast, proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS; - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr); + case IEEE80211_MESH_AE_10: /* ucast, proxy */ + KASSERT(rt != NULL, ("route is NULL")); + IEEE80211_ADDR_COPY(wh->i_addr1, rt->rt_nexthop); IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - /* XXX not right, need MeshDA */ - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost); - /* XXX assume are MeshSA */ + IEEE80211_ADDR_COPY(wh->i_addr3, rt->rt_mesh_gate); IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, vap->iv_myaddr); - mc->mc_flags = 2; - IEEE80211_ADDR_COPY(mc->mc_addr4, eh.ether_dhost); - IEEE80211_ADDR_COPY(mc->mc_addr5, eh.ether_shost); + mc->mc_flags = IEEE80211_MESH_AE_10; + IEEE80211_ADDR_COPY(mc->mc_addr5, eh.ether_dhost); + IEEE80211_ADDR_COPY(mc->mc_addr6, eh.ether_shost); qos = ((struct ieee80211_qosframe_addr4 *) wh)->i_qos; break; default: @@ -1363,6 +1391,7 @@ bad: m_freem(m); return NULL; #undef WH4 +#undef MC01 } /* From owner-svn-src-all@FreeBSD.ORG Tue May 1 15:58:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 461C6106566C; Tue, 1 May 2012 15:58:11 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 316548FC0A; Tue, 1 May 2012 15:58:11 +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 q41FwBcG033091; Tue, 1 May 2012 15:58:11 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FwAkY033089; Tue, 1 May 2012 15:58:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011558.q41FwAkY033089@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234879 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:58:11 -0000 Author: monthadar Date: Tue May 1 15:58:10 2012 New Revision: 234879 URL: http://svn.freebsd.org/changeset/base/234879 Log: Added route lifetime update for destination and source mesh along a mesh path; * In mesh_recv_indiv_data_to_fwd update route entry for both meshDA and meshSA; * In mesh_recv_indiv_data_to_me update route entry for meshSA; * in ieee80211_mesh_rt_update put code so that a proxy entry that is gated by us (number of hops == 0) is never invalidated; * Fixed so that we always call ieee80211_mesh_rt_update with lifetime in ms; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:56:26 2012 (r234878) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:58:10 2012 (r234879) @@ -241,6 +241,13 @@ ieee80211_mesh_rt_update(struct ieee8021 now = ticks; RT_ENTRY_LOCK(rt); + + /* dont clobber a proxy entry gated by us */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && rt->rt_nhops == 0) { + RT_ENTRY_UNLOCK(rt); + return rt->rt_lifetime; + } + timesince = ticks_to_msecs(now - rt->rt_updtime); rt->rt_updtime = now; if (timesince >= rt->rt_lifetime) { @@ -1115,16 +1122,31 @@ static int mesh_recv_indiv_data_to_fwrd(struct ieee80211vap *vap, struct mbuf *m, struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) { + struct ieee80211_qosframe_addr4 *qwh; + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_mesh_route *rt_meshda, *rt_meshsa; + + qwh = (struct ieee80211_qosframe_addr4 *)wh; /* * TODO: * o verify addr2 is a legitimate transmitter - * o set lifetime of addr3 to initial value - * o set lifetime of addr4 to initial value * o lifetime of precursor of addr3 (addr2) is max(init, curr) * o lifetime of precursor of addr4 (nexthop) is max(init, curr) */ + /* set lifetime of addr3 (meshDA) to initial value */ + rt_meshda = ieee80211_mesh_rt_find(vap, qwh->i_addr3); + KASSERT(rt_meshda != NULL, ("no route")); + ieee80211_mesh_rt_update(rt_meshda, ticks_to_msecs( + ms->ms_ppath->mpp_inact)); + + /* set lifetime of addr4 (meshSA) to initial value */ + rt_meshsa = ieee80211_mesh_rt_find(vap, qwh->i_addr4); + KASSERT(rt_meshsa != NULL, ("no route")); + ieee80211_mesh_rt_update(rt_meshsa, ticks_to_msecs( + ms->ms_ppath->mpp_inact)); + mesh_forward(vap, m, mc); return (1); /* dont process locally */ } @@ -1144,6 +1166,7 @@ mesh_recv_indiv_data_to_me(struct ieee80 { struct ieee80211_qosframe_addr4 *qwh; const struct ieee80211_meshcntl_ae10 *mc10; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt; int ae; @@ -1153,10 +1176,15 @@ mesh_recv_indiv_data_to_me(struct ieee80 /* * TODO: * o verify addr2 is a legitimate transmitter - * o set lifetime of addr4 to initial value * o lifetime of precursor entry is max(init, curr) */ + /* set lifetime of addr4 (meshSA) to initial value */ + rt = ieee80211_mesh_rt_find(vap, qwh->i_addr4); + KASSERT(rt != NULL, ("no route")); + ieee80211_mesh_rt_update(rt, ticks_to_msecs(ms->ms_ppath->mpp_inact)); + rt = NULL; + ae = mc10->mc_flags & IEEE80211_MESH_AE_MASK; KASSERT(ae == IEEE80211_MESH_AE_00 || ae == IEEE80211_MESH_AE_10, ("bad AE %d", ae)); @@ -1673,7 +1701,8 @@ mesh_recv_mgmt(struct ieee80211_node *ni rt = ieee80211_mesh_rt_find(vap, wh->i_addr2); if(rt != NULL) { ieee80211_mesh_rt_update(rt, - ms->ms_ppath->mpp_inact); + ticks_to_msecs( + ms->ms_ppath->mpp_inact)); } break; } From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:00:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5DF751065670; Tue, 1 May 2012 16:00:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48E018FC08; Tue, 1 May 2012 16:00:32 +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 q41G0WXh033233; Tue, 1 May 2012 16:00:32 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G0Wsi033230; Tue, 1 May 2012 16:00:32 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011600.q41G0Wsi033230@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:00:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234880 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:00:32 -0000 Author: monthadar Date: Tue May 1 16:00:31 2012 New Revision: 234880 URL: http://svn.freebsd.org/changeset/base/234880 Log: * MeshForwarding update mesh_recv_indiv_data_to_fwrd to silently discard unknown meshDA instead of panic, which is allowed per amendment spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:58:10 2012 (r234879) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:00:31 2012 (r234880) @@ -1137,7 +1137,19 @@ mesh_recv_indiv_data_to_fwrd(struct ieee /* set lifetime of addr3 (meshDA) to initial value */ rt_meshda = ieee80211_mesh_rt_find(vap, qwh->i_addr3); - KASSERT(rt_meshda != NULL, ("no route")); + if (rt_meshda == NULL) { + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, qwh->i_addr2, + "no route to meshDA(%6D)", qwh->i_addr3, ":"); + /* + * [Optional] any of the following three actions: + * o silently discard [X] + * o trigger a path discovery [ ] + * o inform TA that meshDA is unknown. [ ] + */ + /* XXX: stats */ + return (-1); + } + ieee80211_mesh_rt_update(rt_meshda, ticks_to_msecs( ms->ms_ppath->mpp_inact)); From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:02:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A100106566C; Tue, 1 May 2012 16:02:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D9D038FC0A; Tue, 1 May 2012 16:02: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 q41G2VJk033354; Tue, 1 May 2012 16:02:31 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G2Vrk033351; Tue, 1 May 2012 16:02:31 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011602.q41G2Vrk033351@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:02: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: r234881 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:02:32 -0000 Author: monthadar Date: Tue May 1 16:02:31 2012 New Revision: 234881 URL: http://svn.freebsd.org/changeset/base/234881 Log: PREP update * Added assertion in mesh_rt_update; * Fixed some prep propagation that where multicast, ALL PREPS ARE UNICAST; * Fixed PREP acceptance criteria; * Fixed some PREP debug messages; * HWMP intermediate reply (PREP) should only be sent if we have newer forwarding infomration (FI) about target; * Fixed PREP propagation condition and PREP w/ AE handling; * Ignore PREPs that have unknown originator. * Removed old code inside PREP that was for proactive path building to root mesh; Other errors include: * use seq number of target and not orig mesh STA; * Metric is what we have stored in our FI; * Error in amendment, Hop count is not 0 but equals FI hopcount for target; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:00:31 2012 (r234880) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:02:31 2012 (r234881) @@ -887,7 +887,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, return; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREQ, source %6D", preq->preq_origaddr, ":"); + "received PREQ, orig %6D, targ(0) %6D", preq->preq_origaddr, ":", + PREQ_TADDR(0), ":"); /* * Acceptance criteria: if the PREQ is not for us or not broadcast @@ -1010,9 +1011,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, * root STA if requested. */ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) && - (PREQ_TFLAGS(0) & - ((IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF) == - (IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF)))) { + (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { uint8_t rootmac[IEEE80211_ADDR_LEN]; IEEE80211_ADDR_COPY(rootmac, preq->preq_origaddr); @@ -1096,26 +1095,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Check if we can send an intermediate Path Reply, * i.e., Target Only bit is not set. */ - if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { + if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO) && + HWMP_SEQ_GEQ(hrtarg->hr_seq, PREQ_TSEQ(0))) { struct ieee80211_meshprep_ie prep; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "intermediate reply for PREQ from %6D", preq->preq_origaddr, ":"); prep.prep_flags = 0; - prep.prep_hopcount = rt->rt_nhops + 1; + prep.prep_hopcount = rttarg->rt_nhops; prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(&prep.prep_targetaddr, PREQ_TADDR(0)); - prep.prep_targetseq = hrorig->hr_seq; + prep.prep_targetseq = hrtarg->hr_seq; prep.prep_lifetime = preq->preq_lifetime; - prep.prep_metric = rt->rt_metric + - ms->ms_pmetric->mpm_metric(ni); + prep.prep_metric =rttarg->rt_metric; IEEE80211_ADDR_COPY(&prep.prep_origaddr, preq->preq_origaddr); prep.prep_origseq = hrorig->hr_seq; hwmp_send_prep(ni, vap->iv_myaddr, - broadcastaddr, &prep); + rtorig->rt_nexthop, &prep); } /* * We have no information about this path, @@ -1191,6 +1190,9 @@ static void hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshprep_ie *prep) { +#define IS_PROXY(rt) (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) +#define PROXIED_BY_US(rt) \ + (IEEE80211_ADDR_EQ(vap->iv_myaddr, rt->rt_mesh_gate)) struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; @@ -1203,63 +1205,31 @@ hwmp_recv_prep(struct ieee80211vap *vap, uint32_t metric = 0; const uint8_t *addr; - /* - * Acceptance criteria: If the corresponding PREP was not generated - * by us or generated by an external mac that is proxied by us - * and forwarding is disabled, discard this PREP. - */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) return; - if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) - return; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP, orig %6D, targ %6D", prep->prep_origaddr, ":", + prep->prep_targetaddr, ":"); + + /* + * Acceptance criteria: (If the corresponding PREP was not generated + * by us OR not generated by an external mac that is not proxied by us) + * AND forwarding is disabled, discard this PREP. + */ rtorig = ieee80211_mesh_rt_find(vap, prep->prep_origaddr); - if (rtorig != NULL && - !(rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)) { + if ((!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) || + (rtorig != NULL && IS_PROXY(rtorig) && !PROXIED_BY_US(rtorig))) && + !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)){ IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREP(%u) for an orig(%6D) not proxied by us", - prep->prep_origseq, prep->prep_origaddr, ":"); + "discard PREP, orig(%6D) not proxied or generated by us", + prep->prep_origaddr, ":"); return; } /* PREP ACCEPTED */ - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREP from %6D", prep->prep_targetaddr, ":"); - -#if 0 - rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); - if (rt == NULL) { - /* - * If we have no entry this could be a reply to a root PREQ. - * XXX: not true anymore cause we dont create entry for target - * when propagating PREQs like the old code did. - */ - if (hs->hs_rootmode != IEEE80211_HWMP_ROOTMODE_DISABLED) { - rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr); - if (rt == NULL) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, - ni, "unable to add PREP path to %6D", - prep->prep_targetaddr, ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); - rt->rt_nhops = prep->prep_hopcount; - ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_metric = prep->prep_metric; - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "add root path to %6D nhops %d metric %lu (PREP)", - prep->prep_targetaddr, ":", - rt->rt_nhops, rt->rt_metric); - return; - } - return; - } -#endif - /* * If accepted shall create or update the active forwarding information * it maintains for the target mesh STA of the PREP (according to the @@ -1278,6 +1248,8 @@ hwmp_recv_prep(struct ieee80211vap *vap, vap->iv_stats.is_mesh_rtaddfailed++; return; } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "adding target %6D", prep->prep_targetaddr, ":"); } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); /* update path metric */ @@ -1315,11 +1287,25 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* - * If it's NOT for us, propagate the PREP. + * If it's NOT for us, propagate the PREP */ if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && - prep->prep_ttl > 1 && prep->prep_hopcount < hs->hs_maxhops) { + prep->prep_ttl > 1 && + prep->prep_hopcount < hs->hs_maxhops) { struct ieee80211_meshprep_ie pprep; /* propagated PREP */ + /* + * NB: We should already have setup the path to orig + * mesh STA when we propagated PREQ to target mesh STA, + * no PREP is generated without a corresponding PREQ. + * XXX: for now just ignore. + */ + if (rtorig == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP for an unknown orig(%6D)", + prep->prep_origaddr, ":"); + return; + } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PREP from %6D", prep->prep_targetaddr, ":"); @@ -1328,13 +1314,17 @@ hwmp_recv_prep(struct ieee80211vap *vap, pprep.prep_hopcount += 1; pprep.prep_ttl -= 1; pprep.prep_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep); + hwmp_send_prep(ni, vap->iv_myaddr, rtorig->rt_nexthop, &pprep); - /* may store target external address if recevied PREP w/ AE */ /* precursor list for the Target Mesh STA Address is updated */ } - /* check if we received a PREP for a proxy address */ - else if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { + + /* + * Check if we received a PREP w/ AE and store target external address. + * We may store target external address if recevied PREP w/ AE + * and we are not final destination + */ + if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { rtext = ieee80211_mesh_rt_find(vap, prep->prep_target_ext_addr); if (rtext == NULL) { @@ -1366,8 +1356,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, rtext->rt_metric = metric; rtext->rt_lifetime = prep->prep_lifetime; rtext->rt_nhops = prep->prep_hopcount + 1; - rtext->rt_ext_seq = prep->prep_origseq; /* proxy seq */ - /* proxy entries have no HWMP priv data, nullify them to be sure? */ + rtext->rt_ext_seq = prep->prep_origseq; /* new proxy seq */ + /* + * XXX: proxy entries have no HWMP priv data, + * nullify them to be sure? + */ } /* * Check for frames queued awaiting path discovery. @@ -1388,6 +1381,8 @@ hwmp_recv_prep(struct ieee80211vap *vap, "flush queued frame %p len %d", m, m->m_pkthdr.len); ifp->if_transmit(ifp, m); } +#undef IS_PROXY +#undef PROXIED_BY_US } static int Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:00:31 2012 (r234880) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:02:31 2012 (r234881) @@ -239,6 +239,8 @@ ieee80211_mesh_rt_update(struct ieee8021 int timesince, now; uint32_t lifetime = 0; + KASSERT(rt != NULL, ("route is NULL")); + now = ticks; RT_ENTRY_LOCK(rt); From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:03:28 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 08FD3106564A; Tue, 1 May 2012 16:03:28 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E817E8FC22; Tue, 1 May 2012 16:03: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 q41G3RrT033424; Tue, 1 May 2012 16:03:27 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G3R9b033422; Tue, 1 May 2012 16:03:27 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011603.q41G3R9b033422@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:03: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: r234882 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:03:28 -0000 Author: monthadar Date: Tue May 1 16:03:27 2012 New Revision: 234882 URL: http://svn.freebsd.org/changeset/base/234882 Log: Change how we enforce PREQ minimum interval. * Moved hs_lastpreq to be hr_lastpreq cause this rate check should be per target mesh STA according to amendment (NB: not applicable for PERR); * Modified hwmp_send_preq to use two extra arguments for last sent PREQ and minimum PREQ interval; * hwmp_send_preq is called with last two arguments equal to NULL when sending Proactive PREQs cause the call back task enforces the rate check; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:02:31 2012 (r234881) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:03:27 2012 (r234882) @@ -89,7 +89,8 @@ static void hwmp_recv_preq(struct ieee80 static int hwmp_send_preq(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], - struct ieee80211_meshpreq_ie *); + struct ieee80211_meshpreq_ie *, + struct timeval *, struct timeval *); static void hwmp_recv_prep(struct ieee80211vap *, struct ieee80211_node *, const struct ieee80211_frame *, const struct ieee80211_meshprep_ie *); @@ -152,14 +153,14 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_seq; /* last HWMP seq seen from dst*/ ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ + struct timeval hr_lastpreq; /* last time we sent a PREQ */ int hr_preqretries; }; struct ieee80211_hwmp_state { ieee80211_hwmp_seq hs_seq; /* next seq to be used */ ieee80211_hwmp_seq hs_preqid; /* next PREQ ID to be used */ - struct timeval hs_lastpreq; /* last time we sent a PREQ */ - struct timeval hs_lastperr; /* last time we sent a PERR */ int hs_rootmode; /* proactive HWMP */ + struct timeval hs_lastperr; /* last time we sent a PERR */ struct callout hs_roottimer; uint8_t hs_maxhops; /* max hop count */ }; @@ -824,7 +825,8 @@ hwmp_rootmode_cb(void *arg) IEEE80211_MESHPREQ_TFLAGS_RF; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; - hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq); + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, + NULL, NULL); /* NB: we enforce rate check ourself */ hwmp_rootmode_setup(vap); } #undef PREQ_TFLAGS @@ -1051,7 +1053,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_discover(vap, rootmac, NULL); return; } - rt = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); /* * Forwarding and Intermediate reply for PREQs with 1 target. @@ -1063,8 +1064,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * We have a valid route to this node. */ - if (rt != NULL && - (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { + if (rttarg != NULL && + (rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { if (preq->preq_ttl > 1 && preq->preq_hopcount < hs->hs_maxhops) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1072,7 +1073,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, preq->preq_origaddr, ":"); /* * Propagate the original PREQ. - * PREQ is unicast now to rt->rt_nexthop + * PREQ is unicast now to rttarg->rt_nexthop */ ppreq.preq_flags &= ~IEEE80211_MESHPREQ_FLAGS_AM; @@ -1089,7 +1090,9 @@ hwmp_recv_preq(struct ieee80211vap *vap, ppreq.preq_targets[0].target_flags &= ~IEEE80211_MESHPREQ_TFLAGS_RF; hwmp_send_preq(ni, vap->iv_myaddr, - rt->rt_nexthop, &ppreq); + rttarg->rt_nexthop, &ppreq, + &hrtarg->hr_lastpreq, + &ieee80211_hwmp_preqminint); } /* * Check if we can send an intermediate Path Reply, @@ -1122,9 +1125,10 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ } else if (preq->preq_ttl > 1 && preq->preq_hopcount < hs->hs_maxhops) { - if (rt == NULL) { - rt = ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); - if (rt == NULL) { + if (rttarg == NULL) { + rttarg = + ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); + if (rttarg == NULL) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add PREQ path to %6D", @@ -1133,12 +1137,12 @@ hwmp_recv_preq(struct ieee80211vap *vap, return; } } - rt->rt_metric = preq->preq_metric; - ieee80211_mesh_rt_update(rt, preq->preq_lifetime); - hrorig = IEEE80211_MESH_ROUTE_PRIV(rt, + rttarg->rt_metric = preq->preq_metric; + ieee80211_mesh_rt_update(rttarg, preq->preq_lifetime); + hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, struct ieee80211_hwmp_route); - hrorig->hr_seq = preq->preq_origseq; - hrorig->hr_preqid = preq->preq_id; + hrtarg->hr_seq = PREQ_TSEQ(0); + hrtarg->hr_preqid = preq->preq_id; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "forward PREQ from %6D", @@ -1147,7 +1151,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, ppreq.preq_ttl -= 1; ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, - &ppreq); + &ppreq, &hrtarg->hr_lastpreq, + &ieee80211_hwmp_preqminint); } } } @@ -1159,16 +1164,19 @@ static int hwmp_send_preq(struct ieee80211_node *ni, const uint8_t sa[IEEE80211_ADDR_LEN], const uint8_t da[IEEE80211_ADDR_LEN], - struct ieee80211_meshpreq_ie *preq) + struct ieee80211_meshpreq_ie *preq, + struct timeval *last, struct timeval *minint) { - struct ieee80211_hwmp_state *hs = ni->ni_vap->iv_hwmp; /* * Enforce PREQ interval. + * NB: Proactive ROOT PREQs rate is handled by cb task. */ - if (ratecheck(&hs->hs_lastpreq, &ieee80211_hwmp_preqminint) == 0) - return EALREADY; - getmicrouptime(&hs->hs_lastpreq); + if (last != NULL && minint != NULL) { + if (ratecheck(last, minint) == 0) + return EALREADY; /* XXX: we should postpone */ + getmicrouptime(last); + } /* * mesh preq action frame format @@ -1677,7 +1685,8 @@ hwmp_discover(struct ieee80211vap *vap, PREQ_TSEQ(0) = hr->hr_seq; /* XXX check return value */ hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &preq); + broadcastaddr, &preq, &hr->hr_lastpreq, + &ieee80211_hwmp_preqminint); } if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ni = ieee80211_find_txnode(vap, rt->rt_nexthop); From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:05:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97F94106564A; Tue, 1 May 2012 16:05:10 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8376C8FC08; Tue, 1 May 2012 16:05:10 +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 q41G5A0M033519; Tue, 1 May 2012 16:05:10 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G5Aq9033517; Tue, 1 May 2012 16:05:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011605.q41G5Aq9033517@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:05:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234883 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:05:10 -0000 Author: monthadar Date: Tue May 1 16:05:09 2012 New Revision: 234883 URL: http://svn.freebsd.org/changeset/base/234883 Log: * Added a mesh max PREQ retires sysctl that governous how many times we try to discover an address; * Added a mesh net travelse time across an MBSS, which is used to enforce discovery rate check; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:03:27 2012 (r234882) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:05:09 2012 (r234883) @@ -154,7 +154,8 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ struct timeval hr_lastpreq; /* last time we sent a PREQ */ - int hr_preqretries; + int hr_preqretries; /* number of discoveries */ + int hr_lastdiscovery; /* last discovery in ticks */ }; struct ieee80211_hwmp_state { ieee80211_hwmp_seq hs_seq; /* next seq to be used */ @@ -177,6 +178,15 @@ static int ieee80211_hwmp_pathtimeout = SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, pathlifetime, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_pathtimeout, 0, ieee80211_sysctl_msecs_ticks, "I", "path entry lifetime (ms)"); +static int ieee80211_hwmp_maxpreq_retries = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, maxpreq_retries, CTLTYPE_INT | CTLFLAG_RW, + &ieee80211_hwmp_maxpreq_retries, 0, ieee80211_sysctl_msecs_ticks, "I", + "maximum number of preq retries"); +static int ieee80211_hwmp_net_diameter_traversaltime = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, net_diameter_traversal_time, + CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_net_diameter_traversaltime, 0, + ieee80211_sysctl_msecs_ticks, "I", + "estimate travelse time across the MBSS (ms)"); static int ieee80211_hwmp_roottimeout = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, roottimeout, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_roottimeout, 0, ieee80211_sysctl_msecs_ticks, "I", @@ -212,10 +222,17 @@ SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, in static void ieee80211_hwmp_init(void) { + /* Default values as per amendment */ ieee80211_hwmp_pathtimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_roottimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_rootint = msecs_to_ticks(2*1000); ieee80211_hwmp_rannint = msecs_to_ticks(1*1000); + ieee80211_hwmp_maxpreq_retries = 3; + /* + * (TU): A measurement of time equal to 1024 μs, + * 500 TU is 512 ms. + */ + ieee80211_hwmp_net_diameter_traversaltime = msecs_to_ticks(512); /* * Register action frame handler. @@ -1288,6 +1305,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric, metric); hr->hr_seq = prep->prep_targetseq; + hr->hr_preqretries = 0; IEEE80211_ADDR_COPY(rt->rt_nexthop, ni->ni_macaddr); rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; @@ -1648,13 +1666,31 @@ hwmp_discover(struct ieee80211vap *vap, hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + if (hr->hr_lastdiscovery != 0 && + (ticks - hr->hr_lastdiscovery < + (ieee80211_hwmp_net_diameter_traversaltime * 2))) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + dest, NULL, "%s", + "too frequent discovery requeust"); + /* XXX: stats? */ + goto done; + } + hr->hr_lastdiscovery = ticks; + if (hr->hr_preqretries >= + ieee80211_hwmp_maxpreq_retries) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + dest, NULL, "%s", + "no valid path , max number of discovery"); + vap->iv_stats.is_mesh_fwd_nopath++; + goto done; + } + hr->hr_preqretries++; if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; /* XXX: special discovery timeout, larger lifetime? */ ieee80211_mesh_rt_update(rt, ticks_to_msecs(ieee80211_hwmp_pathtimeout)); - /* XXX check preq retries */ sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, "start path discovery (src %s), target seq %u", From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:06:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B492D106564A; Tue, 1 May 2012 16:06:21 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 86BB08FC08; Tue, 1 May 2012 16:06: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 q41G6Lkv033597; Tue, 1 May 2012 16:06:21 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G6LJE033594; Tue, 1 May 2012 16:06:21 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011606.q41G6LJE033594@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:06: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: r234884 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:06:21 -0000 Author: monthadar Date: Tue May 1 16:06:20 2012 New Revision: 234884 URL: http://svn.freebsd.org/changeset/base/234884 Log: * Fixed PREQ flag field Adressing mode subfiled according to amendment specs; Approved by: adria Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:05:09 2012 (r234883) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:06:20 2012 (r234884) @@ -824,7 +824,7 @@ hwmp_rootmode_cb(void *arg) IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss, "%s", "send broadcast PREQ"); - preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_flags = 0; if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PR; if (hs->hs_rootmode == IEEE80211_HWMP_ROOTMODE_PROACTIVE) @@ -1092,8 +1092,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Propagate the original PREQ. * PREQ is unicast now to rttarg->rt_nexthop */ - ppreq.preq_flags &= - ~IEEE80211_MESHPREQ_FLAGS_AM; + ppreq.preq_flags |= + IEEE80211_MESHPREQ_FLAGS_AM; ppreq.preq_hopcount += 1; ppreq.preq_ttl -= 1; ppreq.preq_metric += @@ -1701,7 +1701,7 @@ hwmp_discover(struct ieee80211vap *vap, * Try to discover the path for this node. * Group addressed PREQ Case A */ - preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_flags = 0; preq.preq_hopcount = 0; preq.preq_ttl = ms->ms_ttl; preq.preq_id = ++hs->hs_preqid; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:05:09 2012 (r234883) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:06:20 2012 (r234884) @@ -230,7 +230,7 @@ struct ieee80211_meshpreq_ie { uint8_t preq_len; uint8_t preq_flags; #define IEEE80211_MESHPREQ_FLAGS_PR 0x01 /* Portal Role */ -#define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = ucast / 1 = bcast */ +#define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */ uint8_t preq_hopcount; From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:07:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05284106564A; Tue, 1 May 2012 16:07:36 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E57178FC18; Tue, 1 May 2012 16:07: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 q41G7Zdv033671; Tue, 1 May 2012 16:07:35 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G7ZKV033668; Tue, 1 May 2012 16:07:35 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011607.q41G7ZKV033668@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:07: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: r234885 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:07:36 -0000 Author: monthadar Date: Tue May 1 16:07:35 2012 New Revision: 234885 URL: http://svn.freebsd.org/changeset/base/234885 Log: * Fixed hwmp_discover code to populate a PREQ packet correctly; * Removed IEEE80211_MESHPREQ_TFLAGS_RF which is no longer part of the amendment spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:06:20 2012 (r234884) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:07:35 2012 (r234885) @@ -171,9 +171,6 @@ static SYSCTL_NODE(_net_wlan, OID_AUTO, static int ieee80211_hwmp_targetonly = 0; SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, targetonly, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_targetonly, 0, "Set TO bit on generated PREQs"); -static int ieee80211_hwmp_replyforward = 1; -SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW, - &ieee80211_hwmp_replyforward, 0, "Set RF bit on generated PREQs"); static int ieee80211_hwmp_pathtimeout = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, pathlifetime, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_pathtimeout, 0, ieee80211_sysctl_msecs_ticks, "I", @@ -838,8 +835,7 @@ hwmp_rootmode_cb(void *arg) preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), broadcastaddr); - PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO | - IEEE80211_MESHPREQ_TFLAGS_RF; + PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, @@ -1104,8 +1100,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ ppreq.preq_targets[0].target_flags |= IEEE80211_MESHPREQ_TFLAGS_TO; - ppreq.preq_targets[0].target_flags &= - ~IEEE80211_MESHPREQ_TFLAGS_RF; hwmp_send_preq(ni, vap->iv_myaddr, rttarg->rt_nexthop, &ppreq, &hrtarg->hr_lastpreq, @@ -1709,16 +1703,14 @@ hwmp_discover(struct ieee80211vap *vap, preq.preq_origseq = hr->hr_origseq; preq.preq_lifetime = ticks_to_msecs(ieee80211_hwmp_pathtimeout); - preq.preq_metric = rt->rt_metric; + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest); PREQ_TFLAGS(0) = 0; if (ieee80211_hwmp_targetonly) PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO; - if (ieee80211_hwmp_replyforward) - PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_RF; PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN; - PREQ_TSEQ(0) = hr->hr_seq; + PREQ_TSEQ(0) = 0; /* RESERVED when USN flag is set */ /* XXX check return value */ hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, &hr->hr_lastpreq, Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:06:20 2012 (r234884) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:07:35 2012 (r234885) @@ -246,7 +246,6 @@ struct ieee80211_meshpreq_ie { struct { uint8_t target_flags; #define IEEE80211_MESHPREQ_TFLAGS_TO 0x01 /* Target Only */ -#define IEEE80211_MESHPREQ_TFLAGS_RF 0x02 /* Reply and Forward */ #define IEEE80211_MESHPREQ_TFLAGS_USN 0x04 /* Unknown HWMP seq number */ uint8_t target_addr[IEEE80211_ADDR_LEN]; uint32_t target_seq; /* HWMP Sequence Number */ From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:08:47 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F49D1065677; Tue, 1 May 2012 16:08:47 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2AEA28FC1E; Tue, 1 May 2012 16:08:47 +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 q41G8lmk033748; Tue, 1 May 2012 16:08:47 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G8k9l033746; Tue, 1 May 2012 16:08:46 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011608.q41G8k9l033746@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:08:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234886 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:08:47 -0000 Author: monthadar Date: Tue May 1 16:08:46 2012 New Revision: 234886 URL: http://svn.freebsd.org/changeset/base/234886 Log: * Proactive PREQ (original transmission) must also set IEEE80211_MESHPREQ_TFLAGS_USN flag in target_flag field; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:07:35 2012 (r234885) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:08:46 2012 (r234886) @@ -835,7 +835,8 @@ hwmp_rootmode_cb(void *arg) preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), broadcastaddr); - PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO; + PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO | + IEEE80211_MESHPREQ_TFLAGS_USN; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:09:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E752B1065673; Tue, 1 May 2012 16:09:44 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D2AE38FC18; Tue, 1 May 2012 16:09:44 +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 q41G9iTu033811; Tue, 1 May 2012 16:09:44 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G9inu033809; Tue, 1 May 2012 16:09:44 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011609.q41G9inu033809@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234887 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:09:45 -0000 Author: monthadar Date: Tue May 1 16:09:44 2012 New Revision: 234887 URL: http://svn.freebsd.org/changeset/base/234887 Log: * PREQ acceptance criteria updated to check for proxy condition as in amendment; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:08:46 2012 (r234886) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:09:44 2012 (r234887) @@ -907,13 +907,17 @@ hwmp_recv_preq(struct ieee80211vap *vap, PREQ_TADDR(0), ":"); /* - * Acceptance criteria: if the PREQ is not for us or not broadcast + * Acceptance criteria: (if the PREQ is not for us or not broadcast, + * or an external mac address not proxied by us), * AND forwarding is disabled, discard this PREQ. - * XXX: need to check PROXY */ - if ((!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || - !IEEE80211_IS_MULTICAST(PREQ_TADDR(0))) && - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { + rttarg = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); + if (!(ms->ms_flags & IEEE80211_MESHFLAGS_FWD) && + (!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || + !IEEE80211_IS_MULTICAST(PREQ_TADDR(0)) || + (rttarg != NULL && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && + IEEE80211_ADDR_EQ(vap->iv_myaddr, rttarg->rt_mesh_gate)))) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_HWMP, preq->preq_origaddr, NULL, "%s", "not accepting PREQ"); return; @@ -922,7 +926,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Acceptance criteria: if unicast addressed * AND no valid forwarding for Target of PREQ, discard this PREQ. */ - rttarg = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); if(rttarg != NULL) hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, struct ieee80211_hwmp_route); From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:10:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E78411065680; Tue, 1 May 2012 16:10:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D25938FC0A; Tue, 1 May 2012 16:10:32 +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 q41GAWE8033882; Tue, 1 May 2012 16:10:32 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GAWjX033880; Tue, 1 May 2012 16:10:32 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011610.q41GAWjX033880@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:10:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234888 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:10:33 -0000 Author: monthadar Date: Tue May 1 16:10:32 2012 New Revision: 234888 URL: http://svn.freebsd.org/changeset/base/234888 Log: Updated PREQ propagation code; * When receiving a Proactive PREQ dont return after processing it but propagate; * When we propagate we should not enforce ratechecking; * Added checking for multiple pred ID detection; * Storing proxy orig address when PREQ is not for us; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:09:44 2012 (r234887) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:10:32 2012 (r234888) @@ -886,11 +886,13 @@ hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; + struct ieee80211_mesh_route *rtorig_ext = NULL; struct ieee80211_mesh_route *rttarg = NULL; struct ieee80211_hwmp_route *hrorig = NULL; struct ieee80211_hwmp_route *hrtarg = NULL; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_meshprep_ie prep; + ieee80211_hwmp_seq preqid; /* last seen preqid for orig */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) @@ -945,15 +947,22 @@ hwmp_recv_preq(struct ieee80211vap *vap, rtorig = ieee80211_mesh_rt_find(vap, preq->preq_origaddr); if (rtorig == NULL) { rtorig = ieee80211_mesh_rt_add(vap, preq->preq_origaddr); + if (rtorig == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig path to %6D", + preq->preq_origaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "adding originator %6D", preq->preq_origaddr, ":"); } - if (rtorig == NULL) { - /* XXX stat */ - return; - } hrorig = IEEE80211_MESH_ROUTE_PRIV(rtorig, struct ieee80211_hwmp_route); + /* record last seen preqid */ + preqid = hrorig->hr_preqid; + hrorig->hr_preqid = HWMP_SEQ_MAX(hrorig->hr_preqid, preq->preq_id); + /* Data creation and update of forwarding information * according to Table 11C-8 for originator mesh STA. */ @@ -968,13 +977,16 @@ hwmp_recv_preq(struct ieee80211vap *vap, ieee80211_mesh_rt_update(rtorig, preq->preq_lifetime); /* path to orig is valid now */ rtorig->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - }else if(hrtarg != NULL && - HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0)) && - (rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + }else if ((hrtarg != NULL && + HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0)) && + ((rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0)) || + preqid >= preq->preq_id) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREQ from %6D, old seq no %u <= %u", + "discard PREQ from %6D, old seqno %u <= %u," + " or old preqid %u < %u", preq->preq_origaddr, ":", - preq->preq_origseq, hrorig->hr_seq); + preq->preq_origseq, hrorig->hr_seq, + preq->preq_id, preqid); return; } @@ -1025,6 +1037,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep); return; } + /* we may update our proxy information for the orig external */ + else if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_AE) { + rtorig_ext = + ieee80211_mesh_rt_find(vap, preq->preq_orig_ext_addr); + if (rtorig_ext == NULL) { + rtorig_ext = ieee80211_mesh_rt_add(vap, + preq->preq_orig_ext_addr); + if (rtorig_ext == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig ext proxy to %6D", + preq->preq_orig_ext_addr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } + IEEE80211_ADDR_COPY(rtorig_ext->rt_mesh_gate, + preq->preq_origaddr); + } + rtorig_ext->rt_ext_seq = preq->preq_origseq; + ieee80211_mesh_rt_update(rtorig_ext, preq->preq_lifetime); + } /* * Proactive PREQ: reply with a proactive PREP to the * root STA if requested. @@ -1067,54 +1099,29 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_send_prep(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &prep); } - hwmp_discover(vap, rootmac, NULL); - return; } /* * Forwarding and Intermediate reply for PREQs with 1 target. */ - if (preq->preq_tcount == 1) { + if ((preq->preq_tcount == 1) && (preq->preq_ttl > 1) && + (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { struct ieee80211_meshpreq_ie ppreq; /* propagated PREQ */ memcpy(&ppreq, preq, sizeof(ppreq)); + /* * We have a valid route to this node. */ if (rttarg != NULL && (rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { - if (preq->preq_ttl > 1 && - preq->preq_hopcount < hs->hs_maxhops) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "forward PREQ from %6D", - preq->preq_origaddr, ":"); - /* - * Propagate the original PREQ. - * PREQ is unicast now to rttarg->rt_nexthop - */ - ppreq.preq_flags |= - IEEE80211_MESHPREQ_FLAGS_AM; - ppreq.preq_hopcount += 1; - ppreq.preq_ttl -= 1; - ppreq.preq_metric += - ms->ms_pmetric->mpm_metric(ni); - /* - * Set TO and unset RF bits because we are - * going to send a PREP next. - */ - ppreq.preq_targets[0].target_flags |= - IEEE80211_MESHPREQ_TFLAGS_TO; - hwmp_send_preq(ni, vap->iv_myaddr, - rttarg->rt_nexthop, &ppreq, - &hrtarg->hr_lastpreq, - &ieee80211_hwmp_preqminint); - } /* * Check if we can send an intermediate Path Reply, - * i.e., Target Only bit is not set. + * i.e., Target Only bit is not set and target is not + * the MAC broadcast address. */ if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO) && - HWMP_SEQ_GEQ(hrtarg->hr_seq, PREQ_TSEQ(0))) { + !IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr)) { struct ieee80211_meshprep_ie prep; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1133,42 +1140,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, prep.prep_origseq = hrorig->hr_seq; hwmp_send_prep(ni, vap->iv_myaddr, rtorig->rt_nexthop, &prep); - } - /* - * We have no information about this path, - * propagate the PREQ. - */ - } else if (preq->preq_ttl > 1 && - preq->preq_hopcount < hs->hs_maxhops) { - if (rttarg == NULL) { - rttarg = - ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); - if (rttarg == NULL) { - IEEE80211_NOTE(vap, - IEEE80211_MSG_HWMP, ni, - "unable to add PREQ path to %6D", - PREQ_TADDR(0), ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - } - rttarg->rt_metric = preq->preq_metric; - ieee80211_mesh_rt_update(rttarg, preq->preq_lifetime); - hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, - struct ieee80211_hwmp_route); - hrtarg->hr_seq = PREQ_TSEQ(0); - hrtarg->hr_preqid = preq->preq_id; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "forward PREQ from %6D", - preq->preq_origaddr, ":"); - ppreq.preq_hopcount += 1; - ppreq.preq_ttl -= 1; - ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, - &ppreq, &hrtarg->hr_lastpreq, - &ieee80211_hwmp_preqminint); + /* + * Set TO and unset RF bits because we have + * sent a PREP. + */ + ppreq.preq_targets[0].target_flags |= + IEEE80211_MESHPREQ_TFLAGS_TO; + } } + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "forward PREQ from %6D", + preq->preq_origaddr, ":"); + ppreq.preq_hopcount += 1; + ppreq.preq_ttl -= 1; + ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); + + /* don't do PREQ ratecheck when we propagate */ + hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, + &ppreq, NULL, NULL); } } #undef PREQ_TFLAGS From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:11:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8D52E1065677; Tue, 1 May 2012 16:11:48 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E9E18FC18; Tue, 1 May 2012 16:11:48 +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 q41GBmbF033975; Tue, 1 May 2012 16:11:48 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GBmeN033973; Tue, 1 May 2012 16:11:48 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011611.q41GBmeN033973@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:11:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234889 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:11:48 -0000 Author: monthadar Date: Tue May 1 16:11:47 2012 New Revision: 234889 URL: http://svn.freebsd.org/changeset/base/234889 Log: * Modified PERR acceptance criteria according to amendment; * Modified how PERR is handled and propagated according to amendment; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:10:32 2012 (r234888) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:11:47 2012 (r234889) @@ -1450,7 +1450,7 @@ hwmp_peerdown(struct ieee80211_node *ni) PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_USN; PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_RC; IEEE80211_ADDR_COPY(PERR_DADDR(0), rt->rt_dest); - PERR_DSEQ(0) = hr->hr_seq; + PERR_DSEQ(0) = ++hr->hr_seq; PERR_DRCODE(0) = IEEE80211_REASON_MESH_PERR_DEST_UNREACH; /* NB: flush everything passing through peer */ ieee80211_mesh_rt_flush_peer(vap, ni->ni_macaddr); @@ -1461,60 +1461,117 @@ hwmp_peerdown(struct ieee80211_node *ni) #undef PERR_DSEQ #undef PERR_DRCODE -#define PERR_DFLAGS(n) perr->perr_dests[n].dest_flags -#define PERR_DADDR(n) perr->perr_dests[n].dest_addr -#define PERR_DSEQ(n) perr->perr_dests[n].dest_seq -#define PERR_DRCODE(n) perr->perr_dests[n].dest_rcode +#define PERR_DFLAGS(n) perr->perr_dests[n].dest_flags +#define PERR_DADDR(n) perr->perr_dests[n].dest_addr +#define PERR_DSEQ(n) perr->perr_dests[n].dest_seq +#define PERR_DEXTADDR(n) perr->perr_dests[n].dest_ext_addr +#define PERR_DRCODE(n) perr->perr_dests[n].dest_rcode static void hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshperr_ie *perr) { struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rt_ext = NULL; struct ieee80211_hwmp_route *hr; - struct ieee80211_meshperr_ie pperr; - int i, forward = 0; + struct ieee80211_meshperr_ie *pperr = NULL; + int i, j = 0, forward = 0; - /* - * Acceptance criteria: check if we received a PERR from a - * neighbor and forwarding is enabled. - */ if (ni == vap->iv_bss || - ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) + ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) return; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PERR from %6D", wh->i_addr2, ":"); + + /* + * if forwarding is true, prepare pperr + */ + if (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) { + forward = 1; + pperr = malloc(sizeof(*perr) + 31*sizeof(*perr->perr_dests), + M_80211_MESH_PERR, M_NOWAIT); /* XXX: magic number, 32 err dests */ + } + /* - * Find all routing entries that match and delete them. + * Acceptance criteria: check if we have forwarding information + * stored about destination, and that nexthop == TA of this PERR. + * NB: we also build a new PERR to propagate in case we should forward. */ for (i = 0; i < perr->perr_ndests; i++) { rt = ieee80211_mesh_rt_find(vap, PERR_DADDR(i)); - if (rt == NULL) + if (rt == NULL || rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) continue; + if (!IEEE80211_ADDR_EQ(rt->rt_nexthop, wh->i_addr2)) + continue; + + /* found and accepted a PERR ndest element, process it... */ + if (forward) + memcpy(&pperr->perr_dests[j], &perr->perr_dests[i], + sizeof(*perr->perr_dests)); hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (!(PERR_DFLAGS(0) & IEEE80211_MESHPERR_DFLAGS_USN) && - HWMP_SEQ_GEQ(PERR_DSEQ(i), hr->hr_seq)) { - ieee80211_mesh_rt_del(vap, rt->rt_dest); - ieee80211_mesh_rt_flush_peer(vap, rt->rt_dest); - rt = NULL; - forward = 1; + switch(PERR_DFLAGS(i)) { + case (IEEE80211_REASON_MESH_PERR_NO_FI): + if (PERR_DSEQ(i) == 0) { + hr->hr_seq++; + if (forward) { + pperr->perr_dests[j].dest_seq = + hr->hr_seq; + } + } else { + hr->hr_seq = PERR_DSEQ(i); + } + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + break; + case (IEEE80211_REASON_MESH_PERR_DEST_UNREACH): + if(HWMP_SEQ_GT(PERR_DSEQ(i), hr->hr_seq)) { + hr->hr_seq = PERR_DSEQ(i); + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + } + break; + case (IEEE80211_REASON_MESH_PERR_NO_PROXY): + rt_ext = ieee80211_mesh_rt_find(vap, PERR_DEXTADDR(i)); + if (rt_ext != NULL) { + rt_ext->rt_flags &= + ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + } + break; + default: + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "PERR, unknown reason code %u\n", PERR_DFLAGS(i)); + goto done; /* XXX: stats?? */ } + ieee80211_mesh_rt_flush_peer(vap, rt->rt_dest); + KASSERT(j < 32, ("PERR, error ndest >= 32 (%u)", j)); + } + if (j == 0) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, "%s", + "PERR not accepted"); + goto done; /* XXX: stats?? */ } + /* * Propagate the PERR if we previously found it on our routing table. - * XXX handle ndest > 1 */ if (forward && perr->perr_ttl > 1) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PERR from %6D", wh->i_addr2, ":"); - memcpy(&pperr, perr, sizeof(*perr)); - pperr.perr_ttl--; + pperr->perr_ndests = j; + pperr->perr_ttl--; hwmp_send_perr(vap->iv_bss, vap->iv_myaddr, broadcastaddr, - &pperr); + pperr); } +done: + if (pperr != NULL) + free(pperr, M_80211_MESH_PERR); } #undef PERR_DFLAGS #undef PEER_DADDR #undef PERR_DSEQ +#undef PERR_DEXTADDR #undef PERR_DRCODE static int From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:12:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 712B11065672; Tue, 1 May 2012 16:12:40 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C0F38FC17; Tue, 1 May 2012 16:12:40 +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 q41GCexx034050; Tue, 1 May 2012 16:12:40 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GCeM0034046; Tue, 1 May 2012 16:12:40 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011612.q41GCeM0034046@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:12:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234890 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:12:40 -0000 Author: monthadar Date: Tue May 1 16:12:39 2012 New Revision: 234890 URL: http://svn.freebsd.org/changeset/base/234890 Log: PERR update to be called from mesh code. * Added mpp_senderror for Mesh Path Selection protocol; * Added hwmp_senderror that will send an HWMP PERR according to the supplied reason code; * Call mpp_senderror when deleting a route with correct reason code for whether the route is marked proxy or not; * Call mpp_senderror when trying to forward an individually addressed frame and there is no forwarding information; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:12:39 2012 (r234890) @@ -105,6 +105,9 @@ static int hwmp_send_perr(struct ieee802 const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshperr_ie *); +static void hwmp_senderror(struct ieee80211vap *, + const uint8_t [IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *, int); static void hwmp_recv_rann(struct ieee80211vap *, struct ieee80211_node *, const struct ieee80211_frame *, const struct ieee80211_meshrann_ie *); @@ -206,6 +209,7 @@ static struct ieee80211_mesh_proto_path .mpp_ie = IEEE80211_MESHCONF_PATH_HWMP, .mpp_discover = hwmp_discover, .mpp_peerdown = hwmp_peerdown, + .mpp_senderror = hwmp_senderror, .mpp_vattach = hwmp_vattach, .mpp_vdetach = hwmp_vdetach, .mpp_newstate = hwmp_newstate, @@ -1569,7 +1573,7 @@ done: free(pperr, M_80211_MESH_PERR); } #undef PERR_DFLAGS -#undef PEER_DADDR +#undef PERR_DADDR #undef PERR_DSEQ #undef PERR_DEXTADDR #undef PERR_DRCODE @@ -1614,6 +1618,64 @@ hwmp_send_perr(struct ieee80211_node *ni return hwmp_send_action(ni, sa, da, (uint8_t *)perr, perr->perr_len+2); } +/* + * Called from the rest of the net80211 code (mesh code for example). + * NB: IEEE80211_REASON_MESH_PERR_DEST_UNREACH can be trigger by the fact that + * a mesh STA is unable to forward an MSDU/MMPDU to a next-hop mesh STA. + */ +#define PERR_DFLAGS(n) perr.perr_dests[n].dest_flags +#define PERR_DADDR(n) perr.perr_dests[n].dest_addr +#define PERR_DSEQ(n) perr.perr_dests[n].dest_seq +#define PERR_DEXTADDR(n) perr.perr_dests[n].dest_ext_addr +#define PERR_DRCODE(n) perr.perr_dests[n].dest_rcode +static void +hwmp_senderror(struct ieee80211vap *vap, + const uint8_t addr[IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *rt, int rcode) +{ + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_hwmp_route *hr = NULL; + struct ieee80211_meshperr_ie perr; + + if (rt != NULL) + hr = IEEE80211_MESH_ROUTE_PRIV(rt, + struct ieee80211_hwmp_route); + + perr.perr_ndests = 1; + perr.perr_ttl = ms->ms_ttl; + PERR_DFLAGS(0) = 0; + PERR_DRCODE(0) = rcode; + + switch (rcode) { + case IEEE80211_REASON_MESH_PERR_NO_FI: + IEEE80211_ADDR_COPY(PERR_DADDR(0), addr); + PERR_DSEQ(0) = 0; /* reserved */ + break; + case IEEE80211_REASON_MESH_PERR_NO_PROXY: + KASSERT(rt != NULL, ("no proxy info for sending PERR")); + KASSERT(rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY, + ("route is not marked proxy")); + PERR_DFLAGS(0) |= IEEE80211_MESHPERR_FLAGS_AE; + IEEE80211_ADDR_COPY(PERR_DADDR(0), vap->iv_myaddr); + PERR_DSEQ(0) = rt->rt_ext_seq; + IEEE80211_ADDR_COPY(PERR_DEXTADDR(0), addr); + break; + case IEEE80211_REASON_MESH_PERR_DEST_UNREACH: + KASSERT(rt != NULL, ("no route info for sending PERR")); + IEEE80211_ADDR_COPY(PERR_DADDR(0), addr); + PERR_DSEQ(0) = hr->hr_seq; + break; + default: + KASSERT(0, ("unknown reason code for HWMP PERR (%u)", rcode)); + } + hwmp_send_perr(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &perr); +} +#undef PERR_DFLAGS +#undef PEER_DADDR +#undef PERR_DSEQ +#undef PERR_DEXTADDR +#undef PERR_DRCODE + static void hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshrann_ie *rann) Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:12:39 2012 (r234890) @@ -344,6 +344,13 @@ ieee80211_mesh_rt_del(struct ieee80211va MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { if (IEEE80211_ADDR_EQ(rt->rt_dest, dest)) { + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + ms->ms_ppath->mpp_senderror(vap, dest, rt, + IEEE80211_REASON_MESH_PERR_NO_PROXY); + } else { + ms->ms_ppath->mpp_senderror(vap, dest, rt, + IEEE80211_REASON_MESH_PERR_DEST_UNREACH); + } mesh_rt_del(ms, rt); MESH_RT_UNLOCK(ms); return; @@ -972,10 +979,12 @@ mesh_forward(struct ieee80211vap *vap, s * [Optional] any of the following three actions: * o silently discard * o trigger a path discovery - * o inform TA that meshDA is unreachable. + * o inform TA that meshDA is unknown. */ IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, no path"); + ms->ms_ppath->mpp_senderror(vap, whcopy->i_addr3, NULL, + IEEE80211_REASON_MESH_PERR_NO_FI); vap->iv_stats.is_mesh_fwd_nopath++; m_freem(mcopy); return; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:12:39 2012 (r234890) @@ -449,6 +449,9 @@ struct ieee80211_mesh_proto_path { const uint8_t [IEEE80211_ADDR_LEN], struct mbuf *); void (*mpp_peerdown)(struct ieee80211_node *); + void (*mpp_senderror)(struct ieee80211vap *, + const uint8_t [IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *, int); void (*mpp_vattach)(struct ieee80211vap *); void (*mpp_vdetach)(struct ieee80211vap *); int (*mpp_newstate)(struct ieee80211vap *, From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:13:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAE8B106566B; Tue, 1 May 2012 16:13:22 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4E948FC18; Tue, 1 May 2012 16:13:22 +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 q41GDMBd034117; Tue, 1 May 2012 16:13:22 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GDMtT034114; Tue, 1 May 2012 16:13:22 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011613.q41GDMtT034114@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:13:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234891 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:13:22 -0000 Author: monthadar Date: Tue May 1 16:13:22 2012 New Revision: 234891 URL: http://svn.freebsd.org/changeset/base/234891 Log: RANN update * Introduced a new HWMP sysctl, Root Confirmation Interval; * Added hr_lastrootconf to hwmp_route, is for ratecheck for a specific ROOT; * We missed reading RANN.interval subfield from a RANN frame before; * Updated hwmp_recv_rann according to amendment, see comments; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:12:39 2012 (r234890) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:13:22 2012 (r234891) @@ -157,6 +157,7 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ struct timeval hr_lastpreq; /* last time we sent a PREQ */ + struct timeval hr_lastrootconf; /* last sent PREQ root conf */ int hr_preqretries; /* number of discoveries */ int hr_lastdiscovery; /* last discovery in ticks */ }; @@ -199,6 +200,11 @@ static int ieee80211_hwmp_rannint = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rannint, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_rannint, 0, ieee80211_sysctl_msecs_ticks, "I", "root announcement interval (ms)"); +static struct timeval ieee80211_hwmp_rootconfint = { 0, 0 }; +static int ieee80211_hwmp_rootconfint_internal = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rootconfint, CTLTYPE_INT | CTLFLAG_RD, + &ieee80211_hwmp_rootconfint_internal, 0, ieee80211_sysctl_msecs_ticks, "I", + "root confirmation interval (ms) (read-only)"); #define IEEE80211_HWMP_DEFAULT_MAXHOPS 31 @@ -228,6 +234,7 @@ ieee80211_hwmp_init(void) ieee80211_hwmp_roottimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_rootint = msecs_to_ticks(2*1000); ieee80211_hwmp_rannint = msecs_to_ticks(1*1000); + ieee80211_hwmp_rootconfint_internal = msecs_to_ticks(2*1000); ieee80211_hwmp_maxpreq_retries = 3; /* * (TU): A measurement of time equal to 1024 μs, @@ -236,6 +243,13 @@ ieee80211_hwmp_init(void) ieee80211_hwmp_net_diameter_traversaltime = msecs_to_ticks(512); /* + * NB: I dont know how to make SYSCTL_PROC that calls ms to ticks + * and return a struct timeval... + */ + ieee80211_hwmp_rootconfint.tv_usec = + ieee80211_hwmp_rootconfint_internal * 1000; + + /* * Register action frame handler. */ ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESH, @@ -555,6 +569,7 @@ hwmp_recv_action_meshpath(struct ieee802 } memcpy(&rann, mrann, sizeof(rann)); rann.rann_seq = LE_READ_4(&mrann->rann_seq); + rann.rann_interval = LE_READ_4(&mrann->rann_interval); rann.rann_metric = LE_READ_4(&mrann->rann_metric); hwmp_recv_rann(vap, ni, wh, &rann); found++; @@ -873,6 +888,7 @@ hwmp_rootmode_rann_cb(void *arg) rann.rann_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(rann.rann_addr, vap->iv_myaddr); rann.rann_seq = ++hs->hs_seq; + rann.rann_interval = ieee80211_hwmp_rannint; rann.rann_metric = IEEE80211_MESHLMETRIC_INITIALVAL; vap->iv_stats.is_hwmp_rootrann++; @@ -1684,7 +1700,9 @@ hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; struct ieee80211_hwmp_route *hr; + struct ieee80211_meshpreq_ie preq; struct ieee80211_meshrann_ie prann; + uint32_t metric = 0; if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || @@ -1692,27 +1710,74 @@ hwmp_recv_rann(struct ieee80211vap *vap, return; rt = ieee80211_mesh_rt_find(vap, rann->rann_addr); - /* - * Discover the path to the root mesh STA. - * If we already know it, propagate the RANN element. - */ + if (rt != NULL && rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) { + hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + + /* Acceptance criteria: if RANN.seq < stored seq, discard RANN */ + if (HWMP_SEQ_LT(rann->rann_seq, hr->hr_seq)) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "RANN seq %u < %u", rann->rann_seq, hr->hr_seq); + return; + } + + /* Acceptance criteria: if RANN.seq == stored seq AND + * RANN.metric > stored metric, discard RANN */ + if (HWMP_SEQ_EQ(rann->rann_seq, hr->hr_seq) && + rann->rann_metric > rt->rt_metric) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "RANN metric %u > %u", rann->rann_metric, rt->rt_metric); + return; + } + } + + /* RANN ACCEPTED */ + + ieee80211_hwmp_rannint = rann->rann_interval; /* XXX: mtx lock? */ + metric = rann->rann_metric + ms->ms_pmetric->mpm_metric(ni); + if (rt == NULL) { - hwmp_discover(vap, rann->rann_addr, NULL); - return; + rt = ieee80211_mesh_rt_add(vap, rann->rann_addr); + if (rt == NULL) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "unable to add mac for RANN root %6D", + rann->rann_addr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (HWMP_SEQ_GT(rann->rann_seq, hr->hr_seq)) { + /* discovery timeout */ + ieee80211_mesh_rt_update(rt, + ticks_to_msecs(ieee80211_hwmp_roottimeout)); + + preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_hopcount = 0; + preq.preq_ttl = ms->ms_ttl; + preq.preq_id = 0; /* reserved */ + IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); + preq.preq_origseq = ++hs->hs_seq; + preq.preq_lifetime = ieee80211_hwmp_roottimeout; + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + preq.preq_tcount = 1; + preq.preq_targets[0].target_flags = IEEE80211_MESHPREQ_TFLAGS_TO; + /* NB: IEEE80211_MESHPREQ_TFLAGS_USN = 0 implicitly implied */ + IEEE80211_ADDR_COPY(preq.preq_targets[0].target_addr, rann->rann_addr); + preq.preq_targets[0].target_seq = rann->rann_seq; + /* XXX: if rootconfint have not passed, we built this preq in vain */ + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, wh->i_addr2, &preq, + &hr->hr_lastrootconf, &ieee80211_hwmp_rootconfint); + + /* propagate a RANN */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID && + rann->rann_ttl > 1 && + ms->ms_flags & IEEE80211_MESHFLAGS_FWD) { hr->hr_seq = rann->rann_seq; - if (rann->rann_ttl > 1 && - rann->rann_hopcount < hs->hs_maxhops && - (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { - memcpy(&prann, rann, sizeof(prann)); - prann.rann_hopcount += 1; - prann.rann_ttl -= 1; - prann.rann_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &prann); - } + memcpy(&prann, rann, sizeof(prann)); + prann.rann_hopcount += 1; + prann.rann_ttl -= 1; + prann.rann_metric += ms->ms_pmetric->mpm_metric(ni); + hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, + broadcastaddr, &prann); } } Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:12:39 2012 (r234890) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:13:22 2012 (r234891) @@ -426,7 +426,7 @@ struct ieee80211_mesh_route { uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ uint16_t rt_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* patch discovery complete */ +#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* path discovery complete */ #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:14:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 188451065672; Tue, 1 May 2012 16:14:19 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 03B278FC12; Tue, 1 May 2012 16:14:19 +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 q41GEI12034197; Tue, 1 May 2012 16:14:18 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GEISi034191; Tue, 1 May 2012 16:14:18 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011614.q41GEISi034191@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234892 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:14:19 -0000 Author: monthadar Date: Tue May 1 16:14:18 2012 New Revision: 234892 URL: http://svn.freebsd.org/changeset/base/234892 Log: Net80211s update: Mesh Gate Announcement and removal of Portal Announcement. * Renamed IEEE80211_ELEMID_MESHPANN to IEEE80211_ELEMID_MESHGANN according to amendment; * Added IEEE80211_IOC_MESH_GATE that controls whether Mesh Gate Announcement is activated or not; * Renamed all flags from Portal to Gate in HWMP frames; * Removed IEEE80211_ACTION_MESHPANN enum cause its part of the Mesh Action category now as per amendment; * Renamed IEEE80211_MESHFLAGS_PORTAL to IEEE80211_MESHFLAGS_GATE in ieee80211_mesh_state flags; * Modified ieee80211_hwmp.c/ieee80211_mesh.c to use new GATE flags; Approved by: adrian Modified: head/sys/net80211/ieee80211.h head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_ioctl.h head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211.h ============================================================================== --- head/sys/net80211/ieee80211.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211.h Tue May 1 16:14:18 2012 (r234892) @@ -734,7 +734,7 @@ enum { IEEE80211_ELEMID_MESHAWAKEW = 119, IEEE80211_ELEMID_MESHBEACONT = 120, /* 121-124 MMCAOP not implemented yet */ - IEEE80211_ELEMID_MESHPANN = 125, /* XXX: is GANN now, not used */ + IEEE80211_ELEMID_MESHGANN = 125, IEEE80211_ELEMID_MESHRANN = 126, /* 127 Extended Capabilities */ /* 128-129 reserved */ Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:14:18 2012 (r234892) @@ -840,9 +840,9 @@ hwmp_rootmode_cb(void *arg) IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss, "%s", "send broadcast PREQ"); - preq.preq_flags = 0; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PR; + preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_GATE; if (hs->hs_rootmode == IEEE80211_HWMP_ROOTMODE_PROACTIVE) preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PP; preq.preq_hopcount = 0; @@ -882,8 +882,8 @@ hwmp_rootmode_rann_cb(void *arg) "%s", "send broadcast RANN"); rann.rann_flags = 0; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - rann.rann_flags |= IEEE80211_MESHRANN_FLAGS_PR; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + rann.rann_flags |= IEEE80211_MESHFLAGS_GATE; rann.rann_hopcount = 0; rann.rann_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(rann.rann_addr, vap->iv_myaddr); Modified: head/sys/net80211/ieee80211_ioctl.h ============================================================================== --- head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:14:18 2012 (r234892) @@ -709,6 +709,7 @@ struct ieee80211req { #define IEEE80211_IOC_MESH_PR_SIG 178 /* mesh sig protocol */ #define IEEE80211_IOC_MESH_PR_CC 179 /* mesh congestion protocol */ #define IEEE80211_IOC_MESH_PR_AUTH 180 /* mesh auth protocol */ +#define IEEE80211_IOC_MESH_GATE 181 /* mesh gate XXX: 173? */ #define IEEE80211_IOC_HWMP_ROOTMODE 190 /* HWMP root mode */ #define IEEE80211_IOC_HWMP_MAXHOPS 191 /* number of hops before drop */ Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:14:18 2012 (r234892) @@ -1262,7 +1262,7 @@ mesh_recv_group_data(struct ieee80211vap * This happens by delivering the packet, and a bridge * will sent it on another port member. */ - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL && + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE && ms->ms_flags & IEEE80211_MESHFLAGS_FWD) IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, MC01(mc)->mc_addr4, "%s", @@ -2768,8 +2768,8 @@ ieee80211_add_meshconf(uint8_t *frm, str /* NB: set the number of neighbors before the rest */ *frm = (ms->ms_neighbors > IEEE80211_MESH_MAX_NEIGHBORS ? IEEE80211_MESH_MAX_NEIGHBORS : ms->ms_neighbors) << 1; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - *frm |= IEEE80211_MESHCONF_FORM_MP; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + *frm |= IEEE80211_MESHCONF_FORM_GATE; frm += 1; caps = 0; if (ms->ms_flags & IEEE80211_MESHFLAGS_AP) @@ -2961,6 +2961,9 @@ mesh_ioctl_get80211(struct ieee80211vap case IEEE80211_IOC_MESH_FWRD: ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) != 0; break; + case IEEE80211_IOC_MESH_GATE: + ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) != 0; + break; case IEEE80211_IOC_MESH_TTL: ireq->i_val = ms->ms_ttl; break; @@ -3076,6 +3079,12 @@ mesh_ioctl_set80211(struct ieee80211vap else ms->ms_flags &= ~IEEE80211_MESHFLAGS_FWD; break; + case IEEE80211_IOC_MESH_GATE: + if (ireq->i_val) + ms->ms_flags |= IEEE80211_MESHFLAGS_GATE; + else + ms->ms_flags &= ~IEEE80211_MESHFLAGS_GATE; + break; case IEEE80211_IOC_MESH_TTL: ms->ms_ttl = (uint8_t) ireq->i_val; break; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:14:18 2012 (r234892) @@ -98,7 +98,7 @@ enum { }; /* Mesh Formation Info */ -#define IEEE80211_MESHCONF_FORM_MP 0x01 /* Connected to Portal */ +#define IEEE80211_MESHCONF_FORM_GATE 0x01 /* Connected to Gate */ #define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */ #define IEEE80211_MESHCONF_FORM_SA 0xF0 /* indicating 802.1X auth */ @@ -193,9 +193,9 @@ struct ieee80211_meshbeacont_ie { } __packed; #endif -/* Portal (MP) Annoucement */ -struct ieee80211_meshpann_ie { - uint8_t pann_ie; /* IEEE80211_ELEMID_MESHPANN */ +/* Gate (GANN) Annoucement */ +struct ieee80211_meshgann_ie { + uint8_t pann_ie; /* IEEE80211_ELEMID_MESHGANN */ uint8_t pann_len; uint8_t pann_flags; uint8_t pann_hopcount; @@ -210,7 +210,7 @@ struct ieee80211_meshrann_ie { uint8_t rann_ie; /* IEEE80211_ELEMID_MESHRANN */ uint8_t rann_len; uint8_t rann_flags; -#define IEEE80211_MESHRANN_FLAGS_PR 0x01 /* Portal Role */ +#define IEEE80211_MESHRANN_FLAGS_GATE 0x01 /* Mesh Gate */ uint8_t rann_hopcount; uint8_t rann_ttl; uint8_t rann_addr[IEEE80211_ADDR_LEN]; @@ -229,7 +229,7 @@ struct ieee80211_meshpreq_ie { uint8_t preq_ie; /* IEEE80211_ELEMID_MESHPREQ */ uint8_t preq_len; uint8_t preq_flags; -#define IEEE80211_MESHPREQ_FLAGS_PR 0x01 /* Portal Role */ +#define IEEE80211_MESHPREQ_FLAGS_GATE 0x01 /* Mesh Gate */ #define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */ @@ -360,14 +360,6 @@ enum { }; /* - * Mesh Portal Annoucement Action codes. - */ -enum { - IEEE80211_ACTION_MESHPANN = 0, - /* 1-255 reserved */ -}; - -/* * Different mesh control structures based on the AE * (Address Extension) bits. */ @@ -498,7 +490,7 @@ struct ieee80211_mesh_state { uint16_t ms_neighbors; uint8_t ms_ttl; /* mesh ttl set in packets */ #define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */ -#define IEEE80211_MESHFLAGS_PORTAL 0x02 /* mesh portal role */ +#define IEEE80211_MESHFLAGS_GATE 0x02 /* mesh gate role */ #define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */ uint8_t ms_flags; struct mtx ms_rt_lock; @@ -556,7 +548,7 @@ ieee80211_mesh_isproxyena(struct ieee802 { struct ieee80211_mesh_state *ms = vap->iv_mesh; return (ms->ms_flags & - (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_PORTAL)) != 0; + (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0; } /* From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:15:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C1D87106581A; Tue, 1 May 2012 16:15:35 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9292C8FC16; Tue, 1 May 2012 16:15: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 q41GFZJv034281; Tue, 1 May 2012 16:15:35 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GFZa1034278; Tue, 1 May 2012 16:15:35 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011615.q41GFZa1034278@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:15: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: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:15:35 -0000 Author: monthadar Date: Tue May 1 16:15:34 2012 New Revision: 234893 URL: http://svn.freebsd.org/changeset/base/234893 Log: * Added new command to ifconfig to activate Mesh Gate Announcement called meshgate with corresponding explanation; Approved by: adrian Modified: head/sbin/ifconfig/ifconfig.8 head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Tue May 1 16:14:18 2012 (r234892) +++ head/sbin/ifconfig/ifconfig.8 Tue May 1 16:15:34 2012 (r234893) @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by By default .Cm meshforward is enabled. +.It Cm meshgate +This attribute specifies whether or not the mesh STA activates mesh gate +announcements. +By default +.Cm meshgate +is disabled. .It Cm meshmetric Ar protocol Set the specified .Ar protocol Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue May 1 16:14:18 2012 (r234892) +++ head/sbin/ifconfig/ifieee80211.c Tue May 1 16:15:34 2012 (r234893) @@ -1883,6 +1883,12 @@ DECL_CMD_FUNC(set80211meshforward, val, } static +DECL_CMD_FUNC(set80211meshgate, val, d) +{ + set80211(s, IEEE80211_IOC_MESH_GATE, d, 0, NULL); +} + +static DECL_CMD_FUNC(set80211meshpeering, val, d) { set80211(s, IEEE80211_IOC_MESH_AP, d, 0, NULL); @@ -4832,6 +4838,12 @@ end: else LINE_CHECK("-meshforward"); } + if (get80211val(s, IEEE80211_IOC_MESH_GATE, &val) != -1) { + if (val) + LINE_CHECK("meshgate"); + else + LINE_CHECK("-meshgate"); + } if (get80211len(s, IEEE80211_IOC_MESH_PR_METRIC, data, 12, &len) != -1) { data[len] = '\0'; @@ -5271,6 +5283,8 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD_ARG("meshttl", set80211meshttl), DEF_CMD("meshforward", 1, set80211meshforward), DEF_CMD("-meshforward", 0, set80211meshforward), + DEF_CMD("meshgate", 1, set80211meshgate), + DEF_CMD("-meshgate", 0, set80211meshgate), DEF_CMD("meshpeering", 1, set80211meshpeering), DEF_CMD("-meshpeering", 0, set80211meshpeering), DEF_CMD_ARG("meshmetric", set80211meshmetric), From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:16:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28C5E106567B; Tue, 1 May 2012 16:16:21 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 12D3D8FC20; Tue, 1 May 2012 16:16: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 q41GGKrE034352; Tue, 1 May 2012 16:16:20 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GGKN7034347; Tue, 1 May 2012 16:16:20 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011616.q41GGKN7034347@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:16:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234894 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:16:21 -0000 Author: monthadar Date: Tue May 1 16:16:20 2012 New Revision: 234894 URL: http://svn.freebsd.org/changeset/base/234894 Log: PREQ discovery update. * Added a new discovery flag IEEE80211_MESHRT_FLAGS_DISCOVER; * Modified ieee80211_ioctl.h to include IEEE80211_MESHRT_FLAGS_DISCOVER; * Added hwmp_rediscover_cb, which will be called by a timeout to do rediscovery if we have not reach max number of preq discovery; * Modified hwmp_discover to setup a callout for path rediscovery; * Added to ieee80211req_mesh_route to have a back pointer to ieee80211vap for the discovery callout context; * Modified mesh_rt_add_locked arguemnt from ieee80211_mesh_state to ieee80211vap, this because we have to initialize the above back pointer; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_ioctl.h head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:16:20 2012 (r234894) @@ -1319,7 +1319,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + rt->rt_flags = IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* * If it's NOT for us, propagate the PREP @@ -1805,6 +1805,64 @@ hwmp_send_rann(struct ieee80211_node *ni #define PREQ_TFLAGS(n) preq.preq_targets[n].target_flags #define PREQ_TADDR(n) preq.preq_targets[n].target_addr #define PREQ_TSEQ(n) preq.preq_targets[n].target_seq +static void +hwmp_rediscover_cb(void *arg) +{ + struct ieee80211_mesh_route *rt = arg; + struct ieee80211vap *vap = rt->rt_vap; + struct ieee80211_hwmp_state *hs = vap->iv_hwmp; + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_hwmp_route *hr; + struct ieee80211_meshpreq_ie preq; /* Optimize: storing first preq? */ + + if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) + return ; /* nothing to do */ + + hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + if (hr->hr_preqretries >= + ieee80211_hwmp_maxpreq_retries) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + rt->rt_dest, NULL, "%s", + "no valid path , max number of discovery, send GATE"); + /* TODO: send to known gates */ + vap->iv_stats.is_mesh_fwd_nopath++; + rt->rt_flags = 0; /* Mark invalid */ + return ; /* XXX: flush queue? */ + } + + hr->hr_preqretries++; + + + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, rt->rt_dest, + "start path rediscovery , target seq %u", hr->hr_seq); + /* + * Try to discover the path for this node. + * Group addressed PREQ Case A + */ + preq.preq_flags = 0; + preq.preq_hopcount = 0; + preq.preq_ttl = ms->ms_ttl; + preq.preq_id = ++hs->hs_preqid; + IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); + preq.preq_origseq = hr->hr_origseq; + preq.preq_lifetime = ticks_to_msecs(ieee80211_hwmp_pathtimeout); + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + preq.preq_tcount = 1; + IEEE80211_ADDR_COPY(PREQ_TADDR(0), rt->rt_dest); + PREQ_TFLAGS(0) = 0; + if (ieee80211_hwmp_targetonly) + PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO; + PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN; + PREQ_TSEQ(0) = 0; /* RESERVED when USN flag is set */ + /* XXX check return value */ + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, + broadcastaddr, &preq, &hr->hr_lastpreq, + &ieee80211_hwmp_preqminint); + callout_reset(&rt->rt_discovery, + ieee80211_hwmp_net_diameter_traversaltime * 2, + hwmp_rediscover_cb, rt); +} + static struct ieee80211_node * hwmp_discover(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m) @@ -1857,13 +1915,11 @@ hwmp_discover(struct ieee80211vap *vap, vap->iv_stats.is_mesh_fwd_nopath++; goto done; } + rt->rt_flags = IEEE80211_MESHRT_FLAGS_DISCOVER; hr->hr_preqretries++; if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; - /* XXX: special discovery timeout, larger lifetime? */ - ieee80211_mesh_rt_update(rt, - ticks_to_msecs(ieee80211_hwmp_pathtimeout)); sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, "start path discovery (src %s), target seq %u", @@ -1894,6 +1950,9 @@ hwmp_discover(struct ieee80211vap *vap, hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, &hr->hr_lastpreq, &ieee80211_hwmp_preqminint); + callout_reset(&rt->rt_discovery, + ieee80211_hwmp_net_diameter_traversaltime * 2, + hwmp_rediscover_cb, rt); } if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ni = ieee80211_find_txnode(vap, rt->rt_nexthop); Modified: head/sys/net80211/ieee80211_ioctl.h ============================================================================== --- head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:16:20 2012 (r234894) @@ -339,8 +339,9 @@ enum { struct ieee80211req_mesh_route { uint8_t imr_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 -#define IEEE80211_MESHRT_FLAGS_PROXY 0x02 +#define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 +#define IEEE80211_MESHRT_FLAGS_VALID 0x02 +#define IEEE80211_MESHRT_FLAGS_PROXY 0x04 uint8_t imr_dest[IEEE80211_ADDR_LEN]; uint8_t imr_nexthop[IEEE80211_ADDR_LEN]; uint16_t imr_nhops; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:16:20 2012 (r234894) @@ -175,9 +175,10 @@ mesh_rt_find_locked(struct ieee80211_mes } static struct ieee80211_mesh_route * -mesh_rt_add_locked(struct ieee80211_mesh_state *ms, +mesh_rt_add_locked(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN]) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt; KASSERT(!IEEE80211_ADDR_EQ(broadcastaddr, dest), @@ -188,9 +189,11 @@ mesh_rt_add_locked(struct ieee80211_mesh rt = malloc(ALIGN(sizeof(struct ieee80211_mesh_route)) + ms->ms_ppath->mpp_privlen, M_80211_MESH_RT, M_NOWAIT | M_ZERO); if (rt != NULL) { + rt->rt_vap = vap; IEEE80211_ADDR_COPY(rt->rt_dest, dest); rt->rt_priv = (void *)ALIGN(&rt[1]); mtx_init(&rt->rt_lock, "MBSS_RT", "802.11s route entry", MTX_DEF); + callout_init(&rt->rt_discovery, CALLOUT_MPSAFE); rt->rt_updtime = ticks; /* create time */ TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next); } @@ -223,7 +226,7 @@ ieee80211_mesh_rt_add(struct ieee80211va ("%s: adding self to the routing table", __func__)); MESH_RT_LOCK(ms); - rt = mesh_rt_add_locked(ms, dest); + rt = mesh_rt_add_locked(vap, dest); MESH_RT_UNLOCK(ms); return rt; } @@ -285,7 +288,7 @@ ieee80211_mesh_proxy_check(struct ieee80 MESH_RT_LOCK(ms); rt = mesh_rt_find_locked(ms, dest); if (rt == NULL) { - rt = mesh_rt_add_locked(ms, dest); + rt = mesh_rt_add_locked(vap, dest); if (rt == NULL) { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, "%s", "unable to add proxy entry"); @@ -330,6 +333,7 @@ mesh_rt_del(struct ieee80211_mesh_state * is holding the route. */ RT_ENTRY_LOCK(rt); + callout_drain(&rt->rt_discovery); mtx_destroy(&rt->rt_lock); free(rt, M_80211_MESH_RT); } @@ -402,13 +406,11 @@ mesh_rt_flush_invalid(struct ieee80211va return; MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { + /* Discover paths will be deleted by their own callout */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) + continue; ieee80211_mesh_rt_update(rt, 0); - /* - * NB: we check for lifetime == 0 so that we give a chance - * for route discovery to complete. - */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 && - rt->rt_lifetime == 0) + if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) mesh_rt_del(ms, rt); } MESH_RT_UNLOCK(ms); Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:16:20 2012 (r234894) @@ -410,7 +410,9 @@ MALLOC_DECLARE(M_80211_MESH_RT); */ struct ieee80211_mesh_route { TAILQ_ENTRY(ieee80211_mesh_route) rt_next; + struct ieee80211vap *rt_vap; struct mtx rt_lock; /* fine grained route lock */ + struct callout rt_discovery; /* discovery timeout */ int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ @@ -418,8 +420,9 @@ struct ieee80211_mesh_route { uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ uint16_t rt_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* path discovery complete */ -#define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ +#define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 /* path discovery */ +#define IEEE80211_MESHRT_FLAGS_VALID 0x02 /* path discovery complete */ +#define IEEE80211_MESHRT_FLAGS_PROXY 0x04 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ uint32_t rt_ext_seq; /* proxy seq number */ From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:17:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F92D1065672; Tue, 1 May 2012 16:17:18 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B75F8FC22; Tue, 1 May 2012 16:17:18 +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 q41GHI0J034421; Tue, 1 May 2012 16:17:18 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GHIbO034418; Tue, 1 May 2012 16:17:18 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011617.q41GHIbO034418@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:17:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234895 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:17:18 -0000 Author: monthadar Date: Tue May 1 16:17:17 2012 New Revision: 234895 URL: http://svn.freebsd.org/changeset/base/234895 Log: * Modified ifconfig to show the IEEE80211_MESHRT_FLAGS_DISCOVER flag with a 'D'; Approved by: adrian Modified: head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue May 1 16:16:20 2012 (r234894) +++ head/sbin/ifconfig/ifieee80211.c Tue May 1 16:17:17 2012 (r234895) @@ -4020,6 +4020,8 @@ list_mesh(int s) ether_ntoa((const struct ether_addr *)rt->imr_nexthop), rt->imr_nhops, rt->imr_metric, rt->imr_lifetime, rt->imr_lastmseq, + (rt->imr_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) ? + 'D' : (rt->imr_flags & IEEE80211_MESHRT_FLAGS_VALID) ? 'V' : '!', (rt->imr_flags & IEEE80211_MESHRT_FLAGS_PROXY) ? From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:18:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A5D5106566C; Tue, 1 May 2012 16:18:39 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14C998FC08; Tue, 1 May 2012 16:18:39 +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 q41GIcMQ034504; Tue, 1 May 2012 16:18:38 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GIcsV034502; Tue, 1 May 2012 16:18:38 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011618.q41GIcsV034502@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234896 - head/sys/net80211 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:18:39 -0000 Author: monthadar Date: Tue May 1 16:18:38 2012 New Revision: 234896 URL: http://svn.freebsd.org/changeset/base/234896 Log: Update HWMP Proactive code and mesh route flags. * Modified hwmp_recv_preq: o cleaned up code, removed rootmac variable because preq->origaddr is the root when we recevie a Proactive PREQ; o Modified so that a PREP in response of a Proactive PREQ is unicast, a PREP is ALWAYS unicast; * Modified hwmp_recv_prep: o Before we mark a route to be valid we should remove the discovery flag and then mark it valid in such a way we wont lose the isgate flag; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:17:17 2012 (r234895) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:18:38 2012 (r234896) @@ -904,7 +904,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { struct ieee80211_mesh_state *ms = vap->iv_mesh; - struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; struct ieee80211_mesh_route *rtorig_ext = NULL; struct ieee80211_mesh_route *rttarg = NULL; @@ -1083,33 +1082,20 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) && (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { - uint8_t rootmac[IEEE80211_ADDR_LEN]; - - IEEE80211_ADDR_COPY(rootmac, preq->preq_origaddr); - rt = ieee80211_mesh_rt_find(vap, rootmac); - if (rt == NULL) { - rt = ieee80211_mesh_rt_add(vap, rootmac); - if (rt == NULL) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "unable to add root mesh path to %6D", - rootmac, ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - } IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "root mesh station @ %6D", rootmac, ":"); + "root mesh station @ %6D", preq->preq_origaddr, ":"); /* * Reply with a PREP if we don't have a path to the root * or if the root sent us a proactive PREQ. */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || + if ((rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_PP)) { prep.prep_flags = 0; prep.prep_hopcount = 0; prep.prep_ttl = ms->ms_ttl; - IEEE80211_ADDR_COPY(prep.prep_origaddr, rootmac); + IEEE80211_ADDR_COPY(prep.prep_origaddr, + preq->preq_origaddr); prep.prep_origseq = preq->preq_origseq; prep.prep_lifetime = preq->preq_lifetime; prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL; @@ -1117,7 +1103,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, vap->iv_myaddr); prep.prep_targetseq = ++hs->hs_seq; hwmp_send_prep(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &prep); + rtorig->rt_nexthop, &prep); } } @@ -1319,7 +1305,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_flags = IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) { + /* discovery complete */ + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_DISCOVER; + } + rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* * If it's NOT for us, propagate the PREP From owner-svn-src-all@FreeBSD.ORG Tue May 1 16:38:34 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F4841065670; Tue, 1 May 2012 16:38:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A1718FC15; Tue, 1 May 2012 16:38:34 +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 q41GcYwb035297; Tue, 1 May 2012 16:38:34 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GcYRW035295; Tue, 1 May 2012 16:38:34 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205011638.q41GcYRW035295@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 16:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234897 - head/sys/boot/sparc64/loader X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:38:34 -0000 Author: marius Date: Tue May 1 16:38:33 2012 New Revision: 234897 URL: http://svn.freebsd.org/changeset/base/234897 Log: Add a command for showing the heap usage. PR: 165025 Submitted by: Gavin Mu MFC after: 1 week Modified: head/sys/boot/sparc64/loader/main.c Modified: head/sys/boot/sparc64/loader/main.c ============================================================================== --- head/sys/boot/sparc64/loader/main.c Tue May 1 16:18:38 2012 (r234896) +++ head/sys/boot/sparc64/loader/main.c Tue May 1 16:38:33 2012 (r234897) @@ -800,6 +800,18 @@ main(int (*openfirm)(void *)) return (1); } +COMMAND_SET(heap, "heap", "show heap usage", command_heap); + +static int +command_heap(int argc, char *argv[]) +{ + + mallocstats(); + printf("heap base at %p, top at %p, upper limit at %p\n", heapva, + sbrk(0), heapva + HEAPSZ); + return(CMD_OK); +} + COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); static int From owner-svn-src-all@FreeBSD.ORG Tue May 1 17:16:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CA9C21065672; Tue, 1 May 2012 17:16:01 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B26EF8FC0C; Tue, 1 May 2012 17:16:01 +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 q41HG1BB036613; Tue, 1 May 2012 17:16:01 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41HG1fL036603; Tue, 1 May 2012 17:16:01 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205011716.q41HG1fL036603@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 17:16:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 17:16:01 -0000 Author: marius Date: Tue May 1 17:16:01 2012 New Revision: 234898 URL: http://svn.freebsd.org/changeset/base/234898 Log: Add initial support for booting from ZFS on sparc64. At least on Sun Fire V100, the firmware is known to be broken and not allowing to simultaneously open disk devices, causing attempts to boot from a mirror or RAIDZ to cause a crash. This will be worked around later. The firmwares of newer sun4u models don't seem to exhibit this problem though. Steps for ZFS booting: 1. create VTOC8 label # gpart create -s vtoc8 da0 2. add partitions, f.e.: # gpart add -t freebsd-zfs -s 60g da0 # gpart add -t freebsd-swap da0 resulting in something like: # gpart show => 0 143331930 da0 VTOC8 (68G) 0 125821080 1 freebsd-zfs (60G) 125821080 17510850 2 freebsd-swap (8.4G) 3. create zpool # zpool create bunker da0a or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.): # zpool create bunker mirror da0a da1a # zpool create bunker raidz da0a da1a da2a ... 4. set bootfs # zpool set bootfs=bunker bunker 5. install zfsboot # zpool export bunker # gpart bootcode -p /boot/zfsboot da0 6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool for this, so dd(1) has to be used for this purpose) When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated for the additional disks in order to be able to boot from another disk in case of failure. # sysctl kern.geom.debugflags=0x10 # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc # zpool import bunker 7. install system on ZFS filesystem Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in loader.conf as well as 'zfs_enable="YES"'in rc.conf. 8. copy zpool.cache to the ZFS filesystem cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache 9. set mountpoint # zfs set mountpoint=/ bunker 10. Now, given that aliases for all disks in the zpool exists (check with the `devalias` command on the boot monitor prompt) and disk0 corresponds to da0 (likewise for additional disks), the system can be booted from the ZFS with: {1} ok boot disk0 PR: 165025 Submitted by: Gavin Mu Added: head/sys/boot/sparc64/zfsboot/ head/sys/boot/sparc64/zfsboot/Makefile (contents, props changed) head/sys/boot/sparc64/zfsloader/ head/sys/boot/sparc64/zfsloader/Makefile (contents, props changed) Modified: head/sys/boot/ofw/libofw/devicename.c head/sys/boot/sparc64/Makefile head/sys/boot/sparc64/boot1/Makefile head/sys/boot/sparc64/boot1/boot1.c head/sys/boot/sparc64/loader/Makefile head/sys/boot/sparc64/loader/main.c head/sys/boot/zfs/zfs.c Modified: head/sys/boot/ofw/libofw/devicename.c ============================================================================== --- head/sys/boot/ofw/libofw/devicename.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/ofw/libofw/devicename.c Tue May 1 17:16:01 2012 (r234898) @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); #include + +#include "bootstrap.h" #include "libofw.h" static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); @@ -76,6 +78,7 @@ ofw_parsedev(struct ofw_devdesc **dev, c phandle_t handle; const char *p; const char *s; + char *ep; char name[256]; char type[64]; int len; @@ -87,9 +90,10 @@ ofw_parsedev(struct ofw_devdesc **dev, c len = s - devspec; bcopy(devspec, name, len); name[len] = '\0'; - if ((handle = OF_finddevice(name)) == -1) - break; - if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1) + if ((handle = OF_finddevice(name)) == -1) { + bcopy(name, type, len); + type[len] = '\0'; + } else if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1) continue; for (i = 0; (dv = devsw[i]) != NULL; i++) { if (strncmp(dv->dv_name, type, strlen(dv->dv_name)) == 0) @@ -109,6 +113,18 @@ found: strcpy(idev->d_path, name); idev->d_dev = dv; idev->d_type = dv->dv_type; + if (idev->d_type == DEVT_ZFS) { + idev->d_unit = 0; + p = name + strlen(dv->dv_name); + if (*p && (*p != ':')) { + idev->d_unit = strtol(p, &ep, 0); + if (ep == p) { + free(idev); + return (EUNIT); + } + } + } + if (dev == NULL) { free(idev); } else { Modified: head/sys/boot/sparc64/Makefile ============================================================================== --- head/sys/boot/sparc64/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= boot1 loader +SUBDIR= boot1 loader zfsboot zfsloader .include Modified: head/sys/boot/sparc64/boot1/Makefile ============================================================================== --- head/sys/boot/sparc64/boot1/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/boot1/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -3,22 +3,23 @@ PROG= boot1.elf INTERNALPROG= NO_MAN= -FILES= boot1 +FILES?= boot1 SRCS= _start.s boot1.c +CLEANFILES+=boot1 boot1.aout BOOTBLOCKBASE= 0x4000 -CFLAGS= -mcmodel=medlow -Os -I${.CURDIR}/../../common +CFLAGS+=-mcmodel=medlow -Os -I${.CURDIR}/../../common LDFLAGS=-Ttext ${BOOTBLOCKBASE} -Wl,-N # Construct boot1. sunlabel expects it to contain zeroed-out space for the # label, and to be of the correct size. boot1: boot1.aout + @set -- `ls -l boot1.aout`; x=$$((7680-$$5)); \ + echo "$$x bytes available"; test $$x -ge 0 dd if=/dev/zero of=${.TARGET} bs=512 count=16 dd if=boot1.aout of=${.TARGET} bs=512 oseek=1 conv=notrunc -CLEANFILES= boot1.aout - boot1.aout: boot1.elf elf2aout -o ${.TARGET} ${.ALLSRC} Modified: head/sys/boot/sparc64/boot1/boot1.c ============================================================================== --- head/sys/boot/sparc64/boot1/boot1.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/boot1/boot1.c Tue May 1 17:16:01 2012 (r234898) @@ -20,11 +20,13 @@ __FBSDID("$FreeBSD$"); #include #include + #include #include -#define _PATH_LOADER "/boot/loader" -#define _PATH_KERNEL "/boot/kernel/kernel" +#define _PATH_LOADER "/boot/loader" +#define _PATH_KERNEL "/boot/kernel/kernel" +#define READ_BUF_SIZE 8192 typedef int putc_func_t(char c, void *arg); typedef int32_t ofwh_t; @@ -45,17 +47,21 @@ static ofwh_t bootdev; static uint32_t fs_off; int main(int ac, char **av); - static void exit(int) __dead2; -static void load(const char *); -static int dskread(void *, u_int64_t, int); - static void usage(void); +#ifdef ZFSBOOT +static void loadzfs(void); +static int zbread(char *buf, off_t off, size_t bytes); +#else +static void load(const char *); +#endif + static void bcopy(const void *src, void *dst, size_t len); static void bzero(void *b, size_t len); static int mount(const char *device); +static int dskread(void *buf, u_int64_t lba, int nblk); static void panic(const char *fmt, ...) __dead2; static int printf(const char *fmt, ...); @@ -312,8 +318,6 @@ strcmp(const char *s1, const char *s2) return ((u_char)*s1 - (u_char)*s2); } -#include "ufsread.c" - int main(int ac, char **av) { @@ -335,14 +339,22 @@ main(int ac, char **av) } } - printf(" \n>> FreeBSD/sparc64 boot block\n" - " Boot path: %s\n" - " Boot loader: %s\n", bootpath, path); +#ifdef ZFSBOOT + printf(" \n>> FreeBSD/sparc64 ZFS boot block\n Boot path: %s\n", + bootpath); +#else + printf(" \n>> FreeBSD/sparc64 boot block\n Boot path: %s\n" + " Boot loader: %s\n", "", bootpath, path); +#endif if (mount(bootpath) == -1) panic("mount"); +#ifdef ZFSBOOT + loadzfs(); +#else load(path); +#endif return (1); } @@ -361,24 +373,86 @@ exit(int code) ofw_exit(); } -static struct dmadat __dmadat; +#ifdef ZFSBOOT + +#define VDEV_BOOT_OFFSET (2 * 256 * 1024) +static char zbuf[READ_BUF_SIZE]; static int -mount(const char *device) +zbread(char *buf, off_t off, size_t bytes) { + size_t len; + off_t poff; + off_t soff; + char *p; + unsigned int nb; + unsigned int lb; - dmadat = &__dmadat; - if ((bootdev = ofw_open(device)) == -1) { - printf("mount: can't open device\n"); - return (-1); + p = buf; + soff = VDEV_BOOT_OFFSET + off; + lb = (soff + bytes + DEV_BSIZE - 1) / DEV_BSIZE; + poff = soff; + while (poff < soff + bytes) { + nb = lb - poff / DEV_BSIZE; + if (nb > READ_BUF_SIZE / DEV_BSIZE) + nb = READ_BUF_SIZE / DEV_BSIZE; + if (dskread(zbuf, poff / DEV_BSIZE, nb)) + break; + if ((poff / DEV_BSIZE + nb) * DEV_BSIZE > soff + bytes) + len = soff + bytes - poff; + else + len = (poff / DEV_BSIZE + nb) * DEV_BSIZE - poff; + memcpy(p, zbuf + poff % DEV_BSIZE, len); + p += len; + poff += len; } - if (fsread(0, NULL, 0)) { - printf("mount: can't read superblock\n"); - return (-1); + return (poff - soff); +} + +static void +loadzfs(void) +{ + Elf64_Ehdr eh; + Elf64_Phdr ph; + caddr_t p; + ino_t ino; + int i; + + if (zbread((char *)&eh, 0, sizeof(eh)) != sizeof(eh)) { + printf("Can't read elf header\n"); + return; } - return (0); + if (!IS_ELF(eh)) { + printf("Not an ELF file\n"); + return; + } + for (i = 0; i < eh.e_phnum; i++) { + fs_off = eh.e_phoff + i * eh.e_phentsize; + if (zbread((char *)&ph, fs_off, sizeof(ph)) != sizeof(ph)) { + printf("Can't read program header %d\n", i); + return; + } + if (ph.p_type != PT_LOAD) + continue; + fs_off = ph.p_offset; + p = (caddr_t)ph.p_vaddr; + if (zbread(p, fs_off, ph.p_filesz) != ph.p_filesz) { + printf("Can't read content of section %d\n", i); + return; + } + if (ph.p_filesz != ph.p_memsz) + bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); + } + ofw_close(bootdev); + (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); } +#else + +#include "ufsread.c" + +static struct dmadat __dmadat; + static void load(const char *fname) { @@ -421,6 +495,26 @@ load(const char *fname) (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); } +#endif /* ZFSBOOT */ + +static int +mount(const char *device) +{ + + if ((bootdev = ofw_open(device)) == -1) { + printf("mount: can't open device\n"); + return (-1); + } +#ifndef ZFSBOOT + dmadat = &__dmadat; + if (fsread(0, NULL, 0)) { + printf("mount: can't read superblock\n"); + return (-1); + } +#endif + return (0); +} + static int dskread(void *buf, u_int64_t lba, int nblk) { Modified: head/sys/boot/sparc64/loader/Makefile ============================================================================== --- head/sys/boot/sparc64/loader/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/loader/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -3,8 +3,8 @@ .include MK_SSP= no -PROG= loader -NEWVERSWHAT= "bootstrap loader" sparc64 +PROG?= loader +NEWVERSWHAT?= "bootstrap loader" sparc64 INSTALLFLAGS= -b # Architecture-specific loader code @@ -13,12 +13,17 @@ SRCS= locore.S main.c metadata.c vers.c LOADER_DISK_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= yes +LOADER_ZFS_SUPPORT?= no LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= yes LOADER_GZIP_SUPPORT?= yes LOADER_BZIP2_SUPPORT?= no +LOADER_DEBUG?= no +.if ${LOADER_DEBUG} == "yes" +CFLAGS+= -DLOADER_DEBUG +.endif .if ${LOADER_DISK_SUPPORT} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .endif @@ -28,6 +33,11 @@ CFLAGS+= -DLOADER_UFS_SUPPORT .if ${LOADER_CD9660_SUPPORT} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif +.if ${LOADER_ZFS_SUPPORT} == "yes" +CFLAGS+= -DLOADER_ZFS_SUPPORT +CFLAGS+= -I${.CURDIR}/../../zfs +CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs +.endif .if ${LOADER_GZIP_SUPPORT} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif @@ -47,7 +57,8 @@ CFLAGS+= -DLOADER_TFTP_SUPPORT .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/sparc64 +CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl +CFLAGS+= -I${.CURDIR}/../../ficl/sparc64 LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif @@ -75,8 +86,9 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBOFW} -lstand -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \ + ${NEWVERSWHAT} loader.help: help.common help.sparc64 cat ${.ALLSRC} | \ Modified: head/sys/boot/sparc64/loader/main.c ============================================================================== --- head/sys/boot/sparc64/loader/main.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/loader/main.c Tue May 1 17:16:01 2012 (r234898) @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef LOADER_ZFS_SUPPORT +#include +#endif #include #include @@ -143,6 +146,11 @@ static vm_offset_t heapva; static phandle_t root; +#ifdef LOADER_ZFS_SUPPORT +static int zfs_dev_init(void); +#include "zfs.c" +#endif + /* * Machine dependent structures that the machine independent * loader part uses. @@ -154,6 +162,9 @@ struct devsw *devsw[] = { #ifdef LOADER_NET_SUPPORT &netdev, #endif +#ifdef LOADER_ZFS_SUPPORT + &zfs_dev, +#endif 0 }; struct arch_switch archsw; @@ -166,6 +177,7 @@ struct file_format *file_formats[] = { &sparc64_elf, 0 }; + struct fs_ops *file_system[] = { #ifdef LOADER_UFS_SUPPORT &ufs_fsops, @@ -173,6 +185,9 @@ struct fs_ops *file_system[] = { #ifdef LOADER_CD9660_SUPPORT &cd9660_fsops, #endif +#ifdef LOADER_ZFS_SUPPORT + &zfs_fsops, +#endif #ifdef LOADER_ZIP_SUPPORT &zipfs_fsops, #endif @@ -721,6 +736,82 @@ tlb_init_sun4u(void) panic("%s: can't allocate TLB store", __func__); } +#ifdef LOADER_ZFS_SUPPORT + +static int +zfs_dev_init(void) +{ + struct vtoc8 vtoc; + char devname[512]; + spa_t *spa; + vdev_t *vdev; + uint64_t guid; + int fd, part, unit; + + zfs_init(); + + guid = 0; + /* Get the GUID of the ZFS pool on the boot device. */ + fd = open(getenv("currdev"), O_RDONLY); + if (fd != -1) { + if (vdev_probe(vdev_read, (void *)(uintptr_t) fd, &spa) == 0) + guid = spa->spa_guid; + close(fd); + } + + /* Clean up the environment to let ZFS work. */ + while ((vdev = STAILQ_FIRST(&zfs_vdevs)) != NULL) { + STAILQ_REMOVE_HEAD(&zfs_vdevs, v_alllink); + free(vdev); + } + while ((spa = STAILQ_FIRST(&zfs_pools)) != NULL) { + STAILQ_REMOVE_HEAD(&zfs_pools, spa_link); + free(spa); + } + + for (unit = 0; unit < MAXBDDEV; unit++) { + /* Find freebsd-zfs slices in the VTOC. */ + sprintf(devname, "disk%d:", unit); + fd = open(devname, O_RDONLY); + if (fd == -1) + continue; + lseek(fd, 0, SEEK_SET); + if (read(fd, &vtoc, sizeof(vtoc)) != sizeof(vtoc)) { + close(fd); + continue; + } + close(fd); + + for (part = 0; part < 8; part++) { + if (part == 2 || vtoc.part[part].tag != + VTOC_TAG_FREEBSD_ZFS) + continue; + sprintf(devname, "disk%d:%c", unit, part + 'a'); + fd = open(devname, O_RDONLY); + if (fd == -1) + break; + + if (vdev_probe(vdev_read, (void*)(uintptr_t) fd, 0)) + close(fd); + } + } + + if (guid != 0) { + unit = zfs_guid_to_unit(guid); + if (unit >= 0) { + /* Update the environment for ZFS. */ + sprintf(devname, "zfs%d", unit); + env_setenv("currdev", EV_VOLATILE, devname, + ofw_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, devname, + env_noset, env_nounset); + } + } + return (0); +} + +#endif /* LOADER_ZFS_SUPPORT */ + int main(int (*openfirm)(void *)) { @@ -756,14 +847,6 @@ main(int (*openfirm)(void *)) mmu_ops->tlb_init(); /* - * Initialize devices. - */ - for (dp = devsw; *dp != 0; dp++) { - if ((*dp)->dv_init != 0) - (*dp)->dv_init(); - } - - /* * Set up the current device. */ OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath)); @@ -780,7 +863,8 @@ main(int (*openfirm)(void *)) * needs to be altered. */ if (bootpath[strlen(bootpath) - 2] == ':' && - bootpath[strlen(bootpath) - 1] == 'f') { + bootpath[strlen(bootpath) - 1] == 'f' && + strstr(bootpath, "cdrom")) { bootpath[strlen(bootpath) - 1] = 'a'; printf("Boot path set to %s\n", bootpath); } @@ -790,6 +874,13 @@ main(int (*openfirm)(void *)) env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset, env_nounset); + /* + * Initialize devices. + */ + for (dp = devsw; *dp != 0; dp++) + if ((*dp)->dv_init != 0) + (*dp)->dv_init(); + printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); Added: head/sys/boot/sparc64/zfsboot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/sparc64/zfsboot/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../boot1 + +PROGNAME= zfsboot +CFLAGS+= -DZFSBOOT +FILES= zfsboot +CLEANFILES+= zfsboot + +zfsboot: boot1 + ln -s ${.ALLSRC} ${.TARGET} + +.include "${.CURDIR}/../boot1/Makefile" Added: head/sys/boot/sparc64/zfsloader/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/sparc64/zfsloader/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../loader + +PROG= zfsloader +NEWVERSWHAT= "ZFS enabled bootstrap loader" sparc64 +LOADER_ZFS_SUPPORT=yes + +.include "${.CURDIR}/../loader/Makefile" Modified: head/sys/boot/zfs/zfs.c ============================================================================== --- head/sys/boot/zfs/zfs.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/zfs/zfs.c Tue May 1 17:16:01 2012 (r234898) @@ -399,6 +399,7 @@ zfs_guid_to_unit(uint64_t guid) return (-1); } +#if defined(__amd64__) || defined(__i386__) static int zfs_dev_init(void) { @@ -441,6 +442,7 @@ zfs_dev_init(void) return (0); } +#endif /* * Print information about ZFS pools From owner-svn-src-all@FreeBSD.ORG Tue May 1 18:00:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13ECC106567B; Tue, 1 May 2012 18:00:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA0268FC0A; Tue, 1 May 2012 18:00: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 q41I0VAc038187; Tue, 1 May 2012 18:00:31 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41I0VKA038185; Tue, 1 May 2012 18:00:31 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205011800.q41I0VKA038185@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 18:00: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: r234899 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 18:00:32 -0000 Author: mav Date: Tue May 1 18:00:31 2012 New Revision: 234899 URL: http://svn.freebsd.org/changeset/base/234899 Log: Improve spare disks support. Unluckily, for some reason Adaptec 1430SA RAID BIOS doesn't want to understand spare disks created by graid. But at least spares created by BIOS are working fine now. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 17:16:01 2012 (r234898) +++ head/sys/geom/raid/md_ddf.c Tue May 1 18:00:31 2012 (r234899) @@ -179,6 +179,10 @@ static struct g_raid_md_class g_raid_md_ (n) * GET16((m), hdr->Configuration_Record_Length) * \ (m)->sectorsize)) +#define GETSAPTR(m, n) ((struct ddf_sa_record *)((uint8_t *)(m)->cr + \ + (n) * GET16((m), hdr->Configuration_Record_Length) * \ + (m)->sectorsize)) + static int isff(uint8_t *buf, int size) { @@ -294,8 +298,8 @@ g_raid_md_ddf_print(struct ddf_meta *met printf("\n"); printf("VD_Number 0x%04x\n", GET16(meta, vdr->entry[j].VD_Number)); - printf("VD_Type 0x%02x\n", - GET8(meta, vdr->entry[j].VD_Type)); + printf("VD_Type 0x%04x\n", + GET16(meta, vdr->entry[j].VD_Type)); printf("VD_State 0x%02x\n", GET8(meta, vdr->entry[j].VD_State)); printf("Init_State 0x%02x\n", @@ -396,6 +400,7 @@ g_raid_md_ddf_print(struct ddf_meta *met GET16D(meta, sa->entry[i].Secondary_Element)); } break; + case 0x00000000: case 0xFFFFFFFF: break; default: @@ -476,7 +481,8 @@ ddf_meta_find_vdc(struct ddf_meta *meta, memcmp(vdc->VD_GUID, GUID, 24) == 0) return (vdc); } else - if (GET32D(meta, vdc->Signature) == 0xffffffff) + if (GET32D(meta, vdc->Signature) == 0xffffffff || + GET32D(meta, vdc->Signature) == 0) return (vdc); } return (NULL); @@ -527,6 +533,29 @@ ddf_meta_find_disk(struct ddf_vol_meta * return (-1); } +static struct ddf_sa_record * +ddf_meta_find_sa(struct ddf_meta *meta, int create) +{ + struct ddf_sa_record *sa; + int i, num; + + num = GETCRNUM(meta); + for (i = 0; i < num; i++) { + sa = GETSAPTR(meta, i); + if (GET32D(meta, sa->Signature) == DDF_SA_SIGNATURE) + return (sa); + } + if (create) { + for (i = 0; i < num; i++) { + sa = GETSAPTR(meta, i); + if (GET32D(meta, sa->Signature) == 0xffffffff || + GET32D(meta, sa->Signature) == 0) + return (sa); + } + } + return (NULL); +} + static void ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) { @@ -643,9 +672,9 @@ ddf_meta_create(struct g_raid_disk *disk pos += GET32(meta, hdr->Diagnostic_Space_Length); SET32(meta, hdr->Vendor_Specific_Logs, GET32(meta, hdr->Vendor_Specific_Logs_Length) != 0 ? pos : 0xffffffff); - pos += GET32(meta, hdr->Vendor_Specific_Logs_Length); + pos += min(GET32(meta, hdr->Vendor_Specific_Logs_Length), 1); SET64(meta, hdr->Primary_Header_LBA, - anchorlba - pos - 16); + anchorlba - pos); SET64(meta, hdr->Secondary_Header_LBA, 0xffffffffffffffffULL); SET64(meta, hdr->WorkSpace_LBA, @@ -1318,29 +1347,6 @@ ddf_meta_erase(struct g_consumer *cp) return (error); } -#if 0 -static int -ddf_meta_write_spare(struct g_consumer *cp) -{ - struct ddf_header *meta; - int error; - - meta = malloc(sizeof(*meta), M_MD_DDF, M_WAITOK | M_ZERO); - memcpy(&meta->ddf_id[0], DDF_MAGIC, sizeof(DDF_MAGIC) - 1); - meta->dummy_0 = 0x00020000; - meta->integrity = DDF_I_VALID; - meta->disk.flags = DDF_F_SPARE | DDF_F_ONLINE | DDF_F_VALID; - meta->disk.number = 0xff; - arc4rand(&meta->disk.id, sizeof(meta->disk.id), 0); - meta->disk_sectors = cp->provider->mediasize / cp->provider->sectorsize; - meta->disk_sectors -= 131072; - meta->rebuild_lba = UINT32_MAX; - error = ddf_meta_write(cp, &meta, 1); - free(meta, M_MD_DDF); - return (error); -} -#endif - static struct g_raid_volume * g_raid_md_ddf_get_volume(struct g_raid_softc *sc, uint8_t *GUID) { @@ -1574,6 +1580,7 @@ g_raid_md_ddf_start_disk(struct g_raid_d struct ddf_vol_meta *vmeta; struct ddf_meta *pdmeta, *gmeta; struct ddf_vdc_record *vdc1; + struct ddf_sa_record *sa; off_t size, eoff = 0, esize = 0; uint64_t *val2; int disk_pos, md_disk_bvd = -1, md_disk_pos = -1, md_pde_pos; @@ -1596,7 +1603,8 @@ g_raid_md_ddf_start_disk(struct g_raid_d md_pde_pos = ddf_meta_find_pd(gmeta, NULL, reference); if (disk_pos < 0) { - G_RAID_DEBUG1(1, sc, "Disk %s is not part of the volume %s", + G_RAID_DEBUG1(1, sc, + "Disk %s is not a present part of the volume %s", g_raid_get_diskname(disk), vol->v_name); /* Failed stale disk is useless for us. */ @@ -1606,10 +1614,8 @@ g_raid_md_ddf_start_disk(struct g_raid_d } /* If disk has some metadata for this volume - erase. */ - if (pdmeta->cr != NULL && - (vdc1 = ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID)) != NULL) { + if ((vdc1 = ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID)) != NULL) SET32D(pdmeta, vdc1->Signature, 0xffffffff); - } /* If we are in the start process, that's all for now. */ if (!pv->pv_started) @@ -1656,12 +1662,28 @@ g_raid_md_ddf_start_disk(struct g_raid_d md_disk_pos = disk_pos % GET16(vmeta, vdc->Primary_Element_Count); // XXX } else { nofit: - if (ddf_meta_count_vdc(&pd->pd_meta, NULL) == 0) { + if (disk->d_state == G_RAID_DISK_S_NONE) g_raid_change_disk_state(disk, - G_RAID_DISK_S_SPARE); - } + G_RAID_DISK_S_STALE); return (0); } + + /* + * If spare is committable, delete spare record. + * Othersize, mark it active and leave there. + */ + sa = ddf_meta_find_sa(&pd->pd_meta, 0); + if (sa != NULL) { + if ((GET8D(&pd->pd_meta, sa->Spare_Type) & + DDF_SAR_TYPE_REVERTIBLE) == 0) { + SET32D(&pd->pd_meta, sa->Signature, 0xffffffff); + } else { + SET8D(&pd->pd_meta, sa->Spare_Type, + GET8D(&pd->pd_meta, sa->Spare_Type) | + DDF_SAR_TYPE_ACTIVE); + } + } + G_RAID_DEBUG1(1, sc, "Disk %s takes pos %d in the volume %s", g_raid_get_diskname(disk), disk_pos, vol->v_name); resurrection = 1; @@ -1798,6 +1820,7 @@ g_raid_md_ddf_start(struct g_raid_volume struct g_raid_subdisk *sd; struct g_raid_disk *disk; struct g_raid_md_object *md; + struct g_raid_md_ddf_perdisk *pd; struct g_raid_md_ddf_pervolume *pv; struct g_raid_md_ddf_object *mdi; struct ddf_vol_meta *vmeta; @@ -1846,16 +1869,9 @@ g_raid_md_ddf_start(struct g_raid_volume g_raid_start_volume(vol); /* Make all disks found till the moment take their places. */ - for (i = 0, j = 0, bvd = 0; i < vol->v_disks_count; i++, j++) { - if (j == GET16(vmeta, vdc->Primary_Element_Count)) { - j = 0; - bvd++; - } - if (vmeta->bvdc[bvd] == NULL) - continue; - disk = g_raid_md_ddf_get_disk(sc, NULL, - GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[j])); - if (disk != NULL) + TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + if (ddf_meta_find_vdc(&pd->pd_meta, vmeta->vdc->VD_GUID) != NULL) g_raid_md_ddf_start_disk(disk, vol); } @@ -1901,7 +1917,7 @@ g_raid_md_ddf_new_disk(struct g_raid_dis struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; struct ddf_vd_entry *vde; - int i, j, k, num, have, need, needthis, cnt, spare; + int i, j, k, num, have, need, cnt, spare; uint32_t val; char buf[17]; @@ -1963,9 +1979,17 @@ g_raid_md_ddf_new_disk(struct g_raid_dis pv = vol->v_md_data; vmeta = &pv->pv_meta; + if (ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID) == NULL) + continue; + + if (pv->pv_started) { + if (g_raid_md_ddf_start_disk(disk, vol)) + g_raid_md_write_ddf(md, vol, NULL, NULL); + continue; + } + /* If we collected all needed disks - start array. */ need = 0; - needthis = 0; have = 0; for (k = 0; k < GET8(vmeta, vdc->Secondary_Element_Count); k++) { if (vmeta->bvdc[k] == NULL) { @@ -1976,23 +2000,14 @@ g_raid_md_ddf_new_disk(struct g_raid_dis need += cnt; for (i = 0; i < cnt; i++) { val = GET32(vmeta, bvdc[k]->Physical_Disk_Sequence[i]); - if (GET32(pdmeta, pdd->PD_Reference) == val) - needthis++; - else if (g_raid_md_ddf_get_disk(sc, NULL, val) != NULL) + if (g_raid_md_ddf_get_disk(sc, NULL, val) != NULL) have++; } } - if (!needthis) - continue; - if (pv->pv_started) { - if (g_raid_md_ddf_start_disk(disk, vol)) - g_raid_md_write_ddf(md, vol, NULL, NULL); - } else { - G_RAID_DEBUG1(1, sc, "Volume %s now has %d of %d disks", - vol->v_name, have + needthis, need); - if (have + needthis == need) - g_raid_md_ddf_start(vol); - } + G_RAID_DEBUG1(1, sc, "Volume %s now has %d of %d disks", + vol->v_name, have, need); + if (have == need) + g_raid_md_ddf_start(vol); } } @@ -2173,6 +2188,7 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec struct g_raid_md_ddf_perdisk *pd; struct g_raid_md_ddf_pervolume *pv; struct g_raid_md_ddf_object *mdi; + struct ddf_sa_record *sa; struct g_consumer *cp; struct g_provider *pp; char arg[16]; @@ -2610,11 +2626,23 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec /* Welcome the "new" disk. */ g_raid_change_disk_state(disk, G_RAID_DISK_S_SPARE); ddf_meta_create(disk, &mdi->mdio_meta); + sa = ddf_meta_find_sa(&pd->pd_meta, 1); + if (sa != NULL) { + SET32D(&pd->pd_meta, sa->Signature, + DDF_SA_SIGNATURE); + SET8D(&pd->pd_meta, sa->Spare_Type, 0); + SET16D(&pd->pd_meta, sa->Populated_SAEs, 0); + SET16D(&pd->pd_meta, sa->MAX_SAE_Supported, + (GET16(&pd->pd_meta, hdr->Configuration_Record_Length) * + pd->pd_meta.sectorsize - + sizeof(struct ddf_sa_record)) / + sizeof(struct ddf_sa_entry)); + } if (mdi->mdio_meta.hdr == NULL) ddf_meta_copy(&mdi->mdio_meta, &pd->pd_meta); else ddf_meta_update(&mdi->mdio_meta, &pd->pd_meta); -// ddf_meta_write_spare(cp); + g_raid_md_write_ddf(md, NULL, NULL, NULL); g_raid_md_ddf_refill(sc); } return (error); @@ -2636,6 +2664,7 @@ g_raid_md_write_ddf(struct g_raid_md_obj struct ddf_meta *gmeta; struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; + struct ddf_sa_record *sa; uint64_t *val2; int i, j, pos, bvd, size; @@ -2657,7 +2686,8 @@ g_raid_md_write_ddf(struct g_raid_md_obj continue; SET16(gmeta, pdr->entry[i].PD_Type, GET16(gmeta, pdr->entry[i].PD_Type) & - ~DDF_PDE_PARTICIPATING); + ~(DDF_PDE_PARTICIPATING | + DDF_PDE_GLOBAL_SPARE | DDF_PDE_CONFIG_SPARE)); if ((GET16(gmeta, pdr->entry[i].PD_State) & DDF_PDE_PFA) == 0) SET16(gmeta, pdr->entry[i].PD_State, 0); @@ -2759,15 +2789,15 @@ g_raid_md_write_ddf(struct g_raid_md_obj if (sd->sd_state == G_RAID_SUBDISK_S_NONE) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_MISSING); + (DDF_PDE_FAILED | DDF_PDE_MISSING)); else if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_PFA); + (DDF_PDE_FAILED | DDF_PDE_PFA)); else if (sd->sd_state <= G_RAID_SUBDISK_S_REBUILD) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED); + DDF_PDE_REBUILD); else SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | @@ -2775,11 +2805,46 @@ g_raid_md_write_ddf(struct g_raid_md_obj } } + /* Mark spare and failed disks as such. */ + TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + i = ddf_meta_find_pd(gmeta, NULL, + GET32(&pd->pd_meta, pdd->PD_Reference)); + if (i < 0) + continue; + if (disk->d_state == G_RAID_DISK_S_FAILED) { + SET32(gmeta, pdr->entry[i].PD_State, + GET32(gmeta, pdr->entry[i].PD_State) | + (DDF_PDE_FAILED | DDF_PDE_PFA)); + } + if (disk->d_state != G_RAID_DISK_S_SPARE) + continue; + sa = ddf_meta_find_sa(&pd->pd_meta, 0); + if (sa == NULL || + (GET8D(&pd->pd_meta, sa->Spare_Type) & + DDF_SAR_TYPE_DEDICATED) == 0) { + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) | + DDF_PDE_GLOBAL_SPARE); + } else { + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) | + DDF_PDE_CONFIG_SPARE); + } + SET32(gmeta, pdr->entry[i].PD_State, + GET32(gmeta, pdr->entry[i].PD_State) | + DDF_PDE_ONLINE); + } + /* Remove disks without "participating" flag (unused). */ for (i = 0, j = -1; i < GET16(gmeta, pdr->Populated_PDEs); i++) { if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) continue; - if (GET16(gmeta, pdr->entry[i].PD_Type) & DDF_PDE_PARTICIPATING) + if ((GET16(gmeta, pdr->entry[i].PD_Type) & + (DDF_PDE_PARTICIPATING | + DDF_PDE_GLOBAL_SPARE | DDF_PDE_CONFIG_SPARE)) != 0 || + g_raid_md_ddf_get_disk(sc, + NULL, GET32(gmeta, pdr->entry[i].PD_Reference)) != NULL) j = i; else memset(&gmeta->pdr->entry[i], 0xff, @@ -2790,7 +2855,8 @@ g_raid_md_write_ddf(struct g_raid_md_obj /* Update per-disk metadata and write them. */ TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; - if (disk->d_state != G_RAID_DISK_S_ACTIVE) + if (disk->d_state != G_RAID_DISK_S_ACTIVE && + disk->d_state != G_RAID_DISK_S_SPARE) continue; /* Update PDR. */ memcpy(pd->pd_meta.pdr, gmeta->pdr, From owner-svn-src-all@FreeBSD.ORG Tue May 1 20:32:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 03806106564A; Tue, 1 May 2012 20:32:39 +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 E2C298FC0A; Tue, 1 May 2012 20:32:38 +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 q41KWcVl043421; Tue, 1 May 2012 20:32:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41KWcax043419; Tue, 1 May 2012 20:32:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205012032.q41KWcax043419@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 20:32:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234900 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 20:32:39 -0000 Author: adrian Date: Tue May 1 20:32:38 2012 New Revision: 234900 URL: http://svn.freebsd.org/changeset/base/234900 Log: Add in the MII configuration parameters for the AR71xx. Obtained from: Linux/OpenWRT Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Tue May 1 18:00:31 2012 (r234899) +++ head/sys/mips/atheros/ar71xxreg.h Tue May 1 20:32:38 2012 (r234900) @@ -271,12 +271,23 @@ * AR71xx MII control region */ #define AR71XX_MII0_CTRL 0x18070000 -#define AR71XX_MII1_CTRL 0x18070004 #define MII_CTRL_SPEED_SHIFT 4 #define MII_CTRL_SPEED_MASK 3 -#define MII_CTRL_SPEED_10 0 -#define MII_CTRL_SPEED_100 1 -#define MII_CTRL_SPEED_1000 2 +#define MII_CTRL_SPEED_10 0 +#define MII_CTRL_SPEED_100 1 +#define MII_CTRL_SPEED_1000 2 +#define MII_CTRL_IF_MASK 3 +#define MII_CTRL_IF_SHIFT 0 +#define MII0_CTRL_IF_GMII 0 +#define MII0_CTRL_IF_MII 1 +#define MII0_CTRL_IF_RGMII 2 +#define MII0_CTRL_IF_RMII 3 + +#define AR71XX_MII1_CTRL 0x18070004 + +#define MII1_CTRL_IF_RGMII 0 +#define MII1_CTRL_IF_RMII 1 + /* * GigE adapters region From owner-svn-src-all@FreeBSD.ORG Tue May 1 20:42:04 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4C6A91065670; Tue, 1 May 2012 20:42:04 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34D348FC16; Tue, 1 May 2012 20:42: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 q41Kg4DU043807; Tue, 1 May 2012 20:42:04 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Kg4Jj043805; Tue, 1 May 2012 20:42:04 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205012042.q41Kg4Jj043805@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 20:42: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: r234901 - head/sys/arm/at91 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 20:42:04 -0000 Author: marius Date: Tue May 1 20:42:03 2012 New Revision: 234901 URL: http://svn.freebsd.org/changeset/base/234901 Log: - Add missing locking in at91_usart_getc(). - Align the RX buffers on the cache line size, otherwise the requirement of partial cache line flushes on every are pretty much guaranteed. [1] - Make the code setting the RX timeout match its comment (apparently, start and stop bits were missed in the previous calculation). [1] - Cover the busdma operations in at91_usart_bus_{ipend,transmit}() with the hardware mutex, too, so these don't race against each other. - In at91_usart_bus_ipend(), reduce duplication in the code dealing with TX interrupts. - In at91_usart_bus_ipend(), turn the code dealing with RX interrupts into an else-if cascade in order reduce its complexity and to improve its run-time behavior. - In at91_usart_bus_ipend(), add missing BUS_DMASYNC_PREREAD calls on the RX buffer map before handing things over to the hardware again. [1] - In at91_usart_bus_getsig(), used a variable of sufficient width for storing the contents of USART_CSR. - Use KOBJMETHOD_END. - Remove an unused header. Submitted by: Ian Lepore [1] Reviewed by: Ian Lepore MFC after: 1 week Modified: head/sys/arm/at91/uart_dev_at91usart.c Modified: head/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- head/sys/arm/at91/uart_dev_at91usart.c Tue May 1 20:32:38 2012 (r234900) +++ head/sys/arm/at91/uart_dev_at91usart.c Tue May 1 20:42:03 2012 (r234901) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -55,16 +54,17 @@ __FBSDID("$FreeBSD$"); */ struct at91_usart_rx { bus_addr_t pa; - uint8_t buffer[USART_BUFFER_SIZE]; + uint8_t *buffer; bus_dmamap_t map; }; struct at91_usart_softc { struct uart_softc base; - bus_dma_tag_t dmatag; /* bus dma tag for mbufs */ + bus_dma_tag_t tx_tag; bus_dmamap_t tx_map; uint32_t flags; -#define HAS_TIMEOUT 1 +#define HAS_TIMEOUT 1 + bus_dma_tag_t rx_tag; struct at91_usart_rx ping_pong[2]; struct at91_usart_rx *ping; struct at91_usart_rx *pong; @@ -95,7 +95,7 @@ static void at91_usart_init(struct uart_ static void at91_usart_term(struct uart_bas *bas); static void at91_usart_putc(struct uart_bas *bas, int); static int at91_usart_rxready(struct uart_bas *bas); -static int at91_usart_getc(struct uart_bas *bas, struct mtx *mtx); +static int at91_usart_getc(struct uart_bas *bas, struct mtx *hwmtx); extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; @@ -106,7 +106,7 @@ at91_usart_param(struct uart_bas *bas, i uint32_t mr; /* - * Assume 3-write RS-232 configuration. + * Assume 3-wire RS-232 configuration. * XXX Not sure how uart will present the other modes to us, so * XXX they are unimplemented. maybe ioctl? */ @@ -209,6 +209,7 @@ static struct uart_ops at91_usart_ops = static int at91_usart_probe(struct uart_bas *bas) { + /* We know that this is always here */ return (0); } @@ -236,6 +237,7 @@ at91_usart_init(struct uart_bas *bas, in static void at91_usart_term(struct uart_bas *bas) { + /* XXX */ } @@ -247,7 +249,7 @@ static void at91_usart_putc(struct uart_bas *bas, int c) { - while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) + while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) continue; WR4(bas, USART_THR, c); } @@ -266,14 +268,18 @@ at91_usart_rxready(struct uart_bas *bas) * Block waiting for a character. */ static int -at91_usart_getc(struct uart_bas *bas, struct mtx *mtx) +at91_usart_getc(struct uart_bas *bas, struct mtx *hwmtx) { int c; - while (!(RD4(bas, USART_CSR) & USART_CSR_RXRDY)) - continue; - c = RD4(bas, USART_RHR); - c &= 0xff; + uart_lock(hwmtx); + while (!(RD4(bas, USART_CSR) & USART_CSR_RXRDY)) { + uart_unlock(hwmtx); + DELAY(4); + uart_lock(hwmtx); + } + c = RD4(bas, USART_RHR) & 0xff; + uart_unlock(hwmtx); return (c); } @@ -290,7 +296,7 @@ static int at91_usart_bus_transmit(struc static kobj_method_t at91_usart_methods[] = { KOBJMETHOD(uart_probe, at91_usart_bus_probe), - KOBJMETHOD(uart_attach, at91_usart_bus_attach), + KOBJMETHOD(uart_attach, at91_usart_bus_attach), KOBJMETHOD(uart_flush, at91_usart_bus_flush), KOBJMETHOD(uart_getsig, at91_usart_bus_getsig), KOBJMETHOD(uart_ioctl, at91_usart_bus_ioctl), @@ -299,8 +305,8 @@ static kobj_method_t at91_usart_methods[ KOBJMETHOD(uart_receive, at91_usart_bus_receive), KOBJMETHOD(uart_setsig, at91_usart_bus_setsig), KOBJMETHOD(uart_transmit, at91_usart_bus_transmit), - - { 0, 0 } + + KOBJMETHOD_END }; int @@ -316,6 +322,7 @@ at91_usart_bus_probe(struct uart_softc * static void at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { + if (error != 0) return; *(bus_addr_t *)arg = segs[0].ds_addr; @@ -344,41 +351,53 @@ at91_usart_bus_attach(struct uart_softc WR4(&sc->sc_bas, USART_IDR, 0xffffffff); /* - * Allocate DMA tags and maps + * Allocate transmit DMA tag and map. We allow a transmit buffer + * to be any size, but it must map to a single contiguous physical + * extent. */ err = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - USART_BUFFER_SIZE, 1, USART_BUFFER_SIZE, BUS_DMA_ALLOCNOW, NULL, - NULL, &atsc->dmatag); + BUS_SPACE_MAXSIZE_32BIT, 1, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, + NULL, &atsc->tx_tag); if (err != 0) goto errout; - err = bus_dmamap_create(atsc->dmatag, 0, &atsc->tx_map); + err = bus_dmamap_create(atsc->tx_tag, 0, &atsc->tx_map); if (err != 0) goto errout; + if (atsc->flags & HAS_TIMEOUT) { + /* + * Allocate receive DMA tags, maps, and buffers. + * The receive buffers should be aligned to arm_dcache_align, + * otherwise partial cache line flushes on every receive + * interrupt are pretty much guaranteed. + */ + err = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), + arm_dcache_align, 0, BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, NULL, NULL, sc->sc_rxfifosz, 1, + sc->sc_rxfifosz, BUS_DMA_ALLOCNOW, NULL, NULL, + &atsc->rx_tag); + if (err != 0) + goto errout; for (i = 0; i < 2; i++) { - err = bus_dmamap_create(atsc->dmatag, 0, - &atsc->ping_pong[i].map); + err = bus_dmamem_alloc(atsc->rx_tag, + (void **)&atsc->ping_pong[i].buffer, + BUS_DMA_NOWAIT, &atsc->ping_pong[i].map); if (err != 0) goto errout; - err = bus_dmamap_load(atsc->dmatag, + err = bus_dmamap_load(atsc->rx_tag, atsc->ping_pong[i].map, atsc->ping_pong[i].buffer, sc->sc_rxfifosz, at91_getaddr, &atsc->ping_pong[i].pa, 0); if (err != 0) goto errout; - bus_dmamap_sync(atsc->dmatag, atsc->ping_pong[i].map, + bus_dmamap_sync(atsc->rx_tag, atsc->ping_pong[i].map, BUS_DMASYNC_PREREAD); } atsc->ping = &atsc->ping_pong[0]; atsc->pong = &atsc->ping_pong[1]; } - /* - * Prime the pump with the RX buffer. We use two 64 byte bounce - * buffers here to avoid data overflow. - */ - /* Turn on rx and tx */ cr = USART_CR_RSTSTA | USART_CR_RSTRX | USART_CR_RSTTX; WR4(&sc->sc_bas, USART_CR, cr); @@ -397,8 +416,11 @@ at91_usart_bus_attach(struct uart_softc WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - /* Set the receive timeout to be 1.5 character times. */ - WR4(&sc->sc_bas, USART_RTOR, 12); + /* + * Set the receive timeout to be 1.5 character times + * assuming 8N1. + */ + WR4(&sc->sc_bas, USART_RTOR, 15); WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); WR4(&sc->sc_bas, USART_IER, USART_CSR_TIMEOUT | USART_CSR_RXBUFF | USART_CSR_ENDRX); @@ -407,7 +429,6 @@ at91_usart_bus_attach(struct uart_softc } WR4(&sc->sc_bas, USART_IER, USART_CSR_RXBRK); errout: - // XXX bad return (err); } @@ -416,14 +437,17 @@ at91_usart_bus_transmit(struct uart_soft { bus_addr_t addr; struct at91_usart_softc *atsc; + int err; + err = 0; atsc = (struct at91_usart_softc *)sc; - if (bus_dmamap_load(atsc->dmatag, atsc->tx_map, sc->sc_txbuf, - sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0) - return (EAGAIN); - bus_dmamap_sync(atsc->dmatag, atsc->tx_map, BUS_DMASYNC_PREWRITE); - uart_lock(sc->sc_hwmtx); + if (bus_dmamap_load(atsc->tx_tag, atsc->tx_map, sc->sc_txbuf, + sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0) { + err = EAGAIN; + goto errout; + } + bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_PREWRITE); sc->sc_txbusy = 1; /* * Setup the PDC to transfer the data and interrupt us when it @@ -433,9 +457,11 @@ at91_usart_bus_transmit(struct uart_soft WR4(&sc->sc_bas, PDC_TCR, sc->sc_txdatasz); WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_TXTEN); WR4(&sc->sc_bas, USART_IER, USART_CSR_ENDTX); +errout: uart_unlock(sc->sc_hwmtx); - return (0); + return (err); } + static int at91_usart_bus_setsig(struct uart_softc *sc, int sig) { @@ -465,12 +491,14 @@ at91_usart_bus_setsig(struct uart_softc uart_unlock(sc->sc_hwmtx); return (0); } + static int at91_usart_bus_receive(struct uart_softc *sc) { return (0); } + static int at91_usart_bus_param(struct uart_softc *sc, int baudrate, int databits, int stopbits, int parity) @@ -488,33 +516,31 @@ at91_rx_put(struct uart_softc *sc, int k if (sc->sc_sysdev != NULL && sc->sc_sysdev->type == UART_DEV_CONSOLE) kdb_alt_break(key, &sc->sc_altbrk); #endif - uart_rx_put(sc, key); + uart_rx_put(sc, key); } static int at91_usart_bus_ipend(struct uart_softc *sc) { - int csr = RD4(&sc->sc_bas, USART_CSR); - int ipend = 0, i, len; struct at91_usart_softc *atsc; struct at91_usart_rx *p; + int i, ipend, len; + uint32_t csr; - atsc = (struct at91_usart_softc *)sc; + ipend = 0; + atsc = (struct at91_usart_softc *)sc; + uart_lock(sc->sc_hwmtx); + csr = RD4(&sc->sc_bas, USART_CSR); if (csr & USART_CSR_ENDTX) { - bus_dmamap_sync(atsc->dmatag, atsc->tx_map, + bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(atsc->dmatag, atsc->tx_map); + bus_dmamap_unload(atsc->tx_tag, atsc->tx_map); } - uart_lock(sc->sc_hwmtx); - if (csr & USART_CSR_TXRDY) { - if (sc->sc_txbusy) - ipend |= SER_INT_TXIDLE; - WR4(&sc->sc_bas, USART_IDR, USART_CSR_TXRDY); - } - if (csr & USART_CSR_ENDTX) { + if (csr & (USART_CSR_TXRDY | USART_CSR_ENDTX)) { if (sc->sc_txbusy) ipend |= SER_INT_TXIDLE; - WR4(&sc->sc_bas, USART_IDR, USART_CSR_ENDTX); + WR4(&sc->sc_bas, USART_IDR, csr & (USART_CSR_TXRDY | + USART_CSR_ENDTX)); } /* @@ -523,90 +549,103 @@ at91_usart_bus_ipend(struct uart_softc * * and do all the work elsewhere. I need to look at the CSR * bits right now and do things based on them to avoid races. */ - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_RXBUFF)) { - // Have a buffer overflow. Copy all data from both - // ping and pong. Insert overflow character. Reset - // ping and pong and re-enable the PDC to receive - // characters again. - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - bus_dmamap_sync(atsc->dmatag, atsc->pong->map, - BUS_DMASYNC_POSTREAD); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->pong->buffer[i]); - uart_rx_put(sc, UART_STAT_OVERRUN); - csr &= ~(USART_CSR_ENDRX | USART_CSR_TIMEOUT); - WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); - WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); - WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - ipend |= SER_INT_RXREADY; - } - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_ENDRX)) { - // Shuffle data from 'ping' of ping pong buffer, but - // leave current 'pong' in place, as it has become the - // new 'ping'. We need to copy data and setup the old - // 'ping' as the new 'pong' when we're done. - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - p = atsc->ping; - atsc->ping = atsc->pong; - atsc->pong = p; - WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); - WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); - ipend |= SER_INT_RXREADY; - } - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_TIMEOUT)) { - // We have one partial buffer. We need to stop the - // PDC, get the number of characters left and from - // that compute number of valid characters. We then - // need to reset ping and pong and reenable the PDC. - // Not sure if there's a race here at fast baud rates - // we need to worry about. - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTDIS); - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - len = sc->sc_rxfifosz - RD4(&sc->sc_bas, PDC_RCR); - for (i = 0; i < len; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); - WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - ipend |= SER_INT_RXREADY; - } - if (!(atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_RXRDY)) { - // We have another charater in a device that doesn't support - // timeouts, so we do it one character at a time. + if (atsc->flags & HAS_TIMEOUT) { + if (csr & USART_CSR_RXBUFF) { + /* + * We have a buffer overflow. Copy all data from both + * ping and pong. Insert overflow character. Reset + * ping and pong and re-enable the PDC to receive + * characters again. + */ + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_POSTREAD); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->pong->buffer[i]); + uart_rx_put(sc, UART_STAT_OVERRUN); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_PREREAD); + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); + WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); + WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); + ipend |= SER_INT_RXREADY; + } else if (csr & USART_CSR_ENDRX) { + /* + * Shuffle data from ping of ping pong buffer, but + * leave current pong in place, as it has become the + * new ping. We need to copy data and setup the old + * ping as the new pong when we're done. + */ + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + p = atsc->ping; + atsc->ping = atsc->pong; + atsc->pong = p; + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); + WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); + ipend |= SER_INT_RXREADY; + } else if (csr & USART_CSR_TIMEOUT) { + /* + * We have one partial buffer. We need to stop the + * PDC, get the number of characters left and from + * that compute number of valid characters. We then + * need to reset ping and pong and reenable the PDC. + * Not sure if there's a race here at fast baud rates + * we need to worry about. + */ + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTDIS); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + len = sc->sc_rxfifosz - RD4(&sc->sc_bas, PDC_RCR); + for (i = 0; i < len; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); + WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); + ipend |= SER_INT_RXREADY; + } + } else if (csr & USART_CSR_RXRDY) { + /* + * We have another charater in a device that doesn't support + * timeouts, so we do it one character at a time. + */ at91_rx_put(sc, RD4(&sc->sc_bas, USART_RHR) & 0xff); ipend |= SER_INT_RXREADY; } if (csr & USART_CSR_RXBRK) { - unsigned int cr = USART_CR_RSTSTA; - ipend |= SER_INT_BREAK; - WR4(&sc->sc_bas, USART_CR, cr); + WR4(&sc->sc_bas, USART_CR, USART_CR_RSTSTA); } uart_unlock(sc->sc_hwmtx); return (ipend); } + static int at91_usart_bus_flush(struct uart_softc *sc, int what) { + return (0); } static int at91_usart_bus_getsig(struct uart_softc *sc) { - uint32_t new, sig; - uint8_t csr; + uint32_t csr, new, sig; uart_lock(sc->sc_hwmtx); csr = RD4(&sc->sc_bas, USART_CSR); @@ -628,6 +667,7 @@ at91_usart_bus_getsig(struct uart_softc static int at91_usart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) { + switch (request) { case UART_IOCTL_BREAK: case UART_IOCTL_IFLOW: @@ -637,7 +677,7 @@ at91_usart_bus_ioctl(struct uart_softc * /* only if we know our master clock rate */ if (DEFAULT_RCLK != 0) WR4(&sc->sc_bas, USART_BRGR, - BAUD2DIVISOR(*(int *)data)); + BAUD2DIVISOR(*(int *)data)); return (0); } return (EINVAL); From owner-svn-src-all@FreeBSD.ORG Tue May 1 21:04:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFBBF106564A; Tue, 1 May 2012 21:04:21 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id 62BD78FC16; Tue, 1 May 2012 21:04:21 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 3D18025D3897; Tue, 1 May 2012 21:04:20 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 61FAEBE609C; Tue, 1 May 2012 21:04:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id fK-Iz+8yRJ8u; Tue, 1 May 2012 21:04:18 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id EF5E8BE609E; Tue, 1 May 2012 21:04:17 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201205011716.q41HG1fL036603@svn.freebsd.org> Date: Tue, 1 May 2012 21:04:17 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> References: <201205011716.q41HG1fL036603@svn.freebsd.org> To: Marius Strobl X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:04:22 -0000 On 1. May 2012, at 17:16 , Marius Strobl wrote: > Author: marius > Date: Tue May 1 17:16:01 2012 > New Revision: 234898 > URL: http://svn.freebsd.org/changeset/base/234898 >=20 > Log: > Add initial support for booting from ZFS on sparc64. At least on Sun = Fire > V100, the firmware is known to be broken and not allowing to = simultaneously > open disk devices, causing attempts to boot from a mirror or RAIDZ to = cause > a crash. This will be worked around later. The firmwares of newer = sun4u models > don't seem to exhibit this problem though. >=20 > Steps for ZFS booting: >=20 > 1. create VTOC8 label > # gpart create -s vtoc8 da0 >=20 > 2. add partitions, f.e.: > # gpart add -t freebsd-zfs -s 60g da0 > # gpart add -t freebsd-swap da0 > resulting in something like: > # gpart show > =3D> 0 143331930 da0 VTOC8 (68G) > 0 125821080 1 freebsd-zfs (60G) > 125821080 17510850 2 freebsd-swap (8.4G) >=20 > 3. create zpool > # zpool create bunker da0a > or for mirror/RAIDZ (after preparing additional disks as in steps 1. = + 2.): > # zpool create bunker mirror da0a da1a > # zpool create bunker raidz da0a da1a da2a ... >=20 > 4. set bootfs > # zpool set bootfs=3Dbunker bunker >=20 > 5. install zfsboot > # zpool export bunker > # gpart bootcode -p /boot/zfsboot da0 >=20 > 6. write zfsloader to the ZFS Boot Block (so far, there's no = dedicated tool > for this, so dd(1) has to be used for this purpose) > When using mirror/RAIDZ, step 4. and the dd(1) invocation should be = repeated > for the additional disks in order to be able to boot from another = disk in > case of failure. > # sysctl kern.geom.debugflags=3D0x10 > # dd if=3D/boot/zfsloader of=3D/dev/da0a bs=3D512 oseek=3D1024 = conv=3Dnotrunc > # zpool import bunker >=20 > 7. install system on ZFS filesystem > Don't forget to set 'zfs_load=3D"YES"' and = vfs.root.mountfrom=3D"zfs:bunker" in > loader.conf as well as 'zfs_enable=3D"YES"'in rc.conf. >=20 > 8. copy zpool.cache to the ZFS filesystem > cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache >=20 > 9. set mountpoint > # zfs set mountpoint=3D/ bunker >=20 > 10. Now, given that aliases for all disks in the zpool exists (check = with > the `devalias` command on the boot monitor prompt) and disk0 = corresponds > to da0 (likewise for additional disks), the system can be booted from = the > ZFS with: > {1} ok boot disk0 These steps belong into documentation (man page, handbook, ...) bit not = really into the commit message. Great news for spacr64 users however, I think. --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-all@FreeBSD.ORG Tue May 1 21:05:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5FAC6106566C; Tue, 1 May 2012 21:05:42 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) by mx1.freebsd.org (Postfix) with ESMTP id F2A998FC15; Tue, 1 May 2012 21:05:41 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 12A5125D3897; Tue, 1 May 2012 21:05:41 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 82BD3BE609D; Tue, 1 May 2012 21:05:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id 4cIY23JQaYwI; Tue, 1 May 2012 21:05:39 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 1CEA8BE609C; Tue, 1 May 2012 21:05:39 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201205011615.q41GFZa1034278@svn.freebsd.org> Date: Tue, 1 May 2012 21:05:38 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201205011615.q41GFZa1034278@svn.freebsd.org> To: Monthadar Al Jaberi X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:05:42 -0000 On 1. May 2012, at 16:15 , Monthadar Al Jaberi wrote: > Author: monthadar > Date: Tue May 1 16:15:34 2012 > New Revision: 234893 > URL: http://svn.freebsd.org/changeset/base/234893 >=20 > Log: > * Added new command to ifconfig to activate Mesh Gate Announcement = called > meshgate with corresponding explanation; >=20 > Approved by: adrian >=20 > Modified: > head/sbin/ifconfig/ifconfig.8 > head/sbin/ifconfig/ifieee80211.c >=20 > Modified: head/sbin/ifconfig/ifconfig.8 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sbin/ifconfig/ifconfig.8 Tue May 1 16:14:18 2012 = (r234892) > +++ head/sbin/ifconfig/ifconfig.8 Tue May 1 16:15:34 2012 = (r234893) Please update .Dd as well. > @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by=20 > By default > .Cm meshforward > is enabled. > +.It Cm meshgate > +This attribute specifies whether or not the mesh STA activates mesh = gate > +announcements. > +By default > +.Cm meshgate > +is disabled. > .It Cm meshmetric Ar protocol > Set the specified > .Ar protocol --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-all@FreeBSD.ORG Tue May 1 21:23:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F2C0B1065675; Tue, 1 May 2012 21:23:21 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 861308FC16; Tue, 1 May 2012 21:23:21 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q41LNKv7048468; Tue, 1 May 2012 23:23:20 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q41LNK9l048467; Tue, 1 May 2012 23:23:20 +0200 (CEST) (envelope-from marius) Date: Tue, 1 May 2012 23:23:19 +0200 From: Marius Strobl To: "Bjoern A. Zeeb" Message-ID: <20120501212319.GF18650@alchemy.franken.de> References: <201205011716.q41HG1fL036603@svn.freebsd.org> <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, Marius Strobl , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:23:22 -0000 On Tue, May 01, 2012 at 09:04:17PM +0000, Bjoern A. Zeeb wrote: > > On 1. May 2012, at 17:16 , Marius Strobl wrote: > > > Author: marius > > Date: Tue May 1 17:16:01 2012 > > New Revision: 234898 > > URL: http://svn.freebsd.org/changeset/base/234898 > > > > Log: > > Add initial support for booting from ZFS on sparc64. At least on Sun Fire > > V100, the firmware is known to be broken and not allowing to simultaneously > > open disk devices, causing attempts to boot from a mirror or RAIDZ to cause > > a crash. This will be worked around later. The firmwares of newer sun4u models > > don't seem to exhibit this problem though. > > > > Steps for ZFS booting: > > > > 1. create VTOC8 label > > # gpart create -s vtoc8 da0 > > > > 2. add partitions, f.e.: > > # gpart add -t freebsd-zfs -s 60g da0 > > # gpart add -t freebsd-swap da0 > > resulting in something like: > > # gpart show > > => 0 143331930 da0 VTOC8 (68G) > > 0 125821080 1 freebsd-zfs (60G) > > 125821080 17510850 2 freebsd-swap (8.4G) > > > > 3. create zpool > > # zpool create bunker da0a > > or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.): > > # zpool create bunker mirror da0a da1a > > # zpool create bunker raidz da0a da1a da2a ... > > > > 4. set bootfs > > # zpool set bootfs=bunker bunker > > > > 5. install zfsboot > > # zpool export bunker > > # gpart bootcode -p /boot/zfsboot da0 > > > > 6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool > > for this, so dd(1) has to be used for this purpose) > > When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated > > for the additional disks in order to be able to boot from another disk in > > case of failure. > > # sysctl kern.geom.debugflags=0x10 > > # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc > > # zpool import bunker > > > > 7. install system on ZFS filesystem > > Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in > > loader.conf as well as 'zfs_enable="YES"'in rc.conf. > > > > 8. copy zpool.cache to the ZFS filesystem > > cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache > > > > 9. set mountpoint > > # zfs set mountpoint=/ bunker > > > > 10. Now, given that aliases for all disks in the zpool exists (check with > > the `devalias` command on the boot monitor prompt) and disk0 corresponds > > to da0 (likewise for additional disks), the system can be booted from the > > ZFS with: > > {1} ok boot disk0 > > > These steps belong into documentation (man page, handbook, ...) bit not really > into the commit message. > We've seen way larger commit messages across totally unrelated parts in the past and the commit message seemed like a good place for ensuring the instructions not getting lost for now ... In any case, I'm desperately waiting for property editing on svn:log to be enabled :) Marius From owner-svn-src-all@FreeBSD.ORG Wed May 2 00:30:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DBE4106566C; Wed, 2 May 2012 00:30:31 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 77FBF8FC08; Wed, 2 May 2012 00:30: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 q420UVMN054959; Wed, 2 May 2012 00:30:31 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q420UV65054956; Wed, 2 May 2012 00:30:31 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205020030.q420UV65054956@svn.freebsd.org> From: Xin LI Date: Wed, 2 May 2012 00:30:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234903 - stable/9/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 00:30:31 -0000 Author: delphij Date: Wed May 2 00:30:30 2012 New Revision: 234903 URL: http://svn.freebsd.org/changeset/base/234903 Log: MFC r233770: Eliminate two cases of unwanted strncpy(). The name is not required by the current code, and the results would get overwritten anyway by subsequent memset(). Reviewed by: ume Modified: stable/9/lib/libc/net/getaddrinfo.c stable/9/lib/libc/net/name6.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/getaddrinfo.c ============================================================================== --- stable/9/lib/libc/net/getaddrinfo.c Tue May 1 23:46:18 2012 (r234902) +++ stable/9/lib/libc/net/getaddrinfo.c Wed May 2 00:30:30 2012 (r234903) @@ -847,8 +847,6 @@ set_source(struct ai_order *aio, struct struct in6_ifreq ifr6; u_int32_t flags6; - /* XXX: interface name should not be hardcoded */ - strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name)); memset(&ifr6, 0, sizeof(ifr6)); memcpy(&ifr6.ifr_addr, ai.ai_addr, ai.ai_addrlen); if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) { Modified: stable/9/lib/libc/net/name6.c ============================================================================== --- stable/9/lib/libc/net/name6.c Tue May 1 23:46:18 2012 (r234902) +++ stable/9/lib/libc/net/name6.c Wed May 2 00:30:30 2012 (r234903) @@ -884,8 +884,6 @@ set_source(struct hp_order *aio, struct struct in6_ifreq ifr6; u_int32_t flags6; - /* XXX: interface name should not be hardcoded */ - strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name)); memset(&ifr6, 0, sizeof(ifr6)); memcpy(&ifr6.ifr_addr, &ss, ss.ss_len); if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) { From owner-svn-src-all@FreeBSD.ORG Wed May 2 00:31:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 68F4B1065672; Wed, 2 May 2012 00:31:10 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 534FF8FC08; Wed, 2 May 2012 00:31:10 +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 q420VAj6055031; Wed, 2 May 2012 00:31:10 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q420VAAA055028; Wed, 2 May 2012 00:31:10 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205020031.q420VAAA055028@svn.freebsd.org> From: Xin LI Date: Wed, 2 May 2012 00:31:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234904 - stable/8/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 00:31:10 -0000 Author: delphij Date: Wed May 2 00:31:09 2012 New Revision: 234904 URL: http://svn.freebsd.org/changeset/base/234904 Log: MFC r233770: Eliminate two cases of unwanted strncpy(). The name is not required by the current code, and the results would get overwritten anyway by subsequent memset(). Reviewed by: ume Modified: stable/8/lib/libc/net/getaddrinfo.c stable/8/lib/libc/net/name6.c Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/net/getaddrinfo.c ============================================================================== --- stable/8/lib/libc/net/getaddrinfo.c Wed May 2 00:30:30 2012 (r234903) +++ stable/8/lib/libc/net/getaddrinfo.c Wed May 2 00:31:09 2012 (r234904) @@ -847,8 +847,6 @@ set_source(struct ai_order *aio, struct struct in6_ifreq ifr6; u_int32_t flags6; - /* XXX: interface name should not be hardcoded */ - strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name)); memset(&ifr6, 0, sizeof(ifr6)); memcpy(&ifr6.ifr_addr, ai.ai_addr, ai.ai_addrlen); if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) { Modified: stable/8/lib/libc/net/name6.c ============================================================================== --- stable/8/lib/libc/net/name6.c Wed May 2 00:30:30 2012 (r234903) +++ stable/8/lib/libc/net/name6.c Wed May 2 00:31:09 2012 (r234904) @@ -884,8 +884,6 @@ set_source(struct hp_order *aio, struct struct in6_ifreq ifr6; u_int32_t flags6; - /* XXX: interface name should not be hardcoded */ - strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name)); memset(&ifr6, 0, sizeof(ifr6)); memcpy(&ifr6.ifr_addr, &ss, ss.ss_len); if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) { From owner-svn-src-all@FreeBSD.ORG Wed May 2 01:14:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE2F5106566B; Wed, 2 May 2012 01:14:15 +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 9A1488FC08; Wed, 2 May 2012 01:14: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 q421EFvM056610; Wed, 2 May 2012 01:14:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q421EFrA056608; Wed, 2 May 2012 01:14:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020114.q421EFrA056608@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 01:14: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: r234905 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 01:14:15 -0000 Author: adrian Date: Wed May 2 01:14:15 2012 New Revision: 234905 URL: http://svn.freebsd.org/changeset/base/234905 Log: Introduce an enum which encapsulates the PHY interface types that can be configured. Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Wed May 2 00:31:09 2012 (r234904) +++ head/sys/mips/atheros/ar71xxreg.h Wed May 2 01:14:15 2012 (r234905) @@ -267,6 +267,13 @@ #define AR91XX_REV_ID_REVISION_MASK 0x3 #define AR91XX_REV_ID_REVISION_SHIFT 2 +typedef enum { + AR71XX_MII_MODE_NONE = 0, + AR71XX_MII_MODE_GMII, + AR71XX_MII_MODE_MII, + AR71XX_MII_MODE_RGMII, + AR71XX_MII_MODE_RMII, +} ar71xx_mii_mode; /* * AR71xx MII control region */ @@ -288,7 +295,6 @@ #define MII1_CTRL_IF_RGMII 0 #define MII1_CTRL_IF_RMII 1 - /* * GigE adapters region */ From owner-svn-src-all@FreeBSD.ORG Wed May 2 01:21:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6AF1C106564A; Wed, 2 May 2012 01:21:58 +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 5547A8FC0A; Wed, 2 May 2012 01:21: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 q421LwUs056905; Wed, 2 May 2012 01:21:58 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q421LwFU056899; Wed, 2 May 2012 01:21:58 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020121.q421LwFU056899@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 01:21: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: r234906 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 01:21:58 -0000 Author: adrian Date: Wed May 2 01:21:57 2012 New Revision: 234906 URL: http://svn.freebsd.org/changeset/base/234906 Log: MII related infrastructure changes. * Add a new method to set the MII mode - GMII, RGMII, RMII, MII. + arge0 supports all four (two for non-Gige interfaces.) + arge1 only supports two (one for non-gige interfaces.) * Set the MII clock speed when changing the MAC PLL speed. + Needed for AR91xx and AR71xx; not needed for AR724x. Tested: * AR71xx only, I'll do AR913x testing tonight and fix whichever issues creep up. TODO: * Implement the missing AR7242 arge0 PLL configuration, but don't adjust the MII speed accordingly. * .. the AR7240/AR7241 don't require this, so make sure it's not set accidentally. Bugs (not fixed here): * Statically configured arge speeds are still broken - investigate why that is on the AP96 board. Autonegotiate is working fine, but there still seems to be an occasionally heavy packet loss issue. Obtained from: Linux/Atheros/OpenWRT Modified: head/sys/mips/atheros/ar71xx_chip.c head/sys/mips/atheros/ar71xx_chip.h head/sys/mips/atheros/ar71xx_cpudef.h head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar91xx_chip.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -176,6 +176,50 @@ ar71xx_chip_set_mii_speed(uint32_t unit, ATH_WRITE_REG(reg, val); } +void +ar71xx_chip_set_mii_if(uint32_t unit, uint32_t mii_mode) +{ + uint32_t val, reg, mii_if; + + switch (unit) { + case 0: + reg = AR71XX_MII0_CTRL; + if (mii_mode == AR71XX_MII_MODE_GMII) + mii_if = MII0_CTRL_IF_GMII; + else if (mii_mode == AR71XX_MII_MODE_MII) + mii_if = MII0_CTRL_IF_MII; + else if (mii_mode == AR71XX_MII_MODE_RGMII) + mii_if = MII0_CTRL_IF_RGMII; + else if (mii_mode == AR71XX_MII_MODE_RMII) + mii_if = MII0_CTRL_IF_RMII; + else + printf("%s: invalid MII mode (%d) for unit %d\n", + __func__, mii_mode, unit); + return; + break; + case 1: + reg = AR71XX_MII1_CTRL; + if (mii_mode == AR71XX_MII_MODE_RGMII) + mii_if = MII1_CTRL_IF_RGMII; + if (mii_mode == AR71XX_MII_MODE_RMII) + mii_if = MII1_CTRL_IF_RMII; + else + printf("%s: invalid MII mode (%d) for unit %d\n", + __func__, mii_mode, unit); + return; + break; + default: + printf("%s: invalid MII unit set for arge unit: %d\n", + __func__, unit); + return; + } + + val = ATH_READ_REG(reg); + val &= ~(MII_CTRL_IF_MASK << MII_CTRL_IF_SHIFT); + val |= (mii_if & MII_CTRL_IF_MASK) << MII_CTRL_IF_SHIFT; + ATH_WRITE_REG(reg, val); +} + /* Speed is either 10, 100 or 1000 */ static void ar71xx_chip_set_pll_ge(int unit, int speed) @@ -197,6 +241,7 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit, speed); return; } + switch (unit) { case 0: ar71xx_write_pll(AR71XX_PLL_SEC_CONFIG, @@ -213,6 +258,12 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } + + /* + * AR71xx and AR913x require this; AR724x doesn't require + * an MII clock change at all. + */ + ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -278,6 +329,7 @@ struct ar71xx_cpu_def ar71xx_chip_def = &ar71xx_chip_device_stopped, &ar71xx_chip_set_pll_ge, &ar71xx_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar71xx_chip_ddr_flush_ge, &ar71xx_chip_get_eth_pll, &ar71xx_chip_ddr_flush_ip2, Modified: head/sys/mips/atheros/ar71xx_chip.h ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.h Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_chip.h Wed May 2 01:21:57 2012 (r234906) @@ -31,5 +31,6 @@ extern struct ar71xx_cpu_def ar71xx_chip_def; extern void ar71xx_chip_set_mii_speed(uint32_t unit, uint32_t speed); +extern void ar71xx_chip_set_mii_if(uint32_t unit, uint32_t mii_if); #endif Modified: head/sys/mips/atheros/ar71xx_cpudef.h ============================================================================== --- head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:21:57 2012 (r234906) @@ -37,6 +37,7 @@ struct ar71xx_cpu_def { int (* ar71xx_chip_device_stopped) (uint32_t); void (* ar71xx_chip_set_pll_ge) (int, int); void (* ar71xx_chip_set_mii_speed) (uint32_t, uint32_t); + void (* ar71xx_chip_set_mii_if) (uint32_t, ar71xx_mii_mode); void (* ar71xx_chip_ddr_flush_ge) (int); uint32_t (* ar71xx_chip_get_eth_pll) (unsigned int, int); @@ -90,6 +91,11 @@ static inline void ar71xx_device_set_mii ar71xx_cpu_ops->ar71xx_chip_set_mii_speed(unit, speed); } +static inline void ar71xx_device_set_mii_if(int unit, ar71xx_mii_mode mii_cfg) +{ + ar71xx_cpu_ops->ar71xx_chip_set_mii_if(unit, mii_cfg); +} + static inline void ar71xx_device_flush_ddr_ge(int unit) { ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge(unit); Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -130,6 +131,13 @@ ar724x_chip_set_mii_speed(uint32_t unit, return; } +/* + * XXX TODO: set the PLL for arge0 only on AR7242. + * The PLL/clock requirements are different. + * + * Otherwise, it's a NULL function for AR7240, AR7241 and + * AR7242 arge1. + */ static void ar724x_chip_set_pll_ge(int unit, int speed) { @@ -229,6 +237,7 @@ struct ar71xx_cpu_def ar724x_chip_def = &ar724x_chip_device_stopped, &ar724x_chip_set_pll_ge, &ar724x_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar724x_chip_ddr_flush_ge, &ar724x_chip_get_eth_pll, &ar724x_chip_ddr_flush_ip2, Modified: head/sys/mips/atheros/ar91xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -147,6 +147,7 @@ ar91xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } + ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -211,6 +212,7 @@ struct ar71xx_cpu_def ar91xx_chip_def = &ar91xx_chip_device_stopped, &ar91xx_chip_set_pll_ge, &ar71xx_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar91xx_chip_ddr_flush_ge, &ar91xx_chip_get_eth_pll, &ar91xx_chip_ddr_flush_ip2, From owner-svn-src-all@FreeBSD.ORG Wed May 2 04:51:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1ECA106566C; Wed, 2 May 2012 04:51:44 +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 ACBE98FC08; Wed, 2 May 2012 04:51:44 +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 q424pigx064972; Wed, 2 May 2012 04:51:44 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q424pi8N064966; Wed, 2 May 2012 04:51:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020451.q424pi8N064966@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 04:51:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234907 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 04:51:44 -0000 Author: adrian Date: Wed May 2 04:51:43 2012 New Revision: 234907 URL: http://svn.freebsd.org/changeset/base/234907 Log: Further ar71xx MII support improvements. * Flesh out the PLL configuration fetch function, which will return the PLL configuration based on the unit number and speed. * Remove the PLL speed config logic from the AR71xx/AR91xx chip PLL config function - pass in a 'pll' value instead. * Modify arge_set_pll() to: + fetch the PLL configuration + write the PLL configuration + update the MII speed configuration. This will allow if_arge to override the PLL configuration as required. Obtained from: Linux/Atheros/OpenWRT Modified: head/sys/mips/atheros/ar71xx_chip.c head/sys/mips/atheros/ar71xx_cpudef.h head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar91xx_chip.c head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar71xx_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -222,25 +222,8 @@ ar71xx_chip_set_mii_if(uint32_t unit, ui /* Speed is either 10, 100 or 1000 */ static void -ar71xx_chip_set_pll_ge(int unit, int speed) +ar71xx_chip_set_pll_ge(int unit, int speed, uint32_t pll) { - uint32_t pll; - - switch (speed) { - case 10: - pll = PLL_ETH_INT_CLK_10; - break; - case 100: - pll = PLL_ETH_INT_CLK_100; - break; - case 1000: - pll = PLL_ETH_INT_CLK_1000; - break; - default: - printf("%s%d: invalid speed %d\n", - __func__, unit, speed); - return; - } switch (unit) { case 0: @@ -258,12 +241,6 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } - - /* - * AR71xx and AR913x require this; AR724x doesn't require - * an MII clock change at all. - */ - ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -293,7 +270,24 @@ ar71xx_chip_ddr_flush_ip2(void) static uint32_t ar71xx_chip_get_eth_pll(unsigned int mac, int speed) { - return 0; + uint32_t pll; + + switch (speed) { + case 10: + pll = PLL_ETH_INT_CLK_10; + break; + case 100: + pll = PLL_ETH_INT_CLK_100; + break; + case 1000: + pll = PLL_ETH_INT_CLK_1000; + break; + default: + printf("%s%d: invalid speed %d\n", __func__, mac, speed); + pll = 0; + } + + return (pll); } static void Modified: head/sys/mips/atheros/ar71xx_cpudef.h ============================================================================== --- head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 04:51:43 2012 (r234907) @@ -35,7 +35,7 @@ struct ar71xx_cpu_def { void (* ar71xx_chip_device_stop) (uint32_t); void (* ar71xx_chip_device_start) (uint32_t); int (* ar71xx_chip_device_stopped) (uint32_t); - void (* ar71xx_chip_set_pll_ge) (int, int); + void (* ar71xx_chip_set_pll_ge) (int, int, uint32_t); void (* ar71xx_chip_set_mii_speed) (uint32_t, uint32_t); void (* ar71xx_chip_set_mii_if) (uint32_t, ar71xx_mii_mode); void (* ar71xx_chip_ddr_flush_ge) (int); @@ -81,9 +81,9 @@ static inline int ar71xx_device_stopped( return ar71xx_cpu_ops->ar71xx_chip_device_stopped(mask); } -static inline void ar71xx_device_set_pll_ge(int unit, int speed) +static inline void ar71xx_device_set_pll_ge(int unit, int speed, uint32_t pll) { - ar71xx_cpu_ops->ar71xx_chip_set_pll_ge(unit, speed); + ar71xx_cpu_ops->ar71xx_chip_set_pll_ge(unit, speed, pll); } static inline void ar71xx_device_set_mii_speed(int unit, int speed) @@ -101,6 +101,11 @@ static inline void ar71xx_device_flush_d ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge(unit); } +static inline uint32_t ar71xx_device_get_eth_pll(unsigned int unit, int speed) +{ + return (ar71xx_cpu_ops->ar71xx_chip_get_eth_pll(unit, speed)); +} + static inline void ar71xx_init_usb_peripheral(void) { ar71xx_cpu_ops->ar71xx_chip_init_usb_peripheral(); Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar724x_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -139,7 +139,7 @@ ar724x_chip_set_mii_speed(uint32_t unit, * AR7242 arge1. */ static void -ar724x_chip_set_pll_ge(int unit, int speed) +ar724x_chip_set_pll_ge(int unit, int speed, uint32_t pll) { switch (unit) { @@ -185,7 +185,7 @@ static uint32_t ar724x_chip_get_eth_pll(unsigned int mac, int speed) { - return 0; + return (0); } static void Modified: head/sys/mips/atheros/ar91xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar91xx_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -112,25 +112,9 @@ ar91xx_chip_device_stopped(uint32_t mask } static void -ar91xx_chip_set_pll_ge(int unit, int speed) +ar91xx_chip_set_pll_ge(int unit, int speed, uint32_t pll) { - uint32_t pll; - switch(speed) { - case 10: - pll = AR91XX_PLL_VAL_10; - break; - case 100: - pll = AR91XX_PLL_VAL_100; - break; - case 1000: - pll = AR91XX_PLL_VAL_1000; - break; - default: - printf("%s%d: invalid speed %d\n", - __func__, unit, speed); - return; - } switch (unit) { case 0: ar71xx_write_pll(AR91XX_PLL_REG_ETH_CONFIG, @@ -147,7 +131,6 @@ ar91xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } - ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -179,8 +162,24 @@ ar91xx_chip_ddr_flush_ip2(void) static uint32_t ar91xx_chip_get_eth_pll(unsigned int mac, int speed) { + uint32_t pll; + + switch(speed) { + case 10: + pll = AR91XX_PLL_VAL_10; + break; + case 100: + pll = AR91XX_PLL_VAL_100; + break; + case 1000: + pll = AR91XX_PLL_VAL_1000; + break; + default: + printf("%s%d: invalid speed %d\n", __func__, mac, speed); + pll = 0; + } - return 0; + return (pll); } static void Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/if_arge.c Wed May 2 04:51:43 2012 (r234907) @@ -776,10 +776,13 @@ arge_update_link_locked(struct arge_soft if (mii->mii_media_status & IFM_ACTIVE) { media = IFM_SUBTYPE(mii->mii_media_active); - if (media != IFM_NONE) { sc->arge_link_status = 1; duplex = mii->mii_media_active & IFM_GMASK; + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: media=%d, duplex=%d\n", + __func__, + media, + duplex); arge_set_pll(sc, media, duplex); } } else { @@ -791,7 +794,7 @@ static void arge_set_pll(struct arge_softc *sc, int media, int duplex) { uint32_t cfg, ifcontrol, rx_filtmask; - uint32_t fifo_tx; + uint32_t fifo_tx, pll; int if_speed; ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, @@ -832,6 +835,8 @@ arge_set_pll(struct arge_softc *sc, int "Unknown media %d\n", media); } + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: if_speed=%d\n", __func__, if_speed); + switch (ar71xx_soc) { case AR71XX_SOC_AR7240: case AR71XX_SOC_AR7241: @@ -853,7 +858,13 @@ arge_set_pll(struct arge_softc *sc, int ARGE_WRITE(sc, AR71XX_MAC_FIFO_TX_THRESHOLD, fifo_tx); /* set PLL registers */ - ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed); + pll = ar71xx_device_get_eth_pll(sc->arge_mac_unit, if_speed); + + /* XXX ensure pll != 0 */ + ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); + + /* set MII registers */ + ar71xx_device_set_mii_speed(sc->arge_mac_unit, if_speed); } From owner-svn-src-all@FreeBSD.ORG Wed May 2 05:49:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0AD18106564A; Wed, 2 May 2012 05:49:59 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA4068FC16; Wed, 2 May 2012 05:49: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 q425nwcg066979; Wed, 2 May 2012 05:49:58 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q425nwet066977; Wed, 2 May 2012 05:49:58 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201205020549.q425nwet066977@svn.freebsd.org> From: Tim Kientzle Date: Wed, 2 May 2012 05:49: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: r234908 - head/sys/boot/arm/uboot X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 05:49:59 -0000 Author: kientzle Date: Wed May 2 05:49:58 2012 New Revision: 234908 URL: http://svn.freebsd.org/changeset/base/234908 Log: Remove some redundant register loads. Discussed on: arm@ Modified: head/sys/boot/arm/uboot/start.S Modified: head/sys/boot/arm/uboot/start.S ============================================================================== --- head/sys/boot/arm/uboot/start.S Wed May 2 04:51:43 2012 (r234907) +++ head/sys/boot/arm/uboot/start.S Wed May 2 05:49:58 2012 (r234908) @@ -49,27 +49,20 @@ _start: * syscall() */ ENTRY(syscall) - /* Save caller's lr */ + /* Save caller's lr and r8 */ ldr ip, =saved_regs str lr, [ip, #4] - /* Save loader's r8 */ - ldr ip, =saved_regs str r8, [ip, #8] - /* Restore U-Boot's r8 */ - ldr ip, =saved_regs ldr r8, [ip, #0] /* Call into U-Boot */ ldr lr, =return_from_syscall ldr ip, =syscall_ptr ldr pc, [ip] - return_from_syscall: - /* Restore loader's r8 */ + /* Restore loader's r8 and lr */ ldr ip, =saved_regs ldr r8, [ip, #8] - /* Restore caller's lr */ - ldr ip, =saved_regs ldr lr, [ip, #4] /* Return to caller */ mov pc, lr From owner-svn-src-all@FreeBSD.ORG Wed May 2 06:17:17 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2B045106566B; Wed, 2 May 2012 06:17:17 +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 F0A3B8FC08; Wed, 2 May 2012 06:17:16 +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 q426HGs7068133; Wed, 2 May 2012 06:17:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426HGV1068131; Wed, 2 May 2012 06:17:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020617.q426HGV1068131@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:17:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234909 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:17:17 -0000 Author: adrian Date: Wed May 2 06:17:16 2012 New Revision: 234909 URL: http://svn.freebsd.org/changeset/base/234909 Log: Add a missing newline. Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Wed May 2 05:49:58 2012 (r234908) +++ head/sys/mips/atheros/ar71xxreg.h Wed May 2 06:17:16 2012 (r234909) @@ -274,6 +274,7 @@ typedef enum { AR71XX_MII_MODE_RGMII, AR71XX_MII_MODE_RMII, } ar71xx_mii_mode; + /* * AR71xx MII control region */ From owner-svn-src-all@FreeBSD.ORG Wed May 2 06:18:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1254A1065673; Wed, 2 May 2012 06:18:13 +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 D764D8FC1A; Wed, 2 May 2012 06:18:12 +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 q426IC2j068207; Wed, 2 May 2012 06:18:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426ICmG068202; Wed, 2 May 2012 06:18:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020618.q426ICmG068202@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:18:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234910 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:18:13 -0000 Author: adrian Date: Wed May 2 06:18:12 2012 New Revision: 234910 URL: http://svn.freebsd.org/changeset/base/234910 Log: Allow the MII mode to be overridden via 'hint.arge.X.miimode'. It takes a number at the moment, rather than a string. Some of the Linux board configurations specify the MII mode explicitly. Modified: head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 06:17:16 2012 (r234909) +++ head/sys/mips/atheros/if_arge.c Wed May 2 06:18:12 2012 (r234910) @@ -103,6 +103,14 @@ typedef enum { ARGE_DBG_RESET = 0x00000020, } arge_debug_flags; +static const char * arge_miicfg_str[] = { + "NONE", + "GMII", + "MII", + "RGMII", + "RMII" +}; + #ifdef ARGE_DEBUG #define ARGEDEBUG(_sc, _m, ...) \ do { \ @@ -333,6 +341,7 @@ arge_attach(device_t dev) int is_base_mac_empty, i; uint32_t hint; long eeprom_mac_addr = 0; + int miicfg = 0; sc = device_get_softc(dev); sc->arge_dev = dev; @@ -363,6 +372,17 @@ arge_attach(device_t dev) ("if_arge: Only MAC0 and MAC1 supported")); /* + * Get the MII configuration, if applicable. + */ + if (resource_int_value(device_get_name(dev), device_get_unit(dev), + "miimode", &miicfg) == 0) { + /* XXX bounds check? */ + device_printf(dev, "%s: overriding MII mode to '%s'\n", + __func__, arge_miicfg_str[miicfg]); + sc->arge_miicfg = miicfg; + } + + /* * Get which PHY of 5 available we should use for this unit */ if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -497,6 +517,10 @@ arge_attach(device_t dev) arge_reset_miibus(sc); #endif + /* Configure MII mode, just for convienence */ + if (sc->arge_miicfg != 0) + ar71xx_device_set_mii_if(sc->arge_mac_unit, sc->arge_miicfg); + /* * Set all Ethernet address registers to the same initial values * set all four addresses to 66-88-aa-cc-dd-ee Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Wed May 2 06:17:16 2012 (r234909) +++ head/sys/mips/atheros/if_argevar.h Wed May 2 06:18:12 2012 (r234910) @@ -135,6 +135,7 @@ struct arge_softc { void *arge_intrhand; device_t arge_miibus; device_t arge_miiproxy; + ar71xx_mii_mode arge_miicfg; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; From owner-svn-src-all@FreeBSD.ORG Wed May 2 06:19:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A8284106566B; Wed, 2 May 2012 06:19:26 +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 930E28FC0C; Wed, 2 May 2012 06:19: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 q426JQI4068280; Wed, 2 May 2012 06:19:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426JQpk068278; Wed, 2 May 2012 06:19:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020619.q426JQpk068278@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:19: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: r234911 - head/sys/mips/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:19:26 -0000 Author: adrian Date: Wed May 2 06:19:26 2012 New Revision: 234911 URL: http://svn.freebsd.org/changeset/base/234911 Log: * Force the ethernet MII configuration to be RGMII * Populate the "pll_1000" field, which will soon be used to override the PLL configuration from the default value. Obtained from: Linux OpenWRT Modified: head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Wed May 2 06:18:12 2012 (r234910) +++ head/sys/mips/conf/AP96.hints Wed May 2 06:19:26 2012 (r234911) @@ -16,17 +16,17 @@ hint.mdioproxy.1.at="mdio0" hint.arge.0.phymask=0x0f hint.arge.0.media=1000 hint.arge.0.fduplex=1 +hint.arge.0.miimode=3 # RGMII # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. hint.arge.0.mdio=mdioproxy0 # TODO: RGMII -# TODO: pll_1000 = 0x1f000000 hint.arge.1.phymask=0x10 -# hint.arge.1.media=1000 -# hint.arge.1.fduplex=1 +hint.arge.1.pll_1000 = 0x1f000000 # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. +hint.arge.1.miimode=3 # RGMII hint.arge.1.mdio=mdioproxy1 # ath0 - slot 17 From owner-svn-src-all@FreeBSD.ORG Wed May 2 06:52:00 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B79BF1065672; Wed, 2 May 2012 06:52:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A15428FC16; Wed, 2 May 2012 06:52:00 +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 q426q0eL069710; Wed, 2 May 2012 06:52:00 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426q0nO069704; Wed, 2 May 2012 06:52:00 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020652.q426q0nO069704@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 06:52:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234912 - in stable/8/sys: cam cam/ata geom modules/cam X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:52:00 -0000 Author: mav Date: Wed May 2 06:52:00 2012 New Revision: 234912 URL: http://svn.freebsd.org/changeset/base/234912 Log: Merge ATA_CAM compatibility shims. While 8-STABLE doesn't have ATA_CAM enabled by default, this should make migration easier for users enabling it manually. r221071: Add shim to simplify migration to the CAM-based ATA. For each new adaX device in /dev/ create symbolic link with adY name, trying to mimic old ATA numbering. Imitation is not complete, but should be enough in most cases to mount file systems without touching /etc/fstab. r221384: Do not report legacy unit numbers (do not create legacy aliases) for disks on port multiplier ports above first two. They don't fit into ATA_STATIC_ID scheme and so can't be mapped properly. No need to pollute dev. Modified: stable/8/sys/cam/ata/ata_da.c stable/8/sys/cam/cam_xpt.c stable/8/sys/cam/cam_xpt.h stable/8/sys/geom/geom_dev.c stable/8/sys/modules/cam/Makefile Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/cam/ata/ata_da.c ============================================================================== --- stable/8/sys/cam/ata/ata_da.c Wed May 2 06:19:26 2012 (r234911) +++ stable/8/sys/cam/ata/ata_da.c Wed May 2 06:52:00 2012 (r234912) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ada.h" +#include "opt_ata.h" #include @@ -295,6 +296,14 @@ static void adagetparams(struct cam_per static timeout_t adasendorderedtag; static void adashutdown(void *arg, int howto); +#ifndef ADA_DEFAULT_LEGACY_ALIASES +#ifdef ATA_CAM +#define ADA_DEFAULT_LEGACY_ALIASES 1 +#else +#define ADA_DEFAULT_LEGACY_ALIASES 0 +#endif +#endif + #ifndef ADA_DEFAULT_TIMEOUT #define ADA_DEFAULT_TIMEOUT 30 /* Timeout in seconds */ #endif @@ -332,6 +341,7 @@ static void adashutdown(void *arg, int #define ata_disk_firmware_geom_adjust(disk) #endif +static int ada_legacy_aliases = ADA_DEFAULT_LEGACY_ALIASES; static int ada_retry_count = ADA_DEFAULT_RETRY; static int ada_default_timeout = ADA_DEFAULT_TIMEOUT; static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED; @@ -341,6 +351,9 @@ static int ada_write_cache = ADA_DEFAULT SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RW, + &ada_legacy_aliases, 0, "Create legacy-like device aliases"); +TUNABLE_INT("kern.cam.ada.legacy_aliases", &ada_legacy_aliases); SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RW, &ada_retry_count, 0, "Normal I/O retry count"); TUNABLE_INT("kern.cam.ada.retry_count", &ada_retry_count); @@ -841,11 +854,11 @@ adaregister(struct cam_periph *periph, v struct ada_softc *softc; struct ccb_pathinq cpi; struct ccb_getdev *cgd; - char announce_buf[80]; + char announce_buf[80], buf1[32]; struct disk_params *dp; caddr_t match; u_int maxio; - int quirks; + int legacy_id, quirks; cgd = (struct ccb_getdev *)arg; if (periph == NULL) { @@ -986,6 +999,22 @@ adaregister(struct cam_periph *periph, v softc->disk->d_fwheads = softc->params.heads; ata_disk_firmware_geom_adjust(softc->disk); + if (ada_legacy_aliases) { +#ifdef ATA_STATIC_ID + legacy_id = xpt_path_legacy_ata_id(periph->path); +#else + legacy_id = softc->disk->d_unit; +#endif + if (legacy_id >= 0) { + snprintf(announce_buf, sizeof(announce_buf), + "kern.devalias.%s%d", + softc->disk->d_name, softc->disk->d_unit); + snprintf(buf1, sizeof(buf1), + "ad%d", legacy_id); + setenv(announce_buf, buf1); + } + } else + legacy_id = -1; disk_create(softc->disk, DISK_VERSION); mtx_lock(periph->sim->mtx); cam_periph_unhold(periph); @@ -999,6 +1028,9 @@ adaregister(struct cam_periph *periph, v dp->secsize, dp->heads, dp->secs_per_track, dp->cylinders); xpt_announce_periph(periph, announce_buf); + if (legacy_id >= 0) + printf("%s%d: Previously was known as ad%d\n", + periph->periph_name, periph->unit_number, legacy_id); /* * Create our sysctl variables, now that we know Modified: stable/8/sys/cam/cam_xpt.c ============================================================================== --- stable/8/sys/cam/cam_xpt.c Wed May 2 06:19:26 2012 (r234911) +++ stable/8/sys/cam/cam_xpt.c Wed May 2 06:52:00 2012 (r234912) @@ -3668,6 +3668,45 @@ xpt_path_periph(struct cam_path *path) return (path->periph); } +int +xpt_path_legacy_ata_id(struct cam_path *path) +{ + struct cam_eb *bus; + int bus_id; + + if ((strcmp(path->bus->sim->sim_name, "ata") != 0) && + strcmp(path->bus->sim->sim_name, "ahcich") != 0 && + strcmp(path->bus->sim->sim_name, "mvsch") != 0 && + strcmp(path->bus->sim->sim_name, "siisch") != 0) + return (-1); + + if (strcmp(path->bus->sim->sim_name, "ata") == 0 && + path->bus->sim->unit_number < 2) { + bus_id = path->bus->sim->unit_number; + } else { + bus_id = 2; + xpt_lock_buses(); + TAILQ_FOREACH(bus, &xsoftc.xpt_busses, links) { + if (bus == path->bus) + break; + if ((strcmp(bus->sim->sim_name, "ata") == 0 && + bus->sim->unit_number >= 2) || + strcmp(bus->sim->sim_name, "ahcich") == 0 || + strcmp(bus->sim->sim_name, "mvsch") == 0 || + strcmp(bus->sim->sim_name, "siisch") == 0) + bus_id++; + } + xpt_unlock_buses(); + } + if (path->target != NULL) { + if (path->target->target_id < 2) + return (bus_id * 2 + path->target->target_id); + else + return (-1); + } else + return (bus_id * 2); +} + /* * Release a CAM control block for the caller. Remit the cost of the structure * to the device referenced by the path. If the this device had no 'credits' Modified: stable/8/sys/cam/cam_xpt.h ============================================================================== --- stable/8/sys/cam/cam_xpt.h Wed May 2 06:19:26 2012 (r234911) +++ stable/8/sys/cam/cam_xpt.h Wed May 2 06:52:00 2012 (r234912) @@ -113,6 +113,7 @@ int xpt_path_string(struct cam_path *p path_id_t xpt_path_path_id(struct cam_path *path); target_id_t xpt_path_target_id(struct cam_path *path); lun_id_t xpt_path_lun_id(struct cam_path *path); +int xpt_path_legacy_ata_id(struct cam_path *path); struct cam_sim *xpt_path_sim(struct cam_path *path); struct cam_periph *xpt_path_periph(struct cam_path *path); void xpt_async(u_int32_t async_code, struct cam_path *path, Modified: stable/8/sys/geom/geom_dev.c ============================================================================== --- stable/8/sys/geom/geom_dev.c Wed May 2 06:19:26 2012 (r234911) +++ stable/8/sys/geom/geom_dev.c Wed May 2 06:52:00 2012 (r234912) @@ -113,8 +113,9 @@ g_dev_taste(struct g_class *mp, struct g { struct g_geom *gp; struct g_consumer *cp; - int error; - struct cdev *dev; + int error, len; + struct cdev *dev, *adev; + char buf[64], *val; g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name); g_topology_assert(); @@ -128,12 +129,35 @@ g_dev_taste(struct g_class *mp, struct g ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error)); dev = make_dev(&g_dev_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0640, "%s", gp->name); + + /* Search for device alias name and create it if found. */ + adev = NULL; + for (len = MIN(strlen(gp->name), sizeof(buf) - 15); len > 0; len--) { + snprintf(buf, sizeof(buf), "kern.devalias.%s", gp->name); + buf[14 + len] = 0; + val = getenv(buf); + if (val != NULL) { + snprintf(buf, sizeof(buf), "%s%s", + val, gp->name + len); + freeenv(val); + adev = make_dev_alias(dev, buf); + break; + } + } + if (pp->flags & G_PF_CANDELETE) dev->si_flags |= SI_CANDELETE; dev->si_iosize_max = MAXPHYS; gp->softc = dev; dev->si_drv1 = gp; dev->si_drv2 = cp; + if (adev != NULL) { + if (pp->flags & G_PF_CANDELETE) + adev->si_flags |= SI_CANDELETE; + adev->si_iosize_max = MAXPHYS; + adev->si_drv1 = gp; + adev->si_drv2 = cp; + } return (gp); } Modified: stable/8/sys/modules/cam/Makefile ============================================================================== --- stable/8/sys/modules/cam/Makefile Wed May 2 06:19:26 2012 (r234911) +++ stable/8/sys/modules/cam/Makefile Wed May 2 06:52:00 2012 (r234912) @@ -9,6 +9,7 @@ KMOD= cam # See sys/conf/options for the flags that go into the different opt_*.h files. SRCS= opt_cam.h SRCS+= opt_ada.h +SRCS+= opt_ata.h SRCS+= opt_scsi.h SRCS+= opt_cd.h SRCS+= opt_pt.h From owner-svn-src-all@FreeBSD.ORG Wed May 2 06:58:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C29A91065673; Wed, 2 May 2012 06:58:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9420F8FC0C; Wed, 2 May 2012 06:58:44 +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 q426wiZY070040; Wed, 2 May 2012 06:58:44 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426wiFI070037; Wed, 2 May 2012 06:58:44 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020658.q426wiFI070037@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 06:58:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234913 - in stable/8: share/examples/ses/srcs sys/cam/scsi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:58:44 -0000 Author: mav Date: Wed May 2 06:58:44 2012 New Revision: 234913 URL: http://svn.freebsd.org/changeset/base/234913 Log: MFC r222336, r222339: Add names for few more SES element types according SES-2 specification. Modified: stable/8/share/examples/ses/srcs/eltsub.c stable/8/sys/cam/scsi/scsi_ses.h Directory Properties: stable/8/share/examples/ (props changed) stable/8/sys/ (props changed) Modified: stable/8/share/examples/ses/srcs/eltsub.c ============================================================================== --- stable/8/share/examples/ses/srcs/eltsub.c Wed May 2 06:52:00 2012 (r234912) +++ stable/8/share/examples/ses/srcs/eltsub.c Wed May 2 06:58:44 2012 (r234913) @@ -84,6 +84,9 @@ geteltnm(type) case SESTYP_KEYPAD: sprintf(rbuf, "Key pad entry device"); break; + case SESTYP_ENCLOSURE: + sprintf(rbuf, "Enclosure"); + break; case SESTYP_SCSIXVR: sprintf(rbuf, "SCSI port/transceiver"); break; @@ -108,6 +111,15 @@ geteltnm(type) case SESTYP_SUBENC: sprintf(rbuf, "Simple sub-enclosure"); break; + case SESTYP_ARRAY: + sprintf(rbuf, "Array device"); + break; + case SESTYP_SASEXPANDER: + sprintf(rbuf, "SAS Expender"); + break; + case SESTYP_SASCONNECTOR: + sprintf(rbuf, "SAS Connector"); + break; default: (void) sprintf(rbuf, "", type); break; Modified: stable/8/sys/cam/scsi/scsi_ses.h ============================================================================== --- stable/8/sys/cam/scsi/scsi_ses.h Wed May 2 06:52:00 2012 (r234912) +++ stable/8/sys/cam/scsi/scsi_ses.h Wed May 2 06:58:44 2012 (r234913) @@ -101,6 +101,7 @@ typedef struct { #define SESTYP_UPS 0x0b #define SESTYP_DISPLAY 0x0c #define SESTYP_KEYPAD 0x0d +#define SESTYP_ENCLOSURE 0x0e #define SESTYP_SCSIXVR 0x0f #define SESTYP_LANGUAGE 0x10 #define SESTYP_COMPORT 0x11 @@ -109,6 +110,9 @@ typedef struct { #define SESTYP_SCSI_TGT 0x14 #define SESTYP_SCSI_INI 0x15 #define SESTYP_SUBENC 0x16 +#define SESTYP_ARRAY 0x17 +#define SESTYP_SASEXPANDER 0x18 +#define SESTYP_SASCONNECTOR 0x19 /* * Overall Enclosure Status From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:05:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E5F5106564A; Wed, 2 May 2012 07:05:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7912E8FC15; Wed, 2 May 2012 07:05: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 q4275Lw1070357; Wed, 2 May 2012 07:05:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4275Lm3070355; Wed, 2 May 2012 07:05:21 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020705.q4275Lm3070355@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 07:05:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234914 - stable/8/sys/cam/ata X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:05:21 -0000 Author: mav Date: Wed May 2 07:05:20 2012 New Revision: 234914 URL: http://svn.freebsd.org/changeset/base/234914 Log: MFC r222643: When possible, join ranges of subsequest BIO_DELETE requests to handle more (up to 2048 instead of 256 or even 64) of them with single TRIM request. OCZ Vertex2/Vertex3 SSDs can handle no more then 64 ranges per TRIM request. Due to lack of BIO_DELETE clustering now, it means that we could delete no more then 2MB per request (on FS with 32K block) with limited request rate. This change increases delete rate on Vertex2 from 250MB/s to 950MB/s. MFC r222643: Increase maximum supported number of ranges per TRIM command from 256 to 512 to use full potential of Intel X25-M SSDs. On synthetic test with 32K ranges it gives about 20% speedup, which probably costs more then 2K of RAM. Modified: stable/8/sys/cam/ata/ata_da.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/cam/ata/ata_da.c ============================================================================== --- stable/8/sys/cam/ata/ata_da.c Wed May 2 06:58:44 2012 (r234913) +++ stable/8/sys/cam/ata/ata_da.c Wed May 2 07:05:20 2012 (r234914) @@ -116,11 +116,12 @@ struct disk_params { u_int64_t sectors; /* Total number sectors */ }; -#define TRIM_MAX_BLOCKS 4 -#define TRIM_MAX_RANGES TRIM_MAX_BLOCKS * 64 +#define TRIM_MAX_BLOCKS 8 +#define TRIM_MAX_RANGES (TRIM_MAX_BLOCKS * 64) +#define TRIM_MAX_BIOS (TRIM_MAX_RANGES * 4) struct trim_request { uint8_t data[TRIM_MAX_RANGES * 8]; - struct bio *bps[TRIM_MAX_RANGES]; + struct bio *bps[TRIM_MAX_BIOS]; }; struct ada_softc { @@ -1109,7 +1110,8 @@ adastart(struct cam_periph *periph, unio (bp = bioq_first(&softc->trim_queue)) != 0) { struct trim_request *req = &softc->trim_req; struct bio *bp1; - int bps = 0, ranges = 0; + uint64_t lastlba = (uint64_t)-1; + int bps = 0, c, lastcount = 0, off, ranges = 0; softc->trim_running = 1; bzero(req, sizeof(*req)); @@ -1120,10 +1122,22 @@ adastart(struct cam_periph *periph, unio softc->params.secsize; bioq_remove(&softc->trim_queue, bp1); - while (count > 0) { - int c = min(count, 0xffff); - int off = ranges * 8; + /* Try to extend the previous range. */ + if (lba == lastlba) { + c = min(count, 0xffff - lastcount); + lastcount += c; + off = (ranges - 1) * 8; + req->data[off + 6] = lastcount & 0xff; + req->data[off + 7] = + (lastcount >> 8) & 0xff; + count -= c; + lba += c; + } + + while (count > 0) { + c = min(count, 0xffff); + off = ranges * 8; req->data[off + 0] = lba & 0xff; req->data[off + 1] = (lba >> 8) & 0xff; req->data[off + 2] = (lba >> 16) & 0xff; @@ -1134,11 +1148,14 @@ adastart(struct cam_periph *periph, unio req->data[off + 7] = (c >> 8) & 0xff; lba += c; count -= c; + lastcount = c; ranges++; } + lastlba = lba; req->bps[bps++] = bp1; bp1 = bioq_first(&softc->trim_queue); - if (bp1 == NULL || + if (bps >= TRIM_MAX_BIOS || + bp1 == NULL || bp1->bio_bcount / softc->params.secsize > (softc->trim_max_ranges - ranges) * 0xffff) break; @@ -1430,8 +1447,7 @@ adadone(struct cam_periph *periph, union (struct trim_request *)ataio->data_ptr; int i; - for (i = 1; i < softc->trim_max_ranges && - req->bps[i]; i++) { + for (i = 1; i < TRIM_MAX_BIOS && req->bps[i]; i++) { struct bio *bp1 = req->bps[i]; bp1->bio_resid = bp->bio_resid; From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:08:05 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4496B1065672; Wed, 2 May 2012 07:08:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15C438FC0A; Wed, 2 May 2012 07:08:05 +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 q42784Ex070509; Wed, 2 May 2012 07:08:04 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42784vL070506; Wed, 2 May 2012 07:08:04 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020708.q42784vL070506@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 07:08:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234915 - stable/8/sys/cam/ata X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:08:05 -0000 Author: mav Date: Wed May 2 07:08:04 2012 New Revision: 234915 URL: http://svn.freebsd.org/changeset/base/234915 Log: MFC r223019: Do not report CFA devices as ATAPI, even though IDENTIFY data look alike. Modified: stable/8/sys/cam/ata/ata_all.c stable/8/sys/cam/ata/ata_xpt.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/cam/ata/ata_all.c ============================================================================== --- stable/8/sys/cam/ata/ata_all.c Wed May 2 07:05:20 2012 (r234914) +++ stable/8/sys/cam/ata/ata_all.c Wed May 2 07:08:04 2012 (r234915) @@ -270,6 +270,7 @@ ata_print_ident(struct ata_params *ident sizeof(revision)); printf("<%s %s> %s-%d", product, revision, + (ident_data->config == ATA_PROTO_CFA) ? "CFA" : (ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA", ata_version(ident_data->version_major)); if (ident_data->satacapabilities && ident_data->satacapabilities != 0xffff) { Modified: stable/8/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/8/sys/cam/ata/ata_xpt.c Wed May 2 07:05:20 2012 (r234914) +++ stable/8/sys/cam/ata/ata_xpt.c Wed May 2 07:08:04 2012 (r234915) @@ -1596,12 +1596,14 @@ ata_device_transport(struct cam_path *pa cts.proto_specific.valid = 0; if (ident_buf) { if (path->device->transport == XPORT_ATA) { - cts.xport_specific.ata.atapi = + cts.xport_specific.ata.atapi = + (ident_buf->config == ATA_PROTO_CFA) ? 0 : ((ident_buf->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_16) ? 16 : ((ident_buf->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12) ? 12 : 0; cts.xport_specific.ata.valid = CTS_ATA_VALID_ATAPI; } else { - cts.xport_specific.sata.atapi = + cts.xport_specific.sata.atapi = + (ident_buf->config == ATA_PROTO_CFA) ? 0 : ((ident_buf->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_16) ? 16 : ((ident_buf->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12) ? 12 : 0; cts.xport_specific.sata.valid = CTS_SATA_VALID_ATAPI; @@ -1651,7 +1653,9 @@ ata_action(union ccb *start_ccb) uint16_t p = device->ident_data.config & ATA_PROTO_MASK; - maxlen = (p == ATA_PROTO_ATAPI_16) ? 16 : + maxlen = + (device->ident_data.config == ATA_PROTO_CFA) ? 0 : + (p == ATA_PROTO_ATAPI_16) ? 16 : (p == ATA_PROTO_ATAPI_12) ? 12 : 0; } if (start_ccb->csio.cdb_len > maxlen) { From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:17:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B244106566C; Wed, 2 May 2012 07:17:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF62E8FC16; Wed, 2 May 2012 07:17: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 q427Hr5U070964; Wed, 2 May 2012 07:17:53 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427HrYY070960; Wed, 2 May 2012 07:17:53 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020717.q427HrYY070960@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 07:17:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234916 - in stable/9: sbin/geom/class/multipath sys/geom/multipath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:17:54 -0000 Author: mav Date: Wed May 2 07:17:53 2012 New Revision: 234916 URL: http://svn.freebsd.org/changeset/base/234916 Log: MFC r234415: Some improvements to GEOM MULTIPATH: - Implement "configure" command to allow switching operation mode of running device on-fly without destroying and recreation. - Implement Active/Read mode as hybrid of Active/Active and Active/Passive. In this mode all paths not marked FAIL may handle reads same time, but unlike Active/Active only one path handles write requests at any point in time. It allows to closer follow original write request order if above layers need it for data consistency (not waiting for requisite write completion before sending dependent write). - Hide duplicate messages about device status change. - Remove periodic thread wake up with 10Hz rate. Sponsored by: iXsystems, Inc. Modified: stable/9/sbin/geom/class/multipath/geom_multipath.c stable/9/sbin/geom/class/multipath/gmultipath.8 stable/9/sys/geom/multipath/g_multipath.c Directory Properties: stable/9/sbin/geom/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sbin/geom/class/multipath/geom_multipath.c ============================================================================== --- stable/9/sbin/geom/class/multipath/geom_multipath.c Wed May 2 07:08:04 2012 (r234915) +++ stable/9/sbin/geom/class/multipath/geom_multipath.c Wed May 2 07:17:53 2012 (r234916) @@ -55,17 +55,28 @@ struct g_command class_commands[] = { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - "[-vA] name prov ..." + "[-vAR] name prov ..." }, { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, { { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - "[-vA] name prov ..." + "[-vAR] name prov ..." + }, + { "configure", G_FLAG_VERBOSE, NULL, + { + { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'P', "active_passive", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, + G_OPT_SENTINEL + }, + "[-vAPR] name" }, { "add", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, @@ -195,6 +206,8 @@ mp_label(struct gctl_req *req) } strlcpy(md.md_uuid, ptr, sizeof (md.md_uuid)); md.md_active_active = gctl_get_int(req, "active_active"); + if (gctl_get_int(req, "active_read")) + md.md_active_active = 2; free(ptr); /* Modified: stable/9/sbin/geom/class/multipath/gmultipath.8 ============================================================================== --- stable/9/sbin/geom/class/multipath/gmultipath.8 Wed May 2 07:08:04 2012 (r234915) +++ stable/9/sbin/geom/class/multipath/gmultipath.8 Wed May 2 07:17:53 2012 (r234916) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 31, 2011 +.Dd April 18, 2012 .Dt GMULTIPATH 8 .Os .Sh NAME @@ -33,15 +33,19 @@ .Sh SYNOPSIS .Nm .Cm create -.Op Fl Av +.Op Fl ARv .Ar name .Ar prov ... .Nm .Cm label -.Op Fl Av +.Op Fl ARv .Ar name .Ar prov ... .Nm +.Cm configure +.Op Fl APRv +.Ar name +.Nm .Cm add .Op Fl v .Ar name prov @@ -121,7 +125,9 @@ Kernel will only check that all given pr sector sizes. .Pp .Fl A -option enables Active/Active mode, otherwise Active/Passive mode is used +option enables Active/Active mode, +.Fl R +option enables Active/Read mode, otherwise Active/Passive mode is used by default. .It Cm label Create multipath device with @@ -134,8 +140,19 @@ It reliably protects against specifying Providers with no matching metadata detected will not be added to the device. .Pp .Fl A -option enables Active/Active mode, otherwise Active/Passive mode is used +option enables Active/Active mode, +.Fl R +option enables Active/Read mode, otherwise Active/Passive mode is used by default. +.It Cm configure +Configure the given multipath device. +.Pp +.Fl A +option enables Active/Active mode, +.Fl P +option enables Active/Passive mode, +.Fl R +option enables Active/Read mode. .It Cm add Add the given provider as a path to the given multipath device. Should normally be used only for devices created with @@ -223,7 +240,8 @@ of multiple pathnames refer to the same system operator who will use tools and knowledge of their own storage subsystem to make the correct configuration selection. .Pp -There are Active/Passive and Active/Active operation modes supported. +There are Active/Passive, Active/Read and Active/Active operation modes +supported. In Active/Passive mode only one path has I/O moving on it at any point in time. This I/O continues until an I/O is returned with @@ -233,6 +251,12 @@ in a list is selected as active and the In Active/Active mode all paths not marked FAIL may handle I/O same time. Requests are distributed between paths to equalize load. For capable devices it allows to utilize bandwidth of all paths. +In Active/Read mode all paths not marked FAIL may handle reads same time, +but unlike Active/Active only one path handles write requests at any +point in time. +It allows to closer follow original write request order if above layer +needs it for data consistency (not waiting for requisite write completion +before sending dependent write). .Pp When new devices are added to the system the .Nm MULTIPATH Modified: stable/9/sys/geom/multipath/g_multipath.c ============================================================================== --- stable/9/sys/geom/multipath/g_multipath.c Wed May 2 07:08:04 2012 (r234915) +++ stable/9/sys/geom/multipath/g_multipath.c Wed May 2 07:17:53 2012 (r234916) @@ -151,20 +151,21 @@ g_multipath_fault(struct g_consumer *cp, if (sc->sc_active == NULL) { printf("GEOM_MULTIPATH: out of providers for %s\n", sc->sc_name); - } else if (!sc->sc_active_active) { + } else if (sc->sc_active_active != 1) { printf("GEOM_MULTIPATH: %s is now active path in %s\n", sc->sc_active->provider->name, sc->sc_name); } } static struct g_consumer * -g_multipath_choose(struct g_geom *gp) +g_multipath_choose(struct g_geom *gp, struct bio *bp) { struct g_multipath_softc *sc; struct g_consumer *best, *cp; sc = gp->softc; - if (!sc->sc_active_active) + if (sc->sc_active_active == 0 || + (sc->sc_active_active == 2 && bp->bio_cmd != BIO_READ)) return (sc->sc_active); best = NULL; LIST_FOREACH(cp, &gp->consumer, consumer) { @@ -253,7 +254,7 @@ g_multipath_start(struct bio *bp) return; } mtx_lock(&sc->sc_mtx); - cp = g_multipath_choose(gp); + cp = g_multipath_choose(gp, bp); if (cp == NULL) { mtx_unlock(&sc->sc_mtx); g_destroy_bio(cbp); @@ -323,9 +324,11 @@ g_multipath_done_error(struct bio *bp) cnt = (uintptr_t *)&cp->private; mtx_lock(&sc->sc_mtx); - printf("GEOM_MULTIPATH: Error %d, %s in %s marked FAIL\n", - bp->bio_error, pp->name, sc->sc_name); - g_multipath_fault(cp, MP_FAIL); + if ((cp->index & MP_FAIL) == 0) { + printf("GEOM_MULTIPATH: Error %d, %s in %s marked FAIL\n", + bp->bio_error, pp->name, sc->sc_name); + g_multipath_fault(cp, MP_FAIL); + } (*cnt)--; if (*cnt == 0 && (cp->index & (MP_LOST | MP_POSTED)) == MP_LOST) { cp->index |= MP_POSTED; @@ -363,8 +366,10 @@ g_multipath_kt(void *arg) g_multipath_done_error(bp); mtx_lock(&gmtbq_mtx); } + if (g_multipath_kt_state != GKT_RUN) + break; msleep(&g_multipath_kt_state, &gmtbq_mtx, PRIBIO, - "gkt:wait", hz / 10); + "gkt:wait", 0); } mtx_unlock(&gmtbq_mtx); wakeup(&g_multipath_kt_state); @@ -525,7 +530,7 @@ g_multipath_add_disk(struct g_geom *gp, pp->name, sc->sc_name); if (sc->sc_active == NULL) { sc->sc_active = cp; - if (!sc->sc_active_active) + if (sc->sc_active_active != 1) printf("GEOM_MULTIPATH: %s is now active path in %s\n", pp->name, sc->sc_name); } @@ -599,7 +604,7 @@ g_multipath_rotate(struct g_geom *gp) } if (lcp) { sc->sc_active = lcp; - if (!sc->sc_active_active) + if (sc->sc_active_active != 1) printf("GEOM_MULTIPATH: %s is now active path in %s\n", lcp->provider->name, sc->sc_name); } @@ -611,8 +616,7 @@ g_multipath_init(struct g_class *mp) { bioq_init(&gmtbq); mtx_init(&gmtbq_mtx, "gmtbq", NULL, MTX_DEF); - if (kproc_create(g_multipath_kt, mp, NULL, 0, 0, "g_mp_kt") == 0) - g_multipath_kt_state = GKT_RUN; + kproc_create(g_multipath_kt, mp, NULL, 0, 0, "g_mp_kt"); } static void @@ -879,7 +883,7 @@ g_multipath_ctl_create(struct gctl_req * struct g_geom *gp; const char *mpname, *name; char param[16]; - int *nargs, i, *active_active; + int *nargs, i, *val; g_topology_assert(); @@ -908,10 +912,13 @@ g_multipath_ctl_create(struct gctl_req * md.md_size = 0; md.md_sectorsize = 0; md.md_uuid[0] = 0; - active_active = gctl_get_paraml(req, "active_active", - sizeof(*active_active)); - md.md_active_active = - (active_active == NULL || *active_active == 0) ? 0 : 1; + md.md_active_active = 0; + val = gctl_get_paraml(req, "active_active", sizeof(*val)); + if (val != NULL && *val != 0) + md.md_active_active = 1; + val = gctl_get_paraml(req, "active_read", sizeof(*val)); + if (val != NULL && *val != 0) + md.md_active_active = 2; gp = g_multipath_create(mp, &md); if (gp == NULL) { gctl_error(req, "GEOM_MULTIPATH: cannot create geom %s/%s\n", @@ -931,6 +938,67 @@ g_multipath_ctl_create(struct gctl_req * } static void +g_multipath_ctl_configure(struct gctl_req *req, struct g_class *mp) +{ + struct g_multipath_softc *sc; + struct g_geom *gp; + struct g_consumer *cp; + struct g_provider *pp; + struct g_multipath_metadata *md; + const char *name; + int error, *val; + void *buf; + + g_topology_assert(); + + name = gctl_get_asciiparam(req, "arg0"); + if (name == NULL) { + gctl_error(req, "No 'arg0' argument"); + return; + } + gp = g_multipath_find_geom(mp, name); + if (gp == NULL) { + gctl_error(req, "Device %s is invalid", name); + return; + } + sc = gp->softc; + val = gctl_get_paraml(req, "active_active", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 1; + val = gctl_get_paraml(req, "active_read", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 2; + val = gctl_get_paraml(req, "active_passive", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 0; + if (sc->sc_uuid[0] != 0 && sc->sc_active != NULL) { + cp = sc->sc_active; + pp = cp->provider; + error = g_access(cp, 1, 1, 1); + if (error != 0) { + gctl_error(req, "Can't open %s (%d)", pp->name, error); + return; + } + g_topology_unlock(); + md = buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); + strlcpy(md->md_magic, G_MULTIPATH_MAGIC, sizeof(md->md_magic)); + memcpy(md->md_uuid, sc->sc_uuid, sizeof (sc->sc_uuid)); + strlcpy(md->md_name, name, sizeof(md->md_name)); + md->md_version = G_MULTIPATH_VERSION; + md->md_size = pp->mediasize; + md->md_sectorsize = pp->sectorsize; + md->md_active_active = sc->sc_active_active; + error = g_write_data(cp, pp->mediasize - pp->sectorsize, + buf, pp->sectorsize); + g_topology_lock(); + g_access(cp, -1, -1, -1); + if (error != 0) + gctl_error(req, "Can't update metadata on %s (%d)", + pp->name, error); + } +} + +static void g_multipath_ctl_fail(struct gctl_req *req, struct g_class *mp, int fail) { struct g_multipath_softc *sc; @@ -964,6 +1032,8 @@ g_multipath_ctl_fail(struct gctl_req *re strcmp(cp->provider->name, name) == 0 && (cp->index & MP_LOST) == 0) { found = 1; + if (!fail == !(cp->index & MP_FAIL)) + continue; printf("GEOM_MULTIPATH: %s in %s is marked %s.\n", name, sc->sc_name, fail ? "FAIL" : "OK"); if (fail) { @@ -1172,7 +1242,7 @@ g_multipath_ctl_getactive(struct gctl_re return; } sc = gp->softc; - if (sc->sc_active_active) { + if (sc->sc_active_active == 1) { empty = 1; LIST_FOREACH(cp, &gp->consumer, consumer) { if (cp->index & MP_BAD) @@ -1209,6 +1279,8 @@ g_multipath_config(struct gctl_req *req, g_multipath_ctl_add(req, mp); } else if (strcmp(verb, "create") == 0) { g_multipath_ctl_create(req, mp); + } else if (strcmp(verb, "configure") == 0) { + g_multipath_ctl_configure(req, mp); } else if (strcmp(verb, "stop") == 0) { g_multipath_ctl_stop(req, mp); } else if (strcmp(verb, "destroy") == 0) { @@ -1245,8 +1317,9 @@ g_multipath_dumpconf(struct sbuf *sb, co (cp->index & MP_NEW) ? "NEW" : (cp->index & MP_LOST) ? "LOST" : (cp->index & MP_FAIL) ? "FAIL" : - (sc->sc_active_active || sc->sc_active == cp) ? - "ACTIVE" : "PASSIVE"); + (sc->sc_active_active == 1 || sc->sc_active == cp) ? + "ACTIVE" : + sc->sc_active_active == 2 ? "READ" : "PASSIVE"); } else { good = g_multipath_good(gp); sbuf_printf(sb, "%s%s", indent, @@ -1257,7 +1330,8 @@ g_multipath_dumpconf(struct sbuf *sb, co if (cp == NULL && pp == NULL) { sbuf_printf(sb, "%s%s", indent, sc->sc_uuid); sbuf_printf(sb, "%sActive/%s", indent, - sc->sc_active_active ? "Active" : "Passive"); + sc->sc_active_active == 2 ? "Read" : + sc->sc_active_active == 1 ? "Active" : "Passive"); sbuf_printf(sb, "%s%s", indent, sc->sc_uuid[0] == 0 ? "MANUAL" : "AUTOMATIC"); } From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:22:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46AAE1065765; Wed, 2 May 2012 07:22:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 265DE8FC0A; Wed, 2 May 2012 07:22:59 +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 q427Mxw2071212; Wed, 2 May 2012 07:22:59 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427MxQo071208; Wed, 2 May 2012 07:22:59 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205020722.q427MxQo071208@svn.freebsd.org> From: Alexander Motin Date: Wed, 2 May 2012 07:22:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234917 - in stable/8: sbin/geom/class/multipath sys/geom/multipath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:22:59 -0000 Author: mav Date: Wed May 2 07:22:58 2012 New Revision: 234917 URL: http://svn.freebsd.org/changeset/base/234917 Log: MFC r234415: Some improvements to GEOM MULTIPATH: - Implement "configure" command to allow switching operation mode of running device on-fly without destroying and recreation. - Implement Active/Read mode as hybrid of Active/Active and Active/Passive. In this mode all paths not marked FAIL may handle reads same time, but unlike Active/Active only one path handles write requests at any point in time. It allows to closer follow original write request order if above layers need it for data consistency (not waiting for requisite write completion before sending dependent write). - Hide duplicate messages about device status change. - Remove periodic thread wake up with 10Hz rate. Sponsored by: iXsystems, Inc. Modified: stable/8/sbin/geom/class/multipath/geom_multipath.c stable/8/sbin/geom/class/multipath/gmultipath.8 stable/8/sys/geom/multipath/g_multipath.c Directory Properties: stable/8/sbin/geom/ (props changed) stable/8/sbin/geom/class/multipath/ (props changed) stable/8/sys/ (props changed) Modified: stable/8/sbin/geom/class/multipath/geom_multipath.c ============================================================================== --- stable/8/sbin/geom/class/multipath/geom_multipath.c Wed May 2 07:17:53 2012 (r234916) +++ stable/8/sbin/geom/class/multipath/geom_multipath.c Wed May 2 07:22:58 2012 (r234917) @@ -55,17 +55,28 @@ struct g_command class_commands[] = { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - NULL, "[-vA] name prov ..." + NULL, "[-vAR] name prov ..." }, { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, { { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - NULL, "[-vA] name prov ..." + NULL, "[-vAR] name prov ..." + }, + { "configure", G_FLAG_VERBOSE, NULL, + { + { 'A', "active_active", NULL, G_TYPE_BOOL }, + { 'P', "active_passive", NULL, G_TYPE_BOOL }, + { 'R', "active_read", NULL, G_TYPE_BOOL }, + G_OPT_SENTINEL + }, + NULL, "[-vAPR] name" }, { "add", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, @@ -195,6 +206,8 @@ mp_label(struct gctl_req *req) } strlcpy(md.md_uuid, ptr, sizeof (md.md_uuid)); md.md_active_active = gctl_get_int(req, "active_active"); + if (gctl_get_int(req, "active_read")) + md.md_active_active = 2; free(ptr); /* Modified: stable/8/sbin/geom/class/multipath/gmultipath.8 ============================================================================== --- stable/8/sbin/geom/class/multipath/gmultipath.8 Wed May 2 07:17:53 2012 (r234916) +++ stable/8/sbin/geom/class/multipath/gmultipath.8 Wed May 2 07:22:58 2012 (r234917) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 31, 2011 +.Dd April 18, 2012 .Dt GMULTIPATH 8 .Os .Sh NAME @@ -33,15 +33,19 @@ .Sh SYNOPSIS .Nm .Cm create -.Op Fl Av +.Op Fl ARv .Ar name .Ar prov ... .Nm .Cm label -.Op Fl Av +.Op Fl ARv .Ar name .Ar prov ... .Nm +.Cm configure +.Op Fl APRv +.Ar name +.Nm .Cm add .Op Fl v .Ar name prov @@ -121,7 +125,9 @@ Kernel will only check that all given pr sector sizes. .Pp .Fl A -option enables Active/Active mode, otherwise Active/Passive mode is used +option enables Active/Active mode, +.Fl R +option enables Active/Read mode, otherwise Active/Passive mode is used by default. .It Cm label Create multipath device with @@ -134,8 +140,19 @@ It reliably protects against specifying Providers with no matching metadata detected will not be added to the device. .Pp .Fl A -option enables Active/Active mode, otherwise Active/Passive mode is used +option enables Active/Active mode, +.Fl R +option enables Active/Read mode, otherwise Active/Passive mode is used by default. +.It Cm configure +Configure the given multipath device. +.Pp +.Fl A +option enables Active/Active mode, +.Fl P +option enables Active/Passive mode, +.Fl R +option enables Active/Read mode. .It Cm add Add the given provider as a path to the given multipath device. Should normally be used only for devices created with @@ -223,7 +240,8 @@ of multiple pathnames refer to the same system operator who will use tools and knowledge of their own storage subsystem to make the correct configuration selection. .Pp -There are Active/Passive and Active/Active operation modes supported. +There are Active/Passive, Active/Read and Active/Active operation modes +supported. In Active/Passive mode only one path has I/O moving on it at any point in time. This I/O continues until an I/O is returned with @@ -233,6 +251,12 @@ in a list is selected as active and the In Active/Active mode all paths not marked FAIL may handle I/O same time. Requests are distributed between paths to equalize load. For capable devices it allows to utilize bandwidth of all paths. +In Active/Read mode all paths not marked FAIL may handle reads same time, +but unlike Active/Active only one path handles write requests at any +point in time. +It allows to closer follow original write request order if above layer +needs it for data consistency (not waiting for requisite write completion +before sending dependent write). .Pp When new devices are added to the system the .Nm MULTIPATH Modified: stable/8/sys/geom/multipath/g_multipath.c ============================================================================== --- stable/8/sys/geom/multipath/g_multipath.c Wed May 2 07:17:53 2012 (r234916) +++ stable/8/sys/geom/multipath/g_multipath.c Wed May 2 07:22:58 2012 (r234917) @@ -149,20 +149,21 @@ g_multipath_fault(struct g_consumer *cp, if (sc->sc_active == NULL) { printf("GEOM_MULTIPATH: out of providers for %s\n", sc->sc_name); - } else if (!sc->sc_active_active) { + } else if (sc->sc_active_active != 1) { printf("GEOM_MULTIPATH: %s is now active path in %s\n", sc->sc_active->provider->name, sc->sc_name); } } static struct g_consumer * -g_multipath_choose(struct g_geom *gp) +g_multipath_choose(struct g_geom *gp, struct bio *bp) { struct g_multipath_softc *sc; struct g_consumer *best, *cp; sc = gp->softc; - if (!sc->sc_active_active) + if (sc->sc_active_active == 0 || + (sc->sc_active_active == 2 && bp->bio_cmd != BIO_READ)) return (sc->sc_active); best = NULL; LIST_FOREACH(cp, &gp->consumer, consumer) { @@ -251,7 +252,7 @@ g_multipath_start(struct bio *bp) return; } mtx_lock(&sc->sc_mtx); - cp = g_multipath_choose(gp); + cp = g_multipath_choose(gp, bp); if (cp == NULL) { mtx_unlock(&sc->sc_mtx); g_destroy_bio(cbp); @@ -321,9 +322,11 @@ g_multipath_done_error(struct bio *bp) cnt = (uintptr_t *)&cp->private; mtx_lock(&sc->sc_mtx); - printf("GEOM_MULTIPATH: Error %d, %s in %s marked FAIL\n", - bp->bio_error, pp->name, sc->sc_name); - g_multipath_fault(cp, MP_FAIL); + if ((cp->index & MP_FAIL) == 0) { + printf("GEOM_MULTIPATH: Error %d, %s in %s marked FAIL\n", + bp->bio_error, pp->name, sc->sc_name); + g_multipath_fault(cp, MP_FAIL); + } (*cnt)--; if (*cnt == 0 && (cp->index & (MP_LOST | MP_POSTED)) == MP_LOST) { cp->index |= MP_POSTED; @@ -361,8 +364,10 @@ g_multipath_kt(void *arg) g_multipath_done_error(bp); mtx_lock(&gmtbq_mtx); } + if (g_multipath_kt_state != GKT_RUN) + break; msleep(&g_multipath_kt_state, &gmtbq_mtx, PRIBIO, - "gkt:wait", hz / 10); + "gkt:wait", 0); } mtx_unlock(&gmtbq_mtx); wakeup(&g_multipath_kt_state); @@ -523,7 +528,7 @@ g_multipath_add_disk(struct g_geom *gp, pp->name, sc->sc_name); if (sc->sc_active == NULL) { sc->sc_active = cp; - if (!sc->sc_active_active) + if (sc->sc_active_active != 1) printf("GEOM_MULTIPATH: %s is now active path in %s\n", pp->name, sc->sc_name); } @@ -597,7 +602,7 @@ g_multipath_rotate(struct g_geom *gp) } if (lcp) { sc->sc_active = lcp; - if (!sc->sc_active_active) + if (sc->sc_active_active != 1) printf("GEOM_MULTIPATH: %s is now active path in %s\n", lcp->provider->name, sc->sc_name); } @@ -609,8 +614,7 @@ g_multipath_init(struct g_class *mp) { bioq_init(&gmtbq); mtx_init(&gmtbq_mtx, "gmtbq", NULL, MTX_DEF); - if (kproc_create(g_multipath_kt, mp, NULL, 0, 0, "g_mp_kt") == 0) - g_multipath_kt_state = GKT_RUN; + kproc_create(g_multipath_kt, mp, NULL, 0, 0, "g_mp_kt"); } static void @@ -877,7 +881,7 @@ g_multipath_ctl_create(struct gctl_req * struct g_geom *gp; const char *mpname, *name; char param[16]; - int *nargs, i, *active_active; + int *nargs, i, *val; g_topology_assert(); @@ -906,10 +910,13 @@ g_multipath_ctl_create(struct gctl_req * md.md_size = 0; md.md_sectorsize = 0; md.md_uuid[0] = 0; - active_active = gctl_get_paraml(req, "active_active", - sizeof(*active_active)); - md.md_active_active = - (active_active == NULL || *active_active == 0) ? 0 : 1; + md.md_active_active = 0; + val = gctl_get_paraml(req, "active_active", sizeof(*val)); + if (val != NULL && *val != 0) + md.md_active_active = 1; + val = gctl_get_paraml(req, "active_read", sizeof(*val)); + if (val != NULL && *val != 0) + md.md_active_active = 2; gp = g_multipath_create(mp, &md); if (gp == NULL) { gctl_error(req, "GEOM_MULTIPATH: cannot create geom %s/%s\n", @@ -929,6 +936,67 @@ g_multipath_ctl_create(struct gctl_req * } static void +g_multipath_ctl_configure(struct gctl_req *req, struct g_class *mp) +{ + struct g_multipath_softc *sc; + struct g_geom *gp; + struct g_consumer *cp; + struct g_provider *pp; + struct g_multipath_metadata *md; + const char *name; + int error, *val; + void *buf; + + g_topology_assert(); + + name = gctl_get_asciiparam(req, "arg0"); + if (name == NULL) { + gctl_error(req, "No 'arg0' argument"); + return; + } + gp = g_multipath_find_geom(mp, name); + if (gp == NULL) { + gctl_error(req, "Device %s is invalid", name); + return; + } + sc = gp->softc; + val = gctl_get_paraml(req, "active_active", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 1; + val = gctl_get_paraml(req, "active_read", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 2; + val = gctl_get_paraml(req, "active_passive", sizeof(*val)); + if (val != NULL && *val != 0) + sc->sc_active_active = 0; + if (sc->sc_uuid[0] != 0 && sc->sc_active != NULL) { + cp = sc->sc_active; + pp = cp->provider; + error = g_access(cp, 1, 1, 1); + if (error != 0) { + gctl_error(req, "Can't open %s (%d)", pp->name, error); + return; + } + g_topology_unlock(); + md = buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); + strlcpy(md->md_magic, G_MULTIPATH_MAGIC, sizeof(md->md_magic)); + memcpy(md->md_uuid, sc->sc_uuid, sizeof (sc->sc_uuid)); + strlcpy(md->md_name, name, sizeof(md->md_name)); + md->md_version = G_MULTIPATH_VERSION; + md->md_size = pp->mediasize; + md->md_sectorsize = pp->sectorsize; + md->md_active_active = sc->sc_active_active; + error = g_write_data(cp, pp->mediasize - pp->sectorsize, + buf, pp->sectorsize); + g_topology_lock(); + g_access(cp, -1, -1, -1); + if (error != 0) + gctl_error(req, "Can't update metadata on %s (%d)", + pp->name, error); + } +} + +static void g_multipath_ctl_fail(struct gctl_req *req, struct g_class *mp, int fail) { struct g_multipath_softc *sc; @@ -962,6 +1030,8 @@ g_multipath_ctl_fail(struct gctl_req *re strcmp(cp->provider->name, name) == 0 && (cp->index & MP_LOST) == 0) { found = 1; + if (!fail == !(cp->index & MP_FAIL)) + continue; printf("GEOM_MULTIPATH: %s in %s is marked %s.\n", name, sc->sc_name, fail ? "FAIL" : "OK"); if (fail) { @@ -1170,7 +1240,7 @@ g_multipath_ctl_getactive(struct gctl_re return; } sc = gp->softc; - if (sc->sc_active_active) { + if (sc->sc_active_active == 1) { empty = 1; LIST_FOREACH(cp, &gp->consumer, consumer) { if (cp->index & MP_BAD) @@ -1207,6 +1277,8 @@ g_multipath_config(struct gctl_req *req, g_multipath_ctl_add(req, mp); } else if (strcmp(verb, "create") == 0) { g_multipath_ctl_create(req, mp); + } else if (strcmp(verb, "configure") == 0) { + g_multipath_ctl_configure(req, mp); } else if (strcmp(verb, "stop") == 0) { g_multipath_ctl_stop(req, mp); } else if (strcmp(verb, "destroy") == 0) { @@ -1243,8 +1315,9 @@ g_multipath_dumpconf(struct sbuf *sb, co (cp->index & MP_NEW) ? "NEW" : (cp->index & MP_LOST) ? "LOST" : (cp->index & MP_FAIL) ? "FAIL" : - (sc->sc_active_active || sc->sc_active == cp) ? - "ACTIVE" : "PASSIVE"); + (sc->sc_active_active == 1 || sc->sc_active == cp) ? + "ACTIVE" : + sc->sc_active_active == 2 ? "READ" : "PASSIVE"); } else { good = g_multipath_good(gp); sbuf_printf(sb, "%s%s", indent, @@ -1255,7 +1328,8 @@ g_multipath_dumpconf(struct sbuf *sb, co if (cp == NULL && pp == NULL) { sbuf_printf(sb, "%s%s", indent, sc->sc_uuid); sbuf_printf(sb, "%sActive/%s", indent, - sc->sc_active_active ? "Active" : "Passive"); + sc->sc_active_active == 2 ? "Read" : + sc->sc_active_active == 1 ? "Active" : "Passive"); sbuf_printf(sb, "%s%s", indent, sc->sc_uuid[0] == 0 ? "MANUAL" : "AUTOMATIC"); } From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:41:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C23DD106564A; Wed, 2 May 2012 07:41:26 +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 AD54A8FC08; Wed, 2 May 2012 07:41: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 q427fQqF071892; Wed, 2 May 2012 07:41:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427fQP7071890; Wed, 2 May 2012 07:41:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020741.q427fQP7071890@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 07:41: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: r234918 - head/sys/mips/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:41:26 -0000 Author: adrian Date: Wed May 2 07:41:26 2012 New Revision: 234918 URL: http://svn.freebsd.org/changeset/base/234918 Log: Disable the pll_1000 hint for now, the upcoming work enables it and it breaks without the switch PHY code. Modified: head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Wed May 2 07:22:58 2012 (r234917) +++ head/sys/mips/conf/AP96.hints Wed May 2 07:41:26 2012 (r234918) @@ -23,7 +23,7 @@ hint.arge.0.mdio=mdioproxy0 # TODO: RGMII hint.arge.1.phymask=0x10 -hint.arge.1.pll_1000 = 0x1f000000 +# hint.arge.1.pll_1000 = 0x1f000000 # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. hint.arge.1.miimode=3 # RGMII From owner-svn-src-all@FreeBSD.ORG Wed May 2 07:43:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A4B0106566C; Wed, 2 May 2012 07:43:12 +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 E7C768FC12; Wed, 2 May 2012 07:43:11 +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 q427hB5U071994; Wed, 2 May 2012 07:43:11 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427hBCe071991; Wed, 2 May 2012 07:43:11 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020743.q427hBCe071991@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 07:43:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234919 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:43:12 -0000 Author: adrian Date: Wed May 2 07:43:11 2012 New Revision: 234919 URL: http://svn.freebsd.org/changeset/base/234919 Log: Implement PLL configuration override support, similar to what openwrt implements. Modified: head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 07:41:26 2012 (r234918) +++ head/sys/mips/atheros/if_arge.c Wed May 2 07:43:11 2012 (r234919) @@ -101,6 +101,7 @@ typedef enum { ARGE_DBG_RX = 0x00000008, ARGE_DBG_ERR = 0x00000010, ARGE_DBG_RESET = 0x00000020, + ARGE_DBG_PLL = 0x00000040, } arge_debug_flags; static const char * arge_miicfg_str[] = { @@ -331,6 +332,34 @@ arge_reset_miibus(struct arge_softc *sc) DELAY(100); } +static void +arge_fetch_pll_config(struct arge_softc *sc) +{ + long int val; + + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_10", &val) == 0) { + sc->arge_pllcfg.pll_10 = val; + device_printf(sc->arge_dev, "%s: pll_10 = 0x%x\n", + __func__, (int) val); + } + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_100", &val) == 0) { + sc->arge_pllcfg.pll_100 = val; + device_printf(sc->arge_dev, "%s: pll_100 = 0x%x\n", + __func__, (int) val); + } + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_1000", &val) == 0) { + sc->arge_pllcfg.pll_1000 = val; + device_printf(sc->arge_dev, "%s: pll_1000 = 0x%x\n", + __func__, (int) val); + } +} + static int arge_attach(device_t dev) { @@ -372,6 +401,11 @@ arge_attach(device_t dev) ("if_arge: Only MAC0 and MAC1 supported")); /* + * Fetch the PLL configuration. + */ + arge_fetch_pll_config(sc); + + /* * Get the MII configuration, if applicable. */ if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -821,7 +855,7 @@ arge_set_pll(struct arge_softc *sc, int uint32_t fifo_tx, pll; int if_speed; - ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, + ARGEDEBUG(sc, ARGE_DBG_PLL, "set_pll(%04x, %s)\n", media, duplex == IFM_FDX ? "full" : "half"); cfg = ARGE_READ(sc, AR71XX_MAC_CFG2); cfg &= ~(MAC_CFG2_IFACE_MODE_1000 @@ -859,7 +893,7 @@ arge_set_pll(struct arge_softc *sc, int "Unknown media %d\n", media); } - ARGEDEBUG(sc, ARGE_DBG_MII, "%s: if_speed=%d\n", __func__, if_speed); + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: if_speed=%d\n", __func__, if_speed); switch (ar71xx_soc) { case AR71XX_SOC_AR7240: @@ -881,8 +915,18 @@ arge_set_pll(struct arge_softc *sc, int rx_filtmask); ARGE_WRITE(sc, AR71XX_MAC_FIFO_TX_THRESHOLD, fifo_tx); - /* set PLL registers */ + /* fetch PLL registers */ pll = ar71xx_device_get_eth_pll(sc->arge_mac_unit, if_speed); + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: pll=0x%x\n", __func__, pll); + + /* Override if required by platform data */ + if (if_speed == 10 && sc->arge_pllcfg.pll_10 != 0) + pll = sc->arge_pllcfg.pll_10; + else if (if_speed == 100 && sc->arge_pllcfg.pll_100 != 0) + pll = sc->arge_pllcfg.pll_100; + else if (if_speed == 1000 && sc->arge_pllcfg.pll_1000 != 0) + pll = sc->arge_pllcfg.pll_1000; + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: final pll=0x%x\n", __func__, pll); /* XXX ensure pll != 0 */ ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Wed May 2 07:41:26 2012 (r234918) +++ head/sys/mips/atheros/if_argevar.h Wed May 2 07:43:11 2012 (r234919) @@ -118,6 +118,15 @@ struct arge_ring_data { bus_addr_t arge_tx_ring_paddr; }; +/* + * Allow PLL values to be overridden. + */ +struct arge_pll_data { + uint32_t pll_10; + uint32_t pll_100; + uint32_t pll_1000; +}; + struct arge_softc { struct ifnet *arge_ifp; /* interface info */ device_t arge_dev; @@ -136,6 +145,7 @@ struct arge_softc { device_t arge_miibus; device_t arge_miiproxy; ar71xx_mii_mode arge_miicfg; + struct arge_pll_data arge_pllcfg; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; From owner-svn-src-all@FreeBSD.ORG Wed May 2 08:10:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E86C1065672; Wed, 2 May 2012 08:10:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 669E58FC0A; Wed, 2 May 2012 08:10:16 +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 q428AG9f073073; Wed, 2 May 2012 08:10:16 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q428AGwg073067; Wed, 2 May 2012 08:10:16 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205020810.q428AGwg073067@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 08:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234920 - in head/sys: dev/gxemul dev/gxemul/cons mips/conf mips/gxemul X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 08:10:16 -0000 Author: rwatson Date: Wed May 2 08:10:15 2012 New Revision: 234920 URL: http://svn.freebsd.org/changeset/base/234920 Log: Merge a rudimentary gxemul "oldtestmips" port. This consists almost entirely of one machdep file lifted from the MALTA port, as well as a low-level console and tty driver for the gxemul debugging console device (the emulators stdio). As with many low-level embedded and hypervisor console devices, it is polled only, so we drive TTY I/O from a callout; we are perhaps a bit too aware of the MIPS physical maps in order to attach the console before newbus comes to life. The sample kernel configuration depends on an MD-based root file system, which is not provided. However, any 64-bit, big-endian userspace image (such as one generated for MALTA) should work. This will hopefully be supplemented by additional device drivers for gxemul-specific hardware simulations from Juli Mallett. We have found oldtestmips quite useful for testing and improving aspects of the MIPS port, so it's worth supporting better in FreeBSD. Requested by: theraven, jmallett Sponsored by: DARPA, AFRL MFC after: 3 weeks Added: head/sys/dev/gxemul/ head/sys/dev/gxemul/cons/ head/sys/dev/gxemul/cons/gxemul_cons.c (contents, props changed) head/sys/mips/conf/GXEMUL (contents, props changed) head/sys/mips/conf/GXEMUL.hints (contents, props changed) head/sys/mips/gxemul/ head/sys/mips/gxemul/files.gxemul (contents, props changed) head/sys/mips/gxemul/gxemul_machdep.c (contents, props changed) head/sys/mips/gxemul/std.gxemul (contents, props changed) Added: head/sys/dev/gxemul/cons/gxemul_cons.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/gxemul/cons/gxemul_cons.c Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,334 @@ +/*- + * Copyright (c) 2011-2012 Robert N. M. Watson + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define GC_LOCK_INIT() mtx_init(&gc_lock, "gc_lock", NULL, MTX_SPIN) + +#define GC_LOCK() do { \ + if (!kdb_active) \ + mtx_lock_spin(&gc_lock); \ +} while (0) + +#define GC_LOCK_ASSERT() do { \ + if (!kdb_active) \ + mtx_assert(&gc_lock, MA_OWNED); \ +} while (0) + +#define GC_UNLOCK() do { \ + if (!kdb_active) \ + mtx_unlock_spin(&gc_lock); \ +} while (0) + + +static struct mtx gc_lock; + +/* + * Low-level console driver functions. + */ +static cn_probe_t gxemul_cons_cnprobe; +static cn_init_t gxemul_cons_cninit; +static cn_term_t gxemul_cons_cnterm; +static cn_getc_t gxemul_cons_cngetc; +static cn_putc_t gxemul_cons_cnputc; +static cn_grab_t gxemul_cons_cngrab; +static cn_ungrab_t gxemul_cons_cnungrab; + +/* + * TTY-level fields. + */ +static tsw_outwakeup_t gxemul_cons_outwakeup; + +static struct ttydevsw gxemul_cons_ttydevsw = { + .tsw_flags = TF_NOPREFIX, + .tsw_outwakeup = gxemul_cons_outwakeup, +}; + +static struct callout gxemul_cons_callout; +static u_int gxemul_cons_polltime = 10; +#ifdef KDB +static int gxemul_cons_alt_break_state; +#endif + +static void gxemul_cons_timeout(void *); + +/* + * I/O routines lifted from Deimos. + * + * XXXRW: Should be using FreeBSD's bus routines here, but they are not + * available until later in the boot. + */ +#define MIPS_XKPHYS_UNCACHED_BASE 0x9000000000000000 + +typedef uint64_t paddr_t; +typedef uint64_t vaddr_t; + +static inline vaddr_t +mips_phys_to_uncached(paddr_t phys) +{ + + return (phys | MIPS_XKPHYS_UNCACHED_BASE); +} + +static inline uint8_t +mips_ioread_uint8(vaddr_t vaddr) +{ + uint8_t v; + + __asm__ __volatile__ ("lbu %0, 0(%1)" : "=r" (v) : "r" (vaddr)); + return (v); +} + +static inline void +mips_iowrite_uint8(vaddr_t vaddr, uint8_t v) +{ + + __asm__ __volatile__ ("sb %0, 0(%1)" : : "r" (v), "r" (vaddr)); +} + +/* + * gxemul-specific constants. + */ +#define GXEMUL_CONS_BASE 0x10000000 /* gxemul console device. */ + +/* + * Routines for interacting with the gxemul test console. Programming details + * are a result of manually inspecting the source code for gxemul's + * dev_cons.cc and dev_cons.h. + * + * Offsets of I/O channels relative to the base. + */ +#define GXEMUL_PUTGETCHAR_OFF 0x00000000 +#define GXEMUL_CONS_HALT 0x00000010 + +/* + * One-byte buffer as we can't check whether the console is readable without + * actually reading from it. + */ +static char buffer_data; +static int buffer_valid; + +/* + * Low-level read and write routines. + */ +static inline uint8_t +gxemul_cons_data_read(void) +{ + + return (mips_ioread_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE + + GXEMUL_PUTGETCHAR_OFF))); +} + +static inline void +gxemul_cons_data_write(uint8_t v) +{ + + mips_iowrite_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE + + GXEMUL_PUTGETCHAR_OFF), v); +} + +static int +gxemul_cons_writable(void) +{ + + return (1); +} + +static int +gxemul_cons_readable(void) +{ + uint32_t v; + + GC_LOCK_ASSERT(); + + if (buffer_valid) + return (1); + v = gxemul_cons_data_read(); + if (v != 0) { + buffer_valid = 1; + buffer_data = v; + return (1); + } + return (0); +} + +static void +gxemul_cons_write(char ch) +{ + + GC_LOCK_ASSERT(); + + while (!gxemul_cons_writable()); + gxemul_cons_data_write(ch); +} + +static char +gxemul_cons_read(void) +{ + + GC_LOCK_ASSERT(); + + while (!gxemul_cons_readable()); + buffer_valid = 0; + return (buffer_data); +} + +/* + * Implementation of a FreeBSD low-level, polled console driver. + */ +static void +gxemul_cons_cnprobe(struct consdev *cp) +{ + + sprintf(cp->cn_name, "gxcons"); + cp->cn_pri = CN_NORMAL; +} + +static void +gxemul_cons_cninit(struct consdev *cp) +{ + + GC_LOCK_INIT(); +} + +static void +gxemul_cons_cnterm(struct consdev *cp) +{ + +} + +static int +gxemul_cons_cngetc(struct consdev *cp) +{ + int ret; + + GC_LOCK(); + ret = gxemul_cons_read(); + GC_UNLOCK(); + return (ret); +} + +static void +gxemul_cons_cnputc(struct consdev *cp, int c) +{ + + GC_LOCK(); + gxemul_cons_write(c); + GC_UNLOCK(); +} + +static void +gxemul_cons_cngrab(struct consdev *cp) +{ + +} + +static void +gxemul_cons_cnungrab(struct consdev *cp) +{ + +} + +CONSOLE_DRIVER(gxemul_cons); + +/* + * TTY-level functions for gxemul_cons. + */ +static void +gxemul_cons_ttyinit(void *unused) +{ + struct tty *tp; + + tp = tty_alloc(&gxemul_cons_ttydevsw, NULL); + tty_init_console(tp, 0); + tty_makedev(tp, NULL, "%s", "gxcons"); + callout_init(&gxemul_cons_callout, CALLOUT_MPSAFE); + callout_reset(&gxemul_cons_callout, gxemul_cons_polltime, + gxemul_cons_timeout, tp); + +} +SYSINIT(gxemul_cons_ttyinit, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, + gxemul_cons_ttyinit, NULL); + +static void +gxemul_cons_outwakeup(struct tty *tp) +{ + int len; + u_char ch; + + /* + * XXXRW: Would be nice not to do blocking writes to the console here, + * rescheduling on our timer tick if work remains to be done.. + */ + for (;;) { + len = ttydisc_getc(tp, &ch, sizeof(ch)); + if (len == 0) + break; + GC_LOCK(); + gxemul_cons_write(ch); + GC_UNLOCK(); + } +} + +static void +gxemul_cons_timeout(void *v) +{ + struct tty *tp; + int c; + + tp = v; + tty_lock(tp); + GC_LOCK(); + while (gxemul_cons_readable()) { + c = gxemul_cons_read(); + GC_UNLOCK(); +#ifdef KDB + kdb_alt_break(c, &gxemul_cons_alt_break_state); +#endif + ttydisc_rint(tp, c, 0); + GC_LOCK(); + } + GC_UNLOCK(); + ttydisc_rint_done(tp); + tty_unlock(tp); + callout_reset(&gxemul_cons_callout, gxemul_cons_polltime, + gxemul_cons_timeout, tp); +} Added: head/sys/mips/conf/GXEMUL ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/GXEMUL Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,52 @@ +# +# GXEMUL "oldtestmips" sample kernel configuration. +# +# $FreeBSD$ +# + +ident GXEMUL + +machine mips mips64eb +cpu CPU_MIPS4KC + +options HZ=100 + +makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" + +makeoptions KERNLOADADDR=0xffffffff80100000 + +include "../gxemul/std.gxemul" + +hints "GXEMUL.hints" #Default places to look for devices. + +makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols + +makeoptions MODULES_OVERRIDE="" + +options DDB +options KDB + +options SCHED_ULE + +options FFS #Berkeley Fast Filesystem + +# Debugging for use in -current +#options DEADLKRES #Enable the deadlock resolver +options INVARIANTS #Enable calls of extra sanity checking +options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed + +# +# This kernel configuration uses an embedded 8MB memory root file system. +# Adjust the following path based on local requirements. +# +options MD_ROOT # MD is a potential root device +options MD_ROOT_SIZE=8192 +#makeoptions MFS_IMAGE=/local/scratch/rnw24/mdroot.img +options ROOTDEVNAME=\"ufs:md0\" + +device gxemul_cons +device md +device loop +device random Added: head/sys/mips/conf/GXEMUL.hints ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/GXEMUL.hints Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1 @@ +# $FreeBSD$ Added: head/sys/mips/gxemul/files.gxemul ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/files.gxemul Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,5 @@ +# $FreeBSD$ +dev/gxemul/cons/gxemul_cons.c optional gxemul_cons +mips/gxemul/gxemul_machdep.c standard +mips/mips/intr_machdep.c standard +mips/mips/tick.c standard Added: head/sys/mips/gxemul/gxemul_machdep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,191 @@ +/*- + * Copyright (c) 2006 Wojciech A. Koszek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +extern int *edata; +extern int *end; + +void +platform_cpu_init() +{ + /* Nothing special */ +} + +static void +mips_init(void) +{ + int i; + + for (i = 0; i < 10; i++) { + phys_avail[i] = 0; + } + + /* phys_avail regions are in bytes */ + phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); + phys_avail[1] = ctob(realmem); + + dump_avail[0] = phys_avail[0]; + dump_avail[1] = phys_avail[1]; + + physmem = realmem; + + init_param1(); + init_param2(physmem); + mips_cpu_init(); + pmap_bootstrap(); + mips_proc0_init(); + mutex_init(); + kdb_init(); +#ifdef KDB + if (boothowto & RB_KDB) + kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); +#endif +} + +void +platform_halt(void) +{ + +} + + +void +platform_identify(void) +{ + +} + +/* + * Perform a board-level soft-reset. + * + * XXXRW: Does gxemul have a moral equivalent to board-level reset? + */ +void +platform_reset(void) +{ + + panic("%s: not yet", __func__); +} + +void +platform_trap_enter(void) +{ + +} + +void +platform_trap_exit(void) +{ + +} + +void +platform_start(__register_t a0, __register_t a1, __register_t a2, + __register_t a3) +{ + vm_offset_t kernend; + uint64_t platform_counter_freq; + int argc = a0; + char **argv = (char **)a1; + char **envp = (char **)a2; + unsigned int memsize = a3; + int i; + + /* clear the BSS and SBSS segments */ + kernend = (vm_offset_t)&end; + memset(&edata, 0, kernend - (vm_offset_t)(&edata)); + + mips_postboot_fixup(); + + mips_pcpu0_init(); + + /* + * XXXRW: Support for the gxemul real-time clock required in order to + * usefully determine our emulated timer frequency. Go with something + * classic as the default in the mean time. + */ + platform_counter_freq = MIPS_DEFAULT_HZ; + mips_timer_early_init(platform_counter_freq); + + cninit(); + printf("entry: platform_start()\n"); + + bootverbose = 1; + if (bootverbose) { + printf("cmd line: "); + for (i = 0; i < argc; i++) + printf("%s ", argv[i]); + printf("\n"); + + printf("envp:\n"); + for (i = 0; envp[i]; i += 2) + printf("\t%s = %s\n", envp[i], envp[i+1]); + + printf("memsize = %08x\n", memsize); + } + + realmem = btoc(memsize); + mips_init(); + + mips_timer_init_params(platform_counter_freq, 0); +} Added: head/sys/mips/gxemul/std.gxemul ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/std.gxemul Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,4 @@ +# $FreeBSD$ +files "../gxemul/files.gxemul" + +cpu CPU_MIPS4KC From owner-svn-src-all@FreeBSD.ORG Wed May 2 08:23:53 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AD149106564A; Wed, 2 May 2012 08:23:53 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 978818FC12; Wed, 2 May 2012 08:23: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 q428Nrd9073556; Wed, 2 May 2012 08:23:53 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q428Nrbe073554; Wed, 2 May 2012 08:23:53 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205020823.q428Nrbe073554@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 08:23: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: r234921 - head/sys/mips/mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 08:23:53 -0000 Author: rwatson Date: Wed May 2 08:23:53 2012 New Revision: 234921 URL: http://svn.freebsd.org/changeset/base/234921 Log: Clean up various aspects of the MIPS generic busspace implementation: 1) Always implement missing bus space methods using a panic() stub rather than a NULL pointer. This appeared not to trip up any existing device drivers, but due to the nature of the devices I'm supporting locally, I'm making use of some of the more obscure busspace methods, and panic() is a preferred failure mode. For example, do this for the setregion methods. 2) Hook up several existing busspace method implementations that were provided in the file, but not actually present in the methods structure. Especially, single-byte bus I/O routines. This should allow bugs to be fixed in the Atheros 802.11 driver. There are still some remaining unimplemented methods that would be desirable to implement -- especially, 64-bit I/O calls that would observably accelerate device performance on FPGA-based soft CPU cores that are typically clocked an order of magnitude slower than conventional hard core CPUs, but that remains for another day. MFC after: 3 weeks Discussed with: jmallett, scottl Sponsored by: DARPA, AFRL Modified: head/sys/mips/mips/bus_space_generic.c Modified: head/sys/mips/mips/bus_space_generic.c ============================================================================== --- head/sys/mips/mips/bus_space_generic.c Wed May 2 08:10:15 2012 (r234920) +++ head/sys/mips/mips/bus_space_generic.c Wed May 2 08:23:53 2012 (r234921) @@ -99,8 +99,8 @@ static struct bus_space generic_space = generic_bs_subregion, /* allocation/deallocation */ - NULL, - NULL, + generic_bs_alloc, + generic_bs_free, /* barrier */ generic_bs_barrier, @@ -109,91 +109,91 @@ static struct bus_space generic_space = generic_bs_r_1, generic_bs_r_2, generic_bs_r_4, - NULL, + generic_bs_r_8, /* read multiple */ generic_bs_rm_1, generic_bs_rm_2, generic_bs_rm_4, - NULL, + generic_bs_rm_8, /* read region */ generic_bs_rr_1, generic_bs_rr_2, generic_bs_rr_4, - NULL, + generic_bs_rr_8, /* write (single) */ generic_bs_w_1, generic_bs_w_2, generic_bs_w_4, - NULL, + generic_bs_w_8, /* write multiple */ generic_bs_wm_1, generic_bs_wm_2, generic_bs_wm_4, - NULL, + generic_bs_wm_8, /* write region */ - NULL, + generic_bs_wr_1, generic_bs_wr_2, generic_bs_wr_4, - NULL, + generic_bs_wr_8, /* set multiple */ - NULL, - NULL, - NULL, - NULL, + generic_bs_sm_1, + generic_bs_sm_2, + generic_bs_sm_4, + generic_bs_sm_8, /* set region */ - NULL, + generic_bs_sr_1, generic_bs_sr_2, generic_bs_sr_4, - NULL, + generic_bs_sr_8, /* copy */ - NULL, + generic_bs_c_1, generic_bs_c_2, - NULL, - NULL, + generic_bs_c_4, + generic_bs_c_8, /* read (single) stream */ generic_bs_r_1, generic_bs_r_2, generic_bs_r_4, - NULL, + generic_bs_r_8, /* read multiple stream */ generic_bs_rm_1, generic_bs_rm_2, generic_bs_rm_4, - NULL, + generic_bs_rm_8, /* read region stream */ generic_bs_rr_1, generic_bs_rr_2, generic_bs_rr_4, - NULL, + generic_bs_rr_8, /* write (single) stream */ generic_bs_w_1, generic_bs_w_2, generic_bs_w_4, - NULL, + generic_bs_w_8, /* write multiple stream */ generic_bs_wm_1, generic_bs_wm_2, generic_bs_wm_4, - NULL, + generic_bs_wm_8, /* write region stream */ - NULL, + generic_bs_wr_1, generic_bs_wr_2, generic_bs_wr_4, - NULL, + generic_bs_wr_8, }; /* Ultra-gross kludge */ @@ -253,6 +253,22 @@ generic_bs_subregion(void *t __unused, b return (0); } +int +generic_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, + bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags, + bus_addr_t *bpap, bus_space_handle_t *bshp) +{ + + panic("%s: not implemented", __func__); +} + +void +generic_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) +{ + + panic("%s: not implemented", __func__); +} + uint8_t generic_bs_r_1(void *t, bus_space_handle_t handle, bus_size_t offset) @@ -277,6 +293,12 @@ generic_bs_r_4(void *t, bus_space_handle return (rd32(handle + offset)); } +uint64_t +generic_bs_r_8(void *t, bus_space_handle_t handle, bus_size_t offset) +{ + + panic("%s: not implemented", __func__); +} void generic_bs_rm_1(void *t, bus_space_handle_t bsh, @@ -307,6 +329,13 @@ generic_bs_rm_4(void *t, bus_space_handl *addr++ = rd32(baddr); } +void +generic_bs_rm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} /* * Read `count' 1, 2, 4, or 8 byte quantities from bus space @@ -349,6 +378,14 @@ generic_bs_rr_4(void *t, bus_space_handl } } +void +generic_bs_rr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write the 1, 2, 4, or 8 byte value `value' to bus space * described by tag/handle/offset. @@ -377,6 +414,14 @@ generic_bs_w_4(void *t, bus_space_handle wr32(bsh + offset, value); } +void +generic_bs_w_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer * provided to bus space described by tag/handle/offset. @@ -411,6 +456,14 @@ generic_bs_wm_4(void *t, bus_space_handl wr32(baddr, *addr++); } +void +generic_bs_wm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + const uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided * to bus space described by tag/handle starting at `offset'. @@ -451,6 +504,14 @@ generic_bs_wr_4(void *t, bus_space_handl } } +void +generic_bs_wr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + const uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write the 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle/offset `count' times. @@ -485,6 +546,14 @@ generic_bs_sm_4(void *t, bus_space_handl wr32(addr, value); } +void +generic_bs_sm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle starting at `offset'. @@ -519,6 +588,14 @@ generic_bs_sr_4(void *t, bus_space_handl wr32(addr, value); } +void +generic_bs_sr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Copy `count' 1, 2, 4, or 8 byte values from bus space starting * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. @@ -584,6 +661,14 @@ generic_bs_c_4(void *t, bus_space_handle } void +generic_bs_c_8(void *t, bus_space_handle_t bsh1, bus_size_t off1, + bus_space_handle_t bsh2, bus_size_t off2, size_t count) +{ + + panic("%s: not implemented", __func__); +} + +void generic_bs_barrier(void *t __unused, bus_space_handle_t bsh __unused, bus_size_t offset __unused, bus_size_t len __unused, From owner-svn-src-all@FreeBSD.ORG Wed May 2 08:38:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 476741065672; Wed, 2 May 2012 08:38:44 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27FF58FC15; Wed, 2 May 2012 08:38:44 +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 q428chBJ074173; Wed, 2 May 2012 08:38:44 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q428chJL074166; Wed, 2 May 2012 08:38:43 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201205020838.q428chJL074166@svn.freebsd.org> From: Dmitry Morozovsky Date: Wed, 2 May 2012 08:38:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234922 - in stable/9/sys: geom/part sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 08:38:44 -0000 Author: marck (doc committer) Date: Wed May 2 08:38:43 2012 New Revision: 234922 URL: http://svn.freebsd.org/changeset/base/234922 Log: MFC r234417: VMware environments are not unusual now. Add VMware partitions recognition (both MBR for ESXi <= 4.1 and GPT for ESXi 5) to g_part. Reviewed by: ae Approved by: ae Modified: stable/9/sys/geom/part/g_part.c stable/9/sys/geom/part/g_part.h stable/9/sys/geom/part/g_part_gpt.c stable/9/sys/geom/part/g_part_mbr.c stable/9/sys/sys/diskmbr.h stable/9/sys/sys/gpt.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/part/g_part.c ============================================================================== --- stable/9/sys/geom/part/g_part.c Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/geom/part/g_part.c Wed May 2 08:38:43 2012 (r234922) @@ -103,6 +103,9 @@ struct g_part_alias_list { { "netbsd-lfs", G_PART_ALIAS_NETBSD_LFS }, { "netbsd-raid", G_PART_ALIAS_NETBSD_RAID }, { "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP }, + { "vmware-vmfs", G_PART_ALIAS_VMFS }, + { "vmware-vmkdiag", G_PART_ALIAS_VMKDIAG }, + { "vmware-reserved", G_PART_ALIAS_VMRESERVED }, }; SYSCTL_DECL(_kern_geom); Modified: stable/9/sys/geom/part/g_part.h ============================================================================== --- stable/9/sys/geom/part/g_part.h Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/geom/part/g_part.h Wed May 2 08:38:43 2012 (r234922) @@ -69,6 +69,9 @@ enum g_part_alias { G_PART_ALIAS_EBR, /* A EBR partition entry. */ G_PART_ALIAS_MS_FAT32, /* A Microsoft FAT32 partition entry. */ G_PART_ALIAS_BIOS_BOOT, /* A GRUB 2 boot partition entry. */ + G_PART_ALIAS_VMFS, /* A VMware VMFS partition entry */ + G_PART_ALIAS_VMKDIAG, /* A VMware vmkDiagnostic partition entry */ + G_PART_ALIAS_VMRESERVED, /* A VMware reserved partition entry */ /* Keep the following last */ G_PART_ALIAS_COUNT }; Modified: stable/9/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/9/sys/geom/part/g_part_gpt.c Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/geom/part/g_part_gpt.c Wed May 2 08:38:43 2012 (r234922) @@ -163,6 +163,9 @@ static struct uuid gpt_uuid_linux_data = static struct uuid gpt_uuid_linux_lvm = GPT_ENT_TYPE_LINUX_LVM; static struct uuid gpt_uuid_linux_raid = GPT_ENT_TYPE_LINUX_RAID; static struct uuid gpt_uuid_linux_swap = GPT_ENT_TYPE_LINUX_SWAP; +static struct uuid gpt_uuid_vmfs = GPT_ENT_TYPE_VMFS; +static struct uuid gpt_uuid_vmkdiag = GPT_ENT_TYPE_VMKDIAG; +static struct uuid gpt_uuid_vmreserved = GPT_ENT_TYPE_VMRESERVED; static struct uuid gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; static struct uuid gpt_uuid_ms_reserved = GPT_ENT_TYPE_MS_RESERVED; static struct uuid gpt_uuid_ms_ldm_data = GPT_ENT_TYPE_MS_LDM_DATA; @@ -200,6 +203,9 @@ static struct g_part_uuid_alias { { &gpt_uuid_linux_lvm, G_PART_ALIAS_LINUX_LVM, 0 }, { &gpt_uuid_linux_raid, G_PART_ALIAS_LINUX_RAID, 0 }, { &gpt_uuid_linux_swap, G_PART_ALIAS_LINUX_SWAP, 0 }, + { &gpt_uuid_vmfs, G_PART_ALIAS_VMFS, 0 }, + { &gpt_uuid_vmkdiag, G_PART_ALIAS_VMKDIAG, 0 }, + { &gpt_uuid_vmreserved, G_PART_ALIAS_VMRESERVED, 0 }, { &gpt_uuid_mbr, G_PART_ALIAS_MBR, 0 }, { &gpt_uuid_ms_basic_data, G_PART_ALIAS_MS_BASIC_DATA, 0x0b }, { &gpt_uuid_ms_ldm_data, G_PART_ALIAS_MS_LDM_DATA, 0 }, Modified: stable/9/sys/geom/part/g_part_mbr.c ============================================================================== --- stable/9/sys/geom/part/g_part_mbr.c Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/geom/part/g_part_mbr.c Wed May 2 08:38:43 2012 (r234922) @@ -125,6 +125,8 @@ static struct g_part_mbr_alias { { DOSPTYP_LINUX, G_PART_ALIAS_LINUX_DATA }, { DOSPTYP_LINLVM, G_PART_ALIAS_LINUX_LVM }, { DOSPTYP_LINRAID, G_PART_ALIAS_LINUX_RAID }, + { DOSPTYP_VMFS, G_PART_ALIAS_VMFS }, + { DOSPTYP_VMKDIAG, G_PART_ALIAS_VMKDIAG }, }; static int Modified: stable/9/sys/sys/diskmbr.h ============================================================================== --- stable/9/sys/sys/diskmbr.h Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/sys/diskmbr.h Wed May 2 08:38:43 2012 (r234922) @@ -54,6 +54,8 @@ #define DOSPTYP_LINUX 0x83 /* Linux partition */ #define DOSPTYP_LINLVM 0x8e /* Linux LVM partition */ #define DOSPTYP_PMBR 0xee /* GPT Protective MBR */ +#define DOSPTYP_VMFS 0xfb /* VMware VMFS partition */ +#define DOSPTYP_VMKDIAG 0xfc /* VMware vmkDiagnostic partition */ #define DOSPTYP_LINRAID 0xfd /* Linux raid partition */ struct dos_partition { Modified: stable/9/sys/sys/gpt.h ============================================================================== --- stable/9/sys/sys/gpt.h Wed May 2 08:23:53 2012 (r234921) +++ stable/9/sys/sys/gpt.h Wed May 2 08:38:43 2012 (r234922) @@ -120,6 +120,13 @@ struct gpt_ent { #define GPT_ENT_TYPE_LINUX_LVM \ {0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}} +#define GPT_ENT_TYPE_VMFS \ + {0xaa31e02a,0x400f,0x11db,0x95,0x90,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} +#define GPT_ENT_TYPE_VMKDIAG \ + {0x9d275380,0x40ad,0x11db,0xbf,0x97,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} +#define GPT_ENT_TYPE_VMRESERVED \ + {0x9198effc,0x31c0,0x11db,0x8f,0x78,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} + #define GPT_ENT_TYPE_APPLE_BOOT \ {0x426F6F74,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_APPLE_HFS \ From owner-svn-src-all@FreeBSD.ORG Wed May 2 09:19:43 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F481106564A; Wed, 2 May 2012 09:19:43 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AC538FC08; Wed, 2 May 2012 09:19:43 +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 q429Jhml075613; Wed, 2 May 2012 09:19:43 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q429Jhbm075611; Wed, 2 May 2012 09:19:43 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205020919.q429Jhbm075611@svn.freebsd.org> From: Warner Losh Date: Wed, 2 May 2012 09:19:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234923 - head/sys/arm/at91 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 09:19:43 -0000 Author: imp Date: Wed May 2 09:19:42 2012 New Revision: 234923 URL: http://svn.freebsd.org/changeset/base/234923 Log: The PIT is really 16 bytes long (0x10) not 10 bytes long. Doesn't matter much, since these defines are unused... Obtained from: AT91SAM9G20 datasheet Modified: head/sys/arm/at91/at91sam9g20reg.h Modified: head/sys/arm/at91/at91sam9g20reg.h ============================================================================== --- head/sys/arm/at91/at91sam9g20reg.h Wed May 2 08:38:43 2012 (r234922) +++ head/sys/arm/at91/at91sam9g20reg.h Wed May 2 09:19:42 2012 (r234923) @@ -238,7 +238,7 @@ #define AT91SAM9G20_WDT_SIZE 0x10 #define AT91SAM9G20_PIT_BASE 0xffffd30 -#define AT91SAM9G20_PIT_SIZE 10 +#define AT91SAM9G20_PIT_SIZE 0x10 #define AT91SAM9G20_SMC_BASE 0xfffec00 #define AT91SAM9G20_SMC_SIZE 0x200 From owner-svn-src-all@FreeBSD.ORG Wed May 2 10:15:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC460106566B; Wed, 2 May 2012 10:15:42 +0000 (UTC) (envelope-from jasone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 97E048FC16; Wed, 2 May 2012 10:15:42 +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 q42AFgdS077688; Wed, 2 May 2012 10:15:42 GMT (envelope-from jasone@svn.freebsd.org) Received: (from jasone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42AFgrf077686; Wed, 2 May 2012 10:15:42 GMT (envelope-from jasone@svn.freebsd.org) Message-Id: <201205021015.q42AFgrf077686@svn.freebsd.org> From: Jason Evans Date: Wed, 2 May 2012 10:15:42 +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: r234924 - head/sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 10:15:42 -0000 Author: jasone Date: Wed May 2 10:15:42 2012 New Revision: 234924 URL: http://svn.freebsd.org/changeset/base/234924 Log: Bump __FreeBSD_version due to jemalloc import. Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed May 2 09:19:42 2012 (r234923) +++ head/sys/sys/param.h Wed May 2 10:15:42 2012 (r234924) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1000011 /* Master, propagated to newvers */ +#define __FreeBSD_version 1000012 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-all@FreeBSD.ORG Wed May 2 11:38:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C88810657B0; Wed, 2 May 2012 11:38:59 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3DB518FC1A; Wed, 2 May 2012 11:38:59 +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 q42BcxlP083030; Wed, 2 May 2012 11:38:59 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42BcwSd083023; Wed, 2 May 2012 11:38:58 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201205021138.q42BcwSd083023@svn.freebsd.org> From: Dmitry Morozovsky Date: Wed, 2 May 2012 11:38:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234925 - in stable/8/sys: geom/part sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 11:38:59 -0000 Author: marck (doc committer) Date: Wed May 2 11:38:58 2012 New Revision: 234925 URL: http://svn.freebsd.org/changeset/base/234925 Log: MFC (with appropriate changes to gpt ikernel structures) r234417: VMware environments are not unusual now. Add VMware partitions recognition (both MBR for ESXi <= 4.1 and GPT for ESXi 5) to g_part. Reviewed by: ae Approved by: ae Modified: stable/8/sys/geom/part/g_part.c stable/8/sys/geom/part/g_part.h stable/8/sys/geom/part/g_part_gpt.c stable/8/sys/geom/part/g_part_mbr.c stable/8/sys/sys/diskmbr.h stable/8/sys/sys/gpt.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/geom/part/g_part.c ============================================================================== --- stable/8/sys/geom/part/g_part.c Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/geom/part/g_part.c Wed May 2 11:38:58 2012 (r234925) @@ -103,6 +103,9 @@ struct g_part_alias_list { { "netbsd-lfs", G_PART_ALIAS_NETBSD_LFS }, { "netbsd-raid", G_PART_ALIAS_NETBSD_RAID }, { "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP }, + { "vmware-vmfs", G_PART_ALIAS_VMFS }, + { "vmware-vmkdiag", G_PART_ALIAS_VMKDIAG }, + { "vmware-reserved", G_PART_ALIAS_VMRESERVED }, }; SYSCTL_DECL(_kern_geom); Modified: stable/8/sys/geom/part/g_part.h ============================================================================== --- stable/8/sys/geom/part/g_part.h Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/geom/part/g_part.h Wed May 2 11:38:58 2012 (r234925) @@ -69,6 +69,9 @@ enum g_part_alias { G_PART_ALIAS_EBR, /* A EBR partition entry. */ G_PART_ALIAS_MS_FAT32, /* A Microsoft FAT32 partition entry. */ G_PART_ALIAS_BIOS_BOOT, /* A GRUB 2 boot partition entry. */ + G_PART_ALIAS_VMFS, /* A VMware VMFS partition entry */ + G_PART_ALIAS_VMKDIAG, /* A VMware vmkDiagnostic partition entry */ + G_PART_ALIAS_VMRESERVED, /* A VMware reserved partition entry */ /* Keep the following last */ G_PART_ALIAS_COUNT }; Modified: stable/8/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/8/sys/geom/part/g_part_gpt.c Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/geom/part/g_part_gpt.c Wed May 2 11:38:58 2012 (r234925) @@ -159,6 +159,9 @@ static struct uuid gpt_uuid_linux_data = static struct uuid gpt_uuid_linux_lvm = GPT_ENT_TYPE_LINUX_LVM; static struct uuid gpt_uuid_linux_raid = GPT_ENT_TYPE_LINUX_RAID; static struct uuid gpt_uuid_linux_swap = GPT_ENT_TYPE_LINUX_SWAP; +static struct uuid gpt_uuid_vmfs = GPT_ENT_TYPE_VMFS; +static struct uuid gpt_uuid_vmkdiag = GPT_ENT_TYPE_VMKDIAG; +static struct uuid gpt_uuid_vmreserved = GPT_ENT_TYPE_VMRESERVED; static struct uuid gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; static struct uuid gpt_uuid_ms_reserved = GPT_ENT_TYPE_MS_RESERVED; static struct uuid gpt_uuid_ms_ldm_data = GPT_ENT_TYPE_MS_LDM_DATA; @@ -195,6 +198,9 @@ static struct g_part_uuid_alias { { &gpt_uuid_linux_lvm, G_PART_ALIAS_LINUX_LVM }, { &gpt_uuid_linux_raid, G_PART_ALIAS_LINUX_RAID }, { &gpt_uuid_linux_swap, G_PART_ALIAS_LINUX_SWAP }, + { &gpt_uuid_vmfs, G_PART_ALIAS_VMFS }, + { &gpt_uuid_vmkdiag, G_PART_ALIAS_VMKDIAG }, + { &gpt_uuid_vmreserved, G_PART_ALIAS_VMRESERVED }, { &gpt_uuid_mbr, G_PART_ALIAS_MBR }, { &gpt_uuid_ms_basic_data, G_PART_ALIAS_MS_BASIC_DATA }, { &gpt_uuid_ms_ldm_data, G_PART_ALIAS_MS_LDM_DATA }, Modified: stable/8/sys/geom/part/g_part_mbr.c ============================================================================== --- stable/8/sys/geom/part/g_part_mbr.c Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/geom/part/g_part_mbr.c Wed May 2 11:38:58 2012 (r234925) @@ -121,6 +121,8 @@ static struct g_part_mbr_alias { { DOSPTYP_LINUX, G_PART_ALIAS_LINUX_DATA }, { DOSPTYP_LINLVM, G_PART_ALIAS_LINUX_LVM }, { DOSPTYP_LINRAID, G_PART_ALIAS_LINUX_RAID }, + { DOSPTYP_VMFS, G_PART_ALIAS_VMFS }, + { DOSPTYP_VMKDIAG, G_PART_ALIAS_VMKDIAG }, }; static int Modified: stable/8/sys/sys/diskmbr.h ============================================================================== --- stable/8/sys/sys/diskmbr.h Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/sys/diskmbr.h Wed May 2 11:38:58 2012 (r234925) @@ -54,6 +54,8 @@ #define DOSPTYP_LINUX 0x83 /* Linux partition */ #define DOSPTYP_LINLVM 0x8e /* Linux LVM partition */ #define DOSPTYP_PMBR 0xee /* GPT Protective MBR */ +#define DOSPTYP_VMFS 0xfb /* VMware VMFS partition */ +#define DOSPTYP_VMKDIAG 0xfc /* VMware vmkDiagnostic partition */ #define DOSPTYP_LINRAID 0xfd /* Linux raid partition */ struct dos_partition { Modified: stable/8/sys/sys/gpt.h ============================================================================== --- stable/8/sys/sys/gpt.h Wed May 2 10:15:42 2012 (r234924) +++ stable/8/sys/sys/gpt.h Wed May 2 11:38:58 2012 (r234925) @@ -120,6 +120,13 @@ struct gpt_ent { #define GPT_ENT_TYPE_LINUX_LVM \ {0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}} +#define GPT_ENT_TYPE_VMFS \ + {0xaa31e02a,0x400f,0x11db,0x95,0x90,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} +#define GPT_ENT_TYPE_VMKDIAG \ + {0x9d275380,0x40ad,0x11db,0xbf,0x97,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} +#define GPT_ENT_TYPE_VMRESERVED \ + {0x9198effc,0x31c0,0x11db,0x8f,0x78,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} + #define GPT_ENT_TYPE_APPLE_BOOT \ {0x426F6F74,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_APPLE_HFS \ From owner-svn-src-all@FreeBSD.ORG Wed May 2 11:56:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B1EBB106564A; Wed, 2 May 2012 11:56:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 645A78FC08; Wed, 2 May 2012 11:56:49 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C948DB96B; Wed, 2 May 2012 07:56:48 -0400 (EDT) From: John Baldwin To: Alexander Motin Date: Wed, 2 May 2012 07:52:51 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201205020652.q426q0nO069704@svn.freebsd.org> In-Reply-To: <201205020652.q426q0nO069704@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201205020752.51629.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 02 May 2012 07:56:48 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r234912 - in stable/8/sys: cam cam/ata geom modules/cam X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 11:56:52 -0000 On Wednesday, May 02, 2012 2:52:00 am Alexander Motin wrote: > Author: mav > Date: Wed May 2 06:52:00 2012 > New Revision: 234912 > URL: http://svn.freebsd.org/changeset/base/234912 > > Log: > Merge ATA_CAM compatibility shims. While 8-STABLE doesn't have ATA_CAM > enabled by default, this should make migration easier for users enabling > it manually. Thanks! -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Wed May 2 12:15:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 621361065678; Wed, 2 May 2012 12:15:35 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CCC98FC08; Wed, 2 May 2012 12:15: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 q42CFZod084339; Wed, 2 May 2012 12:15:35 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42CFZo9084337; Wed, 2 May 2012 12:15:35 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205021215.q42CFZo9084337@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 12:15: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: r234926 - head/sys/mips/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 12:15:35 -0000 Author: rwatson Date: Wed May 2 12:15:34 2012 New Revision: 234926 URL: http://svn.freebsd.org/changeset/base/234926 Log: mips/mips64eb became mips/mips64 while I wasn't looking (whoops), so update GXEMUL kernel config for the new world order. Spotted by: bz MFC after: 3 weeks Modified: head/sys/mips/conf/GXEMUL Modified: head/sys/mips/conf/GXEMUL ============================================================================== --- head/sys/mips/conf/GXEMUL Wed May 2 11:38:58 2012 (r234925) +++ head/sys/mips/conf/GXEMUL Wed May 2 12:15:34 2012 (r234926) @@ -6,7 +6,7 @@ ident GXEMUL -machine mips mips64eb +machine mips mips64 cpu CPU_MIPS4KC options HZ=100 From owner-svn-src-all@FreeBSD.ORG Wed May 2 14:25:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D141D106564A; Wed, 2 May 2012 14:25:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BBA5B8FC0A; Wed, 2 May 2012 14:25:39 +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 q42EPdUF088860; Wed, 2 May 2012 14:25:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42EPdqw088857; Wed, 2 May 2012 14:25:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201205021425.q42EPdqw088857@svn.freebsd.org> From: John Baldwin Date: Wed, 2 May 2012 14:25:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 14:25:40 -0000 Author: jhb Date: Wed May 2 14:25:39 2012 New Revision: 234927 URL: http://svn.freebsd.org/changeset/base/234927 Log: - Don't log messages saying that accounting is being disabled and enabled if the accounting log file is atomically replaced with a new file (such as during log rotation). - Simplify accounting log rotation a bit. There is no need to re-run accton(8) after renaming the new log file to it's real name. PR: kern/167321 Tested by: Jeremy Chadwick Modified: head/etc/rc.d/accounting head/sys/kern/kern_acct.c Modified: head/etc/rc.d/accounting ============================================================================== --- head/etc/rc.d/accounting Wed May 2 12:15:34 2012 (r234926) +++ head/etc/rc.d/accounting Wed May 2 14:25:39 2012 (r234927) @@ -65,9 +65,7 @@ accounting_rotate_log() mv ${accounting_file} ${accounting_file}.0 if checkyesno accounting_enable; then - ln $_file ${accounting_file##*/} - ${accounting_command} ${accounting_file} - unlink $_file + mv $_file ${accounting_file} fi } Modified: head/sys/kern/kern_acct.c ============================================================================== --- head/sys/kern/kern_acct.c Wed May 2 12:15:34 2012 (r234926) +++ head/sys/kern/kern_acct.c Wed May 2 14:25:39 2012 (r234927) @@ -122,7 +122,7 @@ static uint32_t encode_timeval(struct ti static uint32_t encode_long(long); static void acctwatch(void); static void acct_thread(void *); -static int acct_disable(struct thread *); +static int acct_disable(struct thread *, int); /* * Accounting vnode pointer, saved vnode pointer, and flags for each. @@ -196,7 +196,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, vfslocked; + int error, flags, vfslocked, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -246,6 +246,13 @@ sys_acct(struct thread *td, struct acct_ sx_xlock(&acct_sx); /* + * Don't log spurious disable/enable messages if we are + * switching from one accounting file to another due to log + * rotation. + */ + replacing = (acct_vp != NULL && uap->path != NULL); + + /* * If accounting was previously enabled, kill the old space-watcher, * close the file, and (if no new file was specified, leave). Reset * the suspended state regardless of whether accounting remains @@ -254,7 +261,7 @@ sys_acct(struct thread *td, struct acct_ acct_suspended = 0; if (acct_vp != NULL) { vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); - error = acct_disable(td); + error = acct_disable(td, !replacing); VFS_UNLOCK_GIANT(vfslocked); } if (uap->path == NULL) { @@ -299,7 +306,8 @@ sys_acct(struct thread *td, struct acct_ } acct_configured = 1; sx_xunlock(&acct_sx); - log(LOG_NOTICE, "Accounting enabled\n"); + if (!replacing) + log(LOG_NOTICE, "Accounting enabled\n"); return (error); } @@ -308,7 +316,7 @@ sys_acct(struct thread *td, struct acct_ * our reference to the credential, and clearing the vnode's flags. */ static int -acct_disable(struct thread *td) +acct_disable(struct thread *td, int logging) { int error; @@ -319,7 +327,8 @@ acct_disable(struct thread *td) acct_vp = NULL; acct_cred = NULL; acct_flags = 0; - log(LOG_NOTICE, "Accounting disabled\n"); + if (logging) + log(LOG_NOTICE, "Accounting disabled\n"); return (error); } @@ -574,7 +583,7 @@ acctwatch(void) */ vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); if (acct_vp->v_type == VBAD) { - (void) acct_disable(NULL); + (void) acct_disable(NULL, 1); VFS_UNLOCK_GIANT(vfslocked); acct_state |= ACCT_EXITREQ; return; From owner-svn-src-all@FreeBSD.ORG Wed May 2 14:38:43 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9A32106564A; Wed, 2 May 2012 14:38:43 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4CFC8FC08; Wed, 2 May 2012 14:38:43 +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 q42Ech54089330; Wed, 2 May 2012 14:38:43 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42Echhn089328; Wed, 2 May 2012 14:38:43 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205021438.q42Echhn089328@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 2 May 2012 14:38:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234928 - head/sys/mips/gxemul X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 14:38:44 -0000 Author: bz Date: Wed May 2 14:38:43 2012 New Revision: 234928 URL: http://svn.freebsd.org/changeset/base/234928 Log: Catch-up with r232853 and remove platform APIs which are not used by any code and which had only stub implementations or no implementation on all platforms. Makes gxemul compile. Hinted by: rwatson MFC after: 3 weeks X-MFC by: rwatson: Modified: head/sys/mips/gxemul/gxemul_machdep.c Modified: head/sys/mips/gxemul/gxemul_machdep.c ============================================================================== --- head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 14:25:39 2012 (r234927) +++ head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 14:38:43 2012 (r234928) @@ -102,19 +102,6 @@ mips_init(void) #endif } -void -platform_halt(void) -{ - -} - - -void -platform_identify(void) -{ - -} - /* * Perform a board-level soft-reset. * @@ -128,18 +115,6 @@ platform_reset(void) } void -platform_trap_enter(void) -{ - -} - -void -platform_trap_exit(void) -{ - -} - -void platform_start(__register_t a0, __register_t a1, __register_t a2, __register_t a3) { From owner-svn-src-all@FreeBSD.ORG Wed May 2 15:15:29 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18DA7106566C; Wed, 2 May 2012 15:15:29 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCFCE8FC16; Wed, 2 May 2012 15:15:28 +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 q42FFS4A090724; Wed, 2 May 2012 15:15:28 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42FFS1O090722; Wed, 2 May 2012 15:15:28 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201205021515.q42FFS1O090722@svn.freebsd.org> From: Jaakko Heinonen Date: Wed, 2 May 2012 15:15:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234929 - in stable/9/sys: i386/conf kern ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 15:15:29 -0000 Author: jh Date: Wed May 2 15:15:28 2012 New Revision: 234929 URL: http://svn.freebsd.org/changeset/base/234929 Log: MFC r233787: - Use more natural ip->i_flags instead of vap->va_flags in the final flags check. - Add a comment for the immutable/append check done after handling of the flags. - Style improvements. No functional change intended. MFC r234421: The part about exec atime no longer applies in the comment. Modified: stable/9/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/i386/conf/XENHVM (props changed) stable/9/sys/kern/subr_witness.c (props changed) Modified: stable/9/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/9/sys/ufs/ufs/ufs_vnops.c Wed May 2 14:38:43 2012 (r234928) +++ stable/9/sys/ufs/ufs/ufs_vnops.c Wed May 2 15:15:28 2012 (r234929) @@ -547,8 +547,8 @@ ufs_setattr(ap) * processes. */ if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) { - if (ip->i_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { + if (ip->i_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { error = securelevel_gt(cred, 0); if (error) return (error); @@ -562,8 +562,8 @@ ufs_setattr(ap) ip->i_flags = vap->va_flags; DIP_SET(ip, i_flags, vap->va_flags); } else { - if (ip->i_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || + if (ip->i_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || (vap->va_flags & UF_SETTABLE) != vap->va_flags) return (EPERM); ip->i_flags &= SF_SETTABLE; @@ -572,9 +572,14 @@ ufs_setattr(ap) } ip->i_flag |= IN_CHANGE; error = UFS_UPDATE(vp, 0); - if (vap->va_flags & (IMMUTABLE | APPEND)) + if (ip->i_flags & (IMMUTABLE | APPEND)) return (error); } + /* + * If immutable or append, no one can change any of its attributes + * except the ones already handled (in some cases, file flags + * including the immutability flags themselves for the superuser). + */ if (ip->i_flags & (IMMUTABLE | APPEND)) return (EPERM); /* From owner-svn-src-all@FreeBSD.ORG Wed May 2 16:23:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 549F01065670; Wed, 2 May 2012 16:23:37 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3EF3E8FC15; Wed, 2 May 2012 16:23:37 +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 q42GNbJV093084; Wed, 2 May 2012 16:23:37 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42GNbGe093082; Wed, 2 May 2012 16:23:37 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201205021623.q42GNbGe093082@svn.freebsd.org> From: "George V. Neville-Neil" Date: Wed, 2 May 2012 16:23:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234930 - head/sys/dev/hwpmc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 16:23:37 -0000 Author: gnn Date: Wed May 2 16:23:36 2012 New Revision: 234930 URL: http://svn.freebsd.org/changeset/base/234930 Log: Fix so that ,usr and ,os work correctly with fixed function (IAF) counters. MFC after: 1 week Modified: head/sys/dev/hwpmc/hwpmc_core.c Modified: head/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_core.c Wed May 2 15:15:28 2012 (r234929) +++ head/sys/dev/hwpmc/hwpmc_core.c Wed May 2 16:23:36 2012 (r234930) @@ -52,7 +52,8 @@ __FBSDID("$FreeBSD$"); #define CORE_CPUID_EDX 0x3 #define IAF_PMC_CAPS \ - (PMC_CAP_READ | PMC_CAP_WRITE | PMC_CAP_INTERRUPT) + (PMC_CAP_READ | PMC_CAP_WRITE | PMC_CAP_INTERRUPT | \ + PMC_CAP_USER | PMC_CAP_SYSTEM) #define IAF_RI_TO_MSR(RI) ((RI) + (1 << 30)) #define IAP_PMC_CAPS (PMC_CAP_INTERRUPT | PMC_CAP_USER | PMC_CAP_SYSTEM | \ From owner-svn-src-all@FreeBSD.ORG Wed May 2 18:41:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FFE4106566B; Wed, 2 May 2012 18:41:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5098FC0A; Wed, 2 May 2012 18:41:59 +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 q42IfwDK097961; Wed, 2 May 2012 18:41:58 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42IfwCY097959; Wed, 2 May 2012 18:41:58 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205021841.q42IfwCY097959@svn.freebsd.org> From: Warner Losh Date: Wed, 2 May 2012 18:41: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: r234931 - head/sys/arm/at91 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 18:41:59 -0000 Author: imp Date: Wed May 2 18:41:58 2012 New Revision: 234931 URL: http://svn.freebsd.org/changeset/base/234931 Log: Fix comment about what board this is really for left over from early cut and paste. Modified: head/sys/arm/at91/board_sam9g20ek.c Modified: head/sys/arm/at91/board_sam9g20ek.c ============================================================================== --- head/sys/arm/at91/board_sam9g20ek.c Wed May 2 16:23:36 2012 (r234930) +++ head/sys/arm/at91/board_sam9g20ek.c Wed May 2 18:41:58 2012 (r234931) @@ -25,11 +25,7 @@ /* * This board file can be used for both: - * Atmel AT91SAM9260-B Development Card and - * Atmel AT91SAM9G20-EK Rev. B Development Card - * - * Since the AT91SAM9260 and AT91SAM9G20 have identical memory maps and - * pin configurations we can use the same file for both. + * Atmel SAM9G20-EK Development Card */ #include From owner-svn-src-all@FreeBSD.ORG Wed May 2 19:25:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 0616E106564A; Wed, 2 May 2012 19:25:15 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from [127.0.0.1] (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8BE3815049E; Wed, 2 May 2012 19:25:14 +0000 (UTC) Message-ID: <4FA18A1B.30203@FreeBSD.org> Date: Wed, 02 May 2012 12:25:15 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: John Baldwin References: <201205021425.q42EPdqw088857@svn.freebsd.org> In-Reply-To: <201205021425.q42EPdqw088857@svn.freebsd.org> X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 19:25:15 -0000 On 5/2/2012 7:25 AM, John Baldwin wrote: > - Simplify accounting log rotation a bit. There is no need to re-run > accton(8) after renaming the new log file to it's real name. Have you thoroughly tested this change? I remember adding that on purpose, but I couldn't tell you for sure at this point exactly why. -- This .signature sanitized for your protection From owner-svn-src-all@FreeBSD.ORG Wed May 2 19:32:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA4831065674; Wed, 2 May 2012 19:32:11 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 94EF88FC1C; Wed, 2 May 2012 19:32:11 +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 q42JWBZ8099731; Wed, 2 May 2012 19:32:11 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42JWBMs099729; Wed, 2 May 2012 19:32:11 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201205021932.q42JWBMs099729@svn.freebsd.org> From: Peter Holm Date: Wed, 2 May 2012 19:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234932 - head/sys/dev/sound/pcm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 19:32:11 -0000 Author: pho Date: Wed May 2 19:32:11 2012 New Revision: 234932 URL: http://svn.freebsd.org/changeset/base/234932 Log: Added D_TRACKCLOSE to sndstat_cdevsw to fix the situation when another process is in open() or stat() for the device node, then close() from the owning process does not result in cdevsw close method call. This fixes the pemanent "Device busy" seen. Changed the sndstat_lock from mutex to sx. This allows to extend the region covered by the lock, to include the uiomove() call in sndstat_read() and bufptr increment. This fixes the "panic: sbuf_put_byte called with finished or corrupt sbuf" seen. In collaboration with: kib MFC after: 1 week Modified: head/sys/dev/sound/pcm/sndstat.c Modified: head/sys/dev/sound/pcm/sndstat.c ============================================================================== --- head/sys/dev/sound/pcm/sndstat.c Wed May 2 18:41:58 2012 (r234931) +++ head/sys/dev/sound/pcm/sndstat.c Wed May 2 19:32:11 2012 (r234932) @@ -53,6 +53,7 @@ static struct cdevsw sndstat_cdevsw = { .d_close = sndstat_close, .d_read = sndstat_read, .d_name = "sndstat", + .d_flags = D_TRACKCLOSE, }; struct sndstat_entry { @@ -63,7 +64,7 @@ struct sndstat_entry { int type, unit; }; -static struct mtx sndstat_lock; +static struct sx sndstat_lock; static struct sbuf sndstat_sbuf; static struct cdev *sndstat_dev = NULL; static int sndstat_bufptr = -1; @@ -93,16 +94,14 @@ sysctl_hw_snd_sndstat_pid(SYSCTL_HANDLER if (sndstat_dev == NULL) return (EINVAL); - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); val = (int)SNDSTAT_PID(sndstat_dev); - mtx_unlock(&sndstat_lock); err = sysctl_handle_int(oidp, &val, 0, req); if (err == 0 && req->newptr != NULL && val == 0) { - mtx_lock(&sndstat_lock); SNDSTAT_FLUSH(); SNDSTAT_PID_SET(sndstat_dev, 0); - mtx_unlock(&sndstat_lock); } + sx_unlock(&sndstat_lock); return (err); } SYSCTL_PROC(_hw_snd, OID_AUTO, sndstat_pid, CTLTYPE_INT | CTLFLAG_RW, @@ -119,12 +118,10 @@ sysctl_hw_sndverbose(SYSCTL_HANDLER_ARGS verbose = snd_verbose; error = sysctl_handle_int(oidp, &verbose, 0, req); if (error == 0 && req->newptr != NULL) { - mtx_lock(&sndstat_lock); if (verbose < 0 || verbose > 4) error = EINVAL; else snd_verbose = verbose; - mtx_unlock(&sndstat_lock); } return error; } @@ -137,20 +134,19 @@ sndstat_open(struct cdev *i_dev, int fla if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) != 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } SNDSTAT_PID_SET(i_dev, td->td_proc->p_pid); - mtx_unlock(&sndstat_lock); if (sbuf_new(&sndstat_sbuf, NULL, 4096, SBUF_AUTOEXTEND) == NULL) { - mtx_lock(&sndstat_lock); SNDSTAT_PID_SET(i_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } sndstat_bufptr = 0; + sx_unlock(&sndstat_lock); return 0; } @@ -160,16 +156,16 @@ sndstat_close(struct cdev *i_dev, int fl if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) == 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } SNDSTAT_FLUSH(); SNDSTAT_PID_SET(i_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -182,20 +178,18 @@ sndstat_read(struct cdev *i_dev, struct if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) != buf->uio_td->td_proc->p_pid || sndstat_bufptr == -1) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } - mtx_unlock(&sndstat_lock); if (sndstat_bufptr == 0) { err = (sndstat_prepare(&sndstat_sbuf) > 0) ? 0 : ENOMEM; if (err) { - mtx_lock(&sndstat_lock); SNDSTAT_FLUSH(); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return err; } } @@ -203,6 +197,7 @@ sndstat_read(struct cdev *i_dev, struct l = min(buf->uio_resid, sbuf_len(&sndstat_sbuf) - sndstat_bufptr); err = (l > 0)? uiomove(sbuf_data(&sndstat_sbuf) + sndstat_bufptr, l, buf) : 0; sndstat_bufptr += l; + sx_unlock(&sndstat_lock); return err; } @@ -228,13 +223,13 @@ sndstat_acquire(struct thread *td) if (sndstat_dev == NULL) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } SNDSTAT_PID_SET(sndstat_dev, td->td_proc->p_pid); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -244,13 +239,13 @@ sndstat_release(struct thread *td) if (sndstat_dev == NULL) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != td->td_proc->p_pid) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } SNDSTAT_PID_SET(sndstat_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -284,12 +279,12 @@ sndstat_register(device_t dev, char *str ent->unit = unit; ent->handler = handler; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_INSERT_HEAD(&sndstat_devlist, ent, link); if (type == SS_TYPE_MODULE) sndstat_files++; sndstat_maxunit = (unit > sndstat_maxunit)? unit : sndstat_maxunit; - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -305,17 +300,17 @@ sndstat_unregister(device_t dev) { struct sndstat_entry *ent; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_FOREACH(ent, &sndstat_devlist, link) { if (ent->dev == dev) { SLIST_REMOVE(&sndstat_devlist, ent, sndstat_entry, link); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); free(ent, M_DEVBUF); return 0; } } - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } @@ -325,18 +320,18 @@ sndstat_unregisterfile(char *str) { struct sndstat_entry *ent; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_FOREACH(ent, &sndstat_devlist, link) { if (ent->dev == NULL && ent->str == str) { SLIST_REMOVE(&sndstat_devlist, ent, sndstat_entry, link); sndstat_files--; - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); free(ent, M_DEVBUF); return 0; } } - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } @@ -399,7 +394,7 @@ sndstat_init(void) { if (sndstat_dev != NULL) return EINVAL; - mtx_init(&sndstat_lock, "sndstat", "sndstat lock", MTX_DEF); + sx_init(&sndstat_lock, "sndstat lock"); sndstat_dev = make_dev(&sndstat_cdevsw, SND_DEV_STATUS, UID_ROOT, GID_WHEEL, 0444, "sndstat"); return 0; @@ -411,20 +406,20 @@ sndstat_uninit(void) if (sndstat_dev == NULL) return EINVAL; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != curthread->td_proc->p_pid) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } - SNDSTAT_FLUSH(); - - mtx_unlock(&sndstat_lock); - + /* XXXPHO: use destroy_dev_sched() */ destroy_dev(sndstat_dev); sndstat_dev = NULL; - mtx_destroy(&sndstat_lock); + SNDSTAT_FLUSH(); + + sx_unlock(&sndstat_lock); + sx_destroy(&sndstat_lock); return 0; } From owner-svn-src-all@FreeBSD.ORG Wed May 2 20:01:28 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA211106564A; Wed, 2 May 2012 20:01:28 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D552C8FC08; Wed, 2 May 2012 20:01:28 +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 q42K1S2j000909; Wed, 2 May 2012 20:01:28 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42K1Shb000907; Wed, 2 May 2012 20:01:28 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205022001.q42K1Shb000907@svn.freebsd.org> From: Monthadar Al Jaberi Date: Wed, 2 May 2012 20:01:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234933 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:01:29 -0000 Author: monthadar Date: Wed May 2 20:01:28 2012 New Revision: 234933 URL: http://svn.freebsd.org/changeset/base/234933 Log: Update man page date to the date of the last commit. Approved by: adrian Modified: head/sbin/ifconfig/ifconfig.8 Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Wed May 2 19:32:11 2012 (r234932) +++ head/sbin/ifconfig/ifconfig.8 Wed May 2 20:01:28 2012 (r234933) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd April 3, 2012 +.Dd May 1, 2012 .Dt IFCONFIG 8 .Os .Sh NAME From owner-svn-src-all@FreeBSD.ORG Wed May 2 20:04:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 171961065677; Wed, 2 May 2012 20:04:11 +0000 (UTC) (envelope-from monthadar@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 270898FC21; Wed, 2 May 2012 20:04:10 +0000 (UTC) Received: by weyt57 with SMTP id t57so888562wey.13 for ; Wed, 02 May 2012 13:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=8I1bBaSqUtQnIgE07xfjUm9KINAERnyNcy+Uts3kQ74=; b=hkEnHBWESPnrDXgba9SYxogoze9o9I+21LjeIqVgRc9jQdLnyQ4ufZdJmCdebHn8bf 5uXOJKOvjas9rxSF4tKBQMwKXqd5Z4ysot0FvwXz4/PgcTrGXjRTizrd8eJ4mJpSI1Aw 8+ixzZ+NulNHKUvwgVw4tnvBCRozraEV0aB7YFUKy/iIFr+eQssgtSpOq57YydPYFUX9 tZgt9pVkTIejPqPjpXAsBVLMf1WJr/SxDQ0D8rSGvXLGIGv12iMZdHCc36Lhi6pPlJFu am+iiri8R5WGVIyfpgY67iLQRXLazt8z2261Rfag8FW5y5adeTjTeXhLAYUayR3iSU9H SCWA== MIME-Version: 1.0 Received: by 10.180.86.132 with SMTP id p4mr9119342wiz.15.1335989049327; Wed, 02 May 2012 13:04:09 -0700 (PDT) Received: by 10.223.155.74 with HTTP; Wed, 2 May 2012 13:04:09 -0700 (PDT) In-Reply-To: References: <201205011615.q41GFZa1034278@svn.freebsd.org> Date: Wed, 2 May 2012 22:04:09 +0200 Message-ID: From: Monthadar Al Jaberi To: "Bjoern A. Zeeb" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Monthadar Al Jaberi , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:04:11 -0000 On Tue, May 1, 2012 at 11:05 PM, Bjoern A. Zeeb wrote: > > On 1. May 2012, at 16:15 , Monthadar Al Jaberi wrote: > >> Author: monthadar >> Date: Tue May =A01 16:15:34 2012 >> New Revision: 234893 >> URL: http://svn.freebsd.org/changeset/base/234893 >> >> Log: >> =A0* Added new command to ifconfig to activate Mesh Gate Announcement ca= lled >> =A0meshgate with corresponding explanation; >> >> =A0Approved by: adrian >> >> Modified: >> =A0head/sbin/ifconfig/ifconfig.8 >> =A0head/sbin/ifconfig/ifieee80211.c >> >> Modified: head/sbin/ifconfig/ifconfig.8 >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sbin/ifconfig/ifconfig.8 =A0 =A0 Tue May =A01 16:14:18 2012 =A0= =A0 =A0 =A0(r234892) >> +++ head/sbin/ifconfig/ifconfig.8 =A0 =A0 Tue May =A01 16:15:34 2012 =A0= =A0 =A0 =A0(r234893) > > > Please update .Dd as well. Done. Thank you. > >> @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by >> By default >> .Cm meshforward >> is enabled. >> +.It Cm meshgate >> +This attribute specifies whether or not the mesh STA activates mesh gat= e >> +announcements. >> +By default >> +.Cm meshgate >> +is disabled. >> .It Cm meshmetric Ar protocol >> Set the specified >> .Ar protocol > > -- > Bjoern A. Zeeb =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 You have to have visions! > =A0 It does not matter how good you are. It matters what good you do! > --=20 Monthadar Al Jaberi From owner-svn-src-all@FreeBSD.ORG Wed May 2 20:56:07 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E0181106566C; Wed, 2 May 2012 20:56:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B4AE48FC15; Wed, 2 May 2012 20:56:07 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 24717B96D; Wed, 2 May 2012 16:56:07 -0400 (EDT) From: John Baldwin To: Doug Barton Date: Wed, 2 May 2012 16:34:21 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201205021425.q42EPdqw088857@svn.freebsd.org> <4FA18A1B.30203@FreeBSD.org> In-Reply-To: <4FA18A1B.30203@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201205021634.21898.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 02 May 2012 16:56:07 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:56:08 -0000 On Wednesday, May 02, 2012 3:25:15 pm Doug Barton wrote: > On 5/2/2012 7:25 AM, John Baldwin wrote: > > - Simplify accounting log rotation a bit. There is no need to re-run > > accton(8) after renaming the new log file to it's real name. > > Have you thoroughly tested this change? I remember adding that on > purpose, but I couldn't tell you for sure at this point exactly why. The reporter tested it. However, the kernel has no notion of the pathname once it has opened the file. It just holds a reference to the vnode directly, and the rename of the file will not invalidate that reference. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Wed May 2 21:24:08 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2B76106566C; Wed, 2 May 2012 21:24:08 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B45F08FC12; Wed, 2 May 2012 21:24:08 +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 q42LO8iE003890; Wed, 2 May 2012 21:24:08 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42LO82Q003888; Wed, 2 May 2012 21:24:08 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201205022124.q42LO82Q003888@svn.freebsd.org> From: Jamie Gritton Date: Wed, 2 May 2012 21:24:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234934 - head/usr.sbin/jail X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 21:24:09 -0000 Author: jamie Date: Wed May 2 21:24:08 2012 New Revision: 234934 URL: http://svn.freebsd.org/changeset/base/234934 Log: Add YY_NO_INPUT so clang doesn't complain about "input" not being used. Modified: head/usr.sbin/jail/jaillex.l Modified: head/usr.sbin/jail/jaillex.l ============================================================================== --- head/usr.sbin/jail/jaillex.l Wed May 2 20:01:28 2012 (r234933) +++ head/usr.sbin/jail/jaillex.l Wed May 2 21:24:08 2012 (r234934) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "jailp.h" #include "y.tab.h" +#define YY_NO_INPUT #define YY_NO_UNPUT extern int yynerrs; From owner-svn-src-all@FreeBSD.ORG Wed May 2 21:50:14 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 06C2A1065670; Wed, 2 May 2012 21:50:14 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E592A8FC14; Wed, 2 May 2012 21:50:13 +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 q42LoDZY004814; Wed, 2 May 2012 21:50:13 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42LoDh9004811; Wed, 2 May 2012 21:50:13 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205022150.q42LoDh9004811@svn.freebsd.org> From: Eitan Adler Date: Wed, 2 May 2012 21:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234935 - in head/share/man: man5 man7 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 21:50:14 -0000 Author: eadler Date: Wed May 2 21:50:13 2012 New Revision: 234935 URL: http://svn.freebsd.org/changeset/base/234935 Log: Prefer the use of csup to cvsup when talking about the binary. PR: docs/167459 Submitted by: "Bryan Drewery" Approved by: bcr MFC after: 1 week Modified: head/share/man/man5/make.conf.5 head/share/man/man7/development.7 Modified: head/share/man/man5/make.conf.5 ============================================================================== --- head/share/man/man5/make.conf.5 Wed May 2 21:24:08 2012 (r234934) +++ head/share/man/man5/make.conf.5 Wed May 2 21:50:13 2012 (r234935) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 11, 2011 +.Dd May 02, 2012 .Dt MAKE.CONF 5 .Os .Sh NAME @@ -318,7 +318,7 @@ The hostname of the sup server to use wh .It Va SUP_UPDATE .Pq Vt bool Set this to use -.Xr cvsup 1 +.Xr csup 1 to update your .Pa src , ports , doc and Modified: head/share/man/man7/development.7 ============================================================================== --- head/share/man/man7/development.7 Wed May 2 21:24:08 2012 (r234934) +++ head/share/man/man7/development.7 Wed May 2 21:50:13 2012 (r234935) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2002 +.Dd May 02, 2012 .Dt DEVELOPMENT 7 .Os .Sh NAME @@ -89,7 +89,7 @@ I recommend a partition of at least 5GB. .Pp On the master server, use -.Xr cvsup 1 Pq Pa ports/net/cvsup +.Xr csup 1 to automatically pull down and maintain the .Fx @@ -108,23 +108,23 @@ The job should look something like this (please randomize the time of day!). Note that you can use the -.Xr cvsup 1 +.Xr csup 1 configuration file example directly from .Pa /usr/share/examples without modification by supplying appropriate arguments to -.Xr cvsup 1 . +.Xr csup 1 . .Bd -literal -offset 4n -33 6 * * * /usr/local/bin/cvsup -g -r 20 -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/cvs-supfile +33 6 * * * /usr/bin/csup -r 20 -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/cvs-supfile .Ed .Pp Run the -.Xr cvsup 1 +.Xr csup 1 manually the first time to pull down the archive. It could take all day depending on how fast your connection is! You will run all -.Xr cvsup 1 +.Xr csup 1 and .Xr cvs 1 operations as @@ -555,7 +555,7 @@ Since the main tree is based on CVS, the former is convenient. .Pp First, you need to modify your -.Xr cvsup 1 +.Xr csup 1 environment to avoid it modifying the local changes you have committed to the repository. It is important to remove the @@ -568,7 +568,7 @@ subdirectory to your .Pa refuse file. For more information, see -.Xr cvsup 1 . +.Xr csup 1 . .Pp The .Fx @@ -598,13 +598,13 @@ For more information on using CVS, see .Pp .Sy WARNING! The -.Xr cvsup 1 +.Xr csup 1 utility may blow away changes made on a local branch in some situations. This has been reported to occur when the master CVS repository is directly manipulated or an RCS file is changed. At this point, -.Xr cvsup 1 +.Xr csup 1 notices that the client and server have entirely different RCS files, so it does a full replace instead of trying to send just deltas. @@ -619,7 +619,7 @@ Bottom line is, if you value your local should back it up before every update. .Sh UPDATING VIA CVS The advantage of using -.Xr cvsup 1 +.Xr csup 1 to maintain an updated copy of the CVS repository instead of using it to maintain source trees directly is that you can then pick and choose when you bring your source tree (or pieces of your From owner-svn-src-all@FreeBSD.ORG Thu May 3 01:41:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 910941065670; Thu, 3 May 2012 01:41:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CDCD8FC15; Thu, 3 May 2012 01:41:13 +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 q431fD92012832; Thu, 3 May 2012 01:41:13 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q431fDO1012830; Thu, 3 May 2012 01:41:13 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201205030141.q431fDO1012830@svn.freebsd.org> From: Ed Maste Date: Thu, 3 May 2012 01:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234936 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 01:41:13 -0000 Author: emaste Date: Thu May 3 01:41:12 2012 New Revision: 234936 URL: http://svn.freebsd.org/changeset/base/234936 Log: Relax restriction on direct tx to child ports Lagg(4) restricts the type of packet that may be sent directly to a child port, to avoid undesired output from accidental misconfiguration. Previously only ETHERTYPE_PAE was permitted. BPF writes to a lagg(4) child port are presumably intentional, so just allow them, while still blocking other packets that should take the aggregation path. PR: kern/138620 Approved by: thompsa@ Modified: head/sys/net/if_lagg.c Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Wed May 2 21:50:13 2012 (r234935) +++ head/sys/net/if_lagg.c Thu May 3 01:41:12 2012 (r234936) @@ -764,28 +764,18 @@ fallback: return (EINVAL); } +/* + * For direct output to child ports. + */ static int lagg_port_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; - struct ether_header *eh; - short type = 0; switch (dst->sa_family) { case pseudo_AF_HDRCMPLT: case AF_UNSPEC: - eh = (struct ether_header *)dst->sa_data; - type = eh->ether_type; - break; - } - - /* - * Only allow ethernet types required to initiate or maintain the link, - * aggregated frames take a different path. - */ - switch (ntohs(type)) { - case ETHERTYPE_PAE: /* EAPOL PAE/802.1x */ return ((*lp->lp_output)(ifp, m, dst, ro)); } From owner-svn-src-all@FreeBSD.ORG Thu May 3 03:05:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B05E8106566B; Thu, 3 May 2012 03:05:19 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 98F8E8FC0A; Thu, 3 May 2012 03:05:19 +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 q4335JD5015979; Thu, 3 May 2012 03:05:19 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4335Js5015973; Thu, 3 May 2012 03:05:19 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201205030305.q4335Js5015973@svn.freebsd.org> From: David Xu Date: Thu, 3 May 2012 03:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234937 - in stable/8: lib/libthr/thread sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 03:05:19 -0000 Author: davidxu Date: Thu May 3 03:05:18 2012 New Revision: 234937 URL: http://svn.freebsd.org/changeset/base/234937 Log: Merge 233103, 233912 from head: 233103: Some software think a mutex can be destroyed after it owned it, for example, it uses a serialization point like following: pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex); pthread_mutex_destroy(&muetx); They think a previous lock holder should have already left the mutex and is no longer referencing it, so they destroy it. To be maximum compatible with such code, we use IA64 version to unlock the mutex in kernel, remove the two steps unlocking code. 233912: umtx operation UMTX_OP_MUTEX_WAKE has a side-effect that it accesses a mutex after a thread has unlocked it, it event writes data to the mutex memory to clear contention bit, there is a race that other threads can lock it and unlock it, then destroy it, so it should not write data to the mutex memory if there isn't any waiter. The new operation UMTX_OP_MUTEX_WAKE2 try to fix the problem. It requires thread library to clear the lock word entirely, then call the WAKE2 operation to check if there is any waiter in kernel, and try to wake up a thread, if necessary, the contention bit is set again by the operation. This also mitgates the chance that other threads find the contention bit and try to enter kernel to compete with each other to wake up sleeping thread, this is unnecessary. With this change, the mutex owner is no longer holding the mutex until it reaches a point where kernel umtx queue is locked, it releases the mutex as soon as possible. Performance is improved when the mutex is contensted heavily. On Intel i3-2310M, the runtime of a benchmark program is reduced from 26.87 seconds to 2.39 seconds, it even is better than UMTX_OP_MUTEX_WAKE which is deprecated now. http://people.freebsd.org/~davidxu/bench/mutex_perf.c Special code for stable/8: And add code to detect if the UMTX_OP_MUTEX_WAKE2 is available. PR: threads/167308 Modified: stable/8/lib/libthr/thread/thr_private.h stable/8/lib/libthr/thread/thr_umtx.c stable/8/lib/libthr/thread/thr_umtx.h stable/8/sys/kern/kern_umtx.c stable/8/sys/sys/umtx.h Directory Properties: stable/8/lib/libthr/ (props changed) Modified: stable/8/lib/libthr/thread/thr_private.h ============================================================================== --- stable/8/lib/libthr/thread/thr_private.h Thu May 3 01:41:12 2012 (r234936) +++ stable/8/lib/libthr/thread/thr_private.h Thu May 3 03:05:18 2012 (r234937) @@ -706,8 +706,6 @@ ssize_t __sys_write(int, const void *, s void __sys_exit(int); #endif -int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden; - static inline int _thr_isthreaded(void) { Modified: stable/8/lib/libthr/thread/thr_umtx.c ============================================================================== --- stable/8/lib/libthr/thread/thr_umtx.c Thu May 3 01:41:12 2012 (r234936) +++ stable/8/lib/libthr/thread/thr_umtx.c Thu May 3 03:05:18 2012 (r234937) @@ -112,6 +112,35 @@ __thr_umutex_timedlock(struct umutex *mt int __thr_umutex_unlock(struct umutex *mtx, uint32_t id) { + static int wake2_avail = 0; + + if (__predict_false(wake2_avail == 0)) { + struct umutex test = DEFAULT_UMUTEX; + + if (_umtx_op(&test, UMTX_OP_MUTEX_WAKE2, test.m_flags, 0, 0) == -1) + wake2_avail = -1; + else + wake2_avail = 1; + } + + if (wake2_avail != 1) + goto unlock; + + uint32_t flags = mtx->m_flags; + + if ((flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) { + uint32_t owner; + do { + owner = mtx->m_owner; + if (__predict_false((owner & ~UMUTEX_CONTESTED) != id)) + return (EPERM); + } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner, + owner, UMUTEX_UNOWNED))); + if ((owner & UMUTEX_CONTESTED)) + (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2, flags, 0, 0); + return (0); + } +unlock: return _umtx_op_err(mtx, UMTX_OP_MUTEX_UNLOCK, 0, 0, 0); } Modified: stable/8/lib/libthr/thread/thr_umtx.h ============================================================================== --- stable/8/lib/libthr/thread/thr_umtx.h Thu May 3 01:41:12 2012 (r234936) +++ stable/8/lib/libthr/thread/thr_umtx.h Thu May 3 03:05:18 2012 (r234937) @@ -34,6 +34,7 @@ #define DEFAULT_UMUTEX {0,0, {0,0},{0,0,0,0}} +int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden; int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, const struct timespec *timeout) __hidden; @@ -100,9 +101,9 @@ _thr_umutex_timedlock(struct umutex *mtx static inline int _thr_umutex_unlock(struct umutex *mtx, uint32_t id) { - if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED)) - return (0); - return (__thr_umutex_unlock(mtx, id)); + if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED)) + return (0); + return (__thr_umutex_unlock(mtx, id)); } static inline int Modified: stable/8/sys/kern/kern_umtx.c ============================================================================== --- stable/8/sys/kern/kern_umtx.c Thu May 3 01:41:12 2012 (r234936) +++ stable/8/sys/kern/kern_umtx.c Thu May 3 03:05:18 2012 (r234937) @@ -1261,6 +1261,78 @@ do_wake_umutex(struct thread *td, struct return (0); } +/* + * Check if the mutex has waiters and tries to fix contention bit. + */ +static int +do_wake2_umutex(struct thread *td, struct umutex *m, uint32_t flags) +{ + struct umtx_key key; + uint32_t owner, old; + int type; + int error; + int count; + + switch(flags & (UMUTEX_PRIO_INHERIT | UMUTEX_PRIO_PROTECT)) { + case 0: + type = TYPE_NORMAL_UMUTEX; + break; + case UMUTEX_PRIO_INHERIT: + type = TYPE_PI_UMUTEX; + break; + case UMUTEX_PRIO_PROTECT: + type = TYPE_PP_UMUTEX; + break; + default: + return (EINVAL); + } + if ((error = umtx_key_get(m, type, GET_SHARE(flags), + &key)) != 0) + return (error); + + owner = 0; + umtxq_lock(&key); + umtxq_busy(&key); + count = umtxq_count(&key); + umtxq_unlock(&key); + /* + * Only repair contention bit if there is a waiter, this means the mutex + * is still being referenced by userland code, otherwise don't update + * any memory. + */ + if (count > 1) { + owner = fuword32(__DEVOLATILE(uint32_t *, &m->m_owner)); + while ((owner & UMUTEX_CONTESTED) ==0) { + old = casuword32(&m->m_owner, owner, + owner|UMUTEX_CONTESTED); + if (old == owner) + break; + owner = old; + } + } else if (count == 1) { + owner = fuword32(__DEVOLATILE(uint32_t *, &m->m_owner)); + while ((owner & ~UMUTEX_CONTESTED) != 0 && + (owner & UMUTEX_CONTESTED) == 0) { + old = casuword32(&m->m_owner, owner, + owner|UMUTEX_CONTESTED); + if (old == owner) + break; + owner = old; + } + } + umtxq_lock(&key); + if (owner == -1) { + error = EFAULT; + umtxq_signal(&key, INT_MAX); + } + else if (count != 0 && (owner & ~UMUTEX_CONTESTED) == 0) + umtxq_signal(&key, 1); + umtxq_unbusy(&key); + umtxq_unlock(&key); + umtx_key_release(&key); + return (error); +} + static inline struct umtx_pi * umtx_pi_alloc(int flags) { @@ -3026,6 +3098,18 @@ __umtx_op_rw_unlock(struct thread *td, s return do_rw_unlock(td, uap->obj); } +static int +__umtx_op_wake2_umutex(struct thread *td, struct _umtx_op_args *uap) +{ + return do_wake2_umutex(td, uap->obj, uap->val); +} + +static int +__umtx_op_not_sup(struct thread *td __unused, struct _umtx_op_args *uap __unused) +{ + return ENOTSUP; +} + typedef int (*_umtx_op_func)(struct thread *td, struct _umtx_op_args *uap); static _umtx_op_func op_table[] = { @@ -3047,7 +3131,11 @@ static _umtx_op_func op_table[] = { __umtx_op_wait_uint_private, /* UMTX_OP_WAIT_UINT_PRIVATE */ __umtx_op_wake_private, /* UMTX_OP_WAKE_PRIVATE */ __umtx_op_wait_umutex, /* UMTX_OP_UMUTEX_WAIT */ - __umtx_op_wake_umutex /* UMTX_OP_UMUTEX_WAKE */ + __umtx_op_wake_umutex, /* UMTX_OP_UMUTEX_WAKE */ + __umtx_op_not_sup, /* UMTX_OP_SEM_WAIT */ + __umtx_op_not_sup, /* UMTX_OP_SEM_WAKE */ + __umtx_op_not_sup, /* UMTX_OP_NWAKE_PRIVATE */ + __umtx_op_wake2_umutex /* UMTX_OP_UMUTEX_WAKE2 */ }; int @@ -3266,7 +3354,11 @@ static _umtx_op_func op_table_compat32[] __umtx_op_wait_uint_private_compat32, /* UMTX_OP_WAIT_UINT_PRIVATE */ __umtx_op_wake_private, /* UMTX_OP_WAKE_PRIVATE */ __umtx_op_wait_umutex_compat32, /* UMTX_OP_UMUTEX_WAIT */ - __umtx_op_wake_umutex /* UMTX_OP_UMUTEX_WAKE */ + __umtx_op_wake_umutex, /* UMTX_OP_UMUTEX_WAKE */ + __umtx_op_not_sup, /* UMTX_OP_SEM_WAIT */ + __umtx_op_not_sup, /* UMTX_OP_SEM_WAKE */ + __umtx_op_not_sup, /* UMTX_OP_NWAKE_PRIVATE */ + __umtx_op_wake2_umutex /* UMTX_OP_UMUTEX_WAKE2 */ }; int Modified: stable/8/sys/sys/umtx.h ============================================================================== --- stable/8/sys/sys/umtx.h Thu May 3 01:41:12 2012 (r234936) +++ stable/8/sys/sys/umtx.h Thu May 3 03:05:18 2012 (r234937) @@ -100,10 +100,11 @@ struct urwlock { #define UMTX_OP_RW_WRLOCK 13 #define UMTX_OP_RW_UNLOCK 14 #define UMTX_OP_WAIT_UINT_PRIVATE 15 -#define UMTX_OP_WAKE_PRIVATE 16 -#define UMTX_OP_MUTEX_WAIT 17 -#define UMTX_OP_MUTEX_WAKE 18 -#define UMTX_OP_MAX 19 +#define UMTX_OP_WAKE_PRIVATE 16 +#define UMTX_OP_MUTEX_WAIT 17 +#define UMTX_OP_MUTEX_WAKE 18 +#define UMTX_OP_MUTEX_WAKE2 22 +#define UMTX_OP_MAX 23 /* flags for UMTX_OP_CV_WAIT */ #define UMTX_CHECK_UNPARKING 0x01 From owner-svn-src-all@FreeBSD.ORG Thu May 3 05:32:57 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 34B82106564A; Thu, 3 May 2012 05:32:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E6EB8FC0A; Thu, 3 May 2012 05:32:57 +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 q435WuTN021395; Thu, 3 May 2012 05:32:56 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q435Wule021387; Thu, 3 May 2012 05:32:56 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205030532.q435Wule021387@svn.freebsd.org> From: Alexander Motin Date: Thu, 3 May 2012 05:32: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: r234940 - in head: sbin/geom/class/raid sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 05:32:57 -0000 Author: mav Date: Thu May 3 05:32:56 2012 New Revision: 234940 URL: http://svn.freebsd.org/changeset/base/234940 Log: Add optional -o argument to the `graid label ` to specify some metadata format options. Use it for specifying byte order for the DDF metadata: big-endian defined by specification and little-endian used by Adaptec. Modified: head/sbin/geom/class/raid/geom_raid.c head/sbin/geom/class/raid/graid.8 head/sys/geom/raid/g_raid.c head/sys/geom/raid/g_raid.h head/sys/geom/raid/g_raid_ctl.c head/sys/geom/raid/g_raid_md_if.m head/sys/geom/raid/md_ddf.c Modified: head/sbin/geom/class/raid/geom_raid.c ============================================================================== --- head/sbin/geom/class/raid/geom_raid.c Thu May 3 05:04:37 2012 (r234939) +++ head/sbin/geom/class/raid/geom_raid.c Thu May 3 05:32:56 2012 (r234940) @@ -48,11 +48,12 @@ struct g_command class_commands[] = { { "label", G_FLAG_VERBOSE, NULL, { { 'f', "force", NULL, G_TYPE_BOOL }, + { 'o', "fmtopt", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'S', "size", G_VAL_OPTIONAL, G_TYPE_NUMBER }, { 's', "strip", G_VAL_OPTIONAL, G_TYPE_NUMBER }, G_OPT_SENTINEL }, - "[-fv] [-S size] [-s stripsize] format label level prov ..." + "[-fv] [-o fmtopt] [-S size] [-s stripsize] format label level prov ..." }, { "add", G_FLAG_VERBOSE, NULL, { Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Thu May 3 05:04:37 2012 (r234939) +++ head/sbin/geom/class/raid/graid.8 Thu May 3 05:32:56 2012 (r234940) @@ -34,6 +34,7 @@ .Nm .Cm label .Op Fl f +.Op Fl o Ar fmtopt .Op Fl S Ar size .Op Fl s Ar strip .Ar format @@ -119,6 +120,8 @@ Additional options include: .It Fl f Enforce specified configuration creation if it is officially unsupported, but technically can be created. +.It Fl o Ar fmtopt +Specifies metadata format options. .It Fl S Ar size Use .Ar size @@ -205,14 +208,18 @@ The format defined by the SNIA Common RA Used by some Adaptec RAID BIOSes and some hardware RAID controllers. Because of high format flexibility different implementations support different set of features and have different on-disk metadata layouts. -To provide compatibility, the GEOM RAID class mimics capabilities and -metadata layout of the first detected DDF array. +To provide compatibility, the GEOM RAID class mimics capabilities +of the first detected DDF array. Respecting that, it may support different number of disks per volume, volumes per array, partitions per disk, etc. The following configurations are supported: RAID0 (2+ disks), RAID1 (2+ disks), RAID1E (3+ disks), RAID3 (3+ disks), RAID4 (3+ disks), RAID5 (3+ disks), RAID5E (4+ disks), RAID5EE (4+ disks), RAID5R (3+ disks), RAID6 (4+ disks), RAIDMDF (5+ disks), RAID10 (4+ disks), SINGLE (1 disk), CONCAT (2+ disks). +.Pp +Format supports two options "BE" and "LE", that mean big-endian byte order +defined by specification (default) and little-endian used by some Adaptec +controllers. .It Intel The format used by Intel RAID BIOS. Supports up to two volumes per array. Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid.c Thu May 3 05:32:56 2012 (r234940) @@ -2143,7 +2143,7 @@ g_raid_taste(struct g_class *mp, struct g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); G_RAID_DEBUG(2, "Tasting provider %s.", pp->name); - gp = g_new_geomf(mp, "mirror:taste"); + gp = g_new_geomf(mp, "raid:taste"); /* * This orphan function should be never called. */ @@ -2173,7 +2173,8 @@ g_raid_taste(struct g_class *mp, struct } int -g_raid_create_node_format(const char *format, struct g_geom **gp) +g_raid_create_node_format(const char *format, struct gctl_req *req, + struct g_geom **gp) { struct g_raid_md_class *class; struct g_raid_md_object *obj; @@ -2191,7 +2192,7 @@ g_raid_create_node_format(const char *fo obj = (void *)kobj_create((kobj_class_t)class, M_RAID, M_WAITOK); obj->mdo_class = class; - status = G_RAID_MD_CREATE(obj, &g_raid_class, gp); + status = G_RAID_MD_CREATE_REQ(obj, &g_raid_class, req, gp); if (status != G_RAID_MD_TASTE_NEW) kobj_delete((kobj_t)obj, M_RAID); return (status); Modified: head/sys/geom/raid/g_raid.h ============================================================================== --- head/sys/geom/raid/g_raid.h Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid.h Thu May 3 05:32:56 2012 (r234940) @@ -382,7 +382,8 @@ const char * g_raid_disk_state2str(int s struct g_raid_softc * g_raid_create_node(struct g_class *mp, const char *name, struct g_raid_md_object *md); -int g_raid_create_node_format(const char *format, struct g_geom **gp); +int g_raid_create_node_format(const char *format, struct gctl_req *req, + struct g_geom **gp); struct g_raid_volume * g_raid_create_volume(struct g_raid_softc *sc, const char *name, int id); struct g_raid_disk * g_raid_create_disk(struct g_raid_softc *sc); Modified: head/sys/geom/raid/g_raid_ctl.c ============================================================================== --- head/sys/geom/raid/g_raid_ctl.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid_ctl.c Thu May 3 05:32:56 2012 (r234940) @@ -88,7 +88,7 @@ g_raid_ctl_label(struct gctl_req *req, s gctl_error(req, "No format recieved."); return; } - crstatus = g_raid_create_node_format(format, &geom); + crstatus = g_raid_create_node_format(format, req, &geom); if (crstatus == G_RAID_MD_TASTE_FAIL) { gctl_error(req, "Failed to create array with format '%s'.", format); Modified: head/sys/geom/raid/g_raid_md_if.m ============================================================================== --- head/sys/geom/raid/g_raid_md_if.m Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid_md_if.m Thu May 3 05:32:56 2012 (r234940) @@ -49,13 +49,22 @@ HEADER { # Default implementations of methods. CODE { static int - g_raid_md_create_default(struct g_raid_md_object *md) + g_raid_md_create_default(struct g_raid_md_object *md, + struct g_class *mp, struct g_geom **gp) { return (G_RAID_MD_TASTE_FAIL); } static int + g_raid_md_create_req_default(struct g_raid_md_object *md, + struct g_class *mp, struct gctl_req *req, struct g_geom **gp) + { + + return (G_RAID_MD_CREATE(md, mp, gp)); + } + + static int g_raid_md_ctl_default(struct g_raid_md_object *md, struct gctl_req *req) { @@ -95,6 +104,14 @@ METHOD int create { struct g_geom **gp; } DEFAULT g_raid_md_create_default; +# create_req() - create new node from scratch, with request argument. +METHOD int create_req { + struct g_raid_md_object *md; + struct g_class *mp; + struct gctl_req *req; + struct g_geom **gp; +} DEFAULT g_raid_md_create_req_default; + # taste() - taste disk and, if needed, create new node. METHOD int taste { struct g_raid_md_object *md; Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/md_ddf.c Thu May 3 05:32:56 2012 (r234940) @@ -88,6 +88,7 @@ struct g_raid_md_ddf_pervolume { struct g_raid_md_ddf_object { struct g_raid_md_object mdio_base; + u_int mdio_bigendian; struct ddf_meta mdio_meta; int mdio_starting; struct callout mdio_start_co; /* STARTING state timer. */ @@ -95,7 +96,7 @@ struct g_raid_md_ddf_object { struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ }; -static g_raid_md_create_t g_raid_md_create_ddf; +static g_raid_md_create_req_t g_raid_md_create_req_ddf; static g_raid_md_taste_t g_raid_md_taste_ddf; static g_raid_md_event_t g_raid_md_event_ddf; static g_raid_md_volume_event_t g_raid_md_volume_event_ddf; @@ -107,7 +108,7 @@ static g_raid_md_free_volume_t g_raid_md static g_raid_md_free_t g_raid_md_free_ddf; static kobj_method_t g_raid_md_ddf_methods[] = { - KOBJMETHOD(g_raid_md_create, g_raid_md_create_ddf), + KOBJMETHOD(g_raid_md_create_req, g_raid_md_create_req_ddf), KOBJMETHOD(g_raid_md_taste, g_raid_md_taste_ddf), KOBJMETHOD(g_raid_md_event, g_raid_md_event_ddf), KOBJMETHOD(g_raid_md_volume_event, g_raid_md_volume_event_ddf), @@ -562,6 +563,7 @@ ddf_meta_create(struct g_raid_disk *disk struct timespec ts; struct clocktime ct; struct g_raid_md_ddf_perdisk *pd; + struct g_raid_md_ddf_object *mdi; struct ddf_meta *meta; struct ddf_pd_entry *pde; off_t anchorlba; @@ -572,13 +574,14 @@ ddf_meta_create(struct g_raid_disk *disk if (sample->hdr == NULL) sample = NULL; + mdi = (struct g_raid_md_ddf_object *)disk->d_softc->sc_md; pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; meta = &pd->pd_meta; ss = disk->d_consumer->provider->sectorsize; anchorlba = disk->d_consumer->provider->mediasize / ss - 1; meta->sectorsize = ss; - meta->bigendian = sample ? sample->bigendian : 0; + meta->bigendian = sample ? sample->bigendian : mdi->mdio_bigendian; getnanotime(&ts); clock_ts_to_ct(&ts, &ct); @@ -2012,11 +2015,26 @@ g_raid_md_ddf_new_disk(struct g_raid_dis } static int -g_raid_md_create_ddf(struct g_raid_md_object *md, struct g_class *mp, - struct g_geom **gp) +g_raid_md_create_req_ddf(struct g_raid_md_object *md, struct g_class *mp, + struct gctl_req *req, struct g_geom **gp) { struct g_geom *geom; struct g_raid_softc *sc; + struct g_raid_md_ddf_object *mdi, *mdi1; + char name[16]; + const char *fmtopt; + int be = 1; + + mdi = (struct g_raid_md_ddf_object *)md; + fmtopt = gctl_get_asciiparam(req, "fmtopt"); + if (fmtopt == NULL || strcasecmp(fmtopt, "BE") == 0) + be = 1; + else if (strcasecmp(fmtopt, "LE") == 0) + be = 0; + else { + gctl_error(req, "Incorrect fmtopt argument."); + return (G_RAID_MD_TASTE_FAIL); + } /* Search for existing node. */ LIST_FOREACH(geom, &mp->geom, geom) { @@ -2027,6 +2045,9 @@ g_raid_md_create_ddf(struct g_raid_md_ob continue; if (sc->sc_md->mdo_class != md->mdo_class) continue; + mdi1 = (struct g_raid_md_ddf_object *)sc->sc_md; + if (mdi1->mdio_bigendian != be) + continue; break; } if (geom != NULL) { @@ -2035,7 +2056,9 @@ g_raid_md_create_ddf(struct g_raid_md_ob } /* Create new one if not found. */ - sc = g_raid_create_node(mp, "DDF", md); + mdi->mdio_bigendian = be; + snprintf(name, sizeof(name), "DDF%s", be ? "" : "-LE"); + sc = g_raid_create_node(mp, name, md); if (sc == NULL) return (G_RAID_MD_TASTE_FAIL); md->mdo_softc = sc; @@ -2053,11 +2076,13 @@ g_raid_md_taste_ddf(struct g_raid_md_obj struct g_raid_disk *disk; struct ddf_meta meta; struct g_raid_md_ddf_perdisk *pd; + struct g_raid_md_ddf_object *mdi; struct g_geom *geom; - int error, result, len; + int error, result, len, be; char name[16]; G_RAID_DEBUG(1, "Tasting DDF on %s", cp->provider->name); + mdi = (struct g_raid_md_ddf_object *)md; pp = cp->provider; /* Read metadata from device. */ @@ -2070,6 +2095,7 @@ g_raid_md_taste_ddf(struct g_raid_md_obj g_access(cp, -1, 0, 0); if (error != 0) return (G_RAID_MD_TASTE_FAIL); + be = meta.bigendian; /* Metadata valid. Print it. */ g_raid_md_ddf_print(&meta); @@ -2084,6 +2110,9 @@ g_raid_md_taste_ddf(struct g_raid_md_obj continue; if (sc->sc_md->mdo_class != md->mdo_class) continue; + mdi = (struct g_raid_md_ddf_object *)sc->sc_md; + if (mdi->mdio_bigendian != be) + continue; break; } @@ -2094,7 +2123,8 @@ g_raid_md_taste_ddf(struct g_raid_md_obj } else { /* Not found matching node -- create one. */ result = G_RAID_MD_TASTE_NEW; - snprintf(name, sizeof(name), "DDF"); + mdi->mdio_bigendian = be; + snprintf(name, sizeof(name), "DDF%s", be ? "" : "-LE"); sc = g_raid_create_node(mp, name, md); md->mdo_softc = sc; geom = sc->sc_geom; From owner-svn-src-all@FreeBSD.ORG Thu May 3 05:52:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 63655106568E; Thu, 3 May 2012 05:52:40 +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 4E6DA8FC0C; Thu, 3 May 2012 05:52:40 +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 q435qebH022094; Thu, 3 May 2012 05:52:40 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q435qemq022092; Thu, 3 May 2012 05:52:40 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205030552.q435qemq022092@svn.freebsd.org> From: Adrian Chadd Date: Thu, 3 May 2012 05:52:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234941 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 05:52:40 -0000 Author: adrian Date: Thu May 3 05:52:39 2012 New Revision: 234941 URL: http://svn.freebsd.org/changeset/base/234941 Log: Fix a totally bone-headed, last minute bounds check snafu that somehow I must've missed when booting a test kernel. This has been validated on the AR7161. Modified: head/sys/mips/atheros/ar71xx_chip.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Thu May 3 05:32:56 2012 (r234940) +++ head/sys/mips/atheros/ar71xx_chip.c Thu May 3 05:52:39 2012 (r234941) @@ -192,21 +192,23 @@ ar71xx_chip_set_mii_if(uint32_t unit, ui mii_if = MII0_CTRL_IF_RGMII; else if (mii_mode == AR71XX_MII_MODE_RMII) mii_if = MII0_CTRL_IF_RMII; - else + else { printf("%s: invalid MII mode (%d) for unit %d\n", __func__, mii_mode, unit); return; + } break; case 1: reg = AR71XX_MII1_CTRL; if (mii_mode == AR71XX_MII_MODE_RGMII) mii_if = MII1_CTRL_IF_RGMII; - if (mii_mode == AR71XX_MII_MODE_RMII) + else if (mii_mode == AR71XX_MII_MODE_RMII) mii_if = MII1_CTRL_IF_RMII; - else + else { printf("%s: invalid MII mode (%d) for unit %d\n", __func__, mii_mode, unit); return; + } break; default: printf("%s: invalid MII unit set for arge unit: %d\n", From owner-svn-src-all@FreeBSD.ORG Thu May 3 07:12:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13326106566B; Thu, 3 May 2012 07:12:39 +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 F12568FC18; Thu, 3 May 2012 07:12:38 +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 q437Cc26024970; Thu, 3 May 2012 07:12:38 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437Ccw7024968; Thu, 3 May 2012 07:12:38 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205030712.q437Ccw7024968@svn.freebsd.org> From: Michael Tuexen Date: Thu, 3 May 2012 07:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234942 - stable/9/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:12:39 -0000 Author: tuexen Date: Thu May 3 07:12:38 2012 New Revision: 234942 URL: http://svn.freebsd.org/changeset/base/234942 Log: MFC r234715,r234716: Export symbols for sctp_sendv() and sctp_recvv(). Move sctp_sendv and sctp_recvv to FBSD_1.3 as suggested by Konstantin Belousov. Modified: stable/9/lib/libc/net/Symbol.map Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/Symbol.map ============================================================================== --- stable/9/lib/libc/net/Symbol.map Thu May 3 05:52:39 2012 (r234941) +++ stable/9/lib/libc/net/Symbol.map Thu May 3 07:12:38 2012 (r234942) @@ -143,6 +143,11 @@ FBSD_1.0 { setsourcefilter; }; +FBSD_1.3 { + sctp_recvv; + sctp_sendv; +}; + FBSDprivate_1.0 { _nsdispatch; _nsyyerror; /* generated from nslexer.l */ From owner-svn-src-all@FreeBSD.ORG Thu May 3 07:17:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B84C0106566B; Thu, 3 May 2012 07:17:25 +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 A31958FC08; Thu, 3 May 2012 07:17: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 q437HPUE025205; Thu, 3 May 2012 07:17:25 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437HPO6025203; Thu, 3 May 2012 07:17:25 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205030717.q437HPO6025203@svn.freebsd.org> From: Michael Tuexen Date: Thu, 3 May 2012 07:17:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234943 - stable/8/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:17:25 -0000 Author: tuexen Date: Thu May 3 07:17:25 2012 New Revision: 234943 URL: http://svn.freebsd.org/changeset/base/234943 Log: MFC r234715,r234716: Export symbols for sctp_sendv() and sctp_recvv(). Move sctp_sendv and sctp_recvv to FBSD_1.3 as suggested by Konstantin Belousov. Modified: stable/8/lib/libc/net/Symbol.map Directory Properties: stable/8/lib/ (props changed) stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/net/Symbol.map ============================================================================== --- stable/8/lib/libc/net/Symbol.map Thu May 3 07:12:38 2012 (r234942) +++ stable/8/lib/libc/net/Symbol.map Thu May 3 07:17:25 2012 (r234943) @@ -143,6 +143,11 @@ FBSD_1.0 { setsourcefilter; }; +FBSD_1.3 { + sctp_recvv; + sctp_sendv; +}; + FBSDprivate_1.0 { _nsdispatch; _nsyyerror; /* generated from nslexer.l */ From owner-svn-src-all@FreeBSD.ORG Thu May 3 07:22:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1EA901065673; Thu, 3 May 2012 07:22:30 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 08D9C8FC12; Thu, 3 May 2012 07:22: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 q437MTSe025468; Thu, 3 May 2012 07:22:29 GMT (envelope-from daichi@svn.freebsd.org) Received: (from daichi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437MTrh025466; Thu, 3 May 2012 07:22:29 GMT (envelope-from daichi@svn.freebsd.org) Message-Id: <201205030722.q437MTrh025466@svn.freebsd.org> From: Daichi GOTO Date: Thu, 3 May 2012 07:22: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: r234944 - head/sys/fs/unionfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:22:30 -0000 Author: daichi Date: Thu May 3 07:22:29 2012 New Revision: 234944 URL: http://svn.freebsd.org/changeset/base/234944 Log: fixed a unionfs_readdir math issue PR: 132987 Submitted by: Matthew Fleming Modified: head/sys/fs/unionfs/union_vnops.c Modified: head/sys/fs/unionfs/union_vnops.c ============================================================================== --- head/sys/fs/unionfs/union_vnops.c Thu May 3 07:17:25 2012 (r234943) +++ head/sys/fs/unionfs/union_vnops.c Thu May 3 07:22:29 2012 (r234944) @@ -1642,7 +1642,7 @@ unionfs_readdir(struct vop_readdir_args pos = newcookies; memcpy(pos, cookies_bk, ncookies_bk * sizeof(u_long)); - pos += ncookies_bk * sizeof(u_long); + pos += ncookies_bk; memcpy(pos, *(ap->a_cookies), *(ap->a_ncookies) * sizeof(u_long)); free(cookies_bk, M_TEMP); free(*(ap->a_cookies), M_TEMP); From owner-svn-src-all@FreeBSD.ORG Thu May 3 07:48:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6C760106566B; Thu, 3 May 2012 07:48:20 +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 573D38FC19; Thu, 3 May 2012 07:48:20 +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 q437mK08026460; Thu, 3 May 2012 07:48:20 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437mKH9026458; Thu, 3 May 2012 07:48:20 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205030748.q437mKH9026458@svn.freebsd.org> From: Adrian Chadd Date: Thu, 3 May 2012 07:48:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234945 - head/sys/mips/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:48:20 -0000 Author: adrian Date: Thu May 3 07:48:19 2012 New Revision: 234945 URL: http://svn.freebsd.org/changeset/base/234945 Log: In the new world order, multiphy is now when the phymask is 0x0. This makes the TP-WN1043ND (ar913x based) work again. Modified: head/sys/mips/conf/TP-WN1043ND.hints Modified: head/sys/mips/conf/TP-WN1043ND.hints ============================================================================== --- head/sys/mips/conf/TP-WN1043ND.hints Thu May 3 07:22:29 2012 (r234944) +++ head/sys/mips/conf/TP-WN1043ND.hints Thu May 3 07:48:19 2012 (r234945) @@ -4,7 +4,8 @@ # $FreeBSD$ # Hard-code the PHY for now, until there's switch phy support. -hint.arge.0.phymask=0x000c +# hint.arge.0.phymask=0x000c +hint.arge.0.phymask=0x0000 hint.arge.0.media=1000 hint.arge.0.fduplex=1 # Where is the MAC address stored in flash for this particular unit. From owner-svn-src-all@FreeBSD.ORG Thu May 3 08:56:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A59991065673; Thu, 3 May 2012 08:56:44 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DE618FC17; Thu, 3 May 2012 08:56:44 +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 q438ui8L028957; Thu, 3 May 2012 08:56:44 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q438ui7R028950; Thu, 3 May 2012 08:56:44 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201205030856.q438ui7R028950@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Thu, 3 May 2012 08:56:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234946 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 08:56:44 -0000 Author: melifaro Date: Thu May 3 08:56:43 2012 New Revision: 234946 URL: http://svn.freebsd.org/changeset/base/234946 Log: Revert r234834 per luigi@ request. Cleaner solution (e.g. adding another header) should be done here. Original log: Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. Remove ipfw/ip_fw_private.h header from non-ipfw code. Requested by: luigi Approved by: kib(mentor) Modified: head/sys/contrib/pf/net/pf.c head/sys/net/if_bridge.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_fw.h head/sys/netinet/ipfw/ip_fw_private.h head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Modified: head/sys/contrib/pf/net/pf.c ============================================================================== --- head/sys/contrib/pf/net/pf.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/contrib/pf/net/pf.c Thu May 3 08:56:43 2012 (r234946) @@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef __FreeBSD__ #include +#include /* XXX: only for DIR_IN/DIR_OUT */ #endif #ifndef __FreeBSD__ Modified: head/sys/net/if_bridge.c ============================================================================== --- head/sys/net/if_bridge.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/net/if_bridge.c Thu May 3 08:56:43 2012 (r234946) @@ -132,6 +132,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include /* * Size of the route hash table. Must be a power of two. Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/net/if_ethersubr.c Thu May 3 08:56:43 2012 (r234946) @@ -72,6 +72,7 @@ #include #include #include +#include #endif #ifdef INET6 #include Modified: head/sys/netinet/ip_fw.h ============================================================================== --- head/sys/netinet/ip_fw.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/netinet/ip_fw.h Thu May 3 08:56:43 2012 (r234946) @@ -545,88 +545,6 @@ struct ipfw_flow_id { #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) -#ifdef _KERNEL -/* Return values from ipfw_[ether_]chk() */ -enum { - IP_FW_PASS = 0, - IP_FW_DENY, - IP_FW_DIVERT, - IP_FW_TEE, - IP_FW_DUMMYNET, - IP_FW_NETGRAPH, - IP_FW_NGTEE, - IP_FW_NAT, - IP_FW_REASS, -}; - -/* - * Hooks sometime need to know the direction of the packet - * (divert, dummynet, netgraph, ...) - * We use a generic definition here, with bit0-1 indicating the - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the - * specific protocol (if necessary) - */ -enum { - DIR_MASK = 0x3, - DIR_OUT = 0, - DIR_IN = 1, - DIR_FWD = 2, - DIR_DROP = 3, - PROTO_LAYER2 = 0x4, /* set for layer 2 */ - /* PROTO_DEFAULT = 0, */ - PROTO_IPV4 = 0x08, - PROTO_IPV6 = 0x10, - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ - /* PROTO_OLDBDG = 0x14, unused, old bridge */ -}; - -/* - * Structure for collecting parameters to dummynet for ip6_output forwarding - */ -struct _ip6dn_args { - struct ip6_pktopts *opt_or; - struct route_in6 ro_or; - int flags_or; - struct ip6_moptions *im6o_or; - struct ifnet *origifp_or; - struct ifnet *ifp_or; - struct sockaddr_in6 dst_or; - u_long mtu_or; - struct route_in6 ro_pmtu_or; -}; - -/* - * Arguments for calling ipfw_chk() and dummynet_io(). We put them - * all into a structure because this way it is easier and more - * efficient to pass variables around and extend the interface. - */ -struct ip_fw_args { - struct mbuf *m; /* the mbuf chain */ - struct ifnet *oif; /* output interface */ - struct sockaddr_in *next_hop; /* forward address */ - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ - - /* - * On return, it points to the matching rule. - * On entry, rule.slot > 0 means the info is valid and - * contains the starting rule for an ipfw search. - * If chain_id == chain->id && slot >0 then jump to that slot. - * Otherwise, we locate the first rule >= rulenum:rule_id - */ - struct ipfw_rule_ref rule; /* match/restart info */ - - struct ether_header *eh; /* for bridged packets */ - - struct ipfw_flow_id f_id; /* grabbed from IP header */ - //uint32_t cookie; /* a cookie depending on rule action */ - struct inpcb *inp; - - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ -}; - -#endif /* _KERNEL */ - /* * Dynamic ipfw rule. */ Modified: head/sys/netinet/ipfw/ip_fw_private.h ============================================================================== --- head/sys/netinet/ipfw/ip_fw_private.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/netinet/ipfw/ip_fw_private.h Thu May 3 08:56:43 2012 (r234946) @@ -48,8 +48,89 @@ #define SYSEND #endif +/* Return values from ipfw_chk() */ +enum { + IP_FW_PASS = 0, + IP_FW_DENY, + IP_FW_DIVERT, + IP_FW_TEE, + IP_FW_DUMMYNET, + IP_FW_NETGRAPH, + IP_FW_NGTEE, + IP_FW_NAT, + IP_FW_REASS, +}; + +/* + * Structure for collecting parameters to dummynet for ip6_output forwarding + */ +struct _ip6dn_args { + struct ip6_pktopts *opt_or; + struct route_in6 ro_or; + int flags_or; + struct ip6_moptions *im6o_or; + struct ifnet *origifp_or; + struct ifnet *ifp_or; + struct sockaddr_in6 dst_or; + u_long mtu_or; + struct route_in6 ro_pmtu_or; +}; + + +/* + * Arguments for calling ipfw_chk() and dummynet_io(). We put them + * all into a structure because this way it is easier and more + * efficient to pass variables around and extend the interface. + */ +struct ip_fw_args { + struct mbuf *m; /* the mbuf chain */ + struct ifnet *oif; /* output interface */ + struct sockaddr_in *next_hop; /* forward address */ + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ + + /* + * On return, it points to the matching rule. + * On entry, rule.slot > 0 means the info is valid and + * contains the starting rule for an ipfw search. + * If chain_id == chain->id && slot >0 then jump to that slot. + * Otherwise, we locate the first rule >= rulenum:rule_id + */ + struct ipfw_rule_ref rule; /* match/restart info */ + + struct ether_header *eh; /* for bridged packets */ + + struct ipfw_flow_id f_id; /* grabbed from IP header */ + //uint32_t cookie; /* a cookie depending on rule action */ + struct inpcb *inp; + + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ +}; + MALLOC_DECLARE(M_IPFW); +/* + * Hooks sometime need to know the direction of the packet + * (divert, dummynet, netgraph, ...) + * We use a generic definition here, with bit0-1 indicating the + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the + * specific protocol + * indicating the protocol (if necessary) + */ +enum { + DIR_MASK = 0x3, + DIR_OUT = 0, + DIR_IN = 1, + DIR_FWD = 2, + DIR_DROP = 3, + PROTO_LAYER2 = 0x4, /* set for layer 2 */ + /* PROTO_DEFAULT = 0, */ + PROTO_IPV4 = 0x08, + PROTO_IPV6 = 0x10, + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ + /* PROTO_OLDBDG = 0x14, unused, old bridge */ +}; + /* wrapper for freeing a packet, in case we need to do more work */ #ifndef FREE_PKT #if defined(__linux__) || defined(_WIN32) Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Thu May 3 08:56:43 2012 (r234946) @@ -68,6 +68,7 @@ #include #include #include +#include #endif #ifdef INET6 #include From owner-svn-src-all@FreeBSD.ORG Thu May 3 09:04:55 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by hub.freebsd.org (Postfix) with ESMTP id 9CB30106566C; Thu, 3 May 2012 09:04:55 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from dhcp170-36-red.yandex.net (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx2.freebsd.org (Postfix) with ESMTP id D20951508CC; Thu, 3 May 2012 09:04:53 +0000 (UTC) Message-ID: <4FA24920.4080809@FreeBSD.org> Date: Thu, 03 May 2012 13:00:16 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111117 Thunderbird/8.0 MIME-Version: 1.0 To: Luigi Rizzo References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> <20120430133904.GA65792@onelab2.iet.unipi.it> In-Reply-To: <20120430133904.GA65792@onelab2.iet.unipi.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:04:55 -0000 On 30.04.2012 17:39, Luigi Rizzo wrote: > On Mon, Apr 30, 2012 at 04:17:30PM +0400, Alexander V. Chernikov wrote: >> On 30.04.2012 15:36, Gleb Smirnoff wrote: >>> On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: >>> L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: >>> L> > Author: melifaro >>> L> > Date: Mon Apr 30 10:22:23 2012 >>> L> > New Revision: 234834 >>> L> > URL: http://svn.freebsd.org/changeset/base/234834 >>> L> > >>> L> > Log: >>> L> > Move several enums and structures required for L2 filtering from >>> ip_fw_private.h to ip_fw.h. >>> L> >>> L> I would be really grateful if you could revert this back and discuss >>> L> what you wanted to achieve with this change other than saving one >>> L> entry in the list of includes. >> Changing something inside ip_fw_private.h (for example, locking change) >> requires changes in several totally unrelated subsystems, which is >> clearly bad. > > There are certainly good reasons to split things even further > (as Gleb suggested) so if you want to follow that route > and have patches for review i will be glad to discuss that. Yup. I'll make another patch > > I am the first one to say that the name ip_fw_private.h is confusing, > but at the time i did not feel brave enough to move from a single > header (ip_fw.h) to the four (ip_fw.h, ip_fw_user.h, ip_fw_kernel.h, > ip_fw_kernel_private.h) that would be needed for proper confinement > of information. > > This said, the change you have made introduce a worse form of header > pollution and this is why i am requesting a backout. Reverted in r234946 > >>> L> >>> L> As clearly mentioned in the commit logs >>> L> >>> L> http://svnweb.freebsd.org/base?view=revision&revision=200580 >> Maybe there are some other possibilities documenting preferred layout >> other than commit log? Searching 2+yrs commit history is not the best >> way of finding information. > > sure, you could have asked people involved with ipfw development > to review this change. > > Also don't expect a single policy in style(9) to hold for all > possible situations: the kernel is huge, it has parts that come > from multiple origins in time and space, and sometimes is shared > with other OSs as well. Refactoring (such as your changes) should > keep that in mind. > > Let's not make a big deal of this thing: we all make mistakes or > have different opinions on how things should be done, and the only > way to avoid them is to discuss thing in advance, or be open to > resolve things when problems arise. No hard feelings. Ok :) > > cheers > luigi > -- WBR, Alexander From owner-svn-src-all@FreeBSD.ORG Thu May 3 09:17:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0B05D106566B; Thu, 3 May 2012 09:17:32 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D066D8FC0C; Thu, 3 May 2012 09:17: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 q439HVYA029732; Thu, 3 May 2012 09:17:31 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q439HVln029728; Thu, 3 May 2012 09:17:31 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201205030917.q439HVln029728@svn.freebsd.org> From: David Xu Date: Thu, 3 May 2012 09:17: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: r234947 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:17:32 -0000 Author: davidxu Date: Thu May 3 09:17:31 2012 New Revision: 234947 URL: http://svn.freebsd.org/changeset/base/234947 Log: MFp4: Enqueue thread in LIFO, this can cause starvation, but it gives better performance. Use _thr_queuefifo to control the frequency of FIFO vs LIFO, you can use environment string LIBPTHREAD_QUEUE_FIFO to configure the variable. Modified: head/lib/libthr/thread/thr_init.c head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_sleepq.c Modified: head/lib/libthr/thread/thr_init.c ============================================================================== --- head/lib/libthr/thread/thr_init.c Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_init.c Thu May 3 09:17:31 2012 (r234947) @@ -112,6 +112,7 @@ size_t _thr_stack_initial = THR_STACK_I int _thr_page_size; int _thr_spinloops; int _thr_yieldloops; +int _thr_queuefifo = 4; int _gc_count; struct umutex _mutex_static_lock = DEFAULT_UMUTEX; struct umutex _cond_static_lock = DEFAULT_UMUTEX; @@ -470,6 +471,9 @@ init_private(void) env = getenv("LIBPTHREAD_YIELDLOOPS"); if (env) _thr_yieldloops = atoi(env); + env = getenv("LIBPTHREAD_QUEUE_FIFO"); + if (env) + _thr_queuefifo = atoi(env); TAILQ_INIT(&_thr_atfork_list); } init_once = 1; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_private.h Thu May 3 09:17:31 2012 (r234947) @@ -710,6 +710,7 @@ extern size_t _thr_stack_initial __hidde extern int _thr_page_size __hidden; extern int _thr_spinloops __hidden; extern int _thr_yieldloops __hidden; +extern int _thr_queuefifo __hidden; /* Garbage thread count. */ extern int _gc_count __hidden; Modified: head/lib/libthr/thread/thr_sleepq.c ============================================================================== --- head/lib/libthr/thread/thr_sleepq.c Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_sleepq.c Thu May 3 09:17:31 2012 (r234947) @@ -39,6 +39,7 @@ struct sleepqueue_chain { struct umutex sc_lock; + int sc_enqcnt; LIST_HEAD(, sleepqueue) sc_queues; int sc_type; }; @@ -124,7 +125,10 @@ _sleepq_add(void *wchan, struct pthread } td->sleepqueue = NULL; td->wchan = wchan; - TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle); + if (((++sc->sc_enqcnt << _thr_queuefifo) & 0xff) != 0) + TAILQ_INSERT_HEAD(&sq->sq_blocked, td, wle); + else + TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle); } int From owner-svn-src-all@FreeBSD.ORG Thu May 3 09:47:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CF3DB106564A; Thu, 3 May 2012 09:47:22 +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 B96F08FC0C; Thu, 3 May 2012 09:47:22 +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 q439lMtf030810; Thu, 3 May 2012 09:47:22 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q439lML1030808; Thu, 3 May 2012 09:47:22 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205030947.q439lML1030808@svn.freebsd.org> From: Michael Tuexen Date: Thu, 3 May 2012 09:47:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234948 - stable/9/contrib/traceroute X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:47:22 -0000 Author: tuexen Date: Thu May 3 09:47:22 2012 New Revision: 234948 URL: http://svn.freebsd.org/changeset/base/234948 Log: MFC r234701: Fix a bug in the TCP tracerouting which resulted in not accepting any incoming packets. So all packets seemed to be lost. Modified: stable/9/contrib/traceroute/traceroute.c Directory Properties: stable/9/contrib/traceroute/ (props changed) Modified: stable/9/contrib/traceroute/traceroute.c ============================================================================== --- stable/9/contrib/traceroute/traceroute.c Thu May 3 09:17:31 2012 (r234947) +++ stable/9/contrib/traceroute/traceroute.c Thu May 3 09:47:22 2012 (r234948) @@ -1406,8 +1406,7 @@ tcp_prep(struct outdata *outdata) tcp->th_sport = htons(ident); tcp->th_dport = htons(port + (fixedPort ? 0 : outdata->seq)); - tcp->th_seq = (tcp->th_sport << 16) | (tcp->th_dport + - (fixedPort ? outdata->seq : 0)); + tcp->th_seq = (tcp->th_sport << 16) | tcp->th_dport; tcp->th_ack = 0; tcp->th_off = 5; tcp->th_flags = TH_SYN; @@ -1425,8 +1424,8 @@ tcp_check(const u_char *data, int seq) struct tcphdr *const tcp = (struct tcphdr *) data; return (ntohs(tcp->th_sport) == ident - && ntohs(tcp->th_dport) == port + (fixedPort ? 0 : seq)) - && tcp->th_seq == (((tcp_seq)ident << 16) | (port + seq)); + && ntohs(tcp->th_dport) == port + (fixedPort ? 0 : seq) + && tcp->th_seq == (tcp_seq)((tcp->th_sport << 16) | tcp->th_dport)); } void From owner-svn-src-all@FreeBSD.ORG Thu May 3 09:57:53 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CEBF61065672; Thu, 3 May 2012 09:57:53 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B53428FC16; Thu, 3 May 2012 09:57: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 q439vrlV031209; Thu, 3 May 2012 09:57:53 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q439vrC0031204; Thu, 3 May 2012 09:57:53 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205030957.q439vrC0031204@svn.freebsd.org> From: Baptiste Daroussin Date: Thu, 3 May 2012 09:57:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234949 - in vendor/byacc: . byacc-20120115 byacc-20120115/package byacc-20120115/package/debian byacc-20120115/package/debian/source byacc-20120115/package/pkgsrc byacc-20120115/test d... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:57:53 -0000 Author: bapt Date: Thu May 3 09:57:52 2012 New Revision: 234949 URL: http://svn.freebsd.org/changeset/base/234949 Log: Import byacc 20120115 Approved by: des (mentor) Added: vendor/byacc/ vendor/byacc/byacc-20120115/ vendor/byacc/byacc-20120115/ACKNOWLEDGEMENTS vendor/byacc/byacc-20120115/AUTHORS vendor/byacc/byacc-20120115/CHANGES vendor/byacc/byacc-20120115/Makefile.old (contents, props changed) vendor/byacc/byacc-20120115/NEW_FEATURES vendor/byacc/byacc-20120115/NOTES vendor/byacc/byacc-20120115/NO_WARRANTY vendor/byacc/byacc-20120115/README vendor/byacc/byacc-20120115/VERSION vendor/byacc/byacc-20120115/aclocal.m4 vendor/byacc/byacc-20120115/closure.c (contents, props changed) vendor/byacc/byacc-20120115/config.guess (contents, props changed) vendor/byacc/byacc-20120115/config.sub (contents, props changed) vendor/byacc/byacc-20120115/config_h.in (contents, props changed) vendor/byacc/byacc-20120115/configure (contents, props changed) vendor/byacc/byacc-20120115/configure.in (contents, props changed) vendor/byacc/byacc-20120115/defs.h (contents, props changed) vendor/byacc/byacc-20120115/descrip.mms vendor/byacc/byacc-20120115/error.c (contents, props changed) vendor/byacc/byacc-20120115/graph.c (contents, props changed) vendor/byacc/byacc-20120115/install-sh (contents, props changed) vendor/byacc/byacc-20120115/lalr.c (contents, props changed) vendor/byacc/byacc-20120115/lr0.c (contents, props changed) vendor/byacc/byacc-20120115/main.c (contents, props changed) vendor/byacc/byacc-20120115/makefile.in (contents, props changed) vendor/byacc/byacc-20120115/mkpar.c (contents, props changed) vendor/byacc/byacc-20120115/output.c (contents, props changed) vendor/byacc/byacc-20120115/package/ vendor/byacc/byacc-20120115/package/byacc.spec vendor/byacc/byacc-20120115/package/debian/ vendor/byacc/byacc-20120115/package/debian/changelog vendor/byacc/byacc-20120115/package/debian/compat vendor/byacc/byacc-20120115/package/debian/control vendor/byacc/byacc-20120115/package/debian/copyright vendor/byacc/byacc-20120115/package/debian/docs vendor/byacc/byacc-20120115/package/debian/postinst vendor/byacc/byacc-20120115/package/debian/prerm vendor/byacc/byacc-20120115/package/debian/rules (contents, props changed) vendor/byacc/byacc-20120115/package/debian/source/ vendor/byacc/byacc-20120115/package/debian/source/format vendor/byacc/byacc-20120115/package/debian/watch vendor/byacc/byacc-20120115/package/pkgsrc/ vendor/byacc/byacc-20120115/package/pkgsrc/DESCR vendor/byacc/byacc-20120115/package/pkgsrc/Makefile (contents, props changed) vendor/byacc/byacc-20120115/package/pkgsrc/PLIST vendor/byacc/byacc-20120115/package/pkgsrc/distinfo vendor/byacc/byacc-20120115/reader.c (contents, props changed) vendor/byacc/byacc-20120115/skeleton.c (contents, props changed) vendor/byacc/byacc-20120115/symtab.c (contents, props changed) vendor/byacc/byacc-20120115/test/ vendor/byacc/byacc-20120115/test/README vendor/byacc/byacc-20120115/test/calc.output vendor/byacc/byacc-20120115/test/calc.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/calc.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/calc.y (contents, props changed) vendor/byacc/byacc-20120115/test/calc1.output vendor/byacc/byacc-20120115/test/calc1.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/calc1.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/calc1.y (contents, props changed) vendor/byacc/byacc-20120115/test/calc2.output vendor/byacc/byacc-20120115/test/calc2.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/calc2.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/calc2.y (contents, props changed) vendor/byacc/byacc-20120115/test/calc3.output vendor/byacc/byacc-20120115/test/calc3.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/calc3.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/calc3.y (contents, props changed) vendor/byacc/byacc-20120115/test/code_calc.code.c (contents, props changed) vendor/byacc/byacc-20120115/test/code_calc.output vendor/byacc/byacc-20120115/test/code_calc.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/code_calc.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/code_calc.y (contents, props changed) vendor/byacc/byacc-20120115/test/code_error.code.c (contents, props changed) vendor/byacc/byacc-20120115/test/code_error.output vendor/byacc/byacc-20120115/test/code_error.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/code_error.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/code_error.y (contents, props changed) vendor/byacc/byacc-20120115/test/error.output vendor/byacc/byacc-20120115/test/error.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/error.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/error.y (contents, props changed) vendor/byacc/byacc-20120115/test/ftp.output vendor/byacc/byacc-20120115/test/ftp.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/ftp.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/ftp.y (contents, props changed) vendor/byacc/byacc-20120115/test/grammar.output vendor/byacc/byacc-20120115/test/grammar.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/grammar.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/grammar.y (contents, props changed) vendor/byacc/byacc-20120115/test/pure_calc.output vendor/byacc/byacc-20120115/test/pure_calc.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/pure_calc.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/pure_calc.y (contents, props changed) vendor/byacc/byacc-20120115/test/pure_error.output vendor/byacc/byacc-20120115/test/pure_error.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/pure_error.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/pure_error.y (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc-s.output vendor/byacc/byacc-20120115/test/quote_calc-s.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc-s.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc.output vendor/byacc/byacc-20120115/test/quote_calc.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc.y (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc2-s.output vendor/byacc/byacc-20120115/test/quote_calc2-s.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc2-s.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc2.output vendor/byacc/byacc-20120115/test/quote_calc2.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc2.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc2.y (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc3-s.output vendor/byacc/byacc-20120115/test/quote_calc3-s.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc3-s.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc3.output vendor/byacc/byacc-20120115/test/quote_calc3.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc3.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc3.y (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc4-s.output vendor/byacc/byacc-20120115/test/quote_calc4-s.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc4-s.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc4.output vendor/byacc/byacc-20120115/test/quote_calc4.tab.c (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc4.tab.h (contents, props changed) vendor/byacc/byacc-20120115/test/quote_calc4.y (contents, props changed) vendor/byacc/byacc-20120115/test/run_lint.sh (contents, props changed) vendor/byacc/byacc-20120115/test/run_make.sh (contents, props changed) vendor/byacc/byacc-20120115/test/run_test.sh (contents, props changed) vendor/byacc/byacc-20120115/verbose.c (contents, props changed) vendor/byacc/byacc-20120115/vmsbuild.com vendor/byacc/byacc-20120115/warshall.c (contents, props changed) vendor/byacc/byacc-20120115/yacc.1 (contents, props changed) vendor/byacc/dist/ vendor/byacc/dist/ACKNOWLEDGEMENTS vendor/byacc/dist/AUTHORS vendor/byacc/dist/CHANGES vendor/byacc/dist/Makefile.old (contents, props changed) vendor/byacc/dist/NEW_FEATURES vendor/byacc/dist/NOTES vendor/byacc/dist/NO_WARRANTY vendor/byacc/dist/README vendor/byacc/dist/VERSION vendor/byacc/dist/aclocal.m4 vendor/byacc/dist/closure.c (contents, props changed) vendor/byacc/dist/config.guess (contents, props changed) vendor/byacc/dist/config.sub (contents, props changed) vendor/byacc/dist/config_h.in (contents, props changed) vendor/byacc/dist/configure (contents, props changed) vendor/byacc/dist/configure.in (contents, props changed) vendor/byacc/dist/defs.h (contents, props changed) vendor/byacc/dist/descrip.mms vendor/byacc/dist/error.c (contents, props changed) vendor/byacc/dist/graph.c (contents, props changed) vendor/byacc/dist/install-sh (contents, props changed) vendor/byacc/dist/lalr.c (contents, props changed) vendor/byacc/dist/lr0.c (contents, props changed) vendor/byacc/dist/main.c (contents, props changed) vendor/byacc/dist/makefile.in (contents, props changed) vendor/byacc/dist/mkpar.c (contents, props changed) vendor/byacc/dist/output.c (contents, props changed) vendor/byacc/dist/package/ vendor/byacc/dist/package/byacc.spec vendor/byacc/dist/package/debian/ vendor/byacc/dist/package/debian/changelog vendor/byacc/dist/package/debian/compat vendor/byacc/dist/package/debian/control vendor/byacc/dist/package/debian/copyright vendor/byacc/dist/package/debian/docs vendor/byacc/dist/package/debian/postinst vendor/byacc/dist/package/debian/prerm vendor/byacc/dist/package/debian/rules (contents, props changed) vendor/byacc/dist/package/debian/source/ vendor/byacc/dist/package/debian/source/format vendor/byacc/dist/package/debian/watch vendor/byacc/dist/package/pkgsrc/ vendor/byacc/dist/package/pkgsrc/DESCR vendor/byacc/dist/package/pkgsrc/Makefile (contents, props changed) vendor/byacc/dist/package/pkgsrc/PLIST vendor/byacc/dist/package/pkgsrc/distinfo vendor/byacc/dist/reader.c (contents, props changed) vendor/byacc/dist/skeleton.c (contents, props changed) vendor/byacc/dist/symtab.c (contents, props changed) vendor/byacc/dist/test/ vendor/byacc/dist/test/README vendor/byacc/dist/test/calc.output vendor/byacc/dist/test/calc.tab.c (contents, props changed) vendor/byacc/dist/test/calc.tab.h (contents, props changed) vendor/byacc/dist/test/calc.y (contents, props changed) vendor/byacc/dist/test/calc1.output vendor/byacc/dist/test/calc1.tab.c (contents, props changed) vendor/byacc/dist/test/calc1.tab.h (contents, props changed) vendor/byacc/dist/test/calc1.y (contents, props changed) vendor/byacc/dist/test/calc2.output vendor/byacc/dist/test/calc2.tab.c (contents, props changed) vendor/byacc/dist/test/calc2.tab.h (contents, props changed) vendor/byacc/dist/test/calc2.y (contents, props changed) vendor/byacc/dist/test/calc3.output vendor/byacc/dist/test/calc3.tab.c (contents, props changed) vendor/byacc/dist/test/calc3.tab.h (contents, props changed) vendor/byacc/dist/test/calc3.y (contents, props changed) vendor/byacc/dist/test/code_calc.code.c (contents, props changed) vendor/byacc/dist/test/code_calc.output vendor/byacc/dist/test/code_calc.tab.c (contents, props changed) vendor/byacc/dist/test/code_calc.tab.h (contents, props changed) vendor/byacc/dist/test/code_calc.y (contents, props changed) vendor/byacc/dist/test/code_error.code.c (contents, props changed) vendor/byacc/dist/test/code_error.output vendor/byacc/dist/test/code_error.tab.c (contents, props changed) vendor/byacc/dist/test/code_error.tab.h (contents, props changed) vendor/byacc/dist/test/code_error.y (contents, props changed) vendor/byacc/dist/test/error.output vendor/byacc/dist/test/error.tab.c (contents, props changed) vendor/byacc/dist/test/error.tab.h (contents, props changed) vendor/byacc/dist/test/error.y (contents, props changed) vendor/byacc/dist/test/ftp.output vendor/byacc/dist/test/ftp.tab.c (contents, props changed) vendor/byacc/dist/test/ftp.tab.h (contents, props changed) vendor/byacc/dist/test/ftp.y (contents, props changed) vendor/byacc/dist/test/grammar.output vendor/byacc/dist/test/grammar.tab.c (contents, props changed) vendor/byacc/dist/test/grammar.tab.h (contents, props changed) vendor/byacc/dist/test/grammar.y (contents, props changed) vendor/byacc/dist/test/pure_calc.output vendor/byacc/dist/test/pure_calc.tab.c (contents, props changed) vendor/byacc/dist/test/pure_calc.tab.h (contents, props changed) vendor/byacc/dist/test/pure_calc.y (contents, props changed) vendor/byacc/dist/test/pure_error.output vendor/byacc/dist/test/pure_error.tab.c (contents, props changed) vendor/byacc/dist/test/pure_error.tab.h (contents, props changed) vendor/byacc/dist/test/pure_error.y (contents, props changed) vendor/byacc/dist/test/quote_calc-s.output vendor/byacc/dist/test/quote_calc-s.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc-s.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc.output vendor/byacc/dist/test/quote_calc.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc.y (contents, props changed) vendor/byacc/dist/test/quote_calc2-s.output vendor/byacc/dist/test/quote_calc2-s.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc2-s.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc2.output vendor/byacc/dist/test/quote_calc2.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc2.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc2.y (contents, props changed) vendor/byacc/dist/test/quote_calc3-s.output vendor/byacc/dist/test/quote_calc3-s.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc3-s.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc3.output vendor/byacc/dist/test/quote_calc3.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc3.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc3.y (contents, props changed) vendor/byacc/dist/test/quote_calc4-s.output vendor/byacc/dist/test/quote_calc4-s.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc4-s.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc4.output vendor/byacc/dist/test/quote_calc4.tab.c (contents, props changed) vendor/byacc/dist/test/quote_calc4.tab.h (contents, props changed) vendor/byacc/dist/test/quote_calc4.y (contents, props changed) vendor/byacc/dist/test/run_lint.sh (contents, props changed) vendor/byacc/dist/test/run_make.sh (contents, props changed) vendor/byacc/dist/test/run_test.sh (contents, props changed) vendor/byacc/dist/verbose.c (contents, props changed) vendor/byacc/dist/vmsbuild.com vendor/byacc/dist/warshall.c (contents, props changed) vendor/byacc/dist/yacc.1 (contents, props changed) Added: vendor/byacc/byacc-20120115/ACKNOWLEDGEMENTS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/byacc/byacc-20120115/ACKNOWLEDGEMENTS Thu May 3 09:57:52 2012 (r234949) @@ -0,0 +1,25 @@ + Berkeley Yacc owes much to the unflagging efforts of Keith Bostic. +His badgering kept me working on it long after I was ready to quit. + + Berkeley Yacc is based on the excellent algorithm for computing LALR(1) +lookaheads developed by Tom Pennello and Frank DeRemer. The algorithm is +described in their almost impenetrable article in TOPLAS 4,4. + + Finally, much of the credit for the latest version must go to those +who pointed out deficiencies of my earlier releases. Among the most +prolific contributors were + + Benson I. Margulies + Dave Gentzel + Antoine Verheijen + Peter S. Housel + Dale Smith + Ozan Yigit + John Campbell + Bill Sommerfeld + Paul Hilfinger + Gary Bridgewater + Dave Bakken + Dan Lanciani + Richard Sargent + Parag Patel Added: vendor/byacc/byacc-20120115/AUTHORS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/byacc/byacc-20120115/AUTHORS Thu May 3 09:57:52 2012 (r234949) @@ -0,0 +1,7 @@ +-- $Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp $ +-- vile:txtmode +-- This file is used by a script that collects contributor information and +-- resolves nicknames vs fullnames. +dickey Thomas Dickey +schmitz Sylvain Schmitz +unknown Robert Corbett Added: vendor/byacc/byacc-20120115/CHANGES ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/byacc/byacc-20120115/CHANGES Thu May 3 09:57:52 2012 (r234949) @@ -0,0 +1,1156 @@ +2012-01-15 Thomas E. Dickey + + * package/debian/copyright: bump + + * test/run_make.sh: workaround for breakage due to GNU make 3.82 + + * test/run_make.sh: + tested with Solaris 10 (bison 1.875) and added scripting to exercise + the /usr/ccs/bin/yacc executable + + * test/grammar.tab.c: regen + + * test/grammar.y: modify to also build with Solaris yacc + + * VERSION, package/debian/changelog, package/byacc.spec: bump + + * test/calc1.output, test/calc1.tab.c: regen + + * test/calc1.y: + undo the change made to appease bison, since it was only a warning. + + * test/pure_calc.tab.c, test/pure_error.tab.c: regen + + * test/run_make.sh: another fix for running from top-level directory + + * makefile.in: + ensure that check_make rule depends on having byacc built. + + * test/run_make.sh: fixes for building from parent directory + + * test/pure_error.y, test/pure_calc.y: bison-fixes + + * test/calc2.tab.c, test/calc3.tab.c, test/code_error.code.c, test/ftp.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c: + regen + + * test/calc2.y, test/calc3.y, test/code_error.y, test/ftp.y: + byacc already declares yyerror + + * test/pure_error.y, test/pure_calc.y: + modified to help make the files build with bison + + * test/run_make.sh: + supply a "%pure-parser" directive when bison needs it. + + * test/code_calc.code.c: regen + + * test/code_calc.y: modified to help make the files build with bison + + * yacc.1: + in testing, found that %expect did not work as documented for bison. + do not recommend it for portable code. + + * test/run_make.sh: workaround breakage in bison's %expect directive + + * test/grammar.y: modified to help make the files build with bison + + * test/calc1.output, test/calc1.tab.c, test/grammar.tab.c: regen + + * test/calc1.y: quiet a spurious warning from bison 2.3 + + * test/calc1.tab.c: regen + + * test/calc1.y: modified to help make the files build with bison + + * yacc.1: comment on "-y" and "-P" options. + + * yacc.1: comment on portability + + * test/ftp.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c: + regen + + * test/ftp.y: modified to help make the files build with bison + (bison's "-y" option is of no use in providing "yacc" compatibility) + + * test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4-s.tab.c, test/quote_calc4.tab.c: + regen + + * test/code_calc.y, test/quote_calc2.y, test/quote_calc.y, test/quote_calc4.y, test/quote_calc3.y: + modified to help make the files build with bison + + * test/calc.tab.c: regen + + * test/calc.y: modified to help make the files build with bison + + * test/error.tab.c: regen + + * test/error.y: modified to help make the files build with bison + + * test/calc2.tab.c, test/calc3.tab.c, test/code_error.code.c: regen + + * test/run_make.sh: + check for older bisons which (2.3 for instance) do not support pure parsers + + * test/code_error.y, test/calc3.y, test/calc2.y: + modified to help make the files build with bison + + * test/run_test.sh: use $opt2 in filenames of the generated files + + * test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c, test/quote_calc4-s.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4.tab.c: + regen + +2012-01-14 Thomas E. Dickey + + * test/calc2.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/calc1.tab.c: + regen + + * output.c: Several changes: + a) add YYLEX_PARAM_TYPE, like YYPARSE_PARAM_TYPE, but for yylex. + b) modify definitions for YYLEX_DECL to be more like YYPARSE_DECL, + using YYLEX_PARAM_TYPE and YYLEX_PARAM. + c) add ifdef's around #define's for YYERROR_DECL and YYERROR_CALL, + to help with redefinitions. + + * test/pure_calc.tab.c: + modified to help make the files build with bison + + * test/run_make.sh: + start work on followup, to check if the generated files build with bison. + + * test/pure_calc.y, test/pure_error.tab.c: + modified to help make the files build with bison + + * test/calc3.tab.c: regen + + * test/quote_calc-s.output, test/quote_calc-s.tab.c, test/quote_calc-s.tab.h, test/quote_calc2-s.output, test/quote_calc2-s.tab.c, test/quote_calc2-s.tab.h, test/quote_calc3-s.output, test/quote_calc3-s.tab.c, test/quote_calc3-s.tab.h, test/quote_calc4-s.output, test/quote_calc4-s.tab.c, test/quote_calc4-s.tab.h: + RCS_BASE + + * test/run_test.sh: generate/test with "-s" option applied. + +2012-01-13 Thomas E. Dickey + + * package/debian/changelog, package/byacc.spec, VERSION: bump + + * yacc.1: improve documentation of -s option + + * yacc.1: note that yacc ignores -y + + * main.c: add -s option to usage message. + + * test/quote_calc3.output, test/quote_calc3.tab.c, test/quote_calc4.output, test/quote_calc4.tab.c, test/quote_calc4.tab.h, test/quote_calc3.y, test/quote_calc.tab.h, test/quote_calc.output, test/quote_calc.tab.c, test/quote_calc2.output, test/quote_calc2.tab.c, test/quote_calc2.tab.h, test/quote_calc3.tab.h, test/quote_calc4.y, test/quote_calc.y, test/quote_calc2.y: + RCS_BASE + + * configure: regen + + * aclocal.m4: resync with my-autoconf, i.e., fixes for CF_XOPEN_SOURCE + +2011-12-19 Thomas E. Dickey + + * package/debian/changelog, package/byacc.spec, VERSION: bump + + * yacc.1, output.c, main.c, defs.h: + add "-s" option to suppress generating #define's based on string contents + in a %token statement. For instance + %token EQLS "Equals" + would generate + #define EQLS 256 + #define Equals 257 + Simply suppressing the second #define makes the behavior closer to yacc. + (report by Paulo Andrade). + +2011-09-08 Thomas E. Dickey + + * package/debian/changelog, package/byacc.spec, VERSION: bump + + * output.c: + fix some more interaction between -i and -d flags to ensure YYERRCODE + and YYSTYPE are declared, tested with cproto. + +2011-09-07 Thomas E. Dickey + + * yacc.1: document "-i" option. + + * package/debian/changelog, package/byacc.spec, VERSION: bump + + * output.c: fix an interaction between -i and -d + + * test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c: + regen - changes for "-i" option move the global/impure variables near the + macros that may add a prefix, etc. + + * skeleton.c, output.c, defs.h: changes to support "-i" option. + +2011-09-06 Thomas E. Dickey + + * reader.c: pass explicit file-pointer to write_section() + + * main.c: + add "-i" option, to generate interface-file (suggested by Denis M. Wilson) + +2011-09-05 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: + resync with my-autoconf: CF_ANSI_CC_CHECK (check for $CFLAGS in $CC) + and CF_XOPEN_SOURCE (update aix, cygwin and netbsd checks) + + * defs.h, error.c, reader.c: + add check for missing "}" on %parse-param and %lex-param lines (report by Denis M Wilson) + +2011-04-01 Thomas E. Dickey + + * config.sub: 2011-04-01 + +2011-02-02 Thomas E. Dickey + + * config.guess: 2011-01-01 + +2010-12-29 Thomas E. Dickey + + * defs.h, skeleton.c: + add const qualifier to skeleton data, per NetBSD changes (report by Christos Zoulas) + + * defs.h: + mark all of the error-functions as non-returning (report by Christos Zoulas) + + * test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c: + regen + + * skeleton.c: + use only realloc() rather than realloc+malloc, agree that systems needing this + are very rare (prompted by NetBSD change). + + * test/ftp.tab.c: regen + +2010-12-29 Christos.Zoulas + + * test/ftp.y: + improve example, which was stuck in 19XX and assumed file sizes were longs. + +2010-12-29 Thomas E. Dickey + + * test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c: + regen + + * test/pure_error.y, test/pure_calc.y, test/ftp.y, test/error.y, test/code_error.y, test/code_calc.y, test/calc.y, test/calc3.y, test/calc2.y, test/calc1.y: + use byacc's YYLEX_DECL/YYERROR_DECL symbols to prototype yylex/yyerror + + * skeleton.c: + remove explicit prototype for yylex() via YYLEX_DECL() macro, since that + would prevent declaring yylex() static (request by Christos Zoulas). + + * test/calc2.tab.c, test/calc3.tab.c: regen + +2010-12-29 Christos.Zoulas + + * output.c: correct definition for YYERROR_DECL() + +2010-12-29 Thomas E. Dickey + + * package/debian/changelog, package/byacc.spec, VERSION: bump + +2010-12-26 Thomas E. Dickey + + * defs.h, main.c: + change return-type of allocate() to avoid warnings of alignment problems + + * main.c: Solaris declares chmod() in + + * configure: regen + + * main.c: ifdef'd use of fcntl.h + + * configure.in: add configure checks for fcntl.h, atexit and mkstemp + + * main.c: for cases where mkstemp() is not available, use tempnam/open + + * aclocal.m4: add CF_MKSTEMP + + * aclocal.m4: + improve quoting, deprecate ${name-value} in favor of standard ${name:-value} + +2010-12-25 Thomas E. Dickey + + * main.c: + start revising use of tmpfile(), to make this work with MinGW. Start by + implementing a mkstemp() alternative - noting that mkstemp() also is broken + for MinGW. + + * package/debian/changelog, package/byacc.spec, VERSION: bump + +2010-11-27 Thomas E. Dickey + + * package/byacc.spec, package/debian/changelog, VERSION: bump + + * test/calc2.tab.c, test/calc3.tab.c: regen + + * output.c: + corrected use of %parse-param value in yyerror(); it doesn't use &yylval + (report by Clifford Yapp) + +2010-11-26 Thomas E. Dickey + + * skeleton.c: typo + + * output.c: + correct line-numbering when "-r" option is used; the 'outline' variable + should only be incremented when writing to the code-file. + + * test/code_calc.code.c, test/code_error.code.c: regen + + * yacc.1: bump date + + * yacc.1: comment on -b option vs -r + + * test/calc2.tab.c, test/calc2.y, test/calc3.tab.c, test/calc3.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c: + regen + + * output.c: + improve on YYERROR_DECL(), adding dummy params which can be used for the + actual function declaration. Also add YYERROR_CALL(). The two macros + simplify maintaining sets of grammars which may/may not be pure. + + * test/calc1.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c: + regen + + * output.c: generate yyerror() calls in output.c + This is for compatibility with bison, which passes the yylval to yyerror + when the %parse-param feature is used. + + * skeleton.c, defs.h: generate yyerror() calls in output.c + + * output.c: simplified a little, using putc_code() and putl_code() + + * test/calc1.tab.h: regen + + * reader.c: + improve ifdef for YYSTYPE union declaration (report by Clifford Yapp) + + * reader.c: + accept underscore as a replacement for dash in command names, e.g., + "%pure_parser" vs "%pure-parser". + + * test/calc1.tab.c: regen + + * output.c, reader.c: + also ifdef YYSTYPE declaration in the generated code (report by Clifford Yapp) + + * package/debian/changelog, package/byacc.spec, VERSION: bump + +2010-11-24 Thomas E. Dickey + + * main.c, defs.h, symtab.c, error.c: reduce global variables + + * package/debian/changelog, package/byacc.spec, VERSION: bump + + * reader.c: + amend fix for Redhat #112617 to still call default_action_warning() for + empty rules (report by Bruce Cran). + +2010-11-22 Thomas E. Dickey + + * output.c: + add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp). + + * test/calc1.tab.c: regen + + * test/calc1.y: cleanup compiler warnings + + * test/grammar.y: add "%expect" + + * test/calc1.tab.h: regen + + * test/calc1.output, test/calc1.tab.c, test/calc1.tab.h: RCS_BASE + + * test/calc2.tab.c, test/calc3.tab.c: regen + + * test/calc1.y: + advanced example from Steve Johnson's paper, uses unions + + * test/calc3.y, test/calc2.y: init 'base', so examples can run + + * test/ftp.tab.c, test/ftp.y: tweaks to compile with g++ + + * output.c: compensate for fix in reader.c + + * reader.c: + add/use putc_both() and puts_both(), incidentally fixing a place where + a union copied to the union_file may be missing the end of the last line. + + * package/debian/changelog, package/byacc.spec, VERSION: bump + +2010-09-28 Thomas E. Dickey + + * config.guess: 2010-09-24 + +2010-09-10 Thomas E. Dickey + + * config.sub: 2010-09-11 + +2010-06-10 Thomas E. Dickey + + * yacc.1, package/debian/changelog, package/byacc.spec, VERSION: + bump to 2010/06/10 + +2010-06-09 Thomas E. Dickey + + * reader.c: free declarations in leak-testing code. + + * main.c: close code_file if -r option used, for leak-testing + + * defs.h, reader.c: + improve %lex-param / %parse-param implementation by allowing for arrays to + be passed as parameters, e.g., "int regs[26]". + + * test/calc3.tab.c, test/calc3.y, test/calc3.output, test/calc3.tab.h, test/calc2.tab.c, test/calc2.y, test/calc2.tab.h, test/calc2.output: + RCS_BASE + + * output.c: + improve %lex-param / %parse-param implementation by allowing for arrays to + be passed as parameters, e.g., "int regs[26]". + + * test/calc.tab.c, test/calc.y: + test-cases and reference files for %lex-param / %parse-param + + * makefile.in: add docs-rule, for html/pdf/txt form of manpage + + * configure: regen + + * aclocal.m4: add CF_XOPEN_SOURCE, etc. + + * configure.in: + use CF_XOPEN_SOURCE check to ensure that strdup is in scope, e.g., for c89 + + * test/ftp.tab.c, test/ftp.y, reader.c, symtab.c, verbose.c, lr0.c, main.c, mkpar.c, output.c, defs.h, closure.c: + fix warnings from clang --analyze + +2010-06-08 Thomas E. Dickey + + * output.c: fix to build with c89, etc. + + * reader.c: gcc warning + + * test/ftp.tab.c, test/ftp.y, test/calc.tab.c, test/code_calc.code.c, test/code_error.code.c, test/code_error.y, test/code_calc.y, test/calc.y, test/pure_error.tab.c, test/error.tab.c, test/error.y, test/pure_error.y, test/pure_calc.tab.c, test/pure_calc.y: + modified test-cases to allow them to compile, to validate pure-parser changes. + updated reference files to match. + + * output.c: + move call for output_stype() earlier since it is used in pure-parser declarations + + * test/grammar.tab.c, test/grammar.y: + modified test-cases to allow them to compile, to validate pure-parser changes. + updated reference files to match. + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: + regen + + * yacc.1: document %lex-param and %parse-param + + * test/run_lint.sh, test/run_make.sh: RCS_BASE + + * test/run_test.sh: + further modify to allow build-directory to be in a different location by + passing this directory's location as a parameter to the script. + + * makefile.in: + add check_make and check_lint rules to help validate the generated files + in the test-directory + +2010-06-07 Thomas E. Dickey + + * test/pure_calc.tab.c, test/pure_error.tab.c: RCS_BASE + + * test/run_test.sh: + provide for testing -r and -P options by checking if the ".y" filename + begins with "code_" or "pure_", respectively. + + * test/code_error.code.c, test/code_error.tab.c, test/code_error.tab.h, test/code_calc.code.c, test/code_calc.tab.c, test/code_calc.tab.h, test/pure_calc.output, test/pure_calc.tab.h, test/pure_error.output, test/pure_error.tab.h, test/code_calc.output, test/code_error.output: + RCS_BASE + + * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: regen + + * test/run_test.sh: + changes to support running "make check" in a separate build-tree + + * main.c: add "-P" to usage message + + * reader.c: use UCH() macro to hide casts. + +2010-06-07 Andres.Mejia + + * main.c, output.c, reader.c, defs.h, skeleton.c: + Fix the output order of the generated parse code file. This allows for + the use of YYPARSE_PARAM, by having the output that checks for + YYPARSE_PARAM to be defined come after the C code block in the + definitions section of a yacc file. + + Implement support for YYLEX_PARAM, similar to bison. This is useful for + support for building reentrant lexers with flex. + + Fix a compatibility issue with bison's pure-parser option. Bison + defines yylex as sending at least one parameter, &yylval, as the first + parameter and doesn't seem to have an easy way to remove that parameter. + This on the other hand is rather convenient to support saving to yylval + from flex when building reentrant lexers and parsers. + + Add support for the %parse-param and %lex-param directives used in + bison. This change bears some similarity to NetBSD's changes to byacc + at http://www.mail-archive.com/source-changes-full@netbsd.org/msg08143.html + + Bison allows for POSIX yacc emulation via a yacc directive in the yacc + file, and also via a command line switch. Implement this feature as a + no-op for byacc, since byacc is designed to be POSIX yacc compatible + anyway. This allows for better compatibility with yacc sources written + for bison. + +2010-06-07 Thomas E. Dickey + + * VERSION: bump to 2010/06/07 + +2010-06-06 Thomas E. Dickey + + * test/calc.tab.c, configure: regen + + * skeleton.c: + move #include's down into the generated code, to allow user-defined code + to override feature definitions, particularly with stdlib.h (request by + Marcus Kool). + + * lr0.c, error.c, reader.c, defs.h: + strict gcc 3.4.6 warnings on 64-bit platform + + * aclocal.m4, configure.in: add check for lint + + * makefile.in: add lint rule + + * defs.h, closure.c, lr0.c, warshall.c, main.c: + fix gcc warnings, mostly for 64-bit platform + + * aclocal.m4: + add macros for checking ctags/etags, e.g., to work with NetBSD pkgsrc + + * makefile.in: add etags/TAGS if available + + * configure.in: add configure check for actual ctags and etags programs + + * package/debian/copyright: add copyright notices for non-PD files + + * package/debian/changelog: + incorporated scripts in upstream to use for test-builds + + * makefile.in: drop mkdirs.sh, just use "mkdir -p" + + * AUTHORS: nicknames for some contributors (see CHANGES for details) + + * package/byacc.spec: RPM file for byacc + + * VERSION: bump to 2010/06/06 + + * aclocal.m4: add copyright notice, from "my-autoconf" macros + http://invisible-island.net/autoconf/autoconf.html + + * package/RCS, package/debian/RCS, package/debian/source/RCS, package/pkgsrc/RCS: + PERMIT FILE + + * aclocal.m4: resync with my-autoconf. summary of changes: + a) CF_ADD_CFLAGS, etc., improve quoting of ifelse() parameter + b) CF_DISABLE_ECHO, change indent-convention for substituted makefile + c) CF_GCC_VERSION, ignore stderr + d) CF_GCC_WARNINGS, adjust options to work with c89 wrapper of gcc + +2010-04-20 Thomas E. Dickey + + * package/debian/changelog, package/debian/compat, package/debian/control, package/debian/copyright, package/debian/docs, package/debian/postinst, package/debian/prerm, package/debian/rules, package/debian/watch: + scripts from Debian package + +2010-02-16 Thomas E. Dickey + + * yacc.1: document -P and bison-extensions + + * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c: + regen + + * output.c: implement %pure-parser + + * skeleton.c: + implement %pure-parser, like bison. To help with this, changed the stack + variables, putting them into a struct. + + * reader.c: implement %pure-parser + + * defs.h: modified skeleton to support %pure-parser feature + + * main.c: add -P option to set %pure-parser + + * output.c: + make -r and -p options work together. The -r option splits the generated + parser into code/table files; for this case we cannot use static data. + Also, we have to repeat the #define's used for prefix (-p) as well as the + redeclaration of yyparse(). Finally, allow any of the prefixed names to + be overridden, e.g., by passing a -D option to the compiler. Make that + a little more readable by putting a blank line before each chunk. + + * defs.h: add definitions for %pure-parser + + * skeleton.c: + put blank line before/after the redeclaration of yyparse() + + * output.c: allow for other program redefining yylex() + + * skeleton.c: + split-off xdecls[] array, to move declaration of yyparse() after #define's + + * defs.h: split-out xdecls[] + + * VERSION: bump + + * configure: regen + + * aclocal.m4: add CF_REMOVE_DEFINE, needed by CF_ADD_CFLAGS + + * aclocal.m4: + resync with my-autoconf CF_ADD_CFLAGS and CF_DISABLE_ECHO changes. + +2010-02-16 Ostap.Cherkashi + + * skeleton.c: fix a memory leak in the generated skeleton + +2010-01-01 Thomas E. Dickey + + * package/debian/source/format: scripts from Debian package + +2009-12-31 Thomas E. Dickey + + * config.guess: 2009-12-30 + + * config.sub: 2009-12-31 + +2009-10-27 Thomas E. Dickey + + * VERSION: 20091027 + + * output.c, mkpar.c, defs.h, lalr.c, closure.c, graph.c, lr0.c, verbose.c, main.c, reader.c: + strict compiler warnings + +2009-10-26 Thomas E. Dickey + + * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c: + resync + + * main.c, defs.h: introduce some typedefs for portability, etc. + + * makefile.in: + don't remove "*.log" in mostlyclean rule since it interferes with regression + script. + + * configure: regen + + * aclocal.m4: resync with my-autoconf + +2009-08-25 Thomas E. Dickey + + * config.guess, config.sub: 2009-08-19 + +2009-02-21 Thomas E. Dickey + + * VERSION: bump + + * output.c: restore "yylval" symbol, omitted in cleanup on 2008/8/25 + +2008-12-26 Thomas E. Dickey + + * configure: regen with autoconf-2.52 (patched) + +2008-12-25 Thomas E. Dickey + + * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c: + regenerated + +2008-12-24 Thomas E. Dickey + + * VERSION: bump + + * skeleton.c: + remove ifdef-lint from goto yyerrlab, to quiet gcc warning + +2008-11-26 Thomas E. Dickey + + * verbose.c, main.c, defs.h, mkpar.c, reader.c: + completed implementation of "%expect" (report by Perry E. Metzger). + add "%expect-rr", which is (unlike bison) allowable in LALR parsers. + +2008-11-24 Thomas E. Dickey + + * closure.c, defs.h, error.c, graph.c, lalr.c, lr0.c, main.c, mkpar.c, output.c, reader.c, skeleton.c, symtab.c, verbose.c, warshall.c: + change indent-style (request by Perry E. Metzger) + +2008-08-27 Thomas E. Dickey + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: + better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro + + * VERSION: bump + + * skeleton.c: + better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, skeleton.c: + change YYRECOVERING to YYRECOVERING(), for compatibility with other yacc's. + + * configure: regen'd + + * configure.in: add -Wwrite-strings to warnings + + * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c: + add YYPARSE_PARAM and YYPARSE_PARAM_TYPE + + * skeleton.c: + add YYPARSE_PARAM (bison) and YYPARSE_PARAM_TYPE (FreeBSD) features. + + * main.c, defs.h, output.c, skeleton.c, symtab.c, error.c, reader.c: + fixes for gcc -Wwrite-strings + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: + generate the tables as static-const (this is an interface change) + + * output.c: realign columns in start_table() + + * output.c: + generate the tables as static-const (this is an interface change) + + * output.c: reorder functions to eliminate forward-references + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: + remove 'register' keywords + +2008-08-26 Thomas E. Dickey + + * warshall.c, verbose.c, symtab.c, skeleton.c, reader.c, output.c, mkpar.c, main.c, lr0.c, lalr.c, graph.c, error.c, closure.c: + remove 'register' keywords + +2008-08-25 Thomas E. Dickey + + * test/ftp.tab.c: regen'd + + * reader.c: + improve the left-curly fix by testing after blanks, to avoid having a + " {" at the beginning of a line. + + * test/error.tab.c, test/grammar.tab.c: regen'd + + * output.c: + move the remaining newline-counting into write_XXX functions. + + * test/calc.tab.c: regen'd + + * output.c: + simplify part of the output_file formatting using new functions, e.g., + start_int_table(), output_newline(). + + * reader.c: + modify copy_action() to indent the first character, it if is is left-curly + brace. That makes the output look more like the original, as well as makes + it simpler to edit (not confuse editors which look for a left-curly in the + first column as if it were the beginning of a function). + + * skeleton.c: minor fixes to avoid gcc -Wconversion warnings + + * output.c: align the #define's produced for "-p" option + + * test/run_test.sh: use the "-p" option for better coverage. + + * output.c: simplify output_prefix() with new define_prefixed() + + * skeleton.c: include string.h, for memset() + change stack size to unsigned to fix gcc -Wconversion warnings. + + * VERSION: bump to 2008/8/25 + + * makefile.in: add dependency on VERSION file. + +2008-08-24 Thomas E. Dickey + + * VERSION: bump + + * lalr.c: improved memory-leak checking by freeing data in includes[] + + * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c: + update to match skeleton-change + + * configure: regen'd + + * skeleton.c: Add fix for stack discussed + http://undeadly.org/cgi?action=article&sid=20080708155228 + and applied + http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/yacc/skeleton.c.diff?r1=1.28&r2=1.29 + + * aclocal.m4: resync with my-autoconf (no major changes) + +2008-07-24 Thomas E. Dickey + + * package/pkgsrc/Makefile, package/pkgsrc/distinfo: + scripts from NetBSD pkgsrc, for test-builds + +2008-03-14 Thomas E. Dickey + + * config.sub: update to 2008-03-08 + + * config.guess: update to 2008-03-12 + +2007-05-09 Thomas E. Dickey + + * main.c: close graph, verbose files if opened, on exit. + + * main.c: + audit memory leaks - valgrind reported some memory still in use on exit. + + * lalr.c, output.c, reader.c, mkpar.c, lr0.c: + add hook for auditing memory leaks + + * defs.h: add hooks for auditing memory leaks + + * configure: regen'd + + * configure.in: + use CF_DISABLE_LEAKS, which combines --disable-leaks, --with-valgrind, + --with-dbmalloc and --with-dmalloc + + * aclocal.m4: add CF_DISABLE_LEAKS and CF_WITH_VALGRIND + + * aclocal.m4: improve version-checking in CF_GCC_VERSION + rework dbmalloc/dmalloc options using CF_NO_LEAKS_OPTION macro + + * VERSION: 2007/5/9 + + * main.c: file_prefix did not always have a trailing null. + +2007-03-25 Thomas E. Dickey + + * mkdirs.sh: improved version for "make -j" + +2006-12-22 Thomas E. Dickey + + * config.guess: 2006/12/22 + +2006-12-08 Thomas E. Dickey + + * config.sub: 2006/12/08 + +2005-08-13 Thomas E. Dickey + + * main.c: add -V to usage message + + * makefile.in: remove -t option from ctags + + * VERSION: 2005/8/13 + +2005-08-13 schmitz + + * main.c: Sylvain Schmitz: + modify the '-o' option to work like bison's, which sets the file-prefix. + +2005-08-13 Matt.Kraai + + * output.c: + Debian #322858 (don't close union_file, which contained data). + This feature is used in groff. + +2005-08-13 Thomas E. Dickey + + * configure: regenerated + + * aclocal.m4: improve checks for Intel compiler warnings + +2005-06-25 Thomas E. Dickey + + * config.sub: 2005/6/2 + + * config.guess: 2005/5/27 + +2005-05-05 Thomas E. Dickey + + * defs.h: add a fallback for GCC_UNUSED + +2005-05-04 Thomas E. Dickey + + * makefile.in: add "." to include-path to pickup config.h + + * reader.c: + apply fix suggested by Steve Dum for end_rule() in Redhat Bugzilla #112617. + + * output.c: + correct a limit check in pack_vector() - report/analysis by William Evans + + * main.c: + exit after printing version. Otherwise "yacc -V" will exit with an erro + after printing the usage message. + + * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: + regenerated after skeleton-changes + + * skeleton.c: replace a few -1's with YYEMPTY + + * skeleton.c: + delete yynewerror (no one uses it any more, and it just makes compiler warnings) + + * skeleton.c: adapt yygrowstack() and related definitions from FreeBSD + + * test/run_test.sh: + filter out lines with YYPATCH, since that will change with each update + + * yacc.1: add -V option + + * main.c: add -V option to print the version. + simplify option-parsing by moving the duplicate logic for setting flags into + new function setflag(). + + * skeleton.c: + move the actual definition of YYMAJOR and YYMINOR to defs.h (as numbers). + add YYPATCH here so it can be tested by applications. + + * defs.h: + add macros to define VERSION in terms of the (numeric) YYMAJOR, YYMINOR and + YYPATCH symbols. + + * lalr.c, lr0.c, mkpar.c, defs.h, closure.c, warshall.c, output.c, verbose.c, graph.c, reader.c, main.c, symtab.c: + reduce externs by making static the procedures that are not referenced outside + the module in which they are defined. + + * makefile.in: + the VERSION file holds the patch-date. Define YYPATCH, so this will be + compiled into the skeleton. + + * VERSION: patch-level for byacc + + * main.c: + add "-o" to usage message. It is too long for a single line; rewrite usage() + to show one option per line. + +2005-05-03 Thomas E. Dickey + + * main.c: add -o option, to work with scripts that assume bison. + simplify create_file_names() with a macro. + simplify done() with a macro. + adapt fix from FreeBSD for signal race, e.g., if done() is interrupted by + onintr(), do not flush output via exit(), but use _exit() instead. + + * defs.h: remove unnecessary externs for main.c + + * yacc.1: add -o option + + * graph.c: remove unused parameter + + * mkpar.c, defs.h, reader.c: + add support for "%expect", a bison feature from FreeBSD sources + + * lr0.c, reader.c, main.c, skeleton.c, graph.c, symtab.c, closure.c, mkpar.c, lalr.c, error.c, warshall.c, verbose.c, output.c: + indent'd + + * configure: regenerated for 2005/5/5 + + * aclocal.m4: miscellaneous updates (adds CF_INTEL_COMPILER) + +2005-04-27 schmitz + + * defs.h, graph.c, lr0.c, main.c, makefile.in, reader.c, yacc.1: + Sylvain Schmitz : + add graphical output of the LALR(1) automaton for graphviz, + associated with command-line option `-g' *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 09:58:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FB231065675; Thu, 3 May 2012 09:58:37 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E54778FC14; Thu, 3 May 2012 09:58: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 q439waVL031272; Thu, 3 May 2012 09:58:36 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q439waNU031271; Thu, 3 May 2012 09:58:36 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205030958.q439waNU031271@svn.freebsd.org> From: Baptiste Daroussin Date: Thu, 3 May 2012 09:58:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234950 - vendor/byacc/20120115 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:58:37 -0000 Author: bapt Date: Thu May 3 09:58:36 2012 New Revision: 234950 URL: http://svn.freebsd.org/changeset/base/234950 Log: Tag byacc 20120115 Added: vendor/byacc/20120115/ - copied from r234949, vendor/byacc/dist/ From owner-svn-src-all@FreeBSD.ORG Thu May 3 10:26:34 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7524E106564A; Thu, 3 May 2012 10:26:34 +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 608078FC14; Thu, 3 May 2012 10:26:34 +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 q43AQYiT032366; Thu, 3 May 2012 10:26:34 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43AQYFi032363; Thu, 3 May 2012 10:26:34 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205031026.q43AQYFi032363@svn.freebsd.org> From: Michael Tuexen Date: Thu, 3 May 2012 10:26:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234951 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 10:26:34 -0000 Author: tuexen Date: Thu May 3 10:26:33 2012 New Revision: 234951 URL: http://svn.freebsd.org/changeset/base/234951 Log: Fix another RFC 6458 issue. Spotted by Irene Ruengeler. MFC after: 3 days Modified: head/sys/netinet/sctp_output.c head/sys/netinet/sctp_uio.h Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Thu May 3 09:58:36 2012 (r234950) +++ head/sys/netinet/sctp_output.c Thu May 3 10:26:33 2012 (r234951) @@ -3430,7 +3430,7 @@ sctp_find_cmsg(int c_type, void *data, s } m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo); sndrcvinfo->sinfo_keynumber_valid = 1; - sndrcvinfo->sinfo_keynumber = authinfo.auth_keyid; + sndrcvinfo->sinfo_keynumber = authinfo.auth_keynumber; break; default: return (found); Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Thu May 3 09:58:36 2012 (r234950) +++ head/sys/netinet/sctp_uio.h Thu May 3 10:26:33 2012 (r234951) @@ -169,7 +169,7 @@ struct sctp_default_prinfo { }; struct sctp_authinfo { - uint16_t auth_keyid; + uint16_t auth_keynumber; }; struct sctp_rcvinfo { From owner-svn-src-all@FreeBSD.ORG Thu May 3 10:38:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46331106564A; Thu, 3 May 2012 10:38:03 +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 30C618FC16; Thu, 3 May 2012 10:38:03 +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 q43Ac3Qx032782; Thu, 3 May 2012 10:38:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Ac2eZ032779; Thu, 3 May 2012 10:38:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205031038.q43Ac2eZ032779@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 3 May 2012 10:38: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: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 10:38:03 -0000 Author: kib Date: Thu May 3 10:38:02 2012 New Revision: 234952 URL: http://svn.freebsd.org/changeset/base/234952 Log: When callout_reset_on() cannot immediately migrate a callout since it is running on other cpu, the CALLOUT_PENDING flag is temporarily cleared. Then, callout_stop() on this, in fact active, callout fails because CALLOUT_PENDING is not set, and callout_stop() returns 0. Now, in sleepq_check_timeout(), the failed callout_stop() causes the sleepq code to execute mi_switch() without even setting the wmesg, since the switch-out is supposed to be transient. In fact, the thread is put off the CPU for full timeout interval, instead of being put on runq immediately. Until timeout fires, the process is unkillable for obvious reasons. Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION flag. The flag is cleared by callout_stop_safe() when the function detects a migration, besides returning the success. The softclock() rechecks the flag for migrating callout and cancels its execution if the flag was cleared meantime. PR: misc/166340 Reported, debugging traces provided and tested by: Christian Esken Reviewed by: avg, jhb MFC after: 1 week Modified: head/sys/kern/kern_timeout.c head/sys/sys/callout.h Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu May 3 10:26:33 2012 (r234951) +++ head/sys/kern/kern_timeout.c Thu May 3 10:38:02 2012 (r234952) @@ -645,6 +645,32 @@ softclock(void *arg) cc_cme_cleanup(cc); /* + * Handle deferred callout stops + */ + if ((c->c_flags & CALLOUT_DFRMIGRATION) + == 0) { + CTR3(KTR_CALLOUT, + "deferred cancelled %p func %p arg %p", + c, new_func, new_arg); + if (cc->cc_next == c) { + cc->cc_next = + TAILQ_NEXT(c, + c_links.tqe); + } + if (c->c_flags & + CALLOUT_LOCAL_ALLOC) { + c->c_func = NULL; + SLIST_INSERT_HEAD( + &cc->cc_callfree, c, + c_links.sle); + } + goto nextc; + } else { + c->c_flags &= ~ + CALLOUT_DFRMIGRATION; + } + + /* * It should be assert here that the * callout is not destroyed but that * is not easy. @@ -659,6 +685,9 @@ softclock(void *arg) panic("migration should not happen"); #endif } +#ifdef SMP +nextc: +#endif steps = 0; c = cc->cc_next; } @@ -814,6 +843,7 @@ callout_reset_on(struct callout *c, int cc->cc_migration_ticks = to_ticks; cc->cc_migration_func = ftn; cc->cc_migration_arg = arg; + c->c_flags |= CALLOUT_DFRMIGRATION; CTR5(KTR_CALLOUT, "migration of %p func %p arg %p in %d to %u deferred", c, c->c_func, c->c_arg, to_ticks, cpu); @@ -984,6 +1014,12 @@ again: CC_UNLOCK(cc); KASSERT(!sq_locked, ("sleepqueue chain locked")); return (1); + } else if ((c->c_flags & CALLOUT_DFRMIGRATION) != 0) { + c->c_flags &= ~CALLOUT_DFRMIGRATION; + CTR3(KTR_CALLOUT, "postponing stop %p func %p arg %p", + c, c->c_func, c->c_arg); + CC_UNLOCK(cc); + return (1); } CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); Modified: head/sys/sys/callout.h ============================================================================== --- head/sys/sys/callout.h Thu May 3 10:26:33 2012 (r234951) +++ head/sys/sys/callout.h Thu May 3 10:38:02 2012 (r234952) @@ -46,6 +46,7 @@ #define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ #define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ #define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ +#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */ struct callout_handle { struct callout *callout; From owner-svn-src-all@FreeBSD.ORG Thu May 3 11:02:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 15E051065672; Thu, 3 May 2012 11:02:11 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id DD6308FC14; Thu, 3 May 2012 11:02:09 +0000 (UTC) Received: by lagv3 with SMTP id v3so1572011lag.13 for ; Thu, 03 May 2012 04:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=26KrrRFA9EmtBrBwW8+aWzefPagZB56LJTRIECY+0XM=; b=uRIXmDP+RqCWPyASXh6zADRaYClvzfMwnV2v8+r28+BXEOrtaPcsfdkj34IXsx1kTV ssrL5ejCfQgKpIcT4dhk1RwZGXV70Xyhe9Gq3xjDolcM4HQf6CKsYpqLdeJmwH+PWczW F03KuCMxPIs5R8zCaeGeXpeIz8/RV7mFJkRliGvolHtJ9PUbtKbICI5zK/soTR0i27ZP PvtTLje415I5skGs2LP2Tw453Mm/od7L0MQoMso6CG+dYj5i0/KWIjiLQi5HIZJStvza WXMKYy7V0K2L8VoeEW6daBoMzpZRl3zl3H985/CmzQKwlBRGZOfV11jxMk7ymi9nUODR EkQw== MIME-Version: 1.0 Received: by 10.112.88.66 with SMTP id be2mr847298lbb.36.1336042928518; Thu, 03 May 2012 04:02:08 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 04:02:08 -0700 (PDT) In-Reply-To: <201205031038.q43Ac2eZ032779@svn.freebsd.org> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> Date: Thu, 3 May 2012 12:02:08 +0100 X-Google-Sender-Auth: 2MZjywyNJHk4hlneXs6srWcIfjc Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 11:02:11 -0000 2012/5/3, Konstantin Belousov : > Author: kib > Date: Thu May 3 10:38:02 2012 > New Revision: 234952 > URL: http://svn.freebsd.org/changeset/base/234952 > > Log: > When callout_reset_on() cannot immediately migrate a callout since it > is running on other cpu, the CALLOUT_PENDING flag is temporarily > cleared. Then, callout_stop() on this, in fact active, callout fails > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > > Now, in sleepq_check_timeout(), the failed callout_stop() causes the > sleepq code to execute mi_switch() without even setting the wmesg, > since the switch-out is supposed to be transient. In fact, the thread > is put off the CPU for full timeout interval, instead of being put on > runq immediately. Until timeout fires, the process is unkillable for > obvious reasons. > > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION > flag. The flag is cleared by callout_stop_safe() when the function > detects a migration, besides returning the success. The softclock() > rechecks the flag for migrating callout and cancels its execution if > the flag was cleared meantime. Can you please clarify why you cannot simply drop the deferred migration in the case !CALLOUT_PENDING in callout_stop_safe()? Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-svn-src-all@FreeBSD.ORG Thu May 3 11:49:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A57C31065674; Thu, 3 May 2012 11:49:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 200E08FC17; Thu, 3 May 2012 11:49:21 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43BnEPQ082065; Thu, 3 May 2012 14:49:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43BnD7U026953; Thu, 3 May 2012 14:49:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43BnDv0026952; Thu, 3 May 2012 14:49:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 May 2012 14:49:13 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VSonL41MObbAuehL" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 11:49:22 -0000 --VSonL41MObbAuehL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > 2012/5/3, Konstantin Belousov : > > Author: kib > > Date: Thu May 3 10:38:02 2012 > > New Revision: 234952 > > URL: http://svn.freebsd.org/changeset/base/234952 > > > > Log: > > When callout_reset_on() cannot immediately migrate a callout since it > > is running on other cpu, the CALLOUT_PENDING flag is temporarily > > cleared. Then, callout_stop() on this, in fact active, callout fails > > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > > > > Now, in sleepq_check_timeout(), the failed callout_stop() causes the > > sleepq code to execute mi_switch() without even setting the wmesg, > > since the switch-out is supposed to be transient. In fact, the thread > > is put off the CPU for full timeout interval, instead of being put on > > runq immediately. Until timeout fires, the process is unkillable for > > obvious reasons. > > > > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION > > flag. The flag is cleared by callout_stop_safe() when the function > > detects a migration, besides returning the success. The softclock() > > rechecks the flag for migrating callout and cancels its execution if > > the flag was cleared meantime. >=20 > Can you please clarify why you cannot simply drop the deferred > migration in the case !CALLOUT_PENDING in callout_stop_safe()? I probably can, I think I went with the route of committed patch because it is slightly less work. Also, the comment in the while() loop suggested me to rely on softclock. --VSonL41MObbAuehL Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+icLkACgkQC3+MBN1Mb4ifBgCguBFmr3XD/vfD28mhzWhtEXC0 3toAoMDSGc/ElSj2X5E+Y1QGocG/Gd1a =NClt -----END PGP SIGNATURE----- --VSonL41MObbAuehL-- From owner-svn-src-all@FreeBSD.ORG Thu May 3 13:08:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4CA84106566C; Thu, 3 May 2012 13:08:12 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3696C8FC08; Thu, 3 May 2012 13:08:12 +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 q43D8CHk039905; Thu, 3 May 2012 13:08:12 GMT (envelope-from bjk@svn.freebsd.org) Received: (from bjk@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43D8CCq039903; Thu, 3 May 2012 13:08:12 GMT (envelope-from bjk@svn.freebsd.org) Message-Id: <201205031308.q43D8CCq039903@svn.freebsd.org> From: Benjamin Kaduk Date: Thu, 3 May 2012 13:08:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234953 - head/share/man/man4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:08:12 -0000 Author: bjk (doc committer) Date: Thu May 3 13:08:11 2012 New Revision: 234953 URL: http://svn.freebsd.org/changeset/base/234953 Log: Grammar and markup fixes. PR: docs/159854 Approved by: hrs (mentor) Modified: head/share/man/man4/carp.4 Modified: head/share/man/man4/carp.4 ============================================================================== --- head/share/man/man4/carp.4 Thu May 3 10:38:02 2012 (r234952) +++ head/share/man/man4/carp.4 Thu May 3 13:08:11 2012 (r234953) @@ -42,8 +42,8 @@ addresses are always available. .Pp To use .Nm , -the administrator needs to configure at minimum a common virtual host ID -(vhid) and attach at least one IP address to this vhid on each machine which +the administrator needs to configure at a minimum a common virtual host ID +(vhid), and attach at least one IP address to this vhid on each machine which is to take part in the virtual group. Additional parameters can also be set on a per-vhid basis: .Cm advbase @@ -72,13 +72,13 @@ Both and .Cm advskew are put inside CARP advertisements. -These configurations can be done using +These values can be configured using .Xr ifconfig 8 , or through the .Dv SIOCSVH .Xr ioctl 2 . .Pp -CARP virtual hosts can be configured on multicast capable interfaces: Ethernet, +CARP virtual hosts can be configured on multicast-capable interfaces: Ethernet, layer 2 VLAN, FDDI and Token Ring. An arbitrary number of virtual host IDs can be configured on an interface. An arbitrary number of IPv4 or IPv6 addresses can be attached to a particular @@ -91,7 +91,7 @@ elections independently. .Pp Additionally, there are a number of global parameters which can be set using .Xr sysctl 8 : -.Bl -tag -width ".Va net.inet.carp.preempt" +.Bl -tag -width ".Va net.inet.carp.ifdown_demotion_factor" .It Va net.inet.carp.allow Accept incoming .Nm @@ -103,14 +103,17 @@ When enabled, a vhid in a backup state w is announcing itself with a lower advskew. Disabled by default. .It Va net.inet.carp.log -Value of 0 disables any logging. -Value of 1 enables logging state changes of +Determines what events relating to +.Nm +interfaces are logged. +A value of 0 disables any logging. +A value of 1 enables logging state changes of .Nm vhids. Values above 1 enable logging of bad .Nm packets. -Default value is 1. +The default value is 1. .It Va net.inet.carp.demotion This value shows current level of CARP demotion. The value is added to the actual advskew sent in announcements for @@ -123,44 +126,48 @@ running a vhid goes down, or while the .Xr pfsync 4 interface is not synchronized. The demotion value is writable, so that user may alter it -depending on some external conditions, for example on status of some +depending on some external conditions, for example on the status of some daemon utility. -However, altering the value should be performed with care, do +However, altering the value should be performed with care, so as to not conflict with subsystems that adjust demotion factor automatically: .Nm and .Xr pfsync 4 . .It Va net.inet.carp.ifdown_demotion_factor -Value added to +This value is added to .Va net.inet.carp.demotion -when interface running a vhid goes down. -Default value is 240 (maximum advskew value). +when an interface running a vhid goes down. +The default value is 240 (the maximum advskew value). .It Va net.inet.carp.senderr_demotion_factor -Value added to +This value is added to .Va net.inet.carp.demotion when .Nm experiences errors sending its announcements. -Default value is 240 (maximum advskew value). +The default value is 240 (the maximum advskew value). .El .\".Sh ARP level load balancing -.\"The +.\"A .\".Nm -.\"has limited abilities for load balancing the incoming connections -.\"between hosts in Ethernet network. -.\"For load balancing operation, one needs several CARP interfaces that +.\"interface has limited abilities for load balancing incoming connections +.\"between hosts in an Ethernet network. +.\"For load-balancing operation, one needs several CARP interfaces that .\"are configured to the same IP address, but to a different vhids. .\"Once an ARP request is received, the CARP protocol will use a hashing .\"function against the source IP address in the ARP request to determine -.\"which vhid should this request belong to. -.\"If the corresponding CARP interface is in master state, the ARP request -.\"will be replied, otherwise it will be ignored. +.\"which vhid the request will be assigned to. +.\"If the corresponding CARP interface is the current +.\"master interface, a reply will +.\"be sent to the ARP request; +.\"otherwise it will be ignored. .\"See the .\".Sx EXAMPLES .\"section for a practical example of load balancing. .\".Pp -.\"The ARP load balancing has some limitations. +.\"The ARP load balancing implemented in +.\".Nm +.\"has some limitations. .\"First, ARP balancing only works on the local network segment. .\"It cannot balance traffic that crosses a router, because the .\"router itself will always be balanced to the same virtual host. @@ -170,10 +177,11 @@ Default value is 240 (maximum advskew va .\"is dangerous, because this creates a race condition between .\"balanced routers and a host they are serving. .\"Imagine an incoming packet creating state on the first router, being -.\"forwarded to its destination, and destination replying faster +.\"forwarded to its destination, and the destination replying faster .\"than the state information is packed and synced with the second router. .\"If the reply would be load balanced to second router, it will be -.\"dropped due to no state. +.\"dropped since the second router has not yet received information about +.\"the connection state. .Sh STATE CHANGE NOTIFICATIONS Sometimes it is useful to get notified about .Nm @@ -183,11 +191,12 @@ This can be accomplished by using hooks. Master/slave events are signalled under system .Dv CARP . -Subsystem specifies vhid and name of interface, where event occurred. -Type of the message displays new state of vhid. +The subsystem specifies the vhid and name of the interface where +the master/slave event occurred. +The type of the message displays the new state of the vhid. Please see .Xr devd.conf 5 -and +and the .Sx EXAMPLES section for more information. .Sh EXAMPLES @@ -195,8 +204,8 @@ For firewalls and routers with multiple failover all of the addresses running .Nm together, when one of the physical interfaces goes down. -This is achieved by the preempt option. -Enable it on both host A and B: +This is achieved by the use of the preempt option. +Enable it on both hosts A and B: .Pp .Dl sysctl net.inet.carp.preempt=1 .Pp @@ -295,7 +304,6 @@ The device was imported into .Fx 5.4 . In -.Fx 10.0 -the +.Fx 10.0 , .Nm was significantly rewritten, and is no longer a pseudo-interface. From owner-svn-src-all@FreeBSD.ORG Thu May 3 13:14:23 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37E89106564A; Thu, 3 May 2012 13:14:23 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 761638FC14; Thu, 3 May 2012 13:14:22 +0000 (UTC) Received: by vbmv11 with SMTP id v11so1650558vbm.13 for ; Thu, 03 May 2012 06:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=7uzJ8xgsPVtntvkCdfcB7L4yRXAV3MCDruYTzC4GA8M=; b=bxc02wTT8tCWdOzWNZtqbtG8hMp041pGRC3olzbk6S82TPhglR6v5EHD9CXDIoaGl0 8A48h8R9/gdF1eZCtS2P3ZNbTcoabFLR0iKpEqxuYCB3G8GDip7zM1doZ0lExkQ1MlsL C//6Pe0VXe16iJ+Z71J2tshe31az/wUkNNCtclB94mpunFyVe22Q4YStvSCgpefD9PdW q0Uy7QDw0A1/IvTwxcX2gI9/dR6SLMlPoxOEKlep9oNf4TiafUEPKKNayglDpUMX877y gfxGcI/qCvaaBrWlK5vK4aOzOLmSIbNdhd9joSFDlUGGb/swNj5MyknhlLUwPQJNRUM0 xUdA== MIME-Version: 1.0 Received: by 10.52.23.70 with SMTP id k6mr979335vdf.86.1336050861664; Thu, 03 May 2012 06:14:21 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.220.38.72 with HTTP; Thu, 3 May 2012 06:14:20 -0700 (PDT) In-Reply-To: <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 14:14:20 +0100 X-Google-Sender-Auth: wCNjRFQNGd-4CgDcioS5uUctlTc Message-ID: From: Attilio Rao To: Konstantin Belousov , christian.esken@trivago.com Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:14:23 -0000 2012/5/3, Konstantin Belousov : > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> 2012/5/3, Konstantin Belousov : >> > Author: kib >> > Date: Thu May 3 10:38:02 2012 >> > New Revision: 234952 >> > URL: http://svn.freebsd.org/changeset/base/234952 >> > >> > Log: >> > When callout_reset_on() cannot immediately migrate a callout since it >> > is running on other cpu, the CALLOUT_PENDING flag is temporarily >> > cleared. Then, callout_stop() on this, in fact active, callout fails >> > because CALLOUT_PENDING is not set, and callout_stop() returns 0. >> > >> > Now, in sleepq_check_timeout(), the failed callout_stop() causes the >> > sleepq code to execute mi_switch() without even setting the wmesg, >> > since the switch-out is supposed to be transient. In fact, the thread >> > is put off the CPU for full timeout interval, instead of being put on >> > runq immediately. Until timeout fires, the process is unkillable for >> > obvious reasons. >> > >> > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION >> > flag. The flag is cleared by callout_stop_safe() when the function >> > detects a migration, besides returning the success. The softclock() >> > rechecks the flag for migrating callout and cancels its execution if >> > the flag was cleared meantime. >> >> Can you please clarify why you cannot simply drop the deferred >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > > I probably can, I think I went with the route of committed patch > because it is slightly less work. Also, the comment in the while() > loop suggested me to rely on softclock. I don't think this is more work at all, the attached patch (pre-r234952, untested) should address it properly in few than 10 lines: http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch without the need to add further flags and re-using existing mechanisms. Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-svn-src-all@FreeBSD.ORG Thu May 3 13:27:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A1A0106564A; Thu, 3 May 2012 13:27:27 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 0019D8FC16; Thu, 3 May 2012 13:27:26 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43DRGQZ098646; Thu, 3 May 2012 16:27:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43DRFhA039663; Thu, 3 May 2012 16:27:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43DRFHK039662; Thu, 3 May 2012 16:27:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 May 2012 16:27:15 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503132715.GN2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="v0lslBALPq2/Zk2u" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:27:27 -0000 --v0lslBALPq2/Zk2u Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: > 2012/5/3, Konstantin Belousov : > > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > >> 2012/5/3, Konstantin Belousov : > >> > Author: kib > >> > Date: Thu May 3 10:38:02 2012 > >> > New Revision: 234952 > >> > URL: http://svn.freebsd.org/changeset/base/234952 > >> > > >> > Log: > >> > When callout_reset_on() cannot immediately migrate a callout since= it > >> > is running on other cpu, the CALLOUT_PENDING flag is temporarily > >> > cleared. Then, callout_stop() on this, in fact active, callout fai= ls > >> > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > >> > > >> > Now, in sleepq_check_timeout(), the failed callout_stop() causes t= he > >> > sleepq code to execute mi_switch() without even setting the wmesg, > >> > since the switch-out is supposed to be transient. In fact, the thr= ead > >> > is put off the CPU for full timeout interval, instead of being put= on > >> > runq immediately. Until timeout fires, the process is unkillable = for > >> > obvious reasons. > >> > > >> > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATI= ON > >> > flag. The flag is cleared by callout_stop_safe() when the function > >> > detects a migration, besides returning the success. The softclock() > >> > rechecks the flag for migrating callout and cancels its execution = if > >> > the flag was cleared meantime. > >> > >> Can you please clarify why you cannot simply drop the deferred > >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > > > > I probably can, I think I went with the route of committed patch > > because it is slightly less work. Also, the comment in the while() > > loop suggested me to rely on softclock. >=20 > I don't think this is more work at all, the attached patch > (pre-r234952, untested) should address it properly in few than 10 > lines: > http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >=20 > without the need to add further flags and re-using existing mechanisms. (cc->cc_curr !=3D c) is not the case which caused the issue. It might be needed to treatened this way, but the reported case is opposite. --v0lslBALPq2/Zk2u Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+ih7MACgkQC3+MBN1Mb4gtdACfUK1QNh57ZBpu2xpbPOIiuSEZ 8hEAn1EF1Yy77YYiz+TVmihpyg9JpZNj =uXBb -----END PGP SIGNATURE----- --v0lslBALPq2/Zk2u-- From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:25:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C6B811065672; Thu, 3 May 2012 15:25:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ACC978FC18; Thu, 3 May 2012 15:25:12 +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 q43FPC3V048763; Thu, 3 May 2012 15:25:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPCZ9048751; Thu, 3 May 2012 15:25:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPCZ9048751@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:12 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c Changes in other areas also in this revision: Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Modified: stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: stable/7/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- stable/7/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: stable/7/crypto/openssl/crypto/mem.c ============================================================================== --- stable/7/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: stable/7/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- stable/7/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: stable/7/crypto/openssl/ssl/s3_enc.c ============================================================================== --- stable/7/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: stable/7/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- stable/7/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -725,6 +734,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.ecdh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: stable/7/crypto/openssl/ssl/ssl.h ============================================================================== --- stable/7/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: stable/7/crypto/openssl/ssl/ssl3.h ============================================================================== --- stable/7/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: stable/7/crypto/openssl/ssl/ssl_err.c ============================================================================== --- stable/7/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ stable/7/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:25:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F3CF1065673; Thu, 3 May 2012 15:25:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E872C8FC19; Thu, 3 May 2012 15:25:12 +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 q43FPC76048779; Thu, 3 May 2012 15:25:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPCpS048767; Thu, 3 May 2012 15:25:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPCpS048767@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:13 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c Changes in other areas also in this revision: Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Modified: stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: stable/8/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- stable/8/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: stable/8/crypto/openssl/crypto/mem.c ============================================================================== --- stable/8/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: stable/8/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- stable/8/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: stable/8/crypto/openssl/ssl/s3_enc.c ============================================================================== --- stable/8/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: stable/8/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- stable/8/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -725,6 +734,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.ecdh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: stable/8/crypto/openssl/ssl/ssl.h ============================================================================== --- stable/8/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: stable/8/crypto/openssl/ssl/ssl3.h ============================================================================== --- stable/8/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: stable/8/crypto/openssl/ssl/ssl_err.c ============================================================================== --- stable/8/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ stable/8/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:25:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4A4041065675; Thu, 3 May 2012 15:25:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3009C8FC0A; Thu, 3 May 2012 15:25:13 +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 q43FPDMo048796; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPC4R048783; Thu, 3 May 2012 15:25:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPC4R048783@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:13 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Changes in other areas also in this revision: Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c Modified: stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: stable/9/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- stable/9/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: stable/9/crypto/openssl/crypto/mem.c ============================================================================== --- stable/9/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: stable/9/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- stable/9/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: stable/9/crypto/openssl/ssl/s3_enc.c ============================================================================== --- stable/9/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: stable/9/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- stable/9/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -725,6 +734,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.ecdh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: stable/9/crypto/openssl/ssl/ssl.h ============================================================================== --- stable/9/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: stable/9/crypto/openssl/ssl/ssl3.h ============================================================================== --- stable/9/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: stable/9/crypto/openssl/ssl/ssl_err.c ============================================================================== --- stable/9/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ stable/9/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:25:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BA6DD106566B; Thu, 3 May 2012 15:25:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A14B88FC1A; Thu, 3 May 2012 15:25:13 +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 q43FPDrX048829; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPDv1048800; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPDv1048800@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:13 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh Changes in other areas also in this revision: Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Modified: releng/7.4/UPDATING ============================================================================== --- releng/7.4/UPDATING Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/UPDATING Thu May 3 15:25:11 2012 (r234954) @@ -8,6 +8,9 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20120503: p7 FreeBSD-SA-12:01.openssl + Fix multiple OpenSSL vulnerabilities. + 20120104: p6 FreeBSD-EN-12:01.freebsd-update Extend the character set accepted by freebsd-update(8) in file names in order to allow upgrades to FreeBSD 9.0-RELEASE. Modified: releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: releng/7.4/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: releng/7.4/crypto/openssl/crypto/mem.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: releng/7.4/crypto/openssl/ssl/s3_enc.c ============================================================================== --- releng/7.4/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: releng/7.4/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- releng/7.4/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -720,6 +729,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.dh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: releng/7.4/crypto/openssl/ssl/ssl.h ============================================================================== --- releng/7.4/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: releng/7.4/crypto/openssl/ssl/ssl3.h ============================================================================== --- releng/7.4/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: releng/7.4/crypto/openssl/ssl/ssl_err.c ============================================================================== --- releng/7.4/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, Modified: releng/7.4/sys/conf/newvers.sh ============================================================================== --- releng/7.4/sys/conf/newvers.sh Thu May 3 13:08:11 2012 (r234953) +++ releng/7.4/sys/conf/newvers.sh Thu May 3 15:25:11 2012 (r234954) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="7.4" -BRANCH="RELEASE-p6" +BRANCH="RELEASE-p7" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi Modified: releng/8.1/UPDATING ============================================================================== --- releng/8.1/UPDATING Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/UPDATING Thu May 3 15:25:11 2012 (r234954) @@ -15,6 +15,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. debugging tools present in HEAD were left in place because sun4v support still needs work to become production ready. +20120503: p9 FreeBSD-SA-12:01.openssl + Fix multiple OpenSSL vulnerabilities. + 20120104: p8 FreeBSD-EN-12:01.freebsd-update Extend the character set accepted by freebsd-update(8) in file names in order to allow upgrades to FreeBSD 9.0-RELEASE. Modified: releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: releng/8.1/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: releng/8.1/crypto/openssl/crypto/mem.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -423,6 +423,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -464,36 +466,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -502,24 +510,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: releng/8.1/crypto/openssl/ssl/s3_enc.c ============================================================================== --- releng/8.1/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -480,6 +480,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: releng/8.1/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- releng/8.1/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -720,6 +729,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.dh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: releng/8.1/crypto/openssl/ssl/ssl.h ============================================================================== --- releng/8.1/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: releng/8.1/crypto/openssl/ssl/ssl3.h ============================================================================== --- releng/8.1/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: releng/8.1/crypto/openssl/ssl/ssl_err.c ============================================================================== --- releng/8.1/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, Modified: releng/8.1/sys/conf/newvers.sh ============================================================================== --- releng/8.1/sys/conf/newvers.sh Thu May 3 13:08:11 2012 (r234953) +++ releng/8.1/sys/conf/newvers.sh Thu May 3 15:25:11 2012 (r234954) @@ -32,7 +32,7 @@ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:25:14 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 087281065674; Thu, 3 May 2012 15:25:14 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E334E8FC1D; Thu, 3 May 2012 15:25:13 +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 q43FPDCT048845; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPDbE048833; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPDbE048833@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:14 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c Changes in other areas also in this revision: Modified: releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- head/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: head/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- head/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: head/crypto/openssl/crypto/mem.c ============================================================================== --- head/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: head/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- head/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: head/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- head/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: head/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- head/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: head/crypto/openssl/ssl/s3_enc.c ============================================================================== --- head/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: head/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- head/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -725,6 +734,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.ecdh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: head/crypto/openssl/ssl/ssl.h ============================================================================== --- head/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: head/crypto/openssl/ssl/ssl3.h ============================================================================== --- head/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: head/crypto/openssl/ssl/ssl_err.c ============================================================================== --- head/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:34:45 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B0AC1065670; Thu, 3 May 2012 15:34:45 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45CA98FC17; Thu, 3 May 2012 15:34: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 q43FYjaA049206; Thu, 3 May 2012 15:34:45 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FYjIR049204; Thu, 3 May 2012 15:34:45 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031534.q43FYjIR049204@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 15:34: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: r234955 - head/tools/tools/netmap X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:34:45 -0000 Author: luigi Date: Thu May 3 15:34:44 2012 New Revision: 234955 URL: http://svn.freebsd.org/changeset/base/234955 Log: - correct a bug in pcap_dispatch(): a count of 0 means infinity. - in pcap_dispatch(), issue a prefetch on the buffer before the callback, this may save a little bit of time if the client is very fast. - in pcap_inject(), use a fast copy routine, which also helps saving a few nanoseconds with fast clients. Modified: head/tools/tools/netmap/pcap.c Modified: head/tools/tools/netmap/pcap.c ============================================================================== --- head/tools/tools/netmap/pcap.c Thu May 3 15:25:11 2012 (r234954) +++ head/tools/tools/netmap/pcap.c Thu May 3 15:34:44 2012 (r234955) @@ -49,6 +49,34 @@ int verbose = 0; __FUNCTION__, __LINE__, ##__VA_ARGS__); \ } while (0) +inline void prefetch (const void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x)); +} + +// XXX only for multiples of 64 bytes, non overlapped. +static inline void +pkt_copy(const void *_src, void *_dst, int l) +{ + const uint64_t *src = _src; + uint64_t *dst = _dst; +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + if (unlikely(l >= 1024)) { + bcopy(src, dst, l); + return; + } + for (; l > 0; l-=64) { + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + } +} /* * We redefine here a number of structures that are in pcap.h @@ -479,21 +507,21 @@ pcap_setfilter(__unused pcap_t *p, __unu int pcap_datalink(__unused pcap_t *p) { - D(""); + D("returns 1"); return 1; // ethernet } const char * pcap_datalink_val_to_name(int dlt) { - D("%d", dlt); + D("%d returns DLT_EN10MB", dlt); return "DLT_EN10MB"; } const char * pcap_datalink_val_to_description(int dlt) { - D("%d", dlt); + D("%d returns Ethernet link", dlt); return "Ethernet link"; } @@ -525,7 +553,8 @@ pcap_open_live(const char *device, __unu { struct my_ring *me; - D("request to open %s", device); + D("request to open %s snaplen %d promisc %d timeout %dms", + device, snaplen, promisc, to_ms); me = calloc(1, sizeof(*me)); if (me == NULL) { D("failed to allocate struct for %s", device); @@ -610,6 +639,8 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h u_int si; ND("cnt %d", cnt); + if (cnt == 0) + cnt = -1; /* scan all rings */ for (si = me->begin; si < me->end; si++) { struct netmap_ring *ring = NETMAP_RXRING(me->nifp, si); @@ -617,6 +648,10 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h if (ring->avail == 0) continue; me->hdr.ts = ring->ts; + /* + * XXX a proper prefetch should be done as + * prefetch(i); callback(i-1); ... + */ while ((cnt == -1 || cnt != got) && ring->avail > 0) { u_int i = ring->cur; u_int idx = ring->slot[i].buf_idx; @@ -626,6 +661,7 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h sleep(2); } u_char *buf = (u_char *)NETMAP_BUF(ring, idx); + prefetch(buf); me->hdr.len = me->hdr.caplen = ring->slot[i].len; // D("call %p len %d", p, me->hdr.len); callback(user, &me->hdr, buf); @@ -660,7 +696,7 @@ pcap_inject(pcap_t *p, const void *buf, } u_char *dst = (u_char *)NETMAP_BUF(ring, idx); ring->slot[i].len = size; - bcopy(buf, dst, size); + pkt_copy(buf, dst, size); ring->cur = NETMAP_RING_NEXT(ring, i); ring->avail--; // if (ring->avail == 0) ioctl(me->fd, NIOCTXSYNC, NULL); From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:37:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A6C3106564A; Thu, 3 May 2012 15:37:06 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53B128FC15; Thu, 3 May 2012 15:37:06 +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 q43Fb6Sf049337; Thu, 3 May 2012 15:37:06 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Fb6Op049335; Thu, 3 May 2012 15:37:06 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031537.q43Fb6Op049335@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 15:37:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234956 - head/tools/tools/netmap X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:37:06 -0000 Author: luigi Date: Thu May 3 15:37:05 2012 New Revision: 234956 URL: http://svn.freebsd.org/changeset/base/234956 Log: - add code to run pkt-gen on top of libpcap so we can see the difference from a native API - add some testing options, such as conditional prefetching and packet copy. Modified: head/tools/tools/netmap/pkt-gen.c Modified: head/tools/tools/netmap/pkt-gen.c ============================================================================== --- head/tools/tools/netmap/pkt-gen.c Thu May 3 15:34:44 2012 (r234955) +++ head/tools/tools/netmap/pkt-gen.c Thu May 3 15:37:05 2012 (r234956) @@ -25,7 +25,7 @@ /* * $FreeBSD$ - * $Id: pkt-gen.c 10637 2012-02-24 16:36:25Z luigi $ + * $Id: pkt-gen.c 10967 2012-05-03 11:29:23Z luigi $ * * Example program to show how to build a multithreaded packet * source/sink using the netmap device. @@ -90,6 +90,36 @@ int verbose = 0; #define SKIP_PAYLOAD 1 /* do not check payload. */ +inline void prefetch (const void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x)); +} + +// XXX only for multiples of 32 bytes, non overlapped. +static inline void +pkt_copy(void *_src, void *_dst, int l) +{ + uint64_t *src = _src; + uint64_t *dst = _dst; +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + if (unlikely(l >= 1024)) { + bcopy(src, dst, l); + return; + } + for (; l > 0; l-=64) { + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + } +} + + #if EXPERIMENTAL /* Wrapper around `rdtsc' to take reliable timestamps flushing the pipeline */ #define netmap_rdtsc(t) \ @@ -140,6 +170,11 @@ struct glob_arg { int npackets; /* total packets to send */ int nthreads; int cpus; + int options; /* testing */ +#define OPT_PREFETCH 1 +#define OPT_ACCESS 2 +#define OPT_COPY 4 +#define OPT_MEMCPY 8 int use_pcap; pcap_t *p; }; @@ -394,19 +429,35 @@ check_payload(char *p, int psize) */ static int send_packets(struct netmap_ring *ring, struct pkt *pkt, - int size, u_int count, int fill_all) + int size, u_int count, int options) { u_int sent, cur = ring->cur; if (ring->avail < count) count = ring->avail; +#if 0 + if (options & (OPT_COPY | OPT_PREFETCH) ) { + for (sent = 0; sent < count; sent++) { + struct netmap_slot *slot = &ring->slot[cur]; + char *p = NETMAP_BUF(ring, slot->buf_idx); + + prefetch(p); + cur = NETMAP_RING_NEXT(ring, cur); + } + cur = ring->cur; + } +#endif for (sent = 0; sent < count; sent++) { struct netmap_slot *slot = &ring->slot[cur]; char *p = NETMAP_BUF(ring, slot->buf_idx); - if (fill_all) + if (options & OPT_COPY) + pkt_copy(pkt, p, size); + else if (options & OPT_MEMCPY) memcpy(p, pkt, size); + else if (options & OPT_PREFETCH) + prefetch(p); slot->len = size; if (sent == count - 1) @@ -428,8 +479,8 @@ sender_body(void *data) struct netmap_if *nifp = targ->nifp; struct netmap_ring *txring; int i, n = targ->g->npackets / targ->g->nthreads, sent = 0; - int fill_all = 1; - + int options = targ->g->options | OPT_COPY; +D("start"); if (setaffinity(targ->thread, targ->affinity)) goto quit; /* setup poll(2) mechanism. */ @@ -444,9 +495,13 @@ sender_body(void *data) void *pkt = &targ->pkt; pcap_t *p = targ->g->p; - for (; sent < n; sent++) { - if (pcap_inject(p, pkt, size) == -1) - break; + for (i = 0; sent < n; i++) { + if (pcap_inject(p, pkt, size) != -1) + sent++; + if (i > 10000) { + targ->count = sent; + i = 0; + } } } else { while (sent < n) { @@ -461,8 +516,8 @@ sender_body(void *data) /* * scan our queues and send on those with room */ - if (sent > 100000) - fill_all = 0; + if (sent > 100000 && !(targ->g->options & OPT_COPY) ) + options &= ~OPT_COPY; for (i = targ->qfirst; i < targ->qlast; i++) { int m, limit = MIN(n - sent, targ->g->burst); @@ -470,12 +525,12 @@ sender_body(void *data) if (txring->avail == 0) continue; m = send_packets(txring, &targ->pkt, targ->g->pkt_size, - limit, fill_all); + limit, options); sent += m; targ->count = sent; } } - /* Tell the interface that we have new packets. */ + /* flush any remaining packets */ ioctl(fds[0].fd, NIOCTXSYNC, NULL); /* final part: wait all the TX queues to be empty. */ @@ -672,6 +727,7 @@ int main(int arc, char **argv) { int i, fd; + char pcap_errbuf[PCAP_ERRBUF_SIZE]; struct glob_arg g; @@ -696,12 +752,15 @@ main(int arc, char **argv) g.cpus = 1; while ( (ch = getopt(arc, argv, - "i:t:r:l:d:s:D:S:b:c:p:T:w:v")) != -1) { + "i:t:r:l:d:s:D:S:b:c:o:p:PT:w:v")) != -1) { switch(ch) { default: D("bad option %c %s", ch, optarg); usage(); break; + case 'o': + g.options = atoi(optarg); + break; case 'i': /* interface */ ifname = optarg; break; @@ -775,6 +834,26 @@ main(int arc, char **argv) usage(); } + if (td_body == sender_body && g.src_mac == NULL) { + static char mybuf[20] = "ff:ff:ff:ff:ff:ff"; + /* retrieve source mac address. */ + if (source_hwaddr(ifname, mybuf) == -1) { + D("Unable to retrieve source mac"); + // continue, fail later + } + g.src_mac = mybuf; + } + + if (g.use_pcap) { + D("using pcap on %s", ifname); + g.p = pcap_open_live(ifname, 0, 1, 100, pcap_errbuf); + if (g.p == NULL) { + D("cannot open pcap on %s", ifname); + usage(); + } + mmap_addr = NULL; + fd = -1; + } else { bzero(&nmr, sizeof(nmr)); nmr.nr_version = NETMAP_API; /* @@ -811,16 +890,6 @@ main(int arc, char **argv) // continue, fail later } - if (td_body == sender_body && g.src_mac == NULL) { - static char mybuf[20] = "ff:ff:ff:ff:ff:ff"; - /* retrieve source mac address. */ - if (source_hwaddr(ifname, mybuf) == -1) { - D("Unable to retrieve source mac"); - // continue, fail later - } - g.src_mac = mybuf; - } - /* * Map the netmap shared memory: instead of issuing mmap() * inside the body of the threads, we prefer to keep this @@ -869,8 +938,15 @@ main(int arc, char **argv) D("aborting"); usage(); } + } - + if (g.options) { + D("special options:%s%s%s%s\n", + g.options & OPT_PREFETCH ? " prefetch" : "", + g.options & OPT_ACCESS ? " access" : "", + g.options & OPT_MEMCPY ? " memcpy" : "", + g.options & OPT_COPY ? " copy" : ""); + } /* Wait for PHY reset. */ D("Wait %d secs for phy reset", wait_link); sleep(wait_link); @@ -881,7 +957,12 @@ main(int arc, char **argv) signal(SIGINT, sigint_h); if (g.use_pcap) { - // XXX g.p = pcap_open_live(..); + g.p = pcap_open_live(ifname, 0, 1, 100, NULL); + if (g.p == NULL) { + D("cannot open pcap on %s", ifname); + usage(); + } else + D("using pcap %p on %s", g.p, ifname); } targs = calloc(g.nthreads, sizeof(*targs)); @@ -1018,9 +1099,11 @@ main(int arc, char **argv) rx_output(count, delta_t); } + if (g.use_pcap == 0) { ioctl(fd, NIOCUNREGIF, &nmr); munmap(mmap_addr, nmr.nr_memsize); close(fd); + } return (0); } From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:51:34 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C00AA1065686; Thu, 3 May 2012 15:51:34 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAD618FC16; Thu, 3 May 2012 15:51:34 +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 q43FpY17049899; Thu, 3 May 2012 15:51:34 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FpYBr049897; Thu, 3 May 2012 15:51:34 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <201205031551.q43FpYBr049897@svn.freebsd.org> From: Christian Brueffer Date: Thu, 3 May 2012 15:51:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234957 - head/sys/security/mac_mls X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:51:34 -0000 Author: brueffer Date: Thu May 3 15:51:34 2012 New Revision: 234957 URL: http://svn.freebsd.org/changeset/base/234957 Log: Check vplabel for NULL before dereferencing it. Fixes a panic when running atop with MAC_MLS enabled. Submitted by: Richard Kojedzinszky Reviewed by: rwatson MFC after: 1 week Modified: head/sys/security/mac_mls/mac_mls.c Modified: head/sys/security/mac_mls/mac_mls.c ============================================================================== --- head/sys/security/mac_mls/mac_mls.c Thu May 3 15:37:05 2012 (r234956) +++ head/sys/security/mac_mls/mac_mls.c Thu May 3 15:51:34 2012 (r234957) @@ -2028,6 +2028,9 @@ mls_system_check_acct(struct ucred *cred if (!mls_enabled) return (0); + if (vplabel == NULL) + return (0); + subj = SLOT(cred->cr_label); obj = SLOT(vplabel); From owner-svn-src-all@FreeBSD.ORG Thu May 3 15:54:07 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F529106566C; Thu, 3 May 2012 15:54:07 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A0EF8FC1C; Thu, 3 May 2012 15:54: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 q43Fs76H050023; Thu, 3 May 2012 15:54:07 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Fs78Q050021; Thu, 3 May 2012 15:54:07 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031554.q43Fs78Q050021@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 15:54: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: r234958 - head/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:54:07 -0000 Author: theraven Date: Thu May 3 15:54:06 2012 New Revision: 234958 URL: http://svn.freebsd.org/changeset/base/234958 Log: Fix after clang decided to rename all of its builtins to include a c11 prefix to disambiguate them from the one provided by GCC. Note: Clang 3.1 also supports the GCC builtins for libstdc++ 4.7 compatibility, but I don't recommend using them because they are very poorly designed. MFC after: 2 weeks Modified: head/include/stdatomic.h Modified: head/include/stdatomic.h ============================================================================== --- head/include/stdatomic.h Thu May 3 15:51:34 2012 (r234957) +++ head/include/stdatomic.h Thu May 3 15:54:06 2012 (r234958) @@ -51,7 +51,7 @@ #if defined(__CLANG_ATOMICS) #define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __atomic_init(obj, value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) #else #define ATOMIC_VAR_INIT(value) { .__val = (value) } #define atomic_init(obj, value) do { \ @@ -104,7 +104,10 @@ enum memory_order { * 7.17.4 Fences. */ -#if defined(__CLANG_ATOMICS) || defined(__GNUC_ATOMICS) +#ifdef __CLANG_ATOMICS +#define atomic_thread_fence(order) __c11_atomic_thread_fence(order) +#define atomic_signal_fence(order) __c11_atomic_signal_fence(order) +#elif defined(__GNUC_ATOMICS) #define atomic_thread_fence(order) __atomic_thread_fence(order) #define atomic_signal_fence(order) __atomic_signal_fence(order) #else @@ -118,7 +121,7 @@ enum memory_order { #if defined(__CLANG_ATOMICS) #define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof(obj)) + __c11_atomic_is_lock_free(sizeof(obj)) #elif defined(__GNUC_ATOMICS) #define atomic_is_lock_free(obj) \ __atomic_is_lock_free(sizeof((obj)->__val)) @@ -182,28 +185,28 @@ typedef _Atomic(__uintmax_t) atomic_uin #if defined(__CLANG_ATOMICS) #define atomic_compare_exchange_strong_explicit(object, expected, \ desired, success, failure) \ - __atomic_compare_exchange_strong(object, expected, desired, \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ success, failure) #define atomic_compare_exchange_weak_explicit(object, expected, \ desired, success, failure) \ - __atomic_compare_exchange_weak(object, expected, desired, \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ success, failure) #define atomic_exchange_explicit(object, desired, order) \ - __atomic_exchange(object, desired, order) + __c11_atomic_exchange(object, desired, order) #define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(object, operand, order) + __c11_atomic_fetch_add(object, operand, order) #define atomic_fetch_and_explicit(object, operand, order) \ - __atomic_fetch_and(object, operand, order) + __c11_atomic_fetch_and(object, operand, order) #define atomic_fetch_or_explicit(object, operand, order) \ - __atomic_fetch_or(object, operand, order) + __c11_atomic_fetch_or(object, operand, order) #define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(object, operand, order) + __c11_atomic_fetch_sub(object, operand, order) #define atomic_fetch_xor_explicit(object, operand, order) \ - __atomic_fetch_xor(object, operand, order) + __c11_atomic_fetch_xor(object, operand, order) #define atomic_load_explicit(object, order) \ - __atomic_load(object, order) + __c11_atomic_load(object, order) #define atomic_store_explicit(object, desired, order) \ - __atomic_store(object, desired, order) + __c11_atomic_store(object, desired, order) #elif defined(__GNUC_ATOMICS) #define atomic_compare_exchange_strong_explicit(object, expected, \ desired, success, failure) \ From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:04:02 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4A981065670; Thu, 3 May 2012 16:04:02 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AED888FC18; Thu, 3 May 2012 16:04: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 q43G424F050460; Thu, 3 May 2012 16:04:02 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G42uD050454; Thu, 3 May 2012 16:04:02 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031604.q43G42uD050454@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 16:04:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234959 - in vendor/libc++/dist: include src X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:04:02 -0000 Author: theraven Date: Thu May 3 16:04:02 2012 New Revision: 234959 URL: http://svn.freebsd.org/changeset/base/234959 Log: Import a new version of libc++ into the vendor branch. Modified: vendor/libc++/dist/include/__config vendor/libc++/dist/include/__tuple vendor/libc++/dist/include/algorithm vendor/libc++/dist/include/atomic vendor/libc++/dist/include/cmath vendor/libc++/dist/include/limits vendor/libc++/dist/include/memory vendor/libc++/dist/include/random vendor/libc++/dist/include/system_error vendor/libc++/dist/include/tuple vendor/libc++/dist/include/type_traits vendor/libc++/dist/include/utility vendor/libc++/dist/src/iostream.cpp vendor/libc++/dist/src/stdexcept.cpp vendor/libc++/dist/src/utility.cpp Modified: vendor/libc++/dist/include/__config ============================================================================== --- vendor/libc++/dist/include/__config Thu May 3 15:54:06 2012 (r234958) +++ vendor/libc++/dist/include/__config Thu May 3 16:04:02 2012 (r234959) @@ -384,7 +384,9 @@ template struct __static_asse #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR -#define constexpr const +#define _LIBCPP_CONSTEXPR +#else +#define _LIBCPP_CONSTEXPR constexpr #endif #ifndef __has_feature Modified: vendor/libc++/dist/include/__tuple ============================================================================== --- vendor/libc++/dist/include/__tuple Thu May 3 15:54:06 2012 (r234958) +++ vendor/libc++/dist/include/__tuple Thu May 3 16:04:02 2012 (r234959) @@ -216,7 +216,7 @@ struct __tuple_convertible_imp : public template struct __tuple_convertible_imp, __tuple_types<_Up0, _Up...> > : public integral_constant::value && + is_convertible<_Tp0, _Up0>::value && __tuple_convertible_imp, __tuple_types<_Up...> >::value> {}; template <> @@ -235,6 +235,33 @@ struct __tuple_convertible<_Tp, _Up, tru typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> {}; +// __tuple_constructible + +template +struct __tuple_constructible_imp : public false_type {}; + +template +struct __tuple_constructible_imp, __tuple_types<_Up0, _Up...> > + : public integral_constant::value && + __tuple_constructible_imp, __tuple_types<_Up...> >::value> {}; + +template <> +struct __tuple_constructible_imp, __tuple_types<> > + : public true_type {}; + +template ::type>::value, + bool = __tuple_like<_Up>::value> +struct __tuple_constructible + : public false_type {}; + +template +struct __tuple_constructible<_Tp, _Up, true, true> + : public __tuple_constructible_imp::type>::value == + tuple_size<_Up>::value, + typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> +{}; + // __tuple_assignable template Modified: vendor/libc++/dist/include/algorithm ============================================================================== --- vendor/libc++/dist/include/algorithm Thu May 3 15:54:06 2012 (r234958) +++ vendor/libc++/dist/include/algorithm Thu May 3 16:04:02 2012 (r234959) @@ -2508,11 +2508,16 @@ private: _Engine_result_type __mask0_; _Engine_result_type __mask1_; +#ifdef _LIBCPP_HAS_NO_CONSTEXPR static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min - + _Working_result_type(1); - static const size_t __m = __log2<_Working_result_type, _Rp>::value; - static const size_t _WDt = numeric_limits<_Working_result_type>::digits; - static const size_t _EDt = numeric_limits<_Engine_result_type>::digits; + + _Working_result_type(1); +#else + static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() + + _Working_result_type(1); +#endif + static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; + static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; + static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; public: // constructors and seeding functions @@ -2712,8 +2717,8 @@ public: result_type operator()(); - static constexpr result_type min() {return _Min;} - static constexpr result_type max() {return _Max;} + static _LIBCPP_CONSTEXPR result_type min() {return _Min;} + static _LIBCPP_CONSTEXPR result_type max() {return _Max;} friend __rs_default __rs_get(); }; Modified: vendor/libc++/dist/include/atomic ============================================================================== --- vendor/libc++/dist/include/atomic Thu May 3 15:54:06 2012 (r234958) +++ vendor/libc++/dist/include/atomic Thu May 3 16:04:02 2012 (r234959) @@ -29,7 +29,7 @@ typedef enum memory_order memory_order_seq_cst // store-release load-acquire } memory_order; -template T kill_dependency(T y); +template T kill_dependency(T y) noexcept; // lock-free property @@ -46,40 +46,40 @@ template T kill_dependency(T y typedef struct atomic_flag { - bool test_and_set(memory_order m = memory_order_seq_cst) volatile; - bool test_and_set(memory_order m = memory_order_seq_cst); - void clear(memory_order m = memory_order_seq_cst) volatile; - void clear(memory_order m = memory_order_seq_cst); - atomic_flag() = default; + bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; + bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; + void clear(memory_order m = memory_order_seq_cst) volatile noexcept; + void clear(memory_order m = memory_order_seq_cst) noexcept; + atomic_flag() noexcept = default; atomic_flag(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) volatile = delete; } atomic_flag; bool - atomic_flag_test_and_set(volatile atomic_flag* obj); + atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; bool - atomic_flag_test_and_set(atomic_flag* obj); + atomic_flag_test_and_set(atomic_flag* obj) noexcept; bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, - memory_order m); + memory_order m) noexcept; bool - atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m); + atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear(volatile atomic_flag* obj); + atomic_flag_clear(volatile atomic_flag* obj) noexcept; void - atomic_flag_clear(atomic_flag* obj); + atomic_flag_clear(atomic_flag* obj) noexcept; void - atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear_explicit(atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; #define ATOMIC_FLAG_INIT see below #define ATOMIC_VAR_INIT(value) see below @@ -87,388 +87,388 @@ void template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T desr, memory_order m = memory_order_seq_cst) volatile; - void store(T desr, memory_order m = memory_order_seq_cst); - T load(memory_order m = memory_order_seq_cst) const volatile; - T load(memory_order m = memory_order_seq_cst) const; - operator T() const volatile; - operator T() const; - T exchange(T desr, memory_order m = memory_order_seq_cst) volatile; - T exchange(T desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) noexcept; + T load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T load(memory_order m = memory_order_seq_cst) const noexcept; + operator T() const volatile noexcept; + operator T() const noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order s, memory_order f) volatile; - bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f); + memory_order s, memory_order f) volatile noexcept; + bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T desr); + atomic() noexcept = default; + constexpr atomic(T desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T operator=(T) volatile; - T operator=(T); + T operator=(T) volatile noexcept; + T operator=(T) noexcept; }; template <> struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(integral desr, memory_order m = memory_order_seq_cst) volatile; - void store(integral desr, memory_order m = memory_order_seq_cst); - integral load(memory_order m = memory_order_seq_cst) const volatile; - integral load(memory_order m = memory_order_seq_cst) const; - operator integral() const volatile; - operator integral() const; + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; + integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; + integral load(memory_order m = memory_order_seq_cst) const noexcept; + operator integral() const volatile noexcept; + operator integral() const noexcept; integral exchange(integral desr, - memory_order m = memory_order_seq_cst) volatile; - integral exchange(integral desr, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) volatile noexcept; + integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; integral - fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_add(integral op, memory_order m = memory_order_seq_cst); + fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_sub(integral op, memory_order m = memory_order_seq_cst); + fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_and(integral op, memory_order m = memory_order_seq_cst); + fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_or(integral op, memory_order m = memory_order_seq_cst); + fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_xor(integral op, memory_order m = memory_order_seq_cst); + fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(integral desr); + atomic() noexcept = default; + constexpr atomic(integral desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - integral operator=(integral desr) volatile; - integral operator=(integral desr); + integral operator=(integral desr) volatile noexcept; + integral operator=(integral desr) noexcept; - integral operator++(int) volatile; - integral operator++(int); - integral operator--(int) volatile; - integral operator--(int); - integral operator++() volatile; - integral operator++(); - integral operator--() volatile; - integral operator--(); - integral operator+=(integral op) volatile; - integral operator+=(integral op); - integral operator-=(integral op) volatile; - integral operator-=(integral op); - integral operator&=(integral op) volatile; - integral operator&=(integral op); - integral operator|=(integral op) volatile; - integral operator|=(integral op); - integral operator^=(integral op) volatile; - integral operator^=(integral op); + integral operator++(int) volatile noexcept; + integral operator++(int) noexcept; + integral operator--(int) volatile noexcept; + integral operator--(int) noexcept; + integral operator++() volatile noexcept; + integral operator++() noexcept; + integral operator--() volatile noexcept; + integral operator--() noexcept; + integral operator+=(integral op) volatile noexcept; + integral operator+=(integral op) noexcept; + integral operator-=(integral op) volatile noexcept; + integral operator-=(integral op) noexcept; + integral operator&=(integral op) volatile noexcept; + integral operator&=(integral op) noexcept; + integral operator|=(integral op) volatile noexcept; + integral operator|=(integral op) noexcept; + integral operator^=(integral op) volatile noexcept; + integral operator^=(integral op) noexcept; }; template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T* desr, memory_order m = memory_order_seq_cst) volatile; - void store(T* desr, memory_order m = memory_order_seq_cst); - T* load(memory_order m = memory_order_seq_cst) const volatile; - T* load(memory_order m = memory_order_seq_cst) const; - operator T*() const volatile; - operator T*() const; - T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile; - T* exchange(T* desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; + T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T* load(memory_order m = memory_order_seq_cst) const noexcept; + operator T*() const volatile noexcept; + operator T*() const noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst); - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T* desr); + atomic() noexcept = default; + constexpr atomic(T* desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T* operator=(T*) volatile; - T* operator=(T*); - T* operator++(int) volatile; - T* operator++(int); - T* operator--(int) volatile; - T* operator--(int); - T* operator++() volatile; - T* operator++(); - T* operator--() volatile; - T* operator--(); - T* operator+=(ptrdiff_t op) volatile; - T* operator+=(ptrdiff_t op); - T* operator-=(ptrdiff_t op) volatile; - T* operator-=(ptrdiff_t op); + T* operator=(T*) volatile noexcept; + T* operator=(T*) noexcept; + T* operator++(int) volatile noexcept; + T* operator++(int) noexcept; + T* operator--(int) volatile noexcept; + T* operator--(int) noexcept; + T* operator++() volatile noexcept; + T* operator++() noexcept; + T* operator--() volatile noexcept; + T* operator--() noexcept; + T* operator+=(ptrdiff_t op) volatile noexcept; + T* operator+=(ptrdiff_t op) noexcept; + T* operator-=(ptrdiff_t op) volatile noexcept; + T* operator-=(ptrdiff_t op) noexcept; }; template bool - atomic_is_lock_free(const volatile atomic* obj); + atomic_is_lock_free(const volatile atomic* obj) noexcept; template bool - atomic_is_lock_free(const atomic* obj); + atomic_is_lock_free(const atomic* obj) noexcept; template void - atomic_init(volatile atomic* obj, T desr); + atomic_init(volatile atomic* obj, T desr) noexcept; template void - atomic_init(atomic* obj, T desr); + atomic_init(atomic* obj, T desr) noexcept; template void - atomic_store(volatile atomic* obj, T desr); + atomic_store(volatile atomic* obj, T desr) noexcept; template void - atomic_store(atomic* obj, T desr); + atomic_store(atomic* obj, T desr) noexcept; template void - atomic_store_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_store_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template void - atomic_store_explicit(atomic* obj, T desr, memory_order m); + atomic_store_explicit(atomic* obj, T desr, memory_order m) noexcept; template T - atomic_load(const volatile atomic* obj); + atomic_load(const volatile atomic* obj) noexcept; template T - atomic_load(const atomic* obj); + atomic_load(const atomic* obj) noexcept; template T - atomic_load_explicit(const volatile atomic* obj, memory_order m); + atomic_load_explicit(const volatile atomic* obj, memory_order m) noexcept; template T - atomic_load_explicit(const atomic* obj, memory_order m); + atomic_load_explicit(const atomic* obj, memory_order m) noexcept; template T - atomic_exchange(volatile atomic* obj, T desr); + atomic_exchange(volatile atomic* obj, T desr) noexcept; template T - atomic_exchange(atomic* obj, T desr); + atomic_exchange(atomic* obj, T desr) noexcept; template T - atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template T - atomic_exchange_explicit(atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(atomic* obj, T desr, memory_order m) noexcept; template bool - atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_weak(atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_weak_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_weak_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template Integral - atomic_fetch_add(volatile atomic* obj, Integral op); + atomic_fetch_add(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_add(atomic* obj, Integral op); + atomic_fetch_add(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_add_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_add_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_sub(volatile atomic* obj, Integral op); + atomic_fetch_sub(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_sub(atomic* obj, Integral op); + atomic_fetch_sub(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_sub_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_sub_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_and(volatile atomic* obj, Integral op); + atomic_fetch_and(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_and(atomic* obj, Integral op); + atomic_fetch_and(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_and_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_and_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_or(volatile atomic* obj, Integral op); + atomic_fetch_or(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_or(atomic* obj, Integral op); + atomic_fetch_or(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_or_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_or_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_xor(volatile atomic* obj, Integral op); + atomic_fetch_xor(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_xor(atomic* obj, Integral op); + atomic_fetch_xor(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_xor_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_xor_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_add(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_add(atomic* obj, ptrdiff_t op); + atomic_fetch_add(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* - atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_sub(atomic* obj, ptrdiff_t op); + atomic_fetch_sub(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; // Atomics for standard typedef types @@ -514,8 +514,8 @@ typedef atomic atomic_uintmax // fences -void atomic_thread_fence(memory_order m); -void atomic_signal_fence(memory_order m); +void atomic_thread_fence(memory_order m) noexcept; +void atomic_signal_fence(memory_order m) noexcept; } // std @@ -545,7 +545,7 @@ typedef enum memory_order template inline _LIBCPP_INLINE_VISIBILITY _Tp -kill_dependency(_Tp __y) +kill_dependency(_Tp __y) _NOEXCEPT { return __y; } @@ -558,70 +558,70 @@ struct __atomic_base // false _Atomic(_Tp) __a_; _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const volatile - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const volatile _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const volatile - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const volatile {return load();} + operator _Tp() const volatile _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const {return load();} + operator _Tp() const _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) { __atomic_store(&__a_, __d, memory_order_seq_cst); } + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; @@ -642,77 +642,77 @@ struct __atomic_base<_Tp, true> { typedef __atomic_base<_Tp, false> __base; _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) volatile {return fetch_add(_Tp(1));} + _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) {return fetch_add(_Tp(1));} + _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) volatile {return fetch_sub(_Tp(1));} + _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) {return fetch_sub(_Tp(1));} + _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() volatile {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() volatile {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) volatile {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) volatile {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) volatile {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) volatile {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) volatile {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} }; // atomic @@ -723,15 +723,15 @@ struct atomic { typedef __atomic_base<_Tp> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) volatile + _Tp operator=(_Tp __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) + _Tp operator=(_Tp __d) _NOEXCEPT {__base::store(__d); return __d;} }; @@ -743,56 +743,56 @@ struct atomic<_Tp*> { typedef __atomic_base<_Tp*> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp* __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) volatile + _Tp* operator=(_Tp* __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) + _Tp* operator=(_Tp* __d) _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) - volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:05:34 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC010106566B; Thu, 3 May 2012 16:05:34 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D7518FC16; Thu, 3 May 2012 16:05:34 +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 q43G5YA9050549; Thu, 3 May 2012 16:05:34 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G5Y2l050548; Thu, 3 May 2012 16:05:34 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031605.q43G5Y2l050548@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 16:05:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234960 - vendor/libc++/r156067 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:05:34 -0000 Author: theraven Date: Thu May 3 16:05:34 2012 New Revision: 234960 URL: http://svn.freebsd.org/changeset/base/234960 Log: Tag new libc++ import. Added: vendor/libc++/r156067/ - copied from r234959, vendor/libc++/dist/ From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:06:23 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 036A01065670; Thu, 3 May 2012 16:06:23 +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 D83748FC1F; Thu, 3 May 2012 16:06:22 +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 q43G6M5E050628; Thu, 3 May 2012 16:06:22 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G6McP050625; Thu, 3 May 2012 16:06:22 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205031606.q43G6McP050625@svn.freebsd.org> From: Hans Petter Selasky Date: Thu, 3 May 2012 16:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234961 - in head/sys/dev/usb: . controller X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:06:23 -0000 Author: hselasky Date: Thu May 3 16:06:22 2012 New Revision: 234961 URL: http://svn.freebsd.org/changeset/base/234961 Log: Make sure the EHCI bandwidth allocation algorithm for FULL speed SPLIT transactions works fully. MFC after: 1 week Modified: head/sys/dev/usb/controller/ehci.c head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/controller/ehci.c ============================================================================== --- head/sys/dev/usb/controller/ehci.c Thu May 3 16:05:34 2012 (r234960) +++ head/sys/dev/usb/controller/ehci.c Thu May 3 16:06:22 2012 (r234961) @@ -2638,11 +2638,29 @@ ehci_device_isoc_fs_enter(struct usb_xfe /* update isoc_next */ xfer->endpoint->isoc_next = (pp_last - &sc->sc_isoc_fs_p_last[0]) & (EHCI_VIRTUAL_FRAMELIST_COUNT - 1); + + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; } static void ehci_device_isoc_fs_start(struct usb_xfer *xfer) { + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; + + /* set a default timeout */ + if (xfer->timeout == 0) + xfer->timeout = 500; /* ms */ + /* put transfer on interrupt queue */ ehci_transfer_intr_enqueue(xfer); } Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Thu May 3 16:05:34 2012 (r234960) +++ head/sys/dev/usb/usb_transfer.c Thu May 3 16:06:22 2012 (r234961) @@ -1681,11 +1681,12 @@ usbd_pipe_enter(struct usb_xfer *xfer) DPRINTF("enter\n"); + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* enter the transfer */ (ep->methods->enter) (xfer); - xfer->flags_int.can_cancel_immed = 1; - /* check for transfer error */ if (xfer->error) { /* some error has happened */ @@ -2418,13 +2419,15 @@ usbd_transfer_start_cb(void *arg) #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); @@ -2599,13 +2602,14 @@ usbd_pipe_start(struct usb_xfer_queue *p #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:09:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B432A106566C; Thu, 3 May 2012 16:09:44 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F5438FC12; Thu, 3 May 2012 16:09:44 +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 q43G9i4O050766; Thu, 3 May 2012 16:09:44 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G9inj050764; Thu, 3 May 2012 16:09:44 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031609.q43G9inj050764@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 16:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234962 - head/tools/tools/netmap X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:09:44 -0000 Author: luigi Date: Thu May 3 16:09:44 2012 New Revision: 234962 URL: http://svn.freebsd.org/changeset/base/234962 Log: add some performance data Modified: head/tools/tools/netmap/README Modified: head/tools/tools/netmap/README ============================================================================== --- head/tools/tools/netmap/README Thu May 3 16:06:22 2012 (r234961) +++ head/tools/tools/netmap/README Thu May 3 16:09:44 2012 (r234962) @@ -9,3 +9,14 @@ This directory contains examples that us testpcap a jumper wire using libnetmap (or libpcap) click* various click examples + +------------------------------------------------------------ +Some performance data as of may 2012 for applications using libpcap. +Throughput is generally in Mpps computed with the 64-byte frames, +using 1 core on a 2.9GHz CPU and 10Gbit/s interface + +Libpcap version -- Application --------------------- +BSD netmap +--------------------------------------------------- + 0.77 3.82 ports/trafshow (version 5) + 0.94 7.7 net-mgmt/ipcad (ip accounting daemon) From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:14:41 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BBE0E1065674; Thu, 3 May 2012 16:14:41 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 750748FC14; Thu, 3 May 2012 16:14:41 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 997ED7300A; Thu, 3 May 2012 18:34:33 +0200 (CEST) Date: Thu, 3 May 2012 18:34:33 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" Message-ID: <20120503163433.GA4727@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> <20120430133904.GA65792@onelab2.iet.unipi.it> <4FA24920.4080809@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FA24920.4080809@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:14:41 -0000 On Thu, May 03, 2012 at 01:00:16PM +0400, Alexander V. Chernikov wrote: ... > Reverted in r234946 thank you very much for the quick resolution of the issue. I really appreciate it. cheers luigi From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:19:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 845BF106566B; Thu, 3 May 2012 16:19:42 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6EC7D8FC12; Thu, 3 May 2012 16:19:42 +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 q43GJgxA051291; Thu, 3 May 2012 16:19:42 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GJglg051289; Thu, 3 May 2012 16:19:42 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031619.q43GJglg051289@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:19:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234963 - stable/9/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:19:42 -0000 Author: eadler Date: Thu May 3 16:19:41 2012 New Revision: 234963 URL: http://svn.freebsd.org/changeset/base/234963 Log: MFC r234714, r234700: Document the standardization status of err* and warn* PR: docs/164939 Approved by: cperciva (implicit) Modified: stable/9/lib/libc/gen/err.3 Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/gen/err.3 ============================================================================== --- stable/9/lib/libc/gen/err.3 Thu May 3 16:09:44 2012 (r234962) +++ stable/9/lib/libc/gen/err.3 Thu May 3 16:19:41 2012 (r234963) @@ -28,7 +28,7 @@ .\" From: @(#)err.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd March 6, 1999 +.Dd March 29, 2012 .Dt ERR 3 .Os .Sh NAME @@ -212,6 +212,18 @@ if (error != 0) .Xr printf 3 , .Xr strerror 3 , .Xr sysexits 3 +.Sh STANDARDS +The +.Fn err +and +.Fn warn +families of functions are +.Bx +extensions. +As such they should not be used in truly portable code. +Use +.Fn strerror +or similar functions instead. .Sh HISTORY The .Fn err From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:20:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 931F8106566B; Thu, 3 May 2012 16:20:51 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D5B78FC20; Thu, 3 May 2012 16:20:51 +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 q43GKp6v051366; Thu, 3 May 2012 16:20:51 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GKpxn051363; Thu, 3 May 2012 16:20:51 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031620.q43GKpxn051363@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:20:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234964 - stable/8/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:20:51 -0000 Author: eadler Date: Thu May 3 16:20:50 2012 New Revision: 234964 URL: http://svn.freebsd.org/changeset/base/234964 Log: MFC r234714, r234700: Document the standardization status of err* and warn* PR: docs/164939 Approved by: cperciva (implicit) Modified: stable/8/lib/libc/gen/err.3 Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/gen/err.3 ============================================================================== --- stable/8/lib/libc/gen/err.3 Thu May 3 16:19:41 2012 (r234963) +++ stable/8/lib/libc/gen/err.3 Thu May 3 16:20:50 2012 (r234964) @@ -28,7 +28,7 @@ .\" From: @(#)err.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd March 6, 1999 +.Dd March 29, 2012 .Dt ERR 3 .Os .Sh NAME @@ -212,6 +212,18 @@ if (error != 0) .Xr printf 3 , .Xr strerror 3 , .Xr sysexits 3 +.Sh STANDARDS +The +.Fn err +and +.Fn warn +families of functions are +.Bx +extensions. +As such they should not be used in truly portable code. +Use +.Fn strerror +or similar functions instead. .Sh HISTORY The .Fn err From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:21:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8C9A3106564A; Thu, 3 May 2012 16:21:27 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 772F38FC1E; Thu, 3 May 2012 16:21: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 q43GLR8T051423; Thu, 3 May 2012 16:21:27 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GLRBM051421; Thu, 3 May 2012 16:21:27 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031621.q43GLRBM051421@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:21:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234965 - stable/7/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:21:27 -0000 Author: eadler Date: Thu May 3 16:21:26 2012 New Revision: 234965 URL: http://svn.freebsd.org/changeset/base/234965 Log: MFC r234714, r234700: Document the standardization status of err* and warn* PR: docs/164939 Approved by: cperciva (implicit) Modified: stable/7/lib/libc/gen/err.3 Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/gen/err.3 ============================================================================== --- stable/7/lib/libc/gen/err.3 Thu May 3 16:20:50 2012 (r234964) +++ stable/7/lib/libc/gen/err.3 Thu May 3 16:21:26 2012 (r234965) @@ -28,7 +28,7 @@ .\" From: @(#)err.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd March 6, 1999 +.Dd March 29, 2012 .Dt ERR 3 .Os .Sh NAME @@ -211,6 +211,18 @@ if (error != 0) .Xr printf 3 , .Xr strerror 3 , .Xr sysexits 3 +.Sh STANDARDS +The +.Fn err +and +.Fn warn +families of functions are +.Bx +extensions. +As such they should not be used in truly portable code. +Use +.Fn strerror +or similar functions instead. .Sh HISTORY The .Fn err From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:31:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 526B31065673; Thu, 3 May 2012 16:31:22 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1E3E8FC1A; Thu, 3 May 2012 16:31: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 q43GVLEP051861; Thu, 3 May 2012 16:31:21 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GVL1j051858; Thu, 3 May 2012 16:31:21 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031631.q43GVL1j051858@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:31:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234966 - stable/9/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:31:22 -0000 Author: eadler Date: Thu May 3 16:31:21 2012 New Revision: 234966 URL: http://svn.freebsd.org/changeset/base/234966 Log: MFC r234131: Return EBADF instead of EMFILE from dup2 when the second argument is outside the range of valid file descriptors PR: kern/164970 Approved by: cperciva (implicit) Modified: stable/9/lib/libc/sys/dup.2 stable/9/lib/libc/sys/fcntl.2 Directory Properties: stable/9/lib/libc/ (props changed) stable/9/lib/libc/sys/ (props changed) Modified: stable/9/lib/libc/sys/dup.2 ============================================================================== --- stable/9/lib/libc/sys/dup.2 Thu May 3 16:21:26 2012 (r234965) +++ stable/9/lib/libc/sys/dup.2 Thu May 3 16:31:21 2012 (r234966) @@ -128,20 +128,27 @@ indicates the cause of the error. .Sh ERRORS The .Fn dup -and -.Fn dup2 -system calls fail if: +system call fails if: .Bl -tag -width Er .It Bq Er EBADF The .Fa oldd -or -.Fa newd argument is not a valid active descriptor .It Bq Er EMFILE Too many descriptors are active. .El +The +.Fn dup2 +system call fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa oldd +argument is not a valid active descriptor or the +.Fa newd +argument is negative or exceeds the maximum allowable descriptor number +.El .Sh SEE ALSO .Xr accept 2 , .Xr cap_new 2 , Modified: stable/9/lib/libc/sys/fcntl.2 ============================================================================== --- stable/9/lib/libc/sys/fcntl.2 Thu May 3 16:21:26 2012 (r234965) +++ stable/9/lib/libc/sys/fcntl.2 Thu May 3 16:31:21 2012 (r234966) @@ -539,8 +539,6 @@ The argument .Fa cmd is .Dv F_DUPFD -or -.Dv F_DUP2FD and the maximum number of file descriptors permitted for the process are already in use, or no file descriptors greater than or equal to From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:31:45 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4189710656E3; Thu, 3 May 2012 16:31:45 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2BC5C8FC1A; Thu, 3 May 2012 16:31: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 q43GVjiF051907; Thu, 3 May 2012 16:31:45 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GVivl051904; Thu, 3 May 2012 16:31:44 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031631.q43GVivl051904@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:31:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234967 - stable/8/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:31:45 -0000 Author: eadler Date: Thu May 3 16:31:44 2012 New Revision: 234967 URL: http://svn.freebsd.org/changeset/base/234967 Log: MFC r234131: Return EBADF instead of EMFILE from dup2 when the second argument is outside the range of valid file descriptors PR: kern/164970 Approved by: cperciva (implicit) Modified: stable/8/lib/libc/sys/dup.2 stable/8/lib/libc/sys/fcntl.2 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/sys/dup.2 ============================================================================== --- stable/8/lib/libc/sys/dup.2 Thu May 3 16:31:21 2012 (r234966) +++ stable/8/lib/libc/sys/dup.2 Thu May 3 16:31:44 2012 (r234967) @@ -123,20 +123,27 @@ indicates the cause of the error. .Sh ERRORS The .Fn dup -and -.Fn dup2 -system calls fail if: +system call fails if: .Bl -tag -width Er .It Bq Er EBADF The .Fa oldd -or -.Fa newd argument is not a valid active descriptor .It Bq Er EMFILE Too many descriptors are active. .El +The +.Fn dup2 +system call fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa oldd +argument is not a valid active descriptor or the +.Fa newd +argument is negative or exceeds the maximum allowable descriptor number +.El .Sh SEE ALSO .Xr accept 2 , .Xr close 2 , Modified: stable/8/lib/libc/sys/fcntl.2 ============================================================================== --- stable/8/lib/libc/sys/fcntl.2 Thu May 3 16:31:21 2012 (r234966) +++ stable/8/lib/libc/sys/fcntl.2 Thu May 3 16:31:44 2012 (r234967) @@ -539,8 +539,6 @@ The argument .Fa cmd is .Dv F_DUPFD -or -.Dv F_DUP2FD and the maximum number of file descriptors permitted for the process are already in use, or no file descriptors greater than or equal to From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:32:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 464B3106567A; Thu, 3 May 2012 16:32:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C0E58FC22; Thu, 3 May 2012 16:32:09 +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 q43GW9Aa051969; Thu, 3 May 2012 16:32:09 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GW96h051966; Thu, 3 May 2012 16:32:09 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031632.q43GW96h051966@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:32:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234968 - stable/7/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:32:10 -0000 Author: eadler Date: Thu May 3 16:32:09 2012 New Revision: 234968 URL: http://svn.freebsd.org/changeset/base/234968 Log: MFC r234131: Return EBADF instead of EMFILE from dup2 when the second argument is outside the range of valid file descriptors PR: kern/164970 Approved by: cperciva (implicit) Modified: stable/7/lib/libc/sys/dup.2 stable/7/lib/libc/sys/fcntl.2 Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/sys/dup.2 ============================================================================== --- stable/7/lib/libc/sys/dup.2 Thu May 3 16:31:44 2012 (r234967) +++ stable/7/lib/libc/sys/dup.2 Thu May 3 16:32:09 2012 (r234968) @@ -123,20 +123,27 @@ indicates the cause of the error. .Sh ERRORS The .Fn dup -and -.Fn dup2 -system calls fail if: +system call fails if: .Bl -tag -width Er .It Bq Er EBADF The .Fa oldd -or -.Fa newd argument is not a valid active descriptor .It Bq Er EMFILE Too many descriptors are active. .El +The +.Fn dup2 +system call fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa oldd +argument is not a valid active descriptor or the +.Fa newd +argument is negative or exceeds the maximum allowable descriptor number +.El .Sh SEE ALSO .Xr accept 2 , .Xr close 2 , Modified: stable/7/lib/libc/sys/fcntl.2 ============================================================================== --- stable/7/lib/libc/sys/fcntl.2 Thu May 3 16:31:44 2012 (r234967) +++ stable/7/lib/libc/sys/fcntl.2 Thu May 3 16:32:09 2012 (r234968) @@ -523,8 +523,6 @@ The argument .Fa cmd is .Dv F_DUPFD -or -.Dv F_DUP2FD and the maximum number of file descriptors permitted for the process are already in use, or no file descriptors greater than or equal to From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:48:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 614841065674; Thu, 3 May 2012 16:48:49 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3213E8FC1B; Thu, 3 May 2012 16:48:49 +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 q43Gmnie052633; Thu, 3 May 2012 16:48:49 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GmmMg052628; Thu, 3 May 2012 16:48:48 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031648.q43GmmMg052628@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:48:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234969 - stable/9/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:48:49 -0000 Author: eadler Date: Thu May 3 16:48:48 2012 New Revision: 234969 URL: http://svn.freebsd.org/changeset/base/234969 Log: MFC r230108: Fix trivial typo Approved by: cperciva (implicit) Modified: stable/9/sys/net/bpf_buffer.c stable/9/sys/net/bpf_buffer.h stable/9/sys/net/bpf_zerocopy.c stable/9/sys/net/bpf_zerocopy.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/bpf_buffer.c ============================================================================== --- stable/9/sys/net/bpf_buffer.c Thu May 3 16:32:09 2012 (r234968) +++ stable/9/sys/net/bpf_buffer.c Thu May 3 16:48:48 2012 (r234969) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/9/sys/net/bpf_buffer.h ============================================================================== --- stable/9/sys/net/bpf_buffer.h Thu May 3 16:32:09 2012 (r234968) +++ stable/9/sys/net/bpf_buffer.h Thu May 3 16:48:48 2012 (r234969) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/9/sys/net/bpf_zerocopy.c ============================================================================== --- stable/9/sys/net/bpf_zerocopy.c Thu May 3 16:32:09 2012 (r234968) +++ stable/9/sys/net/bpf_zerocopy.c Thu May 3 16:48:48 2012 (r234969) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/9/sys/net/bpf_zerocopy.h ============================================================================== --- stable/9/sys/net/bpf_zerocopy.h Thu May 3 16:32:09 2012 (r234968) +++ stable/9/sys/net/bpf_zerocopy.h Thu May 3 16:48:48 2012 (r234969) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:49:28 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6AFFF1065672; Thu, 3 May 2012 16:49:28 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BF638FC1A; Thu, 3 May 2012 16:49:28 +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 q43GnSCt052692; Thu, 3 May 2012 16:49:28 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GnSio052687; Thu, 3 May 2012 16:49:28 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031649.q43GnSio052687@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 16:49:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234970 - stable/8/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:49:28 -0000 Author: eadler Date: Thu May 3 16:49:27 2012 New Revision: 234970 URL: http://svn.freebsd.org/changeset/base/234970 Log: MFC r230108: Fix trivial typo Approved by: cperciva (implicit) Modified: stable/8/sys/net/bpf_buffer.c stable/8/sys/net/bpf_buffer.h stable/8/sys/net/bpf_zerocopy.c stable/8/sys/net/bpf_zerocopy.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/net/bpf_buffer.c ============================================================================== --- stable/8/sys/net/bpf_buffer.c Thu May 3 16:48:48 2012 (r234969) +++ stable/8/sys/net/bpf_buffer.c Thu May 3 16:49:27 2012 (r234970) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/8/sys/net/bpf_buffer.h ============================================================================== --- stable/8/sys/net/bpf_buffer.h Thu May 3 16:48:48 2012 (r234969) +++ stable/8/sys/net/bpf_buffer.h Thu May 3 16:49:27 2012 (r234970) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/8/sys/net/bpf_zerocopy.c ============================================================================== --- stable/8/sys/net/bpf_zerocopy.c Thu May 3 16:48:48 2012 (r234969) +++ stable/8/sys/net/bpf_zerocopy.c Thu May 3 16:49:27 2012 (r234970) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without Modified: stable/8/sys/net/bpf_zerocopy.h ============================================================================== --- stable/8/sys/net/bpf_zerocopy.h Thu May 3 16:48:48 2012 (r234969) +++ stable/8/sys/net/bpf_zerocopy.h Thu May 3 16:49:27 2012 (r234970) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Seccuris Inc. * All rights reserved. * - * This sofware was developed by Robert N. M. Watson under contract to + * This software was developed by Robert N. M. Watson under contract to * Seccuris Inc. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:50:57 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 408151065689; Thu, 3 May 2012 16:50:57 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26DA38FC1C; Thu, 3 May 2012 16:50:57 +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 q43GovAi052794; Thu, 3 May 2012 16:50:57 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Gou9k052775; Thu, 3 May 2012 16:50:56 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205031650.q43Gou9k052775@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 16:50:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234971 - in vendor/llvm/dist: . autoconf cmake/modules docs docs/CommandGuide include/llvm include/llvm-c include/llvm/ADT include/llvm/CodeGen include/llvm/Config include/llvm/MC/MCPa... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:50:57 -0000 Author: dim Date: Thu May 3 16:50:55 2012 New Revision: 234971 URL: http://svn.freebsd.org/changeset/base/234971 Log: Vendor import of llvm release_31 branch r155985: http://llvm.org/svn/llvm-project/llvm/branches/release_31@155985 Added: vendor/llvm/dist/include/llvm/Support/Locale.h vendor/llvm/dist/include/llvm/Support/MDBuilder.h vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/JITRegistrar.h vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/ObjectImage.h vendor/llvm/dist/lib/Support/Locale.cpp vendor/llvm/dist/lib/Support/LocaleGeneric.inc vendor/llvm/dist/lib/Support/LocaleWindows.inc vendor/llvm/dist/lib/Support/LocaleXlocale.inc vendor/llvm/dist/lib/Target/Mips/Disassembler/ vendor/llvm/dist/lib/Target/Mips/Disassembler/CMakeLists.txt vendor/llvm/dist/lib/Target/Mips/Disassembler/LLVMBuild.txt vendor/llvm/dist/lib/Target/Mips/Disassembler/Makefile vendor/llvm/dist/lib/Target/Mips/Disassembler/MipsDisassembler.cpp vendor/llvm/dist/test/CodeGen/PowerPC/ppc-vaarg-agg.ll vendor/llvm/dist/test/CodeGen/X86/2012-04-26-sdglue.ll vendor/llvm/dist/test/CodeGen/X86/GC/cg-O0.ll vendor/llvm/dist/test/CodeGen/X86/avx2-vperm.ll (contents, props changed) vendor/llvm/dist/test/CodeGen/X86/dbg-declare.ll vendor/llvm/dist/test/MC/Disassembler/ARM/invalid-MRRC2-arm.txt vendor/llvm/dist/test/MC/Disassembler/ARM/unpredictable-AI1cmp-arm.txt vendor/llvm/dist/test/MC/Disassembler/ARM/unpredictable-MRRC2-arm.txt vendor/llvm/dist/test/MC/Disassembler/ARM/unpredictable-MRS-arm.txt vendor/llvm/dist/test/MC/Disassembler/ARM/unpredictable-swp-arm.txt vendor/llvm/dist/test/MC/Disassembler/Mips/ vendor/llvm/dist/test/MC/Disassembler/Mips/mips32.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips32_le.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips32r2.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips32r2_le.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips64.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips64_le.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips64r2.txt vendor/llvm/dist/test/MC/Disassembler/Mips/mips64r2_le.txt vendor/llvm/dist/test/MC/Mips/sym-offset.ll vendor/llvm/dist/test/Transforms/BBVectorize/no-ldstr-conn.ll vendor/llvm/dist/test/Transforms/BBVectorize/simple-ldstr-ptrs.ll vendor/llvm/dist/test/Transforms/BBVectorize/simple-sel.ll vendor/llvm/dist/test/Transforms/InstCombine/2012-04-30-SRem.ll vendor/llvm/dist/test/Transforms/LoopStrengthReduce/pr12691.ll vendor/llvm/dist/test/Transforms/LoopUnswitch/2012-04-30-LoopUnswitch-LPad-Crash.ll vendor/llvm/dist/test/Transforms/ObjCARC/escape.ll vendor/llvm/dist/test/Transforms/Reassociate/pr12245.ll vendor/llvm/dist/test/Transforms/SimplifyLibCalls/win-math.ll vendor/llvm/dist/test/Verifier/fpmath.ll vendor/llvm/dist/unittests/Support/MDBuilderTest.cpp Deleted: vendor/llvm/dist/include/llvm/Support/JSONParser.h vendor/llvm/dist/lib/Support/JSONParser.cpp vendor/llvm/dist/lib/Target/Hexagon/HexagonMCInst.h vendor/llvm/dist/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp vendor/llvm/dist/test/CodeGen/Generic/dbg-declare.ll vendor/llvm/dist/test/Verifier/fpaccuracy.ll vendor/llvm/dist/unittests/Support/JSONParserTest.cpp vendor/llvm/dist/utils/json-bench/ Modified: vendor/llvm/dist/CMakeLists.txt vendor/llvm/dist/CREDITS.TXT vendor/llvm/dist/autoconf/configure.ac vendor/llvm/dist/cmake/modules/HandleLLVMOptions.cmake vendor/llvm/dist/configure vendor/llvm/dist/docs/CodeGenerator.html vendor/llvm/dist/docs/CommandGuide/FileCheck.pod vendor/llvm/dist/docs/DebuggingJITedCode.html vendor/llvm/dist/docs/LLVMBuild.html vendor/llvm/dist/docs/LangRef.html vendor/llvm/dist/docs/ProgrammersManual.html vendor/llvm/dist/docs/ReleaseNotes.html vendor/llvm/dist/docs/TestingGuide.html vendor/llvm/dist/include/llvm-c/lto.h vendor/llvm/dist/include/llvm/ADT/SmallPtrSet.h vendor/llvm/dist/include/llvm/ADT/StringMap.h vendor/llvm/dist/include/llvm/CodeGen/DFAPacketizer.h vendor/llvm/dist/include/llvm/CodeGen/Passes.h vendor/llvm/dist/include/llvm/CodeGen/ScheduleDAGInstrs.h vendor/llvm/dist/include/llvm/CodeGen/SlotIndexes.h vendor/llvm/dist/include/llvm/Config/config.h.cmake vendor/llvm/dist/include/llvm/Config/config.h.in vendor/llvm/dist/include/llvm/IntrinsicsX86.td vendor/llvm/dist/include/llvm/LLVMContext.h vendor/llvm/dist/include/llvm/MC/MCParser/AsmLexer.h vendor/llvm/dist/include/llvm/MC/MCParser/MCAsmLexer.h vendor/llvm/dist/include/llvm/Object/ELF.h vendor/llvm/dist/include/llvm/Operator.h vendor/llvm/dist/include/llvm/Support/IRBuilder.h vendor/llvm/dist/include/llvm/Support/Process.h vendor/llvm/dist/include/llvm/Support/SourceMgr.h vendor/llvm/dist/include/llvm/Support/YAMLParser.h vendor/llvm/dist/include/llvm/Support/raw_ostream.h vendor/llvm/dist/include/llvm/TableGen/Error.h vendor/llvm/dist/include/llvm/TableGen/Record.h vendor/llvm/dist/include/llvm/Target/TargetLibraryInfo.h vendor/llvm/dist/include/llvm/Target/TargetRegisterInfo.h vendor/llvm/dist/include/llvm/Transforms/Utils/BasicBlockUtils.h vendor/llvm/dist/include/llvm/Transforms/Vectorize.h vendor/llvm/dist/lib/Analysis/ConstantFolding.cpp vendor/llvm/dist/lib/Analysis/ScalarEvolution.cpp vendor/llvm/dist/lib/Analysis/ValueTracking.cpp vendor/llvm/dist/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp vendor/llvm/dist/lib/CodeGen/AsmPrinter/DwarfAccelTable.h vendor/llvm/dist/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp vendor/llvm/dist/lib/CodeGen/DFAPacketizer.cpp vendor/llvm/dist/lib/CodeGen/LiveIntervalAnalysis.cpp vendor/llvm/dist/lib/CodeGen/MachineBasicBlock.cpp vendor/llvm/dist/lib/CodeGen/MachineBlockPlacement.cpp vendor/llvm/dist/lib/CodeGen/Passes.cpp vendor/llvm/dist/lib/CodeGen/ScheduleDAGInstrs.cpp vendor/llvm/dist/lib/CodeGen/SelectionDAG/DAGCombiner.cpp vendor/llvm/dist/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp vendor/llvm/dist/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp vendor/llvm/dist/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp vendor/llvm/dist/lib/CodeGen/SelectionDAG/TargetLowering.cpp vendor/llvm/dist/lib/CodeGen/SlotIndexes.cpp vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h vendor/llvm/dist/lib/MC/MCParser/AsmParser.cpp vendor/llvm/dist/lib/Object/ELFObjectFile.cpp vendor/llvm/dist/lib/Support/CMakeLists.txt vendor/llvm/dist/lib/Support/SmallPtrSet.cpp vendor/llvm/dist/lib/Support/SourceMgr.cpp vendor/llvm/dist/lib/Support/Unix/Process.inc vendor/llvm/dist/lib/Support/Windows/Process.inc vendor/llvm/dist/lib/Support/YAMLParser.cpp vendor/llvm/dist/lib/Support/raw_ostream.cpp vendor/llvm/dist/lib/TableGen/Error.cpp vendor/llvm/dist/lib/Target/ARM/ARMCallingConv.td vendor/llvm/dist/lib/Target/ARM/ARMInstrFormats.td vendor/llvm/dist/lib/Target/ARM/ARMInstrInfo.td vendor/llvm/dist/lib/Target/ARM/ARMInstrNEON.td vendor/llvm/dist/lib/Target/ARM/ARMTargetMachine.cpp vendor/llvm/dist/lib/Target/ARM/AsmParser/ARMAsmParser.cpp vendor/llvm/dist/lib/Target/ARM/Disassembler/ARMDisassembler.cpp vendor/llvm/dist/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp vendor/llvm/dist/lib/Target/CellSPU/SPUCallingConv.td vendor/llvm/dist/lib/Target/CellSPU/SPUTargetMachine.cpp vendor/llvm/dist/lib/Target/Hexagon/CMakeLists.txt vendor/llvm/dist/lib/Target/Hexagon/Hexagon.h vendor/llvm/dist/lib/Target/Hexagon/HexagonAsmPrinter.cpp vendor/llvm/dist/lib/Target/Hexagon/HexagonISelLowering.cpp vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrFormats.td vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrFormatsV4.td vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrInfo.cpp vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrInfo.h vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrInfo.td vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrInfoV3.td vendor/llvm/dist/lib/Target/Hexagon/HexagonInstrInfoV4.td vendor/llvm/dist/lib/Target/Hexagon/HexagonMCInstLower.cpp vendor/llvm/dist/lib/Target/Hexagon/HexagonSchedule.td vendor/llvm/dist/lib/Target/Hexagon/HexagonScheduleV4.td vendor/llvm/dist/lib/Target/Hexagon/HexagonTargetMachine.cpp vendor/llvm/dist/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp vendor/llvm/dist/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.h vendor/llvm/dist/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt vendor/llvm/dist/lib/Target/Hexagon/MCTargetDesc/HexagonBaseInfo.h vendor/llvm/dist/lib/Target/MBlaze/MBlazeCallingConv.td vendor/llvm/dist/lib/Target/MBlaze/MBlazeTargetMachine.cpp vendor/llvm/dist/lib/Target/MSP430/MSP430TargetMachine.cpp vendor/llvm/dist/lib/Target/Mips/CMakeLists.txt vendor/llvm/dist/lib/Target/Mips/LLVMBuild.txt vendor/llvm/dist/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp vendor/llvm/dist/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp vendor/llvm/dist/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp vendor/llvm/dist/lib/Target/Mips/Makefile vendor/llvm/dist/lib/Target/Mips/Mips64InstrInfo.td vendor/llvm/dist/lib/Target/Mips/MipsCondMov.td vendor/llvm/dist/lib/Target/Mips/MipsISelLowering.cpp vendor/llvm/dist/lib/Target/Mips/MipsInstrFPU.td vendor/llvm/dist/lib/Target/Mips/MipsInstrFormats.td vendor/llvm/dist/lib/Target/Mips/MipsInstrInfo.td vendor/llvm/dist/lib/Target/Mips/MipsTargetMachine.cpp vendor/llvm/dist/lib/Target/PTX/PTXTargetMachine.cpp vendor/llvm/dist/lib/Target/PowerPC/PPCCallingConv.td vendor/llvm/dist/lib/Target/PowerPC/PPCTargetMachine.cpp vendor/llvm/dist/lib/Target/Sparc/SparcTargetMachine.cpp vendor/llvm/dist/lib/Target/TargetLibraryInfo.cpp vendor/llvm/dist/lib/Target/X86/Utils/X86ShuffleDecode.cpp vendor/llvm/dist/lib/Target/X86/X86ISelLowering.cpp vendor/llvm/dist/lib/Target/X86/X86ISelLowering.h vendor/llvm/dist/lib/Target/X86/X86InstrFragmentsSIMD.td vendor/llvm/dist/lib/Target/X86/X86InstrInfo.cpp vendor/llvm/dist/lib/Target/X86/X86InstrSSE.td vendor/llvm/dist/lib/Target/X86/X86Subtarget.cpp vendor/llvm/dist/lib/Target/X86/X86TargetMachine.cpp vendor/llvm/dist/lib/Target/XCore/XCoreTargetMachine.cpp vendor/llvm/dist/lib/Transforms/IPO/Internalize.cpp vendor/llvm/dist/lib/Transforms/IPO/PassManagerBuilder.cpp vendor/llvm/dist/lib/Transforms/Scalar/LoopStrengthReduce.cpp vendor/llvm/dist/lib/Transforms/Scalar/LoopUnswitch.cpp vendor/llvm/dist/lib/Transforms/Scalar/ObjCARC.cpp vendor/llvm/dist/lib/Transforms/Scalar/Reassociate.cpp vendor/llvm/dist/lib/Transforms/Scalar/SimplifyLibCalls.cpp vendor/llvm/dist/lib/Transforms/Utils/BreakCriticalEdges.cpp vendor/llvm/dist/lib/Transforms/Vectorize/BBVectorize.cpp vendor/llvm/dist/lib/VMCore/AutoUpgrade.cpp vendor/llvm/dist/lib/VMCore/Instructions.cpp vendor/llvm/dist/lib/VMCore/LLVMContext.cpp vendor/llvm/dist/lib/VMCore/Module.cpp vendor/llvm/dist/lib/VMCore/Verifier.cpp vendor/llvm/dist/test/Analysis/ScalarEvolution/nsw-offset.ll vendor/llvm/dist/test/Analysis/ScalarEvolution/nsw.ll vendor/llvm/dist/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll vendor/llvm/dist/test/CodeGen/ARM/fusedMAC.ll vendor/llvm/dist/test/CodeGen/ARM/ldr_post.ll vendor/llvm/dist/test/CodeGen/ARM/ldr_pre.ll vendor/llvm/dist/test/CodeGen/ARM/tail-opts.ll vendor/llvm/dist/test/CodeGen/ARM/vector-extend-narrow.ll vendor/llvm/dist/test/CodeGen/ARM/widen-vmovs.ll vendor/llvm/dist/test/CodeGen/CellSPU/2009-01-01-BrCond.ll vendor/llvm/dist/test/CodeGen/Mips/analyzebranch.ll vendor/llvm/dist/test/CodeGen/Mips/eh.ll vendor/llvm/dist/test/CodeGen/Mips/fpbr.ll vendor/llvm/dist/test/CodeGen/Thumb2/thumb2-branch.ll vendor/llvm/dist/test/CodeGen/Thumb2/thumb2-ifcvt2.ll vendor/llvm/dist/test/CodeGen/Thumb2/thumb2-jtb.ll vendor/llvm/dist/test/CodeGen/X86/2006-10-19-SwitchUnnecessaryBranching.ll vendor/llvm/dist/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll vendor/llvm/dist/test/CodeGen/X86/2010-08-04-MaskedSignedCompare.ll vendor/llvm/dist/test/CodeGen/X86/2010-11-18-SelectOfExtload.ll vendor/llvm/dist/test/CodeGen/X86/2011-09-14-valcoalesce.ll vendor/llvm/dist/test/CodeGen/X86/atom-sched.ll vendor/llvm/dist/test/CodeGen/X86/atomic_op.ll vendor/llvm/dist/test/CodeGen/X86/avx2-intrinsics-x86.ll vendor/llvm/dist/test/CodeGen/X86/block-placement.ll vendor/llvm/dist/test/CodeGen/X86/br-fold.ll vendor/llvm/dist/test/CodeGen/X86/call-push.ll vendor/llvm/dist/test/CodeGen/X86/licm-dominance.ll vendor/llvm/dist/test/CodeGen/X86/loop-blocks.ll vendor/llvm/dist/test/CodeGen/X86/machine-cp.ll vendor/llvm/dist/test/CodeGen/X86/postra-licm.ll vendor/llvm/dist/test/CodeGen/X86/pr2659.ll vendor/llvm/dist/test/CodeGen/X86/select.ll vendor/llvm/dist/test/CodeGen/X86/sibcall.ll vendor/llvm/dist/test/CodeGen/X86/sink-hoist.ll vendor/llvm/dist/test/CodeGen/X86/smul-with-overflow.ll vendor/llvm/dist/test/CodeGen/X86/sse41-blend.ll vendor/llvm/dist/test/CodeGen/X86/sub-with-overflow.ll vendor/llvm/dist/test/CodeGen/X86/switch-bt.ll vendor/llvm/dist/test/CodeGen/X86/tail-opts.ll vendor/llvm/dist/test/CodeGen/X86/uint64-to-float.ll vendor/llvm/dist/test/CodeGen/X86/vec_shuffle-20.ll vendor/llvm/dist/test/CodeGen/X86/xor-icmp.ll vendor/llvm/dist/test/CodeGen/XCore/ashr.ll vendor/llvm/dist/test/MC/ARM/neon-add-encoding.s vendor/llvm/dist/test/MC/ARM/neon-shift-encoding.s vendor/llvm/dist/test/MC/ARM/neon-sub-encoding.s vendor/llvm/dist/test/MC/AsmParser/macro-args.s vendor/llvm/dist/test/MC/Disassembler/ARM/arm-tests.txt vendor/llvm/dist/test/MC/Disassembler/ARM/neon.txt vendor/llvm/dist/test/MC/Disassembler/ARM/neont2.txt vendor/llvm/dist/test/MC/Disassembler/X86/intel-syntax.txt vendor/llvm/dist/test/MC/Mips/elf-bigendian.ll vendor/llvm/dist/test/Transforms/GlobalOpt/constantfold-initializers.ll vendor/llvm/dist/test/Transforms/InstCombine/apint-shift.ll vendor/llvm/dist/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll vendor/llvm/dist/test/Transforms/SimplifyLibCalls/floor.ll vendor/llvm/dist/test/lit.cfg vendor/llvm/dist/tools/llc/llc.cpp vendor/llvm/dist/tools/lli/lli.cpp vendor/llvm/dist/tools/llvm-mc/Disassembler.cpp vendor/llvm/dist/tools/llvm-mc/Disassembler.h vendor/llvm/dist/tools/llvm-mc/llvm-mc.cpp vendor/llvm/dist/tools/llvm-shlib/Makefile vendor/llvm/dist/tools/llvm-stress/llvm-stress.cpp vendor/llvm/dist/tools/lto/LTOCodeGenerator.cpp vendor/llvm/dist/tools/lto/LTOCodeGenerator.h vendor/llvm/dist/tools/lto/lto.cpp vendor/llvm/dist/tools/lto/lto.exports vendor/llvm/dist/tools/opt/opt.cpp vendor/llvm/dist/unittests/CMakeLists.txt vendor/llvm/dist/unittests/VMCore/InstructionsTest.cpp vendor/llvm/dist/utils/Makefile vendor/llvm/dist/utils/TableGen/AsmMatcherEmitter.cpp vendor/llvm/dist/utils/TableGen/AsmWriterEmitter.cpp vendor/llvm/dist/utils/TableGen/CodeGenDAGPatterns.cpp vendor/llvm/dist/utils/TableGen/CodeGenRegisters.cpp vendor/llvm/dist/utils/TableGen/EDEmitter.cpp vendor/llvm/dist/utils/TableGen/RegisterInfoEmitter.cpp vendor/llvm/dist/utils/buildit/build_llvm vendor/llvm/dist/utils/release/findRegressions-nightly.py vendor/llvm/dist/utils/release/findRegressions-simple.py vendor/llvm/dist/utils/release/tag.sh vendor/llvm/dist/utils/release/test-release.sh Modified: vendor/llvm/dist/CMakeLists.txt ============================================================================== --- vendor/llvm/dist/CMakeLists.txt Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/CMakeLists.txt Thu May 3 16:50:55 2012 (r234971) @@ -213,15 +213,6 @@ if( WIN32 AND NOT CYGWIN ) set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") endif() -# On Win32 using MS tools, provide an option to set the number of parallel jobs -# to use. -if( MSVC_IDE AND ( MSVC90 OR MSVC10 ) ) - # Only Visual Studio 2008 and 2010 officially supports /MP. Visual Studio - # 2005 supports it but it is experimental. - set(LLVM_COMPILER_JOBS "0" CACHE STRING - "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") -endif() - # Define options to control the inclusion and default build behavior for # components which may not strictly be necessary (tools, runtime, examples, and # tests). @@ -396,7 +387,6 @@ add_subdirectory(utils/FileUpdate) add_subdirectory(utils/count) add_subdirectory(utils/not) add_subdirectory(utils/llvm-lit) -add_subdirectory(utils/json-bench) add_subdirectory(utils/yaml-bench) add_subdirectory(projects) Modified: vendor/llvm/dist/CREDITS.TXT ============================================================================== --- vendor/llvm/dist/CREDITS.TXT Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/CREDITS.TXT Thu May 3 16:50:55 2012 (r234971) @@ -50,9 +50,15 @@ N: Cameron Buschardt E: buschard@uiuc.edu D: The `mem2reg' pass - promotes values stored in memory to registers +N: Brendon Cahoon +E: bcahoon@codeaurora.org +D: Loop unrolling with run-time trip counts. + N: Chandler Carruth E: chandlerc@gmail.com -D: LinkTimeOptimizer for Linux, via binutils integration, and C API +D: Hashing algorithms and interfaces +D: Inline cost analysis +D: Machine block placement pass N: Casey Carter E: ccarter@uiuc.edu @@ -210,6 +216,10 @@ N: Benjamin Kramer E: benny.kra@gmail.com D: Miscellaneous bug fixes +N: Sundeep Kushwaha +E: sundeepk@codeaurora.org +D: Implemented DFA-based target independent VLIW packetizer + N: Christopher Lamb E: christopher.lamb@gmail.com D: aligned load/store support, parts of noalias and restrict support @@ -245,6 +255,10 @@ N: Nick Lewycky E: nicholas@mxc.ca D: PredicateSimplifier pass +N: Tony Linthicum, et. al. +E: tlinth@codeaurora.org +D: Backend for Qualcomm's Hexagon VLIW processor. + N: Bruno Cardoso Lopes E: bruno.cardoso@gmail.com W: http://www.brunocardoso.org @@ -271,6 +285,10 @@ N: Scott Michel E: scottm@aero.org D: Added STI Cell SPU backend. +N: Kai Nacke +E: kai@redstar.de +D: Support for implicit TLS model used with MS VC runtime + N: Takumi Nakamura E: geek4civic@gmail.com E: chapuni@hf.rim.or.jp Modified: vendor/llvm/dist/autoconf/configure.ac ============================================================================== --- vendor/llvm/dist/autoconf/configure.ac Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/autoconf/configure.ac Thu May 3 16:50:55 2012 (r234971) @@ -838,6 +838,13 @@ AC_ARG_WITH(gcc-toolchain, AC_DEFINE_UNQUOTED(GCC_INSTALL_PREFIX,"$withval", [Directory where gcc is installed.]) +AC_ARG_WITH(default-sysroot, + AS_HELP_STRING([--with-default-sysroot], + [Add --sysroot= to all compiler invocations.]),, + withval="") +AC_DEFINE_UNQUOTED(DEFAULT_SYSROOT,"$withval", + [Default to all compiler invocations for --sysroot=.]) + dnl Allow linking of LLVM with GPLv3 binutils code. AC_ARG_WITH(binutils-include, AS_HELP_STRING([--with-binutils-include], Modified: vendor/llvm/dist/cmake/modules/HandleLLVMOptions.cmake ============================================================================== --- vendor/llvm/dist/cmake/modules/HandleLLVMOptions.cmake Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/cmake/modules/HandleLLVMOptions.cmake Thu May 3 16:50:55 2012 (r234971) @@ -110,9 +110,9 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT endif( LLVM_BUILD_32_BITS ) endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) -if( MSVC_IDE AND ( MSVC90 OR MSVC10 ) ) - # Only Visual Studio 2008 and 2010 officially supports /MP. - # Visual Studio 2005 do support it but it's experimental there. +# On Win32 using MS tools, provide an option to set the number of parallel jobs +# to use. +if( MSVC_IDE ) set(LLVM_COMPILER_JOBS "0" CACHE STRING "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) Modified: vendor/llvm/dist/configure ============================================================================== --- vendor/llvm/dist/configure Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/configure Thu May 3 16:50:55 2012 (r234971) @@ -1442,6 +1442,7 @@ Optional Packages: --with-c-include-dirs Colon separated list of directories clang will search for headers --with-gcc-toolchain Directory where gcc is installed. + --with-default-sysroot Add --sysroot= to all compiler invocations. --with-binutils-include Specify path to binutils/include/ containing plugin-api.h file for gold plugin. --with-bug-report-url Specify the URL where bug reports should be @@ -3802,7 +3803,7 @@ else llvm_cv_target_os_type="Darwin" ;; *-*-minix*) llvm_cv_target_os_type="Minix" ;; - *-*-freebsd*| *-*-kfreebsd-gnu) + *-*-freebsd* | *-*-kfreebsd-gnu) llvm_cv_target_os_type="FreeBSD" ;; *-*-openbsd*) llvm_cv_target_os_type="OpenBSD" ;; @@ -5583,6 +5584,20 @@ _ACEOF +# Check whether --with-default-sysroot was given. +if test "${with_default_sysroot+set}" = set; then + withval=$with_default_sysroot; +else + withval="" +fi + + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_SYSROOT "$withval" +_ACEOF + + + # Check whether --with-binutils-include was given. if test "${with_binutils_include+set}" = set; then withval=$with_binutils_include; @@ -10386,7 +10401,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <GenRegisterNames.inc file for that architecture. For instance, by - inspecting lib/Target/X86/X86GenRegisterNames.inc we see that the - 32-bit register EAX is denoted by 15, and the MMX register - MM0 is mapped to 48.

+ inspecting lib/Target/X86/X86GenRegisterInfo.inc we see that the + 32-bit register EAX is denoted by 43, and the MMX register + MM0 is mapped to 65.

Some architectures contain registers that share the same physical location. A notable example is the X86 platform. For instance, in the X86 architecture, @@ -1627,7 +1627,7 @@ def : Pat<(i32 imm:$imm), bits. These physical registers are marked as aliased in LLVM. Given a particular architecture, you can check which registers are aliased by inspecting its RegisterInfo.td file. Moreover, the method - TargetRegisterInfo::getAliasSet(p_reg) returns an array containing + MCRegisterInfo::getAliasSet(p_reg) returns an array containing all the physical registers aliased to the register p_reg.

Physical registers, in LLVM, are grouped in Register Classes. @@ -3182,7 +3182,7 @@ MOVSX32rm16 -> movsx, 32-bit register Chris Lattner
The LLVM Compiler Infrastructure
- Last modified: $Date: 2012-03-27 13:25:16 +0200 (Tue, 27 Mar 2012) $ + Last modified: $Date: 2012-04-15 22:22:36 +0200 (Sun, 15 Apr 2012) $ Modified: vendor/llvm/dist/docs/CommandGuide/FileCheck.pod ============================================================================== --- vendor/llvm/dist/docs/CommandGuide/FileCheck.pod Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/CommandGuide/FileCheck.pod Thu May 3 16:50:55 2012 (r234971) @@ -67,20 +67,20 @@ This syntax says to pipe the current fil llc, then pipe the output of llc into FileCheck. This means that FileCheck will be verifying its standard input (the llc output) against the filename argument specified (the original .ll file specified by "%s"). To see how this works, -lets look at the rest of the .ll file (after the RUN line): +let's look at the rest of the .ll file (after the RUN line): define void @sub1(i32* %p, i32 %v) { entry: - ; CHECK: sub1: - ; CHECK: subl + ; CHECK: sub1: + ; CHECK: subl %0 = tail call i32 @llvm.atomic.load.sub.i32.p0i32(i32* %p, i32 %v) ret void } define void @inc4(i64* %p) { entry: - ; CHECK: inc4: - ; CHECK: incq + ; CHECK: inc4: + ; CHECK: incq %0 = tail call i64 @llvm.atomic.load.add.i64.p0i64(i64* %p, i64 1) ret void } @@ -111,18 +111,18 @@ driven from one .ll file. This is usefu testing different architectural variants with llc. Here's a simple example: ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin9 -mattr=sse41 \ - ; RUN: | FileCheck %s -check-prefix=X32 + ; RUN: | FileCheck %s -check-prefix=X32> ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin9 -mattr=sse41 \ - ; RUN: | FileCheck %s -check-prefix=X64 + ; RUN: | FileCheck %s -check-prefix=X64> define <4 x i32> @pinsrd_1(i32 %s, <4 x i32> %tmp) nounwind { %tmp1 = insertelement <4 x i32>; %tmp, i32 %s, i32 1 ret <4 x i32> %tmp1 - ; X32: pinsrd_1: - ; X32: pinsrd $1, 4(%esp), %xmm0 + ; X32: pinsrd_1: + ; X32: pinsrd $1, 4(%esp), %xmm0 - ; X64: pinsrd_1: - ; X64: pinsrd $1, %edi, %xmm0 + ; X64: pinsrd_1: + ; X64: pinsrd $1, %edi, %xmm0 } In this case, we're testing that we get the expected code generation with @@ -147,13 +147,13 @@ example, something like this works as yo store <2 x double> %tmp9, <2 x double>* %r, align 16 ret void - ; CHECK: t2: - ; CHECK: movl 8(%esp), %eax - ; CHECK-NEXT: movapd (%eax), %xmm0 - ; CHECK-NEXT: movhpd 12(%esp), %xmm0 - ; CHECK-NEXT: movl 4(%esp), %eax - ; CHECK-NEXT: movapd %xmm0, (%eax) - ; CHECK-NEXT: ret + ; CHECK: t2: + ; CHECK: movl 8(%esp), %eax + ; CHECK-NEXT: movapd (%eax), %xmm0 + ; CHECK-NEXT: movhpd 12(%esp), %xmm0 + ; CHECK-NEXT: movl 4(%esp), %eax + ; CHECK-NEXT: movapd %xmm0, (%eax) + ; CHECK-NEXT: ret } CHECK-NEXT: directives reject the input unless there is exactly one newline @@ -177,9 +177,9 @@ can be used: %A = load i8* %P3 ret i8 %A - ; CHECK: @coerce_offset0 - ; CHECK-NOT: load - ; CHECK: ret i8 + ; CHECK: @coerce_offset0 + ; CHECK-NOT: load + ; CHECK: ret i8 } @@ -195,7 +195,7 @@ matching for a majority of what we do, F mixing and matching fixed string matching with regular expressions. This allows you to write things like this: - ; CHECK: movhpd {{[0-9]+}}(%esp), {{%xmm[0-7]}} + ; CHECK: movhpd {{[0-9]+}}(%esp), {{%xmm[0-7]}} In this case, any offset from the ESP register will be allowed, and any xmm register will be allowed. @@ -217,20 +217,20 @@ allows named variables to be defined and simple example: ; CHECK: test5: - ; CHECK: notw [[REGISTER:%[a-z]+]] - ; CHECK: andw {{.*}}[[REGISTER]] + ; CHECK: notw [[REGISTER:%[a-z]+]] + ; CHECK: andw {{.*}}[REGISTER]] -The first check line matches a regex (%[a-z]+) and captures it into -the variables "REGISTER". The second line verifies that whatever is in REGISTER +The first check line matches a regex (B<%[a-z]+>) and captures it into +the variable "REGISTER". The second line verifies that whatever is in REGISTER occurs later in the file after an "andw". FileCheck variable references are -always contained in [[ ]] pairs, are named, and their names can be -formed with the regex "[a-zA-Z_][a-zA-Z0-9_]*". If a colon follows the +always contained in B<[[ ]]> pairs, are named, and their names can be +formed with the regex "B<[a-zA-Z_][a-zA-Z0-9_]*>". If a colon follows the name, then it is a definition of the variable, if not, it is a use. FileCheck variables can be defined multiple times, and uses always get the latest value. Note that variables are all read at the start of a "CHECK" line and are all defined at the end. This means that if you have something like -"CHECK: [[XYZ:.*]]x[[XYZ]]" that the check line will read the previous +"B", the check line will read the previous value of the XYZ variable and define a new one after the match is performed. If you need to do something like this you can probably take advantage of the fact that FileCheck is not actually line-oriented when it matches, this allows you to Modified: vendor/llvm/dist/docs/DebuggingJITedCode.html ============================================================================== --- vendor/llvm/dist/docs/DebuggingJITedCode.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/DebuggingJITedCode.html Thu May 3 16:50:55 2012 (r234971) @@ -8,135 +8,165 @@ -

Debugging JITed Code With GDB

+

Debugging JIT-ed Code With GDB

    -
  1. Example usage
  2. Background
  3. +
  4. GDB Version
  5. +
  6. Debugging MCJIT-ed code
  7. +
-
Written by Reid Kleckner
+
Written by Reid Kleckner and Eli Bendersky
-

Example usage

+

Background

-

In order to debug code JITed by LLVM, you need GDB 7.0 or newer, which is +

Without special runtime support, debugging dynamically generated code with +GDB (as well as most debuggers) can be quite painful. Debuggers generally read +debug information from the object file of the code, but for JITed code, there is +no such file to look for. +

+ +

In order to communicate the necessary debug info to GDB, an interface for +registering JITed code with debuggers has been designed and implemented for +GDB and LLVM MCJIT. At a high level, whenever MCJIT generates new machine code, +it does so in an in-memory object file that contains the debug information in +DWARF format. MCJIT then adds this in-memory object file to a global list of +dynamically generated object files and calls a special function +(__jit_debug_register_code) marked noinline that GDB knows about. When +GDB attaches to a process, it puts a breakpoint in this function and loads all +of the object files in the global list. When MCJIT calls the registration +function, GDB catches the breakpoint signal, loads the new object file from +the inferior's memory, and resumes the execution. In this way, GDB can get the +necessary debug information. +

+
+ + +

GDB Version

+ + +

In order to debug code JIT-ed by LLVM, you need GDB 7.0 or newer, which is available on most modern distributions of Linux. The version of GDB that Apple ships with XCode has been frozen at 6.3 for a while. LLDB may be a better -option for debugging JITed code on Mac OS X. +option for debugging JIT-ed code on Mac OS X.

-

Consider debugging the following code compiled with clang and run through -lli: -

-
-#include <stdio.h>
+
+

Debugging MCJIT-ed code

+ +
-void foo() { - printf("%d\n", *(int*)NULL); // Crash here -} - -void bar() { - foo(); -} - -void baz() { - bar(); -} - -int main(int argc, char **argv) { - baz(); -} -
+

The emerging MCJIT component of LLVM allows full debugging of JIT-ed code with +GDB. This is due to MCJIT's ability to use the MC emitter to provide full +DWARF debugging information to GDB.

-

Here are the commands to run that application under GDB and print the stack -trace at the crash: -

+

Note that lli has to be passed the -use-mcjit flag to JIT the code +with MCJIT instead of the old JIT.

-
-# Compile foo.c to bitcode.  You can use either clang or llvm-gcc with this
-# command line.  Both require -fexceptions, or the calls are all marked
-# 'nounwind' which disables DWARF exception handling info.  Custom frontends
-# should avoid adding this attribute to JITed code, since it interferes with
-# DWARF CFA generation at the moment.
-$ clang foo.c -fexceptions -emit-llvm -c -o foo.bc
-
-# Run foo.bc under lli with -jit-emit-debug.  If you built lli in debug mode,
-# -jit-emit-debug defaults to true.
-$ $GDB_INSTALL/gdb --args lli -jit-emit-debug foo.bc
-...
-
-# Run the code.
-(gdb) run
-Starting program: /tmp/gdb/lli -jit-emit-debug foo.bc
-[Thread debugging using libthread_db enabled]
+

Example

-Program received signal SIGSEGV, Segmentation fault. -0x00007ffff7f55164 in foo () +
-# Print the backtrace, this time with symbols instead of ??. -(gdb) bt -#0 0x00007ffff7f55164 in foo () -#1 0x00007ffff7f550f9 in bar () -#2 0x00007ffff7f55099 in baz () -#3 0x00007ffff7f5502a in main () -#4 0x00000000007c0225 in llvm::JIT::runFunction(llvm::Function*, - std::vector<llvm::GenericValue, - std::allocator<llvm::GenericValue> > const&) () -#5 0x00000000007d6d98 in - llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, - std::vector<std::string, - std::allocator<std::string> > const&, char const* const*) () -#6 0x00000000004dab76 in main () +

Consider the following C code (with line numbers added to make the example +easier to follow):

+ +
+1   int compute_factorial(int n)
+2   {
+3       if (n <= 1)
+4           return 1;
+5
+6       int f = n;
+7       while (--n > 1) 
+8           f *= n;
+9       return f;
+10  }
+11
+12
+13  int main(int argc, char** argv)
+14  {
+15      if (argc < 2)
+16          return -1;
+17      char firstletter = argv[1][0];
+18      int result = compute_factorial(firstletter - '0');
+19  
+20      // Returned result is clipped at 255...
+21      return result;
+22  }
 
-

As you can see, GDB can correctly unwind the stack and has the appropriate -function names. +

Here is a sample command line session that shows how to build and run this +code via lli inside GDB:

-
- -

Background

- -
+
+$ $BINPATH/clang -cc1 -O0 -g -emit-llvm showdebug.c
+$ gdb --quiet --args $BINPATH/lli -use-mcjit showdebug.ll 5
+Reading symbols from $BINPATH/lli...done.
+(gdb) b showdebug.c:6
+No source file named showdebug.c.
+Make breakpoint pending on future shared library load? (y or [n]) y
+Breakpoint 1 (showdebug.c:6) pending.
+(gdb) r
+Starting program: $BINPATH/lli -use-mcjit showdebug.ll 5
+[Thread debugging using libthread_db enabled]
 
-

Without special runtime support, debugging dynamically generated code with -GDB (as well as most debuggers) can be quite painful. Debuggers generally read -debug information from the object file of the code, but for JITed code, there is -no such file to look for. -

+Breakpoint 1, compute_factorial (n=5) at showdebug.c:6 +6 int f = n; +(gdb) p n +$1 = 5 +(gdb) p f +$2 = 0 +(gdb) n +7 while (--n > 1) +(gdb) p f +$3 = 5 +(gdb) b showdebug.c:9 +Breakpoint 2 at 0x7ffff7ed404c: file showdebug.c, line 9. +(gdb) c +Continuing. + +Breakpoint 2, compute_factorial (n=1) at showdebug.c:9 +9 return f; +(gdb) p f +$4 = 120 +(gdb) bt +#0 compute_factorial (n=1) at showdebug.c:9 +#1 0x00007ffff7ed40a9 in main (argc=2, argv=0x16677e0) at showdebug.c:18 +#2 0x3500000001652748 in ?? () +#3 0x00000000016677e0 in ?? () +#4 0x0000000000000002 in ?? () +#5 0x0000000000d953b3 in llvm::MCJIT::runFunction (this=0x16151f0, F=0x1603020, ArgValues=...) at /home/ebenders_test/llvm_svn_rw/lib/ExecutionEngine/MCJIT/MCJIT.cpp:161 +#6 0x0000000000dc8872 in llvm::ExecutionEngine::runFunctionAsMain (this=0x16151f0, Fn=0x1603020, argv=..., envp=0x7fffffffe040) + at /home/ebenders_test/llvm_svn_rw/lib/ExecutionEngine/ExecutionEngine.cpp:397 +#7 0x000000000059c583 in main (argc=4, argv=0x7fffffffe018, envp=0x7fffffffe040) at /home/ebenders_test/llvm_svn_rw/tools/lli/lli.cpp:324 +(gdb) finish +Run till exit from #0 compute_factorial (n=1) at showdebug.c:9 +0x00007ffff7ed40a9 in main (argc=2, argv=0x16677e0) at showdebug.c:18 +18 int result = compute_factorial(firstletter - '0'); +Value returned is $5 = 120 +(gdb) p result +$6 = 23406408 +(gdb) n +21 return result; +(gdb) p result +$7 = 120 +(gdb) c +Continuing. -

Depending on the architecture, this can impact the debugging experience in -different ways. For example, on most 32-bit x86 architectures, you can simply -compile with -fno-omit-frame-pointer for GCC and -disable-fp-elim for LLVM. -When GDB creates a backtrace, it can properly unwind the stack, but the stack -frames owned by JITed code have ??'s instead of the appropriate symbol name. -However, on Linux x86_64 in particular, GDB relies on the DWARF call frame -address (CFA) debug information to unwind the stack, so even if you compile -your program to leave the frame pointer untouched, GDB will usually be unable -to unwind the stack past any JITed code stack frames. -

+Program exited with code 0170. +(gdb) -

In order to communicate the necessary debug info to GDB, an interface for -registering JITed code with debuggers has been designed and implemented for -GDB and LLVM. At a high level, whenever LLVM generates new machine code, it -also generates an object file in memory containing the debug information. LLVM -then adds the object file to the global list of object files and calls a special -function (__jit_debug_register_code) marked noinline that GDB knows about. When -GDB attaches to a process, it puts a breakpoint in this function and loads all -of the object files in the global list. When LLVM calls the registration -function, GDB catches the breakpoint signal, loads the new object file from -LLVM's memory, and resumes the execution. In this way, GDB can get the -necessary debug information. -

+
-

At the time of this writing, LLVM only supports architectures that use ELF -object files and it only generates symbols and DWARF CFA information. However, -it would be easy to add more information to the object file, so we don't need to -coordinate with GDB to get better debug information. -

+ +
@@ -145,9 +175,10 @@ coordinate with GDB to get better debug src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"> Valid HTML 4.01 - Reid Kleckner
+ Reid Kleckner, + Eli Bendersky
The LLVM Compiler Infrastructure
- Last modified: $Date: 2011-10-31 12:21:59 +0100 (Mon, 31 Oct 2011) $ + Last modified: $Date: 2012-05-01 09:58:54 +0200 (Tue, 01 May 2012) $ Modified: vendor/llvm/dist/docs/LLVMBuild.html ============================================================================== --- vendor/llvm/dist/docs/LLVMBuild.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/LLVMBuild.html Thu May 3 16:50:55 2012 (r234971) @@ -101,7 +101,7 @@ $ROOT of project trees for things which

As mentioned earlier, LLVM projects are organized into - logical components. Every component is typically grouped into it's + logical components. Every component is typically grouped into its own subdirectory. Generally, a component is organized around a coherent group of sources which have some kind of clear API separation from other parts of the code.

@@ -190,7 +190,7 @@ required_libraries = Archive BitReader C number in order for files with multiple components ("component_0", "component_1", and so on).

-

Section names not matches this format (or the "common" section) are +

Section names not matching this format (or the "common" section) are currently unused and are disallowed.

Every component is defined by the properties in the section. The exact list @@ -212,7 +212,7 @@ required_libraries = Archive BitReader C

  • parent [required]

    The name of the logical parent of the component. Components are organized into a logical tree to make it easier to navigate and organize - groups of components. The parent's have no semantics as far as the project + groups of components. The parents have no semantics as far as the project build is concerned, however. Typically, the parent will be the main component of the parent directory.

    @@ -263,7 +263,7 @@ required_libraries = Archive BitReader C

    If given, a list of the names of Library or LibraryGroup components which must also be linked in whenever this library is used. That is, the link time dependencies for this component. When tools are built, - the build system will include the transitive closer of + the build system will include the transitive closure of all required_libraries for the components the tool needs.

  • add_to_library_groups [optional] Modified: vendor/llvm/dist/docs/LangRef.html ============================================================================== --- vendor/llvm/dist/docs/LangRef.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/LangRef.html Thu May 3 16:50:55 2012 (r234971) @@ -103,7 +103,7 @@
  • Metadata Nodes and Metadata Strings
    1. 'tbaa' Metadata
    2. -
    3. 'fpaccuracy' Metadata
    4. +
    5. 'fpmath' Metadata
    6. 'range' Metadata
  • @@ -3000,16 +3000,16 @@ call void @llvm.dbg.value(metadata !24,

    - 'fpaccuracy' Metadata + 'fpmath' Metadata

    -

    fpaccuracy metadata may be attached to any instruction of floating - point type. It expresses the maximum relative error allowed in the result - of that instruction, in ULPs, thus potentially allowing the compiler to use - a more efficient but less accurate method of computing it. - ULP is defined as follows:

    +

    fpmath metadata may be attached to any instruction of floating point + type. It can be used to express the maximum acceptable error in the result of + that instruction, in ULPs, thus potentially allowing the compiler to use a + more efficient but less accurate method of computing it. ULP is defined as + follows:

    @@ -3021,13 +3021,12 @@ call void @llvm.dbg.value(metadata !24,
    -

    The metadata node shall consist of a single non-negative floating - point number representing the maximum relative error. For example, - 2.5 ULP:

    +

    The metadata node shall consist of a single positive floating point number + representing the maximum relative error, for example:

    -!0 = metadata !{ float 2.5 }
    +!0 = metadata !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
     
    @@ -8506,7 +8505,7 @@ LLVM.

    Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2012-04-10 10:22:43 +0200 (Tue, 10 Apr 2012) $ + Last modified: $Date: 2012-04-16 21:39:33 +0200 (Mon, 16 Apr 2012) $ Modified: vendor/llvm/dist/docs/ProgrammersManual.html ============================================================================== --- vendor/llvm/dist/docs/ProgrammersManual.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/ProgrammersManual.html Thu May 3 16:50:55 2012 (r234971) @@ -1734,6 +1734,9 @@ already in the table, and each pair in t

    StringMap also provides query methods that take byte ranges, so it only ever copies a string if a value is inserted into the table.

    + +

    StringMap iteratation order, however, is not guaranteed to be deterministic, +so any uses which require that should instead use a std::map.

    @@ -4125,7 +4128,7 @@ arguments. An argument has a pointer to Dinakar Dhurjati and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2012-03-27 13:25:16 +0200 (Tue, 27 Mar 2012) $ + Last modified: $Date: 2012-04-18 22:28:55 +0200 (Wed, 18 Apr 2012) $ Modified: vendor/llvm/dist/docs/ReleaseNotes.html ============================================================================== --- vendor/llvm/dist/docs/ReleaseNotes.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/ReleaseNotes.html Thu May 3 16:50:55 2012 (r234971) @@ -206,6 +206,36 @@ Release Notes.
    + + +

    +Polly: Polyhedral Optimizer +

    + +
    + +

    Polly is an experimental + optimizer for data locality and parallelism. It currently provides high-level + loop optimizations and automatic parallelisation (using the OpenMP run time). + Work in the area of automatic SIMD and accelerator code generation was + started. + +

    Within the LLVM 3.1 time-frame there were the following highlights:

    + +
      +
    • Polly became an official LLVM project
    • +
    • Polly can be loaded directly into clang (Enabled by '-O3 -mllvm -polly' + )
    • +
    • An automatic scheduling optimizer (derived from Pluto) was integrated. It + performs loop transformations to optimize for data-locality and parallelism. + The transformations include, but are not limited to interchange, fusion, + fission, skewing and tiling. +
    • +
    + +
    + @@ -269,6 +299,8 @@ Release Notes. Support to model instruction bundling / packing.
  • ARM Integrated Assembler, A full featured assembler and direct-to-object support for ARM.
  • +
  • Basic Block Placement + Probability driven basic block placement.
  • ....
  • @@ -292,6 +324,9 @@ Release Notes. module as a whole to LLVM subsystems.
  • Loads can now have range metadata attached to them to describe the possible values being loaded.
  • +
  • Inline cost heuristics have been completely overhauled and now closely + model constant propagation through call sites, disregard trivially dead + code costs, and can model C++ STL iterator patterns.
  • ....
  • @@ -308,6 +343,14 @@ Release Notes. optimizers:

      +
    • The loop unroll pass now is able to unroll loops with run-time trip counts. + This feature is turned off by default, and is enabled with the + -unroll-runtime flag.
    • +
    • A new basic-block autovectorization pass is available. Pass + -vectorize to run this pass along with some associated + post-vectorization cleanup passes. For more information, see the EuroLLVM + 2012 slides: + Autovectorization with LLVM.
    • ....
    @@ -373,6 +416,19 @@ Release Notes. target's schedule description which can be queried to determine legal groupings of instructions in a bundle.

    +

    We have added a new target independent VLIW packetizer based on the + DFA infrastructure to group machine instructions into bundles.

    + + + +

    +Basic Block Placement +

    +
    +

    A probability based block placement and code layout algorithm was added to +LLVM's code generator. This layout pass supports probabilities derived from +static heuristics as well as source code annotations such as +__builtin_expect.

    @@ -391,6 +447,7 @@ Release Notes. times and better support for different calling conventions. The old WINCALL instructions are no longer needed.
  • DW2 Exception Handling is enabled on Cygwin and MinGW.
  • +
  • Support for implicit TLS model used with MS VC runtime
  • @@ -451,6 +508,8 @@ syntax, there are still significant gaps
    +

    Support for Qualcomm's Hexagon VLIW processor has been added.

    +
    • ....
    • @@ -524,6 +583,8 @@ syntax, there are still significant gaps
    • llvm::getTrapFunctionName()
    • llvm::EnableSegmentedStacks
    +
  • The MDBuilder class has been added to simplify the creation of + metadata.
  • ....
  • @@ -621,7 +682,7 @@ syntax, there are still significant gaps src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"> LLVM Compiler Infrastructure
    - Last modified: $Date: 2012-04-12 17:17:35 +0200 (Thu, 12 Apr 2012) $ + Last modified: $Date: 2012-04-17 03:13:53 +0200 (Tue, 17 Apr 2012) $ Modified: vendor/llvm/dist/docs/TestingGuide.html ============================================================================== --- vendor/llvm/dist/docs/TestingGuide.html Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/docs/TestingGuide.html Thu May 3 16:50:55 2012 (r234971) @@ -299,15 +299,15 @@ clang/test directory.

    you.

    In order for the regression tests to work, each directory of tests must - have a dg.exp file. Lit looks for this file to determine how to - run the tests. This file is just a Tcl script and it can do anything you want, + have a lit.local.cfg file. Lit looks for this file to determine how + to run the tests. This file is just Python code and thus is very flexible, but we've standardized it for the LLVM regression tests. If you're adding a - directory of tests, just copy dg.exp from another directory to get - running. The standard dg.exp simply loads a Tcl library - (test/lib/llvm.exp) and calls the llvm_runtests function - defined in that library with a list of file names to run. The names are - obtained by using Tcl's glob command. Any directory that contains only - directories does not need the dg.exp file.

    + directory of tests, just copy lit.local.cfg from another directory to + get running. The standard lit.local.cfg simply specifies which files + to look in for tests. Any directory that contains only directories does not + need the lit.local.cfg file. Read the + Lit documentation for more + information.

    The llvm-runtests function looks at each file that is passed to it and gathers any lines together that match "RUN:". These are the "RUN" lines @@ -473,7 +473,7 @@ negatives).

    llc, then pipe the output of llc into FileCheck. This means that FileCheck will be verifying its standard input (the llc output) against the filename argument specified (the original .ll file specified by "%s"). To see how this works, -lets look at the rest of the .ll file (after the RUN line):

    +let's look at the rest of the .ll file (after the RUN line):

    @@ -900,7 +900,7 @@ the The LLVM Compiler Infrastructure
    - Last modified: $Date: 2012-03-27 13:25:16 +0200 (Tue, 27 Mar 2012) $ + Last modified: $Date: 2012-04-18 10:02:25 +0200 (Wed, 18 Apr 2012) $ Modified: vendor/llvm/dist/include/llvm-c/lto.h ============================================================================== --- vendor/llvm/dist/include/llvm-c/lto.h Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/include/llvm-c/lto.h Thu May 3 16:50:55 2012 (r234971) @@ -251,12 +251,6 @@ lto_codegen_set_assembler_args(lto_code_ int nargs); /** - * Enables the internalize pass during LTO optimizations. - */ -extern void -lto_codegen_set_whole_program_optimization(lto_code_gen_t cg); - -/** * Adds to a list of all global symbols that must exist in the final * generated code. If a function is not listed, it might be * inlined into every usage and optimized away. Modified: vendor/llvm/dist/include/llvm/ADT/SmallPtrSet.h ============================================================================== --- vendor/llvm/dist/include/llvm/ADT/SmallPtrSet.h Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/include/llvm/ADT/SmallPtrSet.h Thu May 3 16:50:55 2012 (r234971) @@ -126,9 +126,6 @@ protected: private: bool isSmall() const { return CurArray == SmallArray; } - unsigned Hash(const void *Ptr) const { - return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); - } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); Modified: vendor/llvm/dist/include/llvm/ADT/StringMap.h ============================================================================== --- vendor/llvm/dist/include/llvm/ADT/StringMap.h Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/include/llvm/ADT/StringMap.h Thu May 3 16:50:55 2012 (r234971) @@ -239,7 +239,7 @@ public: explicit StringMap(AllocatorTy A) : StringMapImpl(static_cast(sizeof(MapEntryTy))), Allocator(A) {} - explicit StringMap(const StringMap &RHS) + StringMap(const StringMap &RHS) : StringMapImpl(static_cast(sizeof(MapEntryTy))) { assert(RHS.empty() && "Copy ctor from non-empty stringmap not implemented yet!"); Modified: vendor/llvm/dist/include/llvm/CodeGen/DFAPacketizer.h ============================================================================== --- vendor/llvm/dist/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 16:49:27 2012 (r234970) +++ vendor/llvm/dist/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 16:50:55 2012 (r234971) @@ -28,7 +28,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/ADT/DenseMap.h" -#include namespace llvm { @@ -37,7 +36,7 @@ class MachineInstr; class MachineLoopInfo; class MachineDominatorTree; class InstrItineraryData; -class DefaultVLIWScheduler; +class ScheduleDAGInstrs; class SUnit; class DFAPacketizer { @@ -78,8 +77,6 @@ public: // reserveResources - Reserve the resources occupied by a machine // instruction and change the current state to reflect that change. void reserveResources(llvm::MachineInstr *MI); - - const InstrItineraryData *getInstrItins() const { return InstrItins; } }; // VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The @@ -90,21 +87,20 @@ public: // and machine resource is marked as taken. If any dependency is found, a target // API call is made to prune the dependence. class VLIWPacketizerList { -protected: const TargetMachine &TM; const MachineFunction &MF; const TargetInstrInfo *TII; - // The VLIW Scheduler. - DefaultVLIWScheduler *VLIWScheduler; + // Encapsulate data types not exposed to the target interface. + ScheduleDAGInstrs *SchedulerImpl; +protected: // Vector of instructions assigned to the current packet. std::vector CurrentPacketMIs; // DFA resource tracker. DFAPacketizer *ResourceTracker; - - // Generate MI -> SU map. - std::map MIToSUnit; + // Scheduling units. + std::vector SUnits; public: VLIWPacketizerList( @@ -122,32 +118,17 @@ public: DFAPacketizer *getResourceTracker() {return ResourceTracker;} // addToPacket - Add MI to the current packet. - virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) { - MachineBasicBlock::iterator MII = MI; - CurrentPacketMIs.push_back(MI); - ResourceTracker->reserveResources(MI); - return MII; - } + void addToPacket(MachineInstr *MI); // endPacket - End the current packet. - void endPacket(MachineBasicBlock *MBB, MachineInstr *MI); - - // initPacketizerState - perform initialization before packetizing - // an instruction. This function is supposed to be overrided by - // the target dependent packetizer. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:52:07 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF183106567A; Thu, 3 May 2012 16:52:07 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C18318FC17; Thu, 3 May 2012 16: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 q43Gq7cr052874; Thu, 3 May 2012 16:52:07 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Gq71E052873; Thu, 3 May 2012 16:52:07 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205031652.q43Gq71E052873@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 16:52:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234972 - vendor/llvm/llvm-release_31-r155985 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:52:08 -0000 Author: dim Date: Thu May 3 16:52:07 2012 New Revision: 234972 URL: http://svn.freebsd.org/changeset/base/234972 Log: Tag llvm release_31 branch r155985. Added: vendor/llvm/llvm-release_31-r155985/ - copied from r234971, vendor/llvm/dist/ From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:54:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5C27106567D; Thu, 3 May 2012 16:54:01 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8CF268FC20; Thu, 3 May 2012 16:54:01 +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 q43Gs1Wv053002; Thu, 3 May 2012 16:54:01 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Gs1Ek052968; Thu, 3 May 2012 16:54:01 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205031654.q43Gs1Ek052968@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 16:54:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234973 - in vendor/clang/dist: . bindings/python/clang bindings/python/tests/cindex examples/clang-interpreter include/clang/AST include/clang/Analysis include/clang/Basic include/clan... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:54:01 -0000 Author: dim Date: Thu May 3 16:53:59 2012 New Revision: 234973 URL: http://svn.freebsd.org/changeset/base/234973 Log: Vendor import of clang release_31 branch r155985: http://llvm.org/svn/llvm-project/cfe/branches/release_31@155985 Added: vendor/clang/dist/lib/Sema/SemaStmtAttr.cpp vendor/clang/dist/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp vendor/clang/dist/test/CodeCompletion/preamble.c vendor/clang/dist/test/CodeCompletion/some_struct.h vendor/clang/dist/test/CodeGen/arm-homogenous.c vendor/clang/dist/test/CodeGenCXX/cxx11-exception-spec.cpp vendor/clang/dist/test/CodeGenCXX/mangle-this-cxx11.cpp vendor/clang/dist/test/CodeGenOpenCL/fpmath.cl vendor/clang/dist/test/Misc/unprintable.c vendor/clang/dist/test/Misc/wnull-character.cpp (contents, props changed) vendor/clang/dist/test/Misc/wrong-encoding.c vendor/clang/dist/test/PCH/typo2.cpp vendor/clang/dist/test/Parser/cxx11-stmt-attributes.cpp vendor/clang/dist/test/Rewriter/rewrite-modern-extern-c-func-decl.mm vendor/clang/dist/test/Rewriter/rewrite-modern-protocol-1.mm vendor/clang/dist/test/Rewriter/rewrite-modern-super.mm vendor/clang/dist/test/Rewriter/rewrite-modern-typeof.mm vendor/clang/dist/test/Sema/const-eval-64.c vendor/clang/dist/test/SemaObjC/error-implicit-property.m vendor/clang/dist/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp vendor/clang/dist/test/Tooling/clang-check-args.cpp vendor/clang/dist/www/libstdc++4.7-clang11.patch Deleted: vendor/clang/dist/include/clang/Basic/DelayedCleanupPool.h vendor/clang/dist/include/clang/Index/ vendor/clang/dist/lib/Index/ vendor/clang/dist/test/CodeGenOpenCL/fpaccuracy.cl vendor/clang/dist/test/Misc/pubnames.c Modified: vendor/clang/dist/CMakeLists.txt vendor/clang/dist/bindings/python/clang/cindex.py vendor/clang/dist/bindings/python/tests/cindex/test_type.py vendor/clang/dist/examples/clang-interpreter/CMakeLists.txt vendor/clang/dist/include/clang/AST/Decl.h vendor/clang/dist/include/clang/AST/DeclBase.h vendor/clang/dist/include/clang/AST/DeclLookups.h vendor/clang/dist/include/clang/AST/Expr.h vendor/clang/dist/include/clang/AST/ExternalASTSource.h vendor/clang/dist/include/clang/AST/RecursiveASTVisitor.h vendor/clang/dist/include/clang/AST/Stmt.h vendor/clang/dist/include/clang/AST/Type.h vendor/clang/dist/include/clang/AST/VTableBuilder.h vendor/clang/dist/include/clang/Analysis/ProgramPoint.h vendor/clang/dist/include/clang/Basic/BuiltinsX86.def vendor/clang/dist/include/clang/Basic/ConvertUTF.h vendor/clang/dist/include/clang/Basic/DiagnosticParseKinds.td vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td vendor/clang/dist/include/clang/Basic/ExceptionSpecificationType.h vendor/clang/dist/include/clang/Basic/OnDiskHashTable.h vendor/clang/dist/include/clang/Basic/StmtNodes.td vendor/clang/dist/include/clang/Basic/TargetInfo.h vendor/clang/dist/include/clang/Basic/TokenKinds.def vendor/clang/dist/include/clang/Config/config.h.cmake vendor/clang/dist/include/clang/Config/config.h.in vendor/clang/dist/include/clang/Driver/CC1Options.td vendor/clang/dist/include/clang/Driver/Compilation.h vendor/clang/dist/include/clang/Frontend/ASTUnit.h vendor/clang/dist/include/clang/Frontend/FrontendActions.h vendor/clang/dist/include/clang/Frontend/FrontendOptions.h vendor/clang/dist/include/clang/Frontend/TextDiagnostic.h vendor/clang/dist/include/clang/Parse/Parser.h vendor/clang/dist/include/clang/Sema/DeclSpec.h vendor/clang/dist/include/clang/Sema/ParsedTemplate.h vendor/clang/dist/include/clang/Sema/Scope.h vendor/clang/dist/include/clang/Sema/Sema.h vendor/clang/dist/include/clang/Serialization/ASTBitCodes.h vendor/clang/dist/include/clang/Serialization/ASTReader.h vendor/clang/dist/include/clang/Serialization/ASTWriter.h vendor/clang/dist/include/clang/Serialization/Module.h vendor/clang/dist/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h vendor/clang/dist/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h vendor/clang/dist/include/clang/Tooling/CompilationDatabase.h vendor/clang/dist/lib/AST/ASTContext.cpp vendor/clang/dist/lib/AST/Decl.cpp vendor/clang/dist/lib/AST/Expr.cpp vendor/clang/dist/lib/AST/ExprConstant.cpp vendor/clang/dist/lib/AST/ExternalASTSource.cpp vendor/clang/dist/lib/AST/ItaniumMangle.cpp vendor/clang/dist/lib/AST/Stmt.cpp vendor/clang/dist/lib/AST/StmtPrinter.cpp vendor/clang/dist/lib/AST/StmtProfile.cpp vendor/clang/dist/lib/AST/Type.cpp vendor/clang/dist/lib/AST/VTableBuilder.cpp vendor/clang/dist/lib/Analysis/CFG.cpp vendor/clang/dist/lib/Analysis/CMakeLists.txt vendor/clang/dist/lib/Basic/TargetInfo.cpp vendor/clang/dist/lib/Basic/Targets.cpp vendor/clang/dist/lib/Basic/Version.cpp vendor/clang/dist/lib/CMakeLists.txt vendor/clang/dist/lib/CodeGen/CGBlocks.cpp vendor/clang/dist/lib/CodeGen/CGCall.cpp vendor/clang/dist/lib/CodeGen/CGClass.cpp vendor/clang/dist/lib/CodeGen/CGDebugInfo.cpp vendor/clang/dist/lib/CodeGen/CGDecl.cpp vendor/clang/dist/lib/CodeGen/CGExpr.cpp vendor/clang/dist/lib/CodeGen/CGExprAgg.cpp vendor/clang/dist/lib/CodeGen/CGExprCXX.cpp vendor/clang/dist/lib/CodeGen/CGExprConstant.cpp vendor/clang/dist/lib/CodeGen/CGStmt.cpp vendor/clang/dist/lib/CodeGen/CodeGenFunction.cpp vendor/clang/dist/lib/CodeGen/CodeGenFunction.h vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp vendor/clang/dist/lib/CodeGen/CodeGenTBAA.cpp vendor/clang/dist/lib/CodeGen/CodeGenTBAA.h vendor/clang/dist/lib/CodeGen/TargetInfo.cpp vendor/clang/dist/lib/Driver/Compilation.cpp vendor/clang/dist/lib/Driver/Driver.cpp vendor/clang/dist/lib/Driver/ToolChains.cpp vendor/clang/dist/lib/Driver/Tools.cpp vendor/clang/dist/lib/Frontend/ASTUnit.cpp vendor/clang/dist/lib/Frontend/CompilerInstance.cpp vendor/clang/dist/lib/Frontend/CompilerInvocation.cpp vendor/clang/dist/lib/Frontend/FrontendActions.cpp vendor/clang/dist/lib/Frontend/TextDiagnostic.cpp vendor/clang/dist/lib/FrontendTool/ExecuteCompilerInvocation.cpp vendor/clang/dist/lib/Headers/avx2intrin.h vendor/clang/dist/lib/Headers/avxintrin.h vendor/clang/dist/lib/Makefile vendor/clang/dist/lib/Parse/ParseCXXInlineMethods.cpp vendor/clang/dist/lib/Parse/ParseDecl.cpp vendor/clang/dist/lib/Parse/ParseDeclCXX.cpp vendor/clang/dist/lib/Parse/ParseExpr.cpp vendor/clang/dist/lib/Parse/ParseExprCXX.cpp vendor/clang/dist/lib/Parse/ParseStmt.cpp vendor/clang/dist/lib/Parse/ParseTemplate.cpp vendor/clang/dist/lib/Parse/Parser.cpp vendor/clang/dist/lib/Rewrite/RewriteModernObjC.cpp vendor/clang/dist/lib/Rewrite/RewriteRope.cpp vendor/clang/dist/lib/Sema/CMakeLists.txt vendor/clang/dist/lib/Sema/DeclSpec.cpp vendor/clang/dist/lib/Sema/Sema.cpp vendor/clang/dist/lib/Sema/SemaAccess.cpp vendor/clang/dist/lib/Sema/SemaDecl.cpp vendor/clang/dist/lib/Sema/SemaDeclCXX.cpp vendor/clang/dist/lib/Sema/SemaExceptionSpec.cpp vendor/clang/dist/lib/Sema/SemaExpr.cpp vendor/clang/dist/lib/Sema/SemaExprCXX.cpp vendor/clang/dist/lib/Sema/SemaExprMember.cpp vendor/clang/dist/lib/Sema/SemaLookup.cpp vendor/clang/dist/lib/Sema/SemaOverload.cpp vendor/clang/dist/lib/Sema/SemaPseudoObject.cpp vendor/clang/dist/lib/Sema/SemaStmt.cpp vendor/clang/dist/lib/Sema/SemaTemplate.cpp vendor/clang/dist/lib/Sema/SemaTemplateDeduction.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiate.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp vendor/clang/dist/lib/Sema/SemaType.cpp vendor/clang/dist/lib/Sema/TreeTransform.h vendor/clang/dist/lib/Serialization/ASTReader.cpp vendor/clang/dist/lib/Serialization/ASTReaderDecl.cpp vendor/clang/dist/lib/Serialization/ASTReaderInternals.h vendor/clang/dist/lib/Serialization/ASTReaderStmt.cpp vendor/clang/dist/lib/Serialization/ASTWriter.cpp vendor/clang/dist/lib/Serialization/ASTWriterDecl.cpp vendor/clang/dist/lib/Serialization/ASTWriterStmt.cpp vendor/clang/dist/lib/Serialization/Module.cpp vendor/clang/dist/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp vendor/clang/dist/lib/StaticAnalyzer/Core/AnalysisManager.cpp vendor/clang/dist/lib/StaticAnalyzer/Core/CoreEngine.cpp vendor/clang/dist/lib/StaticAnalyzer/Core/ExprEngine.cpp vendor/clang/dist/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp vendor/clang/dist/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp vendor/clang/dist/lib/Tooling/CompilationDatabase.cpp vendor/clang/dist/test/Analysis/objc-bool.m vendor/clang/dist/test/Analysis/redefined_system.c vendor/clang/dist/test/Analysis/self-init.m vendor/clang/dist/test/CXX/class/class.mem/p2.cpp vendor/clang/dist/test/CXX/except/except.spec/p1.cpp vendor/clang/dist/test/CXX/special/class.inhctor/elsewhere.cpp vendor/clang/dist/test/CXX/special/class.inhctor/p3.cpp vendor/clang/dist/test/CXX/special/class.inhctor/p7.cpp vendor/clang/dist/test/CXX/temp/temp.decls/temp.variadic/p5.cpp vendor/clang/dist/test/CodeGen/avx-shuffle-builtins.c vendor/clang/dist/test/CodeGen/avx2-builtins.c vendor/clang/dist/test/CodeGen/builtins-x86.c vendor/clang/dist/test/CodeGen/may-alias.c vendor/clang/dist/test/CodeGen/packed-nest-unpacked.c vendor/clang/dist/test/CodeGen/tbaa-for-vptr.cpp vendor/clang/dist/test/CodeGenCXX/block-byref-cxx-objc.cpp vendor/clang/dist/test/CodeGenCXX/const-init-cxx11.cpp vendor/clang/dist/test/CodeGenCXX/inheriting-constructor.cpp vendor/clang/dist/test/CodeGenCXX/static-init.cpp vendor/clang/dist/test/Headers/typedef_guards.c vendor/clang/dist/test/Index/get-cursor.m vendor/clang/dist/test/Lexer/newline-eof-c++98-compat.cpp vendor/clang/dist/test/Lexer/newline-eof.c vendor/clang/dist/test/Lexer/utf-16.c vendor/clang/dist/test/Misc/message-length.c vendor/clang/dist/test/Parser/MicrosoftExtensions.cpp vendor/clang/dist/test/Parser/objcxx11-attributes.mm vendor/clang/dist/test/Preprocessor/pragma_sysheader.c vendor/clang/dist/test/Rewriter/blockcast3.mm vendor/clang/dist/test/Rewriter/instancetype-test.mm vendor/clang/dist/test/Rewriter/objc-bool-literal-check-modern.mm vendor/clang/dist/test/Rewriter/objc-bool-literal-modern.mm vendor/clang/dist/test/Rewriter/objc-modern-numeric-literal.mm vendor/clang/dist/test/Rewriter/rewrite-block-consts.mm vendor/clang/dist/test/Rewriter/rewrite-block-literal-1.mm vendor/clang/dist/test/Rewriter/rewrite-block-literal.mm vendor/clang/dist/test/Rewriter/rewrite-block-pointer.mm vendor/clang/dist/test/Rewriter/rewrite-byref-in-nested-blocks.mm vendor/clang/dist/test/Rewriter/rewrite-elaborated-type.mm vendor/clang/dist/test/Rewriter/rewrite-foreach-in-block.mm vendor/clang/dist/test/Rewriter/rewrite-modern-container-literal.mm vendor/clang/dist/test/Rewriter/rewrite-nested-blocks-1.mm vendor/clang/dist/test/Rewriter/rewrite-nested-blocks-2.mm vendor/clang/dist/test/Rewriter/rewrite-nested-blocks.mm vendor/clang/dist/test/Rewriter/rewrite-nested-property-in-blocks.mm vendor/clang/dist/test/Rewriter/rewrite-unique-block-api.mm vendor/clang/dist/test/Sema/const-eval.c vendor/clang/dist/test/Sema/surpress-deprecated.c vendor/clang/dist/test/SemaCXX/constant-expression-cxx11.cpp vendor/clang/dist/test/SemaCXX/cxx98-compat.cpp vendor/clang/dist/test/SemaCXX/dependent-noexcept-unevaluated.cpp vendor/clang/dist/test/SemaCXX/implicit-exception-spec.cpp vendor/clang/dist/test/SemaCXX/warn-everthing.cpp vendor/clang/dist/test/SemaCXX/warn-thread-safety-parsing.cpp vendor/clang/dist/test/SemaObjC/objc-literal-nsnumber.m vendor/clang/dist/test/SemaObjCXX/literals.mm vendor/clang/dist/test/SemaObjCXX/property-reference.mm vendor/clang/dist/test/SemaTemplate/default-expr-arguments.cpp vendor/clang/dist/test/SemaTemplate/dependent-names.cpp vendor/clang/dist/test/SemaTemplate/instantiate-declref.cpp vendor/clang/dist/tools/arcmt-test/Makefile vendor/clang/dist/tools/c-arcmt-test/Makefile vendor/clang/dist/tools/c-index-test/Makefile vendor/clang/dist/tools/c-index-test/c-index-test.c vendor/clang/dist/tools/clang-check/ClangCheck.cpp vendor/clang/dist/tools/driver/CMakeLists.txt vendor/clang/dist/tools/driver/Makefile vendor/clang/dist/tools/libclang/CIndex.cpp vendor/clang/dist/tools/libclang/CMakeLists.txt vendor/clang/dist/tools/libclang/CXCursor.cpp vendor/clang/dist/tools/libclang/Makefile vendor/clang/dist/tools/scan-build/ccc-analyzer vendor/clang/dist/unittests/Frontend/Makefile vendor/clang/dist/unittests/Tooling/CompilationDatabaseTest.cpp vendor/clang/dist/www/cxx_status.html vendor/clang/dist/www/hacking.html Modified: vendor/clang/dist/CMakeLists.txt ============================================================================== --- vendor/clang/dist/CMakeLists.txt Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/CMakeLists.txt Thu May 3 16:53:59 2012 (r234973) @@ -66,6 +66,10 @@ set(CLANG_RESOURCE_DIR "" CACHE STRING set(C_INCLUDE_DIRS "" CACHE STRING "Colon separated list of directories clang will search for headers.") +set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." ) +set(DEFAULT_SYSROOT "" CACHE PATH + "Default to all compiler invocations for --sysroot=." ) + set(CLANG_VENDOR "" CACHE STRING "Vendor-specific text for showing with version information.") Modified: vendor/clang/dist/bindings/python/clang/cindex.py ============================================================================== --- vendor/clang/dist/bindings/python/clang/cindex.py Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/bindings/python/clang/cindex.py Thu May 3 16:53:59 2012 (r234973) @@ -1079,6 +1079,11 @@ class TypeKind(object): self._name_map[value] = key return self._name_map[self] + @property + def spelling(self): + """Retrieve the spelling of this TypeKind.""" + return TypeKind_spelling(self.value) + @staticmethod def from_id(id): if id >= len(TypeKind._kinds) or TypeKind._kinds[id] is None: @@ -1088,6 +1093,10 @@ class TypeKind(object): def __repr__(self): return 'TypeKind.%s' % (self.name,) +TypeKind_spelling = lib.clang_getTypeKindSpelling +TypeKind_spelling.argtypes = [c_uint] +TypeKind_spelling.restype = _CXString +TypeKind_spelling.errcheck = _CXString.from_result TypeKind.INVALID = TypeKind(0) Modified: vendor/clang/dist/bindings/python/tests/cindex/test_type.py ============================================================================== --- vendor/clang/dist/bindings/python/tests/cindex/test_type.py Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/bindings/python/tests/cindex/test_type.py Thu May 3 16:53:59 2012 (r234973) @@ -1,5 +1,4 @@ from clang.cindex import CursorKind -from clang.cindex import Index from clang.cindex import TypeKind from nose.tools import raises from .util import get_cursor @@ -109,6 +108,14 @@ def test_equal(): assert a.type != None assert a.type != 'foo' +def test_typekind_spelling(): + """Ensure TypeKind.spelling works.""" + tu = get_tu('int a;') + a = get_cursor(tu, 'a') + + assert a is not None + assert a.type.kind.spelling == 'Int' + def test_function_argument_types(): """Ensure that Type.argument_types() works as expected.""" tu = get_tu('void f(int, int);') Modified: vendor/clang/dist/examples/clang-interpreter/CMakeLists.txt ============================================================================== --- vendor/clang/dist/examples/clang-interpreter/CMakeLists.txt Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/examples/clang-interpreter/CMakeLists.txt Thu May 3 16:53:59 2012 (r234973) @@ -7,7 +7,6 @@ set(LLVM_USED_LIBS clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore - clangIndex clangAnalysis clangRewrite clangAST Modified: vendor/clang/dist/include/clang/AST/Decl.h ============================================================================== --- vendor/clang/dist/include/clang/AST/Decl.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/Decl.h Thu May 3 16:53:59 2012 (r234973) @@ -64,6 +64,9 @@ public: /// \brief Return the TypeLoc wrapper for the type source info. TypeLoc getTypeLoc() const; // implemented in TypeLoc.h + + /// \brief Override the type stored in this TypeSourceInfo. Use with caution! + void overrideType(QualType T) { Ty = T; } }; /// TranslationUnitDecl - The top declaration context. @@ -242,11 +245,7 @@ public: bool visibilityExplicit() const { return explicit_; } void setLinkage(Linkage L) { linkage_ = L; } - void setVisibility(Visibility V) { visibility_ = V; } void setVisibility(Visibility V, bool E) { visibility_ = V; explicit_ = E; } - void setVisibility(LinkageInfo Other) { - setVisibility(Other.visibility(), Other.visibilityExplicit()); - } void mergeLinkage(Linkage L) { setLinkage(minLinkage(linkage(), L)); Modified: vendor/clang/dist/include/clang/AST/DeclBase.h ============================================================================== --- vendor/clang/dist/include/clang/AST/DeclBase.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/DeclBase.h Thu May 3 16:53:59 2012 (r234973) @@ -861,7 +861,6 @@ public: void dumpXML(raw_ostream &OS) const; private: - const Attr *getAttrsImpl() const; void setAttrsImpl(const AttrVec& Attrs, ASTContext &Ctx); void setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC, ASTContext &Ctx); Modified: vendor/clang/dist/include/clang/AST/DeclLookups.h ============================================================================== --- vendor/clang/dist/include/clang/AST/DeclLookups.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/DeclLookups.h Thu May 3 16:53:59 2012 (r234973) @@ -67,6 +67,8 @@ public: DeclContext::all_lookups_iterator DeclContext::lookups_begin() const { DeclContext *Primary = const_cast(this)->getPrimaryContext(); + if (hasExternalVisibleStorage()) + getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary); if (StoredDeclsMap *Map = Primary->buildLookup()) return all_lookups_iterator(Map->begin(), Map->end()); return all_lookups_iterator(); @@ -74,6 +76,8 @@ DeclContext::all_lookups_iterator DeclCo DeclContext::all_lookups_iterator DeclContext::lookups_end() const { DeclContext *Primary = const_cast(this)->getPrimaryContext(); + if (hasExternalVisibleStorage()) + getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary); if (StoredDeclsMap *Map = Primary->buildLookup()) return all_lookups_iterator(Map->end(), Map->end()); return all_lookups_iterator(); Modified: vendor/clang/dist/include/clang/AST/Expr.h ============================================================================== --- vendor/clang/dist/include/clang/AST/Expr.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/Expr.h Thu May 3 16:53:59 2012 (r234973) @@ -581,16 +581,6 @@ public: /// member expression. static QualType findBoundMemberType(const Expr *expr); - /// \brief Result type of CanThrow(). - enum CanThrowResult { - CT_Cannot, - CT_Dependent, - CT_Can - }; - /// \brief Test if this expression, if evaluated, might throw, according to - /// the rules of C++ [expr.unary.noexcept]. - CanThrowResult CanThrow(ASTContext &C) const; - /// IgnoreImpCasts - Skip past any implicit casts which might /// surround this expression. Only skips ImplicitCastExprs. Expr *IgnoreImpCasts() LLVM_READONLY; @@ -3608,6 +3598,10 @@ public: return LBraceLoc.isValid() && RBraceLoc.isValid(); } + // Is this an initializer for an array of characters, initialized by a string + // literal or an @encode? + bool isStringLiteralInit() const; + SourceLocation getLBraceLoc() const { return LBraceLoc; } void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; } SourceLocation getRBraceLoc() const { return RBraceLoc; } Modified: vendor/clang/dist/include/clang/AST/ExternalASTSource.h ============================================================================== --- vendor/clang/dist/include/clang/AST/ExternalASTSource.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/ExternalASTSource.h Thu May 3 16:53:59 2012 (r234973) @@ -126,6 +126,12 @@ public: virtual DeclContextLookupResult FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name); + /// \brief Ensures that the table of all visible declarations inside this + /// context is up to date. + /// + /// The default implementation of this functino is a no-op. + virtual void completeVisibleDeclsMap(const DeclContext *DC); + /// \brief Finds all declarations lexically contained within the given /// DeclContext, after applying an optional filter predicate. /// Modified: vendor/clang/dist/include/clang/AST/RecursiveASTVisitor.h ============================================================================== --- vendor/clang/dist/include/clang/AST/RecursiveASTVisitor.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/RecursiveASTVisitor.h Thu May 3 16:53:59 2012 (r234973) @@ -1870,6 +1870,7 @@ DEF_TRAVERSE_STMT(GotoStmt, { }) DEF_TRAVERSE_STMT(IfStmt, { }) DEF_TRAVERSE_STMT(IndirectGotoStmt, { }) DEF_TRAVERSE_STMT(LabelStmt, { }) +DEF_TRAVERSE_STMT(AttributedStmt, { }) DEF_TRAVERSE_STMT(NullStmt, { }) DEF_TRAVERSE_STMT(ObjCAtCatchStmt, { }) DEF_TRAVERSE_STMT(ObjCAtFinallyStmt, { }) Modified: vendor/clang/dist/include/clang/AST/Stmt.h ============================================================================== --- vendor/clang/dist/include/clang/AST/Stmt.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/Stmt.h Thu May 3 16:53:59 2012 (r234973) @@ -20,6 +20,7 @@ #include "clang/AST/StmtIterator.h" #include "clang/AST/DeclGroup.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Attr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" @@ -794,6 +795,47 @@ public: }; +/// \brief Represents an attribute applied to a statement. +/// +/// Represents an attribute applied to a statement. For example: +/// [[omp::for(...)]] for (...) { ... } +/// +class AttributedStmt : public Stmt { + Stmt *SubStmt; + SourceLocation AttrLoc; + AttrVec Attrs; + // TODO: It can be done as Attr *Attrs[1]; and variable size array as in + // StringLiteral + + friend class ASTStmtReader; + +public: + AttributedStmt(SourceLocation loc, const AttrVec &attrs, Stmt *substmt) + : Stmt(AttributedStmtClass), SubStmt(substmt), AttrLoc(loc), Attrs(attrs) { + } + + // \brief Build an empty attributed statement. + explicit AttributedStmt(EmptyShell Empty) + : Stmt(AttributedStmtClass, Empty) { + } + + SourceLocation getAttrLoc() const { return AttrLoc; } + const AttrVec &getAttrs() const { return Attrs; } + Stmt *getSubStmt() { return SubStmt; } + const Stmt *getSubStmt() const { return SubStmt; } + + SourceRange getSourceRange() const LLVM_READONLY { + return SourceRange(AttrLoc, SubStmt->getLocEnd()); + } + child_range children() { return child_range(&SubStmt, &SubStmt + 1); } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == AttributedStmtClass; + } + static bool classof(const AttributedStmt *) { return true; } +}; + + /// IfStmt - This represents an if/then/else. /// class IfStmt : public Stmt { Modified: vendor/clang/dist/include/clang/AST/Type.h ============================================================================== --- vendor/clang/dist/include/clang/AST/Type.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/Type.h Thu May 3 16:53:59 2012 (r234973) @@ -79,6 +79,7 @@ namespace clang { class CXXRecordDecl; class EnumDecl; class FieldDecl; + class FunctionDecl; class ObjCInterfaceDecl; class ObjCProtocolDecl; class ObjCMethodDecl; @@ -2700,7 +2701,9 @@ public: ExtProtoInfo() : Variadic(false), HasTrailingReturn(false), TypeQuals(0), ExceptionSpecType(EST_None), RefQualifier(RQ_None), - NumExceptions(0), Exceptions(0), NoexceptExpr(0), ConsumedArguments(0) {} + NumExceptions(0), Exceptions(0), NoexceptExpr(0), + ExceptionSpecDecl(0), ExceptionSpecTemplate(0), + ConsumedArguments(0) {} FunctionType::ExtInfo ExtInfo; bool Variadic : 1; @@ -2711,6 +2714,8 @@ public: unsigned NumExceptions; const QualType *Exceptions; Expr *NoexceptExpr; + FunctionDecl *ExceptionSpecDecl; + FunctionDecl *ExceptionSpecTemplate; const bool *ConsumedArguments; }; @@ -2756,6 +2761,11 @@ private: // NoexceptExpr - Instead of Exceptions, there may be a single Expr* pointing // to the expression in the noexcept() specifier. + // ExceptionSpecDecl, ExceptionSpecTemplate - Instead of Exceptions, there may + // be a pair of FunctionDecl* pointing to the function which should be used to + // instantiate this function type's exception specification, and the function + // from which it should be instantiated. + // ConsumedArgs - A variable size array, following Exceptions // and of length NumArgs, holding flags indicating which arguments // are consumed. This only appears if HasAnyConsumedArgs is true. @@ -2795,6 +2805,9 @@ public: EPI.Exceptions = exception_begin(); } else if (EPI.ExceptionSpecType == EST_ComputedNoexcept) { EPI.NoexceptExpr = getNoexceptExpr(); + } else if (EPI.ExceptionSpecType == EST_Uninstantiated) { + EPI.ExceptionSpecDecl = getExceptionSpecDecl(); + EPI.ExceptionSpecTemplate = getExceptionSpecTemplate(); } if (hasAnyConsumedArgs()) EPI.ConsumedArguments = getConsumedArgsBuffer(); @@ -2838,9 +2851,26 @@ public: // NoexceptExpr sits where the arguments end. return *reinterpret_cast(arg_type_end()); } + /// \brief If this function type has an uninstantiated exception + /// specification, this is the function whose exception specification + /// is represented by this type. + FunctionDecl *getExceptionSpecDecl() const { + if (getExceptionSpecType() != EST_Uninstantiated) + return 0; + return reinterpret_cast(arg_type_end())[0]; + } + /// \brief If this function type has an uninstantiated exception + /// specification, this is the function whose exception specification + /// should be instantiated to find the exception specification for + /// this type. + FunctionDecl *getExceptionSpecTemplate() const { + if (getExceptionSpecType() != EST_Uninstantiated) + return 0; + return reinterpret_cast(arg_type_end())[1]; + } bool isNothrow(ASTContext &Ctx) const { ExceptionSpecificationType EST = getExceptionSpecType(); - assert(EST != EST_Delayed); + assert(EST != EST_Delayed && EST != EST_Uninstantiated); if (EST == EST_DynamicNone || EST == EST_BasicNoexcept) return true; if (EST != EST_ComputedNoexcept) Modified: vendor/clang/dist/include/clang/AST/VTableBuilder.h ============================================================================== --- vendor/clang/dist/include/clang/AST/VTableBuilder.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/AST/VTableBuilder.h Thu May 3 16:53:59 2012 (r234973) @@ -205,11 +205,11 @@ public: typedef llvm::DenseMap AddressPointsMapTy; private: uint64_t NumVTableComponents; - VTableComponent *VTableComponents; + llvm::OwningArrayPtr VTableComponents; /// VTableThunks - Contains thunks needed by vtables. uint64_t NumVTableThunks; - VTableThunkTy *VTableThunks; + llvm::OwningArrayPtr VTableThunks; /// Address points - Address points for all vtables. AddressPointsMapTy AddressPoints; @@ -227,11 +227,11 @@ public: } vtable_component_iterator vtable_component_begin() const { - return VTableComponents; + return VTableComponents.get(); } vtable_component_iterator vtable_component_end() const { - return VTableComponents+NumVTableComponents; + return VTableComponents.get()+NumVTableComponents; } uint64_t getNumVTableThunks() const { @@ -239,11 +239,11 @@ public: } vtable_thunk_iterator vtable_thunk_begin() const { - return VTableThunks; + return VTableThunks.get(); } vtable_thunk_iterator vtable_thunk_end() const { - return VTableThunks+NumVTableThunks; + return VTableThunks.get()+NumVTableThunks; } uint64_t getAddressPoint(BaseSubobject Base) const { Modified: vendor/clang/dist/include/clang/Analysis/ProgramPoint.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/ProgramPoint.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Analysis/ProgramPoint.h Thu May 3 16:53:59 2012 (r234973) @@ -129,7 +129,7 @@ public: static bool classof(const ProgramPoint*) { return true; } bool operator==(const ProgramPoint & RHS) const { - return Data1 == Data1 && + return Data1 == RHS.Data1 && Data2 == RHS.Data2 && L == RHS.L && Tag == RHS.Tag; Modified: vendor/clang/dist/include/clang/Basic/BuiltinsX86.def ============================================================================== --- vendor/clang/dist/include/clang/Basic/BuiltinsX86.def Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/BuiltinsX86.def Thu May 3 16:53:59 2012 (r234973) @@ -412,6 +412,9 @@ BUILTIN(__builtin_ia32_cvtps2pd256, "V4d BUILTIN(__builtin_ia32_cvttpd2dq256, "V4iV4d", "") BUILTIN(__builtin_ia32_cvtpd2dq256, "V4iV4d", "") BUILTIN(__builtin_ia32_cvttps2dq256, "V8iV8f", "") +BUILTIN(__builtin_ia32_vperm2f128_pd256, "V4dV4dV4dIc", "") +BUILTIN(__builtin_ia32_vperm2f128_ps256, "V8fV8fV8fIc", "") +BUILTIN(__builtin_ia32_vperm2f128_si256, "V8iV8iV8iIc", "") BUILTIN(__builtin_ia32_vinsertf128_pd256, "V4dV4dV2dIc", "") BUILTIN(__builtin_ia32_vinsertf128_ps256, "V8fV8fV4fIc", "") BUILTIN(__builtin_ia32_vinsertf128_si256, "V8iV8iV4iIc", "") @@ -560,9 +563,8 @@ BUILTIN(__builtin_ia32_pbroadcastw128, " BUILTIN(__builtin_ia32_pbroadcastd128, "V4iV4i", "") BUILTIN(__builtin_ia32_pbroadcastq128, "V2LLiV2LLi", "") BUILTIN(__builtin_ia32_permvarsi256, "V8iV8iV8i", "") -BUILTIN(__builtin_ia32_permdf256, "V4dV4dIc", "") BUILTIN(__builtin_ia32_permvarsf256, "V8fV8fV8f", "") -BUILTIN(__builtin_ia32_permdi256, "V4LLiV4LLiIc", "") +BUILTIN(__builtin_ia32_permti256, "V4LLiV4LLiV4LLiIc", "") BUILTIN(__builtin_ia32_extract128i256, "V2LLiV4LLiIc", "") BUILTIN(__builtin_ia32_insert128i256, "V4LLiV4LLiV2LLiIc", "") BUILTIN(__builtin_ia32_maskloadd256, "V8iV8iC*V8i", "") Modified: vendor/clang/dist/include/clang/Basic/ConvertUTF.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/ConvertUTF.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/ConvertUTF.h Thu May 3 16:53:59 2012 (r234973) @@ -151,9 +151,9 @@ ConversionResult ConvertUTF16toUTF32 ( ConversionResult ConvertUTF32toUTF16 ( const UTF32** sourceStart, const UTF32* sourceEnd, UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); +#endif Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); -#endif Boolean isLegalUTF8String(const UTF8 *source, const UTF8 *sourceEnd); Modified: vendor/clang/dist/include/clang/Basic/DiagnosticParseKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticParseKinds.td Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/DiagnosticParseKinds.td Thu May 3 16:53:59 2012 (r234973) @@ -410,6 +410,8 @@ def ext_ellipsis_exception_spec : Extens "exception specification of '...' is a Microsoft extension">; def err_dynamic_and_noexcept_specification : Error< "cannot have both throw() and noexcept() clause on the same function">; +def err_except_spec_unparsed : Error< + "unexpected end of exception specification">; def warn_cxx98_compat_noexcept_decl : Warning< "noexcept specifications are incompatible with C++98">, InGroup, DefaultIgnore; Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Thu May 3 16:53:59 2012 (r234973) @@ -231,9 +231,13 @@ def err_using_decl_can_not_refer_to_name "using declaration can not refer to namespace">; def err_using_decl_constructor : Error< "using declaration can not refer to a constructor">; -def warn_cxx98_compat_using_decl_constructor : Warning< - "inherited constructors are incompatible with C++98">, - InGroup, DefaultIgnore; +def err_using_decl_constructor_unsupported : Error< + "inheriting constructors are not supported">; +// FIXME: Replace the above error with this warning if support for +// inheriting constructors is implemented. +//def warn_cxx98_compat_using_decl_constructor : Warning< +// "inheriting constructors are incompatible with C++98">, +// InGroup, DefaultIgnore; def err_using_decl_destructor : Error< "using declaration can not refer to a destructor">; def err_using_decl_template_id : Error< @@ -1547,9 +1551,6 @@ def warn_objc_redundant_literal_use : Wa "using %0 with a literal is redundant">, InGroup; } -def warn_bool_for_boolean_literal : Warning< - "BOOL of type %0 is non-intergal and unsuitable for a " - "boolean literal - ignored">, InGroup>; def err_only_annotate_after_access_spec : Error< "access specifier can only have annotation attributes">; def err_attribute_section_invalid_for_target : Error< @@ -1563,6 +1564,9 @@ def warn_redeclaration_without_attribute def warn_attribute_ignored : Warning<"%0 attribute ignored">; def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; +def warn_attribute_invalid_on_stmt : Warning< + "attribute %0 cannot be specified on a statement">, + InGroup; def warn_declspec_attribute_ignored : Warning< "attribute %0 is ignored, place it after \"%select{class|struct|union|enum}1\" to apply attribute to type declaration">, InGroup; def warn_attribute_precede_definition : Warning< @@ -2583,6 +2587,8 @@ def note_template_enum_def_here : Note< "in instantiation of enumeration %q0 requested here">; def note_template_type_alias_instantiation_here : Note< "in instantiation of template type alias %0 requested here">; +def note_template_exception_spec_instantiation_here : Note< + "in instantiation of exception specification for %0 requested here">; def note_default_arg_instantiation_here : Note< "in instantiation of default argument for '%0' required here">; @@ -3798,6 +3804,9 @@ def warn_null_in_comparison_operation : def err_invalid_this_use : Error< "invalid use of 'this' outside of a non-static member function">; +def err_this_static_member_func : Error< + "'this' cannot be%select{| implicitly}0 used in a static member function " + "declaration">; def err_invalid_member_use_in_static_method : Error< "invalid use of member %0 in static member function">; def err_invalid_qualified_function_type : Error< @@ -3907,7 +3916,7 @@ def err_nosetter_property_incdec : Error def err_nogetter_property_compound_assignment : Error< "a getter method is needed to perform a compound assignment on a property">; def err_nogetter_property_incdec : Error< - "no getter method %1 for %select{increment|decrement} of property">; + "no getter method %1 for %select{increment|decrement}0 of property">; def error_no_subobject_property_setting : Error< "expression is not assignable">; def err_qualified_objc_access : Error< Modified: vendor/clang/dist/include/clang/Basic/ExceptionSpecificationType.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/ExceptionSpecificationType.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/ExceptionSpecificationType.h Thu May 3 16:53:59 2012 (r234973) @@ -16,7 +16,7 @@ namespace clang { -/// \brief The various types of exception specifications that exist in C++0x. +/// \brief The various types of exception specifications that exist in C++11. enum ExceptionSpecificationType { EST_None, ///< no exception specification EST_DynamicNone, ///< throw() @@ -24,7 +24,8 @@ enum ExceptionSpecificationType { EST_MSAny, ///< Microsoft throw(...) extension EST_BasicNoexcept, ///< noexcept EST_ComputedNoexcept, ///< noexcept(expression) - EST_Delayed ///< not known yet + EST_Delayed, ///< not known yet + EST_Uninstantiated ///< not instantiated yet }; inline bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType) { @@ -35,6 +36,19 @@ inline bool isNoexceptExceptionSpec(Exce return ESpecType == EST_BasicNoexcept || ESpecType == EST_ComputedNoexcept; } +/// \brief Possible results from evaluation of a noexcept expression. +enum CanThrowResult { + CT_Cannot, + CT_Dependent, + CT_Can +}; + +inline CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2) { + // CanThrowResult constants are ordered so that the maximum is the correct + // merge result. + return CT1 > CT2 ? CT1 : CT2; +} + } // end namespace clang #endif // LLVM_CLANG_BASIC_EXCEPTIONSPECIFICATIONTYPE_H Modified: vendor/clang/dist/include/clang/Basic/OnDiskHashTable.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/OnDiskHashTable.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/OnDiskHashTable.h Thu May 3 16:53:59 2012 (r234973) @@ -132,7 +132,7 @@ class OnDiskChainedHashTableGenerator { class Bucket { public: io::Offset off; - Item* head; + Item* head; unsigned length; Bucket() {} @@ -201,6 +201,7 @@ public: // Write out the number of items in the bucket. Emit16(out, B.length); + assert(B.length != 0 && "Bucket has a head but zero length?"); // Write out the entries in the bucket. for (Item *I = B.head; I ; I = I->next) { @@ -398,31 +399,30 @@ public: } key_iterator key_end() { return key_iterator(); } - /// \brief Iterates over all the entries in the table, returning - /// a key/data pair. - class item_iterator { + /// \brief Iterates over all the entries in the table, returning the data. + class data_iterator { const unsigned char* Ptr; unsigned NumItemsInBucketLeft; unsigned NumEntriesLeft; Info *InfoObj; public: - typedef std::pair value_type; + typedef data_type value_type; - item_iterator(const unsigned char* const Ptr, unsigned NumEntries, + data_iterator(const unsigned char* const Ptr, unsigned NumEntries, Info *InfoObj) : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries), InfoObj(InfoObj) { } - item_iterator() + data_iterator() : Ptr(0), NumItemsInBucketLeft(0), NumEntriesLeft(0), InfoObj(0) { } - bool operator==(const item_iterator& X) const { + bool operator==(const data_iterator& X) const { return X.NumEntriesLeft == NumEntriesLeft; } - bool operator!=(const item_iterator& X) const { + bool operator!=(const data_iterator& X) const { return X.NumEntriesLeft != NumEntriesLeft; } - item_iterator& operator++() { // Preincrement + data_iterator& operator++() { // Preincrement if (!NumItemsInBucketLeft) { // 'Items' starts with a 16-bit unsigned integer representing the // number of items in this bucket. @@ -438,8 +438,8 @@ public: --NumEntriesLeft; return *this; } - item_iterator operator++(int) { // Postincrement - item_iterator tmp = *this; ++*this; return tmp; + data_iterator operator++(int) { // Postincrement + data_iterator tmp = *this; ++*this; return tmp; } value_type operator*() const { @@ -454,15 +454,14 @@ public: // Read the key. const internal_key_type& Key = InfoObj->ReadKey(LocalPtr, L.first); - return std::make_pair(InfoObj->GetExternalKey(Key), - InfoObj->ReadData(Key, LocalPtr + L.first, L.second)); + return InfoObj->ReadData(Key, LocalPtr + L.first, L.second); } }; - item_iterator item_begin() { - return item_iterator(Base + 4, getNumEntries(), &InfoObj); + data_iterator data_begin() { + return data_iterator(Base + 4, getNumEntries(), &InfoObj); } - item_iterator item_end() { return item_iterator(); } + data_iterator data_end() { return data_iterator(); } Info &getInfoObj() { return InfoObj; } Modified: vendor/clang/dist/include/clang/Basic/StmtNodes.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/StmtNodes.td Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/StmtNodes.td Thu May 3 16:53:59 2012 (r234973) @@ -12,6 +12,7 @@ class DStmt def NullStmt : Stmt; def CompoundStmt : Stmt; def LabelStmt : Stmt; +def AttributedStmt : Stmt; def IfStmt : Stmt; def SwitchStmt : Stmt; def WhileStmt : Stmt; Modified: vendor/clang/dist/include/clang/Basic/TargetInfo.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/TargetInfo.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/TargetInfo.h Thu May 3 16:53:59 2012 (r234973) @@ -132,6 +132,11 @@ protected: IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType, WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType; + /// Flag whether the Objective-C built-in boolean type should be signed char. + /// Otherwise, when this flag is not set, the normal built-in boolean type is + /// used. + unsigned UseSignedCharForObjCBool : 1; + /// Control whether the alignment of bit-field types is respected when laying /// out structures. If true, then the alignment of the bit-field type will be /// used to (a) impact the alignment of the containing structure, and (b) @@ -299,6 +304,16 @@ public: return MCountName; } + /// useSignedCharForObjCBool - Check if the Objective-C built-in boolean + /// type should be signed char. Otherwise, if this returns false, the + /// normal built-in boolean type should also be used for Objective-C. + bool useSignedCharForObjCBool() const { + return UseSignedCharForObjCBool; + } + void noSignedCharForObjCBool() { + UseSignedCharForObjCBool = false; + } + /// useBitFieldTypeAlignment() - Check whether the alignment of bit-field /// types is respected when laying out structures. bool useBitFieldTypeAlignment() const { Modified: vendor/clang/dist/include/clang/Basic/TokenKinds.def ============================================================================== --- vendor/clang/dist/include/clang/Basic/TokenKinds.def Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Basic/TokenKinds.def Thu May 3 16:53:59 2012 (r234973) @@ -105,6 +105,7 @@ TOK(eod) // End of prepr // directive). TOK(code_completion) // Code completion marker TOK(cxx_defaultarg_end) // C++ default argument end marker +TOK(cxx_exceptspec_end) // C++ exception-specification end marker // C99 6.4.9: Comments. TOK(comment) // Comment (only in -E -C[C] mode) Modified: vendor/clang/dist/include/clang/Config/config.h.cmake ============================================================================== --- vendor/clang/dist/include/clang/Config/config.h.cmake Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Config/config.h.cmake Thu May 3 16:53:59 2012 (r234973) @@ -4,8 +4,11 @@ /* Relative directory for resource files */ #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}" -/* Directory where gcc is installed. */ -#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" - /* Directories clang will search for headers */ #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" + +/* Default to all compiler invocations for --sysroot=. */ +#define DEFAULT_SYSROOT "${DEFAULT_SYSROOT}" + +/* Directory where gcc is installed. */ +#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" Modified: vendor/clang/dist/include/clang/Config/config.h.in ============================================================================== --- vendor/clang/dist/include/clang/Config/config.h.in Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Config/config.h.in Thu May 3 16:53:59 2012 (r234973) @@ -9,13 +9,16 @@ /* Relative directory for resource files */ #undef CLANG_RESOURCE_DIR -/* Directory where gcc is installed. */ -#undef GCC_INSTALL_PREFIX - /* Directories clang will search for headers */ #undef C_INCLUDE_DIRS /* Linker version detected at compile time. */ #undef HOST_LINK_VERSION +/* Default to all compiler invocations for --sysroot=. */ +#undef DEFAULT_SYSROOT + +/* Directory where gcc is installed. */ +#undef GCC_INSTALL_PREFIX + #endif Modified: vendor/clang/dist/include/clang/Driver/CC1Options.td ============================================================================== --- vendor/clang/dist/include/clang/Driver/CC1Options.td Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Driver/CC1Options.td Thu May 3 16:53:59 2012 (r234973) @@ -428,9 +428,6 @@ def ast_view : Flag<"-ast-view">, HelpText<"Build ASTs and view them with GraphViz">; def print_decl_contexts : Flag<"-print-decl-contexts">, HelpText<"Print DeclContexts and their Decls">; -def pubnames_dump : Flag<"-pubnames-dump">, - HelpText<"Print all of the public (global) names in the source, e.g., the " - "names of all global declarations and macros">; def emit_module : Flag<"-emit-module">, HelpText<"Generate pre-compiled module file from a module map">; def emit_pth : Flag<"-emit-pth">, Modified: vendor/clang/dist/include/clang/Driver/Compilation.h ============================================================================== --- vendor/clang/dist/include/clang/Driver/Compilation.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Driver/Compilation.h Thu May 3 16:53:59 2012 (r234973) @@ -92,6 +92,9 @@ public: return FailureResultFiles; } + /// Returns the sysroot path. + StringRef getSysRoot() const; + /// getArgsForToolChain - Return the derived argument list for the /// tool chain \arg TC (or the default tool chain, if TC is not /// specified). Modified: vendor/clang/dist/include/clang/Frontend/ASTUnit.h ============================================================================== --- vendor/clang/dist/include/clang/Frontend/ASTUnit.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Frontend/ASTUnit.h Thu May 3 16:53:59 2012 (r234973) @@ -14,7 +14,6 @@ #ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H #define LLVM_CLANG_FRONTEND_ASTUNIT_H -#include "clang/Index/ASTLocation.h" #include "clang/Serialization/ASTBitCodes.h" #include "clang/Sema/Sema.h" #include "clang/Sema/CodeCompleteConsumer.h" @@ -57,8 +56,6 @@ class SourceManager; class TargetInfo; class ASTFrontendAction; -using namespace idx; - /// \brief Utility class for loading a ASTContext from an AST file. /// class ASTUnit : public ModuleLoader { @@ -134,9 +131,6 @@ private: /// The name of the original source file used to generate this ASTUnit. std::string OriginalSourceFile; - // Critical optimization when using clang_getCursor(). - ASTLocation LastLoc; - /// \brief The set of diagnostics produced when creating the preamble. SmallVector PreambleDiagnostics; @@ -474,10 +468,6 @@ public: bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; } void setOwnsRemappedFileBuffers(bool val) { OwnsRemappedFileBuffers = val; } - void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; } - ASTLocation getLastASTLocation() const { return LastLoc; } - - StringRef getMainFileName() const; typedef std::vector::iterator top_level_iterator; Modified: vendor/clang/dist/include/clang/Frontend/FrontendActions.h ============================================================================== --- vendor/clang/dist/include/clang/Frontend/FrontendActions.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Frontend/FrontendActions.h Thu May 3 16:53:59 2012 (r234973) @@ -173,15 +173,6 @@ protected: virtual bool usesPreprocessorOnly() const { return true; } }; -class PubnamesDumpAction : public ASTFrontendAction { -protected: - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile); - -public: - virtual bool hasCodeCompletionSupport() const { return false; } -}; - //===----------------------------------------------------------------------===// // Preprocessor Actions //===----------------------------------------------------------------------===// Modified: vendor/clang/dist/include/clang/Frontend/FrontendOptions.h ============================================================================== --- vendor/clang/dist/include/clang/Frontend/FrontendOptions.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Frontend/FrontendOptions.h Thu May 3 16:53:59 2012 (r234973) @@ -42,7 +42,6 @@ namespace frontend { PrintDeclContext, ///< Print DeclContext and their Decls. PrintPreamble, ///< Print the "preamble" of the input file PrintPreprocessedInput, ///< -E mode. - PubnamesDump, ///< Print all of the "public" names in the source. RewriteMacros, ///< Expand macros but not #includes. RewriteObjC, ///< ObjC->C Rewriter. RewriteTest, ///< Rewriter playground Modified: vendor/clang/dist/include/clang/Frontend/TextDiagnostic.h ============================================================================== --- vendor/clang/dist/include/clang/Frontend/TextDiagnostic.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Frontend/TextDiagnostic.h Thu May 3 16:53:59 2012 (r234973) @@ -18,6 +18,8 @@ #include "clang/Frontend/DiagnosticRenderer.h" +struct SourceColumnMap; + namespace clang { /// \brief Class to encapsulate the logic for formatting and printing a textual @@ -103,15 +105,16 @@ private: SmallVectorImpl& Ranges, ArrayRef Hints); + void emitSnippet(StringRef SourceLine); + void highlightRange(const CharSourceRange &R, unsigned LineNo, FileID FID, - const std::string &SourceLine, + const SourceColumnMap &map, std::string &CaretLine); + std::string buildFixItInsertionLine(unsigned LineNo, - const char *LineStart, - const char *LineEnd, + const SourceColumnMap &map, ArrayRef Hints); - void expandTabs(std::string &SourceLine, std::string &CaretLine); void emitParseableFixits(ArrayRef Hints); }; Modified: vendor/clang/dist/include/clang/Parse/Parser.h ============================================================================== --- vendor/clang/dist/include/clang/Parse/Parser.h Thu May 3 16:52:07 2012 (r234972) +++ vendor/clang/dist/include/clang/Parse/Parser.h Thu May 3 16:53:59 2012 (r234973) @@ -15,7 +15,6 @@ #define LLVM_CLANG_PARSE_PARSER_H #include "clang/Basic/Specifiers.h" -#include "clang/Basic/DelayedCleanupPool.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/CodeCompletionHandler.h" #include "clang/Sema/Sema.h" @@ -192,9 +191,9 @@ class Parser : public CodeCompletionHand /// Factory object for creating AttributeList objects. AttributeFactory AttrFactory; - /// \brief Gathers and cleans up objects when parsing of a top-level - /// declaration is finished. - DelayedCleanupPool TopLevelDeclCleanupPool; + /// \brief Gathers and cleans up TemplateIdAnnotations when parsing of a + /// top-level declaration is finished. + SmallVector TemplateIds; IdentifierInfo *getSEHExceptKeyword(); @@ -568,9 +567,7 @@ private: const char *&PrevSpec, unsigned &DiagID, bool &isInvalid); - /// \brief Get the TemplateIdAnnotation from the token and put it in the - /// cleanup pool so that it gets destroyed when parsing the current top level - /// declaration is finished. + /// \brief Get the TemplateIdAnnotation from the token. TemplateIdAnnotation *takeTemplateIdAnnotation(const Token &tok); /// TentativeParsingAction - An object that is used as a kind of "tentative @@ -858,7 +855,7 @@ private: /// argument (C++ [class.mem]p2). struct LateParsedMethodDeclaration : public LateParsedDeclaration { explicit LateParsedMethodDeclaration(Parser *P, Decl *M) - : Self(P), Method(M), TemplateScope(false) { } + : Self(P), Method(M), TemplateScope(false), ExceptionSpecTokens(0) { } virtual void ParseLexedMethodDeclarations(); @@ -878,6 +875,10 @@ private: /// method will be stored so that they can be reintroduced into /// scope at the appropriate times. SmallVector DefaultArgs; + + /// \brief The set of tokens that make up an exception-specification that + /// has not yet been parsed. + CachedTokens *ExceptionSpecTokens; }; /// LateParsedMemberInitializer - An initializer for a non-static class data @@ -1420,11 +1421,13 @@ private: // C++ 15: C++ Throw Expression ExprResult ParseThrowExpression(); - ExceptionSpecificationType MaybeParseExceptionSpecification( + ExceptionSpecificationType tryParseExceptionSpecification( + bool Delayed, SourceRange &SpecificationRange, SmallVectorImpl &DynamicExceptions, SmallVectorImpl &DynamicExceptionRanges, - ExprResult &NoexceptExpr); + ExprResult &NoexceptExpr, + CachedTokens *&ExceptionSpecTokens); // EndLoc is filled with the location of the last token of the specification. ExceptionSpecificationType ParseDynamicExceptionSpecification( @@ -1517,42 +1520,40 @@ private: //===--------------------------------------------------------------------===// // C99 6.8: Statements and Blocks. - StmtResult ParseStatement(SourceLocation *TrailingElseLoc = NULL) { + StmtResult ParseStatement(SourceLocation *TrailingElseLoc = 0) { StmtVector Stmts(Actions); return ParseStatementOrDeclaration(Stmts, true, TrailingElseLoc); } - StmtResult ParseStatementOrDeclaration(StmtVector& Stmts, + StmtResult ParseStatementOrDeclaration(StmtVector &Stmts, + bool OnlyStatement, + SourceLocation *TrailingElseLoc = 0); + StmtResult ParseStatementOrDeclarationAfterAttributes( + StmtVector &Stmts, bool OnlyStatement, - SourceLocation *TrailingElseLoc = NULL); - StmtResult ParseExprStatement(ParsedAttributes &Attrs); - StmtResult ParseLabeledStatement(ParsedAttributes &Attr); - StmtResult ParseCaseStatement(ParsedAttributes &Attr, - bool MissingCase = false, + SourceLocation *TrailingElseLoc, + ParsedAttributesWithRange &Attrs); + StmtResult ParseExprStatement(); + StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs); + StmtResult ParseCaseStatement(bool MissingCase = false, ExprResult Expr = ExprResult()); - StmtResult ParseDefaultStatement(ParsedAttributes &Attr); - StmtResult ParseCompoundStatement(ParsedAttributes &Attr, - bool isStmtExpr = false); - StmtResult ParseCompoundStatement(ParsedAttributes &Attr, - bool isStmtExpr, + StmtResult ParseDefaultStatement(); + StmtResult ParseCompoundStatement(bool isStmtExpr = false); + StmtResult ParseCompoundStatement(bool isStmtExpr, unsigned ScopeFlags); StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); bool ParseParenExprOrCondition(ExprResult &ExprResult, Decl *&DeclResult, SourceLocation Loc, bool ConvertToBoolean); - StmtResult ParseIfStatement(ParsedAttributes &Attr, - SourceLocation *TrailingElseLoc); - StmtResult ParseSwitchStatement(ParsedAttributes &Attr, - SourceLocation *TrailingElseLoc); - StmtResult ParseWhileStatement(ParsedAttributes &Attr, - SourceLocation *TrailingElseLoc); - StmtResult ParseDoStatement(ParsedAttributes &Attr); - StmtResult ParseForStatement(ParsedAttributes &Attr, - SourceLocation *TrailingElseLoc); - StmtResult ParseGotoStatement(ParsedAttributes &Attr); - StmtResult ParseContinueStatement(ParsedAttributes &Attr); - StmtResult ParseBreakStatement(ParsedAttributes &Attr); - StmtResult ParseReturnStatement(ParsedAttributes &Attr); + StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); + StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); + StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); + StmtResult ParseDoStatement(); + StmtResult ParseForStatement(SourceLocation *TrailingElseLoc); + StmtResult ParseGotoStatement(); + StmtResult ParseContinueStatement(); + StmtResult ParseBreakStatement(); + StmtResult ParseReturnStatement(); StmtResult ParseAsmStatement(bool &msAsm); StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc); @@ -1586,7 +1587,7 @@ private: /// \brief The behavior of this __if_exists or __if_not_exists block /// should. IfExistsBehavior Behavior; -}; + }; bool ParseMicrosoftIfExistsCondition(IfExistsCondition& Result); void ParseMicrosoftIfExistsStatement(StmtVector &Stmts); @@ -1602,14 +1603,14 @@ private: //===--------------------------------------------------------------------===// // C++ 6: Statements and Blocks - StmtResult ParseCXXTryBlock(ParsedAttributes &Attr); + StmtResult ParseCXXTryBlock(); StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc); StmtResult ParseCXXCatchBlock(); //===--------------------------------------------------------------------===// // MS: SEH Statements and Blocks - StmtResult ParseSEHTryBlock(ParsedAttributes &Attr); + StmtResult ParseSEHTryBlock(); StmtResult ParseSEHTryBlockCommon(SourceLocation Loc); StmtResult ParseSEHExceptBlock(SourceLocation Loc); StmtResult ParseSEHFinallyBlock(SourceLocation Loc); @@ -1883,6 +1884,7 @@ private: void ProhibitAttributes(ParsedAttributesWithRange &attrs) { if (!attrs.Range.isValid()) return; DiagnoseProhibitedAttributes(attrs); + attrs.clear(); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 16:54:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1D0D0106573B; Thu, 3 May 2012 16:54:33 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E1A7A8FC14; Thu, 3 May 2012 16:54:32 +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 q43GsWqI053053; Thu, 3 May 2012 16:54:32 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43GsWTr053052; Thu, 3 May 2012 16:54:32 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205031654.q43GsWTr053052@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 16:54:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234974 - vendor/clang/clang-release_31-r155985 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:54:33 -0000 Author: dim Date: Thu May 3 16:54:32 2012 New Revision: 234974 URL: http://svn.freebsd.org/changeset/base/234974 Log: Tag clang release_31 branch r155985. Added: vendor/clang/clang-release_31-r155985/ - copied from r234973, vendor/clang/dist/ From owner-svn-src-all@FreeBSD.ORG Thu May 3 17:08:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4E46410656B5; Thu, 3 May 2012 17:08:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 398218FC15; Thu, 3 May 2012 17:08:41 +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 q43H8fQO053626; Thu, 3 May 2012 17:08:41 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43H8fax053623; Thu, 3 May 2012 17:08:41 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031708.q43H8fax053623@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 17:08:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234975 - head/tools/tools/netmap X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 17:08:41 -0000 Author: luigi Date: Thu May 3 17:08:40 2012 New Revision: 234975 URL: http://svn.freebsd.org/changeset/base/234975 Log: add support for pcap receive statistics (used by net-mgmt/darkstat) Modified: head/tools/tools/netmap/README head/tools/tools/netmap/pcap.c Modified: head/tools/tools/netmap/README ============================================================================== --- head/tools/tools/netmap/README Thu May 3 16:54:32 2012 (r234974) +++ head/tools/tools/netmap/README Thu May 3 17:08:40 2012 (r234975) @@ -20,3 +20,4 @@ BSD netmap --------------------------------------------------- 0.77 3.82 ports/trafshow (version 5) 0.94 7.7 net-mgmt/ipcad (ip accounting daemon) + 0.9 5.0 net-mgmt/darkstat (ip accounting + graphing) Modified: head/tools/tools/netmap/pcap.c ============================================================================== --- head/tools/tools/netmap/pcap.c Thu May 3 16:54:32 2012 (r234974) +++ head/tools/tools/netmap/pcap.c Thu May 3 17:08:40 2012 (r234975) @@ -154,6 +154,8 @@ int pcap_setdirection(pcap_t *p, pcap_di char *pcap_lookupdev(char *errbuf); int pcap_inject(pcap_t *p, const void *buf, size_t size); int pcap_fileno(pcap_t *p); +const char *pcap_lib_version(void); + struct eproto { const char *s; @@ -318,6 +320,11 @@ struct eproto eproto_db[] = { }; +const char *pcap_lib_version(void) +{ + return pcap_version; +} + int pcap_findalldevs(pcap_if_t **alldevsp, __unused char *errbuf) { @@ -532,10 +539,8 @@ pcap_stats(pcap_t *p, struct pcap_stat * struct my_ring *me = p; ND(""); - me->st.ps_recv += 10; *ps = me->st; - sprintf(me->msg, "stats not supported"); - return -1; + return 0; /* accumulate from pcap_dispatch() */ }; char * @@ -670,6 +675,7 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h got++; } } + me->st.ps_recv += got; return got; } From owner-svn-src-all@FreeBSD.ORG Thu May 3 17:44:08 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 76AC71065697; Thu, 3 May 2012 17:44:08 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5158FC08; Thu, 3 May 2012 17:44:08 +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 q43Hi8oA054902; Thu, 3 May 2012 17:44:08 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Hi8fj054896; Thu, 3 May 2012 17:44:08 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031744.q43Hi8fj054896@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 17:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234976 - in head/contrib/libc++: include src X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 17:44:08 -0000 Author: theraven Date: Thu May 3 17:44:07 2012 New Revision: 234976 URL: http://svn.freebsd.org/changeset/base/234976 Log: Import new version of libc++. Among other improvements, this comes with an header that works with clang 3.1 (and, importantly, the pre-3.1 snapshot currently in head) Modified: head/contrib/libc++/include/__config head/contrib/libc++/include/__tuple head/contrib/libc++/include/algorithm head/contrib/libc++/include/atomic head/contrib/libc++/include/cmath head/contrib/libc++/include/limits head/contrib/libc++/include/memory head/contrib/libc++/include/random head/contrib/libc++/include/system_error head/contrib/libc++/include/tuple head/contrib/libc++/include/type_traits head/contrib/libc++/include/utility head/contrib/libc++/src/iostream.cpp head/contrib/libc++/src/stdexcept.cpp head/contrib/libc++/src/utility.cpp Directory Properties: head/contrib/libc++/ (props changed) Modified: head/contrib/libc++/include/__config ============================================================================== --- head/contrib/libc++/include/__config Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/__config Thu May 3 17:44:07 2012 (r234976) @@ -384,7 +384,9 @@ template struct __static_asse #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR -#define constexpr const +#define _LIBCPP_CONSTEXPR +#else +#define _LIBCPP_CONSTEXPR constexpr #endif #ifndef __has_feature Modified: head/contrib/libc++/include/__tuple ============================================================================== --- head/contrib/libc++/include/__tuple Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/__tuple Thu May 3 17:44:07 2012 (r234976) @@ -216,7 +216,7 @@ struct __tuple_convertible_imp : public template struct __tuple_convertible_imp, __tuple_types<_Up0, _Up...> > : public integral_constant::value && + is_convertible<_Tp0, _Up0>::value && __tuple_convertible_imp, __tuple_types<_Up...> >::value> {}; template <> @@ -235,6 +235,33 @@ struct __tuple_convertible<_Tp, _Up, tru typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> {}; +// __tuple_constructible + +template +struct __tuple_constructible_imp : public false_type {}; + +template +struct __tuple_constructible_imp, __tuple_types<_Up0, _Up...> > + : public integral_constant::value && + __tuple_constructible_imp, __tuple_types<_Up...> >::value> {}; + +template <> +struct __tuple_constructible_imp, __tuple_types<> > + : public true_type {}; + +template ::type>::value, + bool = __tuple_like<_Up>::value> +struct __tuple_constructible + : public false_type {}; + +template +struct __tuple_constructible<_Tp, _Up, true, true> + : public __tuple_constructible_imp::type>::value == + tuple_size<_Up>::value, + typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> +{}; + // __tuple_assignable template Modified: head/contrib/libc++/include/algorithm ============================================================================== --- head/contrib/libc++/include/algorithm Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/algorithm Thu May 3 17:44:07 2012 (r234976) @@ -2508,11 +2508,16 @@ private: _Engine_result_type __mask0_; _Engine_result_type __mask1_; +#ifdef _LIBCPP_HAS_NO_CONSTEXPR static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min - + _Working_result_type(1); - static const size_t __m = __log2<_Working_result_type, _Rp>::value; - static const size_t _WDt = numeric_limits<_Working_result_type>::digits; - static const size_t _EDt = numeric_limits<_Engine_result_type>::digits; + + _Working_result_type(1); +#else + static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() + + _Working_result_type(1); +#endif + static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; + static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; + static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; public: // constructors and seeding functions @@ -2712,8 +2717,8 @@ public: result_type operator()(); - static constexpr result_type min() {return _Min;} - static constexpr result_type max() {return _Max;} + static _LIBCPP_CONSTEXPR result_type min() {return _Min;} + static _LIBCPP_CONSTEXPR result_type max() {return _Max;} friend __rs_default __rs_get(); }; Modified: head/contrib/libc++/include/atomic ============================================================================== --- head/contrib/libc++/include/atomic Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/atomic Thu May 3 17:44:07 2012 (r234976) @@ -29,7 +29,7 @@ typedef enum memory_order memory_order_seq_cst // store-release load-acquire } memory_order; -template T kill_dependency(T y); +template T kill_dependency(T y) noexcept; // lock-free property @@ -46,40 +46,40 @@ template T kill_dependency(T y typedef struct atomic_flag { - bool test_and_set(memory_order m = memory_order_seq_cst) volatile; - bool test_and_set(memory_order m = memory_order_seq_cst); - void clear(memory_order m = memory_order_seq_cst) volatile; - void clear(memory_order m = memory_order_seq_cst); - atomic_flag() = default; + bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; + bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; + void clear(memory_order m = memory_order_seq_cst) volatile noexcept; + void clear(memory_order m = memory_order_seq_cst) noexcept; + atomic_flag() noexcept = default; atomic_flag(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) volatile = delete; } atomic_flag; bool - atomic_flag_test_and_set(volatile atomic_flag* obj); + atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; bool - atomic_flag_test_and_set(atomic_flag* obj); + atomic_flag_test_and_set(atomic_flag* obj) noexcept; bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, - memory_order m); + memory_order m) noexcept; bool - atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m); + atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear(volatile atomic_flag* obj); + atomic_flag_clear(volatile atomic_flag* obj) noexcept; void - atomic_flag_clear(atomic_flag* obj); + atomic_flag_clear(atomic_flag* obj) noexcept; void - atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear_explicit(atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; #define ATOMIC_FLAG_INIT see below #define ATOMIC_VAR_INIT(value) see below @@ -87,388 +87,388 @@ void template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T desr, memory_order m = memory_order_seq_cst) volatile; - void store(T desr, memory_order m = memory_order_seq_cst); - T load(memory_order m = memory_order_seq_cst) const volatile; - T load(memory_order m = memory_order_seq_cst) const; - operator T() const volatile; - operator T() const; - T exchange(T desr, memory_order m = memory_order_seq_cst) volatile; - T exchange(T desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) noexcept; + T load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T load(memory_order m = memory_order_seq_cst) const noexcept; + operator T() const volatile noexcept; + operator T() const noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order s, memory_order f) volatile; - bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f); + memory_order s, memory_order f) volatile noexcept; + bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T desr); + atomic() noexcept = default; + constexpr atomic(T desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T operator=(T) volatile; - T operator=(T); + T operator=(T) volatile noexcept; + T operator=(T) noexcept; }; template <> struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(integral desr, memory_order m = memory_order_seq_cst) volatile; - void store(integral desr, memory_order m = memory_order_seq_cst); - integral load(memory_order m = memory_order_seq_cst) const volatile; - integral load(memory_order m = memory_order_seq_cst) const; - operator integral() const volatile; - operator integral() const; + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; + integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; + integral load(memory_order m = memory_order_seq_cst) const noexcept; + operator integral() const volatile noexcept; + operator integral() const noexcept; integral exchange(integral desr, - memory_order m = memory_order_seq_cst) volatile; - integral exchange(integral desr, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) volatile noexcept; + integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; integral - fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_add(integral op, memory_order m = memory_order_seq_cst); + fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_sub(integral op, memory_order m = memory_order_seq_cst); + fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_and(integral op, memory_order m = memory_order_seq_cst); + fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_or(integral op, memory_order m = memory_order_seq_cst); + fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_xor(integral op, memory_order m = memory_order_seq_cst); + fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(integral desr); + atomic() noexcept = default; + constexpr atomic(integral desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - integral operator=(integral desr) volatile; - integral operator=(integral desr); + integral operator=(integral desr) volatile noexcept; + integral operator=(integral desr) noexcept; - integral operator++(int) volatile; - integral operator++(int); - integral operator--(int) volatile; - integral operator--(int); - integral operator++() volatile; - integral operator++(); - integral operator--() volatile; - integral operator--(); - integral operator+=(integral op) volatile; - integral operator+=(integral op); - integral operator-=(integral op) volatile; - integral operator-=(integral op); - integral operator&=(integral op) volatile; - integral operator&=(integral op); - integral operator|=(integral op) volatile; - integral operator|=(integral op); - integral operator^=(integral op) volatile; - integral operator^=(integral op); + integral operator++(int) volatile noexcept; + integral operator++(int) noexcept; + integral operator--(int) volatile noexcept; + integral operator--(int) noexcept; + integral operator++() volatile noexcept; + integral operator++() noexcept; + integral operator--() volatile noexcept; + integral operator--() noexcept; + integral operator+=(integral op) volatile noexcept; + integral operator+=(integral op) noexcept; + integral operator-=(integral op) volatile noexcept; + integral operator-=(integral op) noexcept; + integral operator&=(integral op) volatile noexcept; + integral operator&=(integral op) noexcept; + integral operator|=(integral op) volatile noexcept; + integral operator|=(integral op) noexcept; + integral operator^=(integral op) volatile noexcept; + integral operator^=(integral op) noexcept; }; template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T* desr, memory_order m = memory_order_seq_cst) volatile; - void store(T* desr, memory_order m = memory_order_seq_cst); - T* load(memory_order m = memory_order_seq_cst) const volatile; - T* load(memory_order m = memory_order_seq_cst) const; - operator T*() const volatile; - operator T*() const; - T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile; - T* exchange(T* desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; + T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T* load(memory_order m = memory_order_seq_cst) const noexcept; + operator T*() const volatile noexcept; + operator T*() const noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst); - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T* desr); + atomic() noexcept = default; + constexpr atomic(T* desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T* operator=(T*) volatile; - T* operator=(T*); - T* operator++(int) volatile; - T* operator++(int); - T* operator--(int) volatile; - T* operator--(int); - T* operator++() volatile; - T* operator++(); - T* operator--() volatile; - T* operator--(); - T* operator+=(ptrdiff_t op) volatile; - T* operator+=(ptrdiff_t op); - T* operator-=(ptrdiff_t op) volatile; - T* operator-=(ptrdiff_t op); + T* operator=(T*) volatile noexcept; + T* operator=(T*) noexcept; + T* operator++(int) volatile noexcept; + T* operator++(int) noexcept; + T* operator--(int) volatile noexcept; + T* operator--(int) noexcept; + T* operator++() volatile noexcept; + T* operator++() noexcept; + T* operator--() volatile noexcept; + T* operator--() noexcept; + T* operator+=(ptrdiff_t op) volatile noexcept; + T* operator+=(ptrdiff_t op) noexcept; + T* operator-=(ptrdiff_t op) volatile noexcept; + T* operator-=(ptrdiff_t op) noexcept; }; template bool - atomic_is_lock_free(const volatile atomic* obj); + atomic_is_lock_free(const volatile atomic* obj) noexcept; template bool - atomic_is_lock_free(const atomic* obj); + atomic_is_lock_free(const atomic* obj) noexcept; template void - atomic_init(volatile atomic* obj, T desr); + atomic_init(volatile atomic* obj, T desr) noexcept; template void - atomic_init(atomic* obj, T desr); + atomic_init(atomic* obj, T desr) noexcept; template void - atomic_store(volatile atomic* obj, T desr); + atomic_store(volatile atomic* obj, T desr) noexcept; template void - atomic_store(atomic* obj, T desr); + atomic_store(atomic* obj, T desr) noexcept; template void - atomic_store_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_store_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template void - atomic_store_explicit(atomic* obj, T desr, memory_order m); + atomic_store_explicit(atomic* obj, T desr, memory_order m) noexcept; template T - atomic_load(const volatile atomic* obj); + atomic_load(const volatile atomic* obj) noexcept; template T - atomic_load(const atomic* obj); + atomic_load(const atomic* obj) noexcept; template T - atomic_load_explicit(const volatile atomic* obj, memory_order m); + atomic_load_explicit(const volatile atomic* obj, memory_order m) noexcept; template T - atomic_load_explicit(const atomic* obj, memory_order m); + atomic_load_explicit(const atomic* obj, memory_order m) noexcept; template T - atomic_exchange(volatile atomic* obj, T desr); + atomic_exchange(volatile atomic* obj, T desr) noexcept; template T - atomic_exchange(atomic* obj, T desr); + atomic_exchange(atomic* obj, T desr) noexcept; template T - atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template T - atomic_exchange_explicit(atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(atomic* obj, T desr, memory_order m) noexcept; template bool - atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_weak(atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_weak_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_weak_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template Integral - atomic_fetch_add(volatile atomic* obj, Integral op); + atomic_fetch_add(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_add(atomic* obj, Integral op); + atomic_fetch_add(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_add_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_add_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_sub(volatile atomic* obj, Integral op); + atomic_fetch_sub(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_sub(atomic* obj, Integral op); + atomic_fetch_sub(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_sub_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_sub_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_and(volatile atomic* obj, Integral op); + atomic_fetch_and(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_and(atomic* obj, Integral op); + atomic_fetch_and(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_and_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_and_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_or(volatile atomic* obj, Integral op); + atomic_fetch_or(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_or(atomic* obj, Integral op); + atomic_fetch_or(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_or_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_or_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_xor(volatile atomic* obj, Integral op); + atomic_fetch_xor(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_xor(atomic* obj, Integral op); + atomic_fetch_xor(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_xor_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_xor_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_add(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_add(atomic* obj, ptrdiff_t op); + atomic_fetch_add(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* - atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_sub(atomic* obj, ptrdiff_t op); + atomic_fetch_sub(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; // Atomics for standard typedef types @@ -514,8 +514,8 @@ typedef atomic atomic_uintmax // fences -void atomic_thread_fence(memory_order m); -void atomic_signal_fence(memory_order m); +void atomic_thread_fence(memory_order m) noexcept; +void atomic_signal_fence(memory_order m) noexcept; } // std @@ -545,7 +545,7 @@ typedef enum memory_order template inline _LIBCPP_INLINE_VISIBILITY _Tp -kill_dependency(_Tp __y) +kill_dependency(_Tp __y) _NOEXCEPT { return __y; } @@ -558,70 +558,70 @@ struct __atomic_base // false _Atomic(_Tp) __a_; _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const volatile - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const volatile _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const volatile - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const volatile {return load();} + operator _Tp() const volatile _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const {return load();} + operator _Tp() const _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) { __atomic_store(&__a_, __d, memory_order_seq_cst); } + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; @@ -642,77 +642,77 @@ struct __atomic_base<_Tp, true> { typedef __atomic_base<_Tp, false> __base; _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) volatile {return fetch_add(_Tp(1));} + _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) {return fetch_add(_Tp(1));} + _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) volatile {return fetch_sub(_Tp(1));} + _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) {return fetch_sub(_Tp(1));} + _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() volatile {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() volatile {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) volatile {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) volatile {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) volatile {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) volatile {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) volatile {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} }; // atomic @@ -723,15 +723,15 @@ struct atomic { typedef __atomic_base<_Tp> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) volatile + _Tp operator=(_Tp __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) + _Tp operator=(_Tp __d) _NOEXCEPT {__base::store(__d); return __d;} }; @@ -743,56 +743,56 @@ struct atomic<_Tp*> { typedef __atomic_base<_Tp*> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp* __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) volatile + _Tp* operator=(_Tp* __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) + _Tp* operator=(_Tp* __d) _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) - volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 19:55:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54D19106566B; Thu, 3 May 2012 19:55:37 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D9A48FC16; Thu, 3 May 2012 19:55:37 +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 q43JtbdG060300; Thu, 3 May 2012 19:55:37 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Jtaht060293; Thu, 3 May 2012 19:55:36 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031955.q43Jtaht060293@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 19:55:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234978 - in stable/9: etc/mtree etc/root share/examples share/examples/csh share/skel X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 19:55:37 -0000 Author: eadler Date: Thu May 3 19:55:36 2012 New Revision: 234978 URL: http://svn.freebsd.org/changeset/base/234978 Log: MFC r233429,r233435,r233437,r234077,r234133,r234135,r234159,r234823: A variety of changes that make the default shell easier to use. Approved by: cperciva (implicit) Added: stable/9/share/examples/csh/ - copied from r233429, head/share/examples/csh/ Modified: stable/9/etc/mtree/BSD.usr.dist stable/9/etc/root/dot.cshrc stable/9/share/examples/Makefile stable/9/share/examples/csh/dot.cshrc stable/9/share/skel/dot.cshrc Directory Properties: stable/9/etc/ (props changed) stable/9/share/examples/ (props changed) stable/9/share/skel/ (props changed) Modified: stable/9/etc/mtree/BSD.usr.dist ============================================================================== --- stable/9/etc/mtree/BSD.usr.dist Thu May 3 18:12:01 2012 (r234977) +++ stable/9/etc/mtree/BSD.usr.dist Thu May 3 19:55:36 2012 (r234978) @@ -209,6 +209,8 @@ .. bootforth .. + csh + .. cvs contrib .. Modified: stable/9/etc/root/dot.cshrc ============================================================================== --- stable/9/etc/root/dot.cshrc Thu May 3 18:12:01 2012 (r234977) +++ stable/9/etc/root/dot.cshrc Thu May 3 19:55:36 2012 (r234978) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,19 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up - set prompt = "`/bin/hostname -s`# " + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif Modified: stable/9/share/examples/Makefile ============================================================================== --- stable/9/share/examples/Makefile Thu May 3 18:12:01 2012 (r234977) +++ stable/9/share/examples/Makefile Thu May 3 19:55:36 2012 (r234978) @@ -8,6 +8,7 @@ LDIRS= BSD_daemon \ FreeBSD_version \ IPv6 \ bootforth \ + csh \ cvsup \ diskless \ drivers \ @@ -49,6 +50,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ bootforth/menu.4th \ bootforth/menuconf.4th \ bootforth/screen.4th \ + csh/dot.cshrc \ cvsup/README \ cvsup/cvs-supfile \ cvsup/doc-supfile \ Modified: stable/9/share/examples/csh/dot.cshrc ============================================================================== --- head/share/examples/csh/dot.cshrc Sat Mar 24 18:43:18 2012 (r233429) +++ stable/9/share/examples/csh/dot.cshrc Thu May 3 19:55:36 2012 (r234978) @@ -21,19 +21,20 @@ bindkey "^[[3~" delete-char-or-list-or-e # Make the Ins key work bindkey "\e[2~" overwrite-mode +# Aliases used for completions +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1' +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' + # Some common completions complete chown 'p/1/u/' -complete man 'C/*/c/' -complete service 'n/*/`service -l`/' -complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete dd 'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/=' +complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' +complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' complete kldunload 'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name` @' complete make 'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@' +complete man 'C/*/c/' complete pkg_delete 'c/-/(i v D n p d f G x X r)/' 'n@*@`ls /var/db/pkg`@' -complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed svar/db/pkg/%%`@" -complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' -complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1A -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' +complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed s%/var/db/pkg/%%`@' complete portmaster 'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles \ clean-packages delete-build-only delete-packages force-config help \ index index-first index-only list-origins local-packagedir no-confirm \ @@ -41,6 +42,8 @@ complete portmaster 'c/--/(always-fetc packages-local packages-only show-work update-if-newer version)/' \ 'c/-/(a b B C d D e f F g G h H i l L m n o p r R s t u v w x)/' \ 'n@*@`_PKGS_PkGs_PoRtS_`@' +complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete sysctl 'n/*/`sysctl -Na`/' # Alternate prompts set prompt = '#' @@ -56,5 +59,8 @@ set ellipsis alias ll ls -lAhG alias ls ls -G +# Color on many system utilities +setenv CLICOLOR 1 + # other autolist options set autolist = TAB Modified: stable/9/share/skel/dot.cshrc ============================================================================== --- stable/9/share/skel/dot.cshrc Thu May 3 18:12:01 2012 (r234977) +++ stable/9/share/skel/dot.cshrc Thu May 3 19:55:36 2012 (r234978) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,18 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif From owner-svn-src-all@FreeBSD.ORG Thu May 3 19:56:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 12BE0106564A; Thu, 3 May 2012 19:56:18 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EFD698FC15; Thu, 3 May 2012 19:56: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 q43JuHf9060365; Thu, 3 May 2012 19:56:17 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43JuH41060359; Thu, 3 May 2012 19:56:17 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031956.q43JuH41060359@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 19:56:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234979 - in stable/8: etc/mtree etc/root share/examples share/examples/csh share/skel X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 19:56:18 -0000 Author: eadler Date: Thu May 3 19:56:17 2012 New Revision: 234979 URL: http://svn.freebsd.org/changeset/base/234979 Log: MFC r233429,r233435,r233437,r234077,r234133,r234135,r234159,r234823: A variety of changes that make the default shell easier to use. Approved by: cperciva (implicit) Added: stable/8/share/examples/csh/ - copied from r233429, head/share/examples/csh/ Modified: stable/8/etc/mtree/BSD.usr.dist stable/8/etc/root/dot.cshrc stable/8/share/examples/Makefile stable/8/share/examples/csh/dot.cshrc stable/8/share/skel/dot.cshrc Directory Properties: stable/8/etc/ (props changed) stable/8/share/examples/ (props changed) stable/8/share/skel/ (props changed) Modified: stable/8/etc/mtree/BSD.usr.dist ============================================================================== --- stable/8/etc/mtree/BSD.usr.dist Thu May 3 19:55:36 2012 (r234978) +++ stable/8/etc/mtree/BSD.usr.dist Thu May 3 19:56:17 2012 (r234979) @@ -193,6 +193,8 @@ .. bootforth .. + csh + .. cvs contrib .. Modified: stable/8/etc/root/dot.cshrc ============================================================================== --- stable/8/etc/root/dot.cshrc Thu May 3 19:55:36 2012 (r234978) +++ stable/8/etc/root/dot.cshrc Thu May 3 19:56:17 2012 (r234979) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,19 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up - set prompt = "`/bin/hostname -s`# " + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif Modified: stable/8/share/examples/Makefile ============================================================================== --- stable/8/share/examples/Makefile Thu May 3 19:55:36 2012 (r234978) +++ stable/8/share/examples/Makefile Thu May 3 19:56:17 2012 (r234979) @@ -8,6 +8,7 @@ LDIRS= BSD_daemon \ FreeBSD_version \ IPv6 \ bootforth \ + csh \ cvsup \ diskless \ drivers \ @@ -48,6 +49,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ bootforth/menu.4th \ bootforth/menuconf.4th \ bootforth/screen.4th \ + csh/dot.cshrc \ cvsup/README \ cvsup/cvs-supfile \ cvsup/doc-supfile \ Modified: stable/8/share/examples/csh/dot.cshrc ============================================================================== --- head/share/examples/csh/dot.cshrc Sat Mar 24 18:43:18 2012 (r233429) +++ stable/8/share/examples/csh/dot.cshrc Thu May 3 19:56:17 2012 (r234979) @@ -21,19 +21,20 @@ bindkey "^[[3~" delete-char-or-list-or-e # Make the Ins key work bindkey "\e[2~" overwrite-mode +# Aliases used for completions +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1' +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' + # Some common completions complete chown 'p/1/u/' -complete man 'C/*/c/' -complete service 'n/*/`service -l`/' -complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete dd 'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/=' +complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' +complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' complete kldunload 'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name` @' complete make 'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@' +complete man 'C/*/c/' complete pkg_delete 'c/-/(i v D n p d f G x X r)/' 'n@*@`ls /var/db/pkg`@' -complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed svar/db/pkg/%%`@" -complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' -complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1A -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' +complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed s%/var/db/pkg/%%`@' complete portmaster 'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles \ clean-packages delete-build-only delete-packages force-config help \ index index-first index-only list-origins local-packagedir no-confirm \ @@ -41,6 +42,8 @@ complete portmaster 'c/--/(always-fetc packages-local packages-only show-work update-if-newer version)/' \ 'c/-/(a b B C d D e f F g G h H i l L m n o p r R s t u v w x)/' \ 'n@*@`_PKGS_PkGs_PoRtS_`@' +complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete sysctl 'n/*/`sysctl -Na`/' # Alternate prompts set prompt = '#' @@ -56,5 +59,8 @@ set ellipsis alias ll ls -lAhG alias ls ls -G +# Color on many system utilities +setenv CLICOLOR 1 + # other autolist options set autolist = TAB Modified: stable/8/share/skel/dot.cshrc ============================================================================== --- stable/8/share/skel/dot.cshrc Thu May 3 19:55:36 2012 (r234978) +++ stable/8/share/skel/dot.cshrc Thu May 3 19:56:17 2012 (r234979) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,18 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif From owner-svn-src-all@FreeBSD.ORG Thu May 3 19:56:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88C47106566C; Thu, 3 May 2012 19:56:51 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 71DF98FC12; Thu, 3 May 2012 19:56:51 +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 q43JupsX060420; Thu, 3 May 2012 19:56:51 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Jupqa060414; Thu, 3 May 2012 19:56:51 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205031956.q43Jupqa060414@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 May 2012 19:56:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234980 - in stable/7: etc/mtree etc/root share/examples share/examples/csh share/skel X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 19:56:51 -0000 Author: eadler Date: Thu May 3 19:56:50 2012 New Revision: 234980 URL: http://svn.freebsd.org/changeset/base/234980 Log: MFC r233429,r233435,r233437,r234077,r234133,r234135,r234159,r234823: A variety of changes that make the default shell easier to use. Approved by: cperciva (implicit) Added: stable/7/share/examples/csh/ - copied from r233429, head/share/examples/csh/ Modified: stable/7/etc/mtree/BSD.usr.dist stable/7/etc/root/dot.cshrc stable/7/share/examples/Makefile stable/7/share/examples/csh/dot.cshrc stable/7/share/skel/dot.cshrc Directory Properties: stable/7/etc/ (props changed) stable/7/share/examples/ (props changed) stable/7/share/skel/ (props changed) Modified: stable/7/etc/mtree/BSD.usr.dist ============================================================================== --- stable/7/etc/mtree/BSD.usr.dist Thu May 3 19:56:17 2012 (r234979) +++ stable/7/etc/mtree/BSD.usr.dist Thu May 3 19:56:50 2012 (r234980) @@ -193,6 +193,8 @@ .. bootforth .. + csh + .. cvs contrib .. Modified: stable/7/etc/root/dot.cshrc ============================================================================== --- stable/7/etc/root/dot.cshrc Thu May 3 19:56:17 2012 (r234979) +++ stable/7/etc/root/dot.cshrc Thu May 3 19:56:50 2012 (r234980) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,19 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up - set prompt = "`/bin/hostname -s`# " + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif Modified: stable/7/share/examples/Makefile ============================================================================== --- stable/7/share/examples/Makefile Thu May 3 19:56:17 2012 (r234979) +++ stable/7/share/examples/Makefile Thu May 3 19:56:50 2012 (r234980) @@ -8,6 +8,7 @@ LDIRS= BSD_daemon \ FreeBSD_version \ IPv6 \ bootforth \ + csh \ cvsup \ diskless \ drivers \ @@ -52,6 +53,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ bootforth/menu.4th \ bootforth/menuconf.4th \ bootforth/screen.4th \ + csh/dot.cshrc \ cvsup/README \ cvsup/cvs-supfile \ cvsup/doc-supfile \ Modified: stable/7/share/examples/csh/dot.cshrc ============================================================================== --- head/share/examples/csh/dot.cshrc Sat Mar 24 18:43:18 2012 (r233429) +++ stable/7/share/examples/csh/dot.cshrc Thu May 3 19:56:50 2012 (r234980) @@ -21,19 +21,20 @@ bindkey "^[[3~" delete-char-or-list-or-e # Make the Ins key work bindkey "\e[2~" overwrite-mode +# Aliases used for completions +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1' +alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' + # Some common completions complete chown 'p/1/u/' -complete man 'C/*/c/' -complete service 'n/*/`service -l`/' -complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete dd 'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/=' +complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' +complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' complete kldunload 'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name` @' complete make 'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@' +complete man 'C/*/c/' complete pkg_delete 'c/-/(i v D n p d f G x X r)/' 'n@*@`ls /var/db/pkg`@' -complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed svar/db/pkg/%%`@" -complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' -complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/' -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-name -r | cut -d . -f 1A -alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1`&& pkg_info -E \*' +complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed s%/var/db/pkg/%%`@' complete portmaster 'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles \ clean-packages delete-build-only delete-packages force-config help \ index index-first index-only list-origins local-packagedir no-confirm \ @@ -41,6 +42,8 @@ complete portmaster 'c/--/(always-fetc packages-local packages-only show-work update-if-newer version)/' \ 'c/-/(a b B C d D e f F g G h H i l L m n o p r R s t u v w x)/' \ 'n@*@`_PKGS_PkGs_PoRtS_`@' +complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' +complete sysctl 'n/*/`sysctl -Na`/' # Alternate prompts set prompt = '#' @@ -56,5 +59,8 @@ set ellipsis alias ll ls -lAhG alias ls ls -G +# Color on many system utilities +setenv CLICOLOR 1 + # other autolist options set autolist = TAB Modified: stable/7/share/skel/dot.cshrc ============================================================================== --- stable/7/share/skel/dot.cshrc Thu May 3 19:56:17 2012 (r234979) +++ stable/7/share/skel/dot.cshrc Thu May 3 19:56:50 2012 (r234980) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,18 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif From owner-svn-src-all@FreeBSD.ORG Thu May 3 20:00:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 03D62106578C; Thu, 3 May 2012 20:00:31 +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 E2C878FC15; Thu, 3 May 2012 20:00: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 q43K0Ugl060622; Thu, 3 May 2012 20:00:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43K0Ure060620; Thu, 3 May 2012 20:00:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205032000.q43K0Ure060620@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 3 May 2012 20:00: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: r234981 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:00:31 -0000 Author: kib Date: Thu May 3 20:00:30 2012 New Revision: 234981 URL: http://svn.freebsd.org/changeset/base/234981 Log: Move the code to call the callout callback into the helper function softclock_call_cc(). While there, move some common code to callout_cc_del(). Requested by: avg, jhb Reviewed by: jhb MFC after: 1 week Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu May 3 19:56:50 2012 (r234980) +++ head/sys/kern/kern_timeout.c Thu May 3 20:00:30 2012 (r234981) @@ -437,6 +437,181 @@ callout_cc_add(struct callout *c, struct } } +static void +callout_cc_del(struct callout *c, struct callout_cpu *cc) +{ + + if (cc->cc_next == c) + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); + if (c->c_flags & CALLOUT_LOCAL_ALLOC) { + c->c_func = NULL; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); + } +} + +static struct callout * +softclock_call_cc(struct callout *c, struct callout_cpu *cc, int *mpcalls, + int *lockcalls, int *gcalls) +{ + void (*c_func)(void *); + void *c_arg; + struct lock_class *class; + struct lock_object *c_lock; + int c_flags, sharedlock; +#ifdef SMP + struct callout_cpu *new_cc; + void (*new_func)(void *); + void *new_arg; + int new_cpu, new_ticks; +#endif +#ifdef DIAGNOSTIC + struct bintime bt1, bt2; + struct timespec ts2; + static uint64_t maxdt = 36893488147419102LL; /* 2 msec */ + static timeout_t *lastfunc; +#endif + + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); + class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; + sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? 0 : 1; + c_lock = c->c_lock; + c_func = c->c_func; + c_arg = c->c_arg; + c_flags = c->c_flags; + if (c->c_flags & CALLOUT_LOCAL_ALLOC) + c->c_flags = CALLOUT_LOCAL_ALLOC; + else + c->c_flags &= ~CALLOUT_PENDING; + cc->cc_curr = c; + cc->cc_cancel = 0; + CC_UNLOCK(cc); + if (c_lock != NULL) { + class->lc_lock(c_lock, sharedlock); + /* + * The callout may have been cancelled + * while we switched locks. + */ + if (cc->cc_cancel) { + class->lc_unlock(c_lock); + goto skip; + } + /* The callout cannot be stopped now. */ + cc->cc_cancel = 1; + + if (c_lock == &Giant.lock_object) { + (*gcalls)++; + CTR3(KTR_CALLOUT, "callout %p func %p arg %p", + c, c_func, c_arg); + } else { + (*lockcalls)++; + CTR3(KTR_CALLOUT, "callout lock %p func %p arg %p", + c, c_func, c_arg); + } + } else { + (*mpcalls)++; + CTR3(KTR_CALLOUT, "callout mpsafe %p func %p arg %p", + c, c_func, c_arg); + } +#ifdef DIAGNOSTIC + binuptime(&bt1); +#endif + THREAD_NO_SLEEPING(); + SDT_PROBE(callout_execute, kernel, , callout_start, c, 0, 0, 0, 0); + c_func(c_arg); + SDT_PROBE(callout_execute, kernel, , callout_end, c, 0, 0, 0, 0); + THREAD_SLEEPING_OK(); +#ifdef DIAGNOSTIC + binuptime(&bt2); + bintime_sub(&bt2, &bt1); + if (bt2.frac > maxdt) { + if (lastfunc != c_func || bt2.frac > maxdt * 2) { + bintime2timespec(&bt2, &ts2); + printf( + "Expensive timeout(9) function: %p(%p) %jd.%09ld s\n", + c_func, c_arg, (intmax_t)ts2.tv_sec, ts2.tv_nsec); + } + maxdt = bt2.frac; + lastfunc = c_func; + } +#endif + CTR1(KTR_CALLOUT, "callout %p finished", c); + if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) + class->lc_unlock(c_lock); +skip: + CC_LOCK(cc); + /* + * If the current callout is locally allocated (from + * timeout(9)) then put it on the freelist. + * + * Note: we need to check the cached copy of c_flags because + * if it was not local, then it's not safe to deref the + * callout pointer. + */ + if (c_flags & CALLOUT_LOCAL_ALLOC) { + KASSERT(c->c_flags == CALLOUT_LOCAL_ALLOC, + ("corrupted callout")); + c->c_func = NULL; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); + } + cc->cc_curr = NULL; + if (cc->cc_waiting) { + /* + * There is someone waiting for the + * callout to complete. + * If the callout was scheduled for + * migration just cancel it. + */ + if (cc_cme_migrating(cc)) + cc_cme_cleanup(cc); + cc->cc_waiting = 0; + CC_UNLOCK(cc); + wakeup(&cc->cc_waiting); + CC_LOCK(cc); + } else if (cc_cme_migrating(cc)) { +#ifdef SMP + /* + * If the callout was scheduled for + * migration just perform it now. + */ + new_cpu = cc->cc_migration_cpu; + new_ticks = cc->cc_migration_ticks; + new_func = cc->cc_migration_func; + new_arg = cc->cc_migration_arg; + cc_cme_cleanup(cc); + + /* + * Handle deferred callout stops + */ + if ((c->c_flags & CALLOUT_DFRMIGRATION) == 0) { + CTR3(KTR_CALLOUT, + "deferred cancelled %p func %p arg %p", + c, new_func, new_arg); + callout_cc_del(c, cc); + goto nextc; + } + + c->c_flags &= ~CALLOUT_DFRMIGRATION; + + /* + * It should be assert here that the + * callout is not destroyed but that + * is not easy. + */ + new_cc = callout_cpu_switch(c, cc, new_cpu); + callout_cc_add(c, new_cc, new_ticks, new_func, new_arg, + new_cpu); + CC_UNLOCK(new_cc); + CC_LOCK(cc); +#else + panic("migration should not happen"); +#endif + } +#ifdef SMP +nextc: +#endif + return (cc->cc_next); +} + /* * The callout mechanism is based on the work of Adam M. Costello and * George Varghese, published in a technical report entitled "Redesigning @@ -465,12 +640,6 @@ softclock(void *arg) int mpcalls; int lockcalls; int gcalls; -#ifdef DIAGNOSTIC - struct bintime bt1, bt2; - struct timespec ts2; - static uint64_t maxdt = 36893488147419102LL; /* 2 msec */ - static timeout_t *lastfunc; -#endif #ifndef MAX_SOFTCLOCK_STEPS #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ @@ -492,7 +661,7 @@ softclock(void *arg) cc->cc_softticks++; bucket = &cc->cc_callwheel[curticks & callwheelmask]; c = TAILQ_FIRST(bucket); - while (c) { + while (c != NULL) { depth++; if (c->c_time != curticks) { c = TAILQ_NEXT(c, c_links.tqe); @@ -507,189 +676,10 @@ softclock(void *arg) steps = 0; } } else { - void (*c_func)(void *); - void *c_arg; - struct lock_class *class; - struct lock_object *c_lock; - int c_flags, sharedlock; - - cc->cc_next = TAILQ_NEXT(c, c_links.tqe); TAILQ_REMOVE(bucket, c, c_links.tqe); - class = (c->c_lock != NULL) ? - LOCK_CLASS(c->c_lock) : NULL; - sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? - 0 : 1; - c_lock = c->c_lock; - c_func = c->c_func; - c_arg = c->c_arg; - c_flags = c->c_flags; - if (c->c_flags & CALLOUT_LOCAL_ALLOC) { - c->c_flags = CALLOUT_LOCAL_ALLOC; - } else { - c->c_flags = - (c->c_flags & ~CALLOUT_PENDING); - } - cc->cc_curr = c; - cc->cc_cancel = 0; - CC_UNLOCK(cc); - if (c_lock != NULL) { - class->lc_lock(c_lock, sharedlock); - /* - * The callout may have been cancelled - * while we switched locks. - */ - if (cc->cc_cancel) { - class->lc_unlock(c_lock); - goto skip; - } - /* The callout cannot be stopped now. */ - cc->cc_cancel = 1; - - if (c_lock == &Giant.lock_object) { - gcalls++; - CTR3(KTR_CALLOUT, - "callout %p func %p arg %p", - c, c_func, c_arg); - } else { - lockcalls++; - CTR3(KTR_CALLOUT, "callout lock" - " %p func %p arg %p", - c, c_func, c_arg); - } - } else { - mpcalls++; - CTR3(KTR_CALLOUT, - "callout mpsafe %p func %p arg %p", - c, c_func, c_arg); - } -#ifdef DIAGNOSTIC - binuptime(&bt1); -#endif - THREAD_NO_SLEEPING(); - SDT_PROBE(callout_execute, kernel, , - callout_start, c, 0, 0, 0, 0); - c_func(c_arg); - SDT_PROBE(callout_execute, kernel, , - callout_end, c, 0, 0, 0, 0); - THREAD_SLEEPING_OK(); -#ifdef DIAGNOSTIC - binuptime(&bt2); - bintime_sub(&bt2, &bt1); - if (bt2.frac > maxdt) { - if (lastfunc != c_func || - bt2.frac > maxdt * 2) { - bintime2timespec(&bt2, &ts2); - printf( - "Expensive timeout(9) function: %p(%p) %jd.%09ld s\n", - c_func, c_arg, - (intmax_t)ts2.tv_sec, - ts2.tv_nsec); - } - maxdt = bt2.frac; - lastfunc = c_func; - } -#endif - CTR1(KTR_CALLOUT, "callout %p finished", c); - if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) - class->lc_unlock(c_lock); - skip: - CC_LOCK(cc); - /* - * If the current callout is locally - * allocated (from timeout(9)) - * then put it on the freelist. - * - * Note: we need to check the cached - * copy of c_flags because if it was not - * local, then it's not safe to deref the - * callout pointer. - */ - if (c_flags & CALLOUT_LOCAL_ALLOC) { - KASSERT(c->c_flags == - CALLOUT_LOCAL_ALLOC, - ("corrupted callout")); - c->c_func = NULL; - SLIST_INSERT_HEAD(&cc->cc_callfree, c, - c_links.sle); - } - cc->cc_curr = NULL; - if (cc->cc_waiting) { - - /* - * There is someone waiting for the - * callout to complete. - * If the callout was scheduled for - * migration just cancel it. - */ - if (cc_cme_migrating(cc)) - cc_cme_cleanup(cc); - cc->cc_waiting = 0; - CC_UNLOCK(cc); - wakeup(&cc->cc_waiting); - CC_LOCK(cc); - } else if (cc_cme_migrating(cc)) { -#ifdef SMP - struct callout_cpu *new_cc; - void (*new_func)(void *); - void *new_arg; - int new_cpu, new_ticks; - - /* - * If the callout was scheduled for - * migration just perform it now. - */ - new_cpu = cc->cc_migration_cpu; - new_ticks = cc->cc_migration_ticks; - new_func = cc->cc_migration_func; - new_arg = cc->cc_migration_arg; - cc_cme_cleanup(cc); - - /* - * Handle deferred callout stops - */ - if ((c->c_flags & CALLOUT_DFRMIGRATION) - == 0) { - CTR3(KTR_CALLOUT, - "deferred cancelled %p func %p arg %p", - c, new_func, new_arg); - if (cc->cc_next == c) { - cc->cc_next = - TAILQ_NEXT(c, - c_links.tqe); - } - if (c->c_flags & - CALLOUT_LOCAL_ALLOC) { - c->c_func = NULL; - SLIST_INSERT_HEAD( - &cc->cc_callfree, c, - c_links.sle); - } - goto nextc; - } else { - c->c_flags &= ~ - CALLOUT_DFRMIGRATION; - } - - /* - * It should be assert here that the - * callout is not destroyed but that - * is not easy. - */ - new_cc = callout_cpu_switch(c, cc, - new_cpu); - callout_cc_add(c, new_cc, new_ticks, - new_func, new_arg, new_cpu); - CC_UNLOCK(new_cc); - CC_LOCK(cc); -#else - panic("migration should not happen"); -#endif - } -#ifdef SMP -nextc: -#endif + c = softclock_call_cc(c, cc, &mpcalls, + &lockcalls, &gcalls); steps = 0; - c = cc->cc_next; } } } @@ -1032,19 +1022,12 @@ again: c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); - if (cc->cc_next == c) { - cc->cc_next = TAILQ_NEXT(c, c_links.tqe); - } - TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, - c_links.tqe); - CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); + TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, + c_links.tqe); + callout_cc_del(c, cc); - if (c->c_flags & CALLOUT_LOCAL_ALLOC) { - c->c_func = NULL; - SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); - } CC_UNLOCK(cc); return (1); } From owner-svn-src-all@FreeBSD.ORG Thu May 3 20:41:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A07F9106564A; Thu, 3 May 2012 20:41:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 861488FC0A; Thu, 3 May 2012 20:41:22 +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 q43KfMY8062066; Thu, 3 May 2012 20:41:22 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43KfMYu062048; Thu, 3 May 2012 20:41:22 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205032041.q43KfMYu062048@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 20:41:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234982 - in head: contrib/llvm/include/llvm contrib/llvm/include/llvm-c contrib/llvm/include/llvm/ADT contrib/llvm/include/llvm/CodeGen contrib/llvm/include/llvm/MC/MCParser contrib/ll... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:41:22 -0000 Author: dim Date: Thu May 3 20:41:21 2012 New Revision: 234982 URL: http://svn.freebsd.org/changeset/base/234982 Log: Upgrade our copy of llvm/clang to r155985, from upstream's release_31 branch. This brings us very close to the 3.1 release, which is planned for May 14th. MFC after: 2 weeks Added: head/contrib/llvm/include/llvm/Support/Locale.h - copied unchanged from r234974, vendor/llvm/dist/include/llvm/Support/Locale.h head/contrib/llvm/include/llvm/Support/MDBuilder.h - copied unchanged from r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/JITRegistrar.h - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/JITRegistrar.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImage.h - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/ObjectImage.h head/contrib/llvm/lib/Support/Locale.cpp - copied unchanged from r234974, vendor/llvm/dist/lib/Support/Locale.cpp head/contrib/llvm/lib/Support/LocaleGeneric.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleGeneric.inc head/contrib/llvm/lib/Support/LocaleWindows.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleWindows.inc head/contrib/llvm/lib/Support/LocaleXlocale.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleXlocale.inc head/contrib/llvm/lib/Target/Mips/Disassembler/ - copied from r234974, vendor/llvm/dist/lib/Target/Mips/Disassembler/ head/contrib/llvm/tools/clang/lib/Sema/SemaStmtAttr.cpp - copied unchanged from r234977, vendor/clang/dist/lib/Sema/SemaStmtAttr.cpp Deleted: head/contrib/llvm/include/llvm/Support/JSONParser.h head/contrib/llvm/lib/Support/JSONParser.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonMCInst.h head/contrib/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp head/contrib/llvm/lib/Target/Mips/Disassembler/CMakeLists.txt head/contrib/llvm/lib/Target/Mips/Disassembler/LLVMBuild.txt head/contrib/llvm/lib/Target/Mips/Disassembler/Makefile head/contrib/llvm/tools/clang/include/clang/Basic/DelayedCleanupPool.h head/contrib/llvm/tools/clang/include/clang/Index/ head/contrib/llvm/tools/clang/lib/Index/ head/lib/clang/libclangindex/ Modified: head/contrib/llvm/include/llvm-c/lto.h head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h head/contrib/llvm/include/llvm/ADT/StringMap.h head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h head/contrib/llvm/include/llvm/CodeGen/Passes.h head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h head/contrib/llvm/include/llvm/IntrinsicsX86.td head/contrib/llvm/include/llvm/LLVMContext.h head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h head/contrib/llvm/include/llvm/Object/ELF.h head/contrib/llvm/include/llvm/Operator.h head/contrib/llvm/include/llvm/Support/IRBuilder.h head/contrib/llvm/include/llvm/Support/Process.h head/contrib/llvm/include/llvm/Support/SourceMgr.h head/contrib/llvm/include/llvm/Support/YAMLParser.h head/contrib/llvm/include/llvm/Support/raw_ostream.h head/contrib/llvm/include/llvm/TableGen/Error.h head/contrib/llvm/include/llvm/TableGen/Record.h head/contrib/llvm/include/llvm/Target/TargetLibraryInfo.h head/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h head/contrib/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h head/contrib/llvm/include/llvm/Transforms/Vectorize.h head/contrib/llvm/lib/Analysis/ConstantFolding.cpp head/contrib/llvm/lib/Analysis/ScalarEvolution.cpp head/contrib/llvm/lib/Analysis/ValueTracking.cpp head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.h head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp head/contrib/llvm/lib/CodeGen/DFAPacketizer.cpp head/contrib/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp head/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp head/contrib/llvm/lib/CodeGen/MachineBlockPlacement.cpp head/contrib/llvm/lib/CodeGen/Passes.cpp head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp head/contrib/llvm/lib/CodeGen/SlotIndexes.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h head/contrib/llvm/lib/MC/MCParser/AsmParser.cpp head/contrib/llvm/lib/Object/ELFObjectFile.cpp head/contrib/llvm/lib/Support/SmallPtrSet.cpp head/contrib/llvm/lib/Support/SourceMgr.cpp head/contrib/llvm/lib/Support/Unix/Process.inc head/contrib/llvm/lib/Support/Windows/Process.inc head/contrib/llvm/lib/Support/YAMLParser.cpp head/contrib/llvm/lib/Support/raw_ostream.cpp head/contrib/llvm/lib/TableGen/Error.cpp head/contrib/llvm/lib/Target/ARM/ARMCallingConv.td head/contrib/llvm/lib/Target/ARM/ARMInstrFormats.td head/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td head/contrib/llvm/lib/Target/ARM/ARMInstrNEON.td head/contrib/llvm/lib/Target/ARM/ARMTargetMachine.cpp head/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp head/contrib/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp head/contrib/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp head/contrib/llvm/lib/Target/CellSPU/SPUCallingConv.td head/contrib/llvm/lib/Target/CellSPU/SPUTargetMachine.cpp head/contrib/llvm/lib/Target/Hexagon/Hexagon.h head/contrib/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonInstrFormats.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrFormatsV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.h head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfoV3.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonMCInstLower.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonSchedule.td head/contrib/llvm/lib/Target/Hexagon/HexagonScheduleV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp head/contrib/llvm/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp head/contrib/llvm/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.h head/contrib/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonBaseInfo.h head/contrib/llvm/lib/Target/MBlaze/MBlazeCallingConv.td head/contrib/llvm/lib/Target/MBlaze/MBlazeTargetMachine.cpp head/contrib/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp head/contrib/llvm/lib/Target/Mips/Mips64InstrInfo.td head/contrib/llvm/lib/Target/Mips/MipsCondMov.td head/contrib/llvm/lib/Target/Mips/MipsISelLowering.cpp head/contrib/llvm/lib/Target/Mips/MipsInstrFPU.td head/contrib/llvm/lib/Target/Mips/MipsInstrFormats.td head/contrib/llvm/lib/Target/Mips/MipsInstrInfo.td head/contrib/llvm/lib/Target/Mips/MipsTargetMachine.cpp head/contrib/llvm/lib/Target/PTX/PTXTargetMachine.cpp head/contrib/llvm/lib/Target/PowerPC/PPCCallingConv.td head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp head/contrib/llvm/lib/Target/Sparc/SparcTargetMachine.cpp head/contrib/llvm/lib/Target/TargetLibraryInfo.cpp head/contrib/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp head/contrib/llvm/lib/Target/X86/X86ISelLowering.h head/contrib/llvm/lib/Target/X86/X86InstrFragmentsSIMD.td head/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp head/contrib/llvm/lib/Target/X86/X86InstrSSE.td head/contrib/llvm/lib/Target/X86/X86Subtarget.cpp head/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp head/contrib/llvm/lib/Target/XCore/XCoreTargetMachine.cpp head/contrib/llvm/lib/Transforms/IPO/Internalize.cpp head/contrib/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp head/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp head/contrib/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp head/contrib/llvm/lib/Transforms/Scalar/ObjCARC.cpp head/contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp head/contrib/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp head/contrib/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp head/contrib/llvm/lib/Transforms/Vectorize/BBVectorize.cpp head/contrib/llvm/lib/VMCore/AutoUpgrade.cpp head/contrib/llvm/lib/VMCore/Instructions.cpp head/contrib/llvm/lib/VMCore/LLVMContext.cpp head/contrib/llvm/lib/VMCore/Module.cpp head/contrib/llvm/lib/VMCore/Verifier.cpp head/contrib/llvm/tools/clang/include/clang/AST/Decl.h head/contrib/llvm/tools/clang/include/clang/AST/DeclBase.h head/contrib/llvm/tools/clang/include/clang/AST/DeclLookups.h head/contrib/llvm/tools/clang/include/clang/AST/Expr.h head/contrib/llvm/tools/clang/include/clang/AST/ExternalASTSource.h head/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h head/contrib/llvm/tools/clang/include/clang/AST/Stmt.h head/contrib/llvm/tools/clang/include/clang/AST/Type.h head/contrib/llvm/tools/clang/include/clang/AST/VTableBuilder.h head/contrib/llvm/tools/clang/include/clang/Analysis/ProgramPoint.h head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def head/contrib/llvm/tools/clang/include/clang/Basic/ConvertUTF.h head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td head/contrib/llvm/tools/clang/include/clang/Basic/ExceptionSpecificationType.h head/contrib/llvm/tools/clang/include/clang/Basic/OnDiskHashTable.h head/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td head/contrib/llvm/tools/clang/include/clang/Basic/TargetInfo.h head/contrib/llvm/tools/clang/include/clang/Basic/TokenKinds.def head/contrib/llvm/tools/clang/include/clang/Driver/CC1Options.td head/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h head/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h head/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h head/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h head/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h head/contrib/llvm/tools/clang/include/clang/Parse/Parser.h head/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h head/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h head/contrib/llvm/tools/clang/include/clang/Sema/Scope.h head/contrib/llvm/tools/clang/include/clang/Sema/Sema.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTReader.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h head/contrib/llvm/tools/clang/include/clang/Serialization/Module.h head/contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h head/contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h head/contrib/llvm/tools/clang/include/clang/Tooling/CompilationDatabase.h head/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp head/contrib/llvm/tools/clang/lib/AST/Decl.cpp head/contrib/llvm/tools/clang/lib/AST/Expr.cpp head/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp head/contrib/llvm/tools/clang/lib/AST/ExternalASTSource.cpp head/contrib/llvm/tools/clang/lib/AST/ItaniumMangle.cpp head/contrib/llvm/tools/clang/lib/AST/Stmt.cpp head/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp head/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp head/contrib/llvm/tools/clang/lib/AST/Type.cpp head/contrib/llvm/tools/clang/lib/AST/VTableBuilder.cpp head/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp head/contrib/llvm/tools/clang/lib/Basic/TargetInfo.cpp head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp head/contrib/llvm/tools/clang/lib/Basic/Version.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGBlocks.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGCall.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExpr.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprAgg.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprConstant.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.h head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp head/contrib/llvm/tools/clang/lib/Driver/Compilation.cpp head/contrib/llvm/tools/clang/lib/Driver/Driver.cpp head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp head/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp head/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp head/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp head/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp head/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp head/contrib/llvm/tools/clang/lib/Frontend/TextDiagnostic.cpp head/contrib/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp head/contrib/llvm/tools/clang/lib/Headers/avx2intrin.h head/contrib/llvm/tools/clang/lib/Headers/avxintrin.h head/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp head/contrib/llvm/tools/clang/lib/Parse/Parser.cpp head/contrib/llvm/tools/clang/lib/Rewrite/RewriteModernObjC.cpp head/contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp head/contrib/llvm/tools/clang/lib/Sema/DeclSpec.cpp head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaAccess.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExceptionSpec.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExpr.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExprMember.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaLookup.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaPseudoObject.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateDeduction.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp head/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h head/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderInternals.h head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp head/contrib/llvm/tools/clang/lib/Serialization/Module.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp head/contrib/llvm/tools/clang/lib/Tooling/CompilationDatabase.cpp head/contrib/llvm/tools/llc/llc.cpp head/contrib/llvm/tools/lli/lli.cpp head/contrib/llvm/tools/llvm-mc/Disassembler.cpp head/contrib/llvm/tools/llvm-mc/Disassembler.h head/contrib/llvm/tools/llvm-mc/llvm-mc.cpp head/contrib/llvm/tools/llvm-stress/llvm-stress.cpp head/contrib/llvm/tools/opt/opt.cpp head/contrib/llvm/utils/TableGen/AsmMatcherEmitter.cpp head/contrib/llvm/utils/TableGen/AsmWriterEmitter.cpp head/contrib/llvm/utils/TableGen/CodeGenDAGPatterns.cpp head/contrib/llvm/utils/TableGen/CodeGenRegisters.cpp head/contrib/llvm/utils/TableGen/EDEmitter.cpp head/contrib/llvm/utils/TableGen/RegisterInfoEmitter.cpp head/lib/clang/Makefile head/lib/clang/clang.build.mk head/lib/clang/include/clang/Basic/Version.inc head/lib/clang/include/clang/Config/config.h head/lib/clang/include/llvm/Config/config.h head/lib/clang/libclangsema/Makefile head/lib/clang/libllvmruntimedyld/Makefile head/lib/clang/libllvmsupport/Makefile head/usr.bin/clang/clang/Makefile Directory Properties: head/contrib/llvm/ (props changed) head/contrib/llvm/tools/clang/ (props changed) Modified: head/contrib/llvm/include/llvm-c/lto.h ============================================================================== --- head/contrib/llvm/include/llvm-c/lto.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm-c/lto.h Thu May 3 20:41:21 2012 (r234982) @@ -251,12 +251,6 @@ lto_codegen_set_assembler_args(lto_code_ int nargs); /** - * Enables the internalize pass during LTO optimizations. - */ -extern void -lto_codegen_set_whole_program_optimization(lto_code_gen_t cg); - -/** * Adds to a list of all global symbols that must exist in the final * generated code. If a function is not listed, it might be * inlined into every usage and optimized away. Modified: head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h ============================================================================== --- head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h Thu May 3 20:41:21 2012 (r234982) @@ -126,9 +126,6 @@ protected: private: bool isSmall() const { return CurArray == SmallArray; } - unsigned Hash(const void *Ptr) const { - return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); - } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); Modified: head/contrib/llvm/include/llvm/ADT/StringMap.h ============================================================================== --- head/contrib/llvm/include/llvm/ADT/StringMap.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/ADT/StringMap.h Thu May 3 20:41:21 2012 (r234982) @@ -239,7 +239,7 @@ public: explicit StringMap(AllocatorTy A) : StringMapImpl(static_cast(sizeof(MapEntryTy))), Allocator(A) {} - explicit StringMap(const StringMap &RHS) + StringMap(const StringMap &RHS) : StringMapImpl(static_cast(sizeof(MapEntryTy))) { assert(RHS.empty() && "Copy ctor from non-empty stringmap not implemented yet!"); Modified: head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 20:41:21 2012 (r234982) @@ -28,7 +28,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/ADT/DenseMap.h" -#include namespace llvm { @@ -37,7 +36,7 @@ class MachineInstr; class MachineLoopInfo; class MachineDominatorTree; class InstrItineraryData; -class DefaultVLIWScheduler; +class ScheduleDAGInstrs; class SUnit; class DFAPacketizer { @@ -78,8 +77,6 @@ public: // reserveResources - Reserve the resources occupied by a machine // instruction and change the current state to reflect that change. void reserveResources(llvm::MachineInstr *MI); - - const InstrItineraryData *getInstrItins() const { return InstrItins; } }; // VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The @@ -90,21 +87,20 @@ public: // and machine resource is marked as taken. If any dependency is found, a target // API call is made to prune the dependence. class VLIWPacketizerList { -protected: const TargetMachine &TM; const MachineFunction &MF; const TargetInstrInfo *TII; - // The VLIW Scheduler. - DefaultVLIWScheduler *VLIWScheduler; + // Encapsulate data types not exposed to the target interface. + ScheduleDAGInstrs *SchedulerImpl; +protected: // Vector of instructions assigned to the current packet. std::vector CurrentPacketMIs; // DFA resource tracker. DFAPacketizer *ResourceTracker; - - // Generate MI -> SU map. - std::map MIToSUnit; + // Scheduling units. + std::vector SUnits; public: VLIWPacketizerList( @@ -122,32 +118,17 @@ public: DFAPacketizer *getResourceTracker() {return ResourceTracker;} // addToPacket - Add MI to the current packet. - virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) { - MachineBasicBlock::iterator MII = MI; - CurrentPacketMIs.push_back(MI); - ResourceTracker->reserveResources(MI); - return MII; - } + void addToPacket(MachineInstr *MI); // endPacket - End the current packet. - void endPacket(MachineBasicBlock *MBB, MachineInstr *MI); - - // initPacketizerState - perform initialization before packetizing - // an instruction. This function is supposed to be overrided by - // the target dependent packetizer. - virtual void initPacketizerState(void) { return; } + void endPacket(MachineBasicBlock *MBB, MachineInstr *I); // ignorePseudoInstruction - Ignore bundling of pseudo instructions. - virtual bool ignorePseudoInstruction(MachineInstr *I, - MachineBasicBlock *MBB) { - return false; - } + bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB); - // isSoloInstruction - return true if instruction MI can not be packetized - // with any other instruction, which means that MI itself is a packet. - virtual bool isSoloInstruction(MachineInstr *MI) { - return true; - } + // isSoloInstruction - return true if instruction I must end previous + // packet. + bool isSoloInstruction(MachineInstr *I); // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ // together. @@ -160,7 +141,6 @@ public: virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { return false; } - }; } Modified: head/contrib/llvm/include/llvm/CodeGen/Passes.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/Passes.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/Passes.h Thu May 3 20:41:21 2012 (r234982) @@ -56,7 +56,7 @@ public: protected: TargetMachine *TM; - PassManagerBase &PM; + PassManagerBase *PM; PassConfigImpl *Impl; // Internal data structures bool Initialized; // Flagged after all passes are configured. Modified: head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h Thu May 3 20:41:21 2012 (r234982) @@ -181,6 +181,13 @@ namespace llvm { /// the def-side latency only. bool UnitLatencies; + /// The standard DAG builder does not normally include terminators as DAG + /// nodes because it does not create the necessary dependencies to prevent + /// reordering. A specialized scheduler can overide + /// TargetInstrInfo::isSchedulingBoundary then enable this flag to indicate + /// it has taken responsibility for scheduling the terminator correctly. + bool CanHandleTerminators; + /// State specific to the current scheduling region. /// ------------------------------------------------ Modified: head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h Thu May 3 20:41:21 2012 (r234982) @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/ilist.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Allocator.h" @@ -33,8 +34,7 @@ namespace llvm { /// SlotIndexes pass. It should not be used directly. See the /// SlotIndex & SlotIndexes classes for the public interface to this /// information. - class IndexListEntry { - IndexListEntry *next, *prev; + class IndexListEntry : public ilist_node { MachineInstr *mi; unsigned index; @@ -51,31 +51,26 @@ namespace llvm { void setIndex(unsigned index) { this->index = index; } - - IndexListEntry* getNext() { return next; } - const IndexListEntry* getNext() const { return next; } - void setNext(IndexListEntry *next) { - this->next = next; - } - IndexListEntry* getPrev() { return prev; } - const IndexListEntry* getPrev() const { return prev; } - void setPrev(IndexListEntry *prev) { - this->prev = prev; - } }; - // Specialize PointerLikeTypeTraits for IndexListEntry. template <> - class PointerLikeTypeTraits { + struct ilist_traits : public ilist_default_traits { + private: + mutable ilist_half_node Sentinel; public: - static inline void* getAsVoidPointer(IndexListEntry *p) { - return p; + IndexListEntry *createSentinel() const { + return static_cast(&Sentinel); } - static inline IndexListEntry* getFromVoidPointer(void *p) { - return static_cast(p); - } - enum { NumLowBitsAvailable = 3 }; + void destroySentinel(IndexListEntry *) const {} + + IndexListEntry *provideInitialHead() const { return createSentinel(); } + IndexListEntry *ensureHead(IndexListEntry*) const { return createSentinel(); } + static void noteHead(IndexListEntry*, IndexListEntry*) {} + void deleteNode(IndexListEntry *N) {} + + private: + void createNode(const IndexListEntry &); }; /// SlotIndex - An opaque wrapper around machine indexes. @@ -112,13 +107,13 @@ namespace llvm { SlotIndex(IndexListEntry *entry, unsigned slot) : lie(entry, slot) {} - IndexListEntry& entry() const { + IndexListEntry* listEntry() const { assert(isValid() && "Attempt to compare reserved index."); - return *lie.getPointer(); + return lie.getPointer(); } int getIndex() const { - return entry().getIndex() | getSlot(); + return listEntry()->getIndex() | getSlot(); } /// Returns the slot for this SlotIndex. @@ -150,8 +145,7 @@ namespace llvm { SlotIndex() : lie(0, 0) {} // Construct a new slot index from the given one, and set the slot. - SlotIndex(const SlotIndex &li, Slot s) - : lie(&li.entry(), unsigned(s)) { + SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) { assert(lie.getPointer() != 0 && "Attempt to construct index with 0 pointer."); } @@ -179,7 +173,7 @@ namespace llvm { bool operator!=(SlotIndex other) const { return lie != other.lie; } - + /// Compare two SlotIndex objects. Return true if the first index /// is strictly lower than the second. bool operator<(SlotIndex other) const { @@ -211,7 +205,7 @@ namespace llvm { /// isEarlierInstr - Return true if A refers to an instruction earlier than /// B. This is equivalent to A < B && !isSameInstr(A, B). static bool isEarlierInstr(SlotIndex A, SlotIndex B) { - return A.entry().getIndex() < B.entry().getIndex(); + return A.listEntry()->getIndex() < B.listEntry()->getIndex(); } /// Return the distance from this index to the given one. @@ -236,25 +230,25 @@ namespace llvm { /// is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBaseIndex() const { - return SlotIndex(&entry(), Slot_Block); + return SlotIndex(listEntry(), Slot_Block); } /// Returns the boundary index for associated with this index. The boundary /// index is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBoundaryIndex() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the register use/def slot in the current instruction for a /// normal or early-clobber def. SlotIndex getRegSlot(bool EC = false) const { - return SlotIndex(&entry(), EC ? Slot_EarlyClobber : Slot_Register); + return SlotIndex(listEntry(), EC ? Slot_EarlyClobber : Slot_Register); } /// Returns the dead def kill slot for the current instruction. SlotIndex getDeadSlot() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the next slot in the index list. This could be either the @@ -266,15 +260,15 @@ namespace llvm { SlotIndex getNextSlot() const { Slot s = getSlot(); if (s == Slot_Dead) { - return SlotIndex(entry().getNext(), Slot_Block); + return SlotIndex(listEntry()->getNextNode(), Slot_Block); } - return SlotIndex(&entry(), s + 1); + return SlotIndex(listEntry(), s + 1); } /// Returns the next index. This is the index corresponding to the this /// index's slot, but for the next instruction. SlotIndex getNextIndex() const { - return SlotIndex(entry().getNext(), getSlot()); + return SlotIndex(listEntry()->getNextNode(), getSlot()); } /// Returns the previous slot in the index list. This could be either the @@ -286,15 +280,15 @@ namespace llvm { SlotIndex getPrevSlot() const { Slot s = getSlot(); if (s == Slot_Block) { - return SlotIndex(entry().getPrev(), Slot_Dead); + return SlotIndex(listEntry()->getPrevNode(), Slot_Dead); } - return SlotIndex(&entry(), s - 1); + return SlotIndex(listEntry(), s - 1); } /// Returns the previous index. This is the index corresponding to this /// index's slot, but for the previous instruction. SlotIndex getPrevIndex() const { - return SlotIndex(entry().getPrev(), getSlot()); + return SlotIndex(listEntry()->getPrevNode(), getSlot()); } }; @@ -315,7 +309,7 @@ namespace llvm { return (LHS == RHS); } }; - + template <> struct isPodLike { static const bool value = true; }; @@ -346,8 +340,10 @@ namespace llvm { class SlotIndexes : public MachineFunctionPass { private: + typedef ilist IndexList; + IndexList indexList; + MachineFunction *mf; - IndexListEntry *indexListHead; unsigned functionSize; typedef DenseMap Mi2IndexMap; @@ -374,84 +370,18 @@ namespace llvm { return entry; } - void initList() { - assert(indexListHead == 0 && "Zero entry non-null at initialisation."); - indexListHead = createEntry(0, ~0U); - indexListHead->setNext(0); - indexListHead->setPrev(indexListHead); - } - - void clearList() { - indexListHead = 0; - ileAllocator.Reset(); - } - - IndexListEntry* getTail() { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - const IndexListEntry* getTail() const { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - // Returns true if the index list is empty. - bool empty() const { return (indexListHead == getTail()); } - - IndexListEntry* front() { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - const IndexListEntry* front() const { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - IndexListEntry* back() { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - const IndexListEntry* back() const { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - /// Insert a new entry before itr. - void insert(IndexListEntry *itr, IndexListEntry *val) { - assert(itr != 0 && "itr should not be null."); - IndexListEntry *prev = itr->getPrev(); - val->setNext(itr); - val->setPrev(prev); - - if (itr != indexListHead) { - prev->setNext(val); - } - else { - indexListHead = val; - } - itr->setPrev(val); - } - - /// Push a new entry on to the end of the list. - void push_back(IndexListEntry *val) { - insert(getTail(), val); - } - - /// Renumber locally after inserting newEntry. - void renumberIndexes(IndexListEntry *newEntry); + /// Renumber locally after inserting curItr. + void renumberIndexes(IndexList::iterator curItr); public: static char ID; - SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) { + SlotIndexes() : MachineFunctionPass(ID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); } virtual void getAnalysisUsage(AnalysisUsage &au) const; - virtual void releaseMemory(); + virtual void releaseMemory(); virtual bool runOnMachineFunction(MachineFunction &fn); @@ -463,22 +393,21 @@ namespace llvm { /// Returns the zero index for this analysis. SlotIndex getZeroIndex() { - assert(front()->getIndex() == 0 && "First index is not 0?"); - return SlotIndex(front(), 0); + assert(indexList.front().getIndex() == 0 && "First index is not 0?"); + return SlotIndex(&indexList.front(), 0); } /// Returns the base index of the last slot in this analysis. SlotIndex getLastIndex() { - return SlotIndex(back(), 0); + return SlotIndex(&indexList.back(), 0); } /// Returns the distance between the highest and lowest indexes allocated /// so far. unsigned getIndexesLength() const { - assert(front()->getIndex() == 0 && + assert(indexList.front().getIndex() == 0 && "Initial index isn't zero?"); - - return back()->getIndex(); + return indexList.back().getIndex(); } /// Returns the number of instructions in the function. @@ -503,19 +432,15 @@ namespace llvm { /// Returns the instruction for the given index, or null if the given /// index has no instruction associated with it. MachineInstr* getInstructionFromIndex(SlotIndex index) const { - return index.isValid() ? index.entry().getInstr() : 0; + return index.isValid() ? index.listEntry()->getInstr() : 0; } /// Returns the next non-null index. SlotIndex getNextNonNullIndex(SlotIndex index) { - SlotIndex nextNonNull = index.getNextIndex(); - - while (&nextNonNull.entry() != getTail() && - getInstructionFromIndex(nextNonNull) == 0) { - nextNonNull = nextNonNull.getNextIndex(); - } - - return nextNonNull; + IndexList::iterator itr(index.listEntry()); + ++itr; + while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; } + return SlotIndex(itr, index.getSlot()); } /// getIndexBefore - Returns the index of the last indexed instruction @@ -659,31 +584,31 @@ namespace llvm { assert(mi->getParent() != 0 && "Instr must be added to function."); // Get the entries where mi should be inserted. - IndexListEntry *prevEntry, *nextEntry; + IndexList::iterator prevItr, nextItr; if (Late) { // Insert mi's index immediately before the following instruction. - nextEntry = &getIndexAfter(mi).entry(); - prevEntry = nextEntry->getPrev(); + nextItr = getIndexAfter(mi).listEntry(); + prevItr = prior(nextItr); } else { // Insert mi's index immediately after the preceeding instruction. - prevEntry = &getIndexBefore(mi).entry(); - nextEntry = prevEntry->getNext(); + prevItr = getIndexBefore(mi).listEntry(); + nextItr = llvm::next(prevItr); } // Get a number for the new instr, or 0 if there's no room currently. // In the latter case we'll force a renumber later. - unsigned dist = ((nextEntry->getIndex() - prevEntry->getIndex())/2) & ~3u; - unsigned newNumber = prevEntry->getIndex() + dist; + unsigned dist = ((nextItr->getIndex() - prevItr->getIndex())/2) & ~3u; + unsigned newNumber = prevItr->getIndex() + dist; // Insert a new list entry for mi. - IndexListEntry *newEntry = createEntry(mi, newNumber); - insert(nextEntry, newEntry); + IndexList::iterator newItr = + indexList.insert(nextItr, createEntry(mi, newNumber)); // Renumber locally if we need to. if (dist == 0) - renumberIndexes(newEntry); + renumberIndexes(newItr); - SlotIndex newIndex(newEntry, SlotIndex::Slot_Block); + SlotIndex newIndex(&*newItr, SlotIndex::Slot_Block); mi2iMap.insert(std::make_pair(mi, newIndex)); return newIndex; } @@ -694,7 +619,7 @@ namespace llvm { // MachineInstr -> index mappings Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi); if (mi2iItr != mi2iMap.end()) { - IndexListEntry *miEntry(&mi2iItr->second.entry()); + IndexListEntry *miEntry(mi2iItr->second.listEntry()); assert(miEntry->getInstr() == mi && "Instruction indexes broken."); // FIXME: Eventually we want to actually delete these indexes. miEntry->setInstr(0); @@ -709,7 +634,7 @@ namespace llvm { if (mi2iItr == mi2iMap.end()) return; SlotIndex replaceBaseIndex = mi2iItr->second; - IndexListEntry *miEntry(&replaceBaseIndex.entry()); + IndexListEntry *miEntry(replaceBaseIndex.listEntry()); assert(miEntry->getInstr() == mi && "Mismatched instruction in index tables."); miEntry->setInstr(newMI); @@ -726,13 +651,13 @@ namespace llvm { IndexListEntry *nextEntry = 0; if (nextMBB == mbb->getParent()->end()) { - nextEntry = getTail(); + nextEntry = indexList.end(); } else { - nextEntry = &getMBBStartIdx(nextMBB).entry(); + nextEntry = getMBBStartIdx(nextMBB).listEntry(); } - insert(nextEntry, startEntry); - insert(nextEntry, stopEntry); + indexList.insert(nextEntry, startEntry); + indexList.insert(nextEntry, stopEntry); SlotIndex startIdx(startEntry, SlotIndex::Slot_Block); SlotIndex endIdx(nextEntry, SlotIndex::Slot_Block); @@ -766,4 +691,4 @@ namespace llvm { } -#endif // LLVM_CODEGEN_LIVEINDEX_H +#endif // LLVM_CODEGEN_SLOTINDEXES_H Modified: head/contrib/llvm/include/llvm/IntrinsicsX86.td ============================================================================== --- head/contrib/llvm/include/llvm/IntrinsicsX86.td Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/IntrinsicsX86.td Thu May 3 20:41:21 2012 (r234982) @@ -1091,20 +1091,6 @@ let TargetPrefix = "x86" in { // All in GCCBuiltin<"__builtin_ia32_vperm2f128_si256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd : - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps : - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, - llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd_256 : - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps_256 : - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_i8_ty], [IntrNoMem]>; } // Vector blend @@ -1659,15 +1645,9 @@ let TargetPrefix = "x86" in { // All in def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty], [IntrNoMem]>; - def int_x86_avx2_permq : GCCBuiltin<"__builtin_ia32_permdi256">, - Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx2_permpd : GCCBuiltin<"__builtin_ia32_permdf256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">, Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>; Modified: head/contrib/llvm/include/llvm/LLVMContext.h ============================================================================== --- head/contrib/llvm/include/llvm/LLVMContext.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/LLVMContext.h Thu May 3 20:41:21 2012 (r234982) @@ -42,7 +42,7 @@ public: MD_dbg = 0, // "dbg" MD_tbaa = 1, // "tbaa" MD_prof = 2, // "prof" - MD_fpaccuracy = 3, // "fpaccuracy" + MD_fpmath = 3, // "fpmath" MD_range = 4 // "range" }; Modified: head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h ============================================================================== --- head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h Thu May 3 20:41:21 2012 (r234982) @@ -16,14 +16,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCParser/MCAsmLexer.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/DataTypes.h" #include -#include namespace llvm { class MemoryBuffer; -class SMLoc; class MCAsmInfo; /// AsmLexer - Lexer class for assembly files. Modified: head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h ============================================================================== --- head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h Thu May 3 20:41:21 2012 (r234982) @@ -15,8 +15,6 @@ #include "llvm/Support/SMLoc.h" namespace llvm { -class MCAsmLexer; -class MCInst; /// AsmToken - Target independent representation for an assembler token. class AsmToken { @@ -53,6 +51,7 @@ public: Greater, GreaterEqual, GreaterGreater, At }; +private: TokenKind Kind; /// A reference to the entire token contents; this is always a pointer into Modified: head/contrib/llvm/include/llvm/Object/ELF.h ============================================================================== --- head/contrib/llvm/include/llvm/Object/ELF.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Object/ELF.h Thu May 3 20:41:21 2012 (r234982) @@ -33,6 +33,15 @@ namespace llvm { namespace object { +// Subclasses of ELFObjectFile may need this for template instantiation +inline std::pair +getElfArchType(MemoryBuffer *Object) { + if (Object->getBufferSize() < ELF::EI_NIDENT) + return std::make_pair((uint8_t)ELF::ELFCLASSNONE,(uint8_t)ELF::ELFDATANONE); + return std::make_pair( (uint8_t)Object->getBufferStart()[ELF::EI_CLASS] + , (uint8_t)Object->getBufferStart()[ELF::EI_DATA]); +} + // Templates to choose Elf_Addr and Elf_Off depending on is64Bits. template struct ELFDataTypeTypedefHelperCommon { Modified: head/contrib/llvm/include/llvm/Operator.h ============================================================================== --- head/contrib/llvm/include/llvm/Operator.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Operator.h Thu May 3 20:41:21 2012 (r234982) @@ -15,8 +15,9 @@ #ifndef LLVM_OPERATOR_H #define LLVM_OPERATOR_H -#include "llvm/Instruction.h" #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/Type.h" namespace llvm { @@ -129,14 +130,15 @@ public: IsExact = (1 << 0) }; +private: + ~PossiblyExactOperator(); // do not implement + friend class BinaryOperator; friend class ConstantExpr; void setIsExact(bool B) { SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact); } -private: - ~PossiblyExactOperator(); // do not implement public: /// isExact - Test whether this division is known to be exact, with /// zero remainder. @@ -161,7 +163,28 @@ public: (isa(V) && classof(cast(V))); } }; - + +/// FPMathOperator - Utility class for floating point operations which can have +/// information about relaxed accuracy requirements attached to them. +class FPMathOperator : public Operator { +private: + ~FPMathOperator(); // do not implement + +public: + + /// \brief Get the maximum error permitted by this operation in ULPs. An + /// accuracy of 0.0 means that the operation should be performed with the + /// default precision. + float getFPAccuracy() const; + + static inline bool classof(const FPMathOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getType()->isFPOrFPVectorTy(); + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; /// ConcreteOperator - A helper template for defining operators for individual Modified: head/contrib/llvm/include/llvm/Support/IRBuilder.h ============================================================================== --- head/contrib/llvm/include/llvm/Support/IRBuilder.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Support/IRBuilder.h Thu May 3 20:41:21 2012 (r234982) @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/BasicBlock.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -331,49 +332,63 @@ template > class IRBuilder : public IRBuilderBase, public Inserter { T Folder; + MDNode *DefaultFPMathTag; public: - IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter()) - : IRBuilderBase(C), Inserter(I), Folder(F) { + IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(), + MDNode *FPMathTag = 0) + : IRBuilderBase(C), Inserter(I), Folder(F), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(LLVMContext &C) : IRBuilderBase(C), Folder() { + explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0) : IRBuilderBase(C), + Folder(), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(BasicBlock *TheBB, const T &F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(BasicBlock *TheBB) - : IRBuilderBase(TheBB->getContext()), Folder() { + explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(Instruction *IP) - : IRBuilderBase(IP->getContext()), Folder() { + explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0) + : IRBuilderBase(IP->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(IP); SetCurrentDebugLocation(IP->getDebugLoc()); } - explicit IRBuilder(Use &U) - : IRBuilderBase(U->getContext()), Folder() { + explicit IRBuilder(Use &U, MDNode *FPMathTag = 0) + : IRBuilderBase(U->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(U); SetCurrentDebugLocation(cast(U.getUser())->getDebugLoc()); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F, + MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) - : IRBuilderBase(TheBB->getContext()), Folder() { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } /// getFolder - Get the constant folder being used. const T &getFolder() { return Folder; } + /// getDefaultFPMathTag - Get the floating point math metadata being used. + MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; } + + /// SetDefaultFPMathTag - Set the floating point math metadata to be used. + void SetDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; } + /// isNamePreserving - Return true if this builder is configured to actually /// add the requested names to IR created through it. bool isNamePreserving() const { return preserveNames; } @@ -496,6 +511,14 @@ private: if (HasNSW) BO->setHasNoSignedWrap(); return BO; } + + Instruction *AddFPMathTag(Instruction *I, MDNode *FPMathTag) const { + if (!FPMathTag) + FPMathTag = DefaultFPMathTag; + if (FPMathTag) + I->setMetadata(LLVMContext::MD_fpmath, FPMathTag); + return I; + } public: Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -511,11 +534,13 @@ public: Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateAdd(LHS, RHS, Name, true, false); } - Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFAdd(LC, RC), Name); - return Insert(BinaryOperator::CreateFAdd(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFAdd(LHS, RHS), + FPMathTag), Name); } Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -531,11 +556,13 @@ public: Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSub(LHS, RHS, Name, true, false); } - Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFSub(LC, RC), Name); - return Insert(BinaryOperator::CreateFSub(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFSub(LHS, RHS), + FPMathTag), Name); } Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -551,11 +578,13 @@ public: Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateMul(LHS, RHS, Name, true, false); } - Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFMul(LC, RC), Name); - return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFMul(LHS, RHS), + FPMathTag), Name); } Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "", bool isExact = false) { @@ -581,11 +610,13 @@ public: Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSDiv(LHS, RHS, Name, true); } - Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFDiv(LC, RC), Name); - return Insert(BinaryOperator::CreateFDiv(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFDiv(LHS, RHS), + FPMathTag), Name); } Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *LC = dyn_cast(LHS)) @@ -599,11 +630,13 @@ public: return Insert(Folder.CreateSRem(LC, RC), Name); return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name); } - Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFRem(LC, RC), Name); - return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFRem(LHS, RHS), + FPMathTag), Name); } Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "", @@ -729,10 +762,10 @@ public: Value *CreateNUWNeg(Value *V, const Twine &Name = "") { return CreateNeg(V, Name, true, false); } - Value *CreateFNeg(Value *V, const Twine &Name = "") { + Value *CreateFNeg(Value *V, const Twine &Name = "", MDNode *FPMathTag = 0) { if (Constant *VC = dyn_cast(V)) return Insert(Folder.CreateFNeg(VC), Name); - return Insert(BinaryOperator::CreateFNeg(V), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFNeg(V), FPMathTag), Name); } Value *CreateNot(Value *V, const Twine &Name = "") { if (Constant *VC = dyn_cast(V)) Copied: head/contrib/llvm/include/llvm/Support/Locale.h (from r234974, vendor/llvm/dist/include/llvm/Support/Locale.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/include/llvm/Support/Locale.h Thu May 3 20:41:21 2012 (r234982, copy of r234974, vendor/llvm/dist/include/llvm/Support/Locale.h) @@ -0,0 +1,17 @@ +#ifndef LLVM_SUPPORT_LOCALE +#define LLVM_SUPPORT_LOCALE + +#include "llvm/ADT/StringRef.h" + +namespace llvm { +namespace sys { +namespace locale { + +int columnWidth(StringRef s); +bool isPrint(int c); + +} +} +} + +#endif // LLVM_SUPPORT_LOCALE Copied: head/contrib/llvm/include/llvm/Support/MDBuilder.h (from r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/include/llvm/Support/MDBuilder.h Thu May 3 20:41:21 2012 (r234982, copy of r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h) @@ -0,0 +1,118 @@ +//===---- llvm/Support/MDBuilder.h - Builder for LLVM metadata --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the MDBuilder class, which is used as a convenient way to +// create LLVM metadata with a consistent and simplified interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_MDBUILDER_H +#define LLVM_SUPPORT_MDBUILDER_H + +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" +#include "llvm/Metadata.h" *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu May 3 20:50:56 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E113106564A; Thu, 3 May 2012 20:50:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 092178FC0C; Thu, 3 May 2012 20:50: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 q43Kot3F062502; Thu, 3 May 2012 20:50:55 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43KotAu062500; Thu, 3 May 2012 20:50:55 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032050.q43KotAu062500@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 20:50:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234983 - head/release/picobsd/build X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:50:56 -0000 Author: luigi Date: Thu May 3 20:50:55 2012 New Revision: 234983 URL: http://svn.freebsd.org/changeset/base/234983 Log: Omit clang when building picobsd, it takes way too long. Also note that loader.conf support is incomplete. Modified: head/release/picobsd/build/picobsd Modified: head/release/picobsd/build/picobsd ============================================================================== --- head/release/picobsd/build/picobsd Thu May 3 20:41:21 2012 (r234982) +++ head/release/picobsd/build/picobsd Thu May 3 20:50:55 2012 (r234983) @@ -164,6 +164,7 @@ create_includes_and_libraries2() { # opt log "create_includes_and_libraries2() for ${SRC} $1" if [ ${OSVERSION} -ge 600000 ] ; then no="-DNO_CLEAN -DNO_PROFILE -DNO_GAMES -DNO_LIBC_R" # WITHOUT_CDDL=1" + no="$no -DWITHOUT_CLANG" else no="-DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R" fi @@ -882,7 +883,7 @@ fill_floppy_image() { log "Compress with kgzip and copy to floppy image" mkdir -p ${dst}/boot/kernel - # XXX update loader.conf + # XXX loader.conf does not work unless we also load the .4th files echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader" From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:03:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5E6B1065670; Thu, 3 May 2012 21:03:21 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 907F58FC08; Thu, 3 May 2012 21:03: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 q43L3LaK063016; Thu, 3 May 2012 21:03:21 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43L3L74063014; Thu, 3 May 2012 21:03:21 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032103.q43L3L74063014@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 21:03: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: r234984 - head/tools/tools/netrate/netsend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:03:21 -0000 Author: luigi Date: Thu May 3 21:03:21 2012 New Revision: 234984 URL: http://svn.freebsd.org/changeset/base/234984 Log: indicate the time per packet in nanoseconds. Modified: head/tools/tools/netrate/netsend/netsend.c Modified: head/tools/tools/netrate/netsend/netsend.c ============================================================================== --- head/tools/tools/netrate/netsend/netsend.c Thu May 3 20:50:55 2012 (r234983) +++ head/tools/tools/netrate/netsend/netsend.c Thu May 3 21:03:21 2012 (r234984) @@ -147,6 +147,7 @@ timing_loop(struct _a *a) long minres_ns = 20000; int ic, gettimeofday_cycles; int cur_port; + uint64_t n, ns; if (clock_getres(CLOCK_REALTIME, &tmptime) == -1) { perror("clock_getres"); @@ -257,6 +258,13 @@ done: printf("send errors: %ld\n", send_errors); printf("approx send rate: %ld pps\n", (send_calls - send_errors) / a->duration); + n = send_calls - send_errors; + if (n > 0) { + ns = (tmptime.tv_sec - starttime.tv_sec) * 1000000000UL + + (tmptime.tv_nsec - starttime.tv_nsec); + n = ns / n; + } + printf("time/packet: %u ns\n", (u_int)n); printf("approx error rate: %ld\n", (send_errors / send_calls)); printf("waited: %lld\n", waited); printf("approx waits/sec: %lld\n", (long long)(waited / a->duration)); From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:06:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A6641065670; Thu, 3 May 2012 21:06:55 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 7BFF58FC0A; Thu, 3 May 2012 21:06:54 +0000 (UTC) Received: by lbon10 with SMTP id n10so2139926lbo.13 for ; Thu, 03 May 2012 14:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xmQARvYMFE73kil1OfeOehmmBCrKxCLH8Xdq5QNEIGo=; b=OmBGa2simtvDa5oIyjLIdaL3ZZqUUwx1SomiuVg2Y/c+9ehh/BYVy6fINXIE7qwZHL jx5V+dVsKHjaPeo/yKmWe70w64qdXOuaGo5fzbLUriXQ8knX1FHazWFiY7FyBVTWIK7F fihACPCEDI/U7ztxVx3/pQEweBSiWj4kXm+JIuMUyaJ2aT6jD7K8Tccw7jCJTw1SbRIM pEuvwh+1Vf86KA3zWb1CJ8a5IL8GAbp2qJ4UvBgr0qazCQahH4a338hJwhhQ7XGLRlmw KwNto2cEfcE9AvxNvClDM94UMa6fPBPpVo1VnDyehujip6enfcloJfVIGKoMsaDH+KAq 94OA== MIME-Version: 1.0 Received: by 10.152.144.101 with SMTP id sl5mr3414921lab.51.1336079213467; Thu, 03 May 2012 14:06:53 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 14:06:53 -0700 (PDT) In-Reply-To: <20120503132715.GN2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 22:06:53 +0100 X-Google-Sender-Auth: ZqCDjh5acpQSGnh-fxDhNz0oTGA Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:06:55 -0000 2012/5/3 Konstantin Belousov : > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >> 2012/5/3, Konstantin Belousov : >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> >> 2012/5/3, Konstantin Belousov : >> >> > Author: kib >> >> > Date: Thu May =C2=A03 10:38:02 2012 >> >> > New Revision: 234952 >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >> >> > >> >> > Log: >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a callout= since it >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is tempora= rily >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, callo= ut fails >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() retur= ns 0. >> >> > >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop() ca= uses the >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting the = wmesg, >> >> > =C2=A0 since the switch-out is supposed to be transient. In fact, t= he thread >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of bei= ng put on >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process is = unkillable for >> >> > =C2=A0 obvious reasons. >> >> > >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_DFRM= IGRATION >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when the fu= nction >> >> > =C2=A0 detects a migration, besides returning the success. The soft= clock() >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its exec= ution if >> >> > =C2=A0 the flag was cleared meantime. >> >> >> >> Can you please clarify why you cannot simply drop the deferred >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >> > >> > I probably can, I think I went with the route of committed patch >> > because it is slightly less work. Also, the comment in the while() >> > loop suggested me to rely on softclock. >> >> I don't think this is more work at all, the attached patch >> (pre-r234952, untested) should address it properly in few than 10 >> lines: >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >> >> without the need to add further flags and re-using existing mechanisms. > > (cc->cc_curr !=3D c) is not the case which caused the issue. It might be > needed to treatened this way, but the reported case is opposite. Yes, of course, because the migration handover happens in the same critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix is really right. It seems to me that in the case you describe callout_stop() must return 0 and the migration must not be cancelled because the callout is not stopped. It is not stopped not because of the deferred migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid situation to me. Probabilly the bug is in the sleepq use of this mechanism? Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:15:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2197F106566C; Thu, 3 May 2012 21:15:48 +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 E77F58FC12; Thu, 3 May 2012 21:15:47 +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 q43LFlWT063518; Thu, 3 May 2012 21:15:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LFloi063516; Thu, 3 May 2012 21:15:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032115.q43LFloi063516@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:15:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234985 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:15:48 -0000 Author: jpaetzel Date: Thu May 3 21:15:47 2012 New Revision: 234985 URL: http://svn.freebsd.org/changeset/base/234985 Log: Fix parsing values which contain multiple "=" signs. Submitted by: glarkin MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Thu May 3 21:03:21 2012 (r234984) +++ head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Thu May 3 21:15:47 2012 (r234985) @@ -33,7 +33,7 @@ get_value_from_string() { if [ -n "${1}" ] then - export VAL="`echo ${1} | cut -d '=' -f 2-15`" + export VAL="`echo ${1} | cut -d '=' -f 2-`" 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-15` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-` 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-15 | tr -d ' '` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` else exit_err "Error: Did we forgot to supply a setting to grab?" fi @@ -71,7 +71,7 @@ if_check_value_exists() then # Get the first occurrence of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` if [ -z "${VAL}" ] then # This value doesn't exist, lets return @@ -104,7 +104,7 @@ check_value() if [ -n "${1}" -a -n "${2}" ] then # Get the first occurrence of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` VALID="1" for i in ${2} do @@ -133,7 +133,7 @@ file_sanity_check() grep -q "^${i}=" $CFGF 2>/dev/null if [ $? -eq 0 ] then - LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` if [ -z "${LN}" ] then echo "Error: Config fails sanity test! ${i}= is empty" From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:16:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 914F51065673; Thu, 3 May 2012 21:16:54 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CC198FC16; Thu, 3 May 2012 21:16: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 q43LGsPI063595; Thu, 3 May 2012 21:16:54 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LGsYs063593; Thu, 3 May 2012 21:16:54 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032116.q43LGsYs063593@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 21:16: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: r234986 - head/sys/dev/netmap X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:16:54 -0000 Author: luigi Date: Thu May 3 21:16:53 2012 New Revision: 234986 URL: http://svn.freebsd.org/changeset/base/234986 Log: print 'netmap stack ring full' only in verbose mode. Modified: head/sys/dev/netmap/netmap.c Modified: head/sys/dev/netmap/netmap.c ============================================================================== --- head/sys/dev/netmap/netmap.c Thu May 3 21:15:47 2012 (r234985) +++ head/sys/dev/netmap/netmap.c Thu May 3 21:16:53 2012 (r234986) @@ -1067,7 +1067,8 @@ netmap_start(struct ifnet *ifp, struct m kring->nr_hwcur + kring->nr_hwavail, len); na->nm_lock(ifp, NETMAP_CORE_LOCK, 0); if (kring->nr_hwavail >= lim) { - D("stack ring %s full\n", ifp->if_xname); + if (netmap_verbose) + D("stack ring %s full\n", ifp->if_xname); goto done; /* no space */ } if (len > NETMAP_BUF_SIZE) { From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:21:46 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F359F1065674; Thu, 3 May 2012 21:21:45 +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 DE9B58FC12; Thu, 3 May 2012 21:21: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 q43LLj51063809; Thu, 3 May 2012 21:21:45 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LLj9C063807; Thu, 3 May 2012 21:21:45 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032121.q43LLj9C063807@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:21: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: r234987 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:21:46 -0000 Author: jpaetzel Date: Thu May 3 21:21:45 2012 New Revision: 234987 URL: http://svn.freebsd.org/changeset/base/234987 Log: Add the ability to configure multiple interfaces. Submitted by: glarkin Obtained from: PC-BSD MFC after: 3 days Modified: head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-networking.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Thu May 3 21:16:53 2012 (r234986) +++ head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Thu May 3 21:21:45 2012 (r234987) @@ -192,7 +192,7 @@ save_manual_nic() # Get the target nic NIC="$1" - get_value_from_cfg netSaveIP + get_value_from_cfg netSaveIP_${NIC} NETIP="${VAL}" if [ "$NETIP" = "DHCP" ] @@ -212,7 +212,7 @@ save_manual_nic() IFARGS="inet ${NETIP}" # Check if we have a netmask to set - get_value_from_cfg netSaveMask + get_value_from_cfg netSaveMask_${NIC} NETMASK="${VAL}" if [ -n "${NETMASK}" ] then @@ -220,7 +220,7 @@ save_manual_nic() fi fi - get_value_from_cfg netSaveIPv6 + get_value_from_cfg netSaveIPv6_${NIC} NETIP6="${VAL}" if [ -n "${NETIP6}" ] then @@ -239,6 +239,12 @@ save_manual_nic() echo "ifconfig_${NIC}_ipv6=\"${IF6ARGS}\"" >>${FSMNT}/etc/rc.conf fi +}; + +# Function which saves a manual gateway router setup to the installed system +save_manual_router() +{ + # Check if we have a default router to set get_value_from_cfg netSaveDefaultRouter NETROUTE="${VAL}" @@ -253,19 +259,30 @@ save_manual_nic() echo "ipv6_defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf fi +}; + +save_manual_nameserver() +{ # Check if we have a nameserver to enable : > ${FSMNT}/etc/resolv.conf - get_value_from_cfg netSaveNameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf - fi - get_value_from_cfg netSaveIPv6NameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + get_value_from_cfg_with_spaces netSaveNameServer + NAMESERVERLIST="${VAL}" + if [ ! -z "${NAMESERVERLIST}" ] + then + for NAMESERVER in ${NAMESERVERLIST} + do + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + done + fi + + get_value_from_cfg_with_spaces netSaveIPv6NameServer + NAMESERVERLIST="${VAL}" + if [ ! -z "${NAMESERVERLIST}" ] + then + for NAMESERVER in ${NAMESERVERLIST} + do + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + done fi }; @@ -454,25 +471,30 @@ save_networking_install() { # Check if we have any networking requested to save - get_value_from_cfg netSaveDev + get_value_from_cfg_with_spaces netSaveDev if [ -z "${VAL}" ] then return 0 fi - NETDEV="${VAL}" - if [ "$NETDEV" = "AUTO-DHCP" ] + NETDEVLIST="${VAL}" + if [ "$NETDEVLIST" = "AUTO-DHCP" ] then save_auto_dhcp - elif [ "$NETDEV" = "IPv6-SLAAC" ] + elif [ "$NETDEVLIST" = "IPv6-SLAAC" ] then save_auto_slaac - elif [ "$NETDEV" = "AUTO-DHCP-SLAAC" ] + elif [ "$NETDEVLIST" = "AUTO-DHCP-SLAAC" ] then save_auto_dhcp save_auto_slaac else - save_manual_nic ${NETDEV} + for NETDEV in ${NETDEVLIST} + do + save_manual_nic ${NETDEV} + done + save_manual_router + save_manual_nameserver fi }; From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:28:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E2C3E106564A; Thu, 3 May 2012 21:28:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7C08C8FC08; Thu, 3 May 2012 21:28:42 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43LSZLq089113; Fri, 4 May 2012 00:28:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43LSYuf042297; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43LSY9r042296; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 4 May 2012 00:28:34 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503212834.GP2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dKRZzP6oNMY5EfTG" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:28:43 -0000 --dKRZzP6oNMY5EfTG Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: > 2012/5/3 Konstantin Belousov : > > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: > >> 2012/5/3, Konstantin Belousov : > >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > >> >> 2012/5/3, Konstantin Belousov : > >> >> > Author: kib > >> >> > Date: Thu May =9A3 10:38:02 2012 > >> >> > New Revision: 234952 > >> >> > URL: http://svn.freebsd.org/changeset/base/234952 > >> >> > > >> >> > Log: > >> >> > =9A When callout_reset_on() cannot immediately migrate a callout = since it > >> >> > =9A is running on other cpu, the CALLOUT_PENDING flag is temporar= ily > >> >> > =9A cleared. Then, callout_stop() on this, in fact active, callou= t fails > >> >> > =9A because CALLOUT_PENDING is not set, and callout_stop() return= s 0. > >> >> > > >> >> > =9A Now, in sleepq_check_timeout(), the failed callout_stop() cau= ses the > >> >> > =9A sleepq code to execute mi_switch() without even setting the w= mesg, > >> >> > =9A since the switch-out is supposed to be transient. In fact, th= e thread > >> >> > =9A is put off the CPU for full timeout interval, instead of bein= g put on > >> >> > =9A runq immediately. =9AUntil timeout fires, the process is unki= llable for > >> >> > =9A obvious reasons. > >> >> > > >> >> > =9A Fix this by marking the migrating callouts with CALLOUT_DFRMI= GRATION > >> >> > =9A flag. The flag is cleared by callout_stop_safe() when the fun= ction > >> >> > =9A detects a migration, besides returning the success. The softc= lock() > >> >> > =9A rechecks the flag for migrating callout and cancels its execu= tion if > >> >> > =9A the flag was cleared meantime. > >> >> > >> >> Can you please clarify why you cannot simply drop the deferred > >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > >> > > >> > I probably can, I think I went with the route of committed patch > >> > because it is slightly less work. Also, the comment in the while() > >> > loop suggested me to rely on softclock. > >> > >> I don't think this is more work at all, the attached patch > >> (pre-r234952, untested) should address it properly in few than 10 > >> lines: > >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch > >> > >> without the need to add further flags and re-using existing mechanisms. > > > > (cc->cc_curr !=3D c) is not the case which caused the issue. It might be > > needed to treatened this way, but the reported case is opposite. >=20 > Yes, of course, because the migration handover happens in the same > critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix is > really right. >=20 > It seems to me that in the case you describe callout_stop() must > return 0 and the migration must not be cancelled because the callout > is not stopped. It is not stopped not because of the deferred > migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid > situation to me. Yes, and my patch makes the callout to be indeed stopped right after migration is finished. Did you looked at the patch itself ? What is the valid situation ? callout_stop returning 0 but not stopping a pending callout ? I have to disagree. >=20 > Probabilly the bug is in the sleepq use of this mechanism? And, what the bug is, then ? --dKRZzP6oNMY5EfTG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+i+IIACgkQC3+MBN1Mb4g8gACdFRb4hFMRIYccDzPtofqjJk2F oFIAoKunxB+SHTkWgKRHleB37GPxYgE0 =iAP5 -----END PGP SIGNATURE----- --dKRZzP6oNMY5EfTG-- From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:31:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D21E8106566B; Thu, 3 May 2012 21:31:50 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id D231C8FC14; Thu, 3 May 2012 21:31:49 +0000 (UTC) Received: by lagv3 with SMTP id v3so2166477lag.13 for ; Thu, 03 May 2012 14:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=emo8DhR5jaLJrOmpkKGNH0Y2TY78tgpKafzBsigjwFU=; b=OWjLZrqhBthWnltUCQq/yOSH4h7seddkE7qwhBxTZwgldSo+7Q7ato+AmXOd+rceLr oYGIlE98yWfv2Y9eiGJAavkJDVzrR+oybarbWn8prxIwKvY6TYiAV0AXOSphvzzPR4hY wrMd9yzvYCp0Dz3nfKMpqhW7yPa9ob8t2lxB0txlRNVr10UxSFN2Q/nJWHKecchNBdbr ZzduoES7WDu0Ohb/40T7XlLZO17wUou47CKCwJcPGL5zxvMIF9r/gT+dTWqk3/XWUEqw P7SUIqG/Uc1qOt3x/92SFPXHXvSbVe1XIT/NiORX60b+7EurGNofmbMo1bbFtrT+5LZZ mgEg== MIME-Version: 1.0 Received: by 10.152.132.166 with SMTP id ov6mr3801938lab.35.1336080708695; Thu, 03 May 2012 14:31:48 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 14:31:48 -0700 (PDT) In-Reply-To: <20120503212834.GP2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> <20120503212834.GP2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 22:31:48 +0100 X-Google-Sender-Auth: TH52gjxYDjpMyh00j1TxztT-UIU Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:31:50 -0000 2012/5/3 Konstantin Belousov : > On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: >> 2012/5/3 Konstantin Belousov : >> > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >> >> 2012/5/3, Konstantin Belousov : >> >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> >> >> 2012/5/3, Konstantin Belousov : >> >> >> > Author: kib >> >> >> > Date: Thu May =C2=A03 10:38:02 2012 >> >> >> > New Revision: 234952 >> >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >> >> >> > >> >> >> > Log: >> >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a call= out since it >> >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is temp= orarily >> >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, ca= llout fails >> >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() re= turns 0. >> >> >> > >> >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop()= causes the >> >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting t= he wmesg, >> >> >> > =C2=A0 since the switch-out is supposed to be transient. In fact= , the thread >> >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of = being put on >> >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process = is unkillable for >> >> >> > =C2=A0 obvious reasons. >> >> >> > >> >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_D= FRMIGRATION >> >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when the= function >> >> >> > =C2=A0 detects a migration, besides returning the success. The s= oftclock() >> >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its e= xecution if >> >> >> > =C2=A0 the flag was cleared meantime. >> >> >> >> >> >> Can you please clarify why you cannot simply drop the deferred >> >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >> >> > >> >> > I probably can, I think I went with the route of committed patch >> >> > because it is slightly less work. Also, the comment in the while() >> >> > loop suggested me to rely on softclock. >> >> >> >> I don't think this is more work at all, the attached patch >> >> (pre-r234952, untested) should address it properly in few than 10 >> >> lines: >> >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >> >> >> >> without the need to add further flags and re-using existing mechanism= s. >> > >> > (cc->cc_curr !=3D c) is not the case which caused the issue. It might = be >> > needed to treatened this way, but the reported case is opposite. >> >> Yes, of course, because the migration handover happens in the same >> critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix i= s >> really right. >> >> It seems to me that in the case you describe callout_stop() must >> return 0 and the migration must not be cancelled because the callout >> is not stopped. It is not stopped not because of the deferred >> migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid >> situation to me. > Yes, and my patch makes the callout to be indeed stopped right after > migration is finished. Did you looked at the patch itself ? > > What is the valid situation ? callout_stop returning 0 but not stopping > a pending callout ? I have to disagree. The function callout_stop() cancels a callout if it is currently pending. If the callout is pending, then callout_stop() will return a non-zero value. If the callout is not set, has already been serviced or is cur= =E2=80=90 rently being serviced, then zero will be returned. If the callout has= an associated mutex, then that mutex must be held when this function is called. [ From the callout manpage ] If the "callout is currently being serviced" means cc->cc_curr =3D=3D c and it must return 0. I still fail in seeing what are you trying to fix here. Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:39:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 089A0106564A; Thu, 3 May 2012 21:39:24 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7BE78FC0A; Thu, 3 May 2012 21:39:23 +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 q43LdNXa064491; Thu, 3 May 2012 21:39:23 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LdNGa064486; Thu, 3 May 2012 21:39:23 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201205032139.q43LdNGa064486@svn.freebsd.org> From: Jamie Gritton Date: Thu, 3 May 2012 21:39:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234988 - head/usr.sbin/jail X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:39:24 -0000 Author: jamie Date: Thu May 3 21:39:23 2012 New Revision: 234988 URL: http://svn.freebsd.org/changeset/base/234988 Log: Add a meta-parameter IP__NULL to enum intparam, instead of mixing enum values and zeroes. This keeps clang happy (and is just good form). Submitted by: dim Modified: head/usr.sbin/jail/command.c head/usr.sbin/jail/config.c head/usr.sbin/jail/jail.c head/usr.sbin/jail/jailp.h Modified: head/usr.sbin/jail/command.c ============================================================================== --- head/usr.sbin/jail/command.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/command.c Thu May 3 21:39:23 2012 (r234988) @@ -100,7 +100,7 @@ next_command(struct cfjail *j) if (j->comstring == NULL) { j->comparam += create_failed ? -1 : 1; switch ((comparam = *j->comparam)) { - case 0: + case IP__NULL: return 0; case IP_MOUNT_DEVFS: if (!bool_param(j->intparams[IP_MOUNT_DEVFS])) Modified: head/usr.sbin/jail/config.c ============================================================================== --- head/usr.sbin/jail/config.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/config.c Thu May 3 21:39:23 2012 (r234988) @@ -328,7 +328,7 @@ add_param(struct cfjail *j, const struct } } else { flags = PF_APPEND; - if (ipnum != 0) { + if (ipnum != IP__NULL) { name = intparams[ipnum].name; flags |= intparams[ipnum].flags; } else if ((cs = strchr(value, '='))) { @@ -350,7 +350,7 @@ add_param(struct cfjail *j, const struct } /* See if this parameter has already been added. */ - if (ipnum != 0) + if (ipnum != IP__NULL) dp = j->intparams[ipnum]; else TAILQ_FOREACH(dp, &j->params, tq) @@ -375,10 +375,10 @@ add_param(struct cfjail *j, const struct np->flags = flags; np->gen = 0; TAILQ_INSERT_TAIL(&j->params, np, tq); - if (ipnum != 0) + if (ipnum != IP__NULL) j->intparams[ipnum] = np; else - for (ipnum = 1; ipnum < IP_NPARAM; ipnum++) + for (ipnum = IP__NULL + 1; ipnum < IP_NPARAM; ipnum++) if (!(intparams[ipnum].flags & PF_CONV) && equalopts(name, intparams[ipnum].name)) { j->intparams[ipnum] = np; Modified: head/usr.sbin/jail/jail.c ============================================================================== --- head/usr.sbin/jail/jail.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/jail.c Thu May 3 21:39:23 2012 (r234988) @@ -81,7 +81,7 @@ static struct permspec perm_sysctl[] = { }; static const enum intparam startcommands[] = { - 0, + IP__NULL, #ifdef INET IP__IP4_IFADDR, #endif @@ -97,11 +97,11 @@ static const enum intparam startcommands IP_EXEC_START, IP_COMMAND, IP_EXEC_POSTSTART, - 0 + IP__NULL }; static const enum intparam stopcommands[] = { - 0, + IP__NULL, IP_EXEC_PRESTOP, IP_EXEC_STOP, IP_STOP_TIMEOUT, @@ -116,7 +116,7 @@ static const enum intparam stopcommands[ #ifdef INET IP__IP4_IFADDR, #endif - 0 + IP__NULL }; int Modified: head/usr.sbin/jail/jailp.h ============================================================================== --- head/usr.sbin/jail/jailp.h Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/jailp.h Thu May 3 21:39:23 2012 (r234988) @@ -71,7 +71,8 @@ #define JF_DO_STOP(js) (((js) & (JF_SET | JF_STOP)) == JF_STOP) enum intparam { - IP_ALLOW_DYING = 1, /* Allow making changes to a dying jail */ + IP__NULL = 0, /* Null command */ + IP_ALLOW_DYING, /* Allow making changes to a dying jail */ IP_COMMAND, /* Command run inside jail at creation */ IP_DEPEND, /* Jail starts after (stops before) another */ IP_EXEC_CLEAN, /* Run commands in a clean environment */ From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:44:02 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C00321065673; Thu, 3 May 2012 21:44:02 +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 918268FC0C; Thu, 3 May 2012 21:44: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 q43Li2HR064711; Thu, 3 May 2012 21:44:02 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Li2og064707; Thu, 3 May 2012 21:44:02 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201205032144.q43Li2og064707@svn.freebsd.org> From: Attilio Rao Date: Thu, 3 May 2012 21:44: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: r234989 - in head/sys: amd64/include i386/include x86/x86 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:44:02 -0000 Author: attilio Date: Thu May 3 21:44:01 2012 New Revision: 234989 URL: http://svn.freebsd.org/changeset/base/234989 Log: Revert part of r234723 by re-enabling the SMP protection for intr_bind() on x86. This has been requested by jhb and I strongly disagree with this, but as long as he is the x86 and interrupt subsystem maintainer I will follow his directives. The disagreement cames from what we should really consider as a public KPI. IMHO, if we really need a selection between the kernel functions, we may need an explicit protection like _KERNEL_KPI, which defines which subset of the kernel function might really be considered as part of the KPI (for thirdy part modules) and which not. As long as we don't have this mechanism I just consider any possible function as usable by thirdy part code, thus intr_bind() included. MFC after: 1 week Modified: head/sys/amd64/include/intr_machdep.h head/sys/i386/include/intr_machdep.h head/sys/x86/x86/intr_machdep.c Modified: head/sys/amd64/include/intr_machdep.h ============================================================================== --- head/sys/amd64/include/intr_machdep.h Thu May 3 21:39:23 2012 (r234988) +++ head/sys/amd64/include/intr_machdep.h Thu May 3 21:44:01 2012 (r234989) @@ -144,7 +144,9 @@ void intr_add_cpu(u_int cpu); int intr_add_handler(const char *name, int vector, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); +#ifdef SMP int intr_bind(u_int vector, u_char cpu); +#endif int intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol); int intr_describe(u_int vector, void *ih, const char *descr); Modified: head/sys/i386/include/intr_machdep.h ============================================================================== --- head/sys/i386/include/intr_machdep.h Thu May 3 21:39:23 2012 (r234988) +++ head/sys/i386/include/intr_machdep.h Thu May 3 21:44:01 2012 (r234989) @@ -134,7 +134,9 @@ void elcr_write_trigger(u_int irq, enum void intr_add_cpu(u_int cpu); int intr_add_handler(const char *name, int vector, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); +#ifdef SMP int intr_bind(u_int vector, u_char cpu); +#endif int intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol); int intr_describe(u_int vector, void *ih, const char *descr); Modified: head/sys/x86/x86/intr_machdep.c ============================================================================== --- head/sys/x86/x86/intr_machdep.c Thu May 3 21:39:23 2012 (r234988) +++ head/sys/x86/x86/intr_machdep.c Thu May 3 21:44:01 2012 (r234989) @@ -566,14 +566,6 @@ intr_next_cpu(void) return (PCPU_GET(apic_id)); } -/* Return EOPNOTSUPP in the UP case. */ -int -intr_bind(u_int vector __unused, u_char cpu __unused) -{ - - return (EOPNOTSUPP); -} - /* Use an empty stub for compatibility. */ void intr_add_cpu(u_int cpu __unused) From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:53:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 92E29106564A; Thu, 3 May 2012 21:53:26 +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 7D28E8FC08; Thu, 3 May 2012 21:53: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 q43LrQt8065162; Thu, 3 May 2012 21:53:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LrQCL065159; Thu, 3 May 2012 21:53:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032153.q43LrQCL065159@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:53: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: r234990 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:53:26 -0000 Author: jpaetzel Date: Thu May 3 21:53:25 2012 New Revision: 234990 URL: http://svn.freebsd.org/changeset/base/234990 Log: Fix some issues creating zpool mirror / raidz1(2)(3) devices. Fix issues stamping boot on other ZFS drives, now you can boot after removing mirror drive. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Thu May 3 21:44:01 2012 (r234989) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Thu May 3 21:53:25 2012 (r234990) @@ -50,41 +50,39 @@ get_fs_line_xvars() ACTIVEDEV="${1}" LINE="${2}" - echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null + echo $LINE | cut -d ' ' -f 4 | grep -q '(' 2>/dev/null + if [ $? -ne 0 ] ; then return ; fi + + # See if we are looking for ZFS specific options + echo $LINE | grep -q '^ZFS' 2>/dev/null if [ $? -eq 0 ] ; then + ZTYPE="NONE" + ZFSVARS="`echo $LINE | cut -d ' ' -f 4-20 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - # See if we are looking for ZFS specific options - echo $LINE | grep -q '^ZFS' 2>/dev/null + echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null if [ $? -eq 0 ] ; then - ZTYPE="NONE" - ZFSVARS="`echo $LINE | cut -d ' ' -f 4 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - - echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null - if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` - fi - - # Return the ZFS options - if [ "${ZTYPE}" = "NONE" ] ; then - VAR="${ACTIVEDEV} ${ZFSVARS}" - else - VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" - fi - export VAR - return - fi # End of ZFS block + fi - # 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 + # Return the ZFS options + if [ "${ZTYPE}" = "NONE" ] ; then + VAR="${ACTIVEDEV} ${ZFSVARS}" + else + VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" fi + export VAR + return + fi # End of ZFS block - fi # End of xtra-options 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 # If we got here, set VAR to empty and export export VAR="" @@ -96,8 +94,10 @@ setup_zfs_mirror_parts() { _nZFS="" + ZTYPE="`echo ${1} | awk '{print $1}'`" + # Using mirroring, setup boot partitions on each disk - _mirrline="`echo ${1} | sed 's|mirror ||g'`" + _mirrline="`echo ${1} | sed 's|mirror ||g' | sed 's|raidz1 ||g' | sed 's|raidz2 ||g' | sed 's|raidz3 ||g' | sed 's|raidz ||g'`" for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} @@ -107,15 +107,16 @@ setup_zfs_mirror_parts() is_disk "$_zvars" >/dev/null 2>/dev/null if [ $? -eq 0 ] ; then - echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} + echo "Setting up ZFS disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null - rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null _nZFS="$_nZFS ${_zvars}p2" else _nZFS="$_nZFS ${_zvars}" fi done - echo "mirror $2 `echo $_nZFS | tr -s ' '`" + echo "$ZTYPE $2 `echo $_nZFS | tr -s ' '`" } ; # Function which creates a unique label name for the specified mount @@ -290,15 +291,15 @@ setup_gpart_partitions() else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi - XTRAOPTS="${VAR}" + XTRAOPTS="$VAR" # Check if using zfs mirror - echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null + echo ${XTRAOPTS} | grep -q -e "mirror" -e "raidz" if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}") + XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") fi fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Thu May 3 21:44:01 2012 (r234989) +++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Thu May 3 21:53:25 2012 (r234990) @@ -44,6 +44,23 @@ setup_zfs_filesystem() sleep 5 sync + # Check if we have multiple zfs mounts specified + for i in `echo ${PARTMNT} | sed 's|,| |g'` + do + # Check if we ended up with needing a zfs bootable partition + if [ "${i}" = "/" -o "${i}" = "/boot" ] + then + if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi + if [ "${PARTGEOM}" = "MBR" ] ; then + # Lets stamp the proper ZFS boot loader + echo_log "Setting up ZFS boot loader support" + rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" + rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" + fi + fi + done + + # Check if we have some custom zpool arguments and use them if so if [ ! -z "${ZPOOLOPTS}" ] ; then rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}" @@ -55,23 +72,13 @@ setup_zfs_filesystem() # Disable atime for this zfs partition, speed increase rc_nohalt "zfs set atime=off ${ZPOOLNAME}" - # Check if we have multiple zfs mounts specified + # Check if we need to set a bootable zpool for i in `echo ${PARTMNT} | sed 's|,| |g'` do - # Check if we ended up with needing a zfs bootable partition - if [ "${i}" = "/" -o "${i}" = "/boot" ] - then + if [ "${i}" = "/" -o "${i}" = "/boot" ] ; then if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi - if [ "${PARTGEOM}" = "MBR" ] - then - # Lets stamp the proper ZFS boot loader - echo_log "Setting up ZFS boot loader support" - rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" - rc_halt "zpool export ${ZPOOLNAME}" - rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" - rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" - rc_halt "zpool import ${ZPOOLNAME}" - fi + echo_log "Stamping zpool as bootfs" + rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" fi done @@ -90,11 +97,6 @@ setup_filesystems() for PART in `ls ${PARTDIR}` do PARTDEV="`echo $PART | sed 's|-|/|g'`" - if [ ! -e "${PARTDEV}" ] - then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" @@ -103,6 +105,10 @@ setup_filesystems() PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`" PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`" + if [ ! -e "${PARTDEV}" ] ; then + exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" + fi + # Make sure journaling isn't enabled on this device if [ -e "${PARTDEV}.journal" ] then From owner-svn-src-all@FreeBSD.ORG Thu May 3 22:24:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 772C6106564A; Thu, 3 May 2012 22:24:26 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 84D848FC14; Thu, 3 May 2012 22:24:25 +0000 (UTC) Received: by lbon10 with SMTP id n10so2195187lbo.13 for ; Thu, 03 May 2012 15:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Ll9aLERW+fYxBAo7n3vXDfzhaye9ydx8Nb6rB0hMh9s=; b=bXL65MQguDkolXotkLAgkli/g4tsmC6F/nCqttppRE74e0ljo7Rmu9T566rm2/lNsu WrWQGBXX85aUf/8Vnxxj9EzGIU/kRUT0rDU+aokYfwYGIEqVG3JAGqRvjzmWhRYqU1Ec 1JAI4dup7ePWKdMbvKSROEvX9QEGCXex9K93N4d/81gtA0zS9tPCw5GXPC+7bV2fYgDD nq7+hV1ukRFiQjGqe3dNVshLiHwmKdHzg67CK0RN2oqOMNM1Wu3FGPuOFZCwmybXA8Pf MJa3c34jWp4wCFTcAhMFTm78P1LvyssRQUHxFt3LgMERlU+aBwTVl/sUcldQt1i6W7xQ AfRg== MIME-Version: 1.0 Received: by 10.112.37.132 with SMTP id y4mr1857393lbj.8.1336083864102; Thu, 03 May 2012 15:24:24 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 15:24:23 -0700 (PDT) In-Reply-To: References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> <20120503212834.GP2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 23:24:23 +0100 X-Google-Sender-Auth: P3Ax9-DfnhXpngnoCSfSm4I0tVM Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 22:24:26 -0000 2012/5/3 Attilio Rao : > 2012/5/3 Konstantin Belousov : >> On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: >>> 2012/5/3 Konstantin Belousov : >>> > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >>> >> 2012/5/3, Konstantin Belousov : >>> >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >>> >> >> 2012/5/3, Konstantin Belousov : >>> >> >> > Author: kib >>> >> >> > Date: Thu May =C2=A03 10:38:02 2012 >>> >> >> > New Revision: 234952 >>> >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >>> >> >> > >>> >> >> > Log: >>> >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a cal= lout since it >>> >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is tem= porarily >>> >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, c= allout fails >>> >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() r= eturns 0. >>> >> >> > >>> >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop(= ) causes the >>> >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting = the wmesg, >>> >> >> > =C2=A0 since the switch-out is supposed to be transient. In fac= t, the thread >>> >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of= being put on >>> >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process= is unkillable for >>> >> >> > =C2=A0 obvious reasons. >>> >> >> > >>> >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_= DFRMIGRATION >>> >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when th= e function >>> >> >> > =C2=A0 detects a migration, besides returning the success. The = softclock() >>> >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its = execution if >>> >> >> > =C2=A0 the flag was cleared meantime. >>> >> >> >>> >> >> Can you please clarify why you cannot simply drop the deferred >>> >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >>> >> > >>> >> > I probably can, I think I went with the route of committed patch >>> >> > because it is slightly less work. Also, the comment in the while() >>> >> > loop suggested me to rely on softclock. >>> >> >>> >> I don't think this is more work at all, the attached patch >>> >> (pre-r234952, untested) should address it properly in few than 10 >>> >> lines: >>> >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >>> >> >>> >> without the need to add further flags and re-using existing mechanis= ms. >>> > >>> > (cc->cc_curr !=3D c) is not the case which caused the issue. It might= be >>> > needed to treatened this way, but the reported case is opposite. >>> >>> Yes, of course, because the migration handover happens in the same >>> critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix = is >>> really right. >>> >>> It seems to me that in the case you describe callout_stop() must >>> return 0 and the migration must not be cancelled because the callout >>> is not stopped. It is not stopped not because of the deferred >>> migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid >>> situation to me. >> Yes, and my patch makes the callout to be indeed stopped right after >> migration is finished. Did you looked at the patch itself ? >> >> What is the valid situation ? callout_stop returning 0 but not stopping >> a pending callout ? I have to disagree. > > The function callout_stop() cancels a callout if it is currently pending. > =C2=A0 =C2=A0 If the callout is pending, then callout_stop() will return = a non-zero > =C2=A0 =C2=A0 value. =C2=A0If the callout is not set, has already been se= rviced or is cur=E2=80=90 > =C2=A0 =C2=A0 rently being serviced, then zero will be returned. =C2=A0If= the callout has an > =C2=A0 =C2=A0 associated mutex, then that mutex must be held when this fu= nction is > =C2=A0 =C2=A0 called. > > [ From the callout manpage ] > > If the "callout is currently being serviced" means cc->cc_curr =3D=3D c > and it must return 0. Elaborating some more, I see a discrepancy here in the callout interface, which is also present pre-your patch and pre-migration delay. Basically, immagine a callout rearmed during its callback (pretty typical) and a callout_stop() running just after the callout has been rearmed and it is *still* in the callback. What we find is that CALLOUT_PENDING is on and that cc_curr =3D=3D cc. I don't think that the callout should stop successfully in this case. However, because of how _callout_stop_safe() is written, CALLOUT_PENDING check has precedence and wins, returning 1 and removing the CALLOUT_PENDING flag, but please note that the callback is still running (even if only for little time). I think this generally works ok because most of the callout callbacks rearm the callout as last thing in their operation. But I think this is highly fragile and we cannot really rely on this feature. You are seeing a problem in the deferred migration case because it does the other way around, it prefers the check over cc_curr =3D=3D cc to the "pending" (callout migration in this case). I think this is only a problem, also, with callouts which don't have a lock associated with them, like the sleepqueue case, because otherwise the interlock would leave the state consistent. I think we need to think carefully about a pattern for this case that deals with all the races, I need to give this more thinking, but definitively it seems to me we need a patch at the callout policy level. Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-all@FreeBSD.ORG Fri May 4 02:26:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2494E106564A; Fri, 4 May 2012 02:26:16 +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 0FE718FC08; Fri, 4 May 2012 02:26:16 +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 q442QF8X081454; Fri, 4 May 2012 02:26:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q442QFfp081451; Fri, 4 May 2012 02:26:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205040226.q442QFfp081451@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 May 2012 02:26: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: r234992 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 02:26:16 -0000 Author: adrian Date: Fri May 4 02:26:15 2012 New Revision: 234992 URL: http://svn.freebsd.org/changeset/base/234992 Log: Disable setting the MII port speed. This seems to break at least my test board here (AR71xx + AR8316 switch PHY). Since I do have a whole sleuth of "normal" PHY boards (with an AR71xx on a normal PHY port), I'll do some further testing with those to determine whether this is a general issue, or whether it's limited to the behaviour of the "fake" dedicated PHY port mode on these atheros switches. Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Fri May 4 01:35:13 2012 (r234991) +++ head/sys/mips/atheros/if_arge.c Fri May 4 02:26:15 2012 (r234992) @@ -932,7 +932,19 @@ arge_set_pll(struct arge_softc *sc, int ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); /* set MII registers */ + /* + * This was introduced to match what the Linux ag71xx ethernet + * driver does. For the AR71xx case, it does set the port + * MII speed. However, if this is done, non-gigabit speeds + * are not at all reliable when speaking via RGMII through + * 'bridge' PHY port that's pretending to be a local PHY. + * + * Until that gets root caused, and until an AR71xx + normal + * PHY board is tested, leave this disabled. + */ +#if 0 ar71xx_device_set_mii_speed(sc->arge_mac_unit, if_speed); +#endif } From owner-svn-src-all@FreeBSD.ORG Fri May 4 07:32:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59D5D106564A; Fri, 4 May 2012 07:32:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 43DD08FC0C; Fri, 4 May 2012 07:32: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 q447WwFV092211; Fri, 4 May 2012 07:32:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q447Wwcw092207; Fri, 4 May 2012 07:32:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205040732.q447Wwcw092207@svn.freebsd.org> From: Alexander Motin Date: Fri, 4 May 2012 07:32: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: r234993 - in head: sbin/geom/class/raid sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 07:32:58 -0000 Author: mav Date: Fri May 4 07:32:57 2012 New Revision: 234993 URL: http://svn.freebsd.org/changeset/base/234993 Log: Implement read-only support for volumes in optimal state (without using redundancy) for the following RAID levels: RAID4/5E/5EE/6/MDF. Modified: head/sbin/geom/class/raid/graid.8 head/sys/geom/raid/g_raid.c head/sys/geom/raid/tr_raid5.c Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Fri May 4 02:26:15 2012 (r234992) +++ head/sbin/geom/class/raid/graid.8 Fri May 4 07:32:57 2012 (r234993) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 30, 2012 +.Dd May 3, 2012 .Dt GRAID 8 .Os .Sh NAME @@ -261,9 +261,11 @@ own risk: RAID1 (3+ disks), RAID10 (6+ d .Sh SUPPORTED RAID LEVELS The GEOM RAID class follows a modular design, allowing different RAID levels to be used. -Support for the following RAID levels is currently implemented: RAID0, RAID1, -RAID1E, RAID5, RAID10, SINGLE, CONCAT. -RAID5 support is read-only and only for volumes in optimal state. +Full support for the following RAID levels is currently implemented: +RAID0, RAID1, RAID1E, RAID10, SINGLE, CONCAT. +The following RAID levels supported as read-only for volumes in optimal +state (without using redundancy): RAID4, RAID5, RAID5E, RAID5EE, RAID6, +RAIDMDF. .Sh RAID LEVEL MIGRATION The GEOM RAID class has no support for RAID level migration, allowed by some metadata formats. Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Fri May 4 02:26:15 2012 (r234992) +++ head/sys/geom/raid/g_raid.c Fri May 4 07:32:57 2012 (r234993) @@ -376,17 +376,17 @@ g_raid_volume_str2level(const char *str, else if (strcasecmp(str, "RAID3-P0") == 0) { *level = G_RAID_VOLUME_RL_RAID3; *qual = G_RAID_VOLUME_RLQ_R3P0; - } else if (strcasecmp(str, "RAID3-PN") == 0 && + } else if (strcasecmp(str, "RAID3-PN") == 0 || strcasecmp(str, "RAID3") == 0) { *level = G_RAID_VOLUME_RL_RAID3; - *qual = G_RAID_VOLUME_RLQ_R3P0; + *qual = G_RAID_VOLUME_RLQ_R3PN; } else if (strcasecmp(str, "RAID4-P0") == 0) { *level = G_RAID_VOLUME_RL_RAID4; *qual = G_RAID_VOLUME_RLQ_R4P0; - } else if (strcasecmp(str, "RAID4-PN") == 0 && + } else if (strcasecmp(str, "RAID4-PN") == 0 || strcasecmp(str, "RAID4") == 0) { *level = G_RAID_VOLUME_RL_RAID4; - *qual = G_RAID_VOLUME_RLQ_R4P0; + *qual = G_RAID_VOLUME_RLQ_R4PN; } else if (strcasecmp(str, "RAID5-RA") == 0) { *level = G_RAID_VOLUME_RL_RAID5; *qual = G_RAID_VOLUME_RLQ_R5RA; Modified: head/sys/geom/raid/tr_raid5.c ============================================================================== --- head/sys/geom/raid/tr_raid5.c Fri May 4 02:26:15 2012 (r234992) +++ head/sys/geom/raid/tr_raid5.c Fri May 4 07:32:57 2012 (r234993) @@ -106,9 +106,16 @@ g_raid_tr_taste_raid5(struct g_raid_tr_o trs = (struct g_raid_tr_raid5_object *)tr; qual = tr->tro_volume->v_raid_level_qualifier; - if (tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5 && + if (tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID4 && + qual >= 0 && qual <= 1) { + /* RAID4 */ + } else if ((tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5 || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5E || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5EE || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID6 || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAIDMDF) && qual >= 0 && qual <= 3) { - /* RAID5 */ + /* RAID5/5E/5EE/6/MDF */ } else return (G_RAID_TR_TASTE_FAIL); trs->trso_starting = 1; @@ -203,30 +210,55 @@ g_raid_tr_iostart_raid5_read(struct g_ra struct bio *cbp; char *addr; off_t offset, start, length, nstripe, remain; - int no, pno; - u_int strip_size, qual; + int no, pno, ddisks, pdisks; + u_int strip_size, lvl, qual; vol = tr->tro_volume; addr = bp->bio_data; strip_size = vol->v_strip_size; + lvl = tr->tro_volume->v_raid_level; qual = tr->tro_volume->v_raid_level_qualifier; /* Stripe number. */ nstripe = bp->bio_offset / strip_size; /* Start position in stripe. */ start = bp->bio_offset % strip_size; + /* Number of data and parity disks. */ + if (lvl == G_RAID_VOLUME_RL_RAIDMDF) + pdisks = 3; + else if (lvl == G_RAID_VOLUME_RL_RAID5EE || + lvl == G_RAID_VOLUME_RL_RAID6) + pdisks = 2; + else + pdisks = 1; + ddisks = vol->v_disks_count - pdisks; /* Parity disk number. */ - pno = nstripe / (vol->v_disks_count - 1) % vol->v_disks_count; - if (qual >= 2) - pno = (vol->v_disks_count - 1) - pno; - /* Disk number. */ - no = nstripe % (vol->v_disks_count - 1); - if (qual & 1) { - no = (pno + no + 1) % vol->v_disks_count; - } else if (no >= pno) - no++; + if (lvl == G_RAID_VOLUME_RL_RAID4) { + if (qual == 0) /* P0 */ + pno = 0; + else /* PN */ + pno = ddisks; + } else { + pno = (nstripe / ddisks) % vol->v_disks_count; + if (qual >= 2) { /* PN/Left */ + pno = ddisks - pno; + if (pno < 0) + pno += vol->v_disks_count; + } + } + /* Data disk number. */ + no = nstripe % ddisks; + if (lvl == G_RAID_VOLUME_RL_RAID4) { + if (qual == 0) + no += pdisks; + } else if (qual & 1) { /* Continuation/Symmetric */ + no = (pno + pdisks + no) % vol->v_disks_count; + } else if (no >= pno) /* Restart/Asymmetric */ + no += pdisks; + else + no += imax(0, pno + pdisks - vol->v_disks_count); /* Stripe start position in disk. */ - offset = (nstripe / (vol->v_disks_count - 1)) * strip_size; + offset = (nstripe / ddisks) * strip_size; /* Length of data to operate. */ remain = bp->bio_length; @@ -242,33 +274,37 @@ g_raid_tr_iostart_raid5_read(struct g_ra cbp->bio_caller1 = &vol->v_subdisks[no]; bioq_insert_tail(&queue, cbp); no++; - if (qual & 1) { + if (lvl == G_RAID_VOLUME_RL_RAID4) { + no %= vol->v_disks_count; + if (no == pno) + no = (no + pdisks) % vol->v_disks_count; + } else if (qual & 1) { /* Continuation/Symmetric */ no %= vol->v_disks_count; if (no == pno) { - if (qual < 2) { - pno = (pno + 1) % vol->v_disks_count; - no = (no + 2) % vol->v_disks_count; - } else if (pno == 0) - pno = vol->v_disks_count - 1; - else - pno--; + if (qual < 2) /* P0/Right */ + pno++; + else /* PN/Left */ + pno += vol->v_disks_count - 1; + pno %= vol->v_disks_count; + no = (pno + pdisks) % vol->v_disks_count; offset += strip_size; } - } else { + } else { /* Restart/Asymmetric */ if (no == pno) - no++; + no += pdisks; if (no >= vol->v_disks_count) { - no %= vol->v_disks_count; - if (qual < 2) - pno = (pno + 1) % vol->v_disks_count; - else if (pno == 0) - pno = vol->v_disks_count - 1; + no -= vol->v_disks_count; + if (qual < 2) /* P0/Right */ + pno++; + else /* PN/Left */ + pno += vol->v_disks_count - 1; + pno %= vol->v_disks_count; + if (no == pno) + no += pdisks; else - pno--; + no += imax(0, pno + pdisks - vol->v_disks_count); offset += strip_size; } - if (no == pno) - no++; } remain -= length; addr += length; From owner-svn-src-all@FreeBSD.ORG Fri May 4 08:59:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D0AC106566B; Fri, 4 May 2012 08:59:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48BC78FC0C; Fri, 4 May 2012 08:59:20 +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 q448xKrs094852; Fri, 4 May 2012 08:59:20 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q448xKXm094850; Fri, 4 May 2012 08:59:20 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205040859.q448xKXm094850@svn.freebsd.org> From: Alexander Motin Date: Fri, 4 May 2012 08:59:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234994 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 08:59:20 -0000 Author: mav Date: Fri May 4 08:59:19 2012 New Revision: 234994 URL: http://svn.freebsd.org/changeset/base/234994 Log: Fix bug causing memory corruption and panics with big-endian metadata. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Fri May 4 07:32:57 2012 (r234993) +++ head/sys/geom/raid/md_ddf.c Fri May 4 08:59:19 2012 (r234994) @@ -789,7 +789,7 @@ ddf_meta_update(struct ddf_meta *meta, s if (isff(spde->PD_GUID, 24)) continue; j = ddf_meta_find_pd(meta, NULL, - src->pdr->entry[i].PD_Reference); + GET32(src, pdr->entry[i].PD_Reference)); if (j < 0) { j = ddf_meta_find_pd(meta, NULL, 0xffffffff); pde = &meta->pdr->entry[j]; From owner-svn-src-all@FreeBSD.ORG Fri May 4 09:27:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 091E71065670; Fri, 4 May 2012 09:27:01 +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 DC8C38FC08; Fri, 4 May 2012 09:27:00 +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 q449R0hD095740; Fri, 4 May 2012 09:27:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q449R03S095729; Fri, 4 May 2012 09:27:00 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205040927.q449R03S095729@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 09:27:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234995 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 09:27:01 -0000 Author: tuexen Date: Fri May 4 09:27:00 2012 New Revision: 234995 URL: http://svn.freebsd.org/changeset/base/234995 Log: Use SCTP_PRINTF() instead of printf() in all SCTP sources. MFC after: 3 days Modified: head/sys/netinet/sctp_auth.c head/sys/netinet/sctp_bsd_addr.c head/sys/netinet/sctp_cc_functions.c head/sys/netinet/sctp_crc32.c head/sys/netinet/sctp_indata.c head/sys/netinet/sctp_input.c head/sys/netinet/sctp_os_bsd.h head/sys/netinet/sctp_output.c head/sys/netinet/sctp_pcb.c head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_auth.c ============================================================================== --- head/sys/netinet/sctp_auth.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_auth.c Fri May 4 09:27:00 2012 (r234995) @@ -284,16 +284,16 @@ sctp_print_key(sctp_key_t * key, const c uint32_t i; if (key == NULL) { - printf("%s: [Null key]\n", str); + SCTP_PRINTF("%s: [Null key]\n", str); return; } - printf("%s: len %u, ", str, key->keylen); + SCTP_PRINTF("%s: len %u, ", str, key->keylen); if (key->keylen) { for (i = 0; i < key->keylen; i++) - printf("%02x", key->key[i]); - printf("\n"); + SCTP_PRINTF("%02x", key->key[i]); + SCTP_PRINTF("\n"); } else { - printf("[Null key]\n"); + SCTP_PRINTF("[Null key]\n"); } } @@ -303,16 +303,16 @@ sctp_show_key(sctp_key_t * key, const ch uint32_t i; if (key == NULL) { - printf("%s: [Null key]\n", str); + SCTP_PRINTF("%s: [Null key]\n", str); return; } - printf("%s: len %u, ", str, key->keylen); + SCTP_PRINTF("%s: len %u, ", str, key->keylen); if (key->keylen) { for (i = 0; i < key->keylen; i++) - printf("%02x", key->key[i]); - printf("\n"); + SCTP_PRINTF("%02x", key->key[i]); + SCTP_PRINTF("\n"); } else { - printf("[Null key]\n"); + SCTP_PRINTF("[Null key]\n"); } } Modified: head/sys/netinet/sctp_bsd_addr.c ============================================================================== --- head/sys/netinet/sctp_bsd_addr.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_bsd_addr.c Fri May 4 09:27:00 2012 (r234995) @@ -483,7 +483,7 @@ again_locked: } /* Sanity check */ if (thisend >= SCTP_PACKET_LOG_SIZE) { - printf("Insanity stops a log thisbegin:%d thisend:%d writers:%d lock:%d end:%d\n", + SCTP_PRINTF("Insanity stops a log thisbegin:%d thisend:%d writers:%d lock:%d end:%d\n", thisbegin, thisend, SCTP_BASE_VAR(packet_log_writers), Modified: head/sys/netinet/sctp_cc_functions.c ============================================================================== --- head/sys/netinet/sctp_cc_functions.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_cc_functions.c Fri May 4 09:27:00 2012 (r234995) @@ -1594,9 +1594,7 @@ sctp_hs_cwnd_increase(struct sctp_tcb *s cur_val = net->cwnd >> 10; indx = SCTP_HS_TABLE_SIZE - 1; -#ifdef SCTP_DEBUG - printf("HS CC CAlled.\n"); -#endif + if (cur_val < sctp_cwnd_adjust[0].cwnd) { /* normal mode */ if (net->net_ack > net->mtu) { Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_crc32.c Fri May 4 09:27:00 2012 (r234995) @@ -134,7 +134,7 @@ sctp_delayed_cksum(struct mbuf *m, uint3 offset += offsetof(struct sctphdr, checksum); if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) { - printf("sctp_delayed_cksum(): m->len: %d, off: %d.\n", + SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n", (uint32_t) m->m_len, offset); /* * XXX this shouldn't happen, but if it does, the correct Modified: head/sys/netinet/sctp_indata.c ============================================================================== --- head/sys/netinet/sctp_indata.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_indata.c Fri May 4 09:27:00 2012 (r234995) @@ -328,7 +328,7 @@ sctp_mark_non_revokable(struct sctp_asso } SCTP_CALC_TSN_TO_GAP(gap, tsn, asoc->mapping_array_base_tsn); if (!SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) { - printf("gap:%x tsn:%x\n", gap, tsn); + SCTP_PRINTF("gap:%x tsn:%x\n", gap, tsn); sctp_print_mapping_array(asoc); #ifdef INVARIANTS panic("Things are really messed up now!!"); @@ -2308,7 +2308,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS for (i = 0; i < asoc->mapping_array_size; i++) { if ((asoc->mapping_array[i]) || (asoc->nr_mapping_array[i])) { - printf("Error Mapping array's not clean at clear\n"); + SCTP_PRINTF("Error Mapping array's not clean at clear\n"); sctp_print_mapping_array(asoc); } } @@ -2330,7 +2330,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS panic("impossible slide"); #else - printf("impossible slide lgap:%x slide_end:%x slide_from:%x? at:%d\n", + SCTP_PRINTF("impossible slide lgap:%x slide_end:%x slide_from:%x? at:%d\n", lgap, slide_end, slide_from, at); return; #endif @@ -2339,7 +2339,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS panic("would overrun buffer"); #else - printf("Gak, would have overrun map end:%d slide_end:%d\n", + SCTP_PRINTF("Gak, would have overrun map end:%d slide_end:%d\n", asoc->mapping_array_size, slide_end); slide_end = asoc->mapping_array_size; #endif @@ -3489,7 +3489,10 @@ sctp_strike_gap_ack_chunks(struct sctp_t continue; } } - /* printf("OK, we are now ready to FR this guy\n"); */ + /* + * SCTP_PRINTF("OK, we are now ready to FR this + * guy\n"); + */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(tp1->rec.data.TSN_seq, tp1->snd_count, 0, SCTP_FR_MARKED); @@ -3557,7 +3560,7 @@ sctp_strike_gap_ack_chunks(struct sctp_t tot_retrans++; /* mark the sending seq for possible subsequent FR's */ /* - * printf("Marking TSN for FR new value %x\n", + * SCTP_PRINTF("Marking TSN for FR new value %x\n", * (uint32_t)tpi->rec.data.TSN_seq); */ if (TAILQ_EMPTY(&asoc->send_queue)) { @@ -3709,11 +3712,10 @@ sctp_fs_audit(struct sctp_association *a TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { if (chk->sent < SCTP_DATAGRAM_RESEND) { - printf("Chk TSN:%u size:%d inflight cnt:%d\n", + SCTP_PRINTF("Chk TSN:%u size:%d inflight cnt:%d\n", chk->rec.data.TSN_seq, chk->send_size, - chk->snd_count - ); + chk->snd_count); inflight++; } else if (chk->sent == SCTP_DATAGRAM_RESEND) { resend++; @@ -3730,7 +3732,7 @@ sctp_fs_audit(struct sctp_association *a #ifdef INVARIANTS panic("Flight size-express incorrect? \n"); #else - printf("asoc->total_flight:%d cnt:%d\n", + SCTP_PRINTF("asoc->total_flight:%d cnt:%d\n", entry_flight, entry_cnt); SCTP_PRINTF("Flight size-express incorrect F:%d I:%d R:%d Ab:%d ACK:%d\n", @@ -3895,7 +3897,7 @@ sctp_express_handle_sack(struct sctp_tcb TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { if (SCTP_TSN_GE(cumack, tp1->rec.data.TSN_seq)) { if (tp1->sent == SCTP_DATAGRAM_UNSENT) { - printf("Warning, an unsent is now acked?\n"); + SCTP_PRINTF("Warning, an unsent is now acked?\n"); } if (tp1->sent < SCTP_DATAGRAM_ACKED) { /* @@ -4437,10 +4439,10 @@ sctp_handle_sack(struct mbuf *m, int off * no way, we have not even sent this TSN out yet. * Peer is hopelessly messed up with us. */ - printf("NEW cum_ack:%x send_s:%x is smaller or equal\n", + SCTP_PRINTF("NEW cum_ack:%x send_s:%x is smaller or equal\n", cum_ack, send_s); if (tp1) { - printf("Got send_s from tsn:%x + 1 of tp1:%p\n", + SCTP_PRINTF("Got send_s from tsn:%x + 1 of tp1:%p\n", tp1->rec.data.TSN_seq, tp1); } hopeless_peer: @@ -4681,10 +4683,8 @@ sctp_handle_sack(struct mbuf *m, int off * peer is either confused or we are under * attack. We must abort. */ - printf("Hopeless peer! biggest_tsn_acked:%x largest seq:%x\n", - biggest_tsn_acked, - send_s); - + SCTP_PRINTF("Hopeless peer! biggest_tsn_acked:%x largest seq:%x\n", + biggest_tsn_acked, send_s); goto hopeless_peer; } } @@ -4719,7 +4719,7 @@ sctp_handle_sack(struct mbuf *m, int off } if (tp1->sent == SCTP_DATAGRAM_UNSENT) { /* no more sent on list */ - printf("Warning, tp1->sent == %d and its now acked?\n", + SCTP_PRINTF("Warning, tp1->sent == %d and its now acked?\n", tp1->sent); } TAILQ_REMOVE(&asoc->sent_queue, tp1, sctp_next); Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_input.c Fri May 4 09:27:00 2012 (r234995) @@ -786,12 +786,12 @@ sctp_handle_abort(struct sctp_abort_chun sctp_abort_notification(stcb, 0, SCTP_SO_NOT_LOCKED); /* free the tcb */ #if defined(SCTP_PANIC_ON_ABORT) - printf("stcb:%p state:%d rport:%d net:%p\n", + SCTP_PRINTF("stcb:%p state:%d rport:%d net:%p\n", stcb, stcb->asoc.state, stcb->rport, net); if (!(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { panic("Received an ABORT"); } else { - printf("No panic its in state %x closed\n", stcb->asoc.state); + SCTP_PRINTF("No panic its in state %x closed\n", stcb->asoc.state); } #endif SCTP_STAT_INCR_COUNTER32(sctps_aborted); @@ -5792,9 +5792,9 @@ static void sctp_print_mbuf_chain(struct mbuf *m) { for (; m; m = SCTP_BUF_NEXT(m)) { - printf("%p: m_len = %ld\n", m, SCTP_BUF_LEN(m)); + SCTP_PRINTF("%p: m_len = %ld\n", m, SCTP_BUF_LEN(m)); if (SCTP_BUF_IS_EXTENDED(m)) - printf("%p: extend_size = %d\n", m, SCTP_BUF_EXTEND_SIZE(m)); + SCTP_PRINTF("%p: extend_size = %d\n", m, SCTP_BUF_EXTEND_SIZE(m)); } } Modified: head/sys/netinet/sctp_os_bsd.h ============================================================================== --- head/sys/netinet/sctp_os_bsd.h Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_os_bsd.h Fri May 4 09:27:00 2012 (r234995) @@ -157,12 +157,13 @@ MALLOC_DECLARE(SCTP_M_MCORE); */ #define USER_ADDR_NULL (NULL) /* FIX ME: temp */ +#define SCTP_PRINTF(params...) printf(params) #if defined(SCTP_DEBUG) #define SCTPDBG(level, params...) \ { \ do { \ if (SCTP_BASE_SYSCTL(sctp_debug_on) & level ) { \ - printf(params); \ + SCTP_PRINTF(params); \ } \ } while (0); \ } @@ -187,7 +188,6 @@ MALLOC_DECLARE(SCTP_M_MCORE); #define SCTPDBG_ADDR(level, addr) #define SCTPDBG_PKT(level, iph, sh) #endif -#define SCTP_PRINTF(params...) printf(params) #ifdef SCTP_LTRACE_CHUNKS #define SCTP_LTRACE_CHK(a, b, c, d) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_CHUNK_ENABLE) SCTP_CTR6(KTR_SUBSYS, "SCTP:%d[%d]:%x-%x-%x-%x", SCTP_LOG_CHUNK_PROC, 0, a, b, c, d) @@ -196,12 +196,14 @@ MALLOC_DECLARE(SCTP_M_MCORE); #endif #ifdef SCTP_LTRACE_ERRORS -#define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ - printf("mbuf:%p inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ - m, inp, stcb, net, file, __LINE__, err); -#define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ - printf("inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ - inp, stcb, net, file, __LINE__, err); +#define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ + SCTP_PRINTF("mbuf:%p inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ + m, inp, stcb, net, file, __LINE__, err); +#define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ + SCTP_PRINTF("inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ + inp, stcb, net, file, __LINE__, err); #else #define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) #define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_output.c Fri May 4 09:27:00 2012 (r234995) @@ -3062,7 +3062,7 @@ again_with_private_addresses_allowed: continue; } } else { - printf("Stcb is null - no print\n"); + SCTP_PRINTF("Stcb is null - no print\n"); } atomic_add_int(&sifa->refcount, 1); goto out; @@ -9493,7 +9493,7 @@ sctp_chunk_retransmission(struct sctp_in continue; } if (chk->data == NULL) { - printf("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n", + SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n", chk->rec.data.TSN_seq, chk->snd_count, chk->sent); continue; } @@ -13840,7 +13840,7 @@ out_unlocked: if (inp) { sctp_validate_no_locks(inp); } else { - printf("Warning - inp is NULL so cant validate locks\n"); + SCTP_PRINTF("Warning - inp is NULL so cant validate locks\n"); } #endif if (top) { Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_pcb.c Fri May 4 09:27:00 2012 (r234995) @@ -2426,8 +2426,8 @@ sctp_findassociation_ep_asconf(struct mb stcb = sctp_findassoc_by_vtag(NULL, to, ntohl(sh->v_tag), inp_p, netp, sh->src_port, sh->dest_port, 1, vrf_id, 0); /* - * printf("findassociation_ep_asconf: zero lookup address - * finds stcb 0x%x\n", (uint32_t)stcb); + * SCTP_PRINTF("findassociation_ep_asconf: zero lookup + * address finds stcb 0x%x\n", (uint32_t)stcb); */ } else { stcb = sctp_findassociation_ep_addr(inp_p, @@ -5745,7 +5745,7 @@ skip_sleep: if (v6 == 0) { sctp_input_with_port(m, off, 0); } else { - printf("V6 not yet supported\n"); + SCTP_PRINTF("V6 not yet supported\n"); sctp_m_freem(m); } CURVNET_RESTORE(); @@ -6276,8 +6276,8 @@ sctp_load_addresses_from_init(struct sct ptype = ntohs(phdr->param_type); plen = ntohs(phdr->param_length); /* - * printf("ptype => %0x, plen => %d\n", (uint32_t)ptype, - * (int)plen); + * SCTP_PRINTF("ptype => %0x, plen => %d\n", + * (uint32_t)ptype, (int)plen); */ if (offset + plen > limit) { break; Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctputil.c Fri May 4 09:27:00 2012 (r234995) @@ -1127,7 +1127,7 @@ sctp_print_mapping_array(struct sctp_ass { unsigned int i, limit; - printf("Mapping array size: %d, baseTSN: %8.8x, cumAck: %8.8x, highestTSN: (%8.8x, %8.8x).\n", + SCTP_PRINTF("Mapping array size: %d, baseTSN: %8.8x, cumAck: %8.8x, highestTSN: (%8.8x, %8.8x).\n", asoc->mapping_array_size, asoc->mapping_array_base_tsn, asoc->cumulative_tsn, @@ -1138,23 +1138,23 @@ sctp_print_mapping_array(struct sctp_ass break; } } - printf("Renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); + SCTP_PRINTF("Renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); for (i = 0; i < limit; i++) { - printf("%2.2x%c", asoc->mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); + SCTP_PRINTF("%2.2x%c", asoc->mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); } if (limit % 16) - printf("\n"); + SCTP_PRINTF("\n"); for (limit = asoc->mapping_array_size; limit > 1; limit--) { if (asoc->nr_mapping_array[limit - 1]) { break; } } - printf("Non renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); + SCTP_PRINTF("Non renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); for (i = 0; i < limit; i++) { - printf("%2.2x%c", asoc->nr_mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); + SCTP_PRINTF("%2.2x%c", asoc->nr_mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); } if (limit % 16) - printf("\n"); + SCTP_PRINTF("\n"); } int @@ -1292,7 +1292,7 @@ select_a_new_ep: goto no_stcb; } /* If we reach here huh? */ - printf("Unknown it ctl flag %x\n", + SCTP_PRINTF("Unknown it ctl flag %x\n", sctp_it_ctl.iterator_flags); sctp_it_ctl.iterator_flags = 0; } @@ -5392,7 +5392,7 @@ found_one: #ifdef INVARIANTS panic("refcnt already incremented"); #else - printf("refcnt already incremented?\n"); + SCTP_PRINTF("refcnt already incremented?\n"); #endif } else { atomic_add_int(&stcb->asoc.refcnt, 1); From owner-svn-src-all@FreeBSD.ORG Fri May 4 10:06:08 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DCE411065672; Fri, 4 May 2012 10:06:08 +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 C8E8E8FC14; Fri, 4 May 2012 10:06:08 +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 q44A68xk097047; Fri, 4 May 2012 10:06:08 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44A687x097045; Fri, 4 May 2012 10:06:08 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041006.q44A687x097045@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 10:06:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234996 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 10:06:09 -0000 Author: tuexen Date: Fri May 4 10:06:08 2012 New Revision: 234996 URL: http://svn.freebsd.org/changeset/base/234996 Log: Call panic() only under INVARIANTS. MFC after: 3 days Modified: head/sys/netinet/sctp_crc32.c Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Fri May 4 09:27:00 2012 (r234995) +++ head/sys/netinet/sctp_crc32.c Fri May 4 10:06:08 2012 (r234996) @@ -124,7 +124,9 @@ void sctp_delayed_cksum(struct mbuf *m, uint32_t offset) { #if defined(SCTP_WITH_NO_CSUM) +#ifdef INVARIANTS panic("sctp_delayed_cksum() called when using no SCTP CRC."); +#endif #else uint32_t checksum; From owner-svn-src-all@FreeBSD.ORG Fri May 4 10:26:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DC111065670; Fri, 4 May 2012 10:26:50 +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 89B978FC0C; Fri, 4 May 2012 10:26: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 q44AQooM097695; Fri, 4 May 2012 10:26:50 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44AQoQG097692; Fri, 4 May 2012 10:26:50 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041026.q44AQoQG097692@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 10:26: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: r234997 - head/lib/libc/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 10:26:50 -0000 Author: tuexen Date: Fri May 4 10:26:50 2012 New Revision: 234997 URL: http://svn.freebsd.org/changeset/base/234997 Log: Remove debug output. MFC after: 3 days Modified: head/lib/libc/net/sctp_sys_calls.c Modified: head/lib/libc/net/sctp_sys_calls.c ============================================================================== --- head/lib/libc/net/sctp_sys_calls.c Fri May 4 10:06:08 2012 (r234996) +++ head/lib/libc/net/sctp_sys_calls.c Fri May 4 10:26:50 2012 (r234997) @@ -800,7 +800,6 @@ continue_send: } sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs); if (sinfo->sinfo_assoc_id == 0) { - printf("Huh, can't get associd? TSNH!\n"); (void)setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_COMPLETE, (void *)addrs, (socklen_t) addrs->sa_len); errno = ENOENT; From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:05:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9C28106566B; Fri, 4 May 2012 15:05:31 +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 CF4BB8FC08; Fri, 4 May 2012 15:05: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 q44F5Vqd008648; Fri, 4 May 2012 15:05:31 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44F5V9G008606; Fri, 4 May 2012 15:05:31 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041505.q44F5V9G008606@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:05:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235000 - in stable/9/sys: dev/sound/usb dev/usb dev/usb/controller dev/usb/input dev/usb/misc dev/usb/net dev/usb/serial dev/usb/storage dev/usb/template dev/usb/wlan netgraph/bluetoot... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:05:32 -0000 Author: hselasky Date: Fri May 4 15:05:30 2012 New Revision: 235000 URL: http://svn.freebsd.org/changeset/base/235000 Log: MFC r233774: Fix compiler warnings, mostly signed issues, when USB modules are compiled with WARNS=9. Modified: stable/9/sys/dev/sound/usb/uaudio.c stable/9/sys/dev/sound/usb/uaudioreg.h stable/9/sys/dev/usb/controller/at91dci.c stable/9/sys/dev/usb/controller/atmegadci.c stable/9/sys/dev/usb/controller/avr32dci.c stable/9/sys/dev/usb/controller/ehci.c stable/9/sys/dev/usb/controller/musb_otg.c stable/9/sys/dev/usb/controller/ohci.c stable/9/sys/dev/usb/controller/uhci.c stable/9/sys/dev/usb/controller/uss820dci.c stable/9/sys/dev/usb/controller/xhci.c stable/9/sys/dev/usb/input/atp.c stable/9/sys/dev/usb/input/uep.c stable/9/sys/dev/usb/input/uhid.c stable/9/sys/dev/usb/input/ukbd.c stable/9/sys/dev/usb/input/ums.c stable/9/sys/dev/usb/misc/ufm.c stable/9/sys/dev/usb/net/if_aue.c stable/9/sys/dev/usb/net/if_axe.c stable/9/sys/dev/usb/net/if_cdce.c stable/9/sys/dev/usb/net/if_cue.c stable/9/sys/dev/usb/net/if_ipheth.c stable/9/sys/dev/usb/net/if_kue.c stable/9/sys/dev/usb/net/if_rue.c stable/9/sys/dev/usb/net/if_udav.c stable/9/sys/dev/usb/net/if_usie.c stable/9/sys/dev/usb/net/ruephy.c stable/9/sys/dev/usb/net/uhso.c stable/9/sys/dev/usb/serial/ubsa.c stable/9/sys/dev/usb/serial/uchcom.c stable/9/sys/dev/usb/serial/ucycom.c stable/9/sys/dev/usb/serial/ufoma.c stable/9/sys/dev/usb/serial/ulpt.c stable/9/sys/dev/usb/serial/umodem.c stable/9/sys/dev/usb/serial/uplcom.c stable/9/sys/dev/usb/serial/usb_serial.c stable/9/sys/dev/usb/serial/usb_serial.h stable/9/sys/dev/usb/storage/umass.c stable/9/sys/dev/usb/storage/urio.c stable/9/sys/dev/usb/storage/ustorage_fs.c stable/9/sys/dev/usb/template/usb_template.c stable/9/sys/dev/usb/usb_busdma.c stable/9/sys/dev/usb/usb_compat_linux.c stable/9/sys/dev/usb/usb_dev.c stable/9/sys/dev/usb/usb_device.c stable/9/sys/dev/usb/usb_handle_request.c stable/9/sys/dev/usb/usb_hid.c stable/9/sys/dev/usb/usb_hub.c stable/9/sys/dev/usb/usb_msctest.c stable/9/sys/dev/usb/usb_request.c stable/9/sys/dev/usb/usb_transfer.c stable/9/sys/dev/usb/usbdi.h stable/9/sys/dev/usb/usbhid.h stable/9/sys/dev/usb/wlan/if_rum.c stable/9/sys/dev/usb/wlan/if_run.c stable/9/sys/dev/usb/wlan/if_uath.c stable/9/sys/dev/usb/wlan/if_upgt.c stable/9/sys/dev/usb/wlan/if_ural.c stable/9/sys/dev/usb/wlan/if_urtw.c stable/9/sys/dev/usb/wlan/if_zyd.c stable/9/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/sound/usb/uaudio.c ============================================================================== --- stable/9/sys/dev/sound/usb/uaudio.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/sound/usb/uaudio.c Fri May 4 15:05:30 2012 (r235000) @@ -1272,15 +1272,15 @@ uaudio_chan_record_callback(struct usb_x { struct uaudio_chan *ch = usbd_xfer_softc(xfer); struct usb_page_cache *pc; - uint32_t n; - uint32_t m; - uint32_t blockcount; uint32_t offset0; uint32_t offset1; uint32_t mfl; + int m; + int n; int len; int actlen; int nframes; + int blockcount; usbd_xfer_status(xfer, &actlen, NULL, NULL, &nframes); mfl = usbd_xfer_max_framelen(xfer); @@ -1307,9 +1307,9 @@ uaudio_chan_record_callback(struct usb_x m = (ch->end - ch->cur); - if (m > len) { + if (m > len) m = len; - } + usbd_copy_out(pc, offset1, ch->cur, m); len -= m; @@ -1884,10 +1884,10 @@ uaudio_mixer_add_selector(struct uaudio_ static uint32_t uaudio_mixer_feature_get_bmaControls(const struct usb_audio_feature_unit *d, - uint8_t index) + uint8_t i) { uint32_t temp = 0; - uint32_t offset = (index * d->bControlSize); + uint32_t offset = (i * d->bControlSize); if (d->bControlSize > 0) { temp |= d->bmaControls[offset]; @@ -2636,8 +2636,8 @@ uaudio_mixer_feature_name(const struct u return (uat->feature); } -const static struct uaudio_terminal_node * -uaudio_mixer_get_input(const struct uaudio_terminal_node *iot, uint8_t index) +static const struct uaudio_terminal_node * +uaudio_mixer_get_input(const struct uaudio_terminal_node *iot, uint8_t i) { struct uaudio_terminal_node *root = iot->root; uint8_t n; @@ -2645,17 +2645,16 @@ uaudio_mixer_get_input(const struct uaud n = iot->usr.id_max; do { if (iot->usr.bit_input[n / 8] & (1 << (n % 8))) { - if (!index--) { + if (!i--) return (root + n); - } } } while (n--); return (NULL); } -const static struct uaudio_terminal_node * -uaudio_mixer_get_output(const struct uaudio_terminal_node *iot, uint8_t index) +static const struct uaudio_terminal_node * +uaudio_mixer_get_output(const struct uaudio_terminal_node *iot, uint8_t i) { struct uaudio_terminal_node *root = iot->root; uint8_t n; @@ -2663,9 +2662,8 @@ uaudio_mixer_get_output(const struct uau n = iot->usr.id_max; do { if (iot->usr.bit_output[n / 8] & (1 << (n % 8))) { - if (!index--) { + if (!i--) return (root + n); - } } } while (n--); Modified: stable/9/sys/dev/sound/usb/uaudioreg.h ============================================================================== --- stable/9/sys/dev/sound/usb/uaudioreg.h Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/sound/usb/uaudioreg.h Fri May 4 15:05:30 2012 (r235000) @@ -113,9 +113,9 @@ struct usb_audio_streaming_type1_descrip uByte bSamFreqType; #define UA_SAMP_CONTNUOUS 0 uByte tSamFreq[0]; -#define UA_GETSAMP(p, n) (((p)->tSamFreq[((n)*3)+0]) | \ +#define UA_GETSAMP(p, n) ((uint32_t)((((p)->tSamFreq[((n)*3)+0]) | \ ((p)->tSamFreq[((n)*3)+1] << 8) | \ - ((p)->tSamFreq[((n)*3)+2] << 16)) + ((p)->tSamFreq[((n)*3)+2] << 16)))) #define UA_SAMP_LO(p) UA_GETSAMP(p, 0) #define UA_SAMP_HI(p) UA_GETSAMP(p, 1) } __packed; Modified: stable/9/sys/dev/usb/controller/at91dci.c ============================================================================== --- stable/9/sys/dev/usb/controller/at91dci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/at91dci.c Fri May 4 15:05:30 2012 (r235000) @@ -1725,14 +1725,13 @@ static const struct at91dci_config_desc }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min at91dci_hubd = { .bDescLength = sizeof(at91dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ Modified: stable/9/sys/dev/usb/controller/atmegadci.c ============================================================================== --- stable/9/sys/dev/usb/controller/atmegadci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/atmegadci.c Fri May 4 15:05:30 2012 (r235000) @@ -1547,14 +1547,13 @@ static const struct atmegadci_config_des }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min atmegadci_hubd = { .bDescLength = sizeof(atmegadci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ Modified: stable/9/sys/dev/usb/controller/avr32dci.c ============================================================================== --- stable/9/sys/dev/usb/controller/avr32dci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/avr32dci.c Fri May 4 15:05:30 2012 (r235000) @@ -1489,14 +1489,13 @@ static const struct avr32dci_config_desc }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min avr32dci_hubd = { .bDescLength = sizeof(avr32dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ Modified: stable/9/sys/dev/usb/controller/ehci.c ============================================================================== --- stable/9/sys/dev/usb/controller/ehci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/ehci.c Fri May 4 15:05:30 2012 (r235000) @@ -3011,13 +3011,8 @@ static const struct ehci_config_desc ehc static const struct usb_hub_descriptor ehci_hubd = { - 0, /* dynamic length */ - UDESC_HUB, - 0, - {0, 0}, - 0, - 0, - {0}, + .bDescLength = 0, /* dynamic length */ + .bDescriptorType = UDESC_HUB, }; static void Modified: stable/9/sys/dev/usb/controller/musb_otg.c ============================================================================== --- stable/9/sys/dev/usb/controller/musb_otg.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/musb_otg.c Fri May 4 15:05:30 2012 (r235000) @@ -2192,14 +2192,13 @@ static const struct musbotg_config_desc }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min musbotg_hubd = { .bDescLength = sizeof(musbotg_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 16, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ Modified: stable/9/sys/dev/usb/controller/ohci.c ============================================================================== --- stable/9/sys/dev/usb/controller/ohci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/ohci.c Fri May 4 15:05:30 2012 (r235000) @@ -2080,13 +2080,8 @@ struct ohci_config_desc ohci_confd = static const struct usb_hub_descriptor ohci_hubd = { - 0, /* dynamic length */ - UDESC_HUB, - 0, - {0, 0}, - 0, - 0, - {0}, + .bDescLength = 0, /* dynamic length */ + .bDescriptorType = UDESC_HUB, }; static usb_error_t Modified: stable/9/sys/dev/usb/controller/uhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/uhci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/uhci.c Fri May 4 15:05:30 2012 (r235000) @@ -2351,13 +2351,11 @@ static const struct uhci_config_desc uhc static const struct usb_hub_descriptor_min uhci_hubd_piix = { - sizeof(uhci_hubd_piix), - UDESC_HUB, - 2, - {UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL, 0}, - 50, /* power on to power good */ - 0, - {0x00}, /* both ports are removable */ + .bDescLength = sizeof(uhci_hubd_piix), + .bDescriptorType = UDESC_HUB, + .bNbrPorts = 2, + .wHubCharacteristics = {UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL, 0}, + .bPwrOn2PwrGood = 50, }; /* Modified: stable/9/sys/dev/usb/controller/uss820dci.c ============================================================================== --- stable/9/sys/dev/usb/controller/uss820dci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/uss820dci.c Fri May 4 15:05:30 2012 (r235000) @@ -1788,14 +1788,13 @@ static const struct uss820dci_config_des }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min uss820dci_hubd = { .bDescLength = sizeof(uss820dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ Modified: stable/9/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/xhci.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/controller/xhci.c Fri May 4 15:05:30 2012 (r235000) @@ -821,7 +821,7 @@ xhci_check_transfer(struct xhci_softc *s offset = td_event - td->td_self; if (offset >= 0 && - offset < sizeof(td->td_trb)) { + offset < (int64_t)sizeof(td->td_trb)) { usb_pc_cpu_invalidate(td->page_cache); @@ -2805,7 +2805,7 @@ struct usb_pipe_methods xhci_device_gene * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ -#define HSETW(ptr, val) ptr[0] = (uint8_t)(val), ptr[1] = (uint8_t)((val) >> 8) +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } static const struct usb_device_descriptor xhci_devd = @@ -2848,8 +2848,7 @@ struct xhci_bos_desc xhci_bosd = { HSETW(.wSpeedsSupported, 0x000C), .bFunctionalitySupport = 8, .bU1DevExitLat = 255, /* dummy - not used */ - .wU2DevExitLat[0] = 0x00, - .wU2DevExitLat[1] = 0x08, + .wU2DevExitLat = { 0x00, 0x08 }, }, .cidd = { .bLength = sizeof(xhci_bosd.cidd), Modified: stable/9/sys/dev/usb/input/atp.c ============================================================================== --- stable/9/sys/dev/usb/input/atp.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/input/atp.c Fri May 4 15:05:30 2012 (r235000) @@ -761,7 +761,7 @@ atp_get_pressures(int *p, const int *cur * threshold; this will reduce the contribution from * lower pressure readings. */ - if (p[i] <= atp_sensor_noise_threshold) + if ((u_int)p[i] <= atp_sensor_noise_threshold) p[i] = 0; /* filter away noise */ else p[i] -= atp_sensor_noise_threshold; @@ -887,7 +887,7 @@ atp_match_stroke_component(atp_stroke_co delta_mickeys = pspan->loc - component->loc; - if (abs(delta_mickeys) > atp_max_delta_mickeys) + if ((u_int)abs(delta_mickeys) > atp_max_delta_mickeys) return (FALSE); /* the finger span is too far out; no match */ component->loc = pspan->loc; @@ -1164,9 +1164,10 @@ static void atp_add_new_strokes(struct atp_softc *sc, atp_pspan *pspans_x, u_int n_xpspans, atp_pspan *pspans_y, u_int n_ypspans) { - int i, j; atp_pspan spans[2][ATP_MAX_PSPANS_PER_AXIS]; - u_int nspans[2]; + u_int nspans[2]; + u_int i; + u_int j; /* Copy unmatched pspans into the local arrays. */ for (i = 0, nspans[X] = 0; i < n_xpspans; i++) { @@ -1373,9 +1374,9 @@ atp_terminate_stroke(struct atp_softc *s static __inline boolean_t atp_stroke_has_small_movement(const atp_stroke *stroke) { - return ((abs(stroke->components[X].delta_mickeys) <= + return (((u_int)abs(stroke->components[X].delta_mickeys) <= atp_small_movement_threshold) && - (abs(stroke->components[Y].delta_mickeys) <= + ((u_int)abs(stroke->components[Y].delta_mickeys) <= atp_small_movement_threshold)); } @@ -1388,7 +1389,7 @@ static __inline void atp_update_pending_mickeys(atp_stroke_component *component) { component->pending += component->delta_mickeys; - if (abs(component->pending) <= atp_small_movement_threshold) + if ((u_int)abs(component->pending) <= atp_small_movement_threshold) component->delta_mickeys = 0; else { /* @@ -1690,7 +1691,7 @@ atp_attach(device_t dev) if (usb_fifo_attach(sc->sc_usb_device, sc, &sc->sc_mutex, &atp_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644)) { goto detach; } @@ -1764,13 +1765,13 @@ atp_intr(struct usb_xfer *xfer, usb_erro switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (len > sc->sc_params->data_len) { + if (len > (int)sc->sc_params->data_len) { DPRINTFN(ATP_LLEVEL_ERROR, "truncating large packet from %u to %u bytes\n", len, sc->sc_params->data_len); len = sc->sc_params->data_len; } - if (len < sc->sc_params->data_len) + if (len < (int)sc->sc_params->data_len) goto tr_setup; pc = usbd_xfer_get_frame(xfer, 0); @@ -2213,9 +2214,9 @@ static device_method_t atp_methods[] = { }; static driver_t atp_driver = { - ATP_DRIVER_NAME, - atp_methods, - sizeof(struct atp_softc) + .name = ATP_DRIVER_NAME, + .methods = atp_methods, + .size = sizeof(struct atp_softc) }; static devclass_t atp_devclass; Modified: stable/9/sys/dev/usb/input/uep.c ============================================================================== --- stable/9/sys/dev/usb/input/uep.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/input/uep.c Fri May 4 15:05:30 2012 (r235000) @@ -202,7 +202,7 @@ uep_intr_callback(struct usb_xfer *xfer, u_char buf[17], *p; int pkt_len; - if (len > sizeof(buf)) { + if (len > (int)sizeof(buf)) { DPRINTF("bad input length %d\n", len); goto tr_setup; } @@ -329,7 +329,7 @@ uep_attach(device_t dev) } error = usb_fifo_attach(uaa->device, sc, &sc->mtx, &uep_fifo_methods, - &sc->fifo, device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + &sc->fifo, device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { Modified: stable/9/sys/dev/usb/input/uhid.c ============================================================================== --- stable/9/sys/dev/usb/input/uhid.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/input/uhid.c Fri May 4 15:05:30 2012 (r235000) @@ -170,10 +170,10 @@ uhid_intr_callback(struct usb_xfer *xfer * If the ID byte is non zero we allow descriptors * having multiple sizes: */ - if ((actlen >= sc->sc_isize) || + if ((actlen >= (int)sc->sc_isize) || ((actlen > 0) && (sc->sc_iid != 0))) { /* limit report length to the maximum */ - if (actlen > sc->sc_isize) + if (actlen > (int)sc->sc_isize) actlen = sc->sc_isize; usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], pc, 0, actlen, 1); @@ -768,7 +768,7 @@ uhid_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &uhid_fifo_methods, &sc->sc_fifo, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; Modified: stable/9/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/9/sys/dev/usb/input/ukbd.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/input/ukbd.c Fri May 4 15:05:30 2012 (r235000) @@ -2121,7 +2121,7 @@ ukbd_key2scan(struct ukbd_softc *sc, int 0x5c, /* Keyboard Intl' 6 (Keypad ,) (For PC-9821 layout) */ }; - if ((code >= 89) && (code < (89 + (sizeof(scan) / sizeof(scan[0]))))) { + if ((code >= 89) && (code < (int)(89 + (sizeof(scan) / sizeof(scan[0]))))) { code = scan[code - 89]; } /* Pause/Break */ Modified: stable/9/sys/dev/usb/input/ums.c ============================================================================== --- stable/9/sys/dev/usb/input/ums.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/input/ums.c Fri May 4 15:05:30 2012 (r235000) @@ -201,7 +201,7 @@ ums_intr_callback(struct usb_xfer *xfer, case USB_ST_TRANSFERRED: DPRINTFN(6, "sc=%p actlen=%d\n", sc, len); - if (len > sizeof(sc->sc_temp)) { + if (len > (int)sizeof(sc->sc_temp)) { DPRINTFN(6, "truncating large packet to %zu bytes\n", sizeof(sc->sc_temp)); len = sizeof(sc->sc_temp); @@ -644,7 +644,7 @@ ums_attach(device_t dev) /* Some wheels need the Z axis reversed. */ info->sc_flags |= UMS_FLAG_REVZ; } - if (isize > usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])) { + if (isize > (int)usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])) { DPRINTF("WARNING: report size, %d bytes, is larger " "than interrupt size, %d bytes!\n", isize, usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])); @@ -698,7 +698,7 @@ ums_attach(device_t dev) err = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ums_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (err) { goto detach; Modified: stable/9/sys/dev/usb/misc/ufm.c ============================================================================== --- stable/9/sys/dev/usb/misc/ufm.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/misc/ufm.c Fri May 4 15:05:30 2012 (r235000) @@ -156,7 +156,7 @@ ufm_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ufm_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; Modified: stable/9/sys/dev/usb/net/if_aue.c ============================================================================== --- stable/9/sys/dev/usb/net/if_aue.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_aue.c Fri May 4 15:05:30 2012 (r235000) @@ -740,7 +740,7 @@ aue_intr_callback(struct usb_xfer *xfer, case USB_ST_TRANSFERRED: if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && - actlen >= sizeof(pkt)) { + actlen >= (int)sizeof(pkt)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); @@ -793,7 +793,7 @@ aue_bulk_read_callback(struct usb_xfer * } } else { - if (actlen <= sizeof(stat) + ETHER_CRC_LEN) { + if (actlen <= (int)(sizeof(stat) + ETHER_CRC_LEN)) { ifp->if_ierrors++; goto tr_setup; } Modified: stable/9/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/9/sys/dev/usb/net/if_axe.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_axe.c Fri May 4 15:05:30 2012 (r235000) @@ -1037,7 +1037,7 @@ axe_rx_frame(struct usb_ether *ue, struc error = 0; if ((sc->sc_flags & AXE_FLAG_STD_FRAME) != 0) { while (pos < actlen) { - if ((pos + sizeof(hdr)) > actlen) { + if ((int)(pos + sizeof(hdr)) > actlen) { /* too little data */ error = EINVAL; break; @@ -1061,7 +1061,7 @@ axe_rx_frame(struct usb_ether *ue, struc } } else if ((sc->sc_flags & AXE_FLAG_CSUM_FRAME) != 0) { while (pos < actlen) { - if ((pos + sizeof(csum_hdr)) > actlen) { + if ((int)(pos + sizeof(csum_hdr)) > actlen) { /* too little data */ error = EINVAL; break; Modified: stable/9/sys/dev/usb/net/if_cdce.c ============================================================================== --- stable/9/sys/dev/usb/net/if_cdce.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_cdce.c Fri May 4 15:05:30 2012 (r235000) @@ -303,8 +303,8 @@ cdce_ncm_init(struct cdce_softc *sc) int err; ufd = usbd_find_descriptor(sc->sc_ue.ue_udev, NULL, - sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0 - 1, - UCDC_NCM_FUNC_DESC_SUBTYPE, 0 - 1); + sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0xFF, + UCDC_NCM_FUNC_DESC_SUBTYPE, 0xFF); /* verify length of NCM functional descriptor */ if (ufd != NULL) { @@ -514,7 +514,7 @@ cdce_attach(device_t dev) ud = usbd_find_descriptor (uaa->device, NULL, uaa->info.bIfaceIndex, - UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_UNION, 0 - 1); + UDESC_CS_INTERFACE, 0xFF, UDESCSUB_CDC_UNION, 0xFF); if ((ud == NULL) || (ud->bLength < sizeof(*ud)) || (sc->sc_flags & CDCE_FLAG_NO_UNION)) { @@ -598,7 +598,7 @@ alloc_transfers: ued = usbd_find_descriptor (uaa->device, NULL, uaa->info.bIfaceIndex, - UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_ENF, 0 - 1); + UDESC_CS_INTERFACE, 0xFF, UDESCSUB_CDC_ENF, 0xFF); if ((ued == NULL) || (ued->bLength < sizeof(*ued))) { error = USB_ERR_INVAL; @@ -892,7 +892,9 @@ cdce_bulk_read_callback(struct usb_xfer struct cdce_softc *sc = usbd_xfer_softc(xfer); struct mbuf *m; uint8_t x; - int actlen, aframes, len; + int actlen; + int aframes; + int len; usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL); @@ -911,7 +913,7 @@ cdce_bulk_read_callback(struct usb_xfer if ((sc->sc_flags & CDCE_FLAG_ZAURUS) && len >= 14) len -= 4; - if (len < sizeof(struct ether_header)) { + if (len < (int)sizeof(struct ether_header)) { m_freem(m); continue; } @@ -1096,7 +1098,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer break; } - if (m->m_pkthdr.len > rem) { + if (m->m_pkthdr.len > (int)rem) { if (n == 0) { /* The frame won't fit in our buffer */ DPRINTFN(1, "Frame too big to be transmitted!\n"); @@ -1278,7 +1280,7 @@ cdce_ncm_bulk_read_callback(struct usb_x DPRINTFN(1, "received %u bytes in %u frames\n", actlen, aframes); - if (actlen < (sizeof(sc->sc_ncm.hdr) + + if (actlen < (int)(sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt))) { DPRINTFN(1, "frame too short\n"); goto tr_setup; @@ -1305,7 +1307,7 @@ cdce_ncm_bulk_read_callback(struct usb_x goto tr_stall; } temp = UGETW(sc->sc_ncm.hdr.wDptIndex); - if ((temp + sizeof(sc->sc_ncm.dpt)) > actlen) { + if ((int)(temp + sizeof(sc->sc_ncm.dpt)) > actlen) { DPRINTFN(1, "invalid DPT index: 0x%04x\n", temp); goto tr_stall; } @@ -1354,7 +1356,7 @@ cdce_ncm_bulk_read_callback(struct usb_x temp = UGETW(sc->sc_ncm.dp[x].wFrameLength); if ((offset == 0) || - (temp < sizeof(struct ether_header)) || + (temp < (int)sizeof(struct ether_header)) || (temp > (MCLBYTES - ETHER_ALIGN))) { DPRINTFN(1, "NULL frame detected at %d\n", x); m = NULL; @@ -1366,7 +1368,7 @@ cdce_ncm_bulk_read_callback(struct usb_x m = NULL; /* silently ignore this frame */ continue; - } else if (temp > (MHLEN - ETHER_ALIGN)) { + } else if (temp > (int)(MHLEN - ETHER_ALIGN)) { m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); } else { m = m_gethdr(M_DONTWAIT, MT_DATA); Modified: stable/9/sys/dev/usb/net/if_cue.c ============================================================================== --- stable/9/sys/dev/usb/net/if_cue.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_cue.c Fri May 4 15:05:30 2012 (r235000) @@ -457,7 +457,7 @@ cue_bulk_read_callback(struct usb_xfer * switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen <= (2 + sizeof(struct ether_header))) { + if (actlen <= (int)(2 + sizeof(struct ether_header))) { ifp->if_ierrors++; goto tr_setup; } Modified: stable/9/sys/dev/usb/net/if_ipheth.c ============================================================================== --- stable/9/sys/dev/usb/net/if_ipheth.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_ipheth.c Fri May 4 15:05:30 2012 (r235000) @@ -471,7 +471,7 @@ ipheth_bulk_read_callback(struct usb_xfe sc->sc_rx_buf[x] = NULL; len = usbd_xfer_frame_len(xfer, x); - if (len < (sizeof(struct ether_header) + + if (len < (int)(sizeof(struct ether_header) + IPHETH_RX_ADJ)) { m_freem(m); continue; Modified: stable/9/sys/dev/usb/net/if_kue.c ============================================================================== --- stable/9/sys/dev/usb/net/if_kue.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_kue.c Fri May 4 15:05:30 2012 (r235000) @@ -545,7 +545,7 @@ kue_bulk_read_callback(struct usb_xfer * switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen <= (2 + sizeof(struct ether_header))) { + if (actlen <= (int)(2 + sizeof(struct ether_header))) { ifp->if_ierrors++; goto tr_setup; } Modified: stable/9/sys/dev/usb/net/if_rue.c ============================================================================== --- stable/9/sys/dev/usb/net/if_rue.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_rue.c Fri May 4 15:05:30 2012 (r235000) @@ -638,7 +638,7 @@ rue_intr_callback(struct usb_xfer *xfer, case USB_ST_TRANSFERRED: if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) && - actlen >= sizeof(pkt)) { + actlen >= (int)sizeof(pkt)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); Modified: stable/9/sys/dev/usb/net/if_udav.c ============================================================================== --- stable/9/sys/dev/usb/net/if_udav.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_udav.c Fri May 4 15:05:30 2012 (r235000) @@ -642,7 +642,7 @@ udav_bulk_read_callback(struct usb_xfer switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen < sizeof(stat) + ETHER_CRC_LEN) { + if (actlen < (int)(sizeof(stat) + ETHER_CRC_LEN)) { ifp->if_ierrors++; goto tr_setup; } Modified: stable/9/sys/dev/usb/net/if_usie.c ============================================================================== --- stable/9/sys/dev/usb/net/if_usie.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/if_usie.c Fri May 4 15:05:30 2012 (r235000) @@ -918,7 +918,7 @@ tr_setup: if (m == NULL) break; - if (m->m_pkthdr.len > (MCLBYTES - ETHER_HDR_LEN + + if (m->m_pkthdr.len > (int)(MCLBYTES - ETHER_HDR_LEN + ETHER_CRC_LEN - sizeof(sc->sc_txd))) { DPRINTF("packet len is too big: %d\n", m->m_pkthdr.len); Modified: stable/9/sys/dev/usb/net/ruephy.c ============================================================================== --- stable/9/sys/dev/usb/net/ruephy.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/ruephy.c Fri May 4 15:05:30 2012 (r235000) @@ -67,9 +67,9 @@ static device_method_t ruephy_methods[] static devclass_t ruephy_devclass; static driver_t ruephy_driver = { - "ruephy", - ruephy_methods, - sizeof(struct mii_softc) + .name = "ruephy", + .methods = ruephy_methods, + .size = sizeof(struct mii_softc) }; DRIVER_MODULE(ruephy, miibus, ruephy_driver, ruephy_devclass, 0, 0); Modified: stable/9/sys/dev/usb/net/uhso.c ============================================================================== --- stable/9/sys/dev/usb/net/uhso.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/net/uhso.c Fri May 4 15:05:30 2012 (r235000) @@ -482,9 +482,9 @@ static device_method_t uhso_methods[] = }; static driver_t uhso_driver = { - "uhso", - uhso_methods, - sizeof(struct uhso_softc) + .name = "uhso", + .methods = uhso_methods, + .size = sizeof(struct uhso_softc) }; static devclass_t uhso_devclass; @@ -1366,7 +1366,7 @@ uhso_bs_intr_callback(struct usb_xfer *x UHSO_DPRINTF(0, "UCDC notification too short: %d\n", actlen); goto tr_setup; } - else if (actlen > sizeof(struct usb_cdc_notification)) { + else if (actlen > (int)sizeof(struct usb_cdc_notification)) { UHSO_DPRINTF(0, "UCDC notification too large: %d\n", actlen); actlen = sizeof(struct usb_cdc_notification); } Modified: stable/9/sys/dev/usb/serial/ubsa.c ============================================================================== --- stable/9/sys/dev/usb/serial/ubsa.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/ubsa.c Fri May 4 15:05:30 2012 (r235000) @@ -627,7 +627,7 @@ ubsa_intr_callback(struct usb_xfer *xfer switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen >= sizeof(buf)) { + if (actlen >= (int)sizeof(buf)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, buf, sizeof(buf)); Modified: stable/9/sys/dev/usb/serial/uchcom.c ============================================================================== --- stable/9/sys/dev/usb/serial/uchcom.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/uchcom.c Fri May 4 15:05:30 2012 (r235000) @@ -846,9 +846,9 @@ static device_method_t uchcom_methods[] }; static driver_t uchcom_driver = { - "ucom", - uchcom_methods, - sizeof(struct uchcom_softc) + .name = "ucom", + .methods = uchcom_methods, + .size = sizeof(struct uchcom_softc) }; static devclass_t uchcom_devclass; Modified: stable/9/sys/dev/usb/serial/ucycom.c ============================================================================== --- stable/9/sys/dev/usb/serial/ucycom.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/ucycom.c Fri May 4 15:05:30 2012 (r235000) @@ -519,7 +519,7 @@ ucycom_intr_read_callback(struct usb_xfe struct usb_page_cache *pc; uint8_t buf[2]; uint32_t offset; - uint32_t len; + int len; int actlen; usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); Modified: stable/9/sys/dev/usb/serial/ufoma.c ============================================================================== --- stable/9/sys/dev/usb/serial/ufoma.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/ufoma.c Fri May 4 15:05:30 2012 (r235000) @@ -684,7 +684,7 @@ ufoma_intr_callback(struct usb_xfer *xfe DPRINTF("too short message\n"); goto tr_setup; } - if (actlen > sizeof(pkt)) { + if (actlen > (int)sizeof(pkt)) { DPRINTF("truncating message\n"); actlen = sizeof(pkt); } Modified: stable/9/sys/dev/usb/serial/ulpt.c ============================================================================== --- stable/9/sys/dev/usb/serial/ulpt.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/ulpt.c Fri May 4 15:05:30 2012 (r235000) @@ -543,7 +543,7 @@ ulpt_attach(device_t dev) /* search through all the descriptors looking for bidir mode */ id = usbd_get_interface_descriptor(uaa->iface); - alt_index = 0 - 1; + alt_index = 0xFF; while (1) { if (id == NULL) { break; @@ -631,14 +631,14 @@ found: error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ulpt_fifo_methods, &sc->sc_fifo, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; } error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &unlpt_fifo_methods, &sc->sc_fifo_noreset, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; Modified: stable/9/sys/dev/usb/serial/umodem.c ============================================================================== --- stable/9/sys/dev/usb/serial/umodem.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/umodem.c Fri May 4 15:05:30 2012 (r235000) @@ -317,7 +317,7 @@ umodem_attach(device_t dev) cud = usbd_find_descriptor(uaa->device, NULL, uaa->info.bIfaceIndex, UDESC_CS_INTERFACE, - 0 - 1, UDESCSUB_CDC_UNION, 0 - 1); + 0xFF, UDESCSUB_CDC_UNION, 0xFF); if ((cud == NULL) || (cud->bLength < sizeof(*cud))) { DPRINTF("Missing descriptor. " @@ -702,7 +702,7 @@ umodem_intr_callback(struct usb_xfer *xf "%d bytes\n", actlen); goto tr_setup; } - if (actlen > sizeof(pkt)) { + if (actlen > (int)sizeof(pkt)) { DPRINTF("truncating message\n"); actlen = sizeof(pkt); } @@ -842,7 +842,7 @@ static void * umodem_get_desc(struct usb_attach_arg *uaa, uint8_t type, uint8_t subtype) { return (usbd_find_descriptor(uaa->device, NULL, uaa->info.bIfaceIndex, - type, 0 - 1, subtype, 0 - 1)); + type, 0xFF, subtype, 0xFF)); } static usb_error_t Modified: stable/9/sys/dev/usb/serial/uplcom.c ============================================================================== --- stable/9/sys/dev/usb/serial/uplcom.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/uplcom.c Fri May 4 15:05:30 2012 (r235000) @@ -606,7 +606,7 @@ uplcom_cfg_set_break(struct ucom_softc * &req, NULL, 0, 1000); } -static const int32_t uplcom_rates[] = { +static const uint32_t uplcom_rates[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, /* Modified: stable/9/sys/dev/usb/serial/usb_serial.c ============================================================================== --- stable/9/sys/dev/usb/serial/usb_serial.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/usb_serial.c Fri May 4 15:05:30 2012 (r235000) @@ -236,14 +236,14 @@ ucom_unit_free(int unit) */ int ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, - uint32_t subunits, void *parent, + int subunits, void *parent, const struct ucom_callback *callback, struct mtx *mtx) { - uint32_t subunit; + int subunit; int error = 0; if ((sc == NULL) || - (subunits == 0) || + (subunits <= 0) || (callback == NULL)) { return (EINVAL); } @@ -293,7 +293,7 @@ ucom_attach(struct ucom_super_softc *ssc void ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc) { - uint32_t subunit; + int subunit; if (ssc->sc_subunits == 0) return; /* not initialized */ @@ -1089,11 +1089,6 @@ ucom_param(struct tty *tp, struct termio DPRINTF("sc = %p\n", sc); /* Check requested parameters. */ - if (t->c_ospeed < 0) { - DPRINTF("negative ospeed\n"); - error = EINVAL; - goto done; - } if (t->c_ispeed && (t->c_ispeed != t->c_ospeed)) { DPRINTF("mismatch ispeed and ospeed\n"); error = EINVAL; Modified: stable/9/sys/dev/usb/serial/usb_serial.h ============================================================================== --- stable/9/sys/dev/usb/serial/usb_serial.h Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/serial/usb_serial.h Fri May 4 15:05:30 2012 (r235000) @@ -166,7 +166,7 @@ struct ucom_softc { struct tty *sc_tty; struct mtx *sc_mtx; void *sc_parent; - uint32_t sc_subunit; + int sc_subunit; uint16_t sc_portno; uint16_t sc_flag; #define UCOM_FLAG_RTS_IFLOW 0x01 /* use RTS input flow control */ @@ -194,7 +194,7 @@ struct ucom_softc { usbd_do_request_proc(udev,&(com)->sc_super->sc_tq,req,ptr,flags,NULL,timo) int ucom_attach(struct ucom_super_softc *, - struct ucom_softc *, uint32_t, void *, + struct ucom_softc *, int, void *, const struct ucom_callback *callback, struct mtx *); void ucom_detach(struct ucom_super_softc *, struct ucom_softc *); void ucom_set_pnpinfo_usb(struct ucom_super_softc *, device_t); Modified: stable/9/sys/dev/usb/storage/umass.c ============================================================================== --- stable/9/sys/dev/usb/storage/umass.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/storage/umass.c Fri May 4 15:05:30 2012 (r235000) @@ -1482,7 +1482,7 @@ umass_t_bbb_status_callback(struct usb_x /* Zero missing parts of the CSW: */ - if (actlen < sizeof(sc->csw)) + if (actlen < (int)sizeof(sc->csw)) memset(&sc->csw, 0, sizeof(sc->csw)); pc = usbd_xfer_get_frame(xfer, 0); @@ -2016,7 +2016,7 @@ umass_t_cbi_status_callback(struct usb_x switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen < sizeof(sc->sbl)) { + if (actlen < (int)sizeof(sc->sbl)) { goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); Modified: stable/9/sys/dev/usb/storage/urio.c ============================================================================== --- stable/9/sys/dev/usb/storage/urio.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/storage/urio.c Fri May 4 15:05:30 2012 (r235000) @@ -246,7 +246,7 @@ urio_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &urio_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; Modified: stable/9/sys/dev/usb/storage/ustorage_fs.c ============================================================================== --- stable/9/sys/dev/usb/storage/ustorage_fs.c Fri May 4 14:10:54 2012 (r234999) +++ stable/9/sys/dev/usb/storage/ustorage_fs.c Fri May 4 15:05:30 2012 (r235000) @@ -967,7 +967,7 @@ ustorage_fs_verify(struct ustorage_fs_so } /* XXX TODO: verify that data is readable */ done: - return (ustorage_fs_min_len(sc, 0, 0 - 1)); + return (ustorage_fs_min_len(sc, 0, -1U)); } /*------------------------------------------------------------------------* @@ -989,7 +989,7 @@ ustorage_fs_inquiry(struct ustorage_fs_s memset(buf, 0, 36); buf[0] = 0x7f; /* Unsupported, no device - type */ - return (ustorage_fs_min_len(sc, 36, 0 - 1)); + return (ustorage_fs_min_len(sc, 36, -1U)); } memset(buf, 0, 8); /* Non - removable, direct - access device */ @@ -1008,7 +1008,7 @@ ustorage_fs_inquiry(struct ustorage_fs_s #if (USTORAGE_QDATA_MAX < 36) #error "(USTORAGE_QDATA_MAX < 36)" #endif - return (ustorage_fs_min_len(sc, 36, 0 - 1)); + return (ustorage_fs_min_len(sc, 36, -1U)); } /*------------------------------------------------------------------------* @@ -1077,7 +1077,7 @@ ustorage_fs_request_sense(struct ustorag #if (USTORAGE_QDATA_MAX < 18) #error "(USTORAGE_QDATA_MAX < 18)" #endif - return (ustorage_fs_min_len(sc, 18, 0 - 1)); + return (ustorage_fs_min_len(sc, 18, -1U)); } /*------------------------------------------------------------------------* @@ -1108,7 +1108,7 @@ ustorage_fs_read_capacity(struct ustorag #if (USTORAGE_QDATA_MAX < 8) #error "(USTORAGE_QDATA_MAX < 8)" #endif - return (ustorage_fs_min_len(sc, 8, 0 - 1)); + return (ustorage_fs_min_len(sc, 8, -1U)); } /*------------------------------------------------------------------------* @@ -1215,7 +1215,7 @@ ustorage_fs_mode_sense(struct ustorage_f #if (USTORAGE_QDATA_MAX < 24) #error "(USTORAGE_QDATA_MAX < 24)" #endif - return (ustorage_fs_min_len(sc, len, 0 - 1)); + return (ustorage_fs_min_len(sc, len, -1U)); } /*------------------------------------------------------------------------* @@ -1305,7 +1305,7 @@ ustorage_fs_read_format_capacities(struc #if (USTORAGE_QDATA_MAX < 12) #error "(USTORAGE_QDATA_MAX < 12)" #endif - return (ustorage_fs_min_len(sc, 12, 0 - 1)); + return (ustorage_fs_min_len(sc, 12, -1U)); } /*------------------------------------------------------------------------* @@ -1618,7 +1618,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so switch (sc->sc_cmd_data[0]) { case SC_INQUIRY: sc->sc_transfer.cmd_dir = DIR_WRITE; - error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], 0 - 1); + error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], -1U); if (error) { break; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:10:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C689A1065676; Fri, 4 May 2012 15:10:49 +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 ADFD58FC16; Fri, 4 May 2012 15:10:49 +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 q44FAnHM008952; Fri, 4 May 2012 15:10:49 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FAnLF008945; Fri, 4 May 2012 15:10:49 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041510.q44FAnLF008945@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:10:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235001 - in stable/9/sys/dev/usb: . controller X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:10:49 -0000 Author: hselasky Date: Fri May 4 15:10:49 2012 New Revision: 235001 URL: http://svn.freebsd.org/changeset/base/235001 Log: MFC r234803 and r234961: Add support for Multi-TT mode of modern USB HUBs. This will give you more bandwidth for isochronous FULL speed applications connected through a High Speed HUB. This patch has been tested with XHCI and EHCI. Modified: stable/9/sys/dev/usb/controller/ehci.c stable/9/sys/dev/usb/controller/xhci.c stable/9/sys/dev/usb/usb_controller.h stable/9/sys/dev/usb/usb_hub.c stable/9/sys/dev/usb/usb_hub.h stable/9/sys/dev/usb/usb_transfer.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/usb/controller/ehci.c ============================================================================== --- stable/9/sys/dev/usb/controller/ehci.c Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/controller/ehci.c Fri May 4 15:10:49 2012 (r235001) @@ -2398,9 +2398,9 @@ ehci_device_isoc_fs_open(struct usb_xfer EHCI_SITD_SET_HUBA(xfer->xroot->udev->hs_hub_addr) | EHCI_SITD_SET_PORT(xfer->xroot->udev->hs_port_no); - if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) { + if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) sitd_portaddr |= EHCI_SITD_SET_DIR_IN; - } + sitd_portaddr = htohc32(sc, sitd_portaddr); /* initialize all TD's */ @@ -2436,9 +2436,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe { struct usb_page_search buf_res; ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); - struct usb_fs_isoc_schedule *fss_start; - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss; ehci_sitd_t *td; ehci_sitd_t *td_last = NULL; ehci_sitd_t **pp_last; @@ -2450,7 +2447,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe uint16_t tlen; uint8_t sa; uint8_t sb; - uint8_t error; #ifdef USB_DEBUG uint8_t once = 1; @@ -2495,9 +2491,8 @@ ehci_device_isoc_fs_enter(struct usb_xfe * pre-compute when the isochronous transfer will be finished: */ xfer->isoc_time_complete = - usbd_fs_isoc_schedule_isoc_time_expand - (xfer->xroot->udev, &fss_start, &fss_end, nframes) + buf_offset + - xfer->nframes; + usb_isoc_time_expand(&sc->sc_bus, nframes) + + buf_offset + xfer->nframes; /* get the real number of frames */ @@ -2520,19 +2515,14 @@ ehci_device_isoc_fs_enter(struct usb_xfe xfer->qh_pos = xfer->endpoint->isoc_next; - fss = fss_start + (xfer->qh_pos % USB_ISOC_TIME_MAX); - while (nframes--) { if (td == NULL) { panic("%s:%d: out of TD's\n", __FUNCTION__, __LINE__); } - if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) { + if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) pp_last = &sc->sc_isoc_fs_p_last[0]; - } - if (fss >= fss_end) { - fss = fss_start; - } + /* reuse sitd_portaddr and sitd_back from last transfer */ if (*plen > xfer->max_frame_size) { @@ -2547,17 +2537,19 @@ ehci_device_isoc_fs_enter(struct usb_xfe #endif *plen = xfer->max_frame_size; } - /* - * We currently don't care if the ISOCHRONOUS schedule is - * full! - */ - error = usbd_fs_isoc_schedule_alloc(fss, &sa, *plen); - if (error) { + + /* allocate a slot */ + + sa = usbd_fs_isoc_schedule_alloc_slot(xfer, + xfer->isoc_time_complete - nframes - 1); + + if (sa == 255) { /* - * The FULL speed schedule is FULL! Set length - * to zero. + * Schedule is FULL, set length to zero: */ + *plen = 0; + sa = USB_FS_ISOC_UFRAME_MAX - 1; } if (*plen) { /* @@ -2637,7 +2629,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe pp_last++; plen++; - fss++; td_last = td; td = td->obj_next; } @@ -2647,11 +2638,29 @@ ehci_device_isoc_fs_enter(struct usb_xfe /* update isoc_next */ xfer->endpoint->isoc_next = (pp_last - &sc->sc_isoc_fs_p_last[0]) & (EHCI_VIRTUAL_FRAMELIST_COUNT - 1); + + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; } static void ehci_device_isoc_fs_start(struct usb_xfer *xfer) { + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; + + /* set a default timeout */ + if (xfer->timeout == 0) + xfer->timeout = 500; /* ms */ + /* put transfer on interrupt queue */ ehci_transfer_intr_enqueue(xfer); } Modified: stable/9/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/xhci.c Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/controller/xhci.c Fri May 4 15:10:49 2012 (r235001) @@ -115,6 +115,7 @@ struct xhci_std_temp { uint8_t tbc; uint8_t tlbpc; uint8_t step_td; + uint8_t do_isoc_sync; }; static void xhci_do_poll(struct usb_bus *); @@ -1657,11 +1658,15 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(temp->trb_type) | - XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) | + XHCI_TRB_3_TYPE_SET(temp->trb_type) | + (temp->do_isoc_sync ? + XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) : + XHCI_TRB_3_ISO_SIA_BIT) | XHCI_TRB_3_TBC_SET(temp->tbc) | XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + temp->do_isoc_sync = 0; + if (temp->direction == UE_DIR_IN) { dword |= XHCI_TRB_3_DIR_IN; @@ -1764,6 +1769,7 @@ xhci_setup_generic_chain(struct usb_xfer uint32_t y; uint8_t mult; + temp.do_isoc_sync = 0; temp.step_td = 0; temp.tbc = 0; temp.tlbpc = 0; @@ -1841,6 +1847,8 @@ xhci_setup_generic_chain(struct usb_xfer */ xfer->endpoint->isoc_next = XHCI_MFINDEX_GET(x + (3 * 8)); xfer->endpoint->is_synced = 1; + temp.do_isoc_sync = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); } @@ -1931,7 +1939,10 @@ xhci_setup_generic_chain(struct usb_xfer uint8_t tdpc; - /* isochronous transfers don't have short packet termination */ + /* + * Isochronous transfers don't have short + * packet termination: + */ temp.shortpkt = 1; @@ -2271,12 +2282,29 @@ xhci_configure_device(struct usb_device switch (udev->speed) { case USB_SPEED_LOW: temp |= XHCI_SCTX_0_SPEED_SET(2); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_HIGH: temp |= XHCI_SCTX_0_SPEED_SET(3); + if (sc->sc_hw.devs[index].nports != 0 && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { + DPRINTF("HUB supports MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_FULL: temp |= XHCI_SCTX_0_SPEED_SET(1); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; default: temp |= XHCI_SCTX_0_SPEED_SET(4); @@ -2287,15 +2315,8 @@ xhci_configure_device(struct usb_device (udev->speed == USB_SPEED_SUPER || udev->speed == USB_SPEED_HIGH); - if (is_hub) { + if (is_hub) temp |= XHCI_SCTX_0_HUB_SET(1); -#if 0 - if (udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { - DPRINTF("HUB supports MTT\n"); - temp |= XHCI_SCTX_0_MTT_SET(1); - } -#endif - } xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); @@ -2327,8 +2348,10 @@ xhci_configure_device(struct usb_device temp = XHCI_SCTX_2_IRQ_TARGET_SET(0); - if (is_hub) - temp |= XHCI_SCTX_2_TT_THINK_TIME_SET(sc->sc_hw.devs[index].tt); + if (is_hub) { + temp |= XHCI_SCTX_2_TT_THINK_TIME_SET( + sc->sc_hw.devs[index].tt); + } hubdev = udev->parent_hs_hub; Modified: stable/9/sys/dev/usb/usb_controller.h ============================================================================== --- stable/9/sys/dev/usb/usb_controller.h Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/usb_controller.h Fri May 4 15:10:49 2012 (r235001) @@ -231,7 +231,8 @@ void usb_bus_mem_flush_all(struct usb_bu uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb); void usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb); uint16_t usb_isoc_time_expand(struct usb_bus *bus, uint16_t isoc_time_curr); -uint16_t usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, struct usb_fs_isoc_schedule **pp_start, struct usb_fs_isoc_schedule **pp_end, uint16_t isoc_time); -uint8_t usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len); +#if USB_HAVE_TT_SUPPORT +uint8_t usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time); +#endif #endif /* _USB_CONTROLLER_H_ */ Modified: stable/9/sys/dev/usb/usb_hub.c ============================================================================== --- stable/9/sys/dev/usb/usb_hub.c Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/usb_hub.c Fri May 4 15:10:49 2012 (r235001) @@ -109,6 +109,7 @@ struct uhub_softc { #define UHUB_PROTO(sc) ((sc)->sc_udev->ddesc.bDeviceProtocol) #define UHUB_IS_HIGH_SPEED(sc) (UHUB_PROTO(sc) != UDPROTO_FSHUB) #define UHUB_IS_SINGLE_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBSTT) +#define UHUB_IS_MULTI_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBMTT) #define UHUB_IS_SUPER_SPEED(sc) (UHUB_PROTO(sc) == UDPROTO_SSHUB) /* prototypes for type checking: */ @@ -948,6 +949,16 @@ uhub_attach(device_t dev) "bus powered HUB. HUB ignored\n"); goto error; } + + if (UHUB_IS_MULTI_TT(sc)) { + err = usbd_set_alt_interface_index(udev, 0, 1); + if (err) { + device_printf(dev, "MTT could not be enabled\n"); + goto error; + } + device_printf(dev, "MTT enabled\n"); + } + /* get HUB descriptor */ DPRINTFN(2, "Getting HUB descriptor\n"); @@ -1057,10 +1068,6 @@ uhub_attach(device_t dev) } udev->hub = hub; -#if USB_HAVE_TT_SUPPORT - /* init FULL-speed ISOCHRONOUS schedule */ - usbd_fs_isoc_schedule_init_all(hub->fs_isoc_schedule); -#endif /* initialize HUB structure */ hub->hubsoftc = sc; hub->explore = &uhub_explore; @@ -1656,42 +1663,6 @@ usb_hs_bandwidth_free(struct usb_xfer *x } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_sub - * - * This function initialises an USB FULL speed isochronous schedule - * entry. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -static void -usbd_fs_isoc_schedule_init_sub(struct usb_fs_isoc_schedule *fss) -{ - fss->total_bytes = (USB_FS_ISOC_UFRAME_MAX * - USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_bytes = (USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_slot = 0; -} -#endif - -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_all - * - * This function will reset the complete USB FULL speed isochronous - * bandwidth schedule. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -void -usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss) -{ - struct usb_fs_isoc_schedule *fss_end = fss + USB_ISOC_TIME_MAX; - - while (fss != fss_end) { - usbd_fs_isoc_schedule_init_sub(fss); - fss++; - } -} -#endif - -/*------------------------------------------------------------------------* * usb_isoc_time_expand * * This function will expand the time counter from 7-bit to 16-bit. @@ -1723,114 +1694,130 @@ usb_isoc_time_expand(struct usb_bus *bus } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_isoc_time_expand + * usbd_fs_isoc_schedule_alloc_slot * - * This function does multiple things. First of all it will expand the - * passed isochronous time, which is the return value. Then it will - * store where the current FULL speed isochronous schedule is - * positioned in time and where the end is. See "pp_start" and - * "pp_end" arguments. + * This function will allocate bandwidth for an isochronous FULL speed + * transaction in the FULL speed schedule. * * Returns: - * Expanded version of "isoc_time". - * - * NOTE: This function depends on being called regularly with - * intervals less than "USB_ISOC_TIME_MAX". + * <8: Success + * Else: Error *------------------------------------------------------------------------*/ #if USB_HAVE_TT_SUPPORT -uint16_t -usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, - struct usb_fs_isoc_schedule **pp_start, - struct usb_fs_isoc_schedule **pp_end, - uint16_t isoc_time) +uint8_t +usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time) { - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss_a; - struct usb_fs_isoc_schedule *fss_b; - struct usb_hub *hs_hub; + struct usb_xfer *xfer; + struct usb_xfer *pipe_xfer; + struct usb_bus *bus; + usb_frlength_t len; + usb_frlength_t data_len; + uint16_t delta; + uint16_t slot; + uint8_t retval; - isoc_time = usb_isoc_time_expand(udev->bus, isoc_time); + data_len = 0; + slot = 0; - hs_hub = udev->parent_hs_hub->hub; + bus = isoc_xfer->xroot->bus; - if (hs_hub != NULL) { + TAILQ_FOREACH(xfer, &bus->intr_q.head, wait_entry) { - fss_a = hs_hub->fs_isoc_schedule + - (hs_hub->isoc_last_time % USB_ISOC_TIME_MAX); + /* skip self, if any */ - hs_hub->isoc_last_time = isoc_time; + if (xfer == isoc_xfer) + continue; - fss_b = hs_hub->fs_isoc_schedule + - (isoc_time % USB_ISOC_TIME_MAX); + /* check if this USB transfer is going through the same TT */ - fss_end = hs_hub->fs_isoc_schedule + USB_ISOC_TIME_MAX; + if (xfer->xroot->udev->parent_hs_hub != + isoc_xfer->xroot->udev->parent_hs_hub) { + continue; + } + if ((isoc_xfer->xroot->udev->parent_hs_hub-> + ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) && + (xfer->xroot->udev->hs_port_no != + isoc_xfer->xroot->udev->hs_port_no)) { + continue; + } + if (xfer->endpoint->methods != isoc_xfer->endpoint->methods) + continue; + + /* check if isoc_time is part of this transfer */ + + delta = xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= xfer->nframes) { + delta = xfer->nframes - delta; + + len = xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; + } + + /* check double buffered transfers */ - *pp_start = hs_hub->fs_isoc_schedule; - *pp_end = fss_end; + TAILQ_FOREACH(pipe_xfer, &xfer->endpoint->endpoint_q.head, + wait_entry) { - while (fss_a != fss_b) { - if (fss_a == fss_end) { - fss_a = hs_hub->fs_isoc_schedule; + /* skip self, if any */ + + if (pipe_xfer == isoc_xfer) continue; + + /* check if isoc_time is part of this transfer */ + + delta = pipe_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= pipe_xfer->nframes) { + delta = pipe_xfer->nframes - delta; + + len = pipe_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - usbd_fs_isoc_schedule_init_sub(fss_a); - fss_a++; } + } - } else { - - *pp_start = NULL; - *pp_end = NULL; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; } - return (isoc_time); -} -#endif -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_alloc - * - * This function will allocate bandwidth for an isochronous FULL speed - * transaction in the FULL speed schedule. The microframe slot where - * the transaction should be started is stored in the byte pointed to - * by "pstart". The "len" argument specifies the length of the - * transaction in bytes. - * - * Returns: - * 0: Success - * Else: Error - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -uint8_t -usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, - uint8_t *pstart, uint16_t len) -{ - uint8_t slot = fss->frame_slot; + /* check for overflow */ - /* Compute overhead and bit-stuffing */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); - len += 8; + retval = slot; - len *= 7; - len /= 6; + delta = isoc_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= isoc_xfer->nframes) { + delta = isoc_xfer->nframes - delta; - if (len > fss->total_bytes) { - *pstart = 0; /* set some dummy value */ - return (1); /* error */ + len = isoc_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - if (len > 0) { - fss->total_bytes -= len; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; + } - while (len >= fss->frame_bytes) { - len -= fss->frame_bytes; - fss->frame_bytes = USB_FS_BYTES_PER_HS_UFRAME; - fss->frame_slot++; - } + /* check for overflow */ - fss->frame_bytes -= len; - } - *pstart = slot; - return (0); /* success */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); + + return (retval); } #endif Modified: stable/9/sys/dev/usb/usb_hub.h ============================================================================== --- stable/9/sys/dev/usb/usb_hub.h Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/usb_hub.h Fri May 4 15:10:49 2012 (r235001) @@ -38,22 +38,9 @@ struct usb_port { }; /* - * The following structure defines how many bytes are - * left in an 1ms USB time slot. - */ -struct usb_fs_isoc_schedule { - uint16_t total_bytes; - uint8_t frame_bytes; - uint8_t frame_slot; -}; - -/* * The following structure defines an USB HUB. */ struct usb_hub { -#if USB_HAVE_TT_SUPPORT - struct usb_fs_isoc_schedule fs_isoc_schedule[USB_ISOC_TIME_MAX]; -#endif struct usb_device *hubudev; /* the HUB device */ usb_error_t (*explore) (struct usb_device *hub); void *hubsoftc; @@ -68,7 +55,6 @@ struct usb_hub { void usb_hs_bandwidth_alloc(struct usb_xfer *xfer); void usb_hs_bandwidth_free(struct usb_xfer *xfer); -void usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss); void usb_bus_port_set_device(struct usb_bus *bus, struct usb_port *up, struct usb_device *udev, uint8_t device_index); struct usb_device *usb_bus_port_get_device(struct usb_bus *bus, Modified: stable/9/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/9/sys/dev/usb/usb_transfer.c Fri May 4 15:05:30 2012 (r235000) +++ stable/9/sys/dev/usb/usb_transfer.c Fri May 4 15:10:49 2012 (r235001) @@ -1680,11 +1680,12 @@ usbd_pipe_enter(struct usb_xfer *xfer) DPRINTF("enter\n"); + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* enter the transfer */ (ep->methods->enter) (xfer); - xfer->flags_int.can_cancel_immed = 1; - /* check for transfer error */ if (xfer->error) { /* some error has happened */ @@ -2417,13 +2418,15 @@ usbd_transfer_start_cb(void *arg) #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); @@ -2598,13 +2601,14 @@ usbd_pipe_start(struct usb_xfer_queue *p #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:13:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A4B0106564A; Fri, 4 May 2012 15:13:26 +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 E8E1F8FC0A; Fri, 4 May 2012 15:13: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 q44FDPdH009248; Fri, 4 May 2012 15:13:25 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FDPae009245; Fri, 4 May 2012 15:13:25 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041513.q44FDPae009245@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:13:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235002 - in stable/9/sys/dev/usb: . serial X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:13:26 -0000 Author: hselasky Date: Fri May 4 15:13:25 2012 New Revision: 235002 URL: http://svn.freebsd.org/changeset/base/235002 Log: MFC r234541: Add new USB ID to u3g driver. Modified: stable/9/sys/dev/usb/serial/u3g.c stable/9/sys/dev/usb/usbdevs Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/9/sys/dev/usb/serial/u3g.c Fri May 4 15:10:49 2012 (r235001) +++ stable/9/sys/dev/usb/serial/u3g.c Fri May 4 15:13:25 2012 (r235002) @@ -354,6 +354,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(QISDA, H21_2, 0), U3G_DEV(QUALCOMM2, AC8700, 0), U3G_DEV(QUALCOMM2, MF330, 0), + U3G_DEV(QUALCOMM2, SIM5218, 0), U3G_DEV(QUALCOMM2, VW110L, U3GINIT_SCSIEJECT), U3G_DEV(QUALCOMMINC, AC2726, 0), U3G_DEV(QUALCOMMINC, AC8700, 0), Modified: stable/9/sys/dev/usb/usbdevs ============================================================================== --- stable/9/sys/dev/usb/usbdevs Fri May 4 15:10:49 2012 (r235001) +++ stable/9/sys/dev/usb/usbdevs Fri May 4 15:13:25 2012 (r235002) @@ -2680,6 +2680,7 @@ product QUALCOMM2 RWT_FCT 0x3100 RWT FCT product QUALCOMM2 CDMA_MSM 0x3196 CDMA Technologies MSM modem product QUALCOMM2 AC8700 0x6000 AC8700 product QUALCOMM2 VW110L 0x1000 Vertex Wireless 110L modem +product QUALCOMM2 SIM5218 0x9000 SIM5218 product QUALCOMMINC CDMA_MSM 0x0001 CDMA Technologies MSM modem product QUALCOMMINC E0002 0x0002 3G modem product QUALCOMMINC E0003 0x0003 3G modem From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:18:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FA8F1065670; Fri, 4 May 2012 15:18:01 +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 2889A8FC0C; Fri, 4 May 2012 15:18:01 +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 q44FI1J3009661; Fri, 4 May 2012 15:18:01 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FI0Px009658; Fri, 4 May 2012 15:18:00 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041518.q44FI0Px009658@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:18:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235003 - stable/9/usr.sbin/usbdump X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:18:01 -0000 Author: hselasky Date: Fri May 4 15:18:00 2012 New Revision: 235003 URL: http://svn.freebsd.org/changeset/base/235003 Log: MFC r234636 and r234655: Improve support for USB packet filtering also when reading dumps, and allow filtered data to be dumped to a binary file. Add missing and probably also mandatory -h option. Modified: stable/9/usr.sbin/usbdump/usbdump.8 stable/9/usr.sbin/usbdump/usbdump.c Directory Properties: stable/9/usr.sbin/usbdump/ (props changed) Modified: stable/9/usr.sbin/usbdump/usbdump.8 ============================================================================== --- stable/9/usr.sbin/usbdump/usbdump.8 Fri May 4 15:13:25 2012 (r235002) +++ stable/9/usr.sbin/usbdump/usbdump.8 Fri May 4 15:18:00 2012 (r235003) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 16, 2012 +.Dd April 24, 2012 .Dt USBDUMP 8 .Os .Sh NAME @@ -39,6 +39,8 @@ .Op Fl v .Op Fl w Ar file .Op Fl f Ar filter +.Op Fl b Ar file +.Op Fl h .Sh DESCRIPTION The .Nm @@ -46,12 +48,17 @@ utility provides a way to dump USB packe .Pp The following options are accepted: .Bl -tag -width ".Fl f Ar file" +.It Fl b Ar file +Store data part of the USB trace in binary format to the given +.Ar file . +This option also works with the -r and -f options. .It Fl i Ar ifname Listen on USB bus interface .Ar ifname . .It Fl r Ar file Read the raw packets from .Ar file . +This option also works with the -f option. .It Fl s Ar snaplen Snapshot .Ar snaplen @@ -62,6 +69,7 @@ When defined multiple times the verbosit .It Fl w Ar file Write the raw packets to .Ar file . +This option also works with the -s and -v options. .It Fl f Ar filter The filter argument consists of either one or two numbers separated by a dot. The first indicates the device unit number which should be traced. @@ -72,6 +80,8 @@ If 128 is added to the endpoint number t A device unit or endpoint value of -1 means ignore this field. If no filters are specified, all packets are passed through using the default -1,-1 filter. This option can be specified multiple times. +.It Fl h +This option displays a summary of the command line options. .El .Sh EXAMPLES Capture the USB raw packets on usbus2: Modified: stable/9/usr.sbin/usbdump/usbdump.c ============================================================================== --- stable/9/usr.sbin/usbdump/usbdump.c Fri May 4 15:13:25 2012 (r235002) +++ stable/9/usr.sbin/usbdump/usbdump.c Fri May 4 15:18:00 2012 (r235003) @@ -82,6 +82,8 @@ struct usbcap { int wfd; /* for -r option */ int rfd; + /* for -b option */ + int bfd; }; struct usbcap_filehdr { @@ -112,6 +114,8 @@ static int uf_minor; static const char *i_arg = "usbus0"; static const char *r_arg = NULL; static const char *w_arg = NULL; +static const char *b_arg = NULL; +static struct usbcap uc; static const char *errstr_table[USB_ERR_MAX] = { [USB_ERR_NORMAL_COMPLETION] = "0", [USB_ERR_PENDING_REQUESTS] = "PENDING_REQUESTS", @@ -255,6 +259,22 @@ done: pprog->bf_insns = dynamic_insn; } +static int +match_filter(int unit, int endpoint) +{ + struct usb_filt *puf; + + if (STAILQ_FIRST(&usb_filt_head) == NULL) + return (1); + + STAILQ_FOREACH(puf, &usb_filt_head, entry) { + if ((puf->unit == -1 || puf->unit == unit) && + (puf->endpoint == -1 || puf->endpoint == endpoint)) + return (1); + } + return (0); +} + static void free_filter(struct bpf_program *pprog) { @@ -462,28 +482,33 @@ print_apacket(const struct header_32 *hd up->up_packet_count = le32toh(up->up_packet_count); up->up_endpoint = le32toh(up->up_endpoint); + if (!match_filter(up->up_address, up->up_endpoint)) + return; + tv.tv_sec = hdr->ts_sec; tv.tv_usec = hdr->ts_usec; tm = localtime(&tv.tv_sec); len = strftime(buf, sizeof(buf), "%H:%M:%S", tm); - printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n", - (int)len, buf, tv.tv_usec, - (int)up->up_busunit, (int)up->up_address, - (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE", - xfertype_table[up->up_xfertype], - (unsigned int)up->up_endpoint, - usb_speedstr(up->up_speed), - (int)up->up_frames, - (int)(up->up_totlen - USBPF_HDR_LEN - - (USBPF_FRAME_HDR_LEN * up->up_frames)), - (int)up->up_interval, - (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "", - (up->up_type == USBPF_XFERTAP_DONE) ? - usb_errstr(up->up_error) : ""); + if (verbose >= 0) { + printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n", + (int)len, buf, tv.tv_usec, + (int)up->up_busunit, (int)up->up_address, + (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE", + xfertype_table[up->up_xfertype], + (unsigned int)up->up_endpoint, + usb_speedstr(up->up_speed), + (int)up->up_frames, + (int)(up->up_totlen - USBPF_HDR_LEN - + (USBPF_FRAME_HDR_LEN * up->up_frames)), + (int)up->up_interval, + (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "", + (up->up_type == USBPF_XFERTAP_DONE) ? + usb_errstr(up->up_error) : ""); + } - if (verbose >= 1) { + if (verbose >= 1 || b_arg != NULL) { for (x = 0; x != up->up_frames; x++) { const struct usbpf_framehdr *uf; uint32_t framelen; @@ -498,10 +523,12 @@ print_apacket(const struct header_32 *hd framelen = le32toh(uf->length); flags = le32toh(uf->flags); - printf(" frame[%u] %s %d bytes\n", - (unsigned int)x, - (flags & USBPF_FRAMEFLAG_READ) ? "READ" : "WRITE", - (int)framelen); + if (verbose >= 1) { + printf(" frame[%u] %s %d bytes\n", + (unsigned int)x, + (flags & USBPF_FRAMEFLAG_READ) ? "READ" : "WRITE", + (int)framelen); + } if (flags & USBPF_FRAMEFLAG_DATA_FOLLOWS) { @@ -515,7 +542,15 @@ print_apacket(const struct header_32 *hd (int)framelen < 0 || (int)ptr_len < 0) break; - hexdump(ptr, framelen); + if (b_arg != NULL) { + struct usbcap *p = &uc; + int ret; + ret = write(p->bfd, ptr, framelen); + if (ret != (int)framelen) + err(EXIT_FAILURE, "Could not write binary data"); + } + if (verbose >= 1) + hexdump(ptr, framelen); ptr += tot_frame_len; } @@ -592,7 +627,7 @@ print_packets(uint8_t *data, const int d if (next <= ptr) err(EXIT_FAILURE, "Invalid length"); - if (w_arg == NULL || r_arg != NULL) { + if (verbose >= 0 || r_arg != NULL || b_arg != NULL) { print_apacket(&temp, ptr + temp.hdrlen, temp.caplen); } @@ -738,7 +773,9 @@ usage(void) fprintf(stderr, FMT, "-r ", "Read the raw packets from file"); fprintf(stderr, FMT, "-s ", "Snapshot bytes from each packet"); fprintf(stderr, FMT, "-v", "Increase the verbose level"); + fprintf(stderr, FMT, "-b ", "Save raw version of all recorded data to file"); fprintf(stderr, FMT, "-w ", "Write the raw packets to file"); + fprintf(stderr, FMT, "-h", "Display summary of command line options"); #undef FMT exit(EX_USAGE); } @@ -750,7 +787,7 @@ main(int argc, char *argv[]) struct bpf_program total_prog; struct bpf_stat us; struct bpf_version bv; - struct usbcap uc, *p = &uc; + struct usbcap *p = &uc; struct ifreq ifr; long snapshot = 192; uint32_t v; @@ -761,9 +798,7 @@ main(int argc, char *argv[]) const char *optstring; char *pp; - memset(&uc, 0, sizeof(struct usbcap)); - - optstring = "i:r:s:vw:f:"; + optstring = "b:hi:r:s:vw:f:"; while ((o = getopt(argc, argv, optstring)) != -1) { switch (o) { case 'i': @@ -784,6 +819,9 @@ main(int argc, char *argv[]) if (snapshot == 0) snapshot = -1; break; + case 'b': + b_arg = optarg; + break; case 'v': verbose++; break; @@ -811,6 +849,22 @@ main(int argc, char *argv[]) } } + if (b_arg != NULL) { + p->bfd = open(b_arg, O_CREAT | O_TRUNC | + O_WRONLY, S_IRUSR | S_IWUSR); + if (p->bfd < 0) { + err(EXIT_FAILURE, "Could not open " + "'%s' for write", b_arg); + } + } + + /* + * Require more verbosity to print anything when -w or -b is + * specified on the command line: + */ + if (w_arg != NULL || b_arg != NULL) + verbose--; + if (r_arg != NULL) { read_file(p); exit(EXIT_SUCCESS); @@ -882,6 +936,8 @@ main(int argc, char *argv[]) close(p->rfd); if (p->wfd > 0) close(p->wfd); + if (p->bfd > 0) + close(p->bfd); return (EXIT_SUCCESS); } From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:27:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B84F3106564A; Fri, 4 May 2012 15:27:18 +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 9FF7E8FC0A; Fri, 4 May 2012 15:27:18 +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 q44FRI7W010056; Fri, 4 May 2012 15:27:18 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FRIZw010045; Fri, 4 May 2012 15:27:18 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041527.q44FRIZw010045@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:27:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235004 - stable/9/lib/libusb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:27:18 -0000 Author: hselasky Date: Fri May 4 15:27:18 2012 New Revision: 235004 URL: http://svn.freebsd.org/changeset/base/235004 Log: MFC r233667, r234687, r234491, r234193, r233424: Fix some compile warnings. Fix some mdoc issues. Add missing LibUSB 1.0 API function. Modified: stable/9/lib/libusb/Makefile stable/9/lib/libusb/libusb.3 stable/9/lib/libusb/libusb.h stable/9/lib/libusb/libusb10.c stable/9/lib/libusb/libusb10_desc.c stable/9/lib/libusb/libusb10_io.c stable/9/lib/libusb/libusb20.3 stable/9/lib/libusb/libusb20.c stable/9/lib/libusb/libusb20_desc.c stable/9/lib/libusb/libusb20_ugen20.c Directory Properties: stable/9/lib/libusb/ (props changed) Modified: stable/9/lib/libusb/Makefile ============================================================================== --- stable/9/lib/libusb/Makefile Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/Makefile Fri May 4 15:27:18 2012 (r235004) @@ -48,6 +48,7 @@ MLINKS += libusb.3 libusb_get_bus_number MLINKS += libusb.3 libusb_get_device_address.3 MLINKS += libusb.3 libusb_get_device_speed.3 MLINKS += libusb.3 libusb_get_max_packet_size.3 +MLINKS += libusb.3 libusb_get_max_iso_packet_size.3 MLINKS += libusb.3 libusb_ref_device.3 MLINKS += libusb.3 libusb_unref_device.3 MLINKS += libusb.3 libusb_open.3 @@ -69,7 +70,7 @@ MLINKS += libusb.3 libusb_detach_kernel_ MLINKS += libusb.3 libusb_detach_kernel_driver_np.3 MLINKS += libusb.3 libusb_attach_kernel_driver.3 MLINKS += libusb.3 libusb_get_device_descriptor.3 -MLINKS += libusb.3 libsub_get_active_config_descriptor.3 +MLINKS += libusb.3 libusb_get_active_config_descriptor.3 MLINKS += libusb.3 libusb_get_config_descriptor.3 MLINKS += libusb.3 libusb_get_config_descriptor_by_value.3 MLINKS += libusb.3 libusb_free_config_descriptor.3 Modified: stable/9/lib/libusb/libusb.3 ============================================================================== --- stable/9/lib/libusb/libusb.3 Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb.3 Fri May 4 15:27:18 2012 (r235004) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd April 12, 2012 .Dt LIBUSB 3 .Os .Sh NAME @@ -43,7 +43,6 @@ The library contains interfaces for directly managing a usb device. The current implementation supports v1.0 of the libusb API. .Sh LIBRARY INITIALISATION / DEINITIALISATION -.Pp .Ft int .Fn libusb_init libusb_context **ctx This function initialises libusb. @@ -119,6 +118,12 @@ LIBUSB_SPEED_UNKNOWN is returned in case Returns the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure. .Pp +.Ft int +.Fn libusb_get_max_iso_packet_size "libusb_device *dev" "unsigned char endpoint" +Returns the packet size multiplied by the packet multiplier on success, +LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and +LIBUSB_ERROR_OTHERS on other failure. +.Pp .Ft libusb_device * .Fn libusb_ref_device "libusb_device *dev" Increment the reference counter of the device @@ -270,9 +275,7 @@ LIBUSB_ERROR_NO_DEVICE if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be attached because the interface is claimed by a program or driver and a LIBUSB_ERROR code on failure. -.Pp .Sh USB DESCRIPTORS -.Pp .Ft int .Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc" Get the USB device descriptor for the device @@ -282,7 +285,7 @@ Returns 0 on success and a LIBUSB_ERROR failure. .Pp .Ft int -.Fn libsub_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config" +.Fn libusb_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config" Get the USB configuration descriptor for the active configuration. Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the device is in @@ -349,9 +352,7 @@ libusb_free_bos_descriptor function. .Ft void .Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos" This function is NULL safe and frees a parsed BOS descriptor. -.Pp .Sh USB ASYNCHRONOUS I/O -.Pp .Ft struct libusb_transfer * .Fn libusb_alloc_transfer "int iso_packets" Allocate a transfer with the number of isochronous packet descriptors @@ -374,9 +375,7 @@ LIBUSB_ERROR code on other failure. .Fn libusb_cancel_transfer "struct libusb_transfer *tr" This function asynchronously cancels a transfer. Returns 0 on success and a LIBUSB_ERROR code on failure. -.Pp .Sh USB SYNCHRONOUS I/O -.Pp .Ft int .Fn libusb_control_transfer "libusb_device_handle *devh" "uint8_t bmRequestType" "uint8_t bRequest" "uint16_t wValue" "uint16_t wIndex" "unsigned char *data" "uint16_t wLength" "unsigned int timeout" Perform a USB control transfer. @@ -411,9 +410,7 @@ if the transfer timed out, LIBUSB_ERROR_ supported, LIBUSB_ERROR_OVERFLOW if the device offered more data, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and a LIBUSB_ERROR code on other failure. -.Pp .Sh USB EVENTS -.Pp .Ft int .Fn libusb_try_lock_events "libusb_context *ctx" Try to acquire the event handling lock. @@ -429,7 +426,7 @@ This function is blocking. Release the event handling lock. This will wake up any thread blocked on -.B libusb_wait_for_event() . +.Fn libusb_wait_for_event . .Pp .Ft int .Fn libusb_event_handling_ok "libusb_context *ctx" @@ -506,7 +503,6 @@ Retrive a list of file descriptors that libusb event sources. Returns a NULL-terminated list on success or NULL on failure. .Sh LIBUSB VERSION 0.1 COMPATIBILITY -.Pp The library is also compliant with LibUSB version 0.1.12. .Pp .Fn usb_open Modified: stable/9/lib/libusb/libusb.h ============================================================================== --- stable/9/lib/libusb/libusb.h Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb.h Fri May 4 15:27:18 2012 (r235004) @@ -371,6 +371,7 @@ uint8_t libusb_get_device_address(libusb enum libusb_speed libusb_get_device_speed(libusb_device * dev); int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint); int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); +int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); libusb_device *libusb_ref_device(libusb_device * dev); void libusb_unref_device(libusb_device * dev); int libusb_open(libusb_device * dev, libusb_device_handle ** devh); Modified: stable/9/lib/libusb/libusb10.c ============================================================================== --- stable/9/lib/libusb/libusb10.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb10.c Fri May 4 15:27:18 2012 (r235004) @@ -331,6 +331,30 @@ out: return (ret); } +int +libusb_get_max_iso_packet_size(libusb_device *dev, uint8_t endpoint) +{ + int multiplier; + int ret; + + ret = libusb_get_max_packet_size(dev, endpoint); + + switch (libusb20_dev_get_speed(dev->os_priv)) { + case LIBUSB20_SPEED_LOW: + case LIBUSB20_SPEED_FULL: + break; + default: + if (ret > -1) { + multiplier = (1 + ((ret >> 11) & 3)); + if (multiplier > 3) + multiplier = 3; + ret = (ret & 0x7FF) * multiplier; + } + break; + } + return (ret); +} + libusb_device * libusb_ref_device(libusb_device *dev) { @@ -627,17 +651,17 @@ libusb_set_interface_alt_setting(struct static struct libusb20_transfer * libusb10_get_transfer(struct libusb20_device *pdev, - uint8_t endpoint, uint8_t index) + uint8_t endpoint, uint8_t xfer_index) { - index &= 1; /* double buffering */ + xfer_index &= 1; /* double buffering */ - index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4; + xfer_index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4; if (endpoint & LIBUSB20_ENDPOINT_DIR_MASK) { /* this is an IN endpoint */ - index |= 2; + xfer_index |= 2; } - return (libusb20_tr_get_pointer(pdev, index)); + return (libusb20_tr_get_pointer(pdev, xfer_index)); } int Modified: stable/9/lib/libusb/libusb10_desc.c ============================================================================== --- stable/9/lib/libusb/libusb10_desc.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb10_desc.c Fri May 4 15:27:18 2012 (r235004) @@ -390,8 +390,8 @@ libusb_parse_bos_descriptor(const void * struct libusb_bos_descriptor **bos) { struct libusb_bos_descriptor *ptr; - struct libusb_usb_2_0_device_capability_descriptor *dcap_20; - struct libusb_ss_usb_device_capability_descriptor *ss_cap; + struct libusb_usb_2_0_device_capability_descriptor *dcap_20 = NULL; + struct libusb_ss_usb_device_capability_descriptor *ss_cap = NULL; if (buf == NULL || bos == NULL || len < 1) return (LIBUSB_ERROR_INVALID_PARAM); @@ -438,7 +438,7 @@ libusb_parse_bos_descriptor(const void * dtype == LIBUSB_DT_DEVICE_CAPABILITY) { switch (((const uint8_t *)buf)[2]) { case LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY: - if (ptr->usb_2_0_ext_cap != NULL) + if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == NULL) break; if (dlen < LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE) break; @@ -455,7 +455,7 @@ libusb_parse_bos_descriptor(const void * break; case LIBUSB_SS_USB_DEVICE_CAPABILITY: - if (ptr->ss_usb_cap != NULL) + if (ptr->ss_usb_cap != NULL || ss_cap == NULL) break; if (dlen < LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE) break; Modified: stable/9/lib/libusb/libusb10_io.c ============================================================================== --- stable/9/lib/libusb/libusb10_io.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb10_io.c Fri May 4 15:27:18 2012 (r235004) @@ -481,7 +481,7 @@ libusb10_do_transfer(libusb_device_handl { libusb_context *ctx; struct libusb_transfer *xfer; - volatile int complet; + int done; int ret; if (devh == NULL) @@ -502,15 +502,15 @@ libusb10_do_transfer(libusb_device_handl xfer->timeout = timeout; xfer->buffer = data; xfer->length = length; - xfer->user_data = (void *)&complet; + xfer->user_data = (void *)&done; xfer->callback = libusb10_do_transfer_cb; - complet = 0; + done = 0; if ((ret = libusb_submit_transfer(xfer)) < 0) { libusb_free_transfer(xfer); return (ret); } - while (complet == 0) { + while (done == 0) { if ((ret = libusb_handle_events(ctx)) < 0) { libusb_cancel_transfer(xfer); usleep(1000); /* nice it */ @@ -581,7 +581,7 @@ libusb_interrupt_transfer(libusb_device_ } uint8_t * -libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index) +libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t off) { uint8_t *ptr; uint32_t n; @@ -589,35 +589,35 @@ libusb_get_iso_packet_buffer(struct libu if (transfer->num_iso_packets < 0) return (NULL); - if (index >= (uint32_t)transfer->num_iso_packets) + if (off >= (uint32_t)transfer->num_iso_packets) return (NULL); ptr = transfer->buffer; if (ptr == NULL) return (NULL); - for (n = 0; n != index; n++) { + for (n = 0; n != off; n++) { ptr += transfer->iso_packet_desc[n].length; } return (ptr); } uint8_t * -libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index) +libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t off) { uint8_t *ptr; if (transfer->num_iso_packets < 0) return (NULL); - if (index >= (uint32_t)transfer->num_iso_packets) + if (off >= (uint32_t)transfer->num_iso_packets) return (NULL); ptr = transfer->buffer; if (ptr == NULL) return (NULL); - ptr += transfer->iso_packet_desc[0].length * index; + ptr += transfer->iso_packet_desc[0].length * off; return (ptr); } Modified: stable/9/lib/libusb/libusb20.3 ============================================================================== --- stable/9/lib/libusb/libusb20.3 Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb20.3 Fri May 4 15:27:18 2012 (r235004) @@ -235,7 +235,6 @@ applications should consider using . .Sh USB TRANSFER OPERATIONS . -.Pp . .Fn libusb20_tr_close will release all kernel resources associated with an USB @@ -534,7 +533,6 @@ with an USB transfer. . .Sh USB DEVICE OPERATIONS . -.Pp . .Fn libusb20_dev_get_backend_name returns a zero terminated string describing the backend used. @@ -1000,7 +998,6 @@ 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 Modified: stable/9/lib/libusb/libusb20.c ============================================================================== --- stable/9/lib/libusb/libusb20.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb20.c Fri May 4 15:27:18 2012 (r235004) @@ -948,9 +948,8 @@ libusb20_dev_get_config_index(struct lib } error = pdev->methods->get_config_index(pdev, &cfg_index); - if (error) { - cfg_index = 0 - 1; /* current config index */ - } + if (error) + cfg_index = 0xFF; /* current config index */ if (do_close) { if (libusb20_dev_close(pdev)) { /* ignore */ Modified: stable/9/lib/libusb/libusb20_desc.c ============================================================================== --- stable/9/lib/libusb/libusb20_desc.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb20_desc.c Fri May 4 15:27:18 2012 (r235004) @@ -69,7 +69,7 @@ libusb20_parse_config_desc(const void *c uint16_t niface_no_alt; uint16_t niface; uint16_t nendpoint; - uint8_t iface_no; + uint16_t iface_no; ptr = config_desc; if (ptr[1] != LIBUSB20_DT_CONFIG) { @@ -82,7 +82,7 @@ libusb20_parse_config_desc(const void *c niface_no_alt = 0; nendpoint = 0; niface = 0; - iface_no = 0 - 1; + iface_no = 0xFFFF; ptr = NULL; /* get "wTotalLength" and setup "pcdesc" */ @@ -155,7 +155,7 @@ libusb20_parse_config_desc(const void *c /* reset states */ niface = 0; - iface_no = 0 - 1; + iface_no = 0xFFFF; ptr = NULL; lub_interface--; lub_endpoint--; @@ -450,7 +450,7 @@ libusb20_me_encode(void *ptr, uint16_t l * and should be * correct: */ - ps->len = 0 - 1; + ps->len = 0xFFFF; } src_len = libusb20_me_get_1(pd, 0); src_ptr = LIBUSB20_ADD_BYTES(ps->ptr, 1); @@ -465,7 +465,7 @@ libusb20_me_encode(void *ptr, uint16_t l case LIBUSB20_ME_IS_DECODED: /* reserve 3 length bytes */ src_len = libusb20_me_encode(NULL, - 0 - 1 - 3, ps->ptr); + 0xFFFF - 3, ps->ptr); src_ptr = NULL; break; @@ -476,7 +476,7 @@ libusb20_me_encode(void *ptr, uint16_t l } if (src_len > 0xFE) { - if (src_len > (uint16_t)(0 - 1 - 3)) + if (src_len > (0xFFFF - 3)) /* overflow */ goto done; @@ -516,7 +516,7 @@ libusb20_me_encode(void *ptr, uint16_t l uint16_t dummy; dummy = libusb20_me_encode(buf, - 0 - 1 - 3, ps->ptr); + 0xFFFF - 3, ps->ptr); } else { bcopy(src_ptr, buf, src_len); } Modified: stable/9/lib/libusb/libusb20_ugen20.c ============================================================================== --- stable/9/lib/libusb/libusb20_ugen20.c Fri May 4 15:18:00 2012 (r235003) +++ stable/9/lib/libusb/libusb20_ugen20.c Fri May 4 15:27:18 2012 (r235004) @@ -104,7 +104,7 @@ ugen20_path_convert_one(const char **pp) temp += (*ptr - '0'); if (temp >= 1000000) { /* catch overflow early */ - return (0 - 1); + return (0xFFFFFFFF); } ptr++; } From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:31:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6971F106564A; Fri, 4 May 2012 15:31:36 +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 52B458FC08; Fri, 4 May 2012 15:31: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 q44FVa1u010238; Fri, 4 May 2012 15:31:36 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FVaYF010236; Fri, 4 May 2012 15:31:36 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041531.q44FVaYF010236@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:31: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: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:31:36 -0000 Author: jpaetzel Date: Fri May 4 15:31:35 2012 New Revision: 235005 URL: http://svn.freebsd.org/changeset/base/235005 Log: Use a unique zpool name during install, in the case of having another PC-BSD / FreeBSD zpool on the system for another install. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:27:18 2012 (r235004) +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:31:35 2012 (r235005) @@ -216,7 +216,7 @@ fetch_file() fetch -s "${FETCHFILE}" >${SIZEFILE} SIZE="`cat ${SIZEFILE}`" - SIZE="`expr ${SIZE} / 1024`" + SIZE=$((SIZE/1024)) echo "FETCH: ${FETCHFILE}" echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} @@ -276,11 +276,22 @@ get_zpool_name() else # Need to generate a zpool name for this device NUM=`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` - NEWNAME="${BASENAME}${NUM}" + + # Is it used in another zpool? + while + z=1 + do + NEWNAME="${BASENAME}${NUM}" + zpool import | grep -q "${NEWNAME}" + if [ $? -ne 0 ] ; then break ; fi + NUM=$((NUM+1)) + done + + # Now save the new tank name mkdir -p ${TMPDIR}/.zpools/`dirname $DEVICE` echo "$NEWNAME" >${TMPDIR}/.zpools/${DEVICE} echo "${NEWNAME}" - return + return 0 fi }; From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:36:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F5B5106564A; Fri, 4 May 2012 15:36:52 +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 299978FC18; Fri, 4 May 2012 15:36:52 +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 q44FaqiB010445; Fri, 4 May 2012 15:36:52 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FapN5010442; Fri, 4 May 2012 15:36:51 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041536.q44FapN5010442@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:36:51 +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: r235006 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:36:52 -0000 Author: jpaetzel Date: Fri May 4 15:36:51 2012 New Revision: 235006 URL: http://svn.freebsd.org/changeset/base/235006 Log: Add powerpc / powerpc64 support to pc-sysinstall. This patch will autodetect if on powerpc and use the APM gpart GEOM class automaticaly. At this time support for full disk installation is the only supported scheme. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Fri May 4 15:31:35 2012 (r235005) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Fri May 4 15:36:51 2012 (r235006) @@ -177,6 +177,8 @@ setup_gpart_partitions() # Lets read in the config file now and setup our partitions if [ "${_pType}" = "gpt" ] ; then CURPART="2" + elif [ "${_pType}" = "apm" ] ; then + CURPART="3" else PARTLETTER="a" CURPART="1" @@ -255,6 +257,9 @@ setup_gpart_partitions() if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then export FOUNDROOT="0" fi + if [ "${CURPART}" = "3" -a "$_pType" = "apm" ] ; then + export FOUNDROOT="0" + fi if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then export FOUNDROOT="0" fi @@ -269,6 +274,9 @@ setup_gpart_partitions() if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then exit_err "/boot partition must be first partition" fi + if [ "${CURPART}" != "3" -a "${_pType}" = "apm" ] ; then + exit_err "/boot partition must be first partition" + fi if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then exit_err "/boot partition must be first partition" fi @@ -288,6 +296,8 @@ setup_gpart_partitions() # Get any extra options for this fs / line if [ "${_pType}" = "gpt" ] ; then get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}" + elif [ "${_pType}" = "apm" ] ; then + get_fs_line_xvars "${_pDisk}s${CURPART}" "${STRING}" else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi @@ -298,6 +308,8 @@ setup_gpart_partitions() if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") + elif [ "${_pType}" = "apm" ] ; then + XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}s${CURPART}") else XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") fi @@ -323,6 +335,9 @@ setup_gpart_partitions() elif [ "${_pType}" = "gptslice" ]; then sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" + elif [ "${_pType}" = "apm" ]; then + sleep 2 + rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" else sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" @@ -352,6 +367,18 @@ setup_gpart_partitions() if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass fi + elif [ "${_pType}" = "apm" ] ; then + _dFile="`echo $_pDisk | sed 's|/|-|g'`" + echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}s${CURPART} + + # Clear out any headers + sleep 2 + dd if=/dev/zero of=${_pDisk}s${CURPART} count=2048 2>/dev/null + + # If we have a enc password, save it as well + if [ -n "${ENCPASS}" ] ; then + echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}s${CURPART}-encpass + fi else # MBR Partition or GPT slice _dFile="`echo $_wSlice | sed 's|/|-|g'`" @@ -368,9 +395,10 @@ setup_gpart_partitions() # Increment our parts counter - if [ "$_pType" = "gpt" ] ; then + if [ "$_pType" = "gpt" -o "$_pType" = "apm" ] ; then CURPART=$((CURPART+1)) - # If this is a gpt partition, we can continue and skip the MBR part letter stuff + # If this is a gpt/apm partition, + # we can continue and skip the MBR part letter stuff continue else CURPART=$((CURPART+1)) @@ -437,6 +465,9 @@ populate_disk_label() if [ "$type" = "mbr" ] ; then wrkslice="${diskid}s${slicenum}" fi + if [ "$type" = "apm" ] ; then + wrkslice="${diskid}s${slicenum}" + fi if [ "$type" = "gpt" -o "$type" = "gptslice" ] ; then wrkslice="${diskid}p${slicenum}" fi @@ -474,6 +505,9 @@ setup_disk_label() if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi + if [ "$type" = "apm" -a ! -e "${disk}s${pnum}" ] ; then + exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" + fi if [ "$type" = "gptslice" -a ! -e "${disk}p${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:31:35 2012 (r235005) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:36:51 2012 (r235006) @@ -464,6 +464,12 @@ setup_disk_slice() # Found our flag to commit this disk setup / lets do sanity check and do it if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] then + # Make sure we are only installing ppc to full disk + if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ]; then + if [ "$PTYPE" != "all" ] ; then + exit_err "powerpc can only be installed to a full disk" + fi + fi case ${PTYPE} in all) @@ -488,6 +494,12 @@ setup_disk_slice() tmpSLICE="${DISK}p1" fi + if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ] + then + PSCHEME="APM" + tmpSLICE="${DISK}s1" + fi + run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}" ;; @@ -597,6 +609,30 @@ clear_backup_gpt_table() rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=`diskinfo ${1} | awk '{print int($3 / (1024*1024)) - 4;}'`" } ; +# Function which runs gpart and creates a single large APM partition scheme +init_apm_full_disk() +{ + _intDISK=$1 + + # Set our sysctl so we can overwrite any geom using drives + sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} + + # Stop any journaling + stop_gjournal "${_intDISK}" + + # Remove any existing partitions + delete_all_gpart "${_intDISK}" + + sleep 2 + + echo_log "Running gpart on ${_intDISK}" + rc_halt "gpart create -s APM ${_intDISK}" + rc_halt "gpart add -s 800k -t freebsd-boot ${_intDISK}" + + echo_log "Stamping boot sector on ${_intDISK}" + rc_halt "gpart bootcode -p /boot/boot1.hfs -i 1 ${_intDISK}" + +} # Function which runs gpart and creates a single large GPT partition scheme init_gpt_full_disk() @@ -670,7 +706,10 @@ run_gpart_full() BOOT=$2 SCHEME=$3 - if [ "$SCHEME" = "MBR" ] ; then + if [ "$SCHEME" = "APM" ] ; then + init_apm_full_disk "$DISK" + slice=`echo "${DISK}:1:apm" | sed 's|/|-|g'` + elif [ "$SCHEME" = "MBR" ] ; then init_mbr_full_disk "$DISK" "$BOOT" slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'` else From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:38:47 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2FC9106566C; Fri, 4 May 2012 15:38:47 +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 928DE8FC20; Fri, 4 May 2012 15:38:47 +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 q44FclYY010549; Fri, 4 May 2012 15:38:47 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FclqK010547; Fri, 4 May 2012 15:38:47 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041538.q44FclqK010547@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:38:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:38:47 -0000 Author: hselasky Date: Fri May 4 15:38:47 2012 New Revision: 235007 URL: http://svn.freebsd.org/changeset/base/235007 Log: MFC r233662, r233677 and r233678: Writing zero to BAR actually does not disable it and it is even harmful as hselasky found out. Historically, this code was originated from (OLDCARD) CardBus driver and later leaked into PCI driver when CardBus was newbus'ified and refactored with PCI driver. However, it is not really necessary even for CardBus. Modified: stable/9/sys/dev/pci/pci.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/pci/pci.c ============================================================================== --- stable/9/sys/dev/pci/pci.c Fri May 4 15:36:51 2012 (r235006) +++ stable/9/sys/dev/pci/pci.c Fri May 4 15:38:47 2012 (r235007) @@ -2746,16 +2746,15 @@ pci_add_map(device_t bus, device_t dev, prefetch ? RF_PREFETCHABLE : 0); if (res == NULL) { /* - * If the allocation fails, clear the BAR and delete - * the resource list entry to force - * pci_alloc_resource() to allocate resources from the - * parent. + * If the allocation fails, delete the resource list entry + * to force pci_alloc_resource() to allocate resources + * from the parent. */ resource_list_delete(rl, type, reg); - start = 0; - } else + } else { start = rman_get_start(res); - pci_write_bar(dev, pm, start); + pci_write_bar(dev, pm, start); + } return (barlen); } @@ -3824,7 +3823,7 @@ pci_describe_device(device_t dev) if ((desc = malloc(strlen(vp) + strlen(dp) + 3, M_DEVBUF, M_NOWAIT)) != NULL) sprintf(desc, "%s, %s", vp, dp); - out: +out: if (vp != NULL) free(vp, M_DEVBUF); if (dp != NULL) @@ -4100,7 +4099,7 @@ pci_reserve_map(device_t dev, device_t c count, *rid, type, rman_get_start(res)); map = rman_get_start(res); pci_write_bar(child, pm, map); -out:; +out: return (res); } @@ -4289,19 +4288,6 @@ pci_delete_resource(device_t dev, device type, rid, rman_get_start(rle->res)); return; } - -#ifndef __PCI_BAR_ZERO_VALID - /* - * If this is a BAR, clear the BAR so it stops - * decoding before releasing the resource. - */ - switch (type) { - case SYS_RES_IOPORT: - case SYS_RES_MEMORY: - pci_write_bar(child, pci_find_bar(child, rid), 0); - break; - } -#endif resource_list_unreserve(rl, dev, child, type, rid); } resource_list_delete(rl, type, rid); From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:39:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3037F1065673; Fri, 4 May 2012 15:39:42 +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 1AD568FC21; Fri, 4 May 2012 15:39:42 +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 q44FdfgL010612; Fri, 4 May 2012 15:39:41 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Fdff6010610; Fri, 4 May 2012 15:39:41 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041539.q44Fdff6010610@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235008 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:39:42 -0000 Author: jpaetzel Date: Fri May 4 15:39:41 2012 New Revision: 235008 URL: http://svn.freebsd.org/changeset/base/235008 Log: Add bootcamp bootloader stamp Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:38:47 2012 (r235007) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:39:41 2012 (r235008) @@ -766,6 +766,10 @@ run_gpart_gpt_part() # Init the MBR partition rc_halt "gpart create -s BSD ${DISK}p${slicenum}" + # Stamp the bootloader + sleep 4 + rc_halt "gpart bootcode -b /boot/boot ${DISK}p${slicenum}" + # Set the slice to the format we'll be using for gpart later slice=`echo "${1}:${3}:gptslice" | sed 's|/|-|g'` From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:49:09 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3CF8106566B; Fri, 4 May 2012 15:49:08 +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 DE3DE8FC16; Fri, 4 May 2012 15:49:08 +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 q44Fn8Qw010973; Fri, 4 May 2012 15:49:08 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Fn8bH010969; Fri, 4 May 2012 15:49:08 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041549.q44Fn8bH010969@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 15:49:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235009 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:49:09 -0000 Author: tuexen Date: Fri May 4 15:49:08 2012 New Revision: 235009 URL: http://svn.freebsd.org/changeset/base/235009 Log: Add support for SCTP_STREAM_CHANGE_EVENT, SCTP_ASSOC_RESET_EVENT as required by RFC 6525. This also fixes SCTP_STREAM_RESET_EVENT. MFC after: 3 days Modified: head/sys/netinet/sctp.h head/sys/netinet/sctp_usrreq.c head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp.h ============================================================================== --- head/sys/netinet/sctp.h Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctp.h Fri May 4 15:49:08 2012 (r235009) @@ -511,35 +511,37 @@ struct sctp_error_unrecognized_chunk { /* * PCB Features (in sctp_features bitmask) */ -#define SCTP_PCB_FLAGS_DO_NOT_PMTUD 0x00000001 -#define SCTP_PCB_FLAGS_EXT_RCVINFO 0x00000002 /* deprecated */ -#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT 0x00000004 -#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE 0x00000008 -#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x00000010 -#define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020 -#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040 -#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x00000080 +#define SCTP_PCB_FLAGS_DO_NOT_PMTUD 0x00000001 +#define SCTP_PCB_FLAGS_EXT_RCVINFO 0x00000002 /* deprecated */ +#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT 0x00000004 +#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE 0x00000008 +#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x00000010 +#define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020 +#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040 +#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x00000080 /* socket options */ -#define SCTP_PCB_FLAGS_NODELAY 0x00000100 -#define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200 -#define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400 /* deprecated */ -#define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800 -#define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000 -#define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000 -#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000 -#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000 -#define SCTP_PCB_FLAGS_ADAPTATIONEVNT 0x00010000 -#define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000 -#define SCTP_PCB_FLAGS_AUTHEVNT 0x00040000 -#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00080000 -#define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00100000 -#define SCTP_PCB_FLAGS_EXPLICIT_EOR 0x00400000 -#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x00800000 -#define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x01000000 -#define SCTP_PCB_FLAGS_PORTREUSE 0x02000000 -#define SCTP_PCB_FLAGS_DRYEVNT 0x04000000 -#define SCTP_PCB_FLAGS_RECVRCVINFO 0x08000000 -#define SCTP_PCB_FLAGS_RECVNXTINFO 0x10000000 +#define SCTP_PCB_FLAGS_NODELAY 0x00000100 +#define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200 +#define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400 /* deprecated */ +#define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800 +#define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000 +#define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000 +#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000 +#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000 +#define SCTP_PCB_FLAGS_ADAPTATIONEVNT 0x00010000 +#define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000 +#define SCTP_PCB_FLAGS_AUTHEVNT 0x00040000 +#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00080000 +#define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00100000 +#define SCTP_PCB_FLAGS_EXPLICIT_EOR 0x00400000 +#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x00800000 +#define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x01000000 +#define SCTP_PCB_FLAGS_PORTREUSE 0x02000000 +#define SCTP_PCB_FLAGS_DRYEVNT 0x04000000 +#define SCTP_PCB_FLAGS_RECVRCVINFO 0x08000000 +#define SCTP_PCB_FLAGS_RECVNXTINFO 0x10000000 +#define SCTP_PCB_FLAGS_ASSOC_RESETEVNT 0x20000000 +#define SCTP_PCB_FLAGS_STREAM_CHANGEEVNT 0x40000000 /*- * mobility_features parameters (by micchie).Note @@ -547,9 +549,9 @@ struct sctp_error_unrecognized_chunk { * sctp_mobility_features flags.. not the sctp_features * flags. */ -#define SCTP_MOBILITY_BASE 0x00000001 -#define SCTP_MOBILITY_FASTHANDOFF 0x00000002 -#define SCTP_MOBILITY_PRIM_DELETED 0x00000004 +#define SCTP_MOBILITY_BASE 0x00000001 +#define SCTP_MOBILITY_FASTHANDOFF 0x00000002 +#define SCTP_MOBILITY_PRIM_DELETED 0x00000004 #define SCTP_SMALLEST_PMTU 512 /* smallest pmtu allowed when disabling PMTU Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctp_usrreq.c Fri May 4 15:49:08 2012 (r235009) @@ -2983,6 +2983,12 @@ flags_out: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTSUP); error = ENOTSUP; break; + case SCTP_ASSOC_RESET_EVENT: + event_type = SCTP_PCB_FLAGS_ASSOC_RESETEVNT; + break; + case SCTP_STREAM_CHANGE_EVENT: + event_type = SCTP_PCB_FLAGS_STREAM_CHANGEEVNT; + break; default: event_type = 0; SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -5379,6 +5385,12 @@ sctp_setopt(struct socket *so, int optna SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTSUP); error = ENOTSUP; break; + case SCTP_ASSOC_RESET_EVENT: + event_type = SCTP_PCB_FLAGS_ASSOC_RESETEVNT; + break; + case SCTP_STREAM_CHANGE_EVENT: + event_type = SCTP_PCB_FLAGS_STREAM_CHANGEEVNT; + break; default: event_type = 0; SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctputil.c Fri May 4 15:49:08 2012 (r235009) @@ -3214,7 +3214,7 @@ sctp_notify_stream_reset_add(struct sctp struct sctp_stream_change_event *stradd; int len; - if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_CHANGEEVNT)) { /* event not enabled */ return; } @@ -3275,7 +3275,7 @@ sctp_notify_stream_reset_tsn(struct sctp struct sctp_assoc_reset_event *strasoc; int len; - if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ASSOC_RESETEVNT)) { /* event not enabled */ return; } From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:51:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CF35106566C; Fri, 4 May 2012 15:51:24 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EBCDD8FC08; Fri, 4 May 2012 15:51:23 +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 q44FpN8g011085; Fri, 4 May 2012 15:51:23 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FpNDa011083; Fri, 4 May 2012 15:51:23 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201205041551.q44FpNDa011083@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 4 May 2012 15:51:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235010 - in stable/9/sys: i386/conf kern ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:51:24 -0000 Author: jh Date: Fri May 4 15:51:23 2012 New Revision: 235010 URL: http://svn.freebsd.org/changeset/base/235010 Log: MFC r233875: Add a check for unsupported file flags to ufs_setattr(). Modified: stable/9/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/i386/conf/XENHVM (props changed) stable/9/sys/kern/subr_witness.c (props changed) Modified: stable/9/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/9/sys/ufs/ufs/ufs_vnops.c Fri May 4 15:49:08 2012 (r235009) +++ stable/9/sys/ufs/ufs/ufs_vnops.c Fri May 4 15:51:23 2012 (r235010) @@ -528,6 +528,10 @@ ufs_setattr(ap) return (EINVAL); } if (vap->va_flags != VNOVAL) { + if ((vap->va_flags & ~(UF_NODUMP | UF_IMMUTABLE | UF_APPEND | + UF_OPAQUE | UF_NOUNLINK | SF_ARCHIVED | SF_IMMUTABLE | + SF_APPEND | SF_NOUNLINK | SF_SNAPSHOT)) != 0) + return (EOPNOTSUPP); if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); /* From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:55:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 260091065674; Fri, 4 May 2012 15:55:32 +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 065728FC0C; Fri, 4 May 2012 15:55:32 +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 q44FtVja011256; Fri, 4 May 2012 15:55:31 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FtVfA011249; Fri, 4 May 2012 15:55:31 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041555.q44FtVfA011249@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:55:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235011 - in stable/8/sys/dev/usb: . controller X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:55:32 -0000 Author: hselasky Date: Fri May 4 15:55:31 2012 New Revision: 235011 URL: http://svn.freebsd.org/changeset/base/235011 Log: MFC r234803 and r234961: Add support for Multi-TT mode of modern USB HUBs. This will give you more bandwidth for isochronous FULL speed applications connected through a High Speed HUB. This patch has been tested with XHCI and EHCI. Modified: stable/8/sys/dev/usb/controller/ehci.c stable/8/sys/dev/usb/controller/xhci.c stable/8/sys/dev/usb/usb_controller.h stable/8/sys/dev/usb/usb_hub.c stable/8/sys/dev/usb/usb_hub.h stable/8/sys/dev/usb/usb_transfer.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/usb/controller/ehci.c ============================================================================== --- stable/8/sys/dev/usb/controller/ehci.c Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/controller/ehci.c Fri May 4 15:55:31 2012 (r235011) @@ -2398,9 +2398,9 @@ ehci_device_isoc_fs_open(struct usb_xfer EHCI_SITD_SET_HUBA(xfer->xroot->udev->hs_hub_addr) | EHCI_SITD_SET_PORT(xfer->xroot->udev->hs_port_no); - if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) { + if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) sitd_portaddr |= EHCI_SITD_SET_DIR_IN; - } + sitd_portaddr = htohc32(sc, sitd_portaddr); /* initialize all TD's */ @@ -2436,9 +2436,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe { struct usb_page_search buf_res; ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); - struct usb_fs_isoc_schedule *fss_start; - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss; ehci_sitd_t *td; ehci_sitd_t *td_last = NULL; ehci_sitd_t **pp_last; @@ -2450,7 +2447,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe uint16_t tlen; uint8_t sa; uint8_t sb; - uint8_t error; #ifdef USB_DEBUG uint8_t once = 1; @@ -2495,9 +2491,8 @@ ehci_device_isoc_fs_enter(struct usb_xfe * pre-compute when the isochronous transfer will be finished: */ xfer->isoc_time_complete = - usbd_fs_isoc_schedule_isoc_time_expand - (xfer->xroot->udev, &fss_start, &fss_end, nframes) + buf_offset + - xfer->nframes; + usb_isoc_time_expand(&sc->sc_bus, nframes) + + buf_offset + xfer->nframes; /* get the real number of frames */ @@ -2520,19 +2515,14 @@ ehci_device_isoc_fs_enter(struct usb_xfe xfer->qh_pos = xfer->endpoint->isoc_next; - fss = fss_start + (xfer->qh_pos % USB_ISOC_TIME_MAX); - while (nframes--) { if (td == NULL) { panic("%s:%d: out of TD's\n", __FUNCTION__, __LINE__); } - if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) { + if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) pp_last = &sc->sc_isoc_fs_p_last[0]; - } - if (fss >= fss_end) { - fss = fss_start; - } + /* reuse sitd_portaddr and sitd_back from last transfer */ if (*plen > xfer->max_frame_size) { @@ -2547,17 +2537,19 @@ ehci_device_isoc_fs_enter(struct usb_xfe #endif *plen = xfer->max_frame_size; } - /* - * We currently don't care if the ISOCHRONOUS schedule is - * full! - */ - error = usbd_fs_isoc_schedule_alloc(fss, &sa, *plen); - if (error) { + + /* allocate a slot */ + + sa = usbd_fs_isoc_schedule_alloc_slot(xfer, + xfer->isoc_time_complete - nframes - 1); + + if (sa == 255) { /* - * The FULL speed schedule is FULL! Set length - * to zero. + * Schedule is FULL, set length to zero: */ + *plen = 0; + sa = USB_FS_ISOC_UFRAME_MAX - 1; } if (*plen) { /* @@ -2637,7 +2629,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe pp_last++; plen++; - fss++; td_last = td; td = td->obj_next; } @@ -2647,11 +2638,29 @@ ehci_device_isoc_fs_enter(struct usb_xfe /* update isoc_next */ xfer->endpoint->isoc_next = (pp_last - &sc->sc_isoc_fs_p_last[0]) & (EHCI_VIRTUAL_FRAMELIST_COUNT - 1); + + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; } static void ehci_device_isoc_fs_start(struct usb_xfer *xfer) { + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; + + /* set a default timeout */ + if (xfer->timeout == 0) + xfer->timeout = 500; /* ms */ + /* put transfer on interrupt queue */ ehci_transfer_intr_enqueue(xfer); } Modified: stable/8/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/8/sys/dev/usb/controller/xhci.c Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/controller/xhci.c Fri May 4 15:55:31 2012 (r235011) @@ -115,6 +115,7 @@ struct xhci_std_temp { uint8_t tbc; uint8_t tlbpc; uint8_t step_td; + uint8_t do_isoc_sync; }; static void xhci_do_poll(struct usb_bus *); @@ -1657,11 +1658,15 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(temp->trb_type) | - XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) | + XHCI_TRB_3_TYPE_SET(temp->trb_type) | + (temp->do_isoc_sync ? + XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) : + XHCI_TRB_3_ISO_SIA_BIT) | XHCI_TRB_3_TBC_SET(temp->tbc) | XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + temp->do_isoc_sync = 0; + if (temp->direction == UE_DIR_IN) { dword |= XHCI_TRB_3_DIR_IN; @@ -1764,6 +1769,7 @@ xhci_setup_generic_chain(struct usb_xfer uint32_t y; uint8_t mult; + temp.do_isoc_sync = 0; temp.step_td = 0; temp.tbc = 0; temp.tlbpc = 0; @@ -1841,6 +1847,8 @@ xhci_setup_generic_chain(struct usb_xfer */ xfer->endpoint->isoc_next = XHCI_MFINDEX_GET(x + (3 * 8)); xfer->endpoint->is_synced = 1; + temp.do_isoc_sync = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); } @@ -1931,7 +1939,10 @@ xhci_setup_generic_chain(struct usb_xfer uint8_t tdpc; - /* isochronous transfers don't have short packet termination */ + /* + * Isochronous transfers don't have short + * packet termination: + */ temp.shortpkt = 1; @@ -2271,12 +2282,29 @@ xhci_configure_device(struct usb_device switch (udev->speed) { case USB_SPEED_LOW: temp |= XHCI_SCTX_0_SPEED_SET(2); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_HIGH: temp |= XHCI_SCTX_0_SPEED_SET(3); + if (sc->sc_hw.devs[index].nports != 0 && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { + DPRINTF("HUB supports MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_FULL: temp |= XHCI_SCTX_0_SPEED_SET(1); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; default: temp |= XHCI_SCTX_0_SPEED_SET(4); @@ -2287,15 +2315,8 @@ xhci_configure_device(struct usb_device (udev->speed == USB_SPEED_SUPER || udev->speed == USB_SPEED_HIGH); - if (is_hub) { + if (is_hub) temp |= XHCI_SCTX_0_HUB_SET(1); -#if 0 - if (udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { - DPRINTF("HUB supports MTT\n"); - temp |= XHCI_SCTX_0_MTT_SET(1); - } -#endif - } xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); @@ -2327,8 +2348,10 @@ xhci_configure_device(struct usb_device temp = XHCI_SCTX_2_IRQ_TARGET_SET(0); - if (is_hub) - temp |= XHCI_SCTX_2_TT_THINK_TIME_SET(sc->sc_hw.devs[index].tt); + if (is_hub) { + temp |= XHCI_SCTX_2_TT_THINK_TIME_SET( + sc->sc_hw.devs[index].tt); + } hubdev = udev->parent_hs_hub; Modified: stable/8/sys/dev/usb/usb_controller.h ============================================================================== --- stable/8/sys/dev/usb/usb_controller.h Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/usb_controller.h Fri May 4 15:55:31 2012 (r235011) @@ -231,7 +231,8 @@ void usb_bus_mem_flush_all(struct usb_bu uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb); void usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb); uint16_t usb_isoc_time_expand(struct usb_bus *bus, uint16_t isoc_time_curr); -uint16_t usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, struct usb_fs_isoc_schedule **pp_start, struct usb_fs_isoc_schedule **pp_end, uint16_t isoc_time); -uint8_t usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len); +#if USB_HAVE_TT_SUPPORT +uint8_t usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time); +#endif #endif /* _USB_CONTROLLER_H_ */ Modified: stable/8/sys/dev/usb/usb_hub.c ============================================================================== --- stable/8/sys/dev/usb/usb_hub.c Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/usb_hub.c Fri May 4 15:55:31 2012 (r235011) @@ -109,6 +109,7 @@ struct uhub_softc { #define UHUB_PROTO(sc) ((sc)->sc_udev->ddesc.bDeviceProtocol) #define UHUB_IS_HIGH_SPEED(sc) (UHUB_PROTO(sc) != UDPROTO_FSHUB) #define UHUB_IS_SINGLE_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBSTT) +#define UHUB_IS_MULTI_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBMTT) #define UHUB_IS_SUPER_SPEED(sc) (UHUB_PROTO(sc) == UDPROTO_SSHUB) /* prototypes for type checking: */ @@ -948,6 +949,16 @@ uhub_attach(device_t dev) "bus powered HUB. HUB ignored\n"); goto error; } + + if (UHUB_IS_MULTI_TT(sc)) { + err = usbd_set_alt_interface_index(udev, 0, 1); + if (err) { + device_printf(dev, "MTT could not be enabled\n"); + goto error; + } + device_printf(dev, "MTT enabled\n"); + } + /* get HUB descriptor */ DPRINTFN(2, "Getting HUB descriptor\n"); @@ -1057,10 +1068,6 @@ uhub_attach(device_t dev) } udev->hub = hub; -#if USB_HAVE_TT_SUPPORT - /* init FULL-speed ISOCHRONOUS schedule */ - usbd_fs_isoc_schedule_init_all(hub->fs_isoc_schedule); -#endif /* initialize HUB structure */ hub->hubsoftc = sc; hub->explore = &uhub_explore; @@ -1656,42 +1663,6 @@ usb_hs_bandwidth_free(struct usb_xfer *x } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_sub - * - * This function initialises an USB FULL speed isochronous schedule - * entry. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -static void -usbd_fs_isoc_schedule_init_sub(struct usb_fs_isoc_schedule *fss) -{ - fss->total_bytes = (USB_FS_ISOC_UFRAME_MAX * - USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_bytes = (USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_slot = 0; -} -#endif - -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_all - * - * This function will reset the complete USB FULL speed isochronous - * bandwidth schedule. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -void -usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss) -{ - struct usb_fs_isoc_schedule *fss_end = fss + USB_ISOC_TIME_MAX; - - while (fss != fss_end) { - usbd_fs_isoc_schedule_init_sub(fss); - fss++; - } -} -#endif - -/*------------------------------------------------------------------------* * usb_isoc_time_expand * * This function will expand the time counter from 7-bit to 16-bit. @@ -1723,114 +1694,130 @@ usb_isoc_time_expand(struct usb_bus *bus } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_isoc_time_expand + * usbd_fs_isoc_schedule_alloc_slot * - * This function does multiple things. First of all it will expand the - * passed isochronous time, which is the return value. Then it will - * store where the current FULL speed isochronous schedule is - * positioned in time and where the end is. See "pp_start" and - * "pp_end" arguments. + * This function will allocate bandwidth for an isochronous FULL speed + * transaction in the FULL speed schedule. * * Returns: - * Expanded version of "isoc_time". - * - * NOTE: This function depends on being called regularly with - * intervals less than "USB_ISOC_TIME_MAX". + * <8: Success + * Else: Error *------------------------------------------------------------------------*/ #if USB_HAVE_TT_SUPPORT -uint16_t -usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, - struct usb_fs_isoc_schedule **pp_start, - struct usb_fs_isoc_schedule **pp_end, - uint16_t isoc_time) +uint8_t +usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time) { - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss_a; - struct usb_fs_isoc_schedule *fss_b; - struct usb_hub *hs_hub; + struct usb_xfer *xfer; + struct usb_xfer *pipe_xfer; + struct usb_bus *bus; + usb_frlength_t len; + usb_frlength_t data_len; + uint16_t delta; + uint16_t slot; + uint8_t retval; - isoc_time = usb_isoc_time_expand(udev->bus, isoc_time); + data_len = 0; + slot = 0; - hs_hub = udev->parent_hs_hub->hub; + bus = isoc_xfer->xroot->bus; - if (hs_hub != NULL) { + TAILQ_FOREACH(xfer, &bus->intr_q.head, wait_entry) { - fss_a = hs_hub->fs_isoc_schedule + - (hs_hub->isoc_last_time % USB_ISOC_TIME_MAX); + /* skip self, if any */ - hs_hub->isoc_last_time = isoc_time; + if (xfer == isoc_xfer) + continue; - fss_b = hs_hub->fs_isoc_schedule + - (isoc_time % USB_ISOC_TIME_MAX); + /* check if this USB transfer is going through the same TT */ - fss_end = hs_hub->fs_isoc_schedule + USB_ISOC_TIME_MAX; + if (xfer->xroot->udev->parent_hs_hub != + isoc_xfer->xroot->udev->parent_hs_hub) { + continue; + } + if ((isoc_xfer->xroot->udev->parent_hs_hub-> + ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) && + (xfer->xroot->udev->hs_port_no != + isoc_xfer->xroot->udev->hs_port_no)) { + continue; + } + if (xfer->endpoint->methods != isoc_xfer->endpoint->methods) + continue; + + /* check if isoc_time is part of this transfer */ + + delta = xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= xfer->nframes) { + delta = xfer->nframes - delta; + + len = xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; + } + + /* check double buffered transfers */ - *pp_start = hs_hub->fs_isoc_schedule; - *pp_end = fss_end; + TAILQ_FOREACH(pipe_xfer, &xfer->endpoint->endpoint_q.head, + wait_entry) { - while (fss_a != fss_b) { - if (fss_a == fss_end) { - fss_a = hs_hub->fs_isoc_schedule; + /* skip self, if any */ + + if (pipe_xfer == isoc_xfer) continue; + + /* check if isoc_time is part of this transfer */ + + delta = pipe_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= pipe_xfer->nframes) { + delta = pipe_xfer->nframes - delta; + + len = pipe_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - usbd_fs_isoc_schedule_init_sub(fss_a); - fss_a++; } + } - } else { - - *pp_start = NULL; - *pp_end = NULL; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; } - return (isoc_time); -} -#endif -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_alloc - * - * This function will allocate bandwidth for an isochronous FULL speed - * transaction in the FULL speed schedule. The microframe slot where - * the transaction should be started is stored in the byte pointed to - * by "pstart". The "len" argument specifies the length of the - * transaction in bytes. - * - * Returns: - * 0: Success - * Else: Error - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -uint8_t -usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, - uint8_t *pstart, uint16_t len) -{ - uint8_t slot = fss->frame_slot; + /* check for overflow */ - /* Compute overhead and bit-stuffing */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); - len += 8; + retval = slot; - len *= 7; - len /= 6; + delta = isoc_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= isoc_xfer->nframes) { + delta = isoc_xfer->nframes - delta; - if (len > fss->total_bytes) { - *pstart = 0; /* set some dummy value */ - return (1); /* error */ + len = isoc_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - if (len > 0) { - fss->total_bytes -= len; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; + } - while (len >= fss->frame_bytes) { - len -= fss->frame_bytes; - fss->frame_bytes = USB_FS_BYTES_PER_HS_UFRAME; - fss->frame_slot++; - } + /* check for overflow */ - fss->frame_bytes -= len; - } - *pstart = slot; - return (0); /* success */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); + + return (retval); } #endif Modified: stable/8/sys/dev/usb/usb_hub.h ============================================================================== --- stable/8/sys/dev/usb/usb_hub.h Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/usb_hub.h Fri May 4 15:55:31 2012 (r235011) @@ -38,22 +38,9 @@ struct usb_port { }; /* - * The following structure defines how many bytes are - * left in an 1ms USB time slot. - */ -struct usb_fs_isoc_schedule { - uint16_t total_bytes; - uint8_t frame_bytes; - uint8_t frame_slot; -}; - -/* * The following structure defines an USB HUB. */ struct usb_hub { -#if USB_HAVE_TT_SUPPORT - struct usb_fs_isoc_schedule fs_isoc_schedule[USB_ISOC_TIME_MAX]; -#endif struct usb_device *hubudev; /* the HUB device */ usb_error_t (*explore) (struct usb_device *hub); void *hubsoftc; @@ -68,7 +55,6 @@ struct usb_hub { void usb_hs_bandwidth_alloc(struct usb_xfer *xfer); void usb_hs_bandwidth_free(struct usb_xfer *xfer); -void usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss); void usb_bus_port_set_device(struct usb_bus *bus, struct usb_port *up, struct usb_device *udev, uint8_t device_index); struct usb_device *usb_bus_port_get_device(struct usb_bus *bus, Modified: stable/8/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/8/sys/dev/usb/usb_transfer.c Fri May 4 15:51:23 2012 (r235010) +++ stable/8/sys/dev/usb/usb_transfer.c Fri May 4 15:55:31 2012 (r235011) @@ -1680,11 +1680,12 @@ usbd_pipe_enter(struct usb_xfer *xfer) DPRINTF("enter\n"); + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* enter the transfer */ (ep->methods->enter) (xfer); - xfer->flags_int.can_cancel_immed = 1; - /* check for transfer error */ if (xfer->error) { /* some error has happened */ @@ -2417,13 +2418,15 @@ usbd_transfer_start_cb(void *arg) #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); @@ -2598,13 +2601,14 @@ usbd_pipe_start(struct usb_xfer_queue *p #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); From owner-svn-src-all@FreeBSD.ORG Fri May 4 15:57:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D401106566C; Fri, 4 May 2012 15:57:06 +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 078398FC15; Fri, 4 May 2012 15:57:06 +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 q44Fv5nA011356; Fri, 4 May 2012 15:57:05 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Fv5nT011353; Fri, 4 May 2012 15:57:05 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041557.q44Fv5nT011353@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 15:57:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235012 - in stable/8/sys/dev/usb: . serial X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:57:06 -0000 Author: hselasky Date: Fri May 4 15:57:05 2012 New Revision: 235012 URL: http://svn.freebsd.org/changeset/base/235012 Log: MFC r234541: Add new USB ID to u3g driver. Modified: stable/8/sys/dev/usb/serial/u3g.c stable/8/sys/dev/usb/usbdevs Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/8/sys/dev/usb/serial/u3g.c Fri May 4 15:55:31 2012 (r235011) +++ stable/8/sys/dev/usb/serial/u3g.c Fri May 4 15:57:05 2012 (r235012) @@ -354,6 +354,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(QISDA, H21_2, 0), U3G_DEV(QUALCOMM2, AC8700, 0), U3G_DEV(QUALCOMM2, MF330, 0), + U3G_DEV(QUALCOMM2, SIM5218, 0), U3G_DEV(QUALCOMM2, VW110L, U3GINIT_SCSIEJECT), U3G_DEV(QUALCOMMINC, AC2726, 0), U3G_DEV(QUALCOMMINC, AC8700, 0), Modified: stable/8/sys/dev/usb/usbdevs ============================================================================== --- stable/8/sys/dev/usb/usbdevs Fri May 4 15:55:31 2012 (r235011) +++ stable/8/sys/dev/usb/usbdevs Fri May 4 15:57:05 2012 (r235012) @@ -2668,6 +2668,7 @@ product QUALCOMM2 RWT_FCT 0x3100 RWT FCT product QUALCOMM2 CDMA_MSM 0x3196 CDMA Technologies MSM modem product QUALCOMM2 AC8700 0x6000 AC8700 product QUALCOMM2 VW110L 0x1000 Vertex Wireless 110L modem +product QUALCOMM2 SIM5218 0x9000 SIM5218 product QUALCOMMINC CDMA_MSM 0x0001 CDMA Technologies MSM modem product QUALCOMMINC E0002 0x0002 3G modem product QUALCOMMINC E0003 0x0003 3G modem From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:00:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C5458106564A; Fri, 4 May 2012 16:00:24 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 962008FC08; Fri, 4 May 2012 16:00: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 q44G0OR3011533; Fri, 4 May 2012 16:00:24 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44G0O1S011532; Fri, 4 May 2012 16:00:24 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201205041600.q44G0O1S011532@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 4 May 2012 16:00: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: r235013 - in head/sys/powerpc: aim include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:00:25 -0000 Author: nwhitehorn Date: Fri May 4 16:00:22 2012 New Revision: 235013 URL: http://svn.freebsd.org/changeset/base/235013 Log: Fix final bugs in memory barriers on PowerPC: - Use isync/lwsync unconditionally for acquire/release. Use of isync guarantees a complete memory barrier, which is important for serialization of bus space accesses with mutexes on multi-processor systems. - Go back to using sync as the I/O memory barrier, which solves the same problem as above with respect to mutex release using lwsync, while not penalizing non-I/O operations like a return to sync on the atomic release operations would. - Place an acquisition barrier around thread lock acquisition in cpu_switchin(). Modified: head/sys/powerpc/aim/swtch32.S head/sys/powerpc/aim/swtch64.S head/sys/powerpc/include/atomic.h head/sys/powerpc/include/pio.h Modified: head/sys/powerpc/aim/swtch32.S ============================================================================== --- head/sys/powerpc/aim/swtch32.S Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/aim/swtch32.S Fri May 4 16:00:22 2012 (r235013) @@ -124,7 +124,8 @@ cpu_switchin: blocked_loop: lwz %r7,TD_LOCK(%r2) cmpw %r6,%r7 - beq blocked_loop + beq- blocked_loop + isync #endif mfsprg %r7,0 /* Get the pcpu pointer */ Modified: head/sys/powerpc/aim/swtch64.S ============================================================================== --- head/sys/powerpc/aim/swtch64.S Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/aim/swtch64.S Fri May 4 16:00:22 2012 (r235013) @@ -150,7 +150,8 @@ cpu_switchin: blocked_loop: ld %r7,TD_LOCK(%r13) cmpd %r6,%r7 - beq blocked_loop + beq- blocked_loop + isync #endif mfsprg %r7,0 /* Get the pcpu pointer */ Modified: head/sys/powerpc/include/atomic.h ============================================================================== --- head/sys/powerpc/include/atomic.h Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/include/atomic.h Fri May 4 16:00:22 2012 (r235013) @@ -51,13 +51,8 @@ * with the atomic lXarx/stXcx. sequences below. See Appendix B.2 of Book II * of the architecture manual. */ -#ifdef __powerpc64__ -#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") -#define __ATOMIC_ACQ() __asm __volatile("lwsync" : : : "memory") -#else #define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") #define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") -#endif /* * atomic_add(p, v) Modified: head/sys/powerpc/include/pio.h ============================================================================== --- head/sys/powerpc/include/pio.h Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/include/pio.h Fri May 4 16:00:22 2012 (r235013) @@ -39,7 +39,12 @@ * I/O macros. */ -#define powerpc_iomb() __asm __volatile("eieio" : : : "memory") +/* + * Use sync so that bus space operations cannot sneak out the bottom of + * mutex-protected sections (mutex release does not guarantee completion of + * accesses to caching-inhibited memory on some systems) + */ +#define powerpc_iomb() __asm __volatile("sync" : : : "memory") static __inline void __outb(volatile u_int8_t *a, u_int8_t v) From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:00:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0EAD2106566B; Fri, 4 May 2012 16:00:40 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECFBA8FC14; Fri, 4 May 2012 16:00:39 +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 q44G0duk011590; Fri, 4 May 2012 16:00:39 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44G0dk9011584; Fri, 4 May 2012 16:00:39 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205041600.q44G0dk9011584@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 16:00:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235014 - head/sys/dev/mfi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:00:40 -0000 Author: ambrisko Date: Fri May 4 16:00:39 2012 New Revision: 235014 URL: http://svn.freebsd.org/changeset/base/235014 Log: First fix pr 167226: ThunderBolt cannot read sector >= 2^32 or 2^21 with supplied patch. Second the bigger change, fix RAID operation on ThunderBolt base card such as physically removing a disk from a RAID and replacing it. The current situation is the RAID firmware effectively hangs waiting for an acknowledgement from the driver. This is due to the firmware support of the driver actually accessing the RAID from under the firmware. This is an interesting feature that the FreeBSD driver does not use. However, when the firmare detects the driver has attached it then expects the driver will synchronize LD's with the firmware. If the driver does not sync. then the management part of the firmware will hang waiting for it so a pulled driver will listed as still there. The fix for this problem isn't extremely difficult. However, figuring out why some of the code was the way it was and then redoing it was involved. Not have a spec. made it harder to try to figure out. The existing driver would send a MFI_DCMD_LD_MAP_GET_INFO command in write mode to acknowledge a LD state change. In read mode it gets the RAID map from the firmware. The FreeBSD driver doesn't do that currently. It could be added in the future with the appropriate structures. To simplify things, get the current LD state and then build the MFI_DCMD_LD_MAP_GET_INFO/write command so that it sends an acknowledgement for each LD. The map would probably state which LD's changed so then the driver could probably just acknowledge the LD's that changed versus all. This doesn't seem to be a problem. When a MFI_DCMD_LD_MAP_GET_INFO/write command is sent to the firmware, it will complete later when a change to the LD's happen. So it is very much like an AEN command returning when something happened. When the MFI_DCMD_LD_MAP_GET_INFO/write command completes, we refire the sync'ing of the LD state. This needs to be done in as an event so that MFI_DCMD_LD_GET_LIST can wait for that command to complete before issuing the MFI_DCMD_LD_MAP_GET_INFO/write. The prior code didn't use the call-back function and tried to intercept the MFI_DCMD_LD_MAP_GET_INFO/write command when processing an interrupt. This added a bunch of code complexity to the interrupt handler. Using the call-back that is done for other commands got rid of this need. So the interrupt handler is greatly simplified. It seems that even commands that shouldn't be acknowledged end up in the interrupt handler. To deal with this, code was added to check to see if a command is in the busy queue or not. This might have contributed to the interrupt storm happening without MSI enabled on these cards. Note that MFI_DCMD_LD_MAP_GET_INFO/read returns right away. It would be interesting to see what other complexity could be removed from the ThunderBolt driver that really isn't needed in our mode of operation. Letting the RAID firmware do all of the I/O to disks is a lot faster since it can use its caches. It greatly simplifies what the driver has to do and potential bugs if the driver and firmware are not in sync. Simplify the aen_abort/cm_map_abort and put it in the softc versus in the command structure. This should get merged to 9 before the driver is merged to 8. PR: 167226 Submitted by: Petr Lampa MFC after: 3 days Modified: head/sys/dev/mfi/mfi.c head/sys/dev/mfi/mfi_debug.c head/sys/dev/mfi/mfi_tbolt.c head/sys/dev/mfi/mfireg.h head/sys/dev/mfi/mfivar.h Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi.c Fri May 4 16:00:39 2012 (r235014) @@ -90,8 +90,6 @@ static int mfi_get_controller_info(struc static int mfi_get_log_state(struct mfi_softc *, struct mfi_evt_log_state **); static int mfi_parse_entries(struct mfi_softc *, int, int); -static int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **, - uint32_t, void **, size_t); static void mfi_data_cb(void *, bus_dma_segment_t *, int, int); static void mfi_startup(void *arg); static void mfi_intr(void *arg); @@ -377,6 +375,7 @@ mfi_attach(struct mfi_softc *sc) TAILQ_INIT(&sc->mfi_syspd_tqh); TAILQ_INIT(&sc->mfi_evt_queue); TASK_INIT(&sc->mfi_evt_task, 0, mfi_handle_evt, sc); + TASK_INIT(&sc->mfi_map_sync_task, 0, mfi_handle_map_sync, sc); TAILQ_INIT(&sc->mfi_aen_pids); TAILQ_INIT(&sc->mfi_cam_ccbq); @@ -696,7 +695,6 @@ mfi_attach(struct mfi_softc *sc) return (EINVAL); } sc->mfi_enable_intr(sc); - sc->map_id = 0; } else { if ((error = mfi_comms_init(sc)) != 0) return (error); @@ -762,6 +760,10 @@ mfi_attach(struct mfi_softc *sc) callout_reset(&sc->mfi_watchdog_callout, MFI_CMD_TIMEOUT * hz, mfi_timeout, sc); + if (sc->mfi_flags & MFI_FLAGS_TBOLT) { + mfi_tbolt_sync_map_info(sc); + } + return (0); } @@ -845,7 +847,7 @@ mfi_release_command(struct mfi_command * mfi_enqueue_free(cm); } -static int +int mfi_dcmd_command(struct mfi_softc *sc, struct mfi_command **cmp, uint32_t opcode, void **bufp, size_t bufsize) { @@ -1286,8 +1288,8 @@ mfi_shutdown(struct mfi_softc *sc) if (sc->mfi_aen_cm != NULL) mfi_abort(sc, sc->mfi_aen_cm); - if (sc->map_update_cmd != NULL) - mfi_abort(sc, sc->map_update_cmd); + if (sc->mfi_map_sync_cm != NULL) + mfi_abort(sc, sc->mfi_map_sync_cm); dcmd = &cm->cm_frame->dcmd; dcmd->header.flags = MFI_FRAME_DIR_NONE; @@ -1664,9 +1666,9 @@ mfi_aen_complete(struct mfi_command *cm) if (sc->mfi_aen_cm == NULL) return; - if (sc->mfi_aen_cm->cm_aen_abort || + if (sc->cm_aen_abort || hdr->cmd_status == MFI_STAT_INVALID_STATUS) { - sc->mfi_aen_cm->cm_aen_abort = 0; + sc->cm_aen_abort = 0; aborted = 1; } else { sc->mfi_aen_triggered = 1; @@ -2385,7 +2387,9 @@ mfi_abort(struct mfi_softc *sc, struct m cm->cm_flags = MFI_CMD_POLLED; if (sc->mfi_aen_cm) - sc->mfi_aen_cm->cm_aen_abort = 1; + sc->cm_aen_abort = 1; + if (sc->mfi_map_sync_cm) + sc->cm_map_abort = 1; mfi_mapcmd(sc, cm); mfi_release_command(cm); @@ -2394,6 +2398,11 @@ mfi_abort(struct mfi_softc *sc, struct m 5 * hz); i++; } + while (i < 5 && sc->mfi_map_sync_cm != NULL) { + msleep(&sc->mfi_map_sync_cm, &sc->mfi_io_lock, 0, "mfiabort", + 5 * hz); + i++; + } return (0); } @@ -3549,9 +3558,9 @@ mfi_timeout(void *data) } mtx_lock(&sc->mfi_io_lock); TAILQ_FOREACH(cm, &sc->mfi_busy, cm_link) { - if (sc->mfi_aen_cm == cm) + if (sc->mfi_aen_cm == cm || sc->mfi_map_sync_cm == cm) continue; - if ((sc->mfi_aen_cm != cm) && (cm->cm_timestamp < deadline)) { + if (cm->cm_timestamp < deadline) { if (sc->adpreset != 0 && sc->issuepend_done == 0) { cm->cm_timestamp = time_uptime; } else { Modified: head/sys/dev/mfi/mfi_debug.c ============================================================================== --- head/sys/dev/mfi/mfi_debug.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi_debug.c Fri May 4 16:00:39 2012 (r235014) @@ -172,6 +172,9 @@ mfi_print_dcmd(struct mfi_softc *sc, dev case MFI_DCMD_CLUSTER_RESET_LD: opcode = "CLUSTER_RESET_LD"; break; + case MFI_DCMD_LD_MAP_GET_INFO: + opcode = "LD_MAP_GET_INFO"; + break; default: opcode = "UNKNOWN"; break; Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:00:39 2012 (r235014) @@ -82,7 +82,8 @@ map_tbolt_cmd_status(struct mfi_command static void mfi_issue_pending_cmds_again (struct mfi_softc *sc); static void mfi_kill_hba (struct mfi_softc *sc); static void mfi_process_fw_state_chg_isr(void *arg); -uint8_t mfi_tbolt_get_map_info(struct mfi_softc *sc); +static void mfi_sync_map_complete(struct mfi_command *); +static void mfi_queue_map_sync(struct mfi_softc *sc); #define MFI_FUSION_ENABLE_INTERRUPT_MASK (0x00000008) @@ -627,10 +628,11 @@ mfi_tbolt_return_cmd(struct mfi_softc *s TAILQ_INSERT_TAIL(&sc->mfi_cmd_tbolt_tqh, cmd, next); } -void mfi_tbolt_complete_cmd(struct mfi_softc *sc) +void +mfi_tbolt_complete_cmd(struct mfi_softc *sc) { struct mfi_mpi2_reply_header *desc, *reply_desc; - struct mfi_command *cmd_mfi; /* For MFA Cmds */ + struct mfi_command *cmd_mfi, *cmd_mfi_check; /* For MFA Cmds */ struct mfi_cmd_tbolt *cmd_tbolt; uint16_t smid; uint8_t reply_descript_type; @@ -657,7 +659,6 @@ void mfi_tbolt_complete_cmd(struct mfi_s /* Read Reply descriptor */ while ((val.u.low != 0xFFFFFFFF) && (val.u.high != 0xFFFFFFFF)) { - smid = reply_desc->SMID; if (!smid || smid > sc->mfi_max_fw_cmds + 1) { device_printf(sc->mfi_dev, "smid is %x. Cannot " @@ -669,66 +670,20 @@ void mfi_tbolt_complete_cmd(struct mfi_s cmd_mfi = &sc->mfi_commands[cmd_tbolt->sync_cmd_idx]; scsi_io_req = cmd_tbolt->io_request; - /* Check if internal commands */ status = cmd_mfi->cm_frame->dcmd.header.cmd_status; extStatus = cmd_mfi->cm_frame->dcmd.header.scsi_status; + map_tbolt_cmd_status(cmd_mfi, status, extStatus); - switch (scsi_io_req->Function) { - case MPI2_FUNCTION_LD_IO_REQUEST: - /* Regular Path IO. */ - /* Map the Fw Error Status. */ - map_tbolt_cmd_status(cmd_mfi, status, - extStatus); - if ((cmd_mfi->cm_frame->dcmd.opcode - == MFI_DCMD_LD_MAP_GET_INFO) - && (cmd_mfi->cm_frame->dcmd.mbox[1] == 1)) { - if (cmd_mfi->cm_frame->header.cmd_status - != 0) - device_printf(sc->mfi_dev, - "map sync failed\n"); - else { - sc->map_id++; - device_printf(sc->mfi_dev, - "map sync completed\n"); - mfi_release_command(cmd_mfi); - } - } - if ((cmd_mfi->cm_flags & MFI_ON_MFIQ_BUSY) - == MFI_ON_MFIQ_BUSY - && (cmd_mfi->cm_flags & MFI_CMD_POLLED) == 0) { - /* BHARAT poll workaround */ - mfi_remove_busy(cmd_mfi); - cmd_mfi->cm_error = 0; - mfi_complete(sc, cmd_mfi); - } - mfi_tbolt_return_cmd(sc, cmd_tbolt); - break; - case MPI2_FUNCTION_PASSTHRU_IO_REQUEST: - map_tbolt_cmd_status(cmd_mfi, status, extStatus); - if ((cmd_mfi->cm_frame->dcmd.opcode - == MFI_DCMD_LD_MAP_GET_INFO) - && (cmd_mfi->cm_frame->dcmd.mbox[1] == 1)) { - if (cmd_mfi->cm_frame->header.cmd_status != 0) - device_printf(sc->mfi_dev, - "map sync failed\n"); - else { - sc->map_id++; - device_printf(sc->mfi_dev, - "map sync completed\n"); - mfi_release_command(cmd_mfi); - } - } - if ((cmd_mfi->cm_flags & MFI_ON_MFIQ_BUSY) - == MFI_ON_MFIQ_BUSY - && (cmd_mfi->cm_flags & MFI_CMD_POLLED) == 0) { - /* BHARAT poll workaround */ + /* remove command from busy queue if not polled */ + TAILQ_FOREACH(cmd_mfi_check, &sc->mfi_busy, cm_link) { + if (cmd_mfi_check == cmd_mfi) { mfi_remove_busy(cmd_mfi); - cmd_mfi->cm_error = 0; - mfi_complete(sc, cmd_mfi); + break; } - mfi_tbolt_return_cmd(sc, cmd_tbolt); - break; } + cmd_mfi->cm_error = 0; + mfi_complete(sc, cmd_mfi); + mfi_tbolt_return_cmd(sc, cmd_tbolt); sc->last_reply_idx++; if (sc->last_reply_idx >= sc->mfi_max_fw_cmds) { @@ -949,7 +904,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc lba_lo = mfi_cmd->cm_frame->io.lba_lo; lba_hi = mfi_cmd->cm_frame->io.lba_hi; - if ((num_lba <= 0xFF) && (lba_lo <= 0x1FFFFF)) { + if (lba_hi == 0 && (num_lba <= 0xFF) && (lba_lo <= 0x1FFFFF)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 6 or Write 6 */ cdb[0] = (uint8_t) (0x0A); @@ -962,7 +917,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc cdb[1] = (uint8_t) ((lba_lo >> 16) & 0x1F); cdb_len = 6; } - else if ((num_lba <= 0xFFFF) && (lba_lo <= 0xFFFFFFFF)) { + else if (lba_hi == 0 && (num_lba <= 0xFFFF) && (lba_lo <= 0xFFFFFFFF)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 10 or Write 10 */ cdb[0] = (uint8_t) (0x2A); @@ -1152,8 +1107,8 @@ mfi_tbolt_send_frame(struct mfi_softc *s cm->cm_timestamp = time_uptime; mfi_enqueue_busy(cm); } - else { - hdr->cmd_status = 0xff; + else { /* still get interrupts for it */ + hdr->cmd_status = MFI_STAT_INVALID_STATUS; hdr->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; } @@ -1189,16 +1144,16 @@ mfi_tbolt_send_frame(struct mfi_softc *s return 0; /* This is a polled command, so busy-wait for it to complete. */ - while (hdr->cmd_status == 0xff) { + while (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { DELAY(1000); tm -= 1; if (tm <= 0) - break; + break; } - - if (hdr->cmd_status == 0xff) { + + if (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { device_printf(sc->mfi_dev, "Frame %p timed out " - "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); + "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); return (ETIMEDOUT); } return 0; @@ -1308,9 +1263,9 @@ static void mfi_process_fw_state_chg_isr mfi_release_command(sc->mfi_aen_cm); sc->mfi_aen_cm = NULL; } - if (sc->map_update_cmd) { - mfi_release_command(sc->map_update_cmd); - sc->map_update_cmd = NULL; + if (sc->mfi_map_sync_cm) { + mfi_release_command(sc->mfi_map_sync_cm); + sc->mfi_map_sync_cm = NULL; } mfi_issue_pending_cmds_again(sc); @@ -1337,3 +1292,171 @@ static void mfi_process_fw_state_chg_isr } mtx_unlock(&sc->mfi_io_lock); } + + +/* + * The ThunderBolt HW has an option for the driver to directly + * access the underlying disks and operate on the RAID. To + * do this there needs to be a capability to keep the RAID controller + * and driver in sync. The FreeBSD driver does not take advantage + * of this feature since it adds a lot of complexity and slows down + * performance. Performance is gained by using the controller's + * cache etc. + * + * Even though this driver doesn't access the disks directly, an + * AEN like command is used to inform the RAID firmware to "sync" + * with all LD's via the MFI_DCMD_LD_MAP_GET_INFO command. This + * command in write mode will return when the RAID firmware has + * detected a change to the RAID state. Examples of this type + * of change are removing a disk. Once the command returns then + * the driver needs to acknowledge this and "sync" all LD's again. + * This repeats until we shutdown. Then we need to cancel this + * pending command. + * + * If this is not done right the RAID firmware will not remove a + * pulled drive and the RAID won't go degraded etc. Effectively, + * stopping any RAID mangement to functions. + * + * Doing another LD sync, requires the use of an event since the + * driver needs to do a mfi_wait_command and can't do that in an + * interrupt thread. + * + * The driver could get the RAID state via the MFI_DCMD_LD_MAP_GET_INFO + * That requires a bunch of structure and it is simplier to just do + * the MFI_DCMD_LD_GET_LIST versus walking the RAID map. + */ + +void +mfi_tbolt_sync_map_info(struct mfi_softc *sc) +{ + int error = 0, i; + struct mfi_command *cmd; + struct mfi_dcmd_frame *dcmd; + uint32_t context = 0; + union mfi_ld_ref *ld_sync; + size_t ld_size; + struct mfi_frame_header *hdr; + struct mfi_command *cm = NULL; + struct mfi_ld_list *list = NULL; + + if (sc->mfi_map_sync_cm != NULL || sc->cm_map_abort) + return; + + mtx_lock(&sc->mfi_io_lock); + error = mfi_dcmd_command(sc, &cm, MFI_DCMD_LD_GET_LIST, + (void **)&list, sizeof(*list)); + if (error) + goto out; + + cm->cm_flags = MFI_CMD_POLLED | MFI_CMD_DATAIN; + if (mfi_wait_command(sc, cm) != 0) { + device_printf(sc->mfi_dev, "Failed to get device listing\n"); + goto out; + } + + hdr = &cm->cm_frame->header; + if (hdr->cmd_status != MFI_STAT_OK) { + device_printf(sc->mfi_dev, "MFI_DCMD_LD_GET_LIST failed %x\n", + hdr->cmd_status); + goto out; + } + + ld_size = sizeof(*ld_sync) * list->ld_count; + mtx_unlock(&sc->mfi_io_lock); + ld_sync = (union mfi_ld_ref *) malloc(ld_size, M_MFIBUF, + M_WAITOK | M_ZERO); + for (i = 0; i < list->ld_count; i++) { + ld_sync[i].ref = list->ld_list[i].ld.ref; + } + + mtx_lock(&sc->mfi_io_lock); + if ((cmd = mfi_dequeue_free(sc)) == NULL) + return; + context = cmd->cm_frame->header.context; + bzero(cmd->cm_frame, sizeof(union mfi_frame)); + cmd->cm_frame->header.context = context; + + dcmd = &cmd->cm_frame->dcmd; + bzero(dcmd->mbox, MFI_MBOX_SIZE); + dcmd->header.cmd = MFI_CMD_DCMD; + dcmd->header.flags = MFI_FRAME_DIR_WRITE; + dcmd->header.timeout = 0; + dcmd->header.data_len = ld_size; + dcmd->header.scsi_status = 0; + dcmd->opcode = MFI_DCMD_LD_MAP_GET_INFO; + cmd->cm_sg = &dcmd->sgl; + cmd->cm_total_frame_size = MFI_DCMD_FRAME_SIZE; + cmd->cm_data = ld_sync; + cmd->cm_private = ld_sync; + + cmd->cm_len = ld_size; + cmd->cm_complete = mfi_sync_map_complete; + sc->mfi_map_sync_cm = cmd; + + cmd->cm_flags = MFI_CMD_DATAOUT; + cmd->cm_frame->dcmd.mbox[0] = list->ld_count; + cmd->cm_frame->dcmd.mbox[1] = MFI_DCMD_MBOX_PEND_FLAG; + + if ((error = mfi_mapcmd(sc, cmd)) != 0) { + device_printf(sc->mfi_dev, "failed to send map sync\n"); + return; + } + +out: + if (list) + free(list, M_MFIBUF); + if (cm) + mfi_release_command(cm); + mtx_unlock(&sc->mfi_io_lock); + + return; +} + + +static void +mfi_sync_map_complete(struct mfi_command *cm) +{ + struct mfi_frame_header *hdr; + struct mfi_softc *sc; + int aborted = 0; + + sc = cm->cm_sc; + mtx_assert(&sc->mfi_io_lock, MA_OWNED); + + hdr = &cm->cm_frame->header; + + if (sc->mfi_map_sync_cm == NULL) + return; + + if (sc->cm_map_abort || + hdr->cmd_status == MFI_STAT_INVALID_STATUS) { + sc->cm_map_abort = 0; + aborted = 1; + } + + free(cm->cm_data, M_MFIBUF); + sc->mfi_map_sync_cm = NULL; + wakeup(&sc->mfi_map_sync_cm); + mfi_release_command(cm); + + /* set it up again so the driver can catch more events */ + if (!aborted) { + mfi_queue_map_sync(sc); + } +} + +static void +mfi_queue_map_sync(struct mfi_softc *sc) +{ + mtx_assert(&sc->mfi_io_lock, MA_OWNED); + taskqueue_enqueue(taskqueue_swi, &sc->mfi_map_sync_task); +} + +void +mfi_handle_map_sync(void *context, int pending) +{ + struct mfi_softc *sc; + + sc = context; + mfi_tbolt_sync_map_info(sc); +} Modified: head/sys/dev/mfi/mfireg.h ============================================================================== --- head/sys/dev/mfi/mfireg.h Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfireg.h Fri May 4 16:00:39 2012 (r235014) @@ -403,6 +403,7 @@ typedef enum { #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152 #define MR_EVT_PD_REMOVED 0x0070 #define MR_EVT_PD_INSERTED 0x005b +#define MR_EVT_LD_CHANGE 0x0051 typedef enum { MR_LD_CACHE_WRITE_BACK = 0x01, Modified: head/sys/dev/mfi/mfivar.h ============================================================================== --- head/sys/dev/mfi/mfivar.h Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfivar.h Fri May 4 16:00:39 2012 (r235014) @@ -105,7 +105,6 @@ struct mfi_command { #define MFI_ON_MFIQ_READY (1<<6) #define MFI_ON_MFIQ_BUSY (1<<7) #define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7)) - int cm_aen_abort; uint8_t retry_for_fw_reset; void (* cm_complete)(struct mfi_command *cm); void *cm_private; @@ -216,9 +215,13 @@ struct mfi_softc { TAILQ_HEAD(,mfi_evt_queue_elm) mfi_evt_queue; struct task mfi_evt_task; + struct task mfi_map_sync_task; TAILQ_HEAD(,mfi_aen) mfi_aen_pids; struct mfi_command *mfi_aen_cm; struct mfi_command *mfi_skinny_cm; + struct mfi_command *mfi_map_sync_cm; + int cm_aen_abort; + int cm_map_abort; uint32_t mfi_aen_triggered; uint32_t mfi_poll_waiting; uint32_t mfi_boot_seq_num; @@ -303,8 +306,6 @@ struct mfi_softc { /* ThunderBolt */ uint32_t mfi_tbolt; uint32_t MFA_enabled; - uint64_t map_id; - struct mfi_command *map_update_cmd; /* Single Reply structure size */ uint16_t reply_size; /* Singler message size. */ @@ -417,7 +418,10 @@ extern int mfi_tbolt_alloc_cmd(struct mf extern int mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_command *cm); extern int mfi_tbolt_adp_reset(struct mfi_softc *sc); extern int mfi_tbolt_reset(struct mfi_softc *sc); -extern int mfi_tbolt_sync_map_info(struct mfi_softc *sc); +extern void mfi_tbolt_sync_map_info(struct mfi_softc *sc); +extern void mfi_handle_map_sync(void *context, int pending); +extern int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **, + uint32_t, void **, size_t); #define MFIQ_ADD(sc, qname) \ do { \ From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:08:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 570B8106564A; Fri, 4 May 2012 16:08:25 +0000 (UTC) (envelope-from joel@vnode.se) Received: from mail.vnode.se (mail.vnode.se [62.119.52.80]) by mx1.freebsd.org (Postfix) with ESMTP id 02E4F8FC16; Fri, 4 May 2012 16:08:25 +0000 (UTC) Received: from mail.vnode.se (localhost [127.0.0.1]) by mail.vnode.se (Postfix) with ESMTP id 30005E3F079; Fri, 4 May 2012 18:08:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at vnode.se Received: from mail.vnode.se ([127.0.0.1]) by mail.vnode.se (mail.vnode.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Um0p+1gXY8uH; Fri, 4 May 2012 18:08:11 +0200 (CEST) Received: from goofy01.vnodelab.local (jd.benders.se [212.247.52.12]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.vnode.se (Postfix) with ESMTPSA id 2EA08E3F07B; Fri, 4 May 2012 18:08:11 +0200 (CEST) Date: Fri, 4 May 2012 18:08:06 +0200 From: Joel Dahl To: Alexander Motin Message-ID: <20120504160806.GF6475@goofy01.vnodelab.local> References: <201203102158.q2ALw89R080428@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201203102158.q2ALw89R080428@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r232798 - in stable/9: share/man/man4 sys/conf sys/dev/sound/pci/hda sys/dev/sound/pcm sys/modules/sound/driver/hda X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:08:25 -0000 On 10-03-2012 21:58, Alexander Motin wrote: > Author: mav > Date: Sat Mar 10 21:58:08 2012 > New Revision: 232798 > URL: http://svn.freebsd.org/changeset/base/232798 > > Log: > MFC r230130, r230181, r230312, r230326, r230331, r230451, r230465, r230488, > r230507, r230511, r230513, r230532, r230537, r230551, r230554, r230571, > r230574, r230585, r230641, r230768, r230807, r231024: > Sync snd_hda(4) driver with HEAD. > > This includes major code refactoring, HDMI support, new volume control, > automatic recording source selection, runtime reconfigureation, support > for more then 4 PCM devices on controller, multichannel recording, > additional playback/record streams, higher bandwidths support, more > informative device names and many other things. > > Sponsored by: iXsystems, Inc. I'm still having problems with r230451. Every time I boot one of the machines I have at home it makes a short but loud "popping" sound. I almost fell of my chair the first time it happened. Now I'm being forced to unplug my speakers every time I boot it, just to avoid having a heart attack... -- Joel From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:15:38 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 037A1106566B; Fri, 4 May 2012 16:15:38 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id CC2228FC15; Fri, 4 May 2012 16:15:37 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 33BA7B93E; Fri, 4 May 2012 12:15:37 -0400 (EDT) From: John Baldwin To: Hans Petter Selasky Date: Fri, 4 May 2012 12:14:16 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201205041538.q44FclqK010547@svn.freebsd.org> In-Reply-To: <201205041538.q44FclqK010547@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201205041214.16342.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 04 May 2012 12:15:37 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:15:38 -0000 On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: > Author: hselasky > Date: Fri May 4 15:38:47 2012 > New Revision: 235007 > URL: http://svn.freebsd.org/changeset/base/235007 > > Log: > MFC r233662, r233677 and r233678: > > Writing zero to BAR actually does not disable it and > it is even harmful as hselasky found out. Historically, > this code was originated from (OLDCARD) CardBus driver and later leaked into > PCI driver when CardBus was newbus'ified and refactored with PCI driver. > However, it is not really necessary even for CardBus. FYI, I've got one bug report on HEAD where these changes broke a machine's ATA controller. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:18:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F9CF106566C; Fri, 4 May 2012 16:18: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 2F5D38FC14; Fri, 4 May 2012 16:18: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 q44GIwe3012201; Fri, 4 May 2012 16:18:58 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44GIwOF012198; Fri, 4 May 2012 16:18:58 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041618.q44GIwOF012198@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 16:18:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235015 - stable/8/usr.sbin/usbdump X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:18:58 -0000 Author: hselasky Date: Fri May 4 16:18:57 2012 New Revision: 235015 URL: http://svn.freebsd.org/changeset/base/235015 Log: MFC r231835, r234636 and r234655: Add support for filtering USB devices and USB endpoints to the usbdump utility when making software USB traces. Improve support for USB packet filtering also when reading dumps, and allow filtered data to be dumped to a binary file. Add missing and probably also mandatory -h option. Modified: stable/8/usr.sbin/usbdump/usbdump.8 (contents, props changed) stable/8/usr.sbin/usbdump/usbdump.c (contents, props changed) Directory Properties: stable/8/usr.sbin/usbdump/ (props changed) Modified: stable/8/usr.sbin/usbdump/usbdump.8 ============================================================================== --- stable/8/usr.sbin/usbdump/usbdump.8 Fri May 4 16:00:39 2012 (r235014) +++ stable/8/usr.sbin/usbdump/usbdump.8 Fri May 4 16:18:57 2012 (r235015) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 31, 2011 +.Dd April 24, 2012 .Dt USBDUMP 8 .Os .Sh NAME @@ -38,6 +38,9 @@ .Op Fl s Ar snaplen .Op Fl v .Op Fl w Ar file +.Op Fl f Ar filter +.Op Fl b Ar file +.Op Fl h .Sh DESCRIPTION The .Nm @@ -45,12 +48,17 @@ utility provides a way to dump USB packe .Pp The following options are accepted: .Bl -tag -width ".Fl f Ar file" +.It Fl b Ar file +Store data part of the USB trace in binary format to the given +.Ar file . +This option also works with the -r and -f options. .It Fl i Ar ifname Listen on USB bus interface .Ar ifname . .It Fl r Ar file Read the raw packets from .Ar file . +This option also works with the -f option. .It Fl s Ar snaplen Snapshot .Ar snaplen @@ -61,6 +69,19 @@ When defined multiple times the verbosit .It Fl w Ar file Write the raw packets to .Ar file . +This option also works with the -s and -v options. +.It Fl f Ar filter +The filter argument consists of either one or two numbers separated by a dot. +The first indicates the device unit number which should be traced. +The second number which is optional indicates the endpoint which should be traced. +To get all traffic for the control endpoint, two filters should be +created, one for endpoint 0 and one for endpoint 128. +If 128 is added to the endpoint number that means IN direction, else OUT direction is implied. +A device unit or endpoint value of -1 means ignore this field. +If no filters are specified, all packets are passed through using the default -1,-1 filter. +This option can be specified multiple times. +.It Fl h +This option displays a summary of the command line options. .El .Sh EXAMPLES Capture the USB raw packets on usbus2: @@ -72,6 +93,11 @@ size limit: .Pp .Dl "usbdump -i usbus2 -s 0 -w /tmp/dump_pkts" .Pp +Dump the USB raw packets of usbus2, but only the control endpoint traffic +of device unit number 3: +.Pp +.Dl "usbdump -i usbus2 -s 0 -f 3.0 -f 3.128 -w /tmp/dump_pkts" +.Pp Read and display the USB raw packets from previous file: .Pp .Dl "usbdump -r /tmp/dump_pkts -v" Modified: stable/8/usr.sbin/usbdump/usbdump.c ============================================================================== --- stable/8/usr.sbin/usbdump/usbdump.c Fri May 4 16:00:39 2012 (r235014) +++ stable/8/usr.sbin/usbdump/usbdump.c Fri May 4 16:18:57 2012 (r235015) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -45,12 +46,33 @@ #include #include #include +#include #include #include #include #include #include +#define BPF_STORE_JUMP(x,_c,_k,_jt,_jf) do { \ + (x).code = (_c); \ + (x).k = (_k); \ + (x).jt = (_jt); \ + (x).jf = (_jf); \ +} while (0) + +#define BPF_STORE_STMT(x,_c,_k) do { \ + (x).code = (_c); \ + (x).k = (_k); \ + (x).jt = 0; \ + (x).jf = 0; \ +} while (0) + +struct usb_filt { + STAILQ_ENTRY(usb_filt) entry; + int unit; + int endpoint; +}; + struct usbcap { int fd; /* fd for /dev/usbpf */ uint32_t bufsize; @@ -60,6 +82,8 @@ struct usbcap { int wfd; /* for -r option */ int rfd; + /* for -b option */ + int bfd; }; struct usbcap_filehdr { @@ -90,6 +114,8 @@ static int uf_minor; static const char *i_arg = "usbus0"; static const char *r_arg = NULL; static const char *w_arg = NULL; +static const char *b_arg = NULL; +static struct usbcap uc; static const char *errstr_table[USB_ERR_MAX] = { [USB_ERR_NORMAL_COMPLETION] = "0", [USB_ERR_PENDING_REQUESTS] = "PENDING_REQUESTS", @@ -137,6 +163,130 @@ static const char *speed_table[USB_SPEED [USB_SPEED_SUPER] = "SUPER", }; +static STAILQ_HEAD(,usb_filt) usb_filt_head = + STAILQ_HEAD_INITIALIZER(usb_filt_head); + +static void +add_filter(int usb_filt_unit, int usb_filt_ep) +{ + struct usb_filt *puf; + + puf = malloc(sizeof(struct usb_filt)); + if (puf == NULL) + errx(EX_SOFTWARE, "Out of memory."); + + puf->unit = usb_filt_unit; + puf->endpoint = usb_filt_ep; + + STAILQ_INSERT_TAIL(&usb_filt_head, puf, entry); +} + +static void +make_filter(struct bpf_program *pprog, int snapshot) +{ + struct usb_filt *puf; + struct bpf_insn *dynamic_insn; + int len; + + len = 0; + + STAILQ_FOREACH(puf, &usb_filt_head, entry) + len++; + + dynamic_insn = malloc(((len * 5) + 1) * sizeof(struct bpf_insn)); + + if (dynamic_insn == NULL) + errx(EX_SOFTWARE, "Out of memory."); + + len++; + + if (len == 1) { + /* accept all packets */ + + BPF_STORE_STMT(dynamic_insn[0], BPF_RET | BPF_K, snapshot); + + goto done; + } + + len = 0; + + STAILQ_FOREACH(puf, &usb_filt_head, entry) { + const int addr_off = (uintptr_t)&((struct usbpf_pkthdr *)0)->up_address; + const int addr_ep = (uintptr_t)&((struct usbpf_pkthdr *)0)->up_endpoint; + + if (puf->unit != -1) { + if (puf->endpoint != -1) { + BPF_STORE_STMT(dynamic_insn[len], + BPF_LD | BPF_B | BPF_ABS, addr_off); + len++; + BPF_STORE_JUMP(dynamic_insn[len], + BPF_JMP | BPF_JEQ | BPF_K, (uint8_t)puf->unit, 0, 3); + len++; + BPF_STORE_STMT(dynamic_insn[len], + BPF_LD | BPF_W | BPF_ABS, addr_ep); + len++; + BPF_STORE_JUMP(dynamic_insn[len], + BPF_JMP | BPF_JEQ | BPF_K, htobe32(puf->endpoint), 0, 1); + len++; + } else { + BPF_STORE_STMT(dynamic_insn[len], + BPF_LD | BPF_B | BPF_ABS, addr_off); + len++; + BPF_STORE_JUMP(dynamic_insn[len], + BPF_JMP | BPF_JEQ | BPF_K, (uint8_t)puf->unit, 0, 1); + len++; + } + } else { + if (puf->endpoint != -1) { + BPF_STORE_STMT(dynamic_insn[len], + BPF_LD | BPF_W | BPF_ABS, addr_ep); + len++; + BPF_STORE_JUMP(dynamic_insn[len], + BPF_JMP | BPF_JEQ | BPF_K, htobe32(puf->endpoint), 0, 1); + len++; + } + } + BPF_STORE_STMT(dynamic_insn[len], + BPF_RET | BPF_K, snapshot); + len++; + } + + BPF_STORE_STMT(dynamic_insn[len], BPF_RET | BPF_K, 0); + len++; + +done: + pprog->bf_len = len; + pprog->bf_insns = dynamic_insn; +} + +static int +match_filter(int unit, int endpoint) +{ + struct usb_filt *puf; + + if (STAILQ_FIRST(&usb_filt_head) == NULL) + return (1); + + STAILQ_FOREACH(puf, &usb_filt_head, entry) { + if ((puf->unit == -1 || puf->unit == unit) && + (puf->endpoint == -1 || puf->endpoint == endpoint)) + return (1); + } + return (0); +} + +static void +free_filter(struct bpf_program *pprog) +{ + struct usb_filt *puf; + + while ((puf = STAILQ_FIRST(&usb_filt_head)) != NULL) { + STAILQ_REMOVE_HEAD(&usb_filt_head, entry); + free(puf); + } + free(pprog->bf_insns); +} + static void handle_sigint(int sig) { @@ -332,28 +482,33 @@ print_apacket(const struct header_32 *hd up->up_packet_count = le32toh(up->up_packet_count); up->up_endpoint = le32toh(up->up_endpoint); + if (!match_filter(up->up_address, up->up_endpoint)) + return; + tv.tv_sec = hdr->ts_sec; tv.tv_usec = hdr->ts_usec; tm = localtime(&tv.tv_sec); len = strftime(buf, sizeof(buf), "%H:%M:%S", tm); - printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n", - (int)len, buf, tv.tv_usec, - (int)up->up_busunit, (int)up->up_address, - (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE", - xfertype_table[up->up_xfertype], - (unsigned int)up->up_endpoint, - usb_speedstr(up->up_speed), - (int)up->up_frames, - (int)(up->up_totlen - USBPF_HDR_LEN - - (USBPF_FRAME_HDR_LEN * up->up_frames)), - (int)up->up_interval, - (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "", - (up->up_type == USBPF_XFERTAP_DONE) ? - usb_errstr(up->up_error) : ""); + if (verbose >= 0) { + printf("%.*s.%06ld usbus%d.%d %s-%s-EP=%08x,SPD=%s,NFR=%d,SLEN=%d,IVAL=%d%s%s\n", + (int)len, buf, tv.tv_usec, + (int)up->up_busunit, (int)up->up_address, + (up->up_type == USBPF_XFERTAP_SUBMIT) ? "SUBM" : "DONE", + xfertype_table[up->up_xfertype], + (unsigned int)up->up_endpoint, + usb_speedstr(up->up_speed), + (int)up->up_frames, + (int)(up->up_totlen - USBPF_HDR_LEN - + (USBPF_FRAME_HDR_LEN * up->up_frames)), + (int)up->up_interval, + (up->up_type == USBPF_XFERTAP_DONE) ? ",ERR=" : "", + (up->up_type == USBPF_XFERTAP_DONE) ? + usb_errstr(up->up_error) : ""); + } - if (verbose >= 1) { + if (verbose >= 1 || b_arg != NULL) { for (x = 0; x != up->up_frames; x++) { const struct usbpf_framehdr *uf; uint32_t framelen; @@ -368,10 +523,12 @@ print_apacket(const struct header_32 *hd framelen = le32toh(uf->length); flags = le32toh(uf->flags); - printf(" frame[%u] %s %d bytes\n", - (unsigned int)x, - (flags & USBPF_FRAMEFLAG_READ) ? "READ" : "WRITE", - (int)framelen); + if (verbose >= 1) { + printf(" frame[%u] %s %d bytes\n", + (unsigned int)x, + (flags & USBPF_FRAMEFLAG_READ) ? "READ" : "WRITE", + (int)framelen); + } if (flags & USBPF_FRAMEFLAG_DATA_FOLLOWS) { @@ -385,7 +542,15 @@ print_apacket(const struct header_32 *hd (int)framelen < 0 || (int)ptr_len < 0) break; - hexdump(ptr, framelen); + if (b_arg != NULL) { + struct usbcap *p = &uc; + int ret; + ret = write(p->bfd, ptr, framelen); + if (ret != (int)framelen) + err(EXIT_FAILURE, "Could not write binary data"); + } + if (verbose >= 1) + hexdump(ptr, framelen); ptr += tot_frame_len; } @@ -462,7 +627,7 @@ print_packets(uint8_t *data, const int d if (next <= ptr) err(EXIT_FAILURE, "Invalid length"); - if (w_arg == NULL || r_arg != NULL) { + if (verbose >= 0 || r_arg != NULL || b_arg != NULL) { print_apacket(&temp, ptr + temp.hdrlen, temp.caplen); } @@ -604,10 +769,13 @@ usage(void) #define FMT " %-14s %s\n" fprintf(stderr, "usage: usbdump [options]\n"); fprintf(stderr, FMT, "-i ", "Listen on USB bus interface"); + fprintf(stderr, FMT, "-f ", "Specify a device and endpoint filter"); fprintf(stderr, FMT, "-r ", "Read the raw packets from file"); fprintf(stderr, FMT, "-s ", "Snapshot bytes from each packet"); fprintf(stderr, FMT, "-v", "Increase the verbose level"); + fprintf(stderr, FMT, "-b ", "Save raw version of all recorded data to file"); fprintf(stderr, FMT, "-w ", "Write the raw packets to file"); + fprintf(stderr, FMT, "-h", "Display summary of command line options"); #undef FMT exit(EX_USAGE); } @@ -616,20 +784,21 @@ int main(int argc, char *argv[]) { struct timeval tv; - struct bpf_insn total_insn; struct bpf_program total_prog; struct bpf_stat us; struct bpf_version bv; - struct usbcap uc, *p = &uc; + struct usbcap *p = &uc; struct ifreq ifr; long snapshot = 192; uint32_t v; - int fd, o; + int fd; + int o; + int filt_unit; + int filt_ep; const char *optstring; + char *pp; - memset(&uc, 0, sizeof(struct usbcap)); - - optstring = "i:r:s:vw:"; + optstring = "b:hi:r:s:vw:f:"; while ((o = getopt(argc, argv, optstring)) != -1) { switch (o) { case 'i': @@ -640,14 +809,19 @@ main(int argc, char *argv[]) init_rfile(p); break; case 's': - snapshot = strtol(optarg, NULL, 10); + snapshot = strtol(optarg, &pp, 10); errno = 0; + if (pp != NULL && *pp != 0) + usage(); if (snapshot == 0 && errno == EINVAL) usage(); /* snapeshot == 0 is special */ if (snapshot == 0) snapshot = -1; break; + case 'b': + b_arg = optarg; + break; case 'v': verbose++; break; @@ -655,12 +829,42 @@ main(int argc, char *argv[]) w_arg = optarg; init_wfile(p); break; + case 'f': + filt_unit = strtol(optarg, &pp, 10); + filt_ep = -1; + if (pp != NULL) { + if (*pp == '.') { + filt_ep = strtol(pp + 1, &pp, 10); + if (pp != NULL && *pp != 0) + usage(); + } else if (*pp != 0) { + usage(); + } + } + add_filter(filt_unit, filt_ep); + break; default: usage(); /* NOTREACHED */ } } + if (b_arg != NULL) { + p->bfd = open(b_arg, O_CREAT | O_TRUNC | + O_WRONLY, S_IRUSR | S_IWUSR); + if (p->bfd < 0) { + err(EXIT_FAILURE, "Could not open " + "'%s' for write", b_arg); + } + } + + /* + * Require more verbosity to print anything when -w or -b is + * specified on the command line: + */ + if (w_arg != NULL || b_arg != NULL) + verbose--; + if (r_arg != NULL) { read_file(p); exit(EXIT_SUCCESS); @@ -700,17 +904,13 @@ main(int argc, char *argv[]) if (p->buffer == NULL) errx(EX_SOFTWARE, "Out of memory."); - /* XXX no read filter rules yet so at this moment accept everything */ - total_insn.code = (u_short)(BPF_RET | BPF_K); - total_insn.jt = 0; - total_insn.jf = 0; - total_insn.k = snapshot; + make_filter(&total_prog, snapshot); - total_prog.bf_len = 1; - total_prog.bf_insns = &total_insn; if (ioctl(p->fd, BIOCSETF, (caddr_t)&total_prog) < 0) err(EXIT_FAILURE, "BIOCSETF ioctl failed"); + free_filter(&total_prog); + /* 1 second read timeout */ tv.tv_sec = 1; tv.tv_usec = 0; @@ -736,6 +936,8 @@ main(int argc, char *argv[]) close(p->rfd); if (p->wfd > 0) close(p->wfd); + if (p->bfd > 0) + close(p->bfd); return (EXIT_SUCCESS); } From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:22:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC17B1065670; Fri, 4 May 2012 16:22:13 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B651F8FC0A; Fri, 4 May 2012 16:22:13 +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 q44GMD0e012354; Fri, 4 May 2012 16:22:13 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44GMDAa012350; Fri, 4 May 2012 16:22:13 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205041622.q44GMDAa012350@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 16:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235016 - head/sys/dev/mfi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:22:14 -0000 Author: ambrisko Date: Fri May 4 16:22:13 2012 New Revision: 235016 URL: http://svn.freebsd.org/changeset/base/235016 Log: Some style improvements. Modified: head/sys/dev/mfi/mfi.c head/sys/dev/mfi/mfi_disk.c head/sys/dev/mfi/mfi_tbolt.c Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi.c Fri May 4 16:22:13 2012 (r235016) @@ -1319,7 +1319,7 @@ mfi_syspdprobe(struct mfi_softc *sc) /* Add SYSTEM PD's */ error = mfi_dcmd_command(sc, &cm, MFI_DCMD_PD_LIST_QUERY, (void **)&pdlist, sizeof(*pdlist)); - if (error){ + if (error) { device_printf(sc->mfi_dev, "Error while forming SYSTEM PD list\n"); goto out; @@ -1958,6 +1958,7 @@ mfi_add_sys_pd_complete(struct mfi_comma mtx_unlock(&Giant); mtx_lock(&sc->mfi_io_lock); } + static struct mfi_command * mfi_bio_command(struct mfi_softc *sc) { @@ -1965,7 +1966,7 @@ mfi_bio_command(struct mfi_softc *sc) struct mfi_command *cm = NULL; /*reserving two commands to avoid starvation for IOCTL*/ - if (sc->mfi_qstat[MFIQ_FREE].q_length < 2){ + if (sc->mfi_qstat[MFIQ_FREE].q_length < 2) { return (NULL); } if ((bio = mfi_dequeue_bio(sc)) == NULL) { @@ -2694,12 +2695,12 @@ static int mfi_check_for_sscd(struct mfi int error = 0; if ((cm->cm_frame->dcmd.opcode == MFI_DCMD_CFG_ADD) && - (conf_data->ld[0].params.isSSCD == 1)){ + (conf_data->ld[0].params.isSSCD == 1)) { error = 1; } else if (cm->cm_frame->dcmd.opcode == MFI_DCMD_LD_DELETE) { error = mfi_dcmd_command (sc, &ld_cm, MFI_DCMD_LD_GET_INFO, (void **)&ld_info, sizeof(*ld_info)); - if (error){ + if (error) { device_printf(sc->mfi_dev, "Failed to allocate" "MFI_DCMD_LD_GET_INFO %d", error); if (ld_info) @@ -2709,7 +2710,7 @@ static int mfi_check_for_sscd(struct mfi ld_cm->cm_flags = MFI_CMD_DATAIN; ld_cm->cm_frame->dcmd.mbox[0]= cm->cm_frame->dcmd.mbox[0]; ld_cm->cm_frame->header.target_id = cm->cm_frame->dcmd.mbox[0]; - if (mfi_wait_command(sc, ld_cm) != 0){ + if (mfi_wait_command(sc, ld_cm) != 0) { device_printf(sc->mfi_dev, "failed to get log drv\n"); mfi_release_command(ld_cm); free(ld_info, M_MFIBUF); Modified: head/sys/dev/mfi/mfi_disk.c ============================================================================== --- head/sys/dev/mfi/mfi_disk.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi_disk.c Fri May 4 16:22:13 2012 (r235016) @@ -256,17 +256,17 @@ mfi_disk_strategy(struct bio *bio) return; } - if (controller->adpreset){ + if (controller->adpreset) { bio->bio_error = EBUSY; return; } - if (controller->hw_crit_error){ + if (controller->hw_crit_error) { bio->bio_error = EBUSY; return; } - if (controller->issuepend_done == 0){ + if (controller->issuepend_done == 0) { bio->bio_error = EBUSY; return; } Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:22:13 2012 (r235016) @@ -141,11 +141,12 @@ mfi_tbolt_issue_cmd_ppc(struct mfi_softc MFI_WRITE4(sc, MFI_IQPH, (uint32_t)((uint64_t)bus_add >> 32)); } -/** +/* * mfi_tbolt_adp_reset - For controller reset * @regs: MFI register set */ -int mfi_tbolt_adp_reset(struct mfi_softc *sc) +int +mfi_tbolt_adp_reset(struct mfi_softc *sc) { int retry = 0, i = 0; int HostDiag; @@ -193,12 +194,10 @@ int mfi_tbolt_adp_reset(struct mfi_softc } /* - ******************************************************************************************* - * Description: - * This routine initialize Thunderbolt specific device information - ******************************************************************************************* + * This routine initialize Thunderbolt specific device information */ -void mfi_tbolt_init_globals(struct mfi_softc *sc) +void +mfi_tbolt_init_globals(struct mfi_softc *sc) { /* Initialize single reply size and Message size */ sc->reply_size = MEGASAS_THUNDERBOLT_REPLY_SIZE; @@ -240,16 +239,12 @@ void mfi_tbolt_init_globals(struct mfi_s } /* - **************************************************************************** - * Description: - * This function calculates the memory requirement for Thunderbolt - * controller - * Return Value: - * Total required memory in bytes - **************************************************************************** + * This function calculates the memory requirement for Thunderbolt + * controller, returns the total required memory in bytes */ -uint32_t mfi_tbolt_get_memory_requirement(struct mfi_softc *sc) +uint32_t +mfi_tbolt_get_memory_requirement(struct mfi_softc *sc) { uint32_t size; size = MEGASAS_THUNDERBOLT_MSG_ALLIGNMENT; /* for Alignment */ @@ -261,7 +256,6 @@ uint32_t mfi_tbolt_get_memory_requiremen } /* - **************************************************************************** * Description: * This function will prepare message pools for the Thunderbolt controller * Arguments: @@ -270,9 +264,9 @@ uint32_t mfi_tbolt_get_memory_requiremen * Return Value: * TRUE if successful * FALSE if failed - **************************************************************************** */ -int mfi_tbolt_init_desc_pool(struct mfi_softc *sc, uint8_t* mem_location, +int +mfi_tbolt_init_desc_pool(struct mfi_softc *sc, uint8_t* mem_location, uint32_t tbolt_contg_length) { uint32_t offset = 0; @@ -329,10 +323,7 @@ int mfi_tbolt_init_desc_pool(struct mfi_ } /* - **************************************************************************** - * Description: - * This routine prepare and issue INIT2 frame to the Firmware - **************************************************************************** + * This routine prepare and issue INIT2 frame to the Firmware */ int @@ -443,7 +434,8 @@ mfi_tbolt_init_MFI_queue(struct mfi_soft } -int mfi_tbolt_alloc_cmd(struct mfi_softc *sc) +int +mfi_tbolt_alloc_cmd(struct mfi_softc *sc) { struct mfi_cmd_tbolt *cmd; bus_addr_t io_req_base_phys; @@ -516,7 +508,8 @@ int mfi_tbolt_alloc_cmd(struct mfi_softc return 0; } -int mfi_tbolt_reset(struct mfi_softc *sc) +int +mfi_tbolt_reset(struct mfi_softc *sc) { uint32_t fw_state; @@ -551,7 +544,8 @@ int mfi_tbolt_reset(struct mfi_softc *sc /* * mfi_intr_tbolt - isr entry point */ -void mfi_intr_tbolt(void *arg) +void +mfi_intr_tbolt(void *arg) { struct mfi_softc *sc = (struct mfi_softc *)arg; @@ -569,7 +563,7 @@ void mfi_intr_tbolt(void *arg) return; } -/** +/* * map_cmd_status - Maps FW cmd status to OS cmd status * @cmd : Pointer to cmd * @status : status of cmd returned by FW @@ -582,7 +576,6 @@ map_tbolt_cmd_status(struct mfi_command { switch (status) { - case MFI_STAT_OK: mfi_cmd->cm_frame->header.cmd_status = 0; mfi_cmd->cm_frame->dcmd.header.cmd_status = 0; @@ -615,7 +608,7 @@ map_tbolt_cmd_status(struct mfi_command } } -/** +/* * mfi_tbolt_return_cmd - Return a cmd to free command pool * @instance: Adapter soft state * @cmd: Command packet to be returned to free command pool @@ -718,15 +711,15 @@ mfi_tbolt_complete_cmd(struct mfi_softc return; } -/** +/* * mfi_get_cmd - Get a command from the free pool * @instance: Adapter soft state * * Returns a free command from the pool */ -struct mfi_cmd_tbolt *mfi_tbolt_get_cmd(struct mfi_softc - *sc) +struct mfi_cmd_tbolt * +mfi_tbolt_get_cmd(struct mfi_softc *sc) { struct mfi_cmd_tbolt *cmd = NULL; @@ -831,7 +824,8 @@ mfi_tbolt_build_ldio(struct mfi_softc *s * MFI_SECTOR_LEN; } -int mfi_tbolt_is_ldio(struct mfi_command *mfi_cmd) +int +mfi_tbolt_is_ldio(struct mfi_command *mfi_cmd) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_READ || mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) @@ -841,7 +835,8 @@ int mfi_tbolt_is_ldio(struct mfi_command } int -mfi_tbolt_build_io(struct mfi_softc *sc, struct mfi_command *mfi_cmd, struct mfi_cmd_tbolt *cmd) +mfi_tbolt_build_io(struct mfi_softc *sc, struct mfi_command *mfi_cmd, + struct mfi_cmd_tbolt *cmd) { uint32_t device_id; uint32_t sge_count; @@ -930,8 +925,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc cdb[3] = (uint8_t) (lba_lo >> 16); cdb[2] = (uint8_t) (lba_lo >> 24); cdb_len = 10; - } - else if ((num_lba > 0xFFFF) && (lba_hi == 0)) { + } else if ((num_lba > 0xFFFF) && (lba_hi == 0)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 12 or Write 12 */ cdb[0] = (uint8_t) (0xAA); @@ -1150,7 +1144,7 @@ mfi_tbolt_send_frame(struct mfi_softc *s if (tm <= 0) break; } - + if (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { device_printf(sc->mfi_dev, "Frame %p timed out " "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); @@ -1159,7 +1153,8 @@ mfi_tbolt_send_frame(struct mfi_softc *s return 0; } -static void mfi_issue_pending_cmds_again (struct mfi_softc *sc) +static void +mfi_issue_pending_cmds_again (struct mfi_softc *sc) { struct mfi_command *cm, *tmp; @@ -1204,7 +1199,8 @@ static void mfi_issue_pending_cmds_again mfi_startio(sc); } -static void mfi_kill_hba (struct mfi_softc *sc) +static void +mfi_kill_hba (struct mfi_softc *sc) { if (sc->mfi_flags & MFI_FLAGS_TBOLT) MFI_WRITE4 (sc, 0x00,MFI_STOP_ADP); @@ -1212,7 +1208,8 @@ static void mfi_kill_hba (struct mfi_sof MFI_WRITE4 (sc, MFI_IDB,MFI_STOP_ADP); } -static void mfi_process_fw_state_chg_isr(void *arg) +static void +mfi_process_fw_state_chg_isr(void *arg) { struct mfi_softc *sc= (struct mfi_softc *)arg; struct mfi_cmd_tbolt *cmd; @@ -1296,7 +1293,7 @@ static void mfi_process_fw_state_chg_isr /* * The ThunderBolt HW has an option for the driver to directly - * access the underlying disks and operate on the RAID. To + * access the underlying disks and operate on the RAID. To * do this there needs to be a capability to keep the RAID controller * and driver in sync. The FreeBSD driver does not take advantage * of this feature since it adds a lot of complexity and slows down From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:25:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AA18B1065674; Fri, 4 May 2012 16:25:35 +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 91EF68FC12; Fri, 4 May 2012 16:25: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 q44GPZ05012512; Fri, 4 May 2012 16:25:35 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44GPZ2Z012501; Fri, 4 May 2012 16:25:35 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205041625.q44GPZ2Z012501@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 4 May 2012 16:25:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235017 - stable/8/lib/libusb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:25:35 -0000 Author: hselasky Date: Fri May 4 16:25:35 2012 New Revision: 235017 URL: http://svn.freebsd.org/changeset/base/235017 Log: MFC r228235, r228236, r233667, r234687, r234491, r234193, and r233424: Minor code simplification. No functional change. Fix some compile warnings. Fix some mdoc issues. Add missing LibUSB 1.0 API function. Modified: stable/8/lib/libusb/Makefile stable/8/lib/libusb/libusb.3 stable/8/lib/libusb/libusb.h stable/8/lib/libusb/libusb10.c stable/8/lib/libusb/libusb10_desc.c stable/8/lib/libusb/libusb10_io.c stable/8/lib/libusb/libusb20.3 stable/8/lib/libusb/libusb20.c stable/8/lib/libusb/libusb20_desc.c stable/8/lib/libusb/libusb20_ugen20.c Directory Properties: stable/8/lib/libusb/ (props changed) Modified: stable/8/lib/libusb/Makefile ============================================================================== --- stable/8/lib/libusb/Makefile Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/Makefile Fri May 4 16:25:35 2012 (r235017) @@ -46,6 +46,7 @@ MLINKS += libusb.3 libusb_get_bus_number MLINKS += libusb.3 libusb_get_device_address.3 MLINKS += libusb.3 libusb_get_device_speed.3 MLINKS += libusb.3 libusb_get_max_packet_size.3 +MLINKS += libusb.3 libusb_get_max_iso_packet_size.3 MLINKS += libusb.3 libusb_ref_device.3 MLINKS += libusb.3 libusb_unref_device.3 MLINKS += libusb.3 libusb_open.3 @@ -67,7 +68,7 @@ MLINKS += libusb.3 libusb_detach_kernel_ MLINKS += libusb.3 libusb_detach_kernel_driver_np.3 MLINKS += libusb.3 libusb_attach_kernel_driver.3 MLINKS += libusb.3 libusb_get_device_descriptor.3 -MLINKS += libusb.3 libsub_get_active_config_descriptor.3 +MLINKS += libusb.3 libusb_get_active_config_descriptor.3 MLINKS += libusb.3 libusb_get_config_descriptor.3 MLINKS += libusb.3 libusb_get_config_descriptor_by_value.3 MLINKS += libusb.3 libusb_free_config_descriptor.3 Modified: stable/8/lib/libusb/libusb.3 ============================================================================== --- stable/8/lib/libusb/libusb.3 Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb.3 Fri May 4 16:25:35 2012 (r235017) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd April 12, 2012 .Dt LIBUSB 3 .Os .Sh NAME @@ -43,7 +43,6 @@ The library contains interfaces for directly managing a usb device. The current implementation supports v1.0 of the libusb API. .Sh LIBRARY INITIALISATION / DEINITIALISATION -.Pp .Ft int .Fn libusb_init libusb_context **ctx This function initialises libusb. @@ -119,6 +118,12 @@ LIBUSB_SPEED_UNKNOWN is returned in case Returns the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure. .Pp +.Ft int +.Fn libusb_get_max_iso_packet_size "libusb_device *dev" "unsigned char endpoint" +Returns the packet size multiplied by the packet multiplier on success, +LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and +LIBUSB_ERROR_OTHERS on other failure. +.Pp .Ft libusb_device * .Fn libusb_ref_device "libusb_device *dev" Increment the reference counter of the device @@ -270,9 +275,7 @@ LIBUSB_ERROR_NO_DEVICE if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be attached because the interface is claimed by a program or driver and a LIBUSB_ERROR code on failure. -.Pp .Sh USB DESCRIPTORS -.Pp .Ft int .Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc" Get the USB device descriptor for the device @@ -282,7 +285,7 @@ Returns 0 on success and a LIBUSB_ERROR failure. .Pp .Ft int -.Fn libsub_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config" +.Fn libusb_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config" Get the USB configuration descriptor for the active configuration. Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the device is in @@ -349,9 +352,7 @@ libusb_free_bos_descriptor function. .Ft void .Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos" This function is NULL safe and frees a parsed BOS descriptor. -.Pp .Sh USB ASYNCHRONOUS I/O -.Pp .Ft struct libusb_transfer * .Fn libusb_alloc_transfer "int iso_packets" Allocate a transfer with the number of isochronous packet descriptors @@ -374,9 +375,7 @@ LIBUSB_ERROR code on other failure. .Fn libusb_cancel_transfer "struct libusb_transfer *tr" This function asynchronously cancels a transfer. Returns 0 on success and a LIBUSB_ERROR code on failure. -.Pp .Sh USB SYNCHRONOUS I/O -.Pp .Ft int .Fn libusb_control_transfer "libusb_device_handle *devh" "uint8_t bmRequestType" "uint8_t bRequest" "uint16_t wValue" "uint16_t wIndex" "unsigned char *data" "uint16_t wLength" "unsigned int timeout" Perform a USB control transfer. @@ -411,9 +410,7 @@ if the transfer timed out, LIBUSB_ERROR_ supported, LIBUSB_ERROR_OVERFLOW if the device offered more data, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and a LIBUSB_ERROR code on other failure. -.Pp .Sh USB EVENTS -.Pp .Ft int .Fn libusb_try_lock_events "libusb_context *ctx" Try to acquire the event handling lock. @@ -429,7 +426,7 @@ This function is blocking. Release the event handling lock. This will wake up any thread blocked on -.B libusb_wait_for_event() . +.Fn libusb_wait_for_event . .Pp .Ft int .Fn libusb_event_handling_ok "libusb_context *ctx" @@ -506,7 +503,6 @@ Retrive a list of file descriptors that libusb event sources. Returns a NULL-terminated list on success or NULL on failure. .Sh LIBUSB VERSION 0.1 COMPATIBILITY -.Pp The library is also compliant with LibUSB version 0.1.12. .Pp .Fn usb_open Modified: stable/8/lib/libusb/libusb.h ============================================================================== --- stable/8/lib/libusb/libusb.h Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb.h Fri May 4 16:25:35 2012 (r235017) @@ -371,6 +371,7 @@ uint8_t libusb_get_device_address(libusb enum libusb_speed libusb_get_device_speed(libusb_device * dev); int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint); int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); +int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); libusb_device *libusb_ref_device(libusb_device * dev); void libusb_unref_device(libusb_device * dev); int libusb_open(libusb_device * dev, libusb_device_handle ** devh); Modified: stable/8/lib/libusb/libusb10.c ============================================================================== --- stable/8/lib/libusb/libusb10.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb10.c Fri May 4 16:25:35 2012 (r235017) @@ -331,6 +331,30 @@ out: return (ret); } +int +libusb_get_max_iso_packet_size(libusb_device *dev, uint8_t endpoint) +{ + int multiplier; + int ret; + + ret = libusb_get_max_packet_size(dev, endpoint); + + switch (libusb20_dev_get_speed(dev->os_priv)) { + case LIBUSB20_SPEED_LOW: + case LIBUSB20_SPEED_FULL: + break; + default: + if (ret > -1) { + multiplier = (1 + ((ret >> 11) & 3)); + if (multiplier > 3) + multiplier = 3; + ret = (ret & 0x7FF) * multiplier; + } + break; + } + return (ret); +} + libusb_device * libusb_ref_device(libusb_device *dev) { @@ -417,9 +441,12 @@ libusb_open_device_with_vid_pid(libusb_c if ((i = libusb_get_device_list(ctx, &devs)) < 0) return (NULL); + pdev = NULL; for (j = 0; j < i; j++) { - pdev = devs[j]->os_priv; - pdesc = libusb20_dev_get_device_desc(pdev); + struct libusb20_device *tdev; + + tdev = devs[j]->os_priv; + pdesc = libusb20_dev_get_device_desc(tdev); /* * NOTE: The USB library will automatically swap the * fields in the device descriptor to be of host @@ -427,13 +454,10 @@ libusb_open_device_with_vid_pid(libusb_c */ if (pdesc->idVendor == vendor_id && pdesc->idProduct == product_id) { - if (libusb_open(devs[j], &pdev) < 0) - pdev = NULL; + libusb_open(devs[j], &pdev); break; } } - if (j == i) - pdev = NULL; libusb_free_device_list(devs, 1); DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); @@ -627,17 +651,17 @@ libusb_set_interface_alt_setting(struct static struct libusb20_transfer * libusb10_get_transfer(struct libusb20_device *pdev, - uint8_t endpoint, uint8_t index) + uint8_t endpoint, uint8_t xfer_index) { - index &= 1; /* double buffering */ + xfer_index &= 1; /* double buffering */ - index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4; + xfer_index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4; if (endpoint & LIBUSB20_ENDPOINT_DIR_MASK) { /* this is an IN endpoint */ - index |= 2; + xfer_index |= 2; } - return (libusb20_tr_get_pointer(pdev, index)); + return (libusb20_tr_get_pointer(pdev, xfer_index)); } int Modified: stable/8/lib/libusb/libusb10_desc.c ============================================================================== --- stable/8/lib/libusb/libusb10_desc.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb10_desc.c Fri May 4 16:25:35 2012 (r235017) @@ -390,8 +390,8 @@ libusb_parse_bos_descriptor(const void * struct libusb_bos_descriptor **bos) { struct libusb_bos_descriptor *ptr; - struct libusb_usb_2_0_device_capability_descriptor *dcap_20; - struct libusb_ss_usb_device_capability_descriptor *ss_cap; + struct libusb_usb_2_0_device_capability_descriptor *dcap_20 = NULL; + struct libusb_ss_usb_device_capability_descriptor *ss_cap = NULL; if (buf == NULL || bos == NULL || len < 1) return (LIBUSB_ERROR_INVALID_PARAM); @@ -438,7 +438,7 @@ libusb_parse_bos_descriptor(const void * dtype == LIBUSB_DT_DEVICE_CAPABILITY) { switch (((const uint8_t *)buf)[2]) { case LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY: - if (ptr->usb_2_0_ext_cap != NULL) + if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == NULL) break; if (dlen < LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE) break; @@ -455,7 +455,7 @@ libusb_parse_bos_descriptor(const void * break; case LIBUSB_SS_USB_DEVICE_CAPABILITY: - if (ptr->ss_usb_cap != NULL) + if (ptr->ss_usb_cap != NULL || ss_cap == NULL) break; if (dlen < LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE) break; Modified: stable/8/lib/libusb/libusb10_io.c ============================================================================== --- stable/8/lib/libusb/libusb10_io.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb10_io.c Fri May 4 16:25:35 2012 (r235017) @@ -481,7 +481,7 @@ libusb10_do_transfer(libusb_device_handl { libusb_context *ctx; struct libusb_transfer *xfer; - volatile int complet; + int done; int ret; if (devh == NULL) @@ -502,15 +502,15 @@ libusb10_do_transfer(libusb_device_handl xfer->timeout = timeout; xfer->buffer = data; xfer->length = length; - xfer->user_data = (void *)&complet; + xfer->user_data = (void *)&done; xfer->callback = libusb10_do_transfer_cb; - complet = 0; + done = 0; if ((ret = libusb_submit_transfer(xfer)) < 0) { libusb_free_transfer(xfer); return (ret); } - while (complet == 0) { + while (done == 0) { if ((ret = libusb_handle_events(ctx)) < 0) { libusb_cancel_transfer(xfer); usleep(1000); /* nice it */ @@ -581,7 +581,7 @@ libusb_interrupt_transfer(libusb_device_ } uint8_t * -libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index) +libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t off) { uint8_t *ptr; uint32_t n; @@ -589,35 +589,35 @@ libusb_get_iso_packet_buffer(struct libu if (transfer->num_iso_packets < 0) return (NULL); - if (index >= (uint32_t)transfer->num_iso_packets) + if (off >= (uint32_t)transfer->num_iso_packets) return (NULL); ptr = transfer->buffer; if (ptr == NULL) return (NULL); - for (n = 0; n != index; n++) { + for (n = 0; n != off; n++) { ptr += transfer->iso_packet_desc[n].length; } return (ptr); } uint8_t * -libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index) +libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t off) { uint8_t *ptr; if (transfer->num_iso_packets < 0) return (NULL); - if (index >= (uint32_t)transfer->num_iso_packets) + if (off >= (uint32_t)transfer->num_iso_packets) return (NULL); ptr = transfer->buffer; if (ptr == NULL) return (NULL); - ptr += transfer->iso_packet_desc[0].length * index; + ptr += transfer->iso_packet_desc[0].length * off; return (ptr); } Modified: stable/8/lib/libusb/libusb20.3 ============================================================================== --- stable/8/lib/libusb/libusb20.3 Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb20.3 Fri May 4 16:25:35 2012 (r235017) @@ -235,7 +235,6 @@ applications should consider using . .Sh USB TRANSFER OPERATIONS . -.Pp . .Fn libusb20_tr_close will release all kernel resources associated with an USB @@ -534,7 +533,6 @@ with an USB transfer. . .Sh USB DEVICE OPERATIONS . -.Pp . .Fn libusb20_dev_get_backend_name returns a zero terminated string describing the backend used. @@ -1000,7 +998,6 @@ 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 Modified: stable/8/lib/libusb/libusb20.c ============================================================================== --- stable/8/lib/libusb/libusb20.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb20.c Fri May 4 16:25:35 2012 (r235017) @@ -948,9 +948,8 @@ libusb20_dev_get_config_index(struct lib } error = pdev->methods->get_config_index(pdev, &cfg_index); - if (error) { - cfg_index = 0 - 1; /* current config index */ - } + if (error) + cfg_index = 0xFF; /* current config index */ if (do_close) { if (libusb20_dev_close(pdev)) { /* ignore */ Modified: stable/8/lib/libusb/libusb20_desc.c ============================================================================== --- stable/8/lib/libusb/libusb20_desc.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb20_desc.c Fri May 4 16:25:35 2012 (r235017) @@ -69,7 +69,7 @@ libusb20_parse_config_desc(const void *c uint16_t niface_no_alt; uint16_t niface; uint16_t nendpoint; - uint8_t iface_no; + uint16_t iface_no; ptr = config_desc; if (ptr[1] != LIBUSB20_DT_CONFIG) { @@ -82,7 +82,7 @@ libusb20_parse_config_desc(const void *c niface_no_alt = 0; nendpoint = 0; niface = 0; - iface_no = 0 - 1; + iface_no = 0xFFFF; ptr = NULL; /* get "wTotalLength" and setup "pcdesc" */ @@ -155,7 +155,7 @@ libusb20_parse_config_desc(const void *c /* reset states */ niface = 0; - iface_no = 0 - 1; + iface_no = 0xFFFF; ptr = NULL; lub_interface--; lub_endpoint--; @@ -450,7 +450,7 @@ libusb20_me_encode(void *ptr, uint16_t l * and should be * correct: */ - ps->len = 0 - 1; + ps->len = 0xFFFF; } src_len = libusb20_me_get_1(pd, 0); src_ptr = LIBUSB20_ADD_BYTES(ps->ptr, 1); @@ -465,7 +465,7 @@ libusb20_me_encode(void *ptr, uint16_t l case LIBUSB20_ME_IS_DECODED: /* reserve 3 length bytes */ src_len = libusb20_me_encode(NULL, - 0 - 1 - 3, ps->ptr); + 0xFFFF - 3, ps->ptr); src_ptr = NULL; break; @@ -476,7 +476,7 @@ libusb20_me_encode(void *ptr, uint16_t l } if (src_len > 0xFE) { - if (src_len > (uint16_t)(0 - 1 - 3)) + if (src_len > (0xFFFF - 3)) /* overflow */ goto done; @@ -516,7 +516,7 @@ libusb20_me_encode(void *ptr, uint16_t l uint16_t dummy; dummy = libusb20_me_encode(buf, - 0 - 1 - 3, ps->ptr); + 0xFFFF - 3, ps->ptr); } else { bcopy(src_ptr, buf, src_len); } Modified: stable/8/lib/libusb/libusb20_ugen20.c ============================================================================== --- stable/8/lib/libusb/libusb20_ugen20.c Fri May 4 16:22:13 2012 (r235016) +++ stable/8/lib/libusb/libusb20_ugen20.c Fri May 4 16:25:35 2012 (r235017) @@ -104,7 +104,7 @@ ugen20_path_convert_one(const char **pp) temp += (*ptr - '0'); if (temp >= 1000000) { /* catch overflow early */ - return (0 - 1); + return (0xFFFFFFFF); } ptr++; } From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:32:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CE028106566B; Fri, 4 May 2012 16:32:19 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe04.c2i.net [212.247.154.98]) by mx1.freebsd.org (Postfix) with ESMTP id 924708FC08; Fri, 4 May 2012 16:32:18 +0000 (UTC) X-T2-Spam-Status: No, hits=-1.0 required=5.0 tests=ALL_TRUSTED Received: from [176.74.212.201] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe04.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 269758721; Fri, 04 May 2012 18:27:09 +0200 From: Hans Petter Selasky To: John Baldwin Date: Fri, 4 May 2012 18:26:19 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.3-STABLE; KDE/4.4.5; amd64; ; ) References: <201205041538.q44FclqK010547@svn.freebsd.org> <201205041214.16342.jhb@freebsd.org> In-Reply-To: <201205041214.16342.jhb@freebsd.org> X-Face: 'mmZ:T{)),Oru^0c+/}w'`gU1$ubmG?lp!=R4Wy\ELYo2)@'UZ24N@d2+AyewRX}mAm; Yp |U[@, _z/([?1bCfM{_"B<.J>mICJCHAzzGHI{y7{%JVz%R~yJHIji`y>Y}k1C4TfysrsUI -%GU9V5]iUZF&nRn9mJ'?&>O MIME-Version: 1.0 Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Message-Id: <201205041826.19435.hselasky@c2i.net> Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:32:19 -0000 On Friday 04 May 2012 18:14:16 John Baldwin wrote: > On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: > > Author: hselasky > > Date: Fri May 4 15:38:47 2012 > > New Revision: 235007 > > URL: http://svn.freebsd.org/changeset/base/235007 > > > > Log: > > MFC r233662, r233677 and r233678: > > > > Writing zero to BAR actually does not disable it and > > it is even harmful as hselasky found out. Historically, > > this code was originated from (OLDCARD) CardBus driver and later leaked > > into PCI driver when CardBus was newbus'ified and refactored with PCI > > driver. However, it is not really necessary even for CardBus. > > FYI, I've got one bug report on HEAD where these changes broke a machine's > ATA controller. Have you considered adding code to disable the I/O or memory range instead of writing 0 to the bar in this case? --HPS From owner-svn-src-all@FreeBSD.ORG Fri May 4 16:40:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13D431065672; Fri, 4 May 2012 16:40:11 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id BC2568FC1A; Fri, 4 May 2012 16:40:10 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so4461374pbb.13 for ; Fri, 04 May 2012 09:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=OSsDv0j8rMYgL8lw65iG2OJnyTQeVF8vetEsuC0v84c=; b=osciytzUpHCKkr5v/CZF8z/eWKjG4c2bX2VvcIcWGg7sYGIi3Xs+nuFlYI5JZ2xSPa 3yoqu6pv52NsruB7I+7pkclag9vAO+Ozj/aQtCLp+LW+U4449VEleQ3EhAH06PNaeFRR cNTVyqc/uguTjCnFceEeq9ftu+RER09qlpJZ1XxYCl3oYn5iw1NyJVxeBc5cF7SpOgZT r+jWtyUjBKgqzF71HkAwoZMoIQNj0zHKXCco9fVtCq0Ry1mzARQq/0hpypWjHKM0fK/H 3ea8SerdPDTnoBuU9m9jwqm/9CzUYqq4xoilMgZ3PhUcgJwTYAznC/hGA1uGsXqunB8J wZYA== Received: by 10.68.233.136 with SMTP id tw8mr2127621pbc.71.1336149224972; Fri, 04 May 2012 09:33:44 -0700 (PDT) Received: from [10.170.185.186] (mobile-166-147-081-047.mycingular.net. [166.147.81.47]) by mx.google.com with ESMTPS id q5sm9058810pbp.28.2012.05.04.09.33.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 09:33:43 -0700 (PDT) References: <201205041531.q44FVaYF010236@svn.freebsd.org> In-Reply-To: <201205041531.q44FVaYF010236@svn.freebsd.org> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: X-Mailer: iPhone Mail (9B179) From: Garrett Cooper Date: Fri, 4 May 2012 09:33:38 -0700 To: Josh Paetzel Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:40:11 -0000 On May 4, 2012, at 8:31 AM, Josh Paetzel wrote: > Author: jpaetzel > Date: Fri May 4 15:31:35 2012 > New Revision: 235005 > URL: http://svn.freebsd.org/changeset/base/235005 >=20 > Log: > Use a unique zpool name during install, in the case of having another > PC-BSD / FreeBSD zpool on the system for another install. >=20 > Submitted by: kmoore > Obtained from: PC-BSD > MFC after: 3 days > Sponsored by: iXsystems >=20 > Modified: > head/usr.sbin/pc-sysinstall/backend/functions.sh >=20 > Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:27:1= 8 2012 (r235004) > +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:31:3= 5 2012 (r235005) > @@ -216,7 +216,7 @@ fetch_file() >=20 > fetch -s "${FETCHFILE}" >${SIZEFILE} > SIZE=3D"`cat ${SIZEFILE}`" > - SIZE=3D"`expr ${SIZE} / 1024`" > + SIZE=3D$((SIZE/1024)) Bug; should be '$SIZE/' > echo "FETCH: ${FETCHFILE}" > echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} >=20 > @@ -276,11 +276,22 @@ get_zpool_name() > else > # Need to generate a zpool name for this device > NUM=3D`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` > - NEWNAME=3D"${BASENAME}${NUM}" > + > + # Is it used in another zpool? > + while > + z=3D1 > + do while : do Is better. > + NEWNAME=3D"${BASENAME}${NUM}" > + zpool import | grep -q "${NEWNAME}" > + if [ $? -ne 0 ] ; then break ; fi Please decompress the conditional. > + NUM=3D$((NUM+1)) Another bug (see above). Thanks, -Garrett= From owner-svn-src-all@FreeBSD.ORG Fri May 4 17:18:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51C311065672; Fri, 4 May 2012 17:18:03 +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 23F0C8FC0C; Fri, 4 May 2012 17:18:03 +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 q44HI26T014327; Fri, 4 May 2012 17:18:02 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44HI2lT014325; Fri, 4 May 2012 17:18:02 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041718.q44HI2lT014325@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 17:18: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: r235021 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 17:18:03 -0000 Author: tuexen Date: Fri May 4 17:18:02 2012 New Revision: 235021 URL: http://svn.freebsd.org/changeset/base/235021 Log: Add support for the SCTP_ENABLE_STREAM_RESET socket option to getsockopt(). This improves the support of RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Fri May 4 17:12:31 2012 (r235020) +++ head/sys/netinet/sctp_usrreq.c Fri May 4 17:18:02 2012 (r235021) @@ -3296,6 +3296,33 @@ flags_out: } break; } + case SCTP_ENABLE_STREAM_RESET: + { + struct sctp_assoc_value *av; + + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + + if (stcb) { + av->assoc_value = (uint32_t) stcb->asoc.local_strreset_support; + SCTP_TCB_UNLOCK(stcb); + } else { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || + (av->assoc_id == SCTP_FUTURE_ASSOC)) { + SCTP_INP_RLOCK(inp); + av->assoc_value = (uint32_t) inp->local_strreset_support; + SCTP_INP_RUNLOCK(inp); + } else { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + } + } + if (error == 0) { + *optsize = sizeof(struct sctp_assoc_value); + } + break; + } default: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOPROTOOPT); error = ENOPROTOOPT; @@ -4096,7 +4123,6 @@ sctp_setopt(struct socket *so, int optna case SCTP_ENABLE_STREAM_RESET: { struct sctp_assoc_value *av; - uint8_t set_value = 0; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); if (av->assoc_value & (~SCTP_ENABLE_VALUE_MASK)) { @@ -4104,10 +4130,9 @@ sctp_setopt(struct socket *so, int optna error = EINVAL; break; } - set_value = av->assoc_value & SCTP_ENABLE_VALUE_MASK; SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - stcb->asoc.local_strreset_support = set_value; + stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -4115,7 +4140,7 @@ sctp_setopt(struct socket *so, int optna (av->assoc_id == SCTP_FUTURE_ASSOC) || (av->assoc_id == SCTP_ALL_ASSOC)) { SCTP_INP_WLOCK(inp); - inp->local_strreset_support = set_value; + inp->local_strreset_support = (uint8_t) av->assoc_value; SCTP_INP_WUNLOCK(inp); } if ((av->assoc_id == SCTP_CURRENT_ASSOC) || @@ -4123,7 +4148,7 @@ sctp_setopt(struct socket *so, int optna SCTP_INP_RLOCK(inp); LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); - stcb->asoc.local_strreset_support = set_value; + stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; SCTP_TCB_UNLOCK(stcb); } SCTP_INP_RUNLOCK(inp); From owner-svn-src-all@FreeBSD.ORG Fri May 4 17:19:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5BB9106564A; Fri, 4 May 2012 17:19:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B59288FC17; Fri, 4 May 2012 17:19:41 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 1D8C4B945; Fri, 4 May 2012 13:19:40 -0400 (EDT) From: John Baldwin To: Hans Petter Selasky Date: Fri, 4 May 2012 13:11:09 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201205041538.q44FclqK010547@svn.freebsd.org> <201205041214.16342.jhb@freebsd.org> <201205041826.19435.hselasky@c2i.net> In-Reply-To: <201205041826.19435.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Message-Id: <201205041311.09237.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 04 May 2012 13:19:40 -0400 (EDT) Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 17:19:42 -0000 On Friday, May 04, 2012 12:26:19 pm Hans Petter Selasky wrote: > On Friday 04 May 2012 18:14:16 John Baldwin wrote: > > On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: > > > Author: hselasky > > > Date: Fri May 4 15:38:47 2012 > > > New Revision: 235007 > > > URL: http://svn.freebsd.org/changeset/base/235007 > > > > > > Log: > > > MFC r233662, r233677 and r233678: > > > > > > Writing zero to BAR actually does not disable it and > > > it is even harmful as hselasky found out. Historically, > > > this code was originated from (OLDCARD) CardBus driver and later leaked > > > into PCI driver when CardBus was newbus'ified and refactored with PCI > > > driver. However, it is not really necessary even for CardBus. > > > > FYI, I've got one bug report on HEAD where these changes broke a machine's > > ATA controller. > > Have you considered adding code to disable the I/O or memory range instead of > writing 0 to the bar in this case? I have to figure out what the user's bug is first. The patch that "fixed" it was to restore writing 0 to a BAR that failed to allocate during the initial bus scan. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Fri May 4 17:23:24 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 188CC106564A; Fri, 4 May 2012 17:23:24 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 909738FC0C; Fri, 4 May 2012 17:23:17 +0000 (UTC) Received: from [10.30.101.53] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q44HJ2Ee032710 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 4 May 2012 11:19:03 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201205041826.19435.hselasky@c2i.net> Date: Fri, 4 May 2012 11:18:56 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201205041538.q44FclqK010547@svn.freebsd.org> <201205041214.16342.jhb@freebsd.org> <201205041826.19435.hselasky@c2i.net> To: Hans Petter Selasky X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 04 May 2012 11:19:03 -0600 (MDT) Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" , John Baldwin Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 17:23:24 -0000 On May 4, 2012, at 10:26 AM, Hans Petter Selasky wrote: > On Friday 04 May 2012 18:14:16 John Baldwin wrote: >> On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: >>> Author: hselasky >>> Date: Fri May 4 15:38:47 2012 >>> New Revision: 235007 >>> URL: http://svn.freebsd.org/changeset/base/235007 >>>=20 >>> Log: >>> MFC r233662, r233677 and r233678: >>>=20 >>> Writing zero to BAR actually does not disable it and >>> it is even harmful as hselasky found out. Historically, >>> this code was originated from (OLDCARD) CardBus driver and later = leaked >>> into PCI driver when CardBus was newbus'ified and refactored with = PCI >>> driver. However, it is not really necessary even for CardBus. >>=20 >> FYI, I've got one bug report on HEAD where these changes broke a = machine's >> ATA controller. >=20 > Have you considered adding code to disable the I/O or memory range = instead of=20 > writing 0 to the bar in this case? I tried that once upon a time, but was problematical with some bridges = that had BARs at non-standard locations that needed the I/O or MEM bit = set in order to work... Warner From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:22:04 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AD30C1065670; Fri, 4 May 2012 18:22:04 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8B3DF8FC0A; Fri, 4 May 2012 18:22:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q44IM43i082553; Fri, 4 May 2012 18:22:04 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q44IM4ET082552; Fri, 4 May 2012 18:22:04 GMT (envelope-from bapt@FreeBSD.org) X-Authentication-Warning: freefall.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f Date: Fri, 4 May 2012 20:22:00 +0200 From: Baptiste Daroussin To: Garrett Cooper Message-ID: <20120504182200.GD1604@azathoth.lan> References: <201205041531.q44FVaYF010236@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bajzpZikUji1w+G9" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Josh Paetzel , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:22:04 -0000 --bajzpZikUji1w+G9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 04, 2012 at 09:33:38AM -0700, Garrett Cooper wrote: > On May 4, 2012, at 8:31 AM, Josh Paetzel wrote: >=20 > > Author: jpaetzel > > Date: Fri May 4 15:31:35 2012 > > New Revision: 235005 > > URL: http://svn.freebsd.org/changeset/base/235005 > >=20 > > Log: > > Use a unique zpool name during install, in the case of having another > > PC-BSD / FreeBSD zpool on the system for another install. > >=20 > > Submitted by: kmoore > > Obtained from: PC-BSD > > MFC after: 3 days > > Sponsored by: iXsystems > >=20 > > Modified: > > head/usr.sbin/pc-sysinstall/backend/functions.sh > >=20 > > Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:2= 7:18 2012 (r235004) > > +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:3= 1:35 2012 (r235005) > > @@ -216,7 +216,7 @@ fetch_file() > >=20 > > fetch -s "${FETCHFILE}" >${SIZEFILE} > > SIZE=3D"`cat ${SIZEFILE}`" > > - SIZE=3D"`expr ${SIZE} / 1024`" > > + SIZE=3D$((SIZE/1024)) >=20 > Bug; should be '$SIZE/' No this is perfectly valid >=20 > > echo "FETCH: ${FETCHFILE}" > > echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} > >=20 > > @@ -276,11 +276,22 @@ get_zpool_name() > > else > > # Need to generate a zpool name for this device > > NUM=3D`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` > > - NEWNAME=3D"${BASENAME}${NUM}" > > + > > + # Is it used in another zpool? > > + while > > + z=3D1 > > + do >=20 > while : > do >=20 > Is better. >=20 > > + NEWNAME=3D"${BASENAME}${NUM}" > > + zpool import | grep -q "${NEWNAME}" > > + if [ $? -ne 0 ] ; then break ; fi >=20 > Please decompress the conditional. or=20 zpool import | grep -q "${NEWNAME}" && break btw this is potentially buggy if there is a zpool named: a${NEWNAME}b for example zpool import | grep -qw "${NEWNAME}" && break should be perhaps better >=20 > > + NUM=3D$((NUM+1)) >=20 > Another bug (see above). >=20 > Thanks, > -Garrett --bajzpZikUji1w+G9 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+kHkgACgkQ8kTtMUmk6EwriACfTQPvFz9qT2HdxyQZUj3FA7zX N5oAoISZGfdLeNb1eUn41wHOke1rrjRG =oi4X -----END PGP SIGNATURE----- --bajzpZikUji1w+G9-- From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:24:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AACA106566C; Fri, 4 May 2012 18:24:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44DAB8FC08; Fri, 4 May 2012 18:24:39 +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 q44IOdkF016993; Fri, 4 May 2012 18:24:39 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44IOdjw016990; Fri, 4 May 2012 18:24:39 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201205041824.q44IOdjw016990@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 4 May 2012 18:24:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235024 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:24:39 -0000 Author: jkim Date: Fri May 4 18:24:38 2012 New Revision: 235024 URL: http://svn.freebsd.org/changeset/base/235024 Log: Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may list CPUs in different orders, especially for disabled logical cores. Now we match ACPI IDs from the MADT with Processor objects, strictly order CPUs accordingly, and ignore disabled cores. This prevents us from executing methods for other CPUs, e. g., _PSS for disabled logical core, which may not exist. Unfortunately, it is known that there are a few systems with buggy BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To work around these problems Modified: head/share/man/man4/acpi.4 head/sys/dev/acpica/acpi.c Modified: head/share/man/man4/acpi.4 ============================================================================== --- head/share/man/man4/acpi.4 Fri May 4 18:23:03 2012 (r235023) +++ head/share/man/man4/acpi.4 Fri May 4 18:24:38 2012 (r235024) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 22, 2012 +.Dd May 4, 2012 .Dt ACPI 4 .Os .Sh NAME @@ -198,6 +198,11 @@ entry for access after boot. Enables loading of a custom ACPI DSDT. .It Va acpi_dsdt_name Name of the DSDT table to load, if loading is enabled. +.It Va debug.acpi.cpu_unordered +Do not use the MADT to match ACPI processor objects to CPUs. +This is needed on a few systems with a buggy BIOS that does not use +consistent processor IDs. +Default is 0 (disabled). .It Va debug.acpi.disabled Selectively disables portions of ACPI for debugging purposes. .It Va debug.acpi.interpreter_slack Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Fri May 4 18:23:03 2012 (r235023) +++ head/sys/dev/acpica/acpi.c Fri May 4 18:24:38 2012 (r235024) @@ -289,6 +289,13 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, reset_ &acpi_reset_clock, 1, "Reset system clock while resuming."); #endif +/* Allow users to ignore processor orders in MADT. */ +static int acpi_cpu_unordered; +TUNABLE_INT("debug.acpi.cpu_unordered", &acpi_cpu_unordered); +SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, + &acpi_cpu_unordered, 0, + "Do not use the MADT to match ACPI processor objects to CPUs."); + /* Allow users to override quirks. */ TUNABLE_INT("debug.acpi.quirks", &acpi_quirks); @@ -1856,11 +1863,15 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) { struct acpi_prw_data prw; + ACPI_BUFFER buf; + ACPI_OBJECT obj; ACPI_OBJECT_TYPE type; ACPI_HANDLE h; + struct pcpu *pc; device_t bus, child; char *handle_str; - int order; + u_int cpuid; + int order, unit; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -1898,6 +1909,31 @@ acpi_probe_child(ACPI_HANDLE handle, UIN case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: case ACPI_TYPE_POWER: + unit = -1; + if (type == ACPI_TYPE_PROCESSOR && acpi_cpu_unordered == 0) { + ACPI_STATUS s; + buf.Pointer = &obj; + buf.Length = sizeof(obj); + s = AcpiEvaluateObject(handle, NULL, NULL, &buf); + if (ACPI_SUCCESS(s)) { + CPU_FOREACH(cpuid) { + pc = pcpu_find(cpuid); + if (pc->pc_acpi_id == obj.Processor.ProcId) { + unit = cpuid; + if (bootverbose) + printf("ACPI: %s (ACPI ID %u) -> cpu%d\n", + handle_str, obj.Processor.ProcId, unit); + break; + } + } + if (unit == -1) { + if (bootverbose) + printf("ACPI: %s (ACPI ID %u) ignored\n", + handle_str, obj.Processor.ProcId); + break; + } + } + } /* * Create a placeholder device for this node. Sort the * placeholder so that the probe/attach passes will run @@ -1908,7 +1944,7 @@ acpi_probe_child(ACPI_HANDLE handle, UIN ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "scanning '%s'\n", handle_str)); order = level * 10 + ACPI_DEV_BASE_ORDER; acpi_probe_order(handle, &order); - child = BUS_ADD_CHILD(bus, order, NULL, -1); + child = BUS_ADD_CHILD(bus, order, NULL, unit); if (child == NULL) break; From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:29:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7D0FB106566B; Fri, 4 May 2012 18:29:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 677C78FC0A; Fri, 4 May 2012 18:29:33 +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 q44ITXgJ017180; Fri, 4 May 2012 18:29:33 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44ITXw0017177; Fri, 4 May 2012 18:29:33 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205041829.q44ITXw0017177@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 18:29:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235025 - vendor/netcat/dist X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:29:33 -0000 Author: delphij Date: Fri May 4 18:29:32 2012 New Revision: 235025 URL: http://svn.freebsd.org/changeset/base/235025 Log: Vendor import of netcat as of OPENBSD_5_1. Modified: vendor/netcat/dist/nc.1 vendor/netcat/dist/netcat.c Modified: vendor/netcat/dist/nc.1 ============================================================================== --- vendor/netcat/dist/nc.1 Fri May 4 18:24:38 2012 (r235024) +++ vendor/netcat/dist/nc.1 Fri May 4 18:29:32 2012 (r235025) @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.57 2011/01/09 22:16:46 jeremy Exp $ +.\" $OpenBSD: nc.1,v 1.60 2012/02/07 12:11:43 lum Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 8 2011 $ +.Dd $Mdocdate: October 4 2011 $ .Dt NC 1 .Os .Sh NAME @@ -41,7 +41,7 @@ .Op Fl P Ar proxy_username .Op Fl p Ar source_port .Op Fl s Ar source -.Op Fl T Ar ToS +.Op Fl T Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar timeout .Op Fl X Ar proxy_protocol @@ -164,14 +164,21 @@ to create and use so that datagrams can It is an error to use this option in conjunction with the .Fl l option. -.It Fl T Ar ToS -Specifies IP Type of Service (ToS) for the connection. -Valid values are the tokens -.Dq lowdelay , -.Dq throughput , -.Dq reliability , -or an 8-bit hexadecimal value preceded by -.Dq 0x . +.It Fl T Ar toskeyword +Change IPv4 TOS value. +.Ar toskeyword +may be one of +.Ar critical , +.Ar inetcontrol , +.Ar lowdelay , +.Ar netcontrol , +.Ar throughput , +.Ar reliability , +or one of the DiffServ Code Points: +.Ar ef , +.Ar af11 ... af43 , +.Ar cs0 ... cs7 ; +or a number in either hex or decimal. .It Fl t Causes .Nm @@ -203,9 +210,9 @@ Have .Nm give more verbose output. .It Fl w Ar timeout -If a connection and stdin are idle for more than +Connections which cannot be established or are idle timeout after .Ar timeout -seconds, then the connection is silently closed. +seconds. The .Fl w flag has no effect on the @@ -442,8 +449,15 @@ Original implementation by *Hobbit* Rewritten with IPv6 support by .An Eric Jackson Aq ericj@monkey.org . .Sh CAVEATS -UDP port scans will always succeed -(i.e. report the port as open), -rendering the +UDP port scans using the .Fl uz -combination of flags relatively useless. +combination of flags will always report success irrespective of +the target machine's state. +However, +in conjunction with a traffic sniffer either on the target machine +or an intermediary device, +the +.Fl uz +combination could be useful for communications diagnostics. +Note that the amount of UDP traffic generated may be limited either +due to hardware resources and/or configuration settings. Modified: vendor/netcat/dist/netcat.c ============================================================================== --- vendor/netcat/dist/netcat.c Fri May 4 18:24:38 2012 (r235024) +++ vendor/netcat/dist/netcat.c Fri May 4 18:29:32 2012 (r235025) @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.101 2011/06/21 17:31:07 mikeb Exp $ */ +/* $OpenBSD: netcat.c,v 1.105 2012/02/09 06:25:35 lum Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -98,6 +98,7 @@ void help(void); int local_listen(char *, char *, struct addrinfo); void readwrite(int); int remote_connect(const char *, const char *, struct addrinfo); +int timeout_connect(int, const struct sockaddr *, socklen_t); int socks_connect(const char *, const char *, struct addrinfo, const char *, const char *, struct addrinfo, int, const char *); int udptest(int); @@ -105,7 +106,7 @@ int unix_bind(char *); int unix_connect(char *); int unix_listen(char *); void set_common_sockopts(int); -int parse_iptos(char *); +int map_tos(char *, int *); void usage(int); int @@ -234,7 +235,18 @@ main(int argc, char *argv[]) Sflag = 1; break; case 'T': - Tflag = parse_iptos(optarg); + errstr = NULL; + errno = 0; + if (map_tos(optarg, &Tflag)) + break; + if (strlen(optarg) > 1 && optarg[0] == '0' && + optarg[1] == 'x') + Tflag = (int)strtol(optarg, NULL, 16); + else + Tflag = (int)strtonum(optarg, 0, 255, + &errstr); + if (Tflag < 0 || Tflag > 255 || errstr || errno) + errx(1, "illegal tos value %s", optarg); break; default: usage(1); @@ -579,7 +591,7 @@ remote_connect(const char *host, const c set_common_sockopts(s); - if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) + if (timeout_connect(s, res0->ai_addr, res0->ai_addrlen) == 0) break; else if (vflag) warn("connect to %s port %s (%s) failed", host, port, @@ -594,6 +606,43 @@ remote_connect(const char *host, const c return (s); } +int +timeout_connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct pollfd pfd; + socklen_t optlen; + int flags, optval; + int ret; + + if (timeout != -1) { + flags = fcntl(s, F_GETFL, 0); + if (fcntl(s, F_SETFL, flags | O_NONBLOCK) == -1) + err(1, "set non-blocking mode"); + } + + if ((ret = connect(s, name, namelen)) != 0 && errno == EINPROGRESS) { + pfd.fd = s; + pfd.events = POLLOUT; + if ((ret = poll(&pfd, 1, timeout)) == 1) { + optlen = sizeof(optval); + if ((ret = getsockopt(s, SOL_SOCKET, SO_ERROR, + &optval, &optlen)) == 0) { + errno = optval; + ret = optval == 0 ? 0 : -1; + } + } else if (ret == 0) { + errno = ETIMEDOUT; + ret = -1; + } else + err(1, "poll failed"); + } + + if (timeout != -1 && fcntl(s, F_SETFL, flags) == -1) + err(1, "restoring flags"); + + return (ret); +} + /* * local_listen() * Returns a socket listening on a local port, binds to specified source @@ -753,7 +802,7 @@ atelnet(int nfd, unsigned char *buf, uns /* * build_ports() - * Build an array or ports in portlist[], listing each port + * Build an array of ports in portlist[], listing each port * that we should try to connect to. */ void @@ -765,9 +814,6 @@ build_ports(char *p) int x = 0; if ((n = strchr(p, '-')) != NULL) { - if (lflag) - errx(1, "Cannot use -l with multiple ports!"); - *n = '\0'; n++; @@ -819,8 +865,7 @@ build_ports(char *p) /* * udptest() * Do a few writes to see if the UDP port is there. - * XXX - Better way of doing this? Doesn't work for IPv6. - * Also fails after around 100 ports checked. + * Fails once PF state table is full. */ int udptest(int s) @@ -874,20 +919,51 @@ set_common_sockopts(int s) } int -parse_iptos(char *s) +map_tos(char *s, int *val) { - int tos = -1; + /* DiffServ Codepoints and other TOS mappings */ + const struct toskeywords { + const char *keyword; + int val; + } *t, toskeywords[] = { + { "af11", IPTOS_DSCP_AF11 }, + { "af12", IPTOS_DSCP_AF12 }, + { "af13", IPTOS_DSCP_AF13 }, + { "af21", IPTOS_DSCP_AF21 }, + { "af22", IPTOS_DSCP_AF22 }, + { "af23", IPTOS_DSCP_AF23 }, + { "af31", IPTOS_DSCP_AF31 }, + { "af32", IPTOS_DSCP_AF32 }, + { "af33", IPTOS_DSCP_AF33 }, + { "af41", IPTOS_DSCP_AF41 }, + { "af42", IPTOS_DSCP_AF42 }, + { "af43", IPTOS_DSCP_AF43 }, + { "critical", IPTOS_PREC_CRITIC_ECP }, + { "cs0", IPTOS_DSCP_CS0 }, + { "cs1", IPTOS_DSCP_CS1 }, + { "cs2", IPTOS_DSCP_CS2 }, + { "cs3", IPTOS_DSCP_CS3 }, + { "cs4", IPTOS_DSCP_CS4 }, + { "cs5", IPTOS_DSCP_CS5 }, + { "cs6", IPTOS_DSCP_CS6 }, + { "cs7", IPTOS_DSCP_CS7 }, + { "ef", IPTOS_DSCP_EF }, + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, + { "lowdelay", IPTOS_LOWDELAY }, + { "netcontrol", IPTOS_PREC_NETCONTROL }, + { "reliability", IPTOS_RELIABILITY }, + { "throughput", IPTOS_THROUGHPUT }, + { NULL, -1 }, + }; + + for (t = toskeywords; t->keyword != NULL; t++) { + if (strcmp(s, t->keyword) == 0) { + *val = t->val; + return (1); + } + } - if (strcmp(s, "lowdelay") == 0) - return (IPTOS_LOWDELAY); - if (strcmp(s, "throughput") == 0) - return (IPTOS_THROUGHPUT); - if (strcmp(s, "reliability") == 0) - return (IPTOS_RELIABILITY); - - if (sscanf(s, "0x%x", &tos) != 1 || tos < 0 || tos > 0xff) - errx(1, "invalid IP Type of Service"); - return (tos); + return (0); } void @@ -911,7 +987,7 @@ help(void) \t-r Randomize remote ports\n\ \t-S Enable the TCP MD5 signature option\n\ \t-s addr\t Local source address\n\ - \t-T ToS\t Set IP Type of Service\n\ + \t-T toskeyword\tSet IP Type of Service\n\ \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\ \t-u UDP mode\n\ From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:29:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 544A6106564A; Fri, 4 May 2012 18:29:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CAEF88FC0C; Fri, 4 May 2012 18:29:35 +0000 (UTC) Message-ID: <4FA4200F.6010300@FreeBSD.org> Date: Fri, 04 May 2012 14:29:35 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120502 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jung-uk Kim References: <201205041824.q44IOdjw016990@svn.freebsd.org> In-Reply-To: <201205041824.q44IOdjw016990@svn.freebsd.org> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r235024 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:29:36 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-05-04 14:24:39 -0400, Jung-uk Kim wrote: > Author: jkim Date: Fri May 4 18:24:38 2012 New Revision: 235024 > URL: http://svn.freebsd.org/changeset/base/235024 > > Log: Use MADT to match ACPI Processor objects to CPUs. MADT and > DSDT/SSDTs may list CPUs in different orders, especially for > disabled logical cores. Now we match ACPI IDs from the MADT with > Processor objects, strictly order CPUs accordingly, and ignore > disabled cores. This prevents us from executing methods for other > CPUs, e. g., _PSS for disabled logical core, which may not exist. > Unfortunately, it is known that there are a few systems with buggy > BIOSes that do not have unique ACPI IDs for MADT and Processor > objects. To work around these problems , 'debug.acpi.cpu_unordered' tunable is added. Set this to non-zero value to restore the old behavior. Sorry, the commit message was incomplete. How do I fix it? Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+kIA8ACgkQmlay1b9qnVM8dQCg1D1cQhd0zLkTD3/uWzFOSI4u Ph4AoL1QzIgRmp4JduHpJaPlP3i64s84 =bXd0 -----END PGP SIGNATURE----- From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:30:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C0A33106568A; Fri, 4 May 2012 18:30:40 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 913E88FC15; Fri, 4 May 2012 18:30:40 +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 q44IUe9m017255; Fri, 4 May 2012 18:30:40 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44IUeTD017254; Fri, 4 May 2012 18:30:40 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205041830.q44IUeTD017254@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 18:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235026 - vendor/netcat/5.1 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:30:40 -0000 Author: delphij Date: Fri May 4 18:30:40 2012 New Revision: 235026 URL: http://svn.freebsd.org/changeset/base/235026 Log: Tag netcat from OpenBSD 5.1. Added: vendor/netcat/5.1/ - copied from r235025, vendor/netcat/dist/ From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:54:52 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B709106566B; Fri, 4 May 2012 18:54:52 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C8038FC08; Fri, 4 May 2012 18:54:52 +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 q44IsqsD018090; Fri, 4 May 2012 18:54:52 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44IsqJ8018087; Fri, 4 May 2012 18:54:52 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201205041854.q44IsqJ8018087@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 4 May 2012 18:54:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235029 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:54:52 -0000 Author: jkim Date: Fri May 4 18:54:51 2012 New Revision: 235029 URL: http://svn.freebsd.org/changeset/base/235029 Log: Complete commit message for r235024: Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may list CPUs in different orders, especially for disabled logical cores. Now we match ACPI IDs from the MADT with Processor objects, strictly order CPUs accordingly, and ignore disabled cores. This prevents us from executing methods for other CPUs, e. g., _PSS for disabled logical core, which may not exist. Unfortunately, it is known that there are a few systems with buggy BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To work around these problems, 'debug.acpi.cpu_unordered' tunable is added. Set this to a non-zero value to restore the old behavior. Many thanks to jhb for pointing me to the right direction and the manual page change. Reported by: Harris, James R (james dot r dot harris at intel dot com) Tested by: Harris, James R (james dot r dot harris at intel dot com) Reviewed by: jhb MFC after: 1 month Modified: head/share/man/man4/acpi.4 head/sys/dev/acpica/acpi.c Modified: head/share/man/man4/acpi.4 ============================================================================== --- head/share/man/man4/acpi.4 Fri May 4 18:36:00 2012 (r235028) +++ head/share/man/man4/acpi.4 Fri May 4 18:54:51 2012 (r235029) @@ -199,7 +199,7 @@ Enables loading of a custom ACPI DSDT. .It Va acpi_dsdt_name Name of the DSDT table to load, if loading is enabled. .It Va debug.acpi.cpu_unordered -Do not use the MADT to match ACPI processor objects to CPUs. +Do not use the MADT to match ACPI Processor objects to CPUs. This is needed on a few systems with a buggy BIOS that does not use consistent processor IDs. Default is 0 (disabled). Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Fri May 4 18:36:00 2012 (r235028) +++ head/sys/dev/acpica/acpi.c Fri May 4 18:54:51 2012 (r235029) @@ -294,7 +294,7 @@ static int acpi_cpu_unordered; TUNABLE_INT("debug.acpi.cpu_unordered", &acpi_cpu_unordered); SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, &acpi_cpu_unordered, 0, - "Do not use the MADT to match ACPI processor objects to CPUs."); + "Do not use the MADT to match ACPI Processor objects to CPUs."); /* Allow users to override quirks. */ TUNABLE_INT("debug.acpi.quirks", &acpi_quirks); From owner-svn-src-all@FreeBSD.ORG Fri May 4 18:59:29 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CDE53106566B; Fri, 4 May 2012 18:59:29 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id 7DACC8FC16; Fri, 4 May 2012 18:59:29 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id C9B12A24; Fri, 4 May 2012 20:59:27 +0200 (CEST) Date: Fri, 4 May 2012 20:57:46 +0200 From: Pawel Jakub Dawidek To: Eitan Adler Message-ID: <20120504185743.GA1397@garage.freebsd.pl> References: <201203242110.q2OLAJSZ049045@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gKMricLos+KVdGMg" Content-Disposition: inline In-Reply-To: <201203242110.q2OLAJSZ049045@svn.freebsd.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r233435 - head/etc/mtree X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:59:29 -0000 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 24, 2012 at 09:10:19PM +0000, Eitan Adler wrote: > Author: eadler > Date: Sat Mar 24 21:10:19 2012 > New Revision: 233435 > URL: http://svn.freebsd.org/changeset/base/233435 >=20 > Log: > Fix build by adding new directory to mtree in r233429 > =20 > Submitted by: flo > Approved by: cperciva > MFC after: 1 week >=20 > Modified: > head/etc/mtree/BSD.usr.dist >=20 > Modified: head/etc/mtree/BSD.usr.dist > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/etc/mtree/BSD.usr.dist Sat Mar 24 19:59:14 2012 (r233434) > +++ head/etc/mtree/BSD.usr.dist Sat Mar 24 21:10:19 2012 (r233435) > @@ -209,6 +209,8 @@ > .. > bootforth > .. > + csh > + .. > cvs You need to use only spaces in this file for indentation just like in all the other lines. That's a shame it was merged into 7, 8 and 9. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --gKMricLos+KVdGMg Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+kJqYACgkQForvXbEpPzTVGwCfelXiwNt0tO5qyicbwKLj2s2c SGwAniXuZPotFQwUMzIHeHHtXmu14vm1 =OPaQ -----END PGP SIGNATURE----- --gKMricLos+KVdGMg-- From owner-svn-src-all@FreeBSD.ORG Fri May 4 19:47:56 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E15021065674; Fri, 4 May 2012 19:47:56 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe08.c2i.net [212.247.154.226]) by mx1.freebsd.org (Postfix) with ESMTP id 9BD2F8FC15; Fri, 4 May 2012 19:47:55 +0000 (UTC) X-T2-Spam-Status: No, hits=-1.0 required=5.0 tests=ALL_TRUSTED Received: from [176.74.212.201] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe08.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 271298319; Fri, 04 May 2012 21:42:45 +0200 From: Hans Petter Selasky To: Warner Losh Date: Fri, 4 May 2012 21:41:55 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.3-STABLE; KDE/4.4.5; amd64; ; ) References: <201205041538.q44FclqK010547@svn.freebsd.org> <201205041826.19435.hselasky@c2i.net> In-Reply-To: X-Face: 'mmZ:T{)),Oru^0c+/}w'`gU1$ubmG?lp!=R4Wy\ELYo2)@'UZ24N@d2+AyewRX}mAm; Yp |U[@, _z/([?1bCfM{_"B<.J>mICJCHAzzGHI{y7{%JVz%R~yJHIji`y>Y}k1C4TfysrsUI -%GU9V5]iUZF&nRn9mJ'?&>O MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201205042141.55089.hselasky@c2i.net> Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" , John Baldwin Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 19:47:57 -0000 On Friday 04 May 2012 19:18:56 Warner Losh wrote: > On May 4, 2012, at 10:26 AM, Hans Petter Selasky wrote: > > On Friday 04 May 2012 18:14:16 John Baldwin wrote: > >> On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: > >>> Author: hselasky > >>> Date: Fri May 4 15:38:47 2012 > >>> New Revision: 235007 > >>> URL: http://svn.freebsd.org/changeset/base/235007 > >>> > >>> Log: > >>> MFC r233662, r233677 and r233678: > >>> > >>> Writing zero to BAR actually does not disable it and > >>> it is even harmful as hselasky found out. Historically, > >>> this code was originated from (OLDCARD) CardBus driver and later > >>> leaked into PCI driver when CardBus was newbus'ified and refactored > >>> with PCI driver. However, it is not really necessary even for > >>> CardBus. > >> > >> FYI, I've got one bug report on HEAD where these changes broke a > >> machine's ATA controller. > > > > Have you considered adding code to disable the I/O or memory range > > instead of writing 0 to the bar in this case? > > I tried that once upon a time, but was problematical with some bridges that > had BARs at non-standard locations that needed the I/O or MEM bit set in > order to work... > > Warner If the size of the bar is a few megabytes, then moving it to location 0 is definitely wrong. Else it might work! --HPS From owner-svn-src-all@FreeBSD.ORG Fri May 4 19:49:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A2100106564A; Fri, 4 May 2012 19:49:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D8C38FC0A; Fri, 4 May 2012 19:49: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 q44JnOmk020197; Fri, 4 May 2012 19:49:24 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44JnO2L020195; Fri, 4 May 2012 19:49:24 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201205041949.q44JnO2L020195@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 4 May 2012 19:49: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: r235033 - head/sbin/geom/class/part X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 19:49:24 -0000 Author: ae Date: Fri May 4 19:49:24 2012 New Revision: 235033 URL: http://svn.freebsd.org/changeset/base/235033 Log: Don't ignore start offset value when user specifies it together with alignment. PR: bin/167567 Tested by: Warren Block MFC after: 1 week Modified: head/sbin/geom/class/part/geom_part.c Modified: head/sbin/geom/class/part/geom_part.c ============================================================================== --- head/sbin/geom/class/part/geom_part.c Fri May 4 19:44:58 2012 (r235032) +++ head/sbin/geom/class/part/geom_part.c Fri May 4 19:49:24 2012 (r235033) @@ -507,6 +507,8 @@ gpart_autofill(struct gctl_req *req) grade = ~0ULL; a_first = ALIGNUP(first + offset, alignment); last = ALIGNDOWN(last + offset, alignment); + if (a_first < start) + a_first = start; while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); lba = (off_t)strtoimax(s, NULL, 0); @@ -536,7 +538,8 @@ gpart_autofill(struct gctl_req *req) s = find_provcfg(pp, "end"); first = (off_t)strtoimax(s, NULL, 0) + 1; - a_first = ALIGNUP(first + offset, alignment); + if (first > a_first) + a_first = ALIGNUP(first + offset, alignment); } if (a_first <= last) { /* Free space [first-last] */ From owner-svn-src-all@FreeBSD.ORG Fri May 4 20:15:02 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id A54481065675; Fri, 4 May 2012 20:15:02 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from [127.0.0.1] (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id B424C14DB89; Fri, 4 May 2012 20:15:00 +0000 (UTC) Message-ID: <4FA438C4.3080701@FreeBSD.org> Date: Fri, 04 May 2012 13:15:00 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 To: Baptiste Daroussin References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> In-Reply-To: <20120504182200.GD1604@azathoth.lan> X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "src-committers@freebsd.org" , Garrett Cooper , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" , "kmoore@freebsd.org" , Josh Paetzel Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 20:15:02 -0000 On 05/04/2012 11:22 AM, Baptiste Daroussin wrote: >>> > > fetch -s "${FETCHFILE}" >${SIZEFILE} >>> > > SIZE="`cat ${SIZEFILE}`" >>> > > - SIZE="`expr ${SIZE} / 1024`" >>> > > + SIZE=$((SIZE/1024)) >> > >> > Bug; should be '$SIZE/' > No this is perfectly valid Yes, that works, but it's not our usual style. However, the point is moot as that whole block should be reduced down to: SIZE=$(( `fetch -s "${FETCHFILE}"` / 1024 )) If SIZEFILE is needed elsewhere that's a different matter, but as it is that's a hot mess. From owner-svn-src-all@FreeBSD.ORG Fri May 4 20:31:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CA92106564A; Fri, 4 May 2012 20:31:27 +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 8812B8FC0C; Fri, 4 May 2012 20:31: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 q44KVRrd021549; Fri, 4 May 2012 20:31:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44KVRZr021547; Fri, 4 May 2012 20:31:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205042031.q44KVRZr021547@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 May 2012 20:31: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: r235034 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 20:31:27 -0000 Author: adrian Date: Fri May 4 20:31:27 2012 New Revision: 235034 URL: http://svn.freebsd.org/changeset/base/235034 Log: Fix a couple of sc_ac2q[] mappings that were using the TID, not the AC. PR: kern/167588 Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Fri May 4 19:49:24 2012 (r235033) +++ head/sys/dev/ath/if_ath_tx.c Fri May 4 20:31:27 2012 (r235034) @@ -4307,9 +4307,9 @@ ath_addba_request(struct ieee80211_node * it'll be "after" the left edge of the BAW and thus it'll * fall within it. */ - ATH_TXQ_LOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_pause(sc, atid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n", @@ -4395,9 +4395,9 @@ ath_addba_stop(struct ieee80211_node *ni DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); /* Pause TID traffic early, so there aren't any races */ - ATH_TXQ_LOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_pause(sc, atid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); /* There's no need to hold the TXQ lock here */ sc->sc_addba_stop(ni, tap); From owner-svn-src-all@FreeBSD.ORG Fri May 4 20:45:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 595DA1065673; Fri, 4 May 2012 20:45:54 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 443428FC12; Fri, 4 May 2012 20:45: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 q44KjrJ7022033; Fri, 4 May 2012 20:45:53 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Kjrs8022031; Fri, 4 May 2012 20:45:53 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201205042045.q44Kjrs8022031@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 4 May 2012 20:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235035 - stable/9/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 20:45:54 -0000 Author: jilles Date: Fri May 4 20:45:53 2012 New Revision: 235035 URL: http://svn.freebsd.org/changeset/base/235035 Log: MFC r234057: sem_open: Make sure to fail an O_CREAT|O_EXCL open, even if that semaphore is already open in this process. If the named semaphore is already open, sem_open() only increments a reference count and did not take the flags into account (which otherwise happens by passing them to open()). Add an extra check for O_CREAT|O_EXCL. PR: kern/166706 Modified: stable/9/lib/libc/gen/sem_new.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/gen/sem_new.c ============================================================================== --- stable/9/lib/libc/gen/sem_new.c Fri May 4 20:31:27 2012 (r235034) +++ stable/9/lib/libc/gen/sem_new.c Fri May 4 20:45:53 2012 (r235035) @@ -162,10 +162,16 @@ _sem_open(const char *name, int flags, . _pthread_mutex_lock(&sem_llock); LIST_FOREACH(ni, &sem_list, next) { if (strcmp(name, ni->name) == 0) { - ni->open_count++; - sem = ni->sem; - _pthread_mutex_unlock(&sem_llock); - return (sem); + if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) { + _pthread_mutex_unlock(&sem_llock); + errno = EEXIST; + return (SEM_FAILED); + } else { + ni->open_count++; + sem = ni->sem; + _pthread_mutex_unlock(&sem_llock); + return (sem); + } } } From owner-svn-src-all@FreeBSD.ORG Fri May 4 21:00:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22DD2106564A; Fri, 4 May 2012 21:00:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E55D8FC1A; Fri, 4 May 2012 21:00:33 +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 q44L0Wog022597; Fri, 4 May 2012 21:00:32 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L0WZJ022595; Fri, 4 May 2012 21:00:32 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042100.q44L0WZJ022595@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:00:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235036 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:00:33 -0000 Author: delphij Date: Fri May 4 21:00:32 2012 New Revision: 235036 URL: http://svn.freebsd.org/changeset/base/235036 Log: Add ToS definitions for DiffServ Codepoints as per RFC2474. Obtained from: OpenBSD MFC after: 2 weeks Modified: head/sys/netinet/ip.h Modified: head/sys/netinet/ip.h ============================================================================== --- head/sys/netinet/ip.h Fri May 4 20:45:53 2012 (r235035) +++ head/sys/netinet/ip.h Fri May 4 21:00:32 2012 (r235036) @@ -92,6 +92,31 @@ struct ip { #define IPTOS_PREC_ROUTINE 0x00 /* + * Definitions for DiffServ Codepoints as per RFC2474 + */ +#define IPTOS_DSCP_CS0 0x00 +#define IPTOS_DSCP_CS1 0x20 +#define IPTOS_DSCP_AF11 0x28 +#define IPTOS_DSCP_AF12 0x30 +#define IPTOS_DSCP_AF13 0x38 +#define IPTOS_DSCP_CS2 0x40 +#define IPTOS_DSCP_AF21 0x48 +#define IPTOS_DSCP_AF22 0x50 +#define IPTOS_DSCP_AF23 0x58 +#define IPTOS_DSCP_CS3 0x60 +#define IPTOS_DSCP_AF31 0x68 +#define IPTOS_DSCP_AF32 0x70 +#define IPTOS_DSCP_AF33 0x78 +#define IPTOS_DSCP_CS4 0x80 +#define IPTOS_DSCP_AF41 0x88 +#define IPTOS_DSCP_AF42 0x90 +#define IPTOS_DSCP_AF43 0x98 +#define IPTOS_DSCP_CS5 0xa0 +#define IPTOS_DSCP_EF 0xb8 +#define IPTOS_DSCP_CS6 0xc0 +#define IPTOS_DSCP_CS7 0xe0 + +/* * ECN (Explicit Congestion Notification) codepoints in RFC3168 mapped to the * lower 2 bits of the TOS field. */ From owner-svn-src-all@FreeBSD.ORG Fri May 4 21:03:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD6E8106564A; Fri, 4 May 2012 21:03:39 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7C918FC0C; Fri, 4 May 2012 21:03:39 +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 q44L3dNg022750; Fri, 4 May 2012 21:03:39 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L3dgo022747; Fri, 4 May 2012 21:03:39 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042103.q44L3dgo022747@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:03:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235037 - head/contrib/netcat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:03:40 -0000 Author: delphij Date: Fri May 4 21:03:39 2012 New Revision: 235037 URL: http://svn.freebsd.org/changeset/base/235037 Log: Merge from OpenBSD 5.1. MFC after: 3 weeks Modified: head/contrib/netcat/nc.1 head/contrib/netcat/netcat.c Directory Properties: head/contrib/netcat/ (props changed) Modified: head/contrib/netcat/nc.1 ============================================================================== --- head/contrib/netcat/nc.1 Fri May 4 21:00:32 2012 (r235036) +++ head/contrib/netcat/nc.1 Fri May 4 21:03:39 2012 (r235037) @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.57 2011/01/09 22:16:46 jeremy Exp $ +.\" $OpenBSD: nc.1,v 1.60 2012/02/07 12:11:43 lum Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 8, 2011 +.Dd October 4, 2011 .Dt NC 1 .Os .Sh NAME @@ -45,7 +45,7 @@ .Op Fl P Ar proxy_username .Op Fl p Ar source_port .Op Fl s Ar source -.Op Fl T Ar ToS +.Op Fl T Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar timeout .Op Fl X Ar proxy_protocol @@ -186,14 +186,21 @@ to create and use so that datagrams can It is an error to use this option in conjunction with the .Fl l option. -.It Fl T Ar ToS -Specifies IP Type of Service (ToS) for the connection. -Valid values are the tokens -.Dq lowdelay , -.Dq throughput , -.Dq reliability , -or an 8-bit hexadecimal value preceded by -.Dq 0x . +.It Fl T Ar toskeyword +Change IPv4 TOS value. +.Ar toskeyword +may be one of +.Ar critical , +.Ar inetcontrol , +.Ar lowdelay , +.Ar netcontrol , +.Ar throughput , +.Ar reliability , +or one of the DiffServ Code Points: +.Ar ef , +.Ar af11 ... af43 , +.Ar cs0 ... cs7 ; +or a number in either hex or decimal. .It Fl t Causes .Nm @@ -227,9 +234,9 @@ Have .Nm give more verbose output. .It Fl w Ar timeout -If a connection and stdin are idle for more than +Connections which cannot be established or are idle timeout after .Ar timeout -seconds, then the connection is silently closed. +seconds. The .Fl w flag has no effect on the @@ -480,8 +487,15 @@ Original implementation by *Hobbit* Rewritten with IPv6 support by .An Eric Jackson Aq ericj@monkey.org . .Sh CAVEATS -UDP port scans will always succeed -(i.e. report the port as open), -rendering the +UDP port scans using the .Fl uz -combination of flags relatively useless. +combination of flags will always report success irrespective of +the target machine's state. +However, +in conjunction with a traffic sniffer either on the target machine +or an intermediary device, +the +.Fl uz +combination could be useful for communications diagnostics. +Note that the amount of UDP traffic generated may be limited either +due to hardware resources and/or configuration settings. Modified: head/contrib/netcat/netcat.c ============================================================================== --- head/contrib/netcat/netcat.c Fri May 4 21:00:32 2012 (r235036) +++ head/contrib/netcat/netcat.c Fri May 4 21:03:39 2012 (r235037) @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.101 2011/06/21 17:31:07 mikeb Exp $ */ +/* $OpenBSD: netcat.c,v 1.105 2012/02/09 06:25:35 lum Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -107,6 +107,7 @@ void help(void); int local_listen(char *, char *, struct addrinfo); void readwrite(int); int remote_connect(const char *, const char *, struct addrinfo); +int timeout_connect(int, const struct sockaddr *, socklen_t); int socks_connect(const char *, const char *, struct addrinfo, const char *, const char *, struct addrinfo, int, const char *); int udptest(int); @@ -114,7 +115,7 @@ int unix_bind(char *); int unix_connect(char *); int unix_listen(char *); void set_common_sockopts(int); -int parse_iptos(char *); +int map_tos(char *, int *); void usage(int); #ifdef IPSEC @@ -281,7 +282,18 @@ main(int argc, char *argv[]) Sflag = 1; break; case 'T': - Tflag = parse_iptos(optarg); + errstr = NULL; + errno = 0; + if (map_tos(optarg, &Tflag)) + break; + if (strlen(optarg) > 1 && optarg[0] == '0' && + optarg[1] == 'x') + Tflag = (int)strtol(optarg, NULL, 16); + else + Tflag = (int)strtonum(optarg, 0, 255, + &errstr); + if (Tflag < 0 || Tflag > 255 || errstr || errno) + errx(1, "illegal tos value %s", optarg); break; default: usage(1); @@ -633,7 +645,7 @@ remote_connect(const char *host, const c set_common_sockopts(s); - if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) + if (timeout_connect(s, res0->ai_addr, res0->ai_addrlen) == 0) break; else if (vflag) warn("connect to %s port %s (%s) failed", host, port, @@ -648,6 +660,43 @@ remote_connect(const char *host, const c return (s); } +int +timeout_connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct pollfd pfd; + socklen_t optlen; + int flags, optval; + int ret; + + if (timeout != -1) { + flags = fcntl(s, F_GETFL, 0); + if (fcntl(s, F_SETFL, flags | O_NONBLOCK) == -1) + err(1, "set non-blocking mode"); + } + + if ((ret = connect(s, name, namelen)) != 0 && errno == EINPROGRESS) { + pfd.fd = s; + pfd.events = POLLOUT; + if ((ret = poll(&pfd, 1, timeout)) == 1) { + optlen = sizeof(optval); + if ((ret = getsockopt(s, SOL_SOCKET, SO_ERROR, + &optval, &optlen)) == 0) { + errno = optval; + ret = optval == 0 ? 0 : -1; + } + } else if (ret == 0) { + errno = ETIMEDOUT; + ret = -1; + } else + err(1, "poll failed"); + } + + if (timeout != -1 && fcntl(s, F_SETFL, flags) == -1) + err(1, "restoring flags"); + + return (ret); +} + /* * local_listen() * Returns a socket listening on a local port, binds to specified source @@ -818,7 +867,7 @@ atelnet(int nfd, unsigned char *buf, uns /* * build_ports() - * Build an array or ports in portlist[], listing each port + * Build an array of ports in portlist[], listing each port * that we should try to connect to. */ void @@ -830,9 +879,6 @@ build_ports(char *p) int x = 0; if ((n = strchr(p, '-')) != NULL) { - if (lflag) - errx(1, "Cannot use -l with multiple ports!"); - *n = '\0'; n++; @@ -884,8 +930,7 @@ build_ports(char *p) /* * udptest() * Do a few writes to see if the UDP port is there. - * XXX - Better way of doing this? Doesn't work for IPv6. - * Also fails after around 100 ports checked. + * Fails once PF state table is full. */ int udptest(int s) @@ -946,20 +991,51 @@ set_common_sockopts(int s) } int -parse_iptos(char *s) +map_tos(char *s, int *val) { - int tos = -1; + /* DiffServ Codepoints and other TOS mappings */ + const struct toskeywords { + const char *keyword; + int val; + } *t, toskeywords[] = { + { "af11", IPTOS_DSCP_AF11 }, + { "af12", IPTOS_DSCP_AF12 }, + { "af13", IPTOS_DSCP_AF13 }, + { "af21", IPTOS_DSCP_AF21 }, + { "af22", IPTOS_DSCP_AF22 }, + { "af23", IPTOS_DSCP_AF23 }, + { "af31", IPTOS_DSCP_AF31 }, + { "af32", IPTOS_DSCP_AF32 }, + { "af33", IPTOS_DSCP_AF33 }, + { "af41", IPTOS_DSCP_AF41 }, + { "af42", IPTOS_DSCP_AF42 }, + { "af43", IPTOS_DSCP_AF43 }, + { "critical", IPTOS_PREC_CRITIC_ECP }, + { "cs0", IPTOS_DSCP_CS0 }, + { "cs1", IPTOS_DSCP_CS1 }, + { "cs2", IPTOS_DSCP_CS2 }, + { "cs3", IPTOS_DSCP_CS3 }, + { "cs4", IPTOS_DSCP_CS4 }, + { "cs5", IPTOS_DSCP_CS5 }, + { "cs6", IPTOS_DSCP_CS6 }, + { "cs7", IPTOS_DSCP_CS7 }, + { "ef", IPTOS_DSCP_EF }, + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, + { "lowdelay", IPTOS_LOWDELAY }, + { "netcontrol", IPTOS_PREC_NETCONTROL }, + { "reliability", IPTOS_RELIABILITY }, + { "throughput", IPTOS_THROUGHPUT }, + { NULL, -1 }, + }; + + for (t = toskeywords; t->keyword != NULL; t++) { + if (strcmp(s, t->keyword) == 0) { + *val = t->val; + return (1); + } + } - if (strcmp(s, "lowdelay") == 0) - return (IPTOS_LOWDELAY); - if (strcmp(s, "throughput") == 0) - return (IPTOS_THROUGHPUT); - if (strcmp(s, "reliability") == 0) - return (IPTOS_RELIABILITY); - - if (sscanf(s, "0x%x", &tos) != 1 || tos < 0 || tos > 0xff) - errx(1, "invalid IP Type of Service"); - return (tos); + return (0); } void @@ -990,7 +1066,7 @@ help(void) \t-r Randomize remote ports\n\ \t-S Enable the TCP MD5 signature option\n\ \t-s addr\t Local source address\n\ - \t-T ToS\t Set IP Type of Service\n\ + \t-T toskeyword\tSet IP Type of Service\n\ \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\ \t-u UDP mode\n\ From owner-svn-src-all@FreeBSD.ORG Fri May 4 21:06:53 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E25E5106566C; Fri, 4 May 2012 21:06:53 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE31B8FC19; Fri, 4 May 2012 21:06: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 q44L6rrf022909; Fri, 4 May 2012 21:06:53 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L6rMa022907; Fri, 4 May 2012 21:06:53 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042106.q44L6rMa022907@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:06: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: r235038 - head/contrib/netcat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:06:54 -0000 Author: delphij Date: Fri May 4 21:06:53 2012 New Revision: 235038 URL: http://svn.freebsd.org/changeset/base/235038 Log: Update FREEBSD-vendor to reflect the current version. Modified: head/contrib/netcat/FREEBSD-vendor Modified: head/contrib/netcat/FREEBSD-vendor ============================================================================== --- head/contrib/netcat/FREEBSD-vendor Fri May 4 21:03:39 2012 (r235037) +++ head/contrib/netcat/FREEBSD-vendor Fri May 4 21:06:53 2012 (r235038) @@ -1,5 +1,5 @@ # $FreeBSD$ Project: netcat (aka src/usr.bin/nc in OpenBSD) ProjectURL: http://www.openbsd.org/ -Version: 4.7 +Version: 5.1 License: BSD From owner-svn-src-all@FreeBSD.ORG Fri May 4 21:31:01 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 853CE106564A; Fri, 4 May 2012 21:31:01 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 19A838FC16; Fri, 4 May 2012 21:31:01 +0000 (UTC) Received: from [10.30.101.53] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q44LPb8s034367 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 4 May 2012 15:25:39 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201205042141.55089.hselasky@c2i.net> Date: Fri, 4 May 2012 15:25:32 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <80963C87-6F37-4AC7-B5E8-132EC5F47D98@bsdimp.com> References: <201205041538.q44FclqK010547@svn.freebsd.org> <201205041826.19435.hselasky@c2i.net> <201205042141.55089.hselasky@c2i.net> To: Hans Petter Selasky X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 04 May 2012 15:25:40 -0600 (MDT) Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" , John Baldwin Subject: Re: svn commit: r235007 - stable/9/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:31:01 -0000 On May 4, 2012, at 1:41 PM, Hans Petter Selasky wrote: > On Friday 04 May 2012 19:18:56 Warner Losh wrote: >> On May 4, 2012, at 10:26 AM, Hans Petter Selasky wrote: >>> On Friday 04 May 2012 18:14:16 John Baldwin wrote: >>>> On Friday, May 04, 2012 11:38:47 am Hans Petter Selasky wrote: >>>>> Author: hselasky >>>>> Date: Fri May 4 15:38:47 2012 >>>>> New Revision: 235007 >>>>> URL: http://svn.freebsd.org/changeset/base/235007 >>>>>=20 >>>>> Log: >>>>> MFC r233662, r233677 and r233678: >>>>>=20 >>>>> Writing zero to BAR actually does not disable it and >>>>> it is even harmful as hselasky found out. Historically, >>>>> this code was originated from (OLDCARD) CardBus driver and later >>>>> leaked into PCI driver when CardBus was newbus'ified and = refactored >>>>> with PCI driver. However, it is not really necessary even for >>>>> CardBus. >>>>=20 >>>> FYI, I've got one bug report on HEAD where these changes broke a >>>> machine's ATA controller. >>>=20 >>> Have you considered adding code to disable the I/O or memory range >>> instead of writing 0 to the bar in this case? >>=20 >> I tried that once upon a time, but was problematical with some = bridges that >> had BARs at non-standard locations that needed the I/O or MEM bit set = in >> order to work... >>=20 >> Warner >=20 > If the size of the bar is a few megabytes, then moving it to location = 0 is=20 > definitely wrong. Else it might work! Only if the bridge passes the transactions for that memory to the PCI = bus for decoding. The reason it worked for as long as it did was that = we had bridges that passed the memory cycles to DRAM for addresses near = 0 and they didn't make it onto the PCI bus. Except in embedded systems, = I fail to see how that could have changed in the interim. The physical = layout of x86 has actual memory at location 0 and it would be a big = performance hit to push those transactions onto the pci bus, so nobody = in their right mind would do that. Warner Warner= From owner-svn-src-all@FreeBSD.ORG Fri May 4 22:54:55 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 754341065701; Fri, 4 May 2012 22:54:55 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 476BD8FC17; Fri, 4 May 2012 22:54: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 q44Mstof026558; Fri, 4 May 2012 22:54:55 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44MstHO026556; Fri, 4 May 2012 22:54:55 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205042254.q44MstHO026556@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 22:54:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235040 - head/sys/dev/mfi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 22:54:55 -0000 Author: ambrisko Date: Fri May 4 22:54:54 2012 New Revision: 235040 URL: http://svn.freebsd.org/changeset/base/235040 Log: Fix the returns in mfi_tbolt_sync_map_info. I forgot to change them to cleanup and goto out when acknowledging the LD's. Check for failure on malloc. Remove a couple of extra lines and remove the spurious return. Prompted by: Petr Lampa MFC after: 3 days Modified: head/sys/dev/mfi/mfi_tbolt.c Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 22:48:44 2012 (r235039) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 22:54:54 2012 (r235040) @@ -1290,7 +1290,6 @@ mfi_process_fw_state_chg_isr(void *arg) mtx_unlock(&sc->mfi_io_lock); } - /* * The ThunderBolt HW has an option for the driver to directly * access the underlying disks and operate on the RAID. To @@ -1362,13 +1361,21 @@ mfi_tbolt_sync_map_info(struct mfi_softc mtx_unlock(&sc->mfi_io_lock); ld_sync = (union mfi_ld_ref *) malloc(ld_size, M_MFIBUF, M_WAITOK | M_ZERO); + if (ld_sync == NULL) { + device_printf(sc->mfi_dev, "Failed to allocate sync\n"); + goto out; + } for (i = 0; i < list->ld_count; i++) { ld_sync[i].ref = list->ld_list[i].ld.ref; } mtx_lock(&sc->mfi_io_lock); - if ((cmd = mfi_dequeue_free(sc)) == NULL) - return; + if ((cmd = mfi_dequeue_free(sc)) == NULL) { + device_printf(sc->mfi_dev, "Failed to get command\n"); + free(ld_sync, M_MFIBUF); + goto out; + } + context = cmd->cm_frame->header.context; bzero(cmd->cm_frame, sizeof(union mfi_frame)); cmd->cm_frame->header.context = context; @@ -1396,7 +1403,10 @@ mfi_tbolt_sync_map_info(struct mfi_softc if ((error = mfi_mapcmd(sc, cmd)) != 0) { device_printf(sc->mfi_dev, "failed to send map sync\n"); - return; + free(ld_sync, M_MFIBUF); + sc->mfi_map_sync_cm = NULL; + mfi_requeue_ready(cmd); + goto out; } out: @@ -1405,11 +1415,8 @@ out: if (cm) mfi_release_command(cm); mtx_unlock(&sc->mfi_io_lock); - - return; } - static void mfi_sync_map_complete(struct mfi_command *cm) { From owner-svn-src-all@FreeBSD.ORG Fri May 4 23:16:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 45C97106564A; Fri, 4 May 2012 23:16:30 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30F2E8FC1B; Fri, 4 May 2012 23:16: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 q44NGUmF027295; Fri, 4 May 2012 23:16:30 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44NGTUM027293; Fri, 4 May 2012 23:16:30 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201205042316.q44NGTUM027293@svn.freebsd.org> From: Marcel Moolenaar Date: Fri, 4 May 2012 23:16: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: r235041 - head/sys/ia64/ia64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 23:16:30 -0000 Author: marcel Date: Fri May 4 23:16:29 2012 New Revision: 235041 URL: http://svn.freebsd.org/changeset/base/235041 Log: Don't assume we have legacy PICs (i.e. 8259A in cascade) at the legacy I/O port addresses. Even if we do, this is hardly the place to mask interrupts. It's not clear that this was at all needed. The code came with CVS revision 1.2 of nexus.c when interrupt support was first added. What is known is that ia64 has always been designed around the IOSAPIC, and that doing I/O like this prevents Altix from booting. Modified: head/sys/ia64/ia64/nexus.c Modified: head/sys/ia64/ia64/nexus.c ============================================================================== --- head/sys/ia64/ia64/nexus.c Fri May 4 22:54:54 2012 (r235040) +++ head/sys/ia64/ia64/nexus.c Fri May 4 23:16:29 2012 (r235041) @@ -65,9 +65,6 @@ #include -#include -#include - #include "clock_if.h" static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); @@ -191,12 +188,6 @@ static int nexus_attach(device_t dev) { - /* - * Mask the legacy PICs - we will use the I/O SAPIC for interrupt. - */ - outb(IO_ICU1+1, 0xff); - outb(IO_ICU2+1, 0xff); - if (acpi_identify() == 0) BUS_ADD_CHILD(dev, 10, "acpi", 0); clock_register(dev, 1000); From owner-svn-src-all@FreeBSD.ORG Fri May 4 23:45:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 126A3106566C; Fri, 4 May 2012 23:45:35 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F11998FC12; Fri, 4 May 2012 23:45:34 +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 q44NjYdp028266; Fri, 4 May 2012 23:45:34 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44NjYJq028264; Fri, 4 May 2012 23:45:34 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201205042345.q44NjYJq028264@svn.freebsd.org> From: Jim Harris Date: Fri, 4 May 2012 23:45:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235043 - head/sys/dev/isci/scil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 23:45:35 -0000 Author: jimharris Date: Fri May 4 23:45:34 2012 New Revision: 235043 URL: http://svn.freebsd.org/changeset/base/235043 Log: Fix off-by-one error in sati_inquiry_block_device_translate_data(). Bug would result in INQUIRY VPD 0x81 to SATA devices to return only 63 bytes of data instead of 64 during SCSI/ATA translation. Sponsored by: Intel Approved by: scottl MFC after: 1 week Modified: head/sys/dev/isci/scil/sati_inquiry.c Modified: head/sys/dev/isci/scil/sati_inquiry.c ============================================================================== --- head/sys/dev/isci/scil/sati_inquiry.c Fri May 4 23:33:40 2012 (r235042) +++ head/sys/dev/isci/scil/sati_inquiry.c Fri May 4 23:45:34 2012 (r235043) @@ -359,7 +359,7 @@ void sati_inquiry_block_device_translate ); //bytes 8-63 are reserved - for(offset = 8; offset < 63; offset++) + for(offset = 8; offset < 64; offset++) { sati_set_data_byte(sequence, scsi_io, offset, 0x00); } From owner-svn-src-all@FreeBSD.ORG Sat May 5 00:28:09 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 052F41065670; Sat, 5 May 2012 00:28:09 +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 CB22A8FC14; Sat, 5 May 2012 00:28:08 +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 q450S8lA029835; Sat, 5 May 2012 00:28:08 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q450S8MU029832; Sat, 5 May 2012 00:28:08 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205050028.q450S8MU029832@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 May 2012 00:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235045 - stable/9/lib/libc/rpc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 00:28:09 -0000 Author: kib Date: Sat May 5 00:28:08 2012 New Revision: 235045 URL: http://svn.freebsd.org/changeset/base/235045 Log: MFC r234769: Fix several memory and lock leaks on the out of memory condition. Modified: stable/9/lib/libc/rpc/svc.c stable/9/lib/libc/rpc/svc_raw.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/rpc/svc.c ============================================================================== --- stable/9/lib/libc/rpc/svc.c Sat May 5 00:08:05 2012 (r235044) +++ stable/9/lib/libc/rpc/svc.c Sat May 5 00:28:08 2012 (r235045) @@ -108,8 +108,10 @@ xprt_register(xprt) if (__svc_xports == NULL) { __svc_xports = (SVCXPRT **) mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); - if (__svc_xports == NULL) + if (__svc_xports == NULL) { + rwlock_unlock(&svc_fd_lock); return; + } memset(__svc_xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *)); } if (sock < FD_SETSIZE) { @@ -565,8 +567,14 @@ svc_xprt_alloc() SVCXPRT_EXT *ext; xprt = mem_alloc(sizeof(SVCXPRT)); + if (xprt == NULL) + return (NULL); memset(xprt, 0, sizeof(SVCXPRT)); ext = mem_alloc(sizeof(SVCXPRT_EXT)); + if (ext == NULL) { + mem_free(xprt, sizeof(SVCXPRT)); + return (NULL); + } memset(ext, 0, sizeof(SVCXPRT_EXT)); xprt->xp_p3 = ext; ext->xp_auth.svc_ah_ops = &svc_auth_null_ops; Modified: stable/9/lib/libc/rpc/svc_raw.c ============================================================================== --- stable/9/lib/libc/rpc/svc_raw.c Sat May 5 00:08:05 2012 (r235044) +++ stable/9/lib/libc/rpc/svc_raw.c Sat May 5 00:28:08 2012 (r235045) @@ -96,10 +96,22 @@ svc_raw_create() mutex_unlock(&svcraw_lock); return (NULL); } - if (__rpc_rawcombuf == NULL) + if (__rpc_rawcombuf == NULL) { __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char)); + if (__rpc_rawcombuf == NULL) { + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } + } srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */ srp->server = svc_xprt_alloc(); + if (srp->server == NULL) { + free(__rpc_rawcombuf); + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } svc_raw_private = srp; } srp->server->xp_fd = FD_SETSIZE; From owner-svn-src-all@FreeBSD.ORG Sat May 5 00:30:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6424B1065672; Sat, 5 May 2012 00:30:44 +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 369F28FC0C; Sat, 5 May 2012 00:30:44 +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 q450UiJt029968; Sat, 5 May 2012 00:30:44 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q450UiwU029965; Sat, 5 May 2012 00:30:44 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205050030.q450UiwU029965@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 May 2012 00:30:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235046 - stable/8/lib/libc/rpc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 00:30:44 -0000 Author: kib Date: Sat May 5 00:30:43 2012 New Revision: 235046 URL: http://svn.freebsd.org/changeset/base/235046 Log: MFC r234769: Fix several memory and lock leaks on the out of memory condition. Modified: stable/8/lib/libc/rpc/svc.c stable/8/lib/libc/rpc/svc_raw.c Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/rpc/svc.c ============================================================================== --- stable/8/lib/libc/rpc/svc.c Sat May 5 00:28:08 2012 (r235045) +++ stable/8/lib/libc/rpc/svc.c Sat May 5 00:30:43 2012 (r235046) @@ -108,8 +108,10 @@ xprt_register(xprt) if (__svc_xports == NULL) { __svc_xports = (SVCXPRT **) mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); - if (__svc_xports == NULL) + if (__svc_xports == NULL) { + rwlock_unlock(&svc_fd_lock); return; + } memset(__svc_xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *)); } if (sock < FD_SETSIZE) { @@ -565,8 +567,14 @@ svc_xprt_alloc() SVCXPRT_EXT *ext; xprt = mem_alloc(sizeof(SVCXPRT)); + if (xprt == NULL) + return (NULL); memset(xprt, 0, sizeof(SVCXPRT)); ext = mem_alloc(sizeof(SVCXPRT_EXT)); + if (ext == NULL) { + mem_free(xprt, sizeof(SVCXPRT)); + return (NULL); + } memset(ext, 0, sizeof(SVCXPRT_EXT)); xprt->xp_p3 = ext; ext->xp_auth.svc_ah_ops = &svc_auth_null_ops; Modified: stable/8/lib/libc/rpc/svc_raw.c ============================================================================== --- stable/8/lib/libc/rpc/svc_raw.c Sat May 5 00:28:08 2012 (r235045) +++ stable/8/lib/libc/rpc/svc_raw.c Sat May 5 00:30:43 2012 (r235046) @@ -96,10 +96,22 @@ svc_raw_create() mutex_unlock(&svcraw_lock); return (NULL); } - if (__rpc_rawcombuf == NULL) + if (__rpc_rawcombuf == NULL) { __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char)); + if (__rpc_rawcombuf == NULL) { + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } + } srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */ srp->server = svc_xprt_alloc(); + if (srp->server == NULL) { + free(__rpc_rawcombuf); + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } svc_raw_private = srp; } srp->server->xp_fd = FD_SETSIZE; From owner-svn-src-all@FreeBSD.ORG Sat May 5 02:01:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74B23106566C; Sat, 5 May 2012 02:01:54 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-pz0-f48.google.com (mail-pz0-f48.google.com [209.85.210.48]) by mx1.freebsd.org (Postfix) with ESMTP id DA5D58FC16; Sat, 5 May 2012 02:01:53 +0000 (UTC) Received: by dadz8 with SMTP id z8so764299dad.7 for ; Fri, 04 May 2012 19:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=DBs7o3NgfNe4MBGVwx7I4KiZoavHlekxoSzgvCNHz4U=; b=I8MWye9ssHfrSFfXiPXb4lHJDaqRUXdSl7aLQ655lBaVvmO6JuXHyfQ+2TARfmeLJf yoqiM4bKFS/9IpWdwOH5Acie0SKOFsB7qvcOvmZYkaPuUEMnmfHf8FE5Lp6jG3GjwnuN Be5xifVRHUUKYqWcN4OZNbkfd64wXggdNnSIFykFQlR3gquMOCo0z165OTn4SlGtGN1U quG13DQHkb6niaIiA9z2SUrAV2KnT9dUC95YgdaEPsMw2FMNow3WWYdjtJVFwg4lm+R7 Fk+sfr1GXJTASiCmcKd3S9ofU1UZiBBDi/A9ZZAozVLC++9HH+mvyndV1H3o4wLUScCu X7Mw== Received: by 10.68.129.131 with SMTP id nw3mr24089054pbb.150.1336183313265; Fri, 04 May 2012 19:01:53 -0700 (PDT) Received: from fuji.netgear.com ([50.125.30.143]) by mx.google.com with ESMTPS id pl8sm10288790pbb.72.2012.05.04.19.01.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 19:01:51 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=us-ascii From: Garrett Cooper In-Reply-To: <20120504182200.GD1604@azathoth.lan> Date: Fri, 4 May 2012 19:01:43 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> To: Baptiste Daroussin X-Mailer: Apple Mail (2.1257) Cc: Josh Paetzel , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 02:01:54 -0000 On May 4, 2012, at 11:22 AM, Baptiste Daroussin wrote: > On Fri, May 04, 2012 at 09:33:38AM -0700, Garrett Cooper wrote: ... >> Bug; should be '$SIZE/' >=20 > No this is perfectly valid Appreciate the clarification. I guess that's what I get for being = impatient and not testing my claim before I fired it off. Thanks! -Garrett= From owner-svn-src-all@FreeBSD.ORG Sat May 5 02:52:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5F63106566B; Sat, 5 May 2012 02:52:41 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9022C8FC0A; Sat, 5 May 2012 02:52:41 +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 q452qf1p034266; Sat, 5 May 2012 02:52:41 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q452qff7034264; Sat, 5 May 2012 02:52:41 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201205050252.q452qff7034264@svn.freebsd.org> From: Glen Barber Date: Sat, 5 May 2012 02:52:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235047 - stable/9/usr.sbin/cron/crontab X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 02:52:41 -0000 Author: gjb (doc committer) Date: Sat May 5 02:52:41 2012 New Revision: 235047 URL: http://svn.freebsd.org/changeset/base/235047 Log: MFC r234775: As cron(8) is started with '-s' by default, timezones that observe DST should not need to worry about scheduling jobs when the DST time changes. Rather than removing the BUGS section in crontab(5) regarding this, note that disabling '-s' may still cause jobs to be executed twice or not at all. PR: 166318 Modified: stable/9/usr.sbin/cron/crontab/crontab.5 Directory Properties: stable/9/usr.sbin/cron/crontab/ (props changed) Modified: stable/9/usr.sbin/cron/crontab/crontab.5 ============================================================================== --- stable/9/usr.sbin/cron/crontab/crontab.5 Sat May 5 00:30:43 2012 (r235046) +++ stable/9/usr.sbin/cron/crontab/crontab.5 Sat May 5 02:52:41 2012 (r235047) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2012 +.Dd April 28, 2012 .Dt CRONTAB 5 .Os .Sh NAME @@ -296,10 +296,21 @@ are extensions. .An Paul Vixie Aq paul@vix.com .Sh BUGS If you are in one of the 70-odd countries that observe Daylight -Savings Time, jobs scheduled during the rollback or advance will be -affected. +Savings Time, jobs scheduled during the rollback or advance may be +affected if +.Xr cron 8 +is not started with the +.Fl s +flag. In general, it is not a good idea to schedule jobs during -this period. +this period if +.Xr cron 8 +is not started with the +.Fl s +flag, which is enabled by default. +See +.Xr cron 8 +for more details. .Pp For US timezones (except parts of AZ and HI) the time shift occurs at 2AM local time. From owner-svn-src-all@FreeBSD.ORG Sat May 5 02:53:03 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 221DA10656FB; Sat, 5 May 2012 02:53:03 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C90A8FC18; Sat, 5 May 2012 02:53:03 +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 q452r2lF034312; Sat, 5 May 2012 02:53:02 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q452r2J1034310; Sat, 5 May 2012 02:53:02 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201205050253.q452r2J1034310@svn.freebsd.org> From: Glen Barber Date: Sat, 5 May 2012 02:53:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235048 - stable/8/usr.sbin/cron/crontab X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 02:53:03 -0000 Author: gjb (doc committer) Date: Sat May 5 02:53:02 2012 New Revision: 235048 URL: http://svn.freebsd.org/changeset/base/235048 Log: MFC r234775: As cron(8) is started with '-s' by default, timezones that observe DST should not need to worry about scheduling jobs when the DST time changes. Rather than removing the BUGS section in crontab(5) regarding this, note that disabling '-s' may still cause jobs to be executed twice or not at all. PR: 166318 Modified: stable/8/usr.sbin/cron/crontab/crontab.5 Directory Properties: stable/8/usr.sbin/cron/crontab/ (props changed) Modified: stable/8/usr.sbin/cron/crontab/crontab.5 ============================================================================== --- stable/8/usr.sbin/cron/crontab/crontab.5 Sat May 5 02:52:41 2012 (r235047) +++ stable/8/usr.sbin/cron/crontab/crontab.5 Sat May 5 02:53:02 2012 (r235048) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2012 +.Dd April 28, 2012 .Dt CRONTAB 5 .Os .Sh NAME @@ -296,10 +296,21 @@ are extensions. .An Paul Vixie Aq paul@vix.com .Sh BUGS If you are in one of the 70-odd countries that observe Daylight -Savings Time, jobs scheduled during the rollback or advance will be -affected. +Savings Time, jobs scheduled during the rollback or advance may be +affected if +.Xr cron 8 +is not started with the +.Fl s +flag. In general, it is not a good idea to schedule jobs during -this period. +this period if +.Xr cron 8 +is not started with the +.Fl s +flag, which is enabled by default. +See +.Xr cron 8 +for more details. .Pp For US timezones (except parts of AZ and HI) the time shift occurs at 2AM local time. From owner-svn-src-all@FreeBSD.ORG Sat May 5 02:53:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BCAAE106564A; Sat, 5 May 2012 02:53:19 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A6D528FC0A; Sat, 5 May 2012 02:53:19 +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 q452rJex034358; Sat, 5 May 2012 02:53:19 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q452rJmj034356; Sat, 5 May 2012 02:53:19 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201205050253.q452rJmj034356@svn.freebsd.org> From: Glen Barber Date: Sat, 5 May 2012 02:53:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235049 - stable/7/usr.sbin/cron/crontab X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 02:53:19 -0000 Author: gjb (doc committer) Date: Sat May 5 02:53:19 2012 New Revision: 235049 URL: http://svn.freebsd.org/changeset/base/235049 Log: MFC r234775: As cron(8) is started with '-s' by default, timezones that observe DST should not need to worry about scheduling jobs when the DST time changes. Rather than removing the BUGS section in crontab(5) regarding this, note that disabling '-s' may still cause jobs to be executed twice or not at all. PR: 166318 Modified: stable/7/usr.sbin/cron/crontab/crontab.5 Directory Properties: stable/7/usr.sbin/cron/crontab/ (props changed) Modified: stable/7/usr.sbin/cron/crontab/crontab.5 ============================================================================== --- stable/7/usr.sbin/cron/crontab/crontab.5 Sat May 5 02:53:02 2012 (r235048) +++ stable/7/usr.sbin/cron/crontab/crontab.5 Sat May 5 02:53:19 2012 (r235049) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2012 +.Dd April 28, 2012 .Dt CRONTAB 5 .Os .Sh NAME @@ -296,10 +296,21 @@ are extensions. .An Paul Vixie Aq paul@vix.com .Sh BUGS If you are in one of the 70-odd countries that observe Daylight -Savings Time, jobs scheduled during the rollback or advance will be -affected. +Savings Time, jobs scheduled during the rollback or advance may be +affected if +.Xr cron 8 +is not started with the +.Fl s +flag. In general, it is not a good idea to schedule jobs during -this period. +this period if +.Xr cron 8 +is not started with the +.Fl s +flag, which is enabled by default. +See +.Xr cron 8 +for more details. .Pp For US timezones (except parts of AZ and HI) the time shift occurs at 2AM local time. From owner-svn-src-all@FreeBSD.ORG Sat May 5 07:15:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93D8A106566C; Sat, 5 May 2012 07:15:35 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F1158FC12; Sat, 5 May 2012 07:15: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 q457FZVE044680; Sat, 5 May 2012 07:15:35 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q457FZ6v044678; Sat, 5 May 2012 07:15:35 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205050715.q457FZ6v044678@svn.freebsd.org> From: Warner Losh Date: Sat, 5 May 2012 07:15: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: r235050 - head/sys/arm/arm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 07:15:35 -0000 Author: imp Date: Sat May 5 07:15:34 2012 New Revision: 235050 URL: http://svn.freebsd.org/changeset/base/235050 Log: Big endian arm boxes need to have a uname -m of armeb, not arm, so that the bootstrap from source works correctly. MFC after: 4 days Modified: head/sys/arm/arm/identcpu.c Modified: head/sys/arm/arm/identcpu.c ============================================================================== --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 (r235049) +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 (r235050) @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#if _BYTE_ORDER == _LITTLE_ENDIAN char machine[] = "arm"; +#else +char machine[] = "armeb"; +#endif SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class"); From owner-svn-src-all@FreeBSD.ORG Sat May 5 07:55:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 68234106566B; Sat, 5 May 2012 07:55:51 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5153E8FC14; Sat, 5 May 2012 07:55:51 +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 q457tp5u045939; Sat, 5 May 2012 07:55:51 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q457tpgZ045934; Sat, 5 May 2012 07:55:51 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201205050755.q457tpgZ045934@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 5 May 2012 07:55:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235051 - stable/9/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 07:55:51 -0000 Author: glebius Date: Sat May 5 07:55:50 2012 New Revision: 235051 URL: http://svn.freebsd.org/changeset/base/235051 Log: Merge 234342 from head: When we receive an ICMP unreach need fragmentation datagram, we take proposed MTU value from it and update the TCP host cache. Then tcp_mss_update() is called on the corresponding tcpcb. It finds the just allocated entry in the TCP host cache and updates MSS on the tcpcb. And then we do a fast retransmit of what we have in the tcp send buffer. This sequence gets broken if the TCP host cache is exausted. In this case allocation fails, and later called tcp_mss_update() finds nothing in cache. The fast retransmit is done with not reduced MSS and is immidiately replied by remote host with new ICMP datagrams and the cycle repeats. This ping-pong can go up to wirespeed. To fix this: - tcp_mss_update() gets new parameter - mtuoffer, that is like offer, but needs to have min_protoh subtracted. - tcp_mtudisc() as notification method renamed to tcp_mtudisc_notify(). - tcp_mtudisc() now accepts not a useless error argument, but proposed MTU value, that is passed to tcp_mss_update() as mtuoffer. Reported by: az Reported by: Andrey Zonov Reviewed by: andre (previous version of patch) Modified: stable/9/sys/netinet/tcp_input.c stable/9/sys/netinet/tcp_output.c stable/9/sys/netinet/tcp_subr.c stable/9/sys/netinet/tcp_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_input.c ============================================================================== --- stable/9/sys/netinet/tcp_input.c Sat May 5 07:15:34 2012 (r235050) +++ stable/9/sys/netinet/tcp_input.c Sat May 5 07:55:50 2012 (r235051) @@ -3315,22 +3315,19 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt * are present. Store the upper limit of the length of options plus * data in maxopd. * - * In case of T/TCP, we call this routine during implicit connection - * setup as well (offer = -1), to initialize maxseg from the cached - * MSS of our peer. - * * NOTE that this routine is only called when we process an incoming - * segment. Outgoing SYN/ACK MSS settings are handled in tcp_mssopt(). + * segment, or an ICMP need fragmentation datagram. Outgoing SYN/ACK MSS + * settings are handled in tcp_mssopt(). */ void -tcp_mss_update(struct tcpcb *tp, int offer, +tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, struct hc_metrics_lite *metricptr, int *mtuflags) { int mss = 0; u_long maxmtu = 0; struct inpcb *inp = tp->t_inpcb; struct hc_metrics_lite metrics; - int origoffer = offer; + int origoffer; #ifdef INET6 int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0; size_t min_protoh = isipv6 ? @@ -3342,6 +3339,12 @@ tcp_mss_update(struct tcpcb *tp, int off INP_WLOCK_ASSERT(tp->t_inpcb); + if (mtuoffer != -1) { + KASSERT(offer == -1, ("%s: conflict", __func__)); + offer = mtuoffer - min_protoh; + } + origoffer = offer; + /* Initialize. */ #ifdef INET6 if (isipv6) { @@ -3500,7 +3503,7 @@ tcp_mss(struct tcpcb *tp, int offer) KASSERT(tp != NULL, ("%s: tp == NULL", __func__)); - tcp_mss_update(tp, offer, &metrics, &mtuflags); + tcp_mss_update(tp, offer, -1, &metrics, &mtuflags); mss = tp->t_maxseg; inp = tp->t_inpcb; Modified: stable/9/sys/netinet/tcp_output.c ============================================================================== --- stable/9/sys/netinet/tcp_output.c Sat May 5 07:15:34 2012 (r235050) +++ stable/9/sys/netinet/tcp_output.c Sat May 5 07:55:50 2012 (r235051) @@ -1298,7 +1298,7 @@ out: */ if (tso) tp->t_flags &= ~TF_TSO; - tcp_mtudisc(tp->t_inpcb, 0); + tcp_mtudisc(tp->t_inpcb, -1); return (0); case EHOSTDOWN: case EHOSTUNREACH: Modified: stable/9/sys/netinet/tcp_subr.c ============================================================================== --- stable/9/sys/netinet/tcp_subr.c Sat May 5 07:15:34 2012 (r235050) +++ stable/9/sys/netinet/tcp_subr.c Sat May 5 07:55:50 2012 (r235051) @@ -222,6 +222,7 @@ VNET_DEFINE(uma_zone_t, sack_hole_zone); VNET_DEFINE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST+1]); static struct inpcb *tcp_notify(struct inpcb *, int); +static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int); static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr, const void *ip6hdr); @@ -1337,7 +1338,7 @@ tcp_ctlinput(int cmd, struct sockaddr *s return; if (cmd == PRC_MSGSIZE) - notify = tcp_mtudisc; + notify = tcp_mtudisc_notify; else if (V_icmp_may_rst && (cmd == PRC_UNREACH_ADMIN_PROHIB || cmd == PRC_UNREACH_PORT || cmd == PRC_TIMXCEED_INTRANS) && ip) notify = tcp_drop_syn_sent; @@ -1410,9 +1411,10 @@ tcp_ctlinput(int cmd, struct sockaddr *s */ if (mtu <= tcp_maxmtu(&inc, NULL)) tcp_hc_updatemtu(&inc, mtu); - } - - inp = (*notify)(inp, inetctlerrmap[cmd]); + tcp_mtudisc(inp, mtu); + } else + inp = (*notify)(inp, + inetctlerrmap[cmd]); } } if (inp != NULL) @@ -1452,7 +1454,7 @@ tcp6_ctlinput(int cmd, struct sockaddr * return; if (cmd == PRC_MSGSIZE) - notify = tcp_mtudisc; + notify = tcp_mtudisc_notify; else if (!PRC_IS_REDIRECT(cmd) && ((unsigned)cmd >= PRC_NCMDS || inet6ctlerrmap[cmd] == 0)) return; @@ -1653,12 +1655,19 @@ tcp_drop_syn_sent(struct inpcb *inp, int /* * When `need fragmentation' ICMP is received, update our idea of the MSS - * based on the new value in the route. Also nudge TCP to send something, - * since we know the packet we just sent was dropped. + * based on the new value. Also nudge TCP to send something, since we + * know the packet we just sent was dropped. * This duplicates some code in the tcp_mss() function in tcp_input.c. */ +static struct inpcb * +tcp_mtudisc_notify(struct inpcb *inp, int error) +{ + + return (tcp_mtudisc(inp, -1)); +} + struct inpcb * -tcp_mtudisc(struct inpcb *inp, int errno) +tcp_mtudisc(struct inpcb *inp, int mtuoffer) { struct tcpcb *tp; struct socket *so; @@ -1671,7 +1680,7 @@ tcp_mtudisc(struct inpcb *inp, int errno tp = intotcpcb(inp); KASSERT(tp != NULL, ("tcp_mtudisc: tp == NULL")); - tcp_mss_update(tp, -1, NULL, NULL); + tcp_mss_update(tp, -1, mtuoffer, NULL, NULL); so = inp->inp_socket; SOCKBUF_LOCK(&so->so_snd); Modified: stable/9/sys/netinet/tcp_var.h ============================================================================== --- stable/9/sys/netinet/tcp_var.h Sat May 5 07:15:34 2012 (r235050) +++ stable/9/sys/netinet/tcp_var.h Sat May 5 07:55:50 2012 (r235051) @@ -675,7 +675,8 @@ void tcp_reass_destroy(void); void tcp_input(struct mbuf *, int); u_long tcp_maxmtu(struct in_conninfo *, int *); u_long tcp_maxmtu6(struct in_conninfo *, int *); -void tcp_mss_update(struct tcpcb *, int, struct hc_metrics_lite *, int *); +void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *, + int *); void tcp_mss(struct tcpcb *, int); int tcp_mssopt(struct in_conninfo *); struct inpcb * From owner-svn-src-all@FreeBSD.ORG Sat May 5 09:00:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DD1A61065670; Sat, 5 May 2012 09:00:37 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 769D88FC18; Sat, 5 May 2012 09:00:37 +0000 (UTC) Received: by obcni5 with SMTP id ni5so6738443obc.13 for ; Sat, 05 May 2012 02:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xqr69o3CTQoJj+Ho49hoaEt6TRilPLGAFxUkppVt7no=; b=w7EDYHimnsMicAgOZPr0KwoonnDMeqUGiRkq/PFuXutTHjC3XYo99PAAfDxn4WzrM7 jabOOQEhV5d1L6utj065iKBn9aGq68Tt1Y+dXHkP3H4gPI3Poiwt0qO+SE86QMvb0Z+J ogVmlqn+n7pUgLWsV0vk2q0jIoAEi7hlnANFLCPTBUYUb/zB68+vbyIq7+WnuFWX4VAC MtNj+rUvoDXSmQkTpuV9iTch/VIHaOovr60yi2WljsBrzlI9O7qELDxe4rOTnfgN+viz mGh38/ZB9gf2qYHnDiTrW0KpNiLu6Bu5bX6ZbKqzS/Kf4j2eGR9KtOrKEd5Dk52vsBnc E2Rw== MIME-Version: 1.0 Received: by 10.50.77.136 with SMTP id s8mr4715373igw.56.1336208436761; Sat, 05 May 2012 02:00:36 -0700 (PDT) Sender: pluknet@gmail.com Received: by 10.64.78.37 with HTTP; Sat, 5 May 2012 02:00:36 -0700 (PDT) In-Reply-To: <201204171628.q3HGSM9P089821@svn.freebsd.org> References: <201204171628.q3HGSM9P089821@svn.freebsd.org> Date: Sat, 5 May 2012 13:00:36 +0400 X-Google-Sender-Auth: QgBU9HaeY3rK0I7x9S5TWJX3IXM Message-ID: From: Sergey Kandaurov To: Kirk McKusick Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234386 - in head/sys: fs/coda fs/ext2fs fs/msdosfs fs/nfsclient kern nfsclient sys ufs/ffs ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:00:38 -0000 On 17 April 2012 20:28, Kirk McKusick wrote: > Author: mckusick > Date: Tue Apr 17 16:28:22 2012 > New Revision: 234386 > URL: http://svn.freebsd.org/changeset/base/234386 > > Log: > =A0Replace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL. > =A0The primary changes are that the user of the interface no longer > =A0needs to manage the mount-mutex locking and that the vnode that > =A0is returned has its mutex locked (thus avoiding the need to check > =A0to see if its is DOOMED or other possible end of life senarios). > > =A0To minimize compatibility issues for third-party developers, the > =A0old MNT_VNODE_FOREACH interface will remain available so that this > =A0change can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH > =A0will be removed in head. > > =A0The reason for this update is to prepare for the addition of the > =A0MNT_VNODE_FOREACH_ACTIVE interface that will loop over just the > =A0active vnodes associated with a mount point (typically less than > =A01% of the vnodes associated with the mount point). > > =A0Reviewed by: kib > =A0Tested by: =A0 Peter Holm > =A0MFC after: =A0 2 weeks > Hi. This commit crashes on old nfsclient. Looks like this change is missed. Index: nfsclient/nfs_vfsops.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- nfsclient/nfs_vfsops.c (revision 235051) +++ nfsclient/nfs_vfsops.c (working copy) @@ -1452,6 +1452,7 @@ MNT_IUNLOCK(mp); return (EBADF); } + MNT_IUNLOCK(mp); /* * Force stale buffer cache information to be flushed. [...] > > Modified: head/sys/nfsclient/nfs_vfsops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/nfsclient/nfs_vfsops.c Tue Apr 17 14:54:00 2012 (= r234385) > +++ head/sys/nfsclient/nfs_vfsops.c Tue Apr 17 16:28:22 2012 (= r234386) > @@ -1457,19 +1457,15 @@ nfs_sync(struct mount *mp, int waitfor) > * Force stale buffer cache information to be flushed. > */ > loop: > - MNT_VNODE_FOREACH(vp, mp, mvp) { > - VI_LOCK(vp); > - MNT_IUNLOCK(mp); > + MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { Now this call results in malloc() and MNT_ILOCK(mp) inside __mnt_vnode_first_all(). But MNT_ILOCK(mp) is already done few lines above (probably because its MNT_IUNLOCK() counterpart was missed in this commit?). [...] > +struct vnode * > +__mnt_vnode_first_all(struct vnode **mvp, struct mount *mp) > +{ > + =A0 =A0 =A0 struct vnode *vp; > + To the moment it already holds MNT_ILOCK(mp) from sys/nfsclient/nfs_vfsops.c:1445 > + =A0 =A0 =A0 *mvp =3D malloc(sizeof(struct vnode), M_VNODE_MARKER, M_WAI= TOK | M_ZERO); > + =A0 =A0 =A0 MNT_ILOCK(mp); > + =A0 =A0 =A0 MNT_REF(mp); > + =A0 =A0 =A0 (*mvp)->v_type =3D VMARKER; > + > + =A0 =A0 =A0 vp =3D TAILQ_FIRST(&mp->mnt_nvnodelist); > + =A0 =A0 =A0 while (vp !=3D NULL && (vp->v_type =3D=3D VMARKER || > + =A0 =A0 =A0 =A0 =A0 (vp->v_iflag & VI_DOOMED) !=3D 0)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vp =3D TAILQ_NEXT(vp, v_nmntvnodes); > + > + =A0 =A0 =A0 /* Check if we are done */ > + =A0 =A0 =A0 if (vp =3D=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 *mvp =3D NULL; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MNT_REL(mp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MNT_IUNLOCK(mp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 free(*mvp, M_VNODE_MARKER); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (NULL); > + =A0 =A0 =A0 } > + =A0 =A0 =A0 (*mvp)->v_mount =3D mp; > + =A0 =A0 =A0 TAILQ_INSERT_AFTER(&mp->mnt_nvnodelist, vp, *mvp, v_nmntvno= des); > + =A0 =A0 =A0 VI_LOCK(vp); > + =A0 =A0 =A0 MNT_IUNLOCK(mp); > + =A0 =A0 =A0 return (vp); > +} [...] uma_zalloc_arg: zone "1024" with the following non-sleepable locks held: exclusive sleep mutex struct mount mtx (struct mount mtx) r =3D 0 (0xfffffe0002907750) locked @ /usr/src/sys/nfsclient/nfs_vfsops.c:1445 KDB: stack backtrace: db_trace_self_wrapper() at 0xffffffff802c75aa =3D db_trace_self_wrapper+0x2= a kdb_backtrace() at 0xffffffff80476547 =3D kdb_backtrace+0x37 _witness_debugger() at 0xffffffff8048d48c =3D _witness_debugger+0x2c witness_warn() at 0xffffffff8048e274 =3D witness_warn+0x2c4 uma_zalloc_arg() at 0xffffffff8068be24 =3D uma_zalloc_arg+0x384 malloc() at 0xffffffff80425026 =3D malloc+0xc6 __mnt_vnode_first_all() at 0xffffffff804dd3f9 =3D __mnt_vnode_first_all+0x2= 9 nfs_sync() at 0xffffffff805f231d =3D nfs_sync+0x8d sys_sync() at 0xffffffff804e8906 =3D sys_sync+0x146 amd64_syscall() at 0xffffffff806c780c =3D amd64_syscall+0x38c Xfast_syscall() at 0xffffffff806b2c47 =3D Xfast_syscall+0xf7 --- syscall (36, FreeBSD ELF64, sys_sync), rip =3D 0x800a95a0c, rsp =3D 0x7fffffffd958, rbp =3D 0x7fffffffdd50 --- panic: _mtx_lock_sleep: recursed on non-recursive mutex struct mount mtx @ /usr/src/sys/kern/vfs_subr.c:4595 cpuid =3D 1 KDB: stack backtrace: db_trace_self_wrapper() at 0xffffffff802c75aa =3D db_trace_self_wrapper+0x2= a kdb_backtrace() at 0xffffffff80476547 =3D kdb_backtrace+0x37 panic() at 0xffffffff8043bc3e =3D panic+0x1ce _mtx_lock_sleep() at 0xffffffff80429058 =3D _mtx_lock_sleep+0x538 _mtx_lock_flags() at 0xffffffff804291e4 =3D _mtx_lock_flags+0x184 __mnt_vnode_first_all() at 0xffffffff804dd413 =3D __mnt_vnode_first_all+0x4= 3 nfs_sync() at 0xffffffff805f231d =3D nfs_sync+0x8d sys_sync() at 0xffffffff804e8906 =3D sys_sync+0x146 amd64_syscall() at 0xffffffff806c780c =3D amd64_syscall+0x38c Xfast_syscall() at 0xffffffff806b2c47 =3D Xfast_syscall+0xf7 --- syscall (36, FreeBSD ELF64, sys_sync), rip =3D 0x800a95a0c, rsp =3D 0x7fffffffd958, rbp =3D 0x7fffffffdd50 --- KDB: enter: panic [ thread pid 1268 tid 100085 ] Stopped at 0xffffffff8047620b =3D kdb_enter+0x3b: movq $0,0x75d252(%rip) db> --=20 wbr, pluknet From owner-svn-src-all@FreeBSD.ORG Sat May 5 09:13:42 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5B323106566C; Sat, 5 May 2012 09:13:42 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail17.syd.optusnet.com.au (mail17.syd.optusnet.com.au [211.29.132.198]) by mx1.freebsd.org (Postfix) with ESMTP id E83048FC0C; Sat, 5 May 2012 09:13:41 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail17.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459DXEe017745 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 May 2012 19:13:34 +1000 Date: Sat, 5 May 2012 19:13:33 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Pawel Jakub Dawidek In-Reply-To: <20120504185743.GA1397@garage.freebsd.pl> Message-ID: <20120505185603.G1113@besplex.bde.org> References: <201203242110.q2OLAJSZ049045@svn.freebsd.org> <20120504185743.GA1397@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler Subject: Re: svn commit: r233435 - head/etc/mtree X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:13:42 -0000 On Fri, 4 May 2012, Pawel Jakub Dawidek wrote: > On Sat, Mar 24, 2012 at 09:10:19PM +0000, Eitan Adler wrote: >> Log: >> Fix build by adding new directory to mtree in r233429 >> >> Submitted by: flo >> Approved by: cperciva >> MFC after: 1 week >> >> Modified: >> head/etc/mtree/BSD.usr.dist >> >> Modified: head/etc/mtree/BSD.usr.dist >> ============================================================================== >> --- head/etc/mtree/BSD.usr.dist Sat Mar 24 19:59:14 2012 (r233434) >> +++ head/etc/mtree/BSD.usr.dist Sat Mar 24 21:10:19 2012 (r233435) >> @@ -209,6 +209,8 @@ >> .. >> bootforth >> .. >> + csh >> + .. >> cvs > > You need to use only spaces in this file for indentation just like in > all the other lines. That's a shame it was merged into 7, 8 and 9. Of course, it doesn't help that mtree files are among the few whose formatting style is specified in detail (in mtree/README). BSD.usr.dist is the only one that has any tabs (82 lines out of 1364). Other misformattings are harder to grep for, but unlikely to be null. A relatively serious ones (equivalent to leaving out necessary braces for a compound statement in C) is visible in the above: the tab for the ".." for csh is not just a style bug, but misindents to an extra level, so the level can't be read off from the indentation. This is without spurious indentation from mailer quoting or tab mis-expansion; in this reply, the mailer quoting combined with only some lines using tabs makes it look like "csh" is missing indentation instead of its ".." having extra indentation. The strings are "<4 spaces>csh" and .." but should be "<12 spaces>" for both.) There is no indent(1) for mtree files, but the README has instructions for producing the correct formatting by running mtree(1) with suitable options. Bruce From owner-svn-src-all@FreeBSD.ORG Sat May 5 09:34:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 336801065672; Sat, 5 May 2012 09:34:36 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E3708FC08; Sat, 5 May 2012 09:34: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 q459YZJZ049094; Sat, 5 May 2012 09:34:35 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q459YZol049092; Sat, 5 May 2012 09:34:35 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201205050934.q459YZol049092@svn.freebsd.org> From: Sergey Kandaurov Date: Sat, 5 May 2012 09:34: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: r235052 - head/sys/nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:34:36 -0000 Author: pluknet Date: Sat May 5 09:34:35 2012 New Revision: 235052 URL: http://svn.freebsd.org/changeset/base/235052 Log: Fix mount mutex handling missed in r234386. Modified: head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/nfsclient/nfs_vfsops.c ============================================================================== --- head/sys/nfsclient/nfs_vfsops.c Sat May 5 07:55:50 2012 (r235051) +++ head/sys/nfsclient/nfs_vfsops.c Sat May 5 09:34:35 2012 (r235052) @@ -1452,6 +1452,7 @@ nfs_sync(struct mount *mp, int waitfor) MNT_IUNLOCK(mp); return (EBADF); } + MNT_IUNLOCK(mp); /* * Force stale buffer cache information to be flushed. From owner-svn-src-all@FreeBSD.ORG Sat May 5 09:39:19 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 041801065670; Sat, 5 May 2012 09:39:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 870348FC1C; Sat, 5 May 2012 09:39:18 +0000 (UTC) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459dAbm026515; Sat, 5 May 2012 19:39:10 +1000 Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459d1OR028213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 May 2012 19:39:02 +1000 Date: Sat, 5 May 2012 19:39:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Doug Barton In-Reply-To: <4FA438C4.3080701@FreeBSD.org> Message-ID: <20120505192318.T1202@besplex.bde.org> References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> <4FA438C4.3080701@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Baptiste Daroussin , "src-committers@freebsd.org" , Garrett Cooper , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" , "kmoore@freebsd.org" , Josh Paetzel Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:39:19 -0000 On Fri, 4 May 2012, Doug Barton wrote: > On 05/04/2012 11:22 AM, Baptiste Daroussin wrote: >>>>>> fetch -s "${FETCHFILE}" >${SIZEFILE} >>>>>> SIZE="`cat ${SIZEFILE}`" >>>>>> - SIZE="`expr ${SIZE} / 1024`" >>>>>> + SIZE=$((SIZE/1024)) >>>> >>>> Bug; should be '$SIZE/' >> No this is perfectly valid > > Yes, that works, but it's not our usual style. However, the point is > moot as that whole block should be reduced down to: > > SIZE=$(( `fetch -s "${FETCHFILE}"` / 1024 )) The KNF rule that there shall be spaces around binary operators should probably apply in shell expressions too, but I don't like the spaces on 1 side of (( and )). Shell syntax doesn't even allow spaces between '$' ((. The rc.d style seems to be to use backquotes and not use $(cmd), but I prefer the opposite except possibly in shell expressions like the above so that it is easier to separate the commands from the shell expressions. > If SIZEFILE is needed elsewhere that's a different matter, but as it is > that's a hot mess. Bruce From owner-svn-src-all@FreeBSD.ORG Sat May 5 10:05:14 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09F82106566C; Sat, 5 May 2012 10:05:14 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7EEF8FC08; Sat, 5 May 2012 10:05:13 +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 q45A5DxP050088; Sat, 5 May 2012 10:05:13 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45A5DTD050083; Sat, 5 May 2012 10:05:13 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201205051005.q45A5DTD050083@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 5 May 2012 10:05:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235053 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 10:05:14 -0000 Author: glebius Date: Sat May 5 10:05:13 2012 New Revision: 235053 URL: http://svn.freebsd.org/changeset/base/235053 Log: Merge 234342 from head: When we receive an ICMP unreach need fragmentation datagram, we take proposed MTU value from it and update the TCP host cache. Then tcp_mss_update() is called on the corresponding tcpcb. It finds the just allocated entry in the TCP host cache and updates MSS on the tcpcb. And then we do a fast retransmit of what we have in the tcp send buffer. This sequence gets broken if the TCP host cache is exausted. In this case allocation fails, and later called tcp_mss_update() finds nothing in cache. The fast retransmit is done with not reduced MSS and is immidiately replied by remote host with new ICMP datagrams and the cycle repeats. This ping-pong can go up to wirespeed. To fix this: - tcp_mss_update() gets new parameter - mtuoffer, that is like offer, but needs to have min_protoh subtracted. - tcp_mtudisc() as notification method renamed to tcp_mtudisc_notify(). - tcp_mtudisc() now accepts not a useless error argument, but proposed MTU value, that is passed to tcp_mss_update() as mtuoffer. Reported by: az Reported by: Andrey Zonov Reviewed by: andre (previous version of patch) Tested by: Andrey Zonov Modified: stable/8/sys/netinet/tcp_input.c stable/8/sys/netinet/tcp_output.c stable/8/sys/netinet/tcp_subr.c stable/8/sys/netinet/tcp_var.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/tcp_input.c ============================================================================== --- stable/8/sys/netinet/tcp_input.c Sat May 5 09:34:35 2012 (r235052) +++ stable/8/sys/netinet/tcp_input.c Sat May 5 10:05:13 2012 (r235053) @@ -3286,22 +3286,19 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt * are present. Store the upper limit of the length of options plus * data in maxopd. * - * In case of T/TCP, we call this routine during implicit connection - * setup as well (offer = -1), to initialize maxseg from the cached - * MSS of our peer. - * * NOTE that this routine is only called when we process an incoming - * segment. Outgoing SYN/ACK MSS settings are handled in tcp_mssopt(). + * segment, or an ICMP need fragmentation datagram. Outgoing SYN/ACK MSS + * settings are handled in tcp_mssopt(). */ void -tcp_mss_update(struct tcpcb *tp, int offer, +tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, struct hc_metrics_lite *metricptr, int *mtuflags) { int mss; u_long maxmtu; struct inpcb *inp = tp->t_inpcb; struct hc_metrics_lite metrics; - int origoffer = offer; + int origoffer; #ifdef INET6 int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0; size_t min_protoh = isipv6 ? @@ -3313,6 +3310,12 @@ tcp_mss_update(struct tcpcb *tp, int off INP_WLOCK_ASSERT(tp->t_inpcb); + if (mtuoffer != -1) { + KASSERT(offer == -1, ("%s: conflict", __func__)); + offer = mtuoffer - min_protoh; + } + origoffer = offer; + /* Initialize. */ #ifdef INET6 if (isipv6) { @@ -3461,7 +3464,7 @@ tcp_mss(struct tcpcb *tp, int offer) KASSERT(tp != NULL, ("%s: tp == NULL", __func__)); - tcp_mss_update(tp, offer, &metrics, &mtuflags); + tcp_mss_update(tp, offer, -1, &metrics, &mtuflags); mss = tp->t_maxseg; inp = tp->t_inpcb; Modified: stable/8/sys/netinet/tcp_output.c ============================================================================== --- stable/8/sys/netinet/tcp_output.c Sat May 5 09:34:35 2012 (r235052) +++ stable/8/sys/netinet/tcp_output.c Sat May 5 10:05:13 2012 (r235053) @@ -1288,7 +1288,7 @@ out: */ if (tso) tp->t_flags &= ~TF_TSO; - tcp_mtudisc(tp->t_inpcb, 0); + tcp_mtudisc(tp->t_inpcb, -1); return (0); case EHOSTDOWN: case EHOSTUNREACH: Modified: stable/8/sys/netinet/tcp_subr.c ============================================================================== --- stable/8/sys/netinet/tcp_subr.c Sat May 5 09:34:35 2012 (r235052) +++ stable/8/sys/netinet/tcp_subr.c Sat May 5 10:05:13 2012 (r235053) @@ -271,6 +271,7 @@ VNET_DEFINE(uma_zone_t, sack_hole_zone); VNET_DEFINE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST+1]); static struct inpcb *tcp_notify(struct inpcb *, int); +static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int); static void tcp_isn_tick(void *); static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr, const void *ip6hdr); @@ -1372,7 +1373,7 @@ tcp_ctlinput(int cmd, struct sockaddr *s return; if (cmd == PRC_MSGSIZE) - notify = tcp_mtudisc; + notify = tcp_mtudisc_notify; else if (V_icmp_may_rst && (cmd == PRC_UNREACH_ADMIN_PROHIB || cmd == PRC_UNREACH_PORT || cmd == PRC_TIMXCEED_INTRANS) && ip) notify = tcp_drop_syn_sent; @@ -1446,9 +1447,10 @@ tcp_ctlinput(int cmd, struct sockaddr *s */ if (mtu <= tcp_maxmtu(&inc, NULL)) tcp_hc_updatemtu(&inc, mtu); - } - - inp = (*notify)(inp, inetctlerrmap[cmd]); + tcp_mtudisc(inp, mtu); + } else + inp = (*notify)(inp, + inetctlerrmap[cmd]); } } if (inp != NULL) @@ -1487,7 +1489,7 @@ tcp6_ctlinput(int cmd, struct sockaddr * return; if (cmd == PRC_MSGSIZE) - notify = tcp_mtudisc; + notify = tcp_mtudisc_notify; else if (!PRC_IS_REDIRECT(cmd) && ((unsigned)cmd >= PRC_NCMDS || inet6ctlerrmap[cmd] == 0)) return; @@ -1706,12 +1708,19 @@ tcp_drop_syn_sent(struct inpcb *inp, int /* * When `need fragmentation' ICMP is received, update our idea of the MSS - * based on the new value in the route. Also nudge TCP to send something, - * since we know the packet we just sent was dropped. + * based on the new value. Also nudge TCP to send something, since we + * know the packet we just sent was dropped. * This duplicates some code in the tcp_mss() function in tcp_input.c. */ +static struct inpcb * +tcp_mtudisc_notify(struct inpcb *inp, int error) +{ + + return (tcp_mtudisc(inp, -1)); +} + struct inpcb * -tcp_mtudisc(struct inpcb *inp, int errno) +tcp_mtudisc(struct inpcb *inp, int mtuoffer) { struct tcpcb *tp; struct socket *so; @@ -1724,7 +1733,7 @@ tcp_mtudisc(struct inpcb *inp, int errno tp = intotcpcb(inp); KASSERT(tp != NULL, ("tcp_mtudisc: tp == NULL")); - tcp_mss_update(tp, -1, NULL, NULL); + tcp_mss_update(tp, -1, mtuoffer, NULL, NULL); so = inp->inp_socket; SOCKBUF_LOCK(&so->so_snd); Modified: stable/8/sys/netinet/tcp_var.h ============================================================================== --- stable/8/sys/netinet/tcp_var.h Sat May 5 09:34:35 2012 (r235052) +++ stable/8/sys/netinet/tcp_var.h Sat May 5 10:05:13 2012 (r235053) @@ -661,7 +661,8 @@ void tcp_reass_destroy(void); void tcp_input(struct mbuf *, int); u_long tcp_maxmtu(struct in_conninfo *, int *); u_long tcp_maxmtu6(struct in_conninfo *, int *); -void tcp_mss_update(struct tcpcb *, int, struct hc_metrics_lite *, int *); +void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *, + int *); void tcp_mss(struct tcpcb *, int); int tcp_mssopt(struct in_conninfo *); struct inpcb * From owner-svn-src-all@FreeBSD.ORG Sat May 5 11:11:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 62A45106566B; Sat, 5 May 2012 11:11:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id EFA028FC0A; Sat, 5 May 2012 11:11:30 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q45BBO02076502; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q45BBOPX089033; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q45BBOuE089032; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 May 2012 14:11:24 +0300 From: Konstantin Belousov To: Sergey Kandaurov Message-ID: <20120505111124.GW2358@deviant.kiev.zoral.com.ua> References: <201204171628.q3HGSM9P089821@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lTD11Lcb85B6e8hZ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Kirk McKusick Subject: Re: svn commit: r234386 - in head/sys: fs/coda fs/ext2fs fs/msdosfs fs/nfsclient kern nfsclient sys ufs/ffs ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:11:31 -0000 --lTD11Lcb85B6e8hZ Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 05, 2012 at 01:00:36PM +0400, Sergey Kandaurov wrote: > On 17 April 2012 20:28, Kirk McKusick wrote: > > Author: mckusick > > Date: Tue Apr 17 16:28:22 2012 > > New Revision: 234386 > > URL: http://svn.freebsd.org/changeset/base/234386 > > > > Log: > > =9AReplace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL. > > =9AThe primary changes are that the user of the interface no longer > > =9Aneeds to manage the mount-mutex locking and that the vnode that > > =9Ais returned has its mutex locked (thus avoiding the need to check > > =9Ato see if its is DOOMED or other possible end of life senarios). > > > > =9ATo minimize compatibility issues for third-party developers, the > > =9Aold MNT_VNODE_FOREACH interface will remain available so that this > > =9Achange can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH > > =9Awill be removed in head. > > > > =9AThe reason for this update is to prepare for the addition of the > > =9AMNT_VNODE_FOREACH_ACTIVE interface that will loop over just the > > =9Aactive vnodes associated with a mount point (typically less than > > =9A1% of the vnodes associated with the mount point). > > > > =9AReviewed by: kib > > =9ATested by: =9A Peter Holm > > =9AMFC after: =9A 2 weeks > > >=20 > Hi. >=20 > This commit crashes on old nfsclient. Looks like this change is missed. >=20 > Index: nfsclient/nfs_vfsops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- nfsclient/nfs_vfsops.c (revision 235051) > +++ nfsclient/nfs_vfsops.c (working copy) > @@ -1452,6 +1452,7 @@ > MNT_IUNLOCK(mp); > return (EBADF); > } > + MNT_IUNLOCK(mp); >=20 > /* > * Force stale buffer cache information to be flushed. >=20 Yes, looks so. And, for the purposes for which the check of MNTK_UNMOUNTF was added, the interlock of the struct mount is not needed there at all. I suggest that you just remove MNT_ILOCK/partial MNT_IUNLOCK and commit the change. Thanks. --lTD11Lcb85B6e8hZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+lCtsACgkQC3+MBN1Mb4iXXgCdEPwENnO81zunpeJLET7ZENVr OoAAnj21/9YyyrWjvpj+C+pssi4+Y+De =ohSf -----END PGP SIGNATURE----- --lTD11Lcb85B6e8hZ-- From owner-svn-src-all@FreeBSD.ORG Sat May 5 11:26:09 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E332106564A; Sat, 5 May 2012 11:26:09 +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 49A438FC0C; Sat, 5 May 2012 11:26:09 +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 q45BQ9g5056207; Sat, 5 May 2012 11:26:09 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45BQ9B5056205; Sat, 5 May 2012 11:26:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205051126.q45BQ9B5056205@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 May 2012 11:26:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235054 - head/libexec/rtld-elf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:26:09 -0000 Author: kib Date: Sat May 5 11:26:08 2012 New Revision: 235054 URL: http://svn.freebsd.org/changeset/base/235054 Log: Work around a situation where symlook_obj() could be called for the object for which digest_dynamic1() was not done yet. Just return EINVAL and do not try to dereference NULL buckets hash array. This seems to happen on ia64 for rtld object itself, where the R_IA_64_FPTR64LSB relocations require symbol lookup. The dynamic linker itself does not rely on identity of the C-level function pointers (i.e. function descriptors). Reported and reviewed by: marcel MFC after: 8 days Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Sat May 5 10:05:13 2012 (r235053) +++ head/libexec/rtld-elf/rtld.c Sat May 5 11:26:08 2012 (r235054) @@ -3480,13 +3480,15 @@ symlook_obj(SymLook *req, const Obj_Entr int flags, res, mres; /* - * There is at least one valid hash at this point, and we prefer to use - * the faster GNU version if available. + * If there is at least one valid hash at this point, we prefer to + * use the faster GNU version if available. */ if (obj->valid_hash_gnu) mres = symlook_obj1_gnu(req, obj); - else + else if (obj->valid_hash_sysv) mres = symlook_obj1_sysv(req, obj); + else + return (EINVAL); if (mres == 0) { if (obj->needed_filtees != NULL) { From owner-svn-src-all@FreeBSD.ORG Sat May 5 11:33:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4684F106564A; Sat, 5 May 2012 11:33:49 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 300FC8FC08; Sat, 5 May 2012 11:33:49 +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 q45BXmtT056487; Sat, 5 May 2012 11:33:48 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45BXmF2056485; Sat, 5 May 2012 11:33:48 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201205051133.q45BXmF2056485@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Sat, 5 May 2012 11:33:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235055 - stable/9/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:33:49 -0000 Author: melifaro Date: Sat May 5 11:33:48 2012 New Revision: 235055 URL: http://svn.freebsd.org/changeset/base/235055 Log: MFC r234572 Do not require radix write lock to be held while dumping route table via sysctl(4) interface. This permits router not to stop forwarding packets while route table is being written to user-supplied buffer. Reported by: Pawel Tyll Approved by: kib(mentor) Modified: stable/9/sys/net/rtsock.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/rtsock.c ============================================================================== --- stable/9/sys/net/rtsock.c Sat May 5 11:26:08 2012 (r235054) +++ stable/9/sys/net/rtsock.c Sat May 5 11:33:48 2012 (r235055) @@ -1859,10 +1859,10 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) for (error = 0; error == 0 && i <= lim; i++) { rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i); if (rnh != NULL) { - RADIX_NODE_HEAD_LOCK(rnh); + RADIX_NODE_HEAD_RLOCK(rnh); error = rnh->rnh_walktree(rnh, sysctl_dumpentry, &w); - RADIX_NODE_HEAD_UNLOCK(rnh); + RADIX_NODE_HEAD_RUNLOCK(rnh); } else if (af != 0) error = EAFNOSUPPORT; } From owner-svn-src-all@FreeBSD.ORG Sat May 5 11:34:27 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0DB410657C2; Sat, 5 May 2012 11:34:27 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B0E58FC15; Sat, 5 May 2012 11:34: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 q45BYRtn056545; Sat, 5 May 2012 11:34:27 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45BYRs6056543; Sat, 5 May 2012 11:34:27 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201205051134.q45BYRs6056543@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Sat, 5 May 2012 11:34:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235056 - stable/8/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:34:27 -0000 Author: melifaro Date: Sat May 5 11:34:27 2012 New Revision: 235056 URL: http://svn.freebsd.org/changeset/base/235056 Log: MFC r234572 Do not require radix write lock to be held while dumping route table via sysctl(4) interface. This permits router not to stop forwarding packets while route table is being written to user-supplied buffer. Reported by: Pawel Tyll Approved by: kib(mentor) Modified: stable/8/sys/net/rtsock.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/net/rtsock.c ============================================================================== --- stable/8/sys/net/rtsock.c Sat May 5 11:33:48 2012 (r235055) +++ stable/8/sys/net/rtsock.c Sat May 5 11:34:27 2012 (r235056) @@ -1857,10 +1857,10 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) for (error = 0; error == 0 && i <= lim; i++) { rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i); if (rnh != NULL) { - RADIX_NODE_HEAD_LOCK(rnh); + RADIX_NODE_HEAD_RLOCK(rnh); error = rnh->rnh_walktree(rnh, sysctl_dumpentry, &w); - RADIX_NODE_HEAD_UNLOCK(rnh); + RADIX_NODE_HEAD_RUNLOCK(rnh); } else if (af != 0) error = EAFNOSUPPORT; } From owner-svn-src-all@FreeBSD.ORG Sat May 5 11:54:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56EE3106564A; Sat, 5 May 2012 11:54:24 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5EF7E8FC14; Sat, 5 May 2012 11:54:23 +0000 (UTC) Received: by weyt57 with SMTP id t57so3026559wey.13 for ; Sat, 05 May 2012 04:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=IdTfVTSo2K/pyE5RKDjKieiDwrp/zi76LoD2l7bwoFw=; b=WJouXTUZ614sf/wruqSA9eRAHR4h7Opo13pAzPJR+7LtsnK7Pci0Xv1U7L+j442FX6 D8mKc9BiNMzF3M9FKdrl3mH3lkT2CTKIvAT1asJ/I1k/Ga6JGpezlDjk/lj24ca60C8l ozcBxRU1TaiUtpLy4HTmY4xE/q9t5XhnKpHOg4sMj4YEPUXqMteD9IcdgJcPpHQaJxyT YD93N/D2b5lJ75/FspflL2Wn6Jmqw8ui9c8PAbr4l+n+XNYZv0eTiQatWgsgHwnKlK4m y5hfoyj+Ox0sGO5q66CtCNM59/0rMUOeE+zJtpN5xJY0JwNNfgY4KQ23EwHK2f5FkMUB 3wKQ== Received: by 10.216.132.6 with SMTP id n6mr6205699wei.26.1336218862211; Sat, 05 May 2012 04:54:22 -0700 (PDT) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id e6sm5079134wix.8.2012.05.05.04.54.19 (version=SSLv3 cipher=OTHER); Sat, 05 May 2012 04:54:20 -0700 (PDT) Sender: Alexander Motin Message-ID: <4FA514EA.1020504@FreeBSD.org> Date: Sat, 05 May 2012 14:54:18 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:10.0.3) Gecko/20120328 Thunderbird/10.0.3 MIME-Version: 1.0 To: Joel Dahl References: <201203102158.q2ALw89R080428@svn.freebsd.org> <20120504160806.GF6475@goofy01.vnodelab.local> In-Reply-To: <20120504160806.GF6475@goofy01.vnodelab.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r232798 - in stable/9: share/man/man4 sys/conf sys/dev/sound/pci/hda sys/dev/sound/pcm sys/modules/sound/driver/hda X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:54:24 -0000 On 05/04/12 19:08, Joel Dahl wrote: > On 10-03-2012 21:58, Alexander Motin wrote: >> Author: mav >> Date: Sat Mar 10 21:58:08 2012 >> New Revision: 232798 >> URL: http://svn.freebsd.org/changeset/base/232798 >> >> Log: >> MFC r230130, r230181, r230312, r230326, r230331, r230451, r230465, r230488, >> r230507, r230511, r230513, r230532, r230537, r230551, r230554, r230571, >> r230574, r230585, r230641, r230768, r230807, r231024: >> Sync snd_hda(4) driver with HEAD. >> >> This includes major code refactoring, HDMI support, new volume control, >> automatic recording source selection, runtime reconfigureation, support >> for more then 4 PCM devices on controller, multichannel recording, >> additional playback/record streams, higher bandwidths support, more >> informative device names and many other things. >> >> Sponsored by: iXsystems, Inc. > > I'm still having problems with r230451. Every time I boot one of the > machines I have at home it makes a short but loud "popping" sound. I almost > fell of my chair the first time it happened. Now I'm being forced to unplug > my speakers every time I boot it, just to avoid having a heart attack... I remember about your problem, but so far you are the only who reported it. It may be specific to your system. I don't know how to fix it now. Some deeper experiments are needed to localize the cause. I would start commenting parts of attach/initialization process to find the situation when click disappear. That may give idea about source of click and what to do about it. -- Alexander Motin From owner-svn-src-all@FreeBSD.ORG Sat May 5 14:06:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A40311065670; Sat, 5 May 2012 14:06:16 +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 74C7C8FC15; Sat, 5 May 2012 14:06:16 +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 q45E6GpY061297; Sat, 5 May 2012 14:06:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45E6GNl061295; Sat, 5 May 2012 14:06:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205051406.q45E6GNl061295@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 14:06:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235057 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 14:06:16 -0000 Author: tuexen Date: Sat May 5 14:06:15 2012 New Revision: 235057 URL: http://svn.freebsd.org/changeset/base/235057 Log: Do error checking for the SCTP_RESET_STREAMS, SCTP_RESET_ASSOC, and SCTP_ADD_STREAMS socket options as specified by RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Sat May 5 11:34:27 2012 (r235056) +++ head/sys/netinet/sctp_usrreq.c Sat May 5 14:06:15 2012 (r235057) @@ -4164,7 +4164,6 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_reset_streams, optsize); SCTP_FIND_STCB(inp, stcb, strrst->srs_assoc_id); - if (stcb == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); error = ENOENT; @@ -4179,15 +4178,6 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { - /* - * User did not enable the operation. - */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); - error = EPERM; - SCTP_TCB_UNLOCK(stcb); - break; - } if (stcb->asoc.stream_reset_outstanding) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); error = EALREADY; @@ -4246,6 +4236,21 @@ sctp_setopt(struct socket *so, int optna error = ENOENT; break; } + if (stcb->asoc.peer_supports_strreset == 0) { + /* + * Peer does not support the chunk type. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; + SCTP_TCB_UNLOCK(stcb); + break; + } + if (stcb->asoc.stream_reset_outstanding) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); + error = EALREADY; + SCTP_TCB_UNLOCK(stcb); + break; + } if ((stradd->sas_outstrms == 0) && (stradd->sas_instrms == 0)) { error = EINVAL; @@ -4309,15 +4314,6 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_ASSOC_REQ)) { - /* - * User did not enable the operation. - */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); - error = EPERM; - SCTP_TCB_UNLOCK(stcb); - break; - } if (stcb->asoc.stream_reset_outstanding) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); error = EALREADY; From owner-svn-src-all@FreeBSD.ORG Sat May 5 15:35:23 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D1D0106564A; Sat, 5 May 2012 15:35:23 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 882B38FC0A; Sat, 5 May 2012 15:35:23 +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 q45FZNU5064086; Sat, 5 May 2012 15:35:23 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45FZNiW064083; Sat, 5 May 2012 15:35:23 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205051535.q45FZNiW064083@svn.freebsd.org> From: Dimitry Andric Date: Sat, 5 May 2012 15:35:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235058 - in head: . lib/clang/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 15:35:23 -0000 Author: dim Date: Sat May 5 15:35:22 2012 New Revision: 235058 URL: http://svn.freebsd.org/changeset/base/235058 Log: Make sure a few new internal clang headers get installed, I missed these in the last import. They are sometimes needed when you want to use advanced instructions. Also, add clang's internal stdalign.h header to ObsoleteFiles.inc, since it is redundant: we already have a stdalign.h header in /usr/include. Pointy hat to: dim PR: kern/167574 Submitted by: jkim Reported by: Oliver Hartmann MFC after: 2 weeks Modified: head/ObsoleteFiles.inc head/lib/clang/include/Makefile Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sat May 5 14:06:15 2012 (r235057) +++ head/ObsoleteFiles.inc Sat May 5 15:35:22 2012 (r235058) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20120505: new clang import installed a redundant internal header +OLD_FILES+=usr/include/clang/3.1/stdalign.h # 20120425: libusb version bump (r234684) OLD_LIBS+=usr/lib/libusb.so.2 OLD_LIBS+=usr/lib32/libusb.so.2 Modified: head/lib/clang/include/Makefile ============================================================================== --- head/lib/clang/include/Makefile Sat May 5 14:06:15 2012 (r235057) +++ head/lib/clang/include/Makefile Sat May 5 15:35:22 2012 (r235058) @@ -5,17 +5,23 @@ INCSDIR=${INCLUDEDIR}/clang/3.1 INCS= altivec.h \ + avx2intrin.h \ avxintrin.h \ + bmi2intrin.h \ + bmiintrin.h \ cpuid.h \ emmintrin.h \ + fma4intrin.h \ immintrin.h \ + lzcntintrin.h \ mm3dnow.h \ mm_malloc.h \ mmintrin.h \ + module.map \ nmmintrin.h \ pmmintrin.h \ + popcntintrin.h \ smmintrin.h \ - stdalign.h \ tmmintrin.h \ unwind.h \ wmmintrin.h \ From owner-svn-src-all@FreeBSD.ORG Sat May 5 16:19:19 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BA0E106566C; Sat, 5 May 2012 16:19:19 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from agogare.doit.wisc.edu (agogare.doit.wisc.edu [144.92.197.211]) by mx1.freebsd.org (Postfix) with ESMTP id 69E508FC0A; Sat, 5 May 2012 16:19:19 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth2.wiscmail.wisc.edu by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0M3K00G005C08M00@smtpauth2.wiscmail.wisc.edu>; Sat, 05 May 2012 11:19:12 -0500 (CDT) Received: from comporellon.tachypleus.net ([unknown] [76.210.67.9]) by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0M3K008DY5BS8110@smtpauth2.wiscmail.wisc.edu>; Sat, 05 May 2012 11:19:05 -0500 (CDT) Date: Sat, 05 May 2012 11:19:03 -0500 From: Nathan Whitehorn In-reply-to: <201205050715.q457FZ6v044678@svn.freebsd.org> To: Warner Losh Message-id: <4FA552F7.70306@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.67.9 X-Spam-PmxInfo: Server=avs-13, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.19.163615, SenderIP=76.210.67.9 References: <201205050715.q457FZ6v044678@svn.freebsd.org> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120429 Thunderbird/12.0 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r235050 - head/sys/arm/arm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:19:19 -0000 On 05/05/12 02:15, Warner Losh wrote: > Author: imp > Date: Sat May 5 07:15:34 2012 > New Revision: 235050 > URL: http://svn.freebsd.org/changeset/base/235050 > > Log: > Big endian arm boxes need to have a uname -m of armeb, not arm, so > that the bootstrap from source works correctly. > > MFC after: 4 days > > Modified: > head/sys/arm/arm/identcpu.c > > Modified: head/sys/arm/arm/identcpu.c > ============================================================================== > --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 (r235049) > +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 (r235050) > @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > > #include > #include > > +#if _BYTE_ORDER == _LITTLE_ENDIAN > char machine[] = "arm"; > +#else > +char machine[] = "armeb"; > +#endif > > SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, > machine, 0, "Machine class"); Didn't you mean to change MACHINE_ARCH in /sys/arm/include/param.h? Setting MACHINE=armeb will break lots of things, including self-hosting. -Nathan From owner-svn-src-all@FreeBSD.ORG Sat May 5 16:37:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 514DF106564A; Sat, 5 May 2012 16:37:15 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3CB6B8FC24; Sat, 5 May 2012 16:37: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 q45GbF7O066079; Sat, 5 May 2012 16:37:15 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45GbFdk066077; Sat, 5 May 2012 16:37:15 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205051637.q45GbFdk066077@svn.freebsd.org> From: Baptiste Daroussin Date: Sat, 5 May 2012 16:37: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: r235059 - head/libexec/rtld-elf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:37:15 -0000 Author: bapt Date: Sat May 5 16:37:14 2012 New Revision: 235059 URL: http://svn.freebsd.org/changeset/base/235059 Log: open the resolved path fix debug message Submitted by: John Marino Approved by: des (mentor) Modified: head/libexec/rtld-elf/libmap.c Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Sat May 5 15:35:22 2012 (r235058) +++ head/libexec/rtld-elf/libmap.c Sat May 5 16:37:14 2012 (r235059) @@ -121,16 +121,16 @@ lmc_parse_file(char *path) } } - fd = open(path, O_RDONLY); + fd = open(rpath, O_RDONLY); if (fd == -1) { - dbg("lm_init: open(\"%s\") failed, %s", path, + dbg("lm_parse_file: open(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; } if (fstat(fd, &st) == -1) { close(fd); - dbg("lm_init: fstat(\"%s\") failed, %s", path, + dbg("lm_parse_file: fstat(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; @@ -138,7 +138,7 @@ lmc_parse_file(char *path) lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (lm_map == (const char *)MAP_FAILED) { close(fd); - dbg("lm_init: mmap(\"%s\") failed, %s", path, + dbg("lm_parse_file: mmap(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; From owner-svn-src-all@FreeBSD.ORG Sat May 5 16:41:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 580D9106564A; Sat, 5 May 2012 16:41:18 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 40B5C8FC14; Sat, 5 May 2012 16:41:18 +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 q45GfIeK066305; Sat, 5 May 2012 16:41:18 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45GfInY066297; Sat, 5 May 2012 16:41:18 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201205051641.q45GfInY066297@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 5 May 2012 16:41:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235060 - in stable/9/sys: conf powerpc/conf powerpc/ofw powerpc/powermac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:41:18 -0000 Author: nwhitehorn Date: Sat May 5 16:41:17 2012 New Revision: 235060 URL: http://svn.freebsd.org/changeset/base/235060 Log: MFC r230993,230994,230995,230999,231003,231026,231046,231149,231908: Reduce code duplication in Open Firmware based PCI bus drivers, implement infrastructure for NEW_PCIB, and switch to using NEW_PCIB by default. Added: stable/9/sys/powerpc/ofw/ofw_pci.c - copied, changed from r230993, head/sys/powerpc/ofw/ofw_pci.c stable/9/sys/powerpc/ofw/ofw_pci.h - copied unchanged from r230993, head/sys/powerpc/ofw/ofw_pci.h Modified: stable/9/sys/conf/files.powerpc stable/9/sys/powerpc/conf/DEFAULTS stable/9/sys/powerpc/powermac/cpcht.c stable/9/sys/powerpc/powermac/grackle.c stable/9/sys/powerpc/powermac/gracklevar.h stable/9/sys/powerpc/powermac/uninorthpci.c stable/9/sys/powerpc/powermac/uninorthvar.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/conf/ (props changed) Modified: stable/9/sys/conf/files.powerpc ============================================================================== --- stable/9/sys/conf/files.powerpc Sat May 5 16:37:14 2012 (r235059) +++ stable/9/sys/conf/files.powerpc Sat May 5 16:41:17 2012 (r235060) @@ -133,6 +133,7 @@ powerpc/mpc85xx/openpic_fdt.c optional f powerpc/mpc85xx/pci_fdt.c optional pci mpc85xx powerpc/ofw/ofw_cpu.c optional aim powerpc/ofw/ofw_machdep.c optional aim +powerpc/ofw/ofw_pci.c optional pci aim powerpc/ofw/ofw_pcibus.c optional pci aim powerpc/ofw/ofw_pcib_pci.c optional pci aim powerpc/ofw/ofw_real.c optional aim Modified: stable/9/sys/powerpc/conf/DEFAULTS ============================================================================== --- stable/9/sys/powerpc/conf/DEFAULTS Sat May 5 16:37:14 2012 (r235059) +++ stable/9/sys/powerpc/conf/DEFAULTS Sat May 5 16:41:17 2012 (r235060) @@ -12,3 +12,6 @@ device uart_z8530 options GEOM_PART_APM options GEOM_PART_MBR + +options NEW_PCIB + Copied and modified: stable/9/sys/powerpc/ofw/ofw_pci.c (from r230993, head/sys/powerpc/ofw/ofw_pci.c) ============================================================================== --- head/sys/powerpc/ofw/ofw_pci.c Sat Feb 4 19:54:13 2012 (r230993, copy source) +++ stable/9/sys/powerpc/ofw/ofw_pci.c Sat May 5 16:41:17 2012 (r235060) @@ -71,6 +71,9 @@ static int ofw_pci_activate_resource(de static int ofw_pci_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *res); +static int ofw_pci_adjust_resource(device_t bus, device_t child, + int type, struct resource *res, u_long start, + u_long end); /* * pcib interface. @@ -106,6 +109,7 @@ static device_method_t ofw_pci_methods[] DEVMETHOD(bus_release_resource, ofw_pci_release_resource), DEVMETHOD(bus_activate_resource, ofw_pci_activate_resource), DEVMETHOD(bus_deactivate_resource, ofw_pci_deactivate_resource), + DEVMETHOD(bus_adjust_resource, ofw_pci_adjust_resource), /* pcib interface */ DEVMETHOD(pcib_maxslots, ofw_pci_maxslots), @@ -421,6 +425,36 @@ ofw_pci_deactivate_resource(device_t bus return (rman_deactivate_resource(res)); } +static int +ofw_pci_adjust_resource(device_t bus, device_t child, int type, + struct resource *res, u_long start, u_long end) +{ + struct rman *rm = NULL; + struct ofw_pci_softc *sc = device_get_softc(bus); + + KASSERT(!(rman_get_flags(res) & RF_ACTIVE), + ("active resources cannot be adjusted")); + if (rman_get_flags(res) & RF_ACTIVE) + return (EINVAL); + + switch (type) { + case SYS_RES_MEMORY: + rm = &sc->sc_mem_rman; + break; + case SYS_RES_IOPORT: + rm = &sc->sc_io_rman; + break; + default: + return (ENXIO); + } + + if (!rman_is_region_manager(res, rm)) + return (EINVAL); + + return (rman_adjust_resource(res, start, end)); +} + + static phandle_t ofw_pci_get_node(device_t bus, device_t dev) { Copied: stable/9/sys/powerpc/ofw/ofw_pci.h (from r230993, head/sys/powerpc/ofw/ofw_pci.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/powerpc/ofw/ofw_pci.h Sat May 5 16:41:17 2012 (r235060, copy of r230993, head/sys/powerpc/ofw/ofw_pci.h) @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 2011 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef POWERPC_OFW_OFW_PCI_H +#define POWERPC_OFW_OFW_PCI_H + +/* + * Export class definition for inheritance purposes + */ +DECLARE_CLASS(ofw_pci_driver); + +struct ofw_pci_range { + uint32_t pci_hi; + uint64_t pci; + uint64_t host; + uint64_t size; +}; + +/* + * Quirks for some adapters + */ +enum { + OFW_PCI_QUIRK_RANGES_ON_CHILDREN = 1, +}; + +struct ofw_pci_softc { + device_t sc_dev; + phandle_t sc_node; + int sc_bus; + + int sc_quirks; + + struct ofw_pci_register sc_pcir; + + struct ofw_pci_range *sc_range; + int sc_nrange; + + struct rman sc_io_rman; + struct rman sc_mem_rman; + bus_space_tag_t sc_memt; + bus_dma_tag_t sc_dmat; + + struct ofw_bus_iinfo sc_pci_iinfo; +}; + +int ofw_pci_attach(device_t dev); + +#endif // POWERPC_OFW_OFW_PCI_H + Modified: stable/9/sys/powerpc/powermac/cpcht.c ============================================================================== --- stable/9/sys/powerpc/powermac/cpcht.c Sat May 5 16:37:14 2012 (r235059) +++ stable/9/sys/powerpc/powermac/cpcht.c Sat May 5 16:41:17 2012 (r235060) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -66,30 +67,13 @@ static int cpcht_attach(device_t); static void cpcht_configure_htbridge(device_t, phandle_t); /* - * Bus interface. - */ -static int cpcht_read_ivar(device_t, device_t, int, - uintptr_t *); -static struct resource *cpcht_alloc_resource(device_t bus, device_t child, - int type, int *rid, u_long start, u_long end, - u_long count, u_int flags); -static int cpcht_activate_resource(device_t bus, device_t child, - int type, int rid, struct resource *res); -static int cpcht_release_resource(device_t bus, device_t child, - int type, int rid, struct resource *res); -static int cpcht_deactivate_resource(device_t bus, device_t child, - int type, int rid, struct resource *res); - -/* * pcib interface. */ -static int cpcht_maxslots(device_t); static u_int32_t cpcht_read_config(device_t, u_int, u_int, u_int, u_int, int); static void cpcht_write_config(device_t, u_int, u_int, u_int, u_int, u_int32_t, int); -static int cpcht_route_interrupt(device_t bus, device_t dev, - int pin); +static int cpcht_route_interrupt(device_t, device_t, int); static int cpcht_alloc_msi(device_t dev, device_t child, int count, int maxcount, int *irqs); static int cpcht_release_msi(device_t dev, device_t child, @@ -102,12 +86,6 @@ static int cpcht_map_msi(device_t dev, int irq, uint64_t *addr, uint32_t *data); /* - * ofw_bus interface - */ - -static phandle_t cpcht_get_node(device_t bus, device_t child); - -/* * Driver methods. */ static device_method_t cpcht_methods[] = { @@ -115,17 +93,7 @@ static device_method_t cpcht_methods[] = DEVMETHOD(device_probe, cpcht_probe), DEVMETHOD(device_attach, cpcht_attach), - /* Bus interface */ - DEVMETHOD(bus_read_ivar, cpcht_read_ivar), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, cpcht_alloc_resource), - DEVMETHOD(bus_release_resource, cpcht_release_resource), - DEVMETHOD(bus_activate_resource, cpcht_activate_resource), - DEVMETHOD(bus_deactivate_resource, cpcht_deactivate_resource), - /* pcib interface */ - DEVMETHOD(pcib_maxslots, cpcht_maxslots), DEVMETHOD(pcib_read_config, cpcht_read_config), DEVMETHOD(pcib_write_config, cpcht_write_config), DEVMETHOD(pcib_route_interrupt, cpcht_route_interrupt), @@ -135,9 +103,6 @@ static device_method_t cpcht_methods[] = DEVMETHOD(pcib_release_msix, cpcht_release_msix), DEVMETHOD(pcib_map_msi, cpcht_map_msi), - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, cpcht_get_node), - DEVMETHOD_END }; @@ -158,25 +123,17 @@ static struct cpcht_irq *cpcht_irqmap = uint32_t cpcht_msipic = 0; struct cpcht_softc { - device_t sc_dev; - phandle_t sc_node; + struct ofw_pci_softc pci_sc; vm_offset_t sc_data; uint64_t sc_populated_slots; - struct rman sc_mem_rman; - struct rman sc_io_rman; struct cpcht_irq htirq_map[128]; struct mtx htirq_mtx; }; -static driver_t cpcht_driver = { - "pcib", - cpcht_methods, - sizeof(struct cpcht_softc) -}; - static devclass_t cpcht_devclass; - +DEFINE_CLASS_1(pcib, cpcht_driver, cpcht_methods, sizeof(struct cpcht_softc), + ofw_pci_driver); DRIVER_MODULE(cpcht, nexus, cpcht_driver, cpcht_devclass, 0, 0); #define CPCHT_IOPORT_BASE 0xf4000000UL /* Hardwired */ @@ -186,17 +143,6 @@ DRIVER_MODULE(cpcht, nexus, cpcht_driver #define HTAPIC_TRIGGER_LEVEL 0x02 #define HTAPIC_MASK 0x01 -struct cpcht_range { - u_int32_t pci_hi; - u_int32_t pci_mid; - u_int32_t pci_lo; - u_int32_t junk; - u_int32_t host_hi; - u_int32_t host_lo; - u_int32_t size_hi; - u_int32_t size_lo; -}; - static int cpcht_probe(device_t dev) { @@ -214,7 +160,6 @@ cpcht_probe(device_t dev) if (strcmp(compatible, "u3-ht") != 0) return (ENXIO); - device_set_desc(dev, "IBM CPC9X5 HyperTransport Tunnel"); return (0); } @@ -225,7 +170,7 @@ cpcht_attach(device_t dev) struct cpcht_softc *sc; phandle_t node, child; u_int32_t reg[3]; - int i, error; + int i; node = ofw_bus_get_node(dev); sc = device_get_softc(dev); @@ -233,35 +178,21 @@ cpcht_attach(device_t dev) if (OF_getprop(node, "reg", reg, sizeof(reg)) < 12) return (ENXIO); - sc->sc_dev = dev; - sc->sc_node = node; + if (OF_getproplen(node, "ranges") <= 0) + sc->pci_sc.sc_quirks = OFW_PCI_QUIRK_RANGES_ON_CHILDREN; sc->sc_populated_slots = 0; sc->sc_data = (vm_offset_t)pmap_mapdev(reg[1], reg[2]); - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "CPCHT Device Memory"; - error = rman_init(&sc->sc_mem_rman); - if (error) { - device_printf(dev, "rman_init() failed. error = %d\n", error); - return (error); - } - - sc->sc_io_rman.rm_type = RMAN_ARRAY; - sc->sc_io_rman.rm_descr = "CPCHT I/O Memory"; - error = rman_init(&sc->sc_io_rman); - if (error) { - device_printf(dev, "rman_init() failed. error = %d\n", error); - return (error); - } - /* * Set up the resource manager and the HT->MPIC mapping. For cpcht, * the ranges are properties of the child bridges, and this is also * where we get the HT interrupts properties. */ +#if 0 /* I/O port mappings are usually not in the device tree */ - rman_manage_region(&sc->sc_io_rman, 0, CPCHT_IOPORT_SIZE - 1); + rman_manage_region(&sc->pci_sc.sc_io_rman, 0, CPCHT_IOPORT_SIZE - 1); +#endif bzero(sc->htirq_map, sizeof(sc->htirq_map)); mtx_init(&sc->htirq_mtx, "cpcht irq", NULL, MTX_DEF); @@ -273,9 +204,7 @@ cpcht_attach(device_t dev) /* Now make the mapping table available to the MPIC */ cpcht_irqmap = sc->htirq_map; - device_add_child(dev, "pci", device_get_unit(dev)); - - return (bus_generic_attach(dev)); + return (ofw_pci_attach(dev)); } static void @@ -283,16 +212,16 @@ cpcht_configure_htbridge(device_t dev, p { struct cpcht_softc *sc; struct ofw_pci_register pcir; - struct cpcht_range ranges[7], *rp; - int nranges, ptr, nextptr; + int ptr, nextptr; uint32_t vend, val; int i, nirq, irq; - u_int f, s; + u_int b, f, s; sc = device_get_softc(dev); if (OF_getprop(child, "reg", &pcir, sizeof(pcir)) == -1) return; + b = OFW_PCI_PHYS_HI_BUS(pcir.phys_hi); s = OFW_PCI_PHYS_HI_DEVICE(pcir.phys_hi); f = OFW_PCI_PHYS_HI_FUNCTION(pcir.phys_hi); @@ -303,32 +232,6 @@ cpcht_configure_htbridge(device_t dev, p sc->sc_populated_slots |= (1 << s); /* - * Next grab this child bus's bus ranges. - */ - bzero(ranges, sizeof(ranges)); - nranges = OF_getprop(child, "ranges", ranges, sizeof(ranges)); - nranges /= sizeof(ranges[0]); - - ranges[6].pci_hi = 0; - for (rp = ranges; rp < ranges + nranges && rp->pci_hi != 0; rp++) { - switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) { - case OFW_PCI_PHYS_HI_SPACE_CONFIG: - break; - case OFW_PCI_PHYS_HI_SPACE_IO: - rman_manage_region(&sc->sc_io_rman, rp->pci_lo, - rp->pci_lo + rp->size_lo - 1); - break; - case OFW_PCI_PHYS_HI_SPACE_MEM32: - rman_manage_region(&sc->sc_mem_rman, rp->pci_lo, - rp->pci_lo + rp->size_lo - 1); - break; - case OFW_PCI_PHYS_HI_SPACE_MEM64: - panic("64-bit CPCHT reserved memory!"); - break; - } - } - - /* * Next build up any HT->MPIC mappings for this sub-bus. One would * naively hope that enabling, disabling, and EOIing interrupts would * cause the appropriate HT bus transactions to that effect. This is @@ -341,41 +244,41 @@ cpcht_configure_htbridge(device_t dev, p */ /* All the devices we are interested in have caps */ - if (!(PCIB_READ_CONFIG(dev, 0, s, f, PCIR_STATUS, 2) + if (!(PCIB_READ_CONFIG(dev, b, s, f, PCIR_STATUS, 2) & PCIM_STATUS_CAPPRESENT)) return; - nextptr = PCIB_READ_CONFIG(dev, 0, s, f, PCIR_CAP_PTR, 1); + nextptr = PCIB_READ_CONFIG(dev, b, s, f, PCIR_CAP_PTR, 1); while (nextptr != 0) { ptr = nextptr; - nextptr = PCIB_READ_CONFIG(dev, 0, s, f, + nextptr = PCIB_READ_CONFIG(dev, b, s, f, ptr + PCICAP_NEXTPTR, 1); /* Find the HT IRQ capabilities */ - if (PCIB_READ_CONFIG(dev, 0, s, f, + if (PCIB_READ_CONFIG(dev, b, s, f, ptr + PCICAP_ID, 1) != PCIY_HT) continue; - val = PCIB_READ_CONFIG(dev, 0, s, f, ptr + PCIR_HT_COMMAND, 2); + val = PCIB_READ_CONFIG(dev, b, s, f, ptr + PCIR_HT_COMMAND, 2); if ((val & PCIM_HTCMD_CAP_MASK) != PCIM_HTCAP_INTERRUPT) continue; /* Ask for the IRQ count */ - PCIB_WRITE_CONFIG(dev, 0, s, f, ptr + PCIR_HT_COMMAND, 0x1, 1); - nirq = PCIB_READ_CONFIG(dev, 0, s, f, ptr + 4, 4); + PCIB_WRITE_CONFIG(dev, b, s, f, ptr + PCIR_HT_COMMAND, 0x1, 1); + nirq = PCIB_READ_CONFIG(dev, b, s, f, ptr + 4, 4); nirq = ((nirq >> 16) & 0xff) + 1; device_printf(dev, "%d HT IRQs on device %d.%d\n", nirq, s, f); for (i = 0; i < nirq; i++) { - PCIB_WRITE_CONFIG(dev, 0, s, f, + PCIB_WRITE_CONFIG(dev, b, s, f, ptr + PCIR_HT_COMMAND, 0x10 + (i << 1), 1); - irq = PCIB_READ_CONFIG(dev, 0, s, f, ptr + 4, 4); + irq = PCIB_READ_CONFIG(dev, b, s, f, ptr + 4, 4); /* * Mask this interrupt for now. */ - PCIB_WRITE_CONFIG(dev, 0, s, f, ptr + 4, + PCIB_WRITE_CONFIG(dev, b, s, f, ptr + 4, irq | HTAPIC_MASK, 4); irq = (irq >> 16) & 0xff; @@ -384,10 +287,10 @@ cpcht_configure_htbridge(device_t dev, p sc->htirq_map[irq].ht_base = sc->sc_data + (((((s & 0x1f) << 3) | (f & 0x07)) << 8) | (ptr)); - PCIB_WRITE_CONFIG(dev, 0, s, f, + PCIB_WRITE_CONFIG(dev, b, s, f, ptr + PCIR_HT_COMMAND, 0x11 + (i << 1), 1); sc->htirq_map[irq].eoi_data = - PCIB_READ_CONFIG(dev, 0, s, f, ptr + 4, 4) | + PCIB_READ_CONFIG(dev, b, s, f, ptr + 4, 4) | 0x80000000; /* @@ -395,7 +298,7 @@ cpcht_configure_htbridge(device_t dev, p * in how we signal EOIs. Check if this device was * made by Apple, and act accordingly. */ - vend = PCIB_READ_CONFIG(dev, 0, s, f, + vend = PCIB_READ_CONFIG(dev, b, s, f, PCIR_DEVVENDOR, 4); if ((vend & 0xffff) == 0x106b) sc->htirq_map[irq].apple_eoi = @@ -404,13 +307,6 @@ cpcht_configure_htbridge(device_t dev, p } } -static int -cpcht_maxslots(device_t dev) -{ - - return (PCI_SLOTMAX); -} - static u_int32_t cpcht_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int width) @@ -474,156 +370,11 @@ cpcht_write_config(device_t dev, u_int b } static int -cpcht_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - switch (which) { - case PCIB_IVAR_DOMAIN: - *result = device_get_unit(dev); - return (0); - case PCIB_IVAR_BUS: - *result = 0; /* Root bus */ - return (0); - } - - return (ENOENT); -} - -static phandle_t -cpcht_get_node(device_t bus, device_t dev) -{ - struct cpcht_softc *sc; - - sc = device_get_softc(bus); - /* We only have one child, the PCI bus, which needs our own node. */ - return (sc->sc_node); -} - -static int cpcht_route_interrupt(device_t bus, device_t dev, int pin) { return (pin); } -static struct resource * -cpcht_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct cpcht_softc *sc; - struct resource *rv; - struct rman *rm; - int needactivate; - - needactivate = flags & RF_ACTIVE; - flags &= ~RF_ACTIVE; - - sc = device_get_softc(bus); - - switch (type) { - case SYS_RES_IOPORT: - end = min(end, start + count); - rm = &sc->sc_io_rman; - break; - - case SYS_RES_MEMORY: - rm = &sc->sc_mem_rman; - break; - - case SYS_RES_IRQ: - return (bus_alloc_resource(bus, type, rid, start, end, count, - flags)); - - default: - device_printf(bus, "unknown resource request from %s\n", - device_get_nameunit(child)); - return (NULL); - } - - rv = rman_reserve_resource(rm, start, end, count, flags, child); - if (rv == NULL) { - device_printf(bus, "failed to reserve resource for %s\n", - device_get_nameunit(child)); - return (NULL); - } - - rman_set_rid(rv, *rid); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - device_printf(bus, - "failed to activate resource for %s\n", - device_get_nameunit(child)); - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); -} - -static int -cpcht_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - void *p; - - if (type == SYS_RES_IRQ) - return (bus_activate_resource(bus, type, rid, res)); - - if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { - vm_offset_t start; - - start = (vm_offset_t)rman_get_start(res); - - if (type == SYS_RES_IOPORT) - start += CPCHT_IOPORT_BASE; - - if (bootverbose) - printf("cpcht mapdev: start %zx, len %ld\n", start, - rman_get_size(res)); - - p = pmap_mapdev(start, (vm_size_t)rman_get_size(res)); - if (p == NULL) - return (ENOMEM); - rman_set_virtual(res, p); - rman_set_bustag(res, &bs_le_tag); - rman_set_bushandle(res, (u_long)p); - } - - return (rman_activate_resource(res)); -} - -static int -cpcht_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - if (rman_get_flags(res) & RF_ACTIVE) { - int error = bus_deactivate_resource(child, type, rid, res); - if (error) - return error; - } - - return (rman_release_resource(res)); -} - -static int -cpcht_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - /* - * If this is a memory resource, unmap it. - */ - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - u_int32_t psize; - - psize = rman_get_size(res); - pmap_unmapdev((vm_offset_t)rman_get_virtual(res), psize); - } - - return (rman_deactivate_resource(res)); -} - static int cpcht_alloc_msi(device_t dev, device_t child, int count, int maxcount, int *irqs) Modified: stable/9/sys/powerpc/powermac/grackle.c ============================================================================== --- stable/9/sys/powerpc/powermac/grackle.c Sat May 5 16:37:14 2012 (r235059) +++ stable/9/sys/powerpc/powermac/grackle.c Sat May 5 16:41:17 2012 (r235060) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -67,36 +68,12 @@ static int grackle_probe(device_t); static int grackle_attach(device_t); /* - * Bus interface. - */ -static int grackle_read_ivar(device_t, device_t, int, - uintptr_t *); -static struct resource * grackle_alloc_resource(device_t bus, - device_t child, int type, int *rid, u_long start, - u_long end, u_long count, u_int flags); -static int grackle_release_resource(device_t bus, device_t child, - int type, int rid, struct resource *res); -static int grackle_activate_resource(device_t bus, device_t child, - int type, int rid, struct resource *res); -static int grackle_deactivate_resource(device_t bus, - device_t child, int type, int rid, - struct resource *res); - - -/* * pcib interface. */ -static int grackle_maxslots(device_t); static u_int32_t grackle_read_config(device_t, u_int, u_int, u_int, u_int, int); static void grackle_write_config(device_t, u_int, u_int, u_int, u_int, u_int32_t, int); -static int grackle_route_interrupt(device_t, device_t, int); - -/* - * ofw_bus interface - */ -static phandle_t grackle_get_node(device_t bus, device_t dev); /* * Local routines. @@ -113,35 +90,16 @@ static device_method_t grackle_methods[] DEVMETHOD(device_probe, grackle_probe), DEVMETHOD(device_attach, grackle_attach), - /* Bus interface */ - DEVMETHOD(bus_read_ivar, grackle_read_ivar), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, grackle_alloc_resource), - DEVMETHOD(bus_release_resource, grackle_release_resource), - DEVMETHOD(bus_activate_resource, grackle_activate_resource), - DEVMETHOD(bus_deactivate_resource, grackle_deactivate_resource), - /* pcib interface */ - DEVMETHOD(pcib_maxslots, grackle_maxslots), DEVMETHOD(pcib_read_config, grackle_read_config), DEVMETHOD(pcib_write_config, grackle_write_config), - DEVMETHOD(pcib_route_interrupt, grackle_route_interrupt), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, grackle_get_node), DEVMETHOD_END }; -static driver_t grackle_driver = { - "pcib", - grackle_methods, - sizeof(struct grackle_softc) -}; - static devclass_t grackle_devclass; - +DEFINE_CLASS_1(pcib, grackle_driver, grackle_methods, + sizeof(struct grackle_softc), ofw_pci_driver); DRIVER_MODULE(grackle, nexus, grackle_driver, grackle_devclass, 0, 0); static int @@ -166,21 +124,9 @@ static int grackle_attach(device_t dev) { struct grackle_softc *sc; - phandle_t node; - u_int32_t busrange[2]; - struct grackle_range *rp, *io, *mem[2]; - int nmem, i, error; - node = ofw_bus_get_node(dev); sc = device_get_softc(dev); - if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) != 8) - return (ENXIO); - - sc->sc_dev = dev; - sc->sc_node = node; - sc->sc_bus = busrange[0]; - /* * The Grackle PCI config addr/data registers are actually in * PCI space, but since they are needed to actually probe the @@ -190,83 +136,7 @@ grackle_attach(device_t dev) sc->sc_addr = (vm_offset_t)pmap_mapdev(GRACKLE_ADDR, PAGE_SIZE); sc->sc_data = (vm_offset_t)pmap_mapdev(GRACKLE_DATA, PAGE_SIZE); - bzero(sc->sc_range, sizeof(sc->sc_range)); - sc->sc_nrange = OF_getprop(node, "ranges", sc->sc_range, - sizeof(sc->sc_range)); - - if (sc->sc_nrange == -1) { - device_printf(dev, "could not get ranges\n"); - return (ENXIO); - } - - sc->sc_nrange /= sizeof(sc->sc_range[0]); - - sc->sc_range[6].pci_hi = 0; - io = NULL; - nmem = 0; - - for (rp = sc->sc_range; rp < sc->sc_range + sc->sc_nrange && - rp->pci_hi != 0; rp++) { - switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) { - case OFW_PCI_PHYS_HI_SPACE_CONFIG: - break; - case OFW_PCI_PHYS_HI_SPACE_IO: - io = rp; - break; - case OFW_PCI_PHYS_HI_SPACE_MEM32: - mem[nmem] = rp; - nmem++; - break; - case OFW_PCI_PHYS_HI_SPACE_MEM64: - break; - } - } - - if (io == NULL) { - device_printf(dev, "can't find io range\n"); - return (ENXIO); - } - sc->sc_io_rman.rm_type = RMAN_ARRAY; - sc->sc_io_rman.rm_descr = "Grackle PCI I/O Ports"; - sc->sc_iostart = io->pci_iospace; - if (rman_init(&sc->sc_io_rman) != 0 || - rman_manage_region(&sc->sc_io_rman, io->pci_lo, - io->pci_lo + io->size_lo) != 0) { - panic("grackle_attach: failed to set up I/O rman"); - } - - if (nmem == 0) { - device_printf(dev, "can't find mem ranges\n"); - return (ENXIO); - } - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "Grackle PCI Memory"; - error = rman_init(&sc->sc_mem_rman); - if (error) { - device_printf(dev, "rman_init() failed. error = %d\n", error); - return (error); - } - for (i = 0; i < nmem; i++) { - error = rman_manage_region(&sc->sc_mem_rman, mem[i]->pci_lo, - mem[i]->pci_lo + mem[i]->size_lo); - if (error) { - device_printf(dev, - "rman_manage_region() failed. error = %d\n", error); - return (error); - } - } - - ofw_bus_setup_iinfo(node, &sc->sc_pci_iinfo, sizeof(cell_t)); - - device_add_child(dev, "pci", device_get_unit(dev)); - return (bus_generic_attach(dev)); -} - -static int -grackle_maxslots(device_t dev) -{ - - return (PCI_SLOTMAX); + return (ofw_pci_attach(dev)); } static u_int32_t @@ -340,175 +210,6 @@ grackle_write_config(device_t dev, u_int } static int -grackle_route_interrupt(device_t bus, device_t dev, int pin) -{ - struct grackle_softc *sc; - struct ofw_pci_register reg; - uint32_t pintr, mintr; - phandle_t iparent; - uint8_t maskbuf[sizeof(reg) + sizeof(pintr)]; - - sc = device_get_softc(bus); - pintr = pin; - if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo, ®, - sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr), - &iparent, maskbuf)) - return (MAP_IRQ(iparent, mintr)); - - /* Maybe it's a real interrupt, not an intpin */ - if (pin > 4) - return (pin); - - device_printf(bus, "could not route pin %d for device %d.%d\n", - pin, pci_get_slot(dev), pci_get_function(dev)); - return (PCI_INVALID_IRQ); -} - -static int -grackle_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct grackle_softc *sc; - - sc = device_get_softc(dev); - - switch (which) { - case PCIB_IVAR_DOMAIN: - *result = 0; - return (0); - case PCIB_IVAR_BUS: - *result = sc->sc_bus; - return (0); - } - - return (ENOENT); -} - -static struct resource * -grackle_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct grackle_softc *sc; - struct resource *rv; - struct rman *rm; - int needactivate; - - needactivate = flags & RF_ACTIVE; - flags &= ~RF_ACTIVE; - - sc = device_get_softc(bus); - - switch (type) { - case SYS_RES_MEMORY: - rm = &sc->sc_mem_rman; - break; - - case SYS_RES_IOPORT: - rm = &sc->sc_io_rman; - break; - - case SYS_RES_IRQ: - return (bus_alloc_resource(bus, type, rid, start, end, count, - flags)); - - default: - device_printf(bus, "unknown resource request from %s\n", - device_get_nameunit(child)); - return (NULL); - } - - rv = rman_reserve_resource(rm, start, end, count, flags, child); - if (rv == NULL) { - device_printf(bus, "failed to reserve resource for %s\n", - device_get_nameunit(child)); - return (NULL); - } - - rman_set_rid(rv, *rid); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - device_printf(bus, - "failed to activate resource for %s\n", - device_get_nameunit(child)); - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); -} - -static int -grackle_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - if (rman_get_flags(res) & RF_ACTIVE) { - int error = bus_deactivate_resource(child, type, rid, res); - if (error) - return error; - } - - return (rman_release_resource(res)); -} - -static int -grackle_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - struct grackle_softc *sc; - void *p; - - sc = device_get_softc(bus); - - if (type == SYS_RES_IRQ) { - return (bus_activate_resource(bus, type, rid, res)); - } - if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { - vm_offset_t start; - - start = (vm_offset_t)rman_get_start(res); - /* - * For i/o-ports, convert the start address to the - * MPC106 PCI i/o window - */ - if (type == SYS_RES_IOPORT) - start += sc->sc_iostart; - - if (bootverbose) - printf("grackle mapdev: start %zx, len %ld\n", start, - rman_get_size(res)); - - p = pmap_mapdev(start, (vm_size_t)rman_get_size(res)); - if (p == NULL) - return (ENOMEM); - - rman_set_virtual(res, p); - rman_set_bustag(res, &bs_le_tag); - rman_set_bushandle(res, (u_long)p); - } - - return (rman_activate_resource(res)); -} - -static int -grackle_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sat May 5 16:50:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 975171065670; Sat, 5 May 2012 16:50:13 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 827EF8FC0C; Sat, 5 May 2012 16:50:13 +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 q45GoD9a066605; Sat, 5 May 2012 16:50:13 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45GoDLx066603; Sat, 5 May 2012 16:50:13 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201205051650.q45GoDLx066603@svn.freebsd.org> From: Isabell Long Date: Sat, 5 May 2012 16:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235061 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:50:13 -0000 Author: issyl0 (doc committer) Date: Sat May 5 16:50:12 2012 New Revision: 235061 URL: http://svn.freebsd.org/changeset/base/235061 Log: - Add my mentor/mentee relationship to committers-doc.dot. (where me = issyl0) Approved by: gabor (mentor) Modified: head/share/misc/committers-doc.dot Modified: head/share/misc/committers-doc.dot ============================================================================== --- head/share/misc/committers-doc.dot Sat May 5 16:41:17 2012 (r235060) +++ head/share/misc/committers-doc.dot Sat May 5 16:50:12 2012 (r235061) @@ -60,6 +60,7 @@ ganbold [label="Ganbold Tsagaankhuu\ngan gavin [label="Gavin Atkinson\ngavin@FreeBSD.org\n2011/07/18"] gjb [label="Glen Barber\ngjb@FreeBSD.org\n2010/09/01"] hrs [label="Hiroki Sato\nhrs@FreeBSD.org\n2000/07/06"] +issyl0 [label="Isabell Long\nissyl0@FreeBSD.org\n2012/04/25"] jkois [label="Johann Kois\njkois@FreeBSD.org\n2004/11/11"] joel [label="Joel Dahl\njoel@FreeBSD.org\n2005/04/05"] keramida [label="Giorgos Keramidas\nkeramida@FreeBSD.org\n2001/10/12"] @@ -107,6 +108,7 @@ delphij -> loader gabor -> pgj gabor -> manolis gabor -> taras +gabor -> issyl0 gjb -> wblock From owner-svn-src-all@FreeBSD.ORG Sat May 5 17:10:18 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BEC57106566B; Sat, 5 May 2012 17:10:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id E69DD8FC08; Sat, 5 May 2012 17:10:11 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id q45HA5mQ066520; Sat, 5 May 2012 21:10:05 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id q45HA5VG066519; Sat, 5 May 2012 21:10:05 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Sat, 5 May 2012 21:10:05 +0400 From: Gleb Smirnoff To: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-stable@FreeBSD.org, svn-src-stable-8@FreeBSD.org Message-ID: <20120505171005.GP18777@FreeBSD.org> References: <201205051005.q45A5DTD050083@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201205051005.q45A5DTD050083@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: Re: svn commit: r235053 - stable/8/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 17:10:18 -0000 On Sat, May 05, 2012 at 10:05:13AM +0000, Gleb Smirnoff wrote: T> Author: glebius T> Date: Sat May 5 10:05:13 2012 T> New Revision: 235053 T> URL: http://svn.freebsd.org/changeset/base/235053 T> T> Log: T> Merge 234342 from head: T> When we receive an ICMP unreach need fragmentation datagram, we take T> proposed MTU value from it and update the TCP host cache. Then T> tcp_mss_update() is called on the corresponding tcpcb. It finds the T> just allocated entry in the TCP host cache and updates MSS on the T> tcpcb. And then we do a fast retransmit of what we have in the tcp T> send buffer. T> T> This sequence gets broken if the TCP host cache is exausted. In this T> case allocation fails, and later called tcp_mss_update() finds nothing T> in cache. The fast retransmit is done with not reduced MSS and is T> immidiately replied by remote host with new ICMP datagrams and the T> cycle repeats. This ping-pong can go up to wirespeed. T> T> To fix this: T> - tcp_mss_update() gets new parameter - mtuoffer, that is like T> offer, but needs to have min_protoh subtracted. T> - tcp_mtudisc() as notification method renamed to tcp_mtudisc_notify(). T> - tcp_mtudisc() now accepts not a useless error argument, but proposed T> MTU value, that is passed to tcp_mss_update() as mtuoffer. T> T> Reported by: az T> Reported by: Andrey Zonov T> Reviewed by: andre (previous version of patch) T> T> Tested by: Andrey Zonov Sorry, should have been: tested by az. Andrej Zverev did extensive testing on stable/8. -- Totus tuus, Glebius. From owner-svn-src-all@FreeBSD.ORG Sat May 5 17:16:03 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 00B54106566C; Sat, 5 May 2012 17:16:03 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 83A878FC0A; Sat, 5 May 2012 17:15:59 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q45H9wZm042807 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Sat, 5 May 2012 11:09:58 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4FA552F7.70306@freebsd.org> Date: Sat, 5 May 2012 11:09:57 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <887183C8-204F-4240-9CA7-E9295B6219B9@bsdimp.com> References: <201205050715.q457FZ6v044678@svn.freebsd.org> <4FA552F7.70306@freebsd.org> To: Nathan Whitehorn X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Sat, 05 May 2012 11:09:58 -0600 (MDT) Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Warner Losh Subject: Re: svn commit: r235050 - head/sys/arm/arm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 17:16:03 -0000 On May 5, 2012, at 10:19 AM, Nathan Whitehorn wrote: > On 05/05/12 02:15, Warner Losh wrote: >> Author: imp >> Date: Sat May 5 07:15:34 2012 >> New Revision: 235050 >> URL: http://svn.freebsd.org/changeset/base/235050 >>=20 >> Log: >> Big endian arm boxes need to have a uname -m of armeb, not arm, so >> that the bootstrap from source works correctly. >>=20 >> MFC after: 4 days >>=20 >> Modified: >> head/sys/arm/arm/identcpu.c >>=20 >> Modified: head/sys/arm/arm/identcpu.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 = (r235049) >> +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 = (r235050) >> @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> #include >> +#include >>=20 >> #include >> #include >>=20 >> +#if _BYTE_ORDER =3D=3D _LITTLE_ENDIAN >> char machine[] =3D "arm"; >> +#else >> +char machine[] =3D "armeb"; >> +#endif >>=20 >> SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, >> machine, 0, "Machine class"); >=20 > Didn't you mean to change MACHINE_ARCH in /sys/arm/include/param.h? = Setting MACHINE=3Darmeb will break lots of things, including = self-hosting. DOh! You're right... I'll fix that. :( Warner From owner-svn-src-all@FreeBSD.ORG Sat May 5 17:20:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AAE06106566B; Sat, 5 May 2012 17:20:12 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 963228FC14; Sat, 5 May 2012 17:20:12 +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 q45HKCCO067562; Sat, 5 May 2012 17:20:12 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45HKCcw067560; Sat, 5 May 2012 17:20:12 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205051720.q45HKCcw067560@svn.freebsd.org> From: Warner Losh Date: Sat, 5 May 2012 17:20:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235062 - head/sys/arm/arm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 17:20:12 -0000 Author: imp Date: Sat May 5 17:20:12 2012 New Revision: 235062 URL: http://svn.freebsd.org/changeset/base/235062 Log: I need to change uname -p, not uname -m, so back this out. Also, fix a couple of style(9) issues while I'm here. Submitted by: nathanw, bde Modified: head/sys/arm/arm/identcpu.c Modified: head/sys/arm/arm/identcpu.c ============================================================================== --- head/sys/arm/arm/identcpu.c Sat May 5 16:50:12 2012 (r235061) +++ head/sys/arm/arm/identcpu.c Sat May 5 17:20:12 2012 (r235062) @@ -57,14 +57,10 @@ __FBSDID("$FreeBSD$"); #include #include -#if _BYTE_ORDER == _LITTLE_ENDIAN char machine[] = "arm"; -#else -char machine[] = "armeb"; -#endif SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, - machine, 0, "Machine class"); + machine, 0, "Machine class"); static const char * const generic_steppings[16] = { "rev 0", "rev 1", "rev 2", "rev 3", @@ -140,7 +136,7 @@ static const char * const pxa2x0_steppin }; /* Steppings for PXA255/26x. - * rev 5: PXA26x B0, rev 6: PXA255 A0 + * rev 5: PXA26x B0, rev 6: PXA255 A0 */ static const char * const pxa255_steppings[16] = { "rev 0", "rev 1", "rev 2", "step A-0", @@ -460,7 +456,7 @@ identify_arm_cpu(void) printf(" %dKB/%dB %d-way %s Data cache\n", arm_pdcache_size / 1024, arm_pdcache_line_size, arm_pdcache_ways, - wtnames[arm_pcache_type]); + wtnames[arm_pcache_type]); } } From owner-svn-src-all@FreeBSD.ORG Sat May 5 19:42:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F803106566B; Sat, 5 May 2012 19:42:39 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88CC28FC08; Sat, 5 May 2012 19:42:39 +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 q45JgdGs072001; Sat, 5 May 2012 19:42:39 GMT (envelope-from netchild@svn.freebsd.org) Received: (from netchild@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45Jgd3P071990; Sat, 5 May 2012 19:42:39 GMT (envelope-from netchild@svn.freebsd.org) Message-Id: <201205051942.q45Jgd3P071990@svn.freebsd.org> From: Alexander Leidinger Date: Sat, 5 May 2012 19:42:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235063 - in head/sys: amd64/linux32 compat/linux i386/linux X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 19:42:39 -0000 Author: netchild Date: Sat May 5 19:42:38 2012 New Revision: 235063 URL: http://svn.freebsd.org/changeset/base/235063 Log: - >500 static DTrace probes for the linuxulator - DTrace scripts to check for errors, performance, ... they serve mostly as examples of what you can do with the static probe;s with moderate load the scripts may be overwhelmed, excessive lock-tracing may influence program behavior (see the last design decission) Design decissions: - use "linuxulator" as the provider for the native bitsize; add the bitsize for the non-native emulation (e.g. "linuxuator32" on amd64) - Add probes only for locks which are acquired in one function and released in another function. Locks which are aquired and released in the same function should be easy to pair in the code, inter-function locking is more easy to verify in DTrace. - Probes for locks should be fired after locking and before releasing to prevent races (to provide data/function stability in DTrace, see the man-page of "dtrace -v ..." and the corresponding DTrace docs). Added: head/sys/compat/linux/check_error.d (contents, props changed) head/sys/compat/linux/check_internal_locks.d (contents, props changed) head/sys/compat/linux/linux_dtrace.h (contents, props changed) head/sys/compat/linux/stats_timing.d (contents, props changed) head/sys/compat/linux/trace_futexes.d (contents, props changed) Modified: head/sys/amd64/linux32/linux.h head/sys/amd64/linux32/linux32_dummy.c head/sys/compat/linux/linux_emul.c head/sys/compat/linux/linux_emul.h head/sys/compat/linux/linux_fork.c head/sys/compat/linux/linux_futex.c head/sys/compat/linux/linux_mib.c head/sys/compat/linux/linux_misc.c head/sys/compat/linux/linux_sysctl.c head/sys/compat/linux/linux_time.c head/sys/compat/linux/linux_uid16.c head/sys/compat/linux/linux_util.c head/sys/compat/linux/linux_util.h head/sys/i386/linux/linux.h head/sys/i386/linux/linux_dummy.c Modified: head/sys/amd64/linux32/linux.h ============================================================================== --- head/sys/amd64/linux32/linux.h Sat May 5 17:20:12 2012 (r235062) +++ head/sys/amd64/linux32/linux.h Sat May 5 19:42:38 2012 (r235063) @@ -42,6 +42,7 @@ extern u_char linux_debug_map[]; #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) #define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid #define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid +#define LINUX_DTRACE linuxulator32 #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINUX); Modified: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/amd64/linux32/linux32_dummy.c Sat May 5 19:42:38 2012 (r235063) @@ -29,14 +29,23 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" +#include "opt_kdtrace.h" + #include +#include +#include #include #include #include #include +#include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + DUMMY(stime); DUMMY(olduname); DUMMY(syslog); Added: head/sys/compat/linux/check_error.d ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/check_error.d Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,144 @@ +#!/usr/sbin/dtrace -qs + +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Report error conditions: + * - emulation errors (unsupportet stuff, unknown stuff, ...) + * - kernel errors (resource shortage, ...) + * - programming errors (errors which can happen, but should not happen) + */ + +linuxulator*:dummy::not_implemented, +linuxulator*:emul:proc_exit:child_clear_tid_error, +linuxulator*:emul:proc_exit:futex_failed, +linuxulator*:emul:linux_schedtail:copyout_error, +linuxulator*:futex:futex_get:error, +linuxulator*:futex:futex_sleep:requeue_error, +linuxulator*:futex:futex_sleep:sleep_error, +linuxulator*:futex:futex_wait:copyin_error, +linuxulator*:futex:futex_wait:itimerfix_error, +linuxulator*:futex:futex_wait:sleep_error, +linuxulator*:futex:futex_atomic_op:missing_access_check, +linuxulator*:futex:futex_atomic_op:unimplemented_op, +linuxulator*:futex:futex_atomic_op:unimplemented_cmp, +linuxulator*:futex:linux_sys_futex:unimplemented_clockswitch, +linuxulator*:futex:linux_sys_futex:copyin_error, +linuxulator*:futex:linux_sys_futex:unhandled_efault, +linuxulator*:futex:linux_sys_futex:unimplemented_lock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_unlock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_trylock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_wait_requeue_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_cmp_requeue_pi, +linuxulator*:futex:linux_sys_futex:unknown_operation, +linuxulator*:futex:linux_get_robust_list:copyout_error, +linuxulator*:futex:handle_futex_death:copyin_error, +linuxulator*:futex:fetch_robust_entry:copyin_error, +linuxulator*:futex:release_futexes:copyin_error, +linuxulator*:time:linux_clock_gettime:conversion_error, +linuxulator*:time:linux_clock_gettime:gettime_error, +linuxulator*:time:linux_clock_gettime:copyout_error, +linuxulator*:time:linux_clock_settime:conversion_error, +linuxulator*:time:linux_clock_settime:settime_error, +linuxulator*:time:linux_clock_settime:copyin_error, +linuxulator*:time:linux_clock_getres:conversion_error, +linuxulator*:time:linux_clock_getres:getres_error, +linuxulator*:time:linux_clock_getres:copyout_error, +linuxulator*:time:linux_nanosleep:conversion_error, +linuxulator*:time:linux_nanosleep:nanosleep_error, +linuxulator*:time:linux_nanosleep:copyout_error, +linuxulator*:time:linux_nanosleep:copyin_error, +linuxulator*:time:linux_clock_nanosleep:copyin_error, +linuxulator*:time:linux_clock_nanosleep:conversion_error, +linuxulator*:time:linux_clock_nanosleep:copyout_error, +linuxulator*:time:linux_clock_nanosleep:nanosleep_error, +linuxulator*:sysctl:handle_string:copyout_error, +linuxulator*:sysctl:linux_sysctl:copyin_error, +linuxulator*:mib:linux_sysctl_osname:sysctl_string_error, +linuxulator*:mib:linux_sysctl_osrelease:sysctl_string_error, +linuxulator*:mib:linux_sysctl_oss_version:sysctl_string_error, +linuxulator*:mib:linux_prison_create:vfs_copyopt_error, +linuxulator*:mib:linux_prison_check:vfs_copyopt_error, +linuxulator*:mib:linux_prison_check:vfs_getopt_error, +linuxulator*:mib:linux_prison_set:vfs_copyopt_error, +linuxulator*:mib:linux_prison_set:vfs_getopt_error, +linuxulator*:mib:linux_prison_get:vfs_setopt_error, +linuxulator*:mib:linux_prison_get:vfs_setopts_error +{ + printf("ERROR: %s in %s:%s:%s\n", probename, probeprov, probemod, probefunc); + stack(); + ustack(); +} + +linuxulator*:util:linux_driver_get_name_dev:nullcall, +linuxulator*:util:linux_driver_get_major_minor:nullcall, +linuxulator*:futex:linux_sys_futex:invalid_cmp_requeue_use, +linuxulator*:futex:linux_sys_futex:deprecated_requeue, +linuxulator*:futex:linux_set_robust_list:size_error, +linuxulator*:time:linux_clock_getres:nullcall +{ + printf("WARNING: %s:%s:%s:%s in application %s, maybe an application error?\n", probename, probeprov, probemod, probefunc, execname); + stack(); + ustack(); +} + +linuxulator*:util:linux_driver_get_major_minor:notfound +{ + printf("WARNING: Application %s failed to find %s in %s:%s:%s, this may or may not be a problem.\n", execname, stringof(args[0]), probename, probeprov, probemod); + stack(); + ustack(); +} + +linuxulator*:time:linux_to_native_clockid:unknown_clockid +{ + printf("INFO: Application %s tried to use unknown clockid %d. Please report this to freebsd-emulation@FreeBSD.org.\n", execname, arg0); +} + +linuxulator*:time:linux_to_native_clockid:unsupported_clockid, +linuxulator*:time:linux_clock_nanosleep:unsupported_clockid +{ + printf("WARNING: Application %s tried to use unsupported clockid (%d), this may or may not be a problem for the application.\nPatches to support this clockid are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, arg0); +} + +linuxulator*:time:linux_clock_nanosleep:unsupported_flags +{ + printf("WARNING: Application %s tried to use unsupported flags (%d), this may or may not be a problem for the application.\nPatches to support those flags are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, arg0); +} + +linuxulator*:sysctl:linux_sysctl:wrong_length +{ + printf("ERROR: Application %s issued a sysctl which failed the length restrictions.\nThe length passed is %d, the min length supported is 1 and the max length supported is %d.\n", execname, arg0, arg1); + stack(); + ustack(); +} + +linuxulator*:sysctl:linux_sysctl:unsupported_sysctl +{ + printf("ERROR: Application %s issued an unsupported sysctl (%s).\nPatches to support this sysctl are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, stringof(args[0])); +} Added: head/sys/compat/linux/check_internal_locks.d ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/check_internal_locks.d Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,132 @@ +#!/usr/sbin/dtrace -qs + +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/** + * Check if the internal locks are correctly acquired/released: + * - no recursive locking (mtx locks, write locks) + * - no unlocking of already unlocked one + * + * Print stacktrace if a lock is longer locked than about 10sec or more. + */ + +#pragma D option dynvarsize=32m +#pragma D option specsize=32m + +BEGIN +{ + check["emul_lock"] = 0; + check["emul_shared_rlock"] = 0; + check["emul_shared_wlock"] = 0; + check["futex_mtx"] = 0; +} + +linuxulator*:locks:emul_lock:locked, +linuxulator*:locks:emul_shared_wlock:locked, +linuxulator*:locks:futex_mtx:locked +/check[probefunc] > 0/ +{ + printf("ERROR: recursive lock of %s (%p),", probefunc, arg0); + printf(" or missing SDT probe in kernel. Stack trace follows:"); + stack(); +} + +linuxulator*:locks:emul_lock:locked, +linuxulator*:locks:emul_shared_rlock:locked, +linuxulator*:locks:emul_shared_wlock:locked, +linuxulator*:locks:futex_mtx:locked +{ + ++check[probefunc]; + @stats[probefunc] = count(); + + ts[probefunc] = timestamp; + spec[probefunc] = speculation(); +} + +linuxulator*:locks:emul_lock:unlock, +linuxulator*:locks:emul_shared_rlock:unlock, +linuxulator*:locks:emul_shared_wlock:unlock, +linuxulator*:locks:futex_mtx:unlock +/check[probefunc] == 0/ +{ + printf("ERROR: unlock attemt of unlocked %s (%p),", probefunc, arg0); + printf(" missing SDT probe in kernel, or dtrace program started"); + printf(" while the %s was already held (race condition).", probefunc); + printf(" Stack trace follows:"); + stack(); +} + +linuxulator*:locks:emul_lock:unlock, +linuxulator*:locks:emul_shared_rlock:unlock, +linuxulator*:locks:emul_shared_wlock:unlock, +linuxulator*:locks:futex_mtx:unlock +{ + discard(spec[probefunc]); + spec[probefunc] = 0; + --check[probefunc]; +} + +/* Timeout handling */ + +tick-10s +/spec["emul_lock"] != 0 && timestamp - ts["emul_lock"] >= 9999999000/ +{ + commit(spec["emul_lock"]); + spec["emul_lock"] = 0; +} + +tick-10s +/spec["emul_shared_wlock"] != 0 && timestamp - ts["emul_shared_wlock"] >= 9999999000/ +{ + commit(spec["emul_shared_wlock"]); + spec["emul_shared_wlock"] = 0; +} + +tick-10s +/spec["emul_shared_rlock"] != 0 && timestamp - ts["emul_shared_rlock"] >= 9999999000/ +{ + commit(spec["emul_shared_rlock"]); + spec["emul_shared_rlock"] = 0; +} + +tick-10s +/spec["futex_mtx"] != 0 && timestamp - ts["futex_mtx"] >= 9999999000/ +{ + commit(spec["futex_mtx"]); + spec["futex_mtx"] = 0; +} + + +/* Statistics */ + +END +{ + printf("Number of locks per type:"); + printa(@stats); +} Added: head/sys/compat/linux/linux_dtrace.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/linux_dtrace.h Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,95 @@ +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUX_DTRACE_H_ +#define _LINUX_DTRACE_H_ + +/** + * DTrace support macros for the linuxulator. + * + * Some wrapper macros to make it more easy to handle the linuxulator + * providers and to allow to make the name depend upon the bitsize. + * + * Basically this is the same as the normal SDT macros in sys/sdt.h. The + * difference is that the provider name is automatically inserted, and + * we do not use a different name for the probe-description. + */ + +#define LIN_SDT_PROVIDER_DEFINE(x) SDT_PROVIDER_DEFINE(x) +#define LIN_SDT_PROVIDER_DECLARE(x) SDT_PROVIDER_DECLARE(x) + +#define _LIN_SDT_PROBE_DECLARE(a, b, c, d) SDT_PROBE_DECLARE(a, b, c, d) +#define LIN_SDT_PROBE_DECLARE(a, b, c) _LIN_SDT_PROBE_DECLARE( \ + LINUX_DTRACE, a, b, c) + +#define _LIN_SDT_PROBE_DEFINE0(a, b, c, d) SDT_PROBE_DEFINE(a, \ + b, c, d, d) +#define LIN_SDT_PROBE_DEFINE0(a, b, c) _LIN_SDT_PROBE_DEFINE0(\ + LINUX_DTRACE, a, b, c) +#define _LIN_SDT_PROBE_DEFINE1(a, b, c, d, e) SDT_PROBE_DEFINE1(a, \ + b, c, d, d, e) +#define LIN_SDT_PROBE_DEFINE1(a, b, c, d) _LIN_SDT_PROBE_DEFINE1(\ + LINUX_DTRACE, a, b, c, d) +#define _LIN_SDT_PROBE_DEFINE2(a, b, c, d, e, f) SDT_PROBE_DEFINE2(a, \ + b, c, d, d, e, f) +#define LIN_SDT_PROBE_DEFINE2(a, b, c, d, e) _LIN_SDT_PROBE_DEFINE2(\ + LINUX_DTRACE, a, b, c, d, e) +#define _LIN_SDT_PROBE_DEFINE3(a, b, c, d, e, f, g) SDT_PROBE_DEFINE3(a, \ + b, c, d, d, e, f, g) +#define LIN_SDT_PROBE_DEFINE3(a, b, c, d, e, f) _LIN_SDT_PROBE_DEFINE3(\ + LINUX_DTRACE, a, b, c, d, e, f) +#define _LIN_SDT_PROBE_DEFINE4(a, b, c, d, e, f, g, h) SDT_PROBE_DEFINE4(a, \ + b, c, d, d, e, f, g, h) +#define LIN_SDT_PROBE_DEFINE4(a, b, c, d, e, f, g) _LIN_SDT_PROBE_DEFINE4(\ + LINUX_DTRACE, a, b, c, d, e, f, g) +#define _LIN_SDT_PROBE_DEFINE5(a, b, c, d, e, f, g, h, i) \ + SDT_PROBE_DEFINE5(a, b, c, d, d, e, f, g, h, i) +#define LIN_SDT_PROBE_DEFINE5(a, b, c, d, e, f, g, h) _LIN_SDT_PROBE_DEFINE5(\ + LINUX_DTRACE, a, b, c, d, e, f, g, h) + +#define _LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e, f) SDT_PROBE_ARGTYPE(a, b,\ + c, d, e, f) +#define LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e) _LIN_SDT_PROBE_ARGTYPE( \ + LINUX_DTRACE, a, b, c, d, e) + +#define LIN_SDT_PROBE0(a, b, c) SDT_PROBE1(LINUX_DTRACE, a, b, \ + c, 0) +#define LIN_SDT_PROBE1(a, b, c, d) SDT_PROBE1(LINUX_DTRACE, a, b, \ + c, d) +#define LIN_SDT_PROBE2(a, b, c, d, e) SDT_PROBE2(LINUX_DTRACE, a, b, \ + c, d, e) +#define LIN_SDT_PROBE3(a, b, c, d, e, f) SDT_PROBE3(LINUX_DTRACE, a, b, \ + c, d, e, f) +#define LIN_SDT_PROBE4(a, b, c, d, e, f, g) SDT_PROBE4(LINUX_DTRACE, a, b, \ + c, d, e, f, g) +#define _LIN_SDT_PROBE5(a, b, c, d, e, f, g, h, i) SDT_PROBE(a, b, c, d, \ + e, f, g, h, i) +#define LIN_SDT_PROBE5(a, b, c, d, e, f, g, h) _LIN_SDT_PROBE5(LINUX_DTRACE, \ + a, b, c, d, e, f, g, h) + +#endif /* _LINUX_DTRACE_H_ */ Modified: head/sys/compat/linux/linux_emul.c ============================================================================== --- head/sys/compat/linux/linux_emul.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_emul.c Sat May 5 19:42:38 2012 (r235063) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -53,9 +55,64 @@ __FBSDID("$FreeBSD$"); #include #endif +#include #include #include +/** + * Special DTrace provider for the linuxulator. + * + * In this file we define the provider for the entire linuxulator. All + * modules (= files of the linuxulator) use it. + * + * We define a different name depending on the emulated bitsize, see + * ../..//linux{,32}/linux.h, e.g.: + * native bitsize = linuxulator + * amd64, 32bit emulation = linuxulator32 + */ +LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE); + +/** + * Special DTrace module "locks", it covers some linuxulator internal + * locks. + */ +LIN_SDT_PROBE_DEFINE1(locks, emul_lock, locked, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_lock, unlock, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, locked, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, unlock, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, locked, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, unlock, "struct sx *"); + +/** + * DTrace probes in this module. + */ +LIN_SDT_PROBE_DEFINE2(emul, em_find, entry, "struct proc *", "int"); +LIN_SDT_PROBE_DEFINE0(emul, em_find, return); +LIN_SDT_PROBE_DEFINE3(emul, proc_init, entry, "struct thread *", "pid_t", + "int"); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, create_thread); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, fork); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, exec); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, return); +LIN_SDT_PROBE_DEFINE1(emul, proc_exit, entry, "struct proc *"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exit, futex_failed); +LIN_SDT_PROBE_DEFINE3(emul, proc_exit, reparent, "pid_t", "pid_t", + "struct proc *"); +LIN_SDT_PROBE_DEFINE1(emul, proc_exit, child_clear_tid_error, "int"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exit, return); +LIN_SDT_PROBE_DEFINE2(emul, proc_exec, entry, "struct proc *", + "struct image_params *"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exec, return); +LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, entry); +LIN_SDT_PROBE_DEFINE1(emul, linux_schedtail, copyout_error, "int"); +LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, return); +LIN_SDT_PROBE_DEFINE1(emul, linux_set_tid_address, entry, "int *"); +LIN_SDT_PROBE_DEFINE0(emul, linux_set_tid_address, return); +LIN_SDT_PROBE_DEFINE2(emul, linux_kill_threads, entry, "struct thread *", + "int"); +LIN_SDT_PROBE_DEFINE1(emul, linux_kill_threads, kill, "pid_t"); +LIN_SDT_PROBE_DEFINE0(emul, linux_kill_threads, return); + struct sx emul_shared_lock; struct mtx emul_lock; @@ -65,6 +122,8 @@ em_find(struct proc *p, int locked) { struct linux_emuldata *em; + LIN_SDT_PROBE2(emul, em_find, entry, p, locked); + if (locked == EMUL_DOLOCK) EMUL_LOCK(&emul_lock); @@ -73,6 +132,7 @@ em_find(struct proc *p, int locked) if (em == NULL && locked == EMUL_DOLOCK) EMUL_UNLOCK(&emul_lock); + LIN_SDT_PROBE1(emul, em_find, return, em); return (em); } @@ -82,8 +142,10 @@ linux_proc_init(struct thread *td, pid_t struct linux_emuldata *em, *p_em; struct proc *p; + LIN_SDT_PROBE3(emul, proc_init, entry, td, child, flags); + if (child != 0) { - /* non-exec call */ + /* fork or create a thread */ em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO); em->pid = child; em->pdeath_signal = 0; @@ -91,9 +153,12 @@ linux_proc_init(struct thread *td, pid_t em->robust_futexes = NULL; if (flags & LINUX_CLONE_THREAD) { /* handled later in the code */ + LIN_SDT_PROBE0(emul, proc_init, create_thread); } else { struct linux_emuldata_shared *s; + LIN_SDT_PROBE0(emul, proc_init, fork); + s = malloc(sizeof *s, M_LINUX, M_WAITOK | M_ZERO); s->refs = 1; s->group_pid = child; @@ -102,6 +167,9 @@ linux_proc_init(struct thread *td, pid_t em->shared = s; } } else { + /* exec */ + LIN_SDT_PROBE0(emul, proc_init, exec); + /* lookup the old one */ em = em_find(td->td_proc, EMUL_DOLOCK); KASSERT(em != NULL, ("proc_init: emuldata not found in exec case.\n")); @@ -136,8 +204,7 @@ linux_proc_init(struct thread *td, pid_t * rwlock held */ } - } - if (child != 0) { + EMUL_SHARED_WLOCK(&emul_shared_lock); LIST_INSERT_HEAD(&em->shared->threads, em, threads); EMUL_SHARED_WUNLOCK(&emul_shared_lock); @@ -149,6 +216,7 @@ linux_proc_init(struct thread *td, pid_t } else EMUL_UNLOCK(&emul_lock); + LIN_SDT_PROBE0(emul, proc_init, return); return (0); } @@ -164,6 +232,8 @@ linux_proc_exit(void *arg __unused, stru if (__predict_true(p->p_sysent != &elf_linux_sysvec)) return; + LIN_SDT_PROBE1(emul, proc_exit, entry, p); + release_futexes(p); /* find the emuldata */ @@ -173,6 +243,9 @@ linux_proc_exit(void *arg __unused, stru /* reparent all procs that are not a thread leader to initproc */ if (em->shared->group_pid != p->p_pid) { + LIN_SDT_PROBE3(emul, proc_exit, reparent, + em->shared->group_pid, p->p_pid, p); + child_clear_tid = em->child_clear_tid; EMUL_UNLOCK(&emul_lock); sx_xlock(&proctree_lock); @@ -208,7 +281,12 @@ linux_proc_exit(void *arg __unused, stru error = copyout(&null, child_clear_tid, sizeof(null)); if (error) { + LIN_SDT_PROBE1(emul, proc_exit, + child_clear_tid_error, error); + free(em, M_LINUX); + + LIN_SDT_PROBE0(emul, proc_exit, return); return; } @@ -224,8 +302,10 @@ linux_proc_exit(void *arg __unused, stru * this cannot happen at the moment and if this happens it * probably means there is a user space bug */ - if (error) + if (error) { + LIN_SDT_PROBE0(emul, proc_exit, futex_failed); printf(LMSG("futex stuff in proc_exit failed.\n")); + } } /* clean the stuff up */ @@ -250,6 +330,8 @@ linux_proc_exit(void *arg __unused, stru EMUL_UNLOCK(&emul_lock); } sx_xunlock(&proctree_lock); + + LIN_SDT_PROBE0(emul, proc_exit, return); } /* @@ -260,6 +342,9 @@ linux_proc_exit(void *arg __unused, stru void linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp) { + if (__predict_false(imgp->sysent == &elf_linux_sysvec)) { + LIN_SDT_PROBE2(emul, proc_exec, entry, p, imgp); + } if (__predict_false(imgp->sysent == &elf_linux_sysvec && p->p_sysent != &elf_linux_sysvec)) linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); @@ -297,6 +382,10 @@ linux_proc_exec(void *arg __unused, stru free(em, M_LINUX); } + + if (__predict_false(imgp->sysent == &elf_linux_sysvec)) { + LIN_SDT_PROBE0(emul, proc_exec, return); + } } void @@ -309,6 +398,8 @@ linux_schedtail(struct thread *td) p = td->td_proc; + LIN_SDT_PROBE1(emul, linux_schedtail, entry, p); + /* find the emuldata */ em = em_find(p, EMUL_DOLOCK); @@ -316,10 +407,18 @@ linux_schedtail(struct thread *td) child_set_tid = em->child_set_tid; EMUL_UNLOCK(&emul_lock); - if (child_set_tid != NULL) + if (child_set_tid != NULL) { error = copyout(&p->p_pid, (int *)child_set_tid, sizeof(p->p_pid)); + if (error != 0) { + LIN_SDT_PROBE1(emul, linux_schedtail, copyout_error, + error); + } + } + + LIN_SDT_PROBE0(emul, linux_schedtail, return); + return; } @@ -328,10 +427,7 @@ linux_set_tid_address(struct thread *td, { struct linux_emuldata *em; -#ifdef DEBUG - if (ldebug(set_tid_address)) - printf(ARGS(set_tid_address, "%p"), args->tidptr); -#endif + LIN_SDT_PROBE1(emul, linux_set_tid_address, entry, args->tidptr); /* find the emuldata */ em = em_find(td->td_proc, EMUL_DOLOCK); @@ -342,6 +438,8 @@ linux_set_tid_address(struct thread *td, td->td_retval[0] = td->td_proc->p_pid; EMUL_UNLOCK(&emul_lock); + + LIN_SDT_PROBE0(emul, linux_set_tid_address, return); return 0; } @@ -351,6 +449,8 @@ linux_kill_threads(struct thread *td, in struct linux_emuldata *em, *td_em, *tmp_em; struct proc *sp; + LIN_SDT_PROBE2(emul, linux_kill_threads, entry, td, sig); + td_em = em_find(td->td_proc, EMUL_DONTLOCK); KASSERT(td_em != NULL, ("linux_kill_threads: emuldata not found.\n")); @@ -364,9 +464,10 @@ linux_kill_threads(struct thread *td, in if ((sp->p_flag & P_WEXIT) == 0) kern_psignal(sp, sig); PROC_UNLOCK(sp); -#ifdef DEBUG - printf(LMSG("linux_kill_threads: kill PID %d\n"), em->pid); -#endif + + LIN_SDT_PROBE1(emul, linux_kill_threads, kill, em->pid); } EMUL_SHARED_RUNLOCK(&emul_shared_lock); + + LIN_SDT_PROBE0(emul, linux_kill_threads, return); } Modified: head/sys/compat/linux/linux_emul.h ============================================================================== --- head/sys/compat/linux/linux_emul.h Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_emul.h Sat May 5 19:42:38 2012 (r235063) @@ -64,13 +64,42 @@ struct linux_emuldata { struct linux_emuldata *em_find(struct proc *, int locked); -#define EMUL_LOCK(l) mtx_lock(l) -#define EMUL_UNLOCK(l) mtx_unlock(l) - -#define EMUL_SHARED_RLOCK(l) sx_slock(l) -#define EMUL_SHARED_RUNLOCK(l) sx_sunlock(l) -#define EMUL_SHARED_WLOCK(l) sx_xlock(l) -#define EMUL_SHARED_WUNLOCK(l) sx_xunlock(l) +/* + * DTrace probes for locks should be fired after locking and before releasing + * to prevent races (to provide data/function stability in dtrace, see the + * output of "dtrace -v ..." and the corresponding dtrace docs). + */ +#define EMUL_LOCK(l) do { \ + mtx_lock(l); \ + LIN_SDT_PROBE1(locks, emul_lock, \ + locked, l); \ + } while (0) +#define EMUL_UNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_lock, \ + unlock, l); \ + mtx_unlock(l); \ + } while (0) + +#define EMUL_SHARED_RLOCK(l) do { \ + sx_slock(l); \ + LIN_SDT_PROBE1(locks, emul_shared_rlock, \ + locked, l); \ + } while (0) +#define EMUL_SHARED_RUNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_shared_rlock, \ + unlock, l); \ + sx_sunlock(l); \ + } while (0) +#define EMUL_SHARED_WLOCK(l) do { \ + sx_xlock(l); \ + LIN_SDT_PROBE1(locks, emul_shared_wlock, \ + locked, l); \ + } while (0) +#define EMUL_SHARED_WUNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_shared_wlock, \ + unlock, l); \ + sx_xunlock(l); \ + } while (0) /* for em_find use */ #define EMUL_DOLOCK 1 Modified: head/sys/compat/linux/linux_fork.c ============================================================================== --- head/sys/compat/linux/linux_fork.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_fork.c Sat May 5 19:42:38 2012 (r235063) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -48,9 +50,17 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#include #include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + +/* Linuxulator-global DTrace probes */ +LIN_SDT_PROBE_DECLARE(locks, emul_lock, locked); +LIN_SDT_PROBE_DECLARE(locks, emul_lock, unlock); + int linux_fork(struct thread *td, struct linux_fork_args *args) Modified: head/sys/compat/linux/linux_futex.c ============================================================================== --- head/sys/compat/linux/linux_futex.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_futex.c Sat May 5 19:42:38 2012 (r235063) @@ -38,6 +38,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #endif #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -51,6 +52,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #include #include #include +#include #include #include @@ -61,10 +63,131 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #include #include #endif +#include #include #include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + +/* Linuxulator-global DTrace probes */ +LIN_SDT_PROBE_DECLARE(locks, emul_lock, locked); +LIN_SDT_PROBE_DECLARE(locks, emul_lock, unlock); + +/** + * Futex part for the special DTrace module "locks". + */ +LIN_SDT_PROBE_DEFINE1(locks, futex_mtx, locked, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, futex_mtx, unlock, "struct mtx *"); + +/** + * Per futex probes. + */ +LIN_SDT_PROBE_DEFINE1(futex, futex, create, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(futex, futex, destroy, "struct sx *"); + +/** + * DTrace probes in this module. + */ +LIN_SDT_PROBE_DEFINE2(futex, futex_put, entry, "struct futex *", + "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_put, destroy, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_put, unlock, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE0(futex, futex_put, return); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, entry, "uint32_t *", "struct futex **", + "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, umtx_key_get_error, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, shared, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, null, "uint32_t *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, new, "uint32_t *", "uint32_t", "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get, entry, "uint32_t *", + "struct waiting_proc **", "struct futex **"); +LIN_SDT_PROBE_DEFINE0(futex, futex_get, error); +LIN_SDT_PROBE_DEFINE1(futex, futex_get, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_sleep, entry, "struct futex *", + "struct waiting_proc **", "int"); +LIN_SDT_PROBE_DEFINE5(futex, futex_sleep, requeue_error, "int", "uint32_t *", + "struct waiting_proc *", "uint32_t *", "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, futex_sleep, sleep_error, "int", "uint32_t *", + "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE1(futex, futex_sleep, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_wake, entry, "struct futex *", "int", + "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, futex_wake, iterate, "uint32_t", + "struct waiting_proc *", "uin32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wake, wakeup, "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wake, return, "int"); +LIN_SDT_PROBE_DEFINE4(futex, futex_requeue, entry, "struct futex *", "int", + "struct futex *", "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_requeue, wakeup, "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_requeue, requeue, "uint32_t *", + "struct waiting_proc *", "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_requeue, return, "int"); +LIN_SDT_PROBE_DEFINE4(futex, futex_wait, entry, "struct futex *", + "struct waiting_proc **", "struct l_timespec *", "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, itimerfix_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, sleep_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_atomic_op, entry, "struct thread *", + "int", "uint32_t"); +LIN_SDT_PROBE_DEFINE4(futex, futex_atomic_op, decoded_op, "int", "int", "int", + "int"); +LIN_SDT_PROBE_DEFINE0(futex, futex_atomic_op, missing_access_check); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, unimplemented_op, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, unimplemented_cmp, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_sys_futex, entry, "struct thread *", + "struct linux_sys_futex_args *"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_clockswitch); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, invalid_cmp_requeue_use); +LIN_SDT_PROBE_DEFINE3(futex, linux_sys_futex, debug_wait, "uint32_t *", + "uint32_t", "uint32_t"); +LIN_SDT_PROBE_DEFINE4(futex, linux_sys_futex, debug_wait_value_neq, + "uint32_t *", "uint32_t", "int", "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, linux_sys_futex, debug_wake, "uint32_t *", + "uint32_t", "uint32_t"); +LIN_SDT_PROBE_DEFINE5(futex, linux_sys_futex, debug_cmp_requeue, "uint32_t *", + "uint32_t", "uint32_t", "uint32_t *", "struct l_timespec *"); +LIN_SDT_PROBE_DEFINE2(futex, linux_sys_futex, debug_cmp_requeue_value_neq, + "uint32_t", "int"); +LIN_SDT_PROBE_DEFINE5(futex, linux_sys_futex, debug_wake_op, "uint32_t *", + "int", "uint32_t", "uint32_t *", "uint32_t"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unhandled_efault); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_lock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_unlock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_trylock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, deprecated_requeue); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_wait_requeue_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_cmp_requeue_pi); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, unknown_operation, "int"); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_set_robust_list, entry, "struct thread *", + "struct linux_set_robust_list_args *"); +LIN_SDT_PROBE_DEFINE0(futex, linux_set_robust_list, size_error); +LIN_SDT_PROBE_DEFINE1(futex, linux_set_robust_list, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_get_robust_list, entry, "struct thread *", + "struct linux_get_robust_list_args *"); +LIN_SDT_PROBE_DEFINE1(futex, linux_get_robust_list, copyout_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, linux_get_robust_list, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, handle_futex_death, entry, "struct proc *", + "uint32_t *", "int"); +LIN_SDT_PROBE_DEFINE1(futex, handle_futex_death, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, handle_futex_death, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, fetch_robust_entry, entry, + "struct linux_robust_list **", "struct linux_robust_list **", "int *"); +LIN_SDT_PROBE_DEFINE1(futex, fetch_robust_entry, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, fetch_robust_entry, return, "int"); +LIN_SDT_PROBE_DEFINE1(futex, release_futexes, entry, "struct proc *"); +LIN_SDT_PROBE_DEFINE1(futex, release_futexes, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE0(futex, release_futexes, return); + static MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes"); static MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futexes wp"); @@ -90,13 +213,30 @@ struct futex_list futex_list; #define FUTEX_LOCK(f) sx_xlock(&(f)->f_lck) #define FUTEX_UNLOCK(f) sx_xunlock(&(f)->f_lck) -#define FUTEX_INIT(f) sx_init_flags(&(f)->f_lck, "ftlk", SX_DUPOK) -#define FUTEX_DESTROY(f) sx_destroy(&(f)->f_lck) +#define FUTEX_INIT(f) do { \ + sx_init_flags(&(f)->f_lck, "ftlk", \ + SX_DUPOK); \ + LIN_SDT_PROBE1(futex, futex, create, \ + &(f)->f_lck); \ + } while (0) +#define FUTEX_DESTROY(f) do { \ + LIN_SDT_PROBE1(futex, futex, destroy, \ + &(f)->f_lck); \ + sx_destroy(&(f)->f_lck); \ + } while (0) #define FUTEX_ASSERT_LOCKED(f) sx_assert(&(f)->f_lck, SA_XLOCKED) struct mtx futex_mtx; /* protects the futex list */ -#define FUTEXES_LOCK mtx_lock(&futex_mtx) -#define FUTEXES_UNLOCK mtx_unlock(&futex_mtx) +#define FUTEXES_LOCK do { \ + mtx_lock(&futex_mtx); \ + LIN_SDT_PROBE1(locks, futex_mtx, \ + locked, &futex_mtx); \ + } while (0) +#define FUTEXES_UNLOCK do { \ + LIN_SDT_PROBE1(locks, futex_mtx, \ + unlock, &futex_mtx); \ + mtx_unlock(&futex_mtx); \ + } while (0) /* flags for futex_get() */ #define FUTEX_CREATE_WP 0x1 /* create waiting_proc */ @@ -123,6 +263,7 @@ int futex_xorl(int oparg, uint32_t *uadd static void futex_put(struct futex *f, struct waiting_proc *wp) { + LIN_SDT_PROBE2(futex, futex_put, entry, f, wp); FUTEX_ASSERT_LOCKED(f); if (wp != NULL) { @@ -137,18 +278,26 @@ futex_put(struct futex *f, struct waitin FUTEXES_UNLOCK; FUTEX_UNLOCK(f); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sat May 5 20:07:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDAFB106566C; Sat, 5 May 2012 20:07:33 +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 C58AF8FC08; Sat, 5 May 2012 20:07:33 +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 q45K7XXI073528; Sat, 5 May 2012 20:07:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45K7X4e073525; Sat, 5 May 2012 20:07:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205052007.q45K7X4e073525@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 20:07:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235064 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 20:07:34 -0000 Author: tuexen Date: Sat May 5 20:07:33 2012 New Revision: 235064 URL: http://svn.freebsd.org/changeset/base/235064 Log: Honor SCTP_ENABLE_STREAM_RESET socket option when processing incoming requests. Fix also the provided result in the response and use names as specified in RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_header.h head/sys/netinet/sctp_input.c Modified: head/sys/netinet/sctp_header.h ============================================================================== --- head/sys/netinet/sctp_header.h Sat May 5 19:42:38 2012 (r235063) +++ head/sys/netinet/sctp_header.h Sat May 5 20:07:33 2012 (r235064) @@ -499,12 +499,13 @@ struct sctp_stream_reset_add_strm { uint16_t reserved; } SCTP_PACKED; -#define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ -#define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ -#define SCTP_STREAM_RESET_REJECT 0x00000002 /* refused to do it */ -#define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ -#define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ -#define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ +#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */ +#define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001 +#define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002 +#define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */ +#define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004 +#define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005 +#define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */ /* * convience structures, note that if you are making a request for specific Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Sat May 5 19:42:38 2012 (r235063) +++ head/sys/netinet/sctp_input.c Sat May 5 20:07:33 2012 (r235064) @@ -3599,7 +3599,7 @@ sctp_handle_stream_reset_response(struct asoc->stream_reset_out_is_outstanding = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* do it */ sctp_reset_out_streams(stcb, number_entries, srparam->list_of_streams); } else { @@ -3610,7 +3610,7 @@ sctp_handle_stream_reset_response(struct number_entries = (lparm_len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t); if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_PERFORMED) { + if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3626,7 +3626,7 @@ sctp_handle_stream_reset_response(struct stcb->asoc.strm_pending_add_size = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* Put the new streams into effect */ stcb->asoc.streamoutcnt += num_stream; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); @@ -3637,7 +3637,7 @@ sctp_handle_stream_reset_response(struct } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_PERFORMED) { + if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, SCTP_STREAM_CHANGED_DENIED); } @@ -3655,7 +3655,7 @@ sctp_handle_stream_reset_response(struct /* huh ? */ return (0); } - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { resp = (struct sctp_stream_reset_response_tsn *)respin; asoc->stream_reset_outstanding--; fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); @@ -3714,10 +3714,12 @@ sctp_handle_str_reset_request_in(struct seq = ntohl(req->request_seq); if (asoc->str_reset_seq_in == seq) { - if (trunc) { + asoc->last_reset_action[1] = asoc->last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (trunc) { /* Can't do it, since they exceeded our buffer size */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else if (stcb->asoc.stream_reset_out_is_outstanding == 0) { len = ntohs(req->ph.param_length); number_entries = ((len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t)); @@ -3725,9 +3727,7 @@ sctp_handle_str_reset_request_in(struct temp = ntohs(req->list_of_streams[i]); req->list_of_streams[i] = temp; } - /* move the reset action back one */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; sctp_add_stream_reset_out(chk, number_entries, req->list_of_streams, asoc->str_reset_seq_out, seq, (asoc->sending_seq - 1)); @@ -3737,8 +3737,7 @@ sctp_handle_str_reset_request_in(struct stcb->asoc.stream_reset_outstanding++; } else { /* Can't do it, since we have sent one out */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_TRY_LATER; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS; } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; @@ -3747,7 +3746,7 @@ sctp_handle_str_reset_request_in(struct } else if (asoc->str_reset_seq_in - 2 == seq) { sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3769,7 +3768,13 @@ sctp_handle_str_reset_request_tsn(struct seq = ntohl(req->request_seq); if (asoc->str_reset_seq_in == seq) { - fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; + + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else + fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); fwdtsn.ch.chunk_type = SCTP_FORWARD_CUM_TSN; fwdtsn.ch.chunk_flags = 0; fwdtsn.new_cumulative_tsn = htonl(stcb->asoc.highest_tsn_inside_map + 1); @@ -3777,45 +3782,41 @@ sctp_handle_str_reset_request_tsn(struct if (abort_flag) { return (1); } - stcb->asoc.highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA; + asoc->highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA; if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) { sctp_log_map(0, 10, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT); } - stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map; - stcb->asoc.mapping_array_base_tsn = stcb->asoc.highest_tsn_inside_map + 1; - memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size); - stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map; - memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.mapping_array_size); - atomic_add_int(&stcb->asoc.sending_seq, 1); + asoc->tsn_last_delivered = asoc->cumulative_tsn = asoc->highest_tsn_inside_map; + asoc->mapping_array_base_tsn = asoc->highest_tsn_inside_map + 1; + memset(asoc->mapping_array, 0, asoc->mapping_array_size); + asoc->highest_tsn_inside_nr_map = asoc->highest_tsn_inside_map; + memset(asoc->nr_mapping_array, 0, asoc->mapping_array_size); + atomic_add_int(&asoc->sending_seq, 1); /* save off historical data for retrans */ - stcb->asoc.last_sending_seq[1] = stcb->asoc.last_sending_seq[0]; - stcb->asoc.last_sending_seq[0] = stcb->asoc.sending_seq; - stcb->asoc.last_base_tsnsent[1] = stcb->asoc.last_base_tsnsent[0]; - stcb->asoc.last_base_tsnsent[0] = stcb->asoc.mapping_array_base_tsn; + asoc->last_sending_seq[1] = asoc->last_sending_seq[0]; + asoc->last_sending_seq[0] = asoc->sending_seq; + asoc->last_base_tsnsent[1] = asoc->last_base_tsnsent[0]; + asoc->last_base_tsnsent[0] = asoc->mapping_array_base_tsn; sctp_add_stream_reset_result_tsn(chk, ntohl(req->request_seq), - SCTP_STREAM_RESET_PERFORMED, - stcb->asoc.sending_seq, - stcb->asoc.mapping_array_base_tsn); + SCTP_STREAM_RESET_RESULT_PERFORMED, + asoc->sending_seq, + asoc->mapping_array_base_tsn); sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + asoc->last_reset_action[1] = asoc->last_reset_action[0]; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; + sctp_notify_stream_reset_tsn(stcb, asoc->sending_seq, (asoc->mapping_array_base_tsn + 1), 0); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[0], - stcb->asoc.last_sending_seq[0], - stcb->asoc.last_base_tsnsent[0] - ); + asoc->last_sending_seq[0], asoc->last_base_tsnsent[0]); } else if (asoc->str_reset_seq_in - 2 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[1], - stcb->asoc.last_sending_seq[1], - stcb->asoc.last_base_tsnsent[1] - ); + asoc->last_sending_seq[1], asoc->last_base_tsnsent[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } return (0); } @@ -3846,12 +3847,14 @@ sctp_handle_str_reset_request_out(struct /* move the reset action back one */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; - if (trunc) { - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + if (!(asoc->local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (trunc) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* we can do it now */ sctp_reset_in_stream(stcb, number_entries, req->list_of_streams); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; } else { /* * we must queue it up and thus wait for the TSN's @@ -3865,8 +3868,8 @@ sctp_handle_str_reset_request_out(struct siz, SCTP_M_STRESET); if (liste == NULL) { /* gak out of memory */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_REJECT); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); return; } liste->tsn = tsn; @@ -3874,7 +3877,7 @@ sctp_handle_str_reset_request_out(struct memcpy(&liste->req, req, (sizeof(struct sctp_stream_reset_out_request) + (number_entries * sizeof(uint16_t)))); TAILQ_INSERT_TAIL(&asoc->resetHead, liste, next_resp); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; @@ -3891,7 +3894,7 @@ sctp_handle_str_reset_request_out(struct */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3914,12 +3917,14 @@ sctp_handle_str_reset_add_strm(struct sc /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { num_stream += stcb->asoc.streamincnt; - if ((num_stream > stcb->asoc.max_inbound_streams) || + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if ((num_stream > stcb->asoc.max_inbound_streams) || (num_stream > 0xffff)) { /* We must reject it they ask for to many */ denied: - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else { /* Ok, we can do that :-) */ struct sctp_stream_in *oldstrm; @@ -3955,8 +3960,7 @@ sctp_handle_str_reset_add_strm(struct sc SCTP_FREE(oldstrm, SCTP_M_STRMI); /* update the size */ stcb->asoc.streamincnt = num_stream; - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); @@ -3974,7 +3978,7 @@ sctp_handle_str_reset_add_strm(struct sc */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3996,10 +4000,12 @@ sctp_handle_str_reset_add_out_strm(struc num_stream = ntohs(str_add->number_of_streams); /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { - if (stcb->asoc.stream_reset_outstanding) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (stcb->asoc.stream_reset_outstanding) { /* We must reject it we have something pending */ - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS; } else { /* Ok, we can do that :-) */ int mychk; @@ -4007,14 +4013,12 @@ sctp_handle_str_reset_add_out_strm(struc mychk = stcb->asoc.streamoutcnt; mychk += num_stream; if (mychk < 0x10000) { - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; if (sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, 1, num_stream, 0, 1)) { - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } } else { - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } } sctp_add_stream_reset_result(chk, seq, stcb->asoc.last_reset_action[0]); @@ -4032,7 +4036,7 @@ sctp_handle_str_reset_add_out_strm(struc */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -4046,7 +4050,6 @@ __attribute__((noinline)) int chk_length, param_len, ptype; struct sctp_paramhdr pstore; uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE]; - uint32_t seq = 0; int num_req = 0; int trunc = 0; @@ -4124,7 +4127,7 @@ strres_nochunk: seq = ntohl(req_out->response_seq); if (seq == stcb->asoc.str_reset_seq_out) { /* implicit ack */ - (void)sctp_handle_stream_reset_response(stcb, seq, SCTP_STREAM_RESET_PERFORMED, NULL); + (void)sctp_handle_stream_reset_response(stcb, seq, SCTP_STREAM_RESET_RESULT_PERFORMED, NULL); } } sctp_handle_str_reset_request_out(stcb, chk, req_out, trunc); From owner-svn-src-all@FreeBSD.ORG Sat May 5 21:41:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF96D106566B; Sat, 5 May 2012 21:41:16 +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 9925C8FC18; Sat, 5 May 2012 21:41:16 +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 q45LfGnv083264; Sat, 5 May 2012 21:41:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45LfGM6083258; Sat, 5 May 2012 21:41:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205052141.q45LfGM6083258@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 21:41:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235066 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 21:41:16 -0000 Author: tuexen Date: Sat May 5 21:41:16 2012 New Revision: 235066 URL: http://svn.freebsd.org/changeset/base/235066 Log: Provide the flags in the SCTP stream reconfig related notification as specified in RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_constants.h head/sys/netinet/sctp_input.c head/sys/netinet/sctp_uio.h head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_constants.h ============================================================================== --- head/sys/netinet/sctp_constants.h Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_constants.h Sat May 5 21:41:16 2012 (r235066) @@ -779,10 +779,9 @@ __FBSDID("$FreeBSD$"); #define SCTP_NOTIFY_SPECIAL_SP_FAIL 27 #define SCTP_NOTIFY_NO_PEER_AUTH 28 #define SCTP_NOTIFY_SENDER_DRY 29 -#define SCTP_NOTIFY_STR_RESET_ADD_OK 30 -#define SCTP_NOTIFY_STR_RESET_ADD_FAIL 31 -#define SCTP_NOTIFY_STR_RESET_INSTREAM_ADD_OK 32 -#define SCTP_NOTIFY_MAX 32 +#define SCTP_NOTIFY_STR_RESET_DENIED_OUT 30 +#define SCTP_NOTIFY_STR_RESET_DENIED_IN 31 +#define SCTP_NOTIFY_MAX 31 /* This is the value for messages that are NOT completely Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_input.c Sat May 5 21:41:16 2012 (r235066) @@ -3602,6 +3602,8 @@ sctp_handle_stream_reset_response(struct if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* do it */ sctp_reset_out_streams(stcb, number_entries, srparam->list_of_streams); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } else { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3610,7 +3612,10 @@ sctp_handle_stream_reset_response(struct number_entries = (lparm_len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t); if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_IN, stcb, + number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3630,16 +3635,22 @@ sctp_handle_stream_reset_response(struct /* Put the new streams into effect */ stcb->asoc.streamoutcnt += num_stream; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGE_DENIED); } else { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGED_DENIED); + SCTP_STREAM_CHANGE_FAILED); } } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_DENIED) { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGED_DENIED); + SCTP_STREAM_CHANGE_DENIED); + } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGE_FAILED); } } else if (type == SCTP_STR_RESET_TSN_REQUEST) { /** @@ -3682,9 +3693,12 @@ sctp_handle_stream_reset_response(struct sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), + SCTP_ASSOC_RESET_DENIED); } else { sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), - SCTP_STREAM_RESET_FAILED); + SCTP_ASSOC_RESET_FAILED); } } /* get rid of the request and get the request flags */ Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_uio.h Sat May 5 21:41:16 2012 (r235066) @@ -454,7 +454,6 @@ struct sctp_stream_reset_event { #define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002 #define SCTP_STREAM_RESET_DENIED 0x0004 #define SCTP_STREAM_RESET_FAILED 0x0008 -#define SCTP_STREAM_CHANGED_DENIED 0x0010 /* * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctputil.c Sat May 5 21:41:16 2012 (r235066) @@ -3507,10 +3507,18 @@ sctp_ulp_notify(uint32_t notification, s sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED)); break; + case SCTP_NOTIFY_STR_RESET_DENIED_OUT: + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_DENIED)); + break; case SCTP_NOTIFY_STR_RESET_FAILED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED)); break; + case SCTP_NOTIFY_STR_RESET_DENIED_IN: + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_DENIED)); + break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, error); From owner-svn-src-all@FreeBSD.ORG Sat May 5 23:51:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B76510657A4; Sat, 5 May 2012 23:51:24 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 869DF8FC0A; Sat, 5 May 2012 23:51: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 q45NpOeD087677; Sat, 5 May 2012 23:51:24 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45NpOLB087675; Sat, 5 May 2012 23:51:24 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201205052351.q45NpOLB087675@svn.freebsd.org> From: David Xu Date: Sat, 5 May 2012 23:51:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235068 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 23:51:25 -0000 Author: davidxu Date: Sat May 5 23:51:24 2012 New Revision: 235068 URL: http://svn.freebsd.org/changeset/base/235068 Log: Fix mis-merged line, move SC_LOOKUP() call to upper level. Modified: head/lib/libthr/thread/thr_sleepq.c Modified: head/lib/libthr/thread/thr_sleepq.c ============================================================================== --- head/lib/libthr/thread/thr_sleepq.c Sat May 5 22:44:08 2012 (r235067) +++ head/lib/libthr/thread/thr_sleepq.c Sat May 5 23:51:24 2012 (r235068) @@ -113,11 +113,11 @@ _sleepq_add(void *wchan, struct pthread struct sleepqueue_chain *sc; struct sleepqueue *sq; + sc = SC_LOOKUP(wchan); sq = _sleepq_lookup(wchan); if (sq != NULL) { SLIST_INSERT_HEAD(&sq->sq_freeq, td->sleepqueue, sq_flink); } else { - sc = SC_LOOKUP(wchan); sq = td->sleepqueue; LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash); sq->sq_wchan = wchan;