From owner-svn-src-stable-9@FreeBSD.ORG Sun Apr 29 08:50:51 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 13:34:38 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 13:37:32 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:10:25 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:12:32 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:16:31 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:20:30 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:22:55 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:25:01 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:26:55 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:29:39 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:33:30 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sun Apr 29 16:35:55 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 06:48:19 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 13:07:22 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 13:34:16 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 15:46:42 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 17:56:50 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Mon Apr 30 22:03:43 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Tue May 1 07:15:18 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Tue May 1 10:49:20 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Wed May 2 00:30:31 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Wed May 2 07:17:54 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Wed May 2 08:38:44 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Wed May 2 15:15:29 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 07:12:39 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 09:47:22 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 15:25:13 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 16:19:42 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 16:31:22 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 16:48:49 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Thu May 3 19:55:37 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:05:31 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:10:49 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:13:26 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:18:01 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:27:18 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:38:47 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 15:51:24 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 16:08:25 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 16:15:38 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 16:32:19 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 17:19:41 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 17:23:24 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 19:47:56 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 20:45:54 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Fri May 4 21:31:01 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 00:28:09 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 02:52:41 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 07:55:51 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 11:33:49 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 11:54:24 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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-stable-9@FreeBSD.ORG Sat May 5 16:41:18 2012 Return-Path: Delivered-To: svn-src-stable-9@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-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree 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 ***