From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 09:21:40 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6BA1DD49; Sun, 7 Jul 2013 09:21:40 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5E3E11C12; Sun, 7 Jul 2013 09:21:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r679Leji025574; Sun, 7 Jul 2013 09:21:40 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r679LeKM025573; Sun, 7 Jul 2013 09:21:40 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201307070921.r679LeKM025573@svn.freebsd.org> From: Martin Matuska Date: Sun, 7 Jul 2013 09:21:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252920 - stable/9/cddl/contrib/opensolaris/cmd/zfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 09:21:40 -0000 Author: mm Date: Sun Jul 7 09:21:39 2013 New Revision: 252920 URL: http://svnweb.freebsd.org/changeset/base/252920 Log: MFC r252732: Fix misleading or remove irrelevant illumos messages and manpage references in the zfs command. PR: bin/178996 Submitted by: Peter Schaefer Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/cddl/contrib/opensolaris/cmd/zfs/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Jul 7 07:06:15 2013 (r252919) +++ stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Jul 7 09:21:39 2013 (r252920) @@ -5590,8 +5590,8 @@ share_mount_one(zfs_handle_t *zhp, int o (void) fprintf(stderr, gettext("cannot share '%s': " "legacy share\n"), zfs_get_name(zhp)); - (void) fprintf(stderr, gettext("use share(1M) to " - "share this filesystem, or set " + (void) fprintf(stderr, gettext("to " + "share this filesystem set " "sharenfs property on\n")); return (1); } @@ -5607,7 +5607,7 @@ share_mount_one(zfs_handle_t *zhp, int o (void) fprintf(stderr, gettext("cannot %s '%s': " "legacy mountpoint\n"), cmdname, zfs_get_name(zhp)); - (void) fprintf(stderr, gettext("use %s(1M) to " + (void) fprintf(stderr, gettext("use %s(8) to " "%s this filesystem\n"), cmdname, cmdname); return (1); } @@ -6045,8 +6045,10 @@ unshare_unmount_path(int op, char *path, strcmp(smbshare_prop, "off") == 0) { (void) fprintf(stderr, gettext("cannot unshare " "'%s': legacy share\n"), path); +#ifdef illumos (void) fprintf(stderr, gettext("use " "unshare(1M) to unshare this filesystem\n")); +#endif } else if (!zfs_is_shared(zhp)) { (void) fprintf(stderr, gettext("cannot unshare '%s': " "not currently shared\n"), path); @@ -6065,7 +6067,7 @@ unshare_unmount_path(int op, char *path, (void) fprintf(stderr, gettext("cannot unmount " "'%s': legacy mountpoint\n"), zfs_get_name(zhp)); - (void) fprintf(stderr, gettext("use umount(1M) " + (void) fprintf(stderr, gettext("use umount(8) " "to unmount this filesystem\n")); } else { ret = zfs_unmountall(zhp, flags); @@ -6287,9 +6289,11 @@ unshare_unmount(int op, int argc, char * (void) fprintf(stderr, gettext("cannot " "unshare '%s': legacy share\n"), zfs_get_name(zhp)); +#ifdef illumos (void) fprintf(stderr, gettext("use " "unshare(1M) to unshare this " "filesystem\n")); +#endif ret = 1; } else if (!zfs_is_shared(zhp)) { (void) fprintf(stderr, gettext("cannot " @@ -6307,7 +6311,7 @@ unshare_unmount(int op, int argc, char * "unmount '%s': legacy " "mountpoint\n"), zfs_get_name(zhp)); (void) fprintf(stderr, gettext("use " - "umount(1M) to unmount this " + "umount(8) to unmount this " "filesystem\n")); ret = 1; } else if (!zfs_is_mounted(zhp, NULL)) { @@ -6493,12 +6497,12 @@ manual_mount(int argc, char **argv) } } else { (void) fprintf(stderr, gettext("filesystem '%s' cannot be " - "mounted using 'mount -F zfs'\n"), dataset); + "mounted using 'mount -t zfs'\n"), dataset); (void) fprintf(stderr, gettext("Use 'zfs set mountpoint=%s' " "instead.\n"), path); - (void) fprintf(stderr, gettext("If you must use 'mount -F zfs' " - "or /etc/vfstab, use 'zfs set mountpoint=legacy'.\n")); - (void) fprintf(stderr, gettext("See zfs(1M) for more " + (void) fprintf(stderr, gettext("If you must use 'mount -t zfs' " + "or /etc/fstab, use 'zfs set mountpoint=legacy'.\n")); + (void) fprintf(stderr, gettext("See zfs(8) for more " "information.\n")); ret = 1; } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:10:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AF62A259; Sun, 7 Jul 2013 11:10:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A08CC1FFD; Sun, 7 Jul 2013 11:10:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BAGkU056252; Sun, 7 Jul 2013 11:10:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BAGxS056251; Sun, 7 Jul 2013 11:10:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071110.r67BAGxS056251@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252922 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:10:16 -0000 Author: tuexen Date: Sun Jul 7 11:10:15 2013 New Revision: 252922 URL: http://svnweb.freebsd.org/changeset/base/252922 Log: MFC r238122: Use consistent method to determine IPV4_OUTPUT/IPV6_OUTPUT. 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 Jul 7 09:22:03 2013 (r252921) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:10:15 2013 (r252922) @@ -10981,8 +10981,9 @@ sctp_send_resp_msg(struct sockaddr *src, return; } SCTP_ATTACH_CHAIN(o_pak, mout, len); + switch (dst->sa_family) { #ifdef INET - if (ip != NULL) { + case AF_INET: if (port) { 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)); @@ -11016,10 +11017,10 @@ sctp_send_resp_msg(struct sockaddr *src, } #endif SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id); - } + break; #endif #ifdef INET6 - if (ip6 != NULL) { + case AF_INET6: ip6->ip6_plen = len - sizeof(struct ip6_hdr); if (port) { #if defined(SCTP_WITH_NO_CSUM) @@ -11046,8 +11047,15 @@ sctp_send_resp_msg(struct sockaddr *src, } #endif SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id); - } + break; #endif + default: + SCTPDBG(SCTP_DEBUG_OUTPUT1, "Unknown protocol (TSNH) type %d\n", + dst->sa_family); + sctp_m_freem(mout); + SCTP_LTRACE_ERR_RET_PKT(mout, NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EFAULT); + return; + } SCTP_STAT_INCR(sctps_sendpackets); SCTP_STAT_INCR_COUNTER64(sctps_outpackets); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:15:55 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3722E3D1; Sun, 7 Jul 2013 11:15:55 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 297001020; Sun, 7 Jul 2013 11:15:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BFt74058710; Sun, 7 Jul 2013 11:15:55 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BFtC8058709; Sun, 7 Jul 2013 11:15:55 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071115.r67BFtC8058709@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:15:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252923 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:15:55 -0000 Author: tuexen Date: Sun Jul 7 11:15:54 2013 New Revision: 252923 URL: http://svnweb.freebsd.org/changeset/base/252923 Log: MFC r238455: Use case for selecting the address family (as in other places). Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:10:15 2013 (r252922) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:15:54 2013 (r252923) @@ -1203,11 +1203,18 @@ sctp_findassociation_ep_addr(struct sctp uint16_t rport; inp = *inp_p; - if (remote->sa_family == AF_INET) { + switch (remote->sa_family) { +#ifdef INET + case AF_INET: rport = (((struct sockaddr_in *)remote)->sin_port); - } else if (remote->sa_family == AF_INET6) { + break; +#endif +#ifdef INET6 + case AF_INET6: rport = (((struct sockaddr_in6 *)remote)->sin6_port); - } else { + break; +#endif + default: return (NULL); } if (locked_tcb) { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:20:13 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8BF3C512; Sun, 7 Jul 2013 11:20:13 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 64C271033; Sun, 7 Jul 2013 11:20:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BKDGH059279; Sun, 7 Jul 2013 11:20:13 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BKDQC059278; Sun, 7 Jul 2013 11:20:13 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071120.r67BKDQC059278@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:20:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252924 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:20:13 -0000 Author: tuexen Date: Sun Jul 7 11:20:12 2013 New Revision: 252924 URL: http://svnweb.freebsd.org/changeset/base/252924 Log: MFC r239035: Testing an interface property should depend on the interface, not on an address. Modified: stable/9/sys/netinet/sctp_bsd_addr.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_bsd_addr.c ============================================================================== --- stable/9/sys/netinet/sctp_bsd_addr.c Sun Jul 7 11:15:54 2013 (r252923) +++ stable/9/sys/netinet/sctp_bsd_addr.c Sun Jul 7 11:20:12 2013 (r252924) @@ -152,12 +152,12 @@ sctp_gather_internal_ifa_flags(struct sc static uint32_t -sctp_is_desired_interface_type(struct ifaddr *ifa) +sctp_is_desired_interface_type(struct ifnet *ifn) { int result; /* check the interface type to see if it's one we care about */ - switch (ifa->ifa_ifp->if_type) { + switch (ifn->if_type) { case IFT_ETHER: case IFT_ISO88023: case IFT_ISO88024: @@ -216,6 +216,10 @@ sctp_init_ifns_for_vrf(int vrfid) IFNET_RLOCK(); TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) { + if (sctp_is_desired_interface_type(ifn) == 0) { + /* non desired type */ + continue; + } IF_ADDR_RLOCK(ifn); TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) { @@ -240,10 +244,6 @@ sctp_init_ifns_for_vrf(int vrfid) default: continue; } - if (sctp_is_desired_interface_type(ifa) == 0) { - /* non desired type */ - continue; - } switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -317,6 +317,10 @@ sctp_addr_change(struct ifaddr *ifa, int if (ifa->ifa_addr == NULL) { return; } + if (sctp_is_desired_interface_type(ifa->ifa_ifp) == 0) { + /* non desired type */ + return; + } switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -338,22 +342,16 @@ sctp_addr_change(struct ifaddr *ifa, int /* non inet/inet6 skip */ return; } - - if (sctp_is_desired_interface_type(ifa) == 0) { - /* non desired type */ - return; - } if (cmd == RTM_ADD) { (void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp, - ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, - ifa->ifa_ifp->if_xname, + ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname, (void *)ifa, ifa->ifa_addr, ifa_flags, 1); } else { sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr, ifa->ifa_ifp->if_index, - ifa->ifa_ifp->if_xname - ); + ifa->ifa_ifp->if_xname); + /* * We don't bump refcount here so when it completes the * final delete will happen. From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:26:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4C6D870E; Sun, 7 Jul 2013 11:26:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3DD971059; Sun, 7 Jul 2013 11:26:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BQGoR061614; Sun, 7 Jul 2013 11:26:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BQGhk061613; Sun, 7 Jul 2013 11:26:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071126.r67BQGhk061613@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:26:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252925 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:26:16 -0000 Author: tuexen Date: Sun Jul 7 11:26:15 2013 New Revision: 252925 URL: http://svnweb.freebsd.org/changeset/base/252925 Log: MFC r240114: Whitespace change. 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 Jul 7 11:20:12 2013 (r252924) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 11:26:15 2013 (r252925) @@ -2385,7 +2385,7 @@ sctp_calculate_rto(struct sctp_tcb *stcb timevalsub(&now, old); /* store the current RTT in us */ net->rtt = (uint64_t) 1000000 *(uint64_t) now.tv_sec + - (uint64_t) now.tv_usec; + (uint64_t) now.tv_usec; /* computer rtt in ms */ rtt = net->rtt / 1000; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:28:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 75E9184F; Sun, 7 Jul 2013 11:28:45 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 577E0106C; Sun, 7 Jul 2013 11:28:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BSj3w061916; Sun, 7 Jul 2013 11:28:45 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BSjWx061915; Sun, 7 Jul 2013 11:28:45 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071128.r67BSjWx061915@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:28:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252926 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:28:45 -0000 Author: tuexen Date: Sun Jul 7 11:28:44 2013 New Revision: 252926 URL: http://svnweb.freebsd.org/changeset/base/252926 Log: MFC r240115: Use the consistenly the size of a variable. This helps to keep the code simpler for the userland implementation. 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 Jul 7 11:26:15 2013 (r252925) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:28:44 2013 (r252926) @@ -3371,7 +3371,7 @@ sctp_find_cmsg(int c_type, void *data, s return (found); } m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh); - if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) { + if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) { /* We dont't have a complete CMSG header. */ return (found); } @@ -3386,11 +3386,11 @@ sctp_find_cmsg(int c_type, void *data, s (cmh.cmsg_type == SCTP_PRINFO) || (cmh.cmsg_type == SCTP_AUTHINFO))))) { if (c_type == cmh.cmsg_type) { - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < cpsize) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < cpsize) { return (found); } /* It is exactly what we want. Copy it out. */ - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), cpsize, (caddr_t)data); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), cpsize, (caddr_t)data); return (1); } else { struct sctp_sndrcvinfo *sndrcvinfo; @@ -3404,10 +3404,10 @@ sctp_find_cmsg(int c_type, void *data, s } switch (cmh.cmsg_type) { case SCTP_SNDINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_sndinfo)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_sndinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_sndinfo), (caddr_t)&sndinfo); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_sndinfo), (caddr_t)&sndinfo); sndrcvinfo->sinfo_stream = sndinfo.snd_sid; sndrcvinfo->sinfo_flags = sndinfo.snd_flags; sndrcvinfo->sinfo_ppid = sndinfo.snd_ppid; @@ -3415,18 +3415,18 @@ sctp_find_cmsg(int c_type, void *data, s sndrcvinfo->sinfo_assoc_id = sndinfo.snd_assoc_id; break; case SCTP_PRINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_prinfo)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_prinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_prinfo), (caddr_t)&prinfo); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_prinfo), (caddr_t)&prinfo); sndrcvinfo->sinfo_timetolive = prinfo.pr_value; sndrcvinfo->sinfo_flags |= prinfo.pr_policy; break; case SCTP_AUTHINFO: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_authinfo)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_authinfo)) { return (found); } - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo); sndrcvinfo->sinfo_keynumber_valid = 1; sndrcvinfo->sinfo_keynumber = authinfo.auth_keynumber; break; @@ -3466,7 +3466,7 @@ sctp_process_cmsgs_for_init(struct sctp_ return (1); } m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh); - if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) { + if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) { /* We dont't have a complete CMSG header. */ *error = EINVAL; return (1); @@ -3479,11 +3479,11 @@ sctp_process_cmsgs_for_init(struct sctp_ if (cmh.cmsg_level == IPPROTO_SCTP) { switch (cmh.cmsg_type) { case SCTP_INIT: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_initmsg)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_initmsg)) { *error = EINVAL; return (1); } - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_initmsg), (caddr_t)&initmsg); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_initmsg), (caddr_t)&initmsg); if (initmsg.sinit_max_attempts) stcb->asoc.max_init_times = initmsg.sinit_max_attempts; if (initmsg.sinit_num_ostreams) @@ -3523,7 +3523,7 @@ sctp_process_cmsgs_for_init(struct sctp_ break; #ifdef INET case SCTP_DSTADDRV4: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in_addr)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) { *error = EINVAL; return (1); } @@ -3531,7 +3531,7 @@ sctp_process_cmsgs_for_init(struct sctp_ sin.sin_family = AF_INET; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_port = stcb->rport; - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr); if ((sin.sin_addr.s_addr == INADDR_ANY) || (sin.sin_addr.s_addr == INADDR_BROADCAST) || IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) { @@ -3547,7 +3547,7 @@ sctp_process_cmsgs_for_init(struct sctp_ #endif #ifdef INET6 case SCTP_DSTADDRV6: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in6_addr)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) { *error = EINVAL; return (1); } @@ -3555,7 +3555,7 @@ sctp_process_cmsgs_for_init(struct sctp_ sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); sin6.sin6_port = stcb->rport; - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr); if (IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr) || IN6_IS_ADDR_MULTICAST(&sin6.sin6_addr)) { *error = EINVAL; @@ -3623,7 +3623,7 @@ sctp_findassociation_cmsgs(struct sctp_i return (NULL); } m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh); - if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) { + if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) { /* We dont't have a complete CMSG header. */ *error = EINVAL; return (NULL); @@ -3637,7 +3637,7 @@ sctp_findassociation_cmsgs(struct sctp_i switch (cmh.cmsg_type) { #ifdef INET case SCTP_DSTADDRV4: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in_addr)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) { *error = EINVAL; return (NULL); } @@ -3645,13 +3645,13 @@ sctp_findassociation_cmsgs(struct sctp_i sin.sin_family = AF_INET; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_port = port; - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr); addr = (struct sockaddr *)&sin; break; #endif #ifdef INET6 case SCTP_DSTADDRV6: - if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in6_addr)) { + if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) { *error = EINVAL; return (NULL); } @@ -3659,7 +3659,7 @@ sctp_findassociation_cmsgs(struct sctp_i sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); sin6.sin6_port = port; - m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr); + m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr); #ifdef INET if (IN6_IS_ADDR_V4MAPPED(&sin6.sin6_addr)) { in6_sin6_2_sin(&sin, &sin6); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:33:53 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8C4029B9; Sun, 7 Jul 2013 11:33:53 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7D82A108F; Sun, 7 Jul 2013 11:33:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BXriG064258; Sun, 7 Jul 2013 11:33:53 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BXpEW064246; Sun, 7 Jul 2013 11:33:51 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071133.r67BXpEW064246@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:33:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252927 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:33:53 -0000 Author: tuexen Date: Sun Jul 7 11:33:51 2013 New Revision: 252927 URL: http://svnweb.freebsd.org/changeset/base/252927 Log: MFC r240148: Using %p in a format string requires a void *. Modified: stable/9/sys/netinet/sctp_asconf.c stable/9/sys/netinet/sctp_auth.c stable/9/sys/netinet/sctp_cc_functions.c stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_timer.c stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_asconf.c ============================================================================== --- stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 11:33:51 2013 (r252927) @@ -2278,7 +2278,7 @@ sctp_set_primary_ip_address_sa(struct sc /* set primary queuing succeeded */ SCTPDBG(SCTP_DEBUG_ASCONF1, "set_primary_ip_address_sa: queued on tcb=%p, ", - stcb); + (void *)stcb); SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa); if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) { #ifdef SCTP_TIMER_BASED_ASCONF @@ -2291,7 +2291,7 @@ sctp_set_primary_ip_address_sa(struct sc } } else { SCTPDBG(SCTP_DEBUG_ASCONF1, "set_primary_ip_address_sa: failed to add to queue on tcb=%p, ", - stcb); + (void *)stcb); SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa); return (-1); } @@ -2314,7 +2314,7 @@ sctp_set_primary_ip_address(struct sctp_ SCTP_SET_PRIM_ADDR)) { /* set primary queuing succeeded */ SCTPDBG(SCTP_DEBUG_ASCONF1, "set_primary_ip_address: queued on stcb=%p, ", - stcb); + (void *)stcb); SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, &ifa->address.sa); if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) { #ifdef SCTP_TIMER_BASED_ASCONF Modified: stable/9/sys/netinet/sctp_auth.c ============================================================================== --- stable/9/sys/netinet/sctp_auth.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_auth.c Sun Jul 7 11:33:51 2013 (r252927) @@ -591,7 +591,7 @@ sctp_auth_key_acquire(struct sctp_tcb *s atomic_add_int(&skey->refcount, 1); SCTPDBG(SCTP_DEBUG_AUTH2, "%s: stcb %p key %u refcount acquire to %d\n", - __FUNCTION__, stcb, key_id, skey->refcount); + __FUNCTION__, (void *)stcb, key_id, skey->refcount); } } @@ -612,7 +612,7 @@ sctp_auth_key_release(struct sctp_tcb *s sctp_free_sharedkey(skey); SCTPDBG(SCTP_DEBUG_AUTH2, "%s: stcb %p key %u refcount release to %d\n", - __FUNCTION__, stcb, key_id, skey->refcount); + __FUNCTION__, (void *)stcb, key_id, skey->refcount); /* see if a notification should be generated */ if ((skey->refcount <= 1) && (skey->deactivated)) { @@ -621,7 +621,7 @@ sctp_auth_key_release(struct sctp_tcb *s key_id, 0, so_locked); SCTPDBG(SCTP_DEBUG_AUTH2, "%s: stcb %p key %u no longer used, %d\n", - __FUNCTION__, stcb, key_id, skey->refcount); + __FUNCTION__, (void *)stcb, key_id, skey->refcount); } } } Modified: stable/9/sys/netinet/sctp_cc_functions.c ============================================================================== --- stable/9/sys/netinet/sctp_cc_functions.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_cc_functions.c Sun Jul 7 11:33:51 2013 (r252927) @@ -984,7 +984,7 @@ sctp_cwnd_update_exit_pf_common(struct s stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, old_cwnd, net->cwnd); SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n", - net, net->cwnd); + (void *)net, net->cwnd); } Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 11:33:51 2013 (r252927) @@ -4420,7 +4420,7 @@ sctp_handle_sack(struct mbuf *m, int off cum_ack, send_s); if (tp1) { SCTP_PRINTF("Got send_s from tsn:%x + 1 of tp1:%p\n", - tp1->rec.data.TSN_seq, tp1); + tp1->rec.data.TSN_seq, (void *)tp1); } hopeless_peer: *abort_now = 1; Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:33:51 2013 (r252927) @@ -91,7 +91,7 @@ sctp_handle_init(struct mbuf *m, int iph struct mbuf *op_err; SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_init: handling INIT tcb:%p\n", - stcb); + (void *)stcb); if (stcb == NULL) { SCTP_INP_RLOCK(inp); } @@ -2652,7 +2652,7 @@ sctp_handle_cookie_echo(struct mbuf *m, SCTP_INP_INCR_REF((*stcb)->sctp_ep); if ((*stcb)->sctp_ep != l_inp) { SCTP_PRINTF("Huh? ep:%p diff then l_inp:%p?\n", - (*stcb)->sctp_ep, l_inp); + (void *)(*stcb)->sctp_ep, (void *)l_inp); } } } @@ -4404,7 +4404,7 @@ __attribute__((noinline)) #endif SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_control: iphlen=%u, offset=%u, length=%u stcb:%p\n", - iphlen, *offset, length, stcb); + iphlen, *offset, length, (void *)stcb); /* validate chunk header length... */ if (ntohs(ch->chunk_length) < sizeof(*ch)) { @@ -5023,7 +5023,7 @@ process_control_chunks: break; case SCTP_ABORT_ASSOCIATION: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ABORT, stcb %p\n", - stcb); + (void *)stcb); if ((stcb) && netp && *netp) sctp_handle_abort((struct sctp_abort_chunk *)ch, stcb, *netp); @@ -5032,7 +5032,7 @@ process_control_chunks: break; case SCTP_SHUTDOWN: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN, stcb %p\n", - stcb); + (void *)stcb); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_shutdown_chunk))) { *offset = length; if (locked_tcb) { @@ -5052,7 +5052,7 @@ process_control_chunks: } break; case SCTP_SHUTDOWN_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-ACK, stcb %p\n", stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-ACK, stcb %p\n", (void *)stcb); if ((stcb) && (netp) && (*netp)) sctp_handle_shutdown_ack((struct sctp_shutdown_ack_chunk *)ch, stcb, *netp); *offset = length; @@ -5068,7 +5068,7 @@ process_control_chunks: break; case SCTP_COOKIE_ECHO: SCTPDBG(SCTP_DEBUG_INPUT3, - "SCTP_COOKIE-ECHO, stcb %p\n", stcb); + "SCTP_COOKIE-ECHO, stcb %p\n", (void *)stcb); if ((stcb) && (stcb->asoc.total_output_queue_size)) { ; } else { @@ -5170,7 +5170,7 @@ process_control_chunks: } break; case SCTP_COOKIE_ACK: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_COOKIE-ACK, stcb %p\n", stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_COOKIE-ACK, stcb %p\n", (void *)stcb); if ((stcb == NULL) || chk_length != sizeof(struct sctp_cookie_ack_chunk)) { if (locked_tcb) { SCTP_TCB_UNLOCK(locked_tcb); @@ -5260,7 +5260,7 @@ process_control_chunks: } break; case SCTP_SHUTDOWN_COMPLETE: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-COMPLETE, stcb %p\n", stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN-COMPLETE, stcb %p\n", (void *)stcb); /* must be first and only chunk */ if ((num_chunks > 1) || (length - *offset > (int)SCTP_SIZE32(chk_length))) { @@ -5619,7 +5619,7 @@ sctp_common_input_processing(struct mbuf sh->checksum = check; if (calc_check != check) { SCTPDBG(SCTP_DEBUG_INPUT1, "Bad CSUM on SCTP packet calc_check:%x check:%x m:%p mlen:%d iphlen:%d\n", - calc_check, check, m, length, iphlen); + calc_check, check, (void *)m, length, iphlen); stcb = sctp_findassociation_addr(m, offset, src, dst, sh, ch, &inp, &net, vrf_id); if ((net != NULL) && (port != 0)) { @@ -5724,13 +5724,13 @@ sctp_common_input_processing(struct mbuf } #endif SCTPDBG(SCTP_DEBUG_INPUT1, "Ok, Common input processing called, m:%p iphlen:%d offset:%d length:%d stcb:%p\n", - m, iphlen, offset, length, stcb); + (void *)m, iphlen, offset, length, (void *)stcb); if (stcb) { /* always clear this before beginning a packet */ stcb->asoc.authenticated = 0; stcb->asoc.seen_a_sack_this_pkt = 0; SCTPDBG(SCTP_DEBUG_INPUT1, "stcb:%p state:%x\n", - stcb, stcb->asoc.state); + (void *)stcb, stcb->asoc.state); if ((stcb->asoc.state & SCTP_STATE_WAS_ABORTED) || (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED)) { @@ -5968,9 +5968,9 @@ static void sctp_print_mbuf_chain(struct mbuf *m) { for (; m; m = SCTP_BUF_NEXT(m)) { - SCTP_PRINTF("%p: m_len = %ld\n", m, SCTP_BUF_LEN(m)); + SCTP_PRINTF("%p: m_len = %ld\n", (void *)m, SCTP_BUF_LEN(m)); if (SCTP_BUF_IS_EXTENDED(m)) - SCTP_PRINTF("%p: extend_size = %d\n", m, SCTP_BUF_EXTEND_SIZE(m)); + SCTP_PRINTF("%p: extend_size = %d\n", (void *)m, SCTP_BUF_EXTEND_SIZE(m)); } } Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:33:51 2013 (r252927) @@ -2985,7 +2985,7 @@ bound_all_plan_b: } SCTPDBG(SCTP_DEBUG_OUTPUT2, "num preferred:%d on interface:%p cur_addr_num:%d\n", - num_preferred, sctp_ifn, cur_addr_num); + num_preferred, (void *)sctp_ifn, cur_addr_num); /* * Ok we have num_eligible_addr set with how many we can @@ -3022,7 +3022,7 @@ again_with_private_addresses_allowed: goto plan_d; } LIST_FOREACH(sctp_ifa, &emit_ifn->ifalist, next_ifa) { - SCTPDBG(SCTP_DEBUG_OUTPUT2, "ifa:%p\n", sctp_ifa); + SCTPDBG(SCTP_DEBUG_OUTPUT2, "ifa:%p\n", (void *)sctp_ifa); if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && (non_asoc_addr_ok == 0)) { SCTPDBG(SCTP_DEBUG_OUTPUT2, "Defer\n"); @@ -3072,7 +3072,7 @@ plan_d: * out and see if we can find an acceptable address somewhere * amongst all interfaces. */ - SCTPDBG(SCTP_DEBUG_OUTPUT2, "Trying Plan D looked_at is %p\n", looked_at); + SCTPDBG(SCTP_DEBUG_OUTPUT2, "Trying Plan D looked_at is %p\n", (void *)looked_at); LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { if (dest_is_loop == 0 && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { /* wrong base scope */ @@ -3812,7 +3812,7 @@ sctp_handle_no_route(struct sctp_tcb *st SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT1, &net->ro._l_addr.sa); if (net->dest_state & SCTP_ADDR_CONFIRMED) { if ((net->dest_state & SCTP_ADDR_REACHABLE) && stcb) { - SCTPDBG(SCTP_DEBUG_OUTPUT1, "no route takes interface %p down\n", net); + SCTPDBG(SCTP_DEBUG_OUTPUT1, "no route takes interface %p down\n", (void *)net); sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN, stcb, 0, (void *)net, @@ -4106,7 +4106,7 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTPDBG(SCTP_DEBUG_OUTPUT3, "Destination is %x\n", (uint32_t) (ntohl(ip->ip_dst.s_addr))); SCTPDBG(SCTP_DEBUG_OUTPUT3, "RTP route is %p through\n", - ro->ro_rt); + (void *)ro->ro_rt); if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) { /* failed to prepend data, give up */ @@ -12157,7 +12157,7 @@ sctp_lower_sosend(struct socket *so, sndlen = SCTP_HEADER_LEN(i_pak); } SCTPDBG(SCTP_DEBUG_OUTPUT1, "Send called addr:%p send length %d\n", - addr, + (void *)addr, sndlen); if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_socket->so_qlimit)) { Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:33:51 2013 (r252927) @@ -553,7 +553,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, vo (sctp_ifap->ifn_p->ifn_index == ifn_index)) { SCTPDBG(SCTP_DEBUG_PCB4, "Using existing ifn %s (0x%x) for ifa %p\n", sctp_ifap->ifn_p->ifn_name, ifn_index, - sctp_ifap); + (void *)sctp_ifap); if (new_ifn_af) { /* Remove the created one that we don't want */ sctp_delete_ifn(sctp_ifnp, SCTP_ADDR_LOCKED); @@ -575,7 +575,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, vo * old one */ SCTPDBG(SCTP_DEBUG_PCB4, "Moving ifa %p from %s (0x%x) to %s (0x%x)\n", - sctp_ifap, sctp_ifap->ifn_p->ifn_name, + (void *)sctp_ifap, sctp_ifap->ifn_p->ifn_name, sctp_ifap->ifn_p->ifn_index, if_name, ifn_index); /* remove the address from the old ifn */ @@ -587,7 +587,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, vo /* repair ifnp which was NULL ? */ sctp_ifap->localifa_flags = SCTP_ADDR_VALID; SCTPDBG(SCTP_DEBUG_PCB4, "Repairing ifn %p for ifa %p\n", - sctp_ifnp, sctp_ifap); + (void *)sctp_ifnp, (void *)sctp_ifap); sctp_add_ifa_to_ifn(sctp_ifnp, sctp_ifap); } goto exit_stage_left; @@ -763,7 +763,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, return; } } - SCTPDBG(SCTP_DEBUG_PCB4, "Deleting ifa %p\n", sctp_ifap); + SCTPDBG(SCTP_DEBUG_PCB4, "Deleting ifa %p\n", (void *)sctp_ifap); sctp_ifap->localifa_flags &= SCTP_ADDR_VALID; sctp_ifap->localifa_flags |= SCTP_BEING_DELETED; vrf->total_ifa_count--; @@ -1678,7 +1678,7 @@ sctp_endpoint_probe(struct sockaddr *nam continue; } SCTPDBG(SCTP_DEBUG_PCB1, "Ok laddr->ifa:%p is possible, ", - laddr->ifa); + (void *)laddr->ifa); if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) { SCTPDBG(SCTP_DEBUG_PCB1, "Huh IFA being deleted\n"); continue; @@ -2181,7 +2181,7 @@ sctp_findassociation_addr(struct mbuf *m retval = sctp_findassociation_addr_sa(src, dst, &inp, netp, find_tcp_pool, vrf_id); } - SCTPDBG(SCTP_DEBUG_PCB1, "retval:%p inp:%p\n", retval, inp); + SCTPDBG(SCTP_DEBUG_PCB1, "retval:%p inp:%p\n", (void *)retval, (void *)inp); if (retval == NULL && inp) { /* Found a EP but not this address */ if ((ch->chunk_type == SCTP_INITIATION) || @@ -2207,7 +2207,7 @@ sctp_findassociation_addr(struct mbuf *m } } } - SCTPDBG(SCTP_DEBUG_PCB1, "retval is %p\n", retval); + SCTPDBG(SCTP_DEBUG_PCB1, "retval is %p\n", (void *)retval); return (retval); } @@ -3100,7 +3100,7 @@ continue_anyway: /* put it in the bucket */ LIST_INSERT_HEAD(head, inp, sctp_hash); SCTPDBG(SCTP_DEBUG_PCB1, "Main hash to bind at head:%p, bound port:%d - in tcp_pool=%d\n", - head, ntohs(lport), port_reuse_active); + (void *)head, ntohs(lport), port_reuse_active); /* set in the port */ inp->sctp_lport = lport; @@ -3368,7 +3368,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, sctp_streamhead); if (sp == NULL) { SCTP_PRINTF("Error, sp is NULL, locked on sending is %p strm:%d\n", - asoc->asoc.locked_on_sending, + (void *)asoc->asoc.locked_on_sending, asoc->asoc.locked_on_sending->stream_no); } else { if ((sp->length == 0) && (sp->msg_is_complete == 0)) @@ -4341,7 +4341,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, LIST_INSERT_HEAD(head, stcb, sctp_tcbhash); } SCTP_INP_WUNLOCK(inp); - SCTPDBG(SCTP_DEBUG_PCB1, "Association %p now allocated\n", stcb); + SCTPDBG(SCTP_DEBUG_PCB1, "Association %p now allocated\n", (void *)stcb); return (stcb); } Modified: stable/9/sys/netinet/sctp_timer.c ============================================================================== --- stable/9/sys/netinet/sctp_timer.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctp_timer.c Sun Jul 7 11:33:51 2013 (r252927) @@ -90,7 +90,7 @@ sctp_threshold_management(struct sctp_in if (net) { net->error_count++; SCTPDBG(SCTP_DEBUG_TIMER4, "Error count for %p now %d thresh:%d\n", - net, net->error_count, + (void *)net, net->error_count, net->failure_threshold); if (net->error_count > net->failure_threshold) { /* We had a threshold failure */ @@ -138,7 +138,7 @@ sctp_threshold_management(struct sctp_in stcb->asoc.overall_error_count++; } SCTPDBG(SCTP_DEBUG_TIMER4, "Overall error count for %p now %d thresh:%u state:%x\n", - &stcb->asoc, stcb->asoc.overall_error_count, + (void *)&stcb->asoc, stcb->asoc.overall_error_count, (uint32_t) threshold, ((net == NULL) ? (uint32_t) 0 : (uint32_t) net->dest_state)); /* @@ -439,7 +439,7 @@ sctp_recover_sent_list(struct sctp_tcb * TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.TSN_seq)) { SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n", - chk, chk->rec.data.TSN_seq, asoc->last_acked_seq); + (void *)chk, chk->rec.data.TSN_seq, asoc->last_acked_seq); TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); if (chk->pr_sctp_on) { if (asoc->pr_sctp_cnt != 0) @@ -460,7 +460,7 @@ sctp_recover_sent_list(struct sctp_tcb * } SCTP_PRINTF("after recover order is as follows\n"); TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { - SCTP_PRINTF("chk:%p TSN:%x\n", chk, chk->rec.data.TSN_seq); + SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.TSN_seq); } } @@ -767,7 +767,7 @@ start_again: if (audit_tf) { SCTPDBG(SCTP_DEBUG_TIMER4, "Audit total flight due to negative value net:%p\n", - net); + (void *)net); stcb->asoc.total_flight = 0; stcb->asoc.total_flight_count = 0; /* Clear all networks flight size */ @@ -775,7 +775,7 @@ start_again: lnets->flight_size = 0; SCTPDBG(SCTP_DEBUG_TIMER4, "Net:%p c-f cwnd:%d ssthresh:%d\n", - lnets, lnets->cwnd, lnets->ssthresh); + (void *)lnets, lnets->cwnd, lnets->ssthresh); } TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { if (chk->sent < SCTP_DATAGRAM_RESEND) { Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 11:28:44 2013 (r252926) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 11:33:51 2013 (r252927) @@ -686,7 +686,7 @@ sctp_auditing(int from, struct sctp_inpc } if (lnet->flight_size != tot_out) { SCTP_PRINTF("net:%p flight was %d corrected to %d\n", - lnet, lnet->flight_size, + (void *)lnet, lnet->flight_size, tot_out); lnet->flight_size = tot_out; } @@ -1434,7 +1434,7 @@ sctp_timeout_handler(void *t) if (tmr->self != (void *)tmr) { /* * SCTP_PRINTF("Stale SCTP timer fired (%p), ignoring...\n", - * tmr); + * (void *)tmr); */ CURVNET_RESTORE(); return; @@ -2112,7 +2112,7 @@ sctp_timer_start(int t_type, struct sctp } if ((to_ticks <= 0) || (tmr == NULL)) { SCTPDBG(SCTP_DEBUG_TIMER1, "%s: %d:software error to_ticks:%d tmr:%p not set ??\n", - __FUNCTION__, t_type, to_ticks, tmr); + __FUNCTION__, t_type, to_ticks, (void *)tmr); return; } if (SCTP_OS_TIMER_PENDING(&tmr->timer)) { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:36:47 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 73287BEE; Sun, 7 Jul 2013 11:36:47 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 639A710AC; Sun, 7 Jul 2013 11:36:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BalBi064646; Sun, 7 Jul 2013 11:36:47 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BalXW064645; Sun, 7 Jul 2013 11:36:47 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071136.r67BalXW064645@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:36:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252928 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:36:47 -0000 Author: tuexen Date: Sun Jul 7 11:36:46 2013 New Revision: 252928 URL: http://svnweb.freebsd.org/changeset/base/252928 Log: MFC r240158: Get rid of a gcc'ism. Modified: stable/9/sys/netinet/sctp_cc_functions.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_cc_functions.c ============================================================================== --- stable/9/sys/netinet/sctp_cc_functions.c Sun Jul 7 11:33:51 2013 (r252927) +++ stable/9/sys/netinet/sctp_cc_functions.c Sun Jul 7 11:36:46 2013 (r252928) @@ -1917,10 +1917,9 @@ measure_achieved_throughput(struct sctp_ return; } net->cc_mod.htcp_ca.bytecount += net->net_ack; - - if (net->cc_mod.htcp_ca.bytecount >= net->cwnd - ((net->cc_mod.htcp_ca.alpha >> 7 ? : 1) * net->mtu) - && now - net->cc_mod.htcp_ca.lasttime >= net->cc_mod.htcp_ca.minRTT - && net->cc_mod.htcp_ca.minRTT > 0) { + if ((net->cc_mod.htcp_ca.bytecount >= net->cwnd - (((net->cc_mod.htcp_ca.alpha >> 7) ? (net->cc_mod.htcp_ca.alpha >> 7) : 1) * net->mtu)) && + (now - net->cc_mod.htcp_ca.lasttime >= net->cc_mod.htcp_ca.minRTT) && + (net->cc_mod.htcp_ca.minRTT > 0)) { uint32_t cur_Bi = net->cc_mod.htcp_ca.bytecount / net->mtu * hz / (now - net->cc_mod.htcp_ca.lasttime); if (htcp_ccount(&net->cc_mod.htcp_ca) <= 3) { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:41:13 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D0BB0EEF; Sun, 7 Jul 2013 11:41:13 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B546D10E0; Sun, 7 Jul 2013 11:41:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BfDeR066909; Sun, 7 Jul 2013 11:41:13 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BfCox066901; Sun, 7 Jul 2013 11:41:12 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071141.r67BfCox066901@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:41:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252929 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:41:13 -0000 Author: tuexen Date: Sun Jul 7 11:41:12 2013 New Revision: 252929 URL: http://svnweb.freebsd.org/changeset/base/252929 Log: MFC r240198: Don't include a structure containing a flexible array in another structure. Modified: stable/9/sys/netinet/sctp_header.h stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_input.h stable/9/sys/netinet/sctp_structs.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_header.h ============================================================================== --- stable/9/sys/netinet/sctp_header.h Sun Jul 7 11:36:46 2013 (r252928) +++ stable/9/sys/netinet/sctp_header.h Sun Jul 7 11:41:12 2013 (r252929) @@ -510,16 +510,6 @@ struct sctp_stream_reset_add_strm { * streams then the request will need to be an overlay structure. */ -struct sctp_stream_reset_out_req { - struct sctp_chunkhdr ch; - struct sctp_stream_reset_out_request sr_req; -} SCTP_PACKED; - -struct sctp_stream_reset_in_req { - struct sctp_chunkhdr ch; - struct sctp_stream_reset_in_request sr_req; -} SCTP_PACKED; - struct sctp_stream_reset_tsn_req { struct sctp_chunkhdr ch; struct sctp_stream_reset_tsn_request sr_req; Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 11:36:46 2013 (r252928) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 11:41:12 2013 (r252929) @@ -2113,7 +2113,7 @@ finish_express_del: */ struct sctp_queued_to_read *ctl, *nctl; - sctp_reset_in_stream(stcb, liste->number_entries, liste->req.list_of_streams); + sctp_reset_in_stream(stcb, liste->number_entries, liste->list_of_streams); TAILQ_REMOVE(&asoc->resetHead, liste, next_resp); SCTP_FREE(liste, SCTP_M_STRESET); /* sa_ignore FREED_MEMORY */ Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:36:46 2013 (r252928) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:41:12 2013 (r252929) @@ -3455,9 +3455,9 @@ process_chunk_drop(struct sctp_tcb *stcb } void -sctp_reset_in_stream(struct sctp_tcb *stcb, int number_entries, uint16_t * list) +sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list) { - int i; + uint32_t i; uint16_t temp; /* @@ -3511,7 +3511,7 @@ struct sctp_stream_reset_out_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chunk **bchk) { struct sctp_association *asoc; - struct sctp_stream_reset_out_req *req; + struct sctp_chunkhdr *ch; struct sctp_stream_reset_out_request *r; struct sctp_tmit_chunk *chk; int len, clen; @@ -3534,8 +3534,8 @@ sctp_find_stream_reset(struct sctp_tcb * *bchk = chk; } clen = chk->send_size; - req = mtod(chk->data, struct sctp_stream_reset_out_req *); - r = &req->sr_req; + ch = mtod(chk->data, struct sctp_chunkhdr *); + r = (struct sctp_stream_reset_out_request *)(ch + 1); if (ntohl(r->request_seq) == seq) { /* found it */ return (r); @@ -3888,8 +3888,7 @@ sctp_handle_str_reset_request_out(struct } liste->tsn = tsn; liste->number_entries = number_entries; - memcpy(&liste->req, req, - (sizeof(struct sctp_stream_reset_out_request) + (number_entries * sizeof(uint16_t)))); + memcpy(&liste->list_of_streams, req->list_of_streams, number_entries * sizeof(uint16_t)); TAILQ_INSERT_TAIL(&asoc->resetHead, liste, next_resp); asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; } @@ -4059,7 +4058,7 @@ __attribute__((noinline)) #endif static int sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, - struct sctp_stream_reset_out_req *sr_req) + struct sctp_chunkhdr *ch_req) { int chk_length, param_len, ptype; struct sctp_paramhdr pstore; @@ -4074,7 +4073,7 @@ __attribute__((noinline)) int num_param = 0; /* now it may be a reset or a reset-response */ - chk_length = ntohs(sr_req->ch.chunk_length); + chk_length = ntohs(ch_req->chunk_length); /* setup for adding the response */ sctp_alloc_a_chunk(stcb, chk); @@ -5413,7 +5412,7 @@ process_control_chunks: */ stcb->asoc.peer_supports_strreset = 1; } - if (sctp_handle_stream_reset(stcb, m, *offset, (struct sctp_stream_reset_out_req *)ch)) { + if (sctp_handle_stream_reset(stcb, m, *offset, ch)) { /* stop processing */ *offset = length; return (NULL); Modified: stable/9/sys/netinet/sctp_input.h ============================================================================== --- stable/9/sys/netinet/sctp_input.h Sun Jul 7 11:36:46 2013 (r252928) +++ stable/9/sys/netinet/sctp_input.h Sun Jul 7 11:41:12 2013 (r252929) @@ -53,7 +53,7 @@ sctp_find_stream_reset(struct sctp_tcb * struct sctp_tmit_chunk **bchk); void -sctp_reset_in_stream(struct sctp_tcb *stcb, int number_entries, +sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list); Modified: stable/9/sys/netinet/sctp_structs.h ============================================================================== --- stable/9/sys/netinet/sctp_structs.h Sun Jul 7 11:36:46 2013 (r252928) +++ stable/9/sys/netinet/sctp_structs.h Sun Jul 7 11:41:12 2013 (r252929) @@ -77,8 +77,8 @@ TAILQ_HEAD(sctpnetlisthead, sctp_nets); struct sctp_stream_reset_list { TAILQ_ENTRY(sctp_stream_reset_list) next_resp; uint32_t tsn; - int number_entries; - struct sctp_stream_reset_out_request req; + uint32_t number_entries; + uint16_t list_of_streams[]; }; TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:44:33 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 85E3FCA; Sun, 7 Jul 2013 11:44:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7719110F7; Sun, 7 Jul 2013 11:44:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BiXH8067352; Sun, 7 Jul 2013 11:44:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BiXVS067351; Sun, 7 Jul 2013 11:44:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071144.r67BiXVS067351@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:44:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252930 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:44:33 -0000 Author: tuexen Date: Sun Jul 7 11:44:32 2013 New Revision: 252930 URL: http://svnweb.freebsd.org/changeset/base/252930 Log: MFC r240250: Whitespace cleanup. Modified: stable/9/sys/netinet/sctp_asconf.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_asconf.c ============================================================================== --- stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 11:41:12 2013 (r252929) +++ stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 11:44:32 2013 (r252930) @@ -1862,7 +1862,6 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb * { int status; - if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0 || sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) { /* subset bound, no ASCONF allowed case, so ignore */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:47:07 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 89E31515; Sun, 7 Jul 2013 11:47:07 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7AE971127; Sun, 7 Jul 2013 11:47:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Bl7k5067727; Sun, 7 Jul 2013 11:47:07 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67Bl7Ap067726; Sun, 7 Jul 2013 11:47:07 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071147.r67Bl7Ap067726@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:47:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252931 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:47:07 -0000 Author: tuexen Date: Sun Jul 7 11:47:06 2013 New Revision: 252931 URL: http://svnweb.freebsd.org/changeset/base/252931 Log: MFC r240263: Whitespace changes. Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:44:32 2013 (r252930) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:47:06 2013 (r252931) @@ -2757,7 +2757,6 @@ sctp_inpcb_bind(struct socket *so, struc return (EINVAL); } lport = sin6->sin6_port; - /* * For LOOPBACK the prison_local_ip6() call * will transmute the ipv6 address to the @@ -2795,7 +2794,7 @@ sctp_inpcb_bind(struct socket *so, struc SCTP_INP_INCR_REF(inp); if (lport) { /* - * Did the caller specify a port? if so we must see if a ep + * Did the caller specify a port? if so we must see if an ep * already has this one bound. */ /* got to be root to get at low ports */ @@ -2876,8 +2875,7 @@ continue_anyway: if (bindall) { /* verify that no lport is not used by a singleton */ if ((port_reuse_active == 0) && - (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id)) - ) { + (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) { /* Sorry someone already has this one bound */ if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) && (sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) { @@ -3043,9 +3041,9 @@ continue_anyway: * zero out the port to find the address! yuck! can't do * this earlier since need port for sctp_pcb_findep() */ - if (sctp_ifap != NULL) + if (sctp_ifap != NULL) { ifa = sctp_ifap; - else { + } else { /* * Note for BSD we hit here always other O/S's will * pass things in via the sctp_ifap argument From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:50:52 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 243F2788; Sun, 7 Jul 2013 11:50:52 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 14F8A114F; Sun, 7 Jul 2013 11:50:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Bop1E069794; Sun, 7 Jul 2013 11:50:51 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67Bop1K069793; Sun, 7 Jul 2013 11:50:51 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071150.r67Bop1K069793@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252932 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:50:52 -0000 Author: tuexen Date: Sun Jul 7 11:50:51 2013 New Revision: 252932 URL: http://svnweb.freebsd.org/changeset/base/252932 Log: MFC r240507: Small cleanups. No functional change. 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 Jul 7 11:47:06 2013 (r252931) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 11:50:51 2013 (r252932) @@ -58,8 +58,7 @@ extern struct sctp_cc_functions sctp_cc_ extern struct sctp_ss_functions sctp_ss_functions[]; void -sctp_sblog(struct sockbuf *sb, - struct sctp_tcb *stcb, int from, int incr) +sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr) { struct sctp_cwnd_log sctp_clog; @@ -103,7 +102,6 @@ sctp_log_closing(struct sctp_inpcb *inp, sctp_clog.x.misc.log4); } - void rto_logging(struct sctp_nets *net, int from) { @@ -198,8 +196,7 @@ sctp_log_map(uint32_t map, uint32_t cum, } void -sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn, - int from) +sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn, int from) { struct sctp_cwnd_log sctp_clog; @@ -242,8 +239,7 @@ sctp_log_mb(struct mbuf *m, int from) } void -sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_read *poschk, - int from) +sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_read *poschk, int from) { struct sctp_cwnd_log sctp_clog; @@ -4215,7 +4211,6 @@ sctp_print_address(struct sockaddr *sa) #ifdef INET6 char ip6buf[INET6_ADDRSTRLEN]; - ip6buf[0] = 0; #endif switch (sa->sa_family) { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:53:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 78CC08C3; Sun, 7 Jul 2013 11:53:35 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5A701115B; Sun, 7 Jul 2013 11:53:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BrZhx070140; Sun, 7 Jul 2013 11:53:35 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BrZk8070136; Sun, 7 Jul 2013 11:53:35 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071153.r67BrZk8070136@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:53:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252933 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:53:35 -0000 Author: tuexen Date: Sun Jul 7 11:53:34 2013 New Revision: 252933 URL: http://svnweb.freebsd.org/changeset/base/252933 Log: MFC r240826: Small cleanups. No functional change. Modified: stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_output.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:50:51 2013 (r252932) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:53:34 2013 (r252933) @@ -11394,11 +11394,11 @@ sctp_send_cwr(struct sctp_tcb *stcb, str struct sctp_cwr_chunk *cwr; struct sctp_tmit_chunk *chk; - asoc = &stcb->asoc; SCTP_TCB_LOCK_ASSERT(stcb); if (net == NULL) { return; } + asoc = &stcb->asoc; TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) { /* @@ -11453,13 +11453,11 @@ sctp_add_stream_reset_out(struct sctp_tm int number_entries, uint16_t * list, uint32_t seq, uint32_t resp_seq, uint32_t last_sent) { - int len, old_len, i; + uint16_t len, old_len, i; struct sctp_stream_reset_out_request *req_out; struct sctp_chunkhdr *ch; ch = mtod(chk->data, struct sctp_chunkhdr *); - - old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); /* get to new offset for the param. */ @@ -11493,19 +11491,16 @@ sctp_add_stream_reset_out(struct sctp_tm return; } - -void +static void sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk, int number_entries, uint16_t * list, uint32_t seq) { - int len, old_len, i; + uint16_t len, old_len, i; struct sctp_stream_reset_in_request *req_in; struct sctp_chunkhdr *ch; ch = mtod(chk->data, struct sctp_chunkhdr *); - - old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); /* get to new offset for the param. */ @@ -11537,18 +11532,15 @@ sctp_add_stream_reset_in(struct sctp_tmi return; } - -void +static void sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk, uint32_t seq) { - int len, old_len; + uint16_t len, old_len; struct sctp_stream_reset_tsn_request *req_tsn; struct sctp_chunkhdr *ch; ch = mtod(chk->data, struct sctp_chunkhdr *); - - old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); /* get to new offset for the param. */ @@ -11572,13 +11564,11 @@ void sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk, uint32_t resp_seq, uint32_t result) { - int len, old_len; + uint16_t len, old_len; struct sctp_stream_reset_response *resp; struct sctp_chunkhdr *ch; ch = mtod(chk->data, struct sctp_chunkhdr *); - - old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); /* get to new offset for the param. */ @@ -11597,22 +11587,18 @@ sctp_add_stream_reset_result(struct sctp chk->send_size = SCTP_SIZE32(chk->book_size); SCTP_BUF_LEN(chk->data) = chk->send_size; return; - } - void sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk, uint32_t resp_seq, uint32_t result, uint32_t send_una, uint32_t recv_next) { - int len, old_len; + uint16_t len, old_len; struct sctp_stream_reset_response_tsn *resp; struct sctp_chunkhdr *ch; ch = mtod(chk->data, struct sctp_chunkhdr *); - - old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); /* get to new offset for the param. */ @@ -11640,7 +11626,7 @@ sctp_add_an_out_stream(struct sctp_tmit_ uint32_t seq, uint16_t adding) { - int len, old_len; + uint16_t len, old_len; struct sctp_chunkhdr *ch; struct sctp_stream_reset_add_strm *addstr; @@ -11673,7 +11659,7 @@ sctp_add_an_in_stream(struct sctp_tmit_c uint32_t seq, uint16_t adding) { - int len, old_len; + uint16_t len, old_len; struct sctp_chunkhdr *ch; struct sctp_stream_reset_add_strm *addstr; @@ -11700,8 +11686,6 @@ sctp_add_an_in_stream(struct sctp_tmit_c return; } - - int sctp_send_str_reset_req(struct sctp_tcb *stcb, int number_entries, uint16_t * list, @@ -11710,8 +11694,7 @@ sctp_send_str_reset_req(struct sctp_tcb uint8_t send_tsn_req, uint8_t add_stream, uint16_t adding_o, - uint16_t adding_i, uint8_t peer_asked -) + uint16_t adding_i, uint8_t peer_asked) { struct sctp_association *asoc; Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Jul 7 11:50:51 2013 (r252932) +++ stable/9/sys/netinet/sctp_output.h Sun Jul 7 11:53:34 2013 (r252933) @@ -173,37 +173,19 @@ void sctp_send_cwr(struct sctp_tcb *, st void -sctp_add_stream_reset_out(struct sctp_tmit_chunk *chk, - int number_entries, uint16_t * list, - uint32_t seq, uint32_t resp_seq, uint32_t last_sent); +sctp_add_stream_reset_out(struct sctp_tmit_chunk *, + int, uint16_t *, uint32_t, uint32_t, uint32_t); void -sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk, - int number_entries, uint16_t * list, - uint32_t seq); + sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t); void -sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk, - uint32_t seq); - -void -sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk, - uint32_t resp_seq, uint32_t result); - -void -sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk, - uint32_t resp_seq, uint32_t result, - uint32_t send_una, uint32_t recv_next); +sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *, + uint32_t, uint32_t, uint32_t, uint32_t); int -sctp_send_str_reset_req(struct sctp_tcb *stcb, - int number_entries, uint16_t * list, - uint8_t send_out_req, - uint8_t send_in_req, - uint8_t send_tsn_req, - uint8_t add_stream, - uint16_t adding_o, - uint16_t adding_i, uint8_t from_peer); +sctp_send_str_reset_req(struct sctp_tcb *, int, uint16_t *, uint8_t, uint8_t, + uint8_t, uint8_t, uint16_t, uint16_t, uint8_t); void sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:56:28 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D8695AE4; Sun, 7 Jul 2013 11:56:28 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CA7701170; Sun, 7 Jul 2013 11:56:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67BuSGt070670; Sun, 7 Jul 2013 11:56:28 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BuSPL070669; Sun, 7 Jul 2013 11:56:28 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071156.r67BuSPL070669@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:56:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252934 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:56:28 -0000 Author: tuexen Date: Sun Jul 7 11:56:28 2013 New Revision: 252934 URL: http://svnweb.freebsd.org/changeset/base/252934 Log: MFC r240842: Fix a bug related to handling Re-config chunks. It is not true that the association can be removed if the socket is gone. Modified: stable/9/sys/netinet/sctp_input.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:53:34 2013 (r252933) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 11:56:28 2013 (r252934) @@ -5387,23 +5387,6 @@ process_control_chunks: *offset = length; return (NULL); } - if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { - /* We are not interested anymore */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) - so = SCTP_INP_SO(inp); - atomic_add_int(&stcb->asoc.refcnt, 1); - SCTP_TCB_UNLOCK(stcb); - SCTP_SOCKET_LOCK(so, 1); - SCTP_TCB_LOCK(stcb); - atomic_subtract_int(&stcb->asoc.refcnt, 1); -#endif - (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_30); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) - SCTP_SOCKET_UNLOCK(so, 1); -#endif - *offset = length; - return (NULL); - } if (stcb->asoc.peer_supports_strreset == 0) { /* * hmm, peer should have announced this, but From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 11:58:44 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F184DC2B; Sun, 7 Jul 2013 11:58:43 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E29AA1181; Sun, 7 Jul 2013 11:58:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Bwhhn070973; Sun, 7 Jul 2013 11:58:43 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67BwhMm070971; Sun, 7 Jul 2013 11:58:43 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071158.r67BwhMm070971@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 11:58:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252935 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 11:58:44 -0000 Author: tuexen Date: Sun Jul 7 11:58:43 2013 New Revision: 252935 URL: http://svnweb.freebsd.org/changeset/base/252935 Log: MFC r240848: Declare a static function as such. 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 Jul 7 11:56:28 2013 (r252934) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 11:58:43 2013 (r252935) @@ -6412,7 +6412,7 @@ error_out: } } -int +static int sctp_med_chunk_output(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_association *asoc, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:25:29 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0B401837; Sun, 7 Jul 2013 12:25:29 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F14BD1281; Sun, 7 Jul 2013 12:25:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CPSu4080113; Sun, 7 Jul 2013 12:25:28 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CPSf3080112; Sun, 7 Jul 2013 12:25:28 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071225.r67CPSf3080112@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:25:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252936 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:25:29 -0000 Author: tuexen Date: Sun Jul 7 12:25:28 2013 New Revision: 252936 URL: http://svnweb.freebsd.org/changeset/base/252936 Log: MFC r240849: Whitespace change. Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 11:58:43 2013 (r252935) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 12:25:28 2013 (r252936) @@ -3323,8 +3323,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, continue; } else if (TAILQ_EMPTY(&asoc->asoc.send_queue) && TAILQ_EMPTY(&asoc->asoc.sent_queue) && - (asoc->asoc.stream_queue_cnt == 0) - ) { + (asoc->asoc.stream_queue_cnt == 0)) { if (asoc->asoc.locked_on_sending) { goto abort_anyway; } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:29:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4C808A5E; Sun, 7 Jul 2013 12:29:02 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3EFCF1298; Sun, 7 Jul 2013 12:29:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CT22Q080602; Sun, 7 Jul 2013 12:29:02 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CT2GY080601; Sun, 7 Jul 2013 12:29:02 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071229.r67CT2GY080601@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252937 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:29:02 -0000 Author: tuexen Date: Sun Jul 7 12:29:01 2013 New Revision: 252937 URL: http://svnweb.freebsd.org/changeset/base/252937 Log: MFC r242326: Add braces (as used elsewhere in the SCTP code). 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 Jul 7 12:25:28 2013 (r252936) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:29:01 2013 (r252937) @@ -3981,9 +3981,9 @@ sctp_lowlevel_chunk_output(struct sctp_i } if ((nofragment_flag) && (port == 0)) { ip->ip_off = IP_DF; - } else + } else { ip->ip_off = 0; - + } /* FreeBSD has a function for ip_id's */ ip->ip_id = ip_newid(); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:32:31 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5465DBC9; Sun, 7 Jul 2013 12:32:31 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 367E612BF; Sun, 7 Jul 2013 12:32:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CWVfm082700; Sun, 7 Jul 2013 12:32:31 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CWUHu082697; Sun, 7 Jul 2013 12:32:30 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071232.r67CWUHu082697@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:32:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252938 - in stable/9/sys: netinet netinet6 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:32:31 -0000 Author: tuexen Date: Sun Jul 7 12:32:30 2013 New Revision: 252938 URL: http://svnweb.freebsd.org/changeset/base/252938 Log: MFC r242327: Whitespace changes due to upstream integration of SCTP changes in the FreeBSD code base. Modified: stable/9/sys/netinet/sctp_uio.h stable/9/sys/netinet/sctp_var.h stable/9/sys/netinet6/sctp6_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Sun Jul 7 12:29:01 2013 (r252937) +++ stable/9/sys/netinet/sctp_uio.h Sun Jul 7 12:32:30 2013 (r252938) @@ -1278,33 +1278,39 @@ void sctp_freeladdrs(struct sockaddr *); int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *); /* deprecated */ -ssize_t sctp_sendmsg -(int, const void *, size_t, const struct sockaddr *, +ssize_t +sctp_sendmsg(int, const void *, size_t, const struct sockaddr *, socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t); /* deprecated */ - ssize_t sctp_send(int, const void *, size_t, - const struct sctp_sndrcvinfo *, int); +ssize_t +sctp_send(int, const void *, size_t, + const struct sctp_sndrcvinfo *, int); /* deprecated */ - ssize_t sctp_sendx(int, const void *, size_t, struct sockaddr *, - int, struct sctp_sndrcvinfo *, int); +ssize_t +sctp_sendx(int, const void *, size_t, struct sockaddr *, + int, struct sctp_sndrcvinfo *, int); /* deprecated */ - ssize_t sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *, - int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t); +ssize_t +sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *, + int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t); - sctp_assoc_t sctp_getassocid(int, struct sockaddr *); +sctp_assoc_t sctp_getassocid(int, struct sockaddr *); /* deprecated */ - ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t *, - struct sctp_sndrcvinfo *, int *); - - ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *, - int, void *, socklen_t, unsigned int, int); - - ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *, - socklen_t *, void *, socklen_t *, unsigned int *, int *); +ssize_t +sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t *, + struct sctp_sndrcvinfo *, int *); + +ssize_t +sctp_sendv(int, const struct iovec *, int, struct sockaddr *, + int, void *, socklen_t, unsigned int, int); + +ssize_t +sctp_recvv(int, const struct iovec *, int, struct sockaddr *, + socklen_t *, void *, socklen_t *, unsigned int *, int *); __END_DECLS Modified: stable/9/sys/netinet/sctp_var.h ============================================================================== --- stable/9/sys/netinet/sctp_var.h Sun Jul 7 12:29:01 2013 (r252937) +++ stable/9/sys/netinet/sctp_var.h Sun Jul 7 12:32:30 2013 (r252938) @@ -321,48 +321,34 @@ struct sctphdr; void sctp_close(struct socket *so); int sctp_disconnect(struct socket *so); - void sctp_ctlinput(int, struct sockaddr *, void *); int sctp_ctloutput(struct socket *, struct sockopt *); #ifdef INET void sctp_input_with_port(struct mbuf *, int, uint16_t); - -#endif -#ifdef INET void sctp_input(struct mbuf *, int); #endif void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t); void sctp_drain(void); void sctp_init(void); - void sctp_finish(void); - int sctp_flush(struct socket *, int); int sctp_shutdown(struct socket *); -void sctp_notify -(struct sctp_inpcb *, struct ip *ip, struct sctphdr *, +void +sctp_notify(struct sctp_inpcb *, struct ip *ip, struct sctphdr *, struct sockaddr *, struct sctp_tcb *, struct sctp_nets *); - - int sctp_bindx(struct socket *, int, struct sockaddr_storage *, - int, int, struct proc *); +int +sctp_bindx(struct socket *, int, struct sockaddr_storage *, + int, int, struct proc *); /* can't use sctp_assoc_t here */ - int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); - - int sctp_ingetaddr(struct socket *, - struct sockaddr ** -); - - int sctp_peeraddr(struct socket *, - struct sockaddr ** -); - - int sctp_listen(struct socket *, int, struct thread *); - - int sctp_accept(struct socket *, struct sockaddr **); +int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); +int sctp_ingetaddr(struct socket *, struct sockaddr **); +int sctp_peeraddr(struct socket *, struct sockaddr **); +int sctp_listen(struct socket *, int, struct thread *); +int sctp_accept(struct socket *, struct sockaddr **); #endif /* _KERNEL */ Modified: stable/9/sys/netinet6/sctp6_var.h ============================================================================== --- stable/9/sys/netinet6/sctp6_var.h Sun Jul 7 12:29:01 2013 (r252937) +++ stable/9/sys/netinet6/sctp6_var.h Sun Jul 7 12:32:30 2013 (r252938) @@ -41,21 +41,15 @@ __FBSDID("$FreeBSD$"); SYSCTL_DECL(_net_inet6_sctp6); extern struct pr_usrreqs sctp6_usrreqs; - int sctp6_input(struct mbuf **, int *, int); -int sctp6_output -(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, +int +sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, struct proc *); - void sctp6_ctlinput(int, struct sockaddr *, void *); - - - extern void sctp6_notify(struct sctp_inpcb *inp, - struct icmp6_hdr *icmph, - struct sctphdr *sh, - struct sockaddr *to, - struct sctp_tcb *stcb, - struct sctp_nets *net); +void sctp6_ctlinput(int, struct sockaddr *, void *); +extern void +sctp6_notify(struct sctp_inpcb *, struct icmp6_hdr *, + struct sctphdr *, struct sockaddr *, + struct sctp_tcb *, struct sctp_nets *); - -#endif /* _KERNEL */ +#endif #endif From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:34:48 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 45BF6DFE; Sun, 7 Jul 2013 12:34:48 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 36A5112DD; Sun, 7 Jul 2013 12:34:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CYm5D083036; Sun, 7 Jul 2013 12:34:48 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CYmDT083035; Sun, 7 Jul 2013 12:34:48 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071234.r67CYmDT083035@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:34:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252939 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:34:48 -0000 Author: tuexen Date: Sun Jul 7 12:34:47 2013 New Revision: 252939 URL: http://svnweb.freebsd.org/changeset/base/252939 Log: MFC r242512: Fix errno in a couple of error cases. Modified: stable/9/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 12:32:30 2013 (r252938) +++ stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 12:34:47 2013 (r252939) @@ -449,6 +449,7 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, opt_len = (socklen_t) ((size_t)asoc + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { + errno = ENOMEM; return (-1); } addrs->sget_assoc_id = id; @@ -777,6 +778,7 @@ sctp_sendx(int sd, const void *msg, size } buf = malloc(len); if (buf == NULL) { + errno = ENOMEM; return (-1); } aa = (int *)buf; @@ -1052,7 +1054,7 @@ sctp_sendv(int sd, CMSG_SPACE(sizeof(struct sctp_authinfo)) + (size_t)addrcnt * CMSG_SPACE(sizeof(struct in6_addr))); if (cmsgbuf == NULL) { - errno = ENOBUFS; + errno = ENOMEM; return (-1); } msg.msg_control = cmsgbuf; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:50:05 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 932801BB; Sun, 7 Jul 2013 12:50:05 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 75AC41331; Sun, 7 Jul 2013 12:50:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Co5Tv086612; Sun, 7 Jul 2013 12:50:05 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67Co4lw086608; Sun, 7 Jul 2013 12:50:04 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071250.r67Co4lw086608@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:50:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252940 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:50:05 -0000 Author: tuexen Date: Sun Jul 7 12:50:04 2013 New Revision: 252940 URL: http://svnweb.freebsd.org/changeset/base/252940 Log: MFC r242627: Move from early SSN assignment to late SSN assignment. This doesn't change functionality, but makes upcoming change much easier. Developed with rrs@ at the IETF 85. Modified: stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_structs.h stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 12:34:47 2013 (r252939) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 12:50:04 2013 (r252940) @@ -1942,7 +1942,7 @@ sctp_process_cookie_existing(struct mbuf sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_NOT_LOCKED); for (i = 0; i < stcb->asoc.streamoutcnt; i++) { stcb->asoc.strmout[i].stream_no = i; - stcb->asoc.strmout[i].next_sequence_sent = 0; + stcb->asoc.strmout[i].next_sequence_send = 0; stcb->asoc.strmout[i].last_msg_incomplete = 0; } /* process the INIT-ACK info (my info) */ @@ -3489,7 +3489,7 @@ sctp_reset_out_streams(struct sctp_tcb * if (number_entries == 0) { for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - stcb->asoc.strmout[i].next_sequence_sent = 0; + stcb->asoc.strmout[i].next_sequence_send = 0; } } else if (number_entries) { for (i = 0; i < number_entries; i++) { @@ -3500,7 +3500,7 @@ sctp_reset_out_streams(struct sctp_tcb * /* no such stream */ continue; } - stcb->asoc.strmout[temp].next_sequence_sent = 0; + stcb->asoc.strmout[temp].next_sequence_send = 0; } } sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_SEND, stcb, number_entries, (void *)list, SCTP_SO_NOT_LOCKED); Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:34:47 2013 (r252939) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:50:04 2013 (r252940) @@ -3513,7 +3513,7 @@ sctp_process_cmsgs_for_init(struct sctp_ stcb->asoc.pre_open_streams = stcb->asoc.streamoutcnt; } for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - stcb->asoc.strmout[i].next_sequence_sent = 0; + stcb->asoc.strmout[i].next_sequence_send = 0; TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); stcb->asoc.strmout[i].stream_no = i; stcb->asoc.strmout[i].last_msg_incomplete = 0; @@ -6194,7 +6194,6 @@ sctp_msg_append(struct sctp_tcb *stcb, sp->timetolive = srcv->sinfo_timetolive; sp->ppid = srcv->sinfo_ppid; sp->context = srcv->sinfo_context; - sp->strseq = 0; if (sp->sinfo_flags & SCTP_ADDR_OVER) { sp->net = net; atomic_add_int(&sp->net->ref_count, 1); @@ -6235,10 +6234,6 @@ sctp_msg_append(struct sctp_tcb *stcb, sctp_snd_sb_alloc(stcb, sp->length); atomic_add_int(&stcb->asoc.stream_queue_cnt, 1); TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); - if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) { - sp->strseq = strm->next_sequence_sent; - strm->next_sequence_sent++; - } stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, strm, sp, 1); m = NULL; if (hold_stcb_lock == 0) { @@ -7379,7 +7374,10 @@ dont_do_it: chk->asoc = &stcb->asoc; chk->pad_inplace = 0; chk->no_fr_allowed = 0; - chk->rec.data.stream_seq = sp->strseq; + chk->rec.data.stream_seq = strq->next_sequence_send; + if (rcv_flags & SCTP_DATA_LAST_FRAG) { + strq->next_sequence_send++; + } chk->rec.data.stream_number = sp->stream; chk->rec.data.payloadtype = sp->ppid; chk->rec.data.context = sp->context; @@ -11794,7 +11792,7 @@ sctp_send_str_reset_req(struct sctp_tcb 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].next_sequence_send = oldstream[i].next_sequence_send; 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]); @@ -11814,7 +11812,7 @@ sctp_send_str_reset_req(struct sctp_tcb /* 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; + stcb->asoc.strmout[i].next_sequence_send = 0x0; TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); stcb->asoc.strmout[i].stream_no = i; stcb->asoc.strmout[i].last_msg_incomplete = 0; @@ -11971,7 +11969,6 @@ sctp_copy_it_in(struct sctp_tcb *stcb, sp->timetolive = srcv->sinfo_timetolive; sp->ppid = srcv->sinfo_ppid; sp->context = srcv->sinfo_context; - sp->strseq = 0; (void)SCTP_GETTIME_TIMEVAL(&sp->ts); sp->stream = srcv->sinfo_stream; @@ -12724,15 +12721,7 @@ skip_preblock: } sctp_snd_sb_alloc(stcb, sp->length); atomic_add_int(&asoc->stream_queue_cnt, 1); - if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) { - sp->strseq = strm->next_sequence_sent; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_AT_SEND_2_SCTP) { - sctp_misc_ints(SCTP_STRMOUT_LOG_ASSIGN, - (uintptr_t) stcb, sp->length, - (uint32_t) ((srcv->sinfo_stream << 16) | sp->strseq), 0); - } - strm->next_sequence_sent++; - } else { + if (srcv->sinfo_flags & SCTP_UNORDERED) { SCTP_STAT_INCR(sctps_sends_with_unord); } TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); Modified: stable/9/sys/netinet/sctp_structs.h ============================================================================== --- stable/9/sys/netinet/sctp_structs.h Sun Jul 7 12:34:47 2013 (r252939) +++ stable/9/sys/netinet/sctp_structs.h Sun Jul 7 12:50:04 2013 (r252940) @@ -517,7 +517,6 @@ struct sctp_stream_queue_pending { uint32_t context; uint16_t sinfo_flags; uint16_t stream; - uint16_t strseq; uint16_t act_flags; uint16_t auth_keyid; uint8_t holds_key_ref; @@ -590,7 +589,7 @@ struct sctp_stream_out { struct sctp_streamhead outqueue; union scheduling_parameters ss_params; uint16_t stream_no; - uint16_t next_sequence_sent; /* next one I expect to send out */ + uint16_t next_sequence_send; /* next one I expect to send out */ uint8_t last_msg_incomplete; }; Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 12:34:47 2013 (r252939) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 12:50:04 2013 (r252940) @@ -1052,7 +1052,7 @@ sctp_init_asoc(struct sctp_inpcb *m, str * that were dropped must be notified to the upper layer as * failed to send. */ - asoc->strmout[i].next_sequence_sent = 0x0; + asoc->strmout[i].next_sequence_send = 0x0; TAILQ_INIT(&asoc->strmout[i].outqueue); asoc->strmout[i].stream_no = i; asoc->strmout[i].last_msg_incomplete = 0; @@ -2973,7 +2973,7 @@ sctp_notify_send_failed2(struct sctp_tcb /* not exactly what the user sent in, but should be close :) */ bzero(&ssf->ssf_info, sizeof(ssf->ssf_info)); ssf->ssf_info.sinfo_stream = sp->stream; - ssf->ssf_info.sinfo_ssn = sp->strseq; + ssf->ssf_info.sinfo_ssn = 0; if (sp->some_taken) { ssf->ssf_info.sinfo_flags = SCTP_DATA_LAST_FRAG; } else { @@ -4774,77 +4774,69 @@ sctp_release_pr_sctp_chunk(struct sctp_t * Still no eom found. That means there is stuff left on the * stream out queue.. yuck. */ - strq = &stcb->asoc.strmout[stream]; SCTP_TCB_SEND_LOCK(stcb); - TAILQ_FOREACH(sp, &strq->outqueue, next) { - /* FIXME: Shouldn't this be a serial number check? */ - if (sp->strseq > seq) { - break; - } - /* Check if its our SEQ */ - if (sp->strseq == seq) { - sp->discard_rest = 1; - /* - * We may need to put a chunk on the queue - * that holds the TSN that would have been - * sent with the LAST bit. - */ + strq = &stcb->asoc.strmout[stream]; + sp = TAILQ_FIRST(&strq->outqueue); + if (sp != NULL) { + sp->discard_rest = 1; + /* + * We may need to put a chunk on the queue that + * holds the TSN that would have been sent with the + * LAST bit. + */ + if (chk == NULL) { + /* Yep, we have to */ + sctp_alloc_a_chunk(stcb, chk); if (chk == NULL) { - /* Yep, we have to */ - sctp_alloc_a_chunk(stcb, chk); - if (chk == NULL) { - /* - * we are hosed. All we can - * do is nothing.. which - * will cause an abort if - * the peer is paying - * attention. - */ - goto oh_well; - } - memset(chk, 0, sizeof(*chk)); - chk->rec.data.rcv_flags = SCTP_DATA_LAST_FRAG; - chk->sent = SCTP_FORWARD_TSN_SKIP; - chk->asoc = &stcb->asoc; - chk->rec.data.stream_seq = sp->strseq; - chk->rec.data.stream_number = sp->stream; - chk->rec.data.payloadtype = sp->ppid; - chk->rec.data.context = sp->context; - chk->flags = sp->act_flags; - if (sp->net) - chk->whoTo = sp->net; - else - chk->whoTo = stcb->asoc.primary_destination; - atomic_add_int(&chk->whoTo->ref_count, 1); - chk->rec.data.TSN_seq = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1); - stcb->asoc.pr_sctp_cnt++; - chk->pr_sctp_on = 1; - TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next); - stcb->asoc.sent_queue_cnt++; - stcb->asoc.pr_sctp_cnt++; - } else { - chk->rec.data.rcv_flags |= SCTP_DATA_LAST_FRAG; - } - oh_well: - if (sp->data) { /* - * Pull any data to free up the SB - * and allow sender to "add more" - * while we will throw away :-) + * we are hosed. All we can do is + * nothing.. which will cause an + * abort if the peer is paying + * attention. */ - sctp_free_spbufspace(stcb, &stcb->asoc, - sp); - ret_sz += sp->length; - do_wakeup_routine = 1; - sp->some_taken = 1; - sctp_m_freem(sp->data); - sp->data = NULL; - sp->tail_mbuf = NULL; - sp->length = 0; + goto oh_well; } - break; + memset(chk, 0, sizeof(*chk)); + chk->rec.data.rcv_flags = SCTP_DATA_LAST_FRAG; + chk->sent = SCTP_FORWARD_TSN_SKIP; + chk->asoc = &stcb->asoc; + chk->rec.data.stream_seq = strq->next_sequence_send; + chk->rec.data.stream_number = sp->stream; + chk->rec.data.payloadtype = sp->ppid; + chk->rec.data.context = sp->context; + chk->flags = sp->act_flags; + if (sp->net) + chk->whoTo = sp->net; + else + chk->whoTo = stcb->asoc.primary_destination; + atomic_add_int(&chk->whoTo->ref_count, 1); + chk->rec.data.TSN_seq = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1); + stcb->asoc.pr_sctp_cnt++; + chk->pr_sctp_on = 1; + TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next); + stcb->asoc.sent_queue_cnt++; + stcb->asoc.pr_sctp_cnt++; + } else { + chk->rec.data.rcv_flags |= SCTP_DATA_LAST_FRAG; + } + strq->next_sequence_send++; + oh_well: + if (sp->data) { + /* + * Pull any data to free up the SB and allow + * sender to "add more" while we will throw + * away :-) + */ + sctp_free_spbufspace(stcb, &stcb->asoc, sp); + ret_sz += sp->length; + do_wakeup_routine = 1; + sp->some_taken = 1; + sctp_m_freem(sp->data); + sp->data = NULL; + sp->tail_mbuf = NULL; + sp->length = 0; } - } /* End tailq_foreach */ + } SCTP_TCB_SEND_UNLOCK(stcb); } if (do_wakeup_routine) { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:54:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 550BD3B7; Sun, 7 Jul 2013 12:54:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 47138134D; Sun, 7 Jul 2013 12:54:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CsGNU088697; Sun, 7 Jul 2013 12:54:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CsFrr088693; Sun, 7 Jul 2013 12:54:15 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071254.r67CsFrr088693@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:54:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252941 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:54:16 -0000 Author: tuexen Date: Sun Jul 7 12:54:15 2013 New Revision: 252941 URL: http://svnweb.freebsd.org/changeset/base/252941 Log: MFC r242708, r242709: Improve PR-SCTP if used in combination with NR-SACK. Based on work done by Mohammad Rajiullah. Modified: stable/9/sys/netinet/sctp_constants.h stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_output.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_constants.h ============================================================================== --- stable/9/sys/netinet/sctp_constants.h Sun Jul 7 12:50:04 2013 (r252940) +++ stable/9/sys/netinet/sctp_constants.h Sun Jul 7 12:54:15 2013 (r252941) @@ -370,6 +370,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_DATAGRAM_ACKED 10010 #define SCTP_DATAGRAM_MARKED 20010 #define SCTP_FORWARD_TSN_SKIP 30010 +#define SCTP_DATAGRAM_NR_MARKED 40010 /* chunk output send from locations */ #define SCTP_OUTPUT_FROM_USR_SEND 0 Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 12:50:04 2013 (r252940) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 12:54:15 2013 (r252941) @@ -2975,9 +2975,10 @@ sctp_process_segment_range(struct sctp_t * All chunks NOT UNSENT fall through here and are marked * (leave PR-SCTP ones that are to skip alone though) */ - if (tp1->sent != SCTP_FORWARD_TSN_SKIP) + if ((tp1->sent != SCTP_FORWARD_TSN_SKIP) && + (tp1->sent != SCTP_DATAGRAM_NR_MARKED)) { tp1->sent = SCTP_DATAGRAM_MARKED; - + } if (tp1->rec.data.chunk_was_revoked) { /* deflate the cwnd */ tp1->whoTo->cwnd -= tp1->book_size; @@ -2985,6 +2986,7 @@ sctp_process_segment_range(struct sctp_t } /* NR Sack code here */ if (nr_sacking) { + tp1->sent = SCTP_DATAGRAM_NR_MARKED; if (tp1->data) { /* * sa_ignore @@ -3600,12 +3602,14 @@ sctp_try_advance_peer_ack_point(struct s } TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { if (tp1->sent != SCTP_FORWARD_TSN_SKIP && - tp1->sent != SCTP_DATAGRAM_RESEND) { + tp1->sent != SCTP_DATAGRAM_RESEND && + tp1->sent != SCTP_DATAGRAM_NR_MARKED) { /* no chance to advance, out of here */ break; } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_TRY_ADVANCE) { - if (tp1->sent == SCTP_FORWARD_TSN_SKIP) { + if ((tp1->sent == SCTP_FORWARD_TSN_SKIP) || + (tp1->sent == SCTP_DATAGRAM_NR_MARKED)) { sctp_misc_ints(SCTP_FWD_TSN_CHECK, asoc->advanced_peer_ack_point, tp1->rec.data.TSN_seq, 0, 0); @@ -3653,7 +3657,8 @@ sctp_try_advance_peer_ack_point(struct s * the chunk, advance our peer ack point and we can check * the next chunk. */ - if (tp1->sent == SCTP_FORWARD_TSN_SKIP) { + if ((tp1->sent == SCTP_FORWARD_TSN_SKIP) || + (tp1->sent == SCTP_DATAGRAM_NR_MARKED)) { /* advance PeerAckPoint goes forward */ if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->advanced_peer_ack_point)) { asoc->advanced_peer_ack_point = tp1->rec.data.TSN_seq; Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:50:04 2013 (r252940) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:54:15 2013 (r252941) @@ -10152,7 +10152,8 @@ sctp_fill_in_rest: unsigned int cnt_of_skipped = 0; TAILQ_FOREACH(at, &asoc->sent_queue, sctp_next) { - if (at->sent != SCTP_FORWARD_TSN_SKIP) { + if ((at->sent != SCTP_FORWARD_TSN_SKIP) && + (at->sent != SCTP_DATAGRAM_NR_MARKED)) { /* no more to look at */ break; } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 12:57:47 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5CEC95E4; Sun, 7 Jul 2013 12:57:47 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4CF32136A; Sun, 7 Jul 2013 12:57:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67CvlMr089269; Sun, 7 Jul 2013 12:57:47 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67CvkEC089260; Sun, 7 Jul 2013 12:57:46 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071257.r67CvkEC089260@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 12:57:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252942 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 12:57:47 -0000 Author: tuexen Date: Sun Jul 7 12:57:45 2013 New Revision: 252942 URL: http://svnweb.freebsd.org/changeset/base/252942 Log: MFC r242714: Add per outgoing stream accounting for chunks in the send and sent queue. This provides no functional change, but is a preparation for an upcoming stream reset improvement. Done with rrs@. Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_structs.h stable/9/sys/netinet/sctp_timer.c stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 12:57:45 2013 (r252942) @@ -3963,7 +3963,15 @@ sctp_express_handle_sack(struct sctp_tcb tp1->whoTo->cwnd -= tp1->book_size; tp1->rec.data.chunk_was_revoked = 0; } - tp1->sent = SCTP_DATAGRAM_ACKED; + if (tp1->sent != SCTP_DATAGRAM_NR_MARKED) { + if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number); +#endif + } + } TAILQ_REMOVE(&asoc->sent_queue, tp1, sctp_next); if (tp1->data) { /* sa_ignore NO_NULL_CHK */ @@ -4699,10 +4707,14 @@ sctp_handle_sack(struct mbuf *m, int off if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cum_ack)) { break; } - if (tp1->sent == SCTP_DATAGRAM_UNSENT) { - /* no more sent on list */ - SCTP_PRINTF("Warning, tp1->sent == %d and its now acked?\n", - tp1->sent); + if (tp1->sent != SCTP_DATAGRAM_NR_MARKED) { + if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number); +#endif + } } TAILQ_REMOVE(&asoc->sent_queue, tp1, sctp_next); if (tp1->pr_sctp_on) { Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 12:57:45 2013 (r252942) @@ -311,6 +311,13 @@ sctp_process_init(struct sctp_init_chunk if (chk->rec.data.stream_number >= newcnt) { TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); asoc->send_queue_cnt--; + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number); +#endif + } if (chk->data != NULL) { sctp_free_bufspace(stcb, asoc, chk, 1); sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb, Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 12:57:45 2013 (r252942) @@ -4949,6 +4949,15 @@ sctp_free_assoc(struct sctp_inpcb *inp, } /* sent queue SHOULD be empty */ TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { + if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number); +#endif + } + } TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); if (chk->data) { if (so) { Modified: stable/9/sys/netinet/sctp_structs.h ============================================================================== --- stable/9/sys/netinet/sctp_structs.h Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctp_structs.h Sun Jul 7 12:57:45 2013 (r252942) @@ -588,6 +588,7 @@ union scheduling_parameters { struct sctp_stream_out { struct sctp_streamhead outqueue; union scheduling_parameters ss_params; + uint32_t chunks_on_queues; uint16_t stream_no; uint16_t next_sequence_send; /* next one I expect to send out */ uint8_t last_msg_incomplete; Modified: stable/9/sys/netinet/sctp_timer.c ============================================================================== --- stable/9/sys/netinet/sctp_timer.c Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctp_timer.c Sun Jul 7 12:57:45 2013 (r252942) @@ -440,6 +440,11 @@ sctp_recover_sent_list(struct sctp_tcb * if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.TSN_seq)) { SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n", (void *)chk, chk->rec.data.TSN_seq, asoc->last_acked_seq); + if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; + } + } TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); if (chk->pr_sctp_on) { if (asoc->pr_sctp_cnt != 0) Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 12:54:15 2013 (r252941) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 12:57:45 2013 (r252942) @@ -3727,6 +3727,15 @@ sctp_report_all_outbound(struct sctp_tcb TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); asoc->sent_queue_cnt--; + if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number); +#endif + } + } if (chk->data != NULL) { sctp_free_bufspace(stcb, asoc, chk, 1); sctp_ulp_notify(SCTP_NOTIFY_SENT_DG_FAIL, stcb, @@ -3743,6 +3752,13 @@ sctp_report_all_outbound(struct sctp_tcb TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); asoc->send_queue_cnt--; + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number); +#endif + } if (chk->data != NULL) { sctp_free_bufspace(stcb, asoc, chk, 1); sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:04:32 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E25B3812; Sun, 7 Jul 2013 13:04:32 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D41701388; Sun, 7 Jul 2013 13:04:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67D4Wvl092071; Sun, 7 Jul 2013 13:04:32 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67D4V8D092063; Sun, 7 Jul 2013 13:04:31 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071304.r67D4V8D092063@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:04:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252943 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:04:33 -0000 Author: tuexen Date: Sun Jul 7 13:04:31 2013 New Revision: 252943 URL: http://svnweb.freebsd.org/changeset/base/252943 Log: MFC r243157: Get the accounting working. We now have counters how many chunks for each SCTP outgoing stream are in the send and sent queue. While there, improve the naming of NR-SACK related constants recently introduced. Modified: stable/9/sys/netinet/sctp_constants.h stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_timer.c stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_constants.h ============================================================================== --- stable/9/sys/netinet/sctp_constants.h Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_constants.h Sun Jul 7 13:04:31 2013 (r252943) @@ -370,7 +370,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_DATAGRAM_ACKED 10010 #define SCTP_DATAGRAM_MARKED 20010 #define SCTP_FORWARD_TSN_SKIP 30010 -#define SCTP_DATAGRAM_NR_MARKED 40010 +#define SCTP_DATAGRAM_NR_ACKED 40010 /* chunk output send from locations */ #define SCTP_OUTPUT_FROM_USR_SEND 0 Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 13:04:31 2013 (r252943) @@ -2976,7 +2976,7 @@ sctp_process_segment_range(struct sctp_t * (leave PR-SCTP ones that are to skip alone though) */ if ((tp1->sent != SCTP_FORWARD_TSN_SKIP) && - (tp1->sent != SCTP_DATAGRAM_NR_MARKED)) { + (tp1->sent != SCTP_DATAGRAM_NR_ACKED)) { tp1->sent = SCTP_DATAGRAM_MARKED; } if (tp1->rec.data.chunk_was_revoked) { @@ -2985,8 +2985,16 @@ sctp_process_segment_range(struct sctp_t tp1->rec.data.chunk_was_revoked = 0; } /* NR Sack code here */ - if (nr_sacking) { - tp1->sent = SCTP_DATAGRAM_NR_MARKED; + if (nr_sacking && + (tp1->sent != SCTP_DATAGRAM_NR_ACKED)) { + if (stcb->asoc.strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) { + stcb->asoc.strmout[tp1->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number); +#endif + } + tp1->sent = SCTP_DATAGRAM_NR_ACKED; if (tp1->data) { /* * sa_ignore @@ -3091,7 +3099,6 @@ sctp_check_for_revoked(struct sctp_tcb * uint32_t biggest_tsn_acked) { struct sctp_tmit_chunk *tp1; - int tot_revoked = 0; TAILQ_FOREACH(tp1, &asoc->sent_queue, sctp_next) { if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cumack)) { @@ -3126,7 +3133,6 @@ sctp_check_for_revoked(struct sctp_tcb * * artificial inflation of the flight_size. */ tp1->whoTo->cwnd += tp1->book_size; - tot_revoked++; if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SACK_LOGGING_ENABLE) { sctp_log_sack(asoc->last_acked_seq, cumack, @@ -3603,13 +3609,13 @@ sctp_try_advance_peer_ack_point(struct s TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { if (tp1->sent != SCTP_FORWARD_TSN_SKIP && tp1->sent != SCTP_DATAGRAM_RESEND && - tp1->sent != SCTP_DATAGRAM_NR_MARKED) { + tp1->sent != SCTP_DATAGRAM_NR_ACKED) { /* no chance to advance, out of here */ break; } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_TRY_ADVANCE) { if ((tp1->sent == SCTP_FORWARD_TSN_SKIP) || - (tp1->sent == SCTP_DATAGRAM_NR_MARKED)) { + (tp1->sent == SCTP_DATAGRAM_NR_ACKED)) { sctp_misc_ints(SCTP_FWD_TSN_CHECK, asoc->advanced_peer_ack_point, tp1->rec.data.TSN_seq, 0, 0); @@ -3658,7 +3664,7 @@ sctp_try_advance_peer_ack_point(struct s * the next chunk. */ if ((tp1->sent == SCTP_FORWARD_TSN_SKIP) || - (tp1->sent == SCTP_DATAGRAM_NR_MARKED)) { + (tp1->sent == SCTP_DATAGRAM_NR_ACKED)) { /* advance PeerAckPoint goes forward */ if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->advanced_peer_ack_point)) { asoc->advanced_peer_ack_point = tp1->rec.data.TSN_seq; @@ -3963,7 +3969,7 @@ sctp_express_handle_sack(struct sctp_tcb tp1->whoTo->cwnd -= tp1->book_size; tp1->rec.data.chunk_was_revoked = 0; } - if (tp1->sent != SCTP_DATAGRAM_NR_MARKED) { + if (tp1->sent != SCTP_DATAGRAM_NR_ACKED) { if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) { asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--; #ifdef INVARIANTS @@ -4630,7 +4636,9 @@ sctp_handle_sack(struct mbuf *m, int off tp1->whoTo->cwnd -= tp1->book_size; tp1->rec.data.chunk_was_revoked = 0; } - tp1->sent = SCTP_DATAGRAM_ACKED; + if (tp1->sent != SCTP_DATAGRAM_NR_ACKED) { + tp1->sent = SCTP_DATAGRAM_ACKED; + } } } else { break; @@ -4707,7 +4715,7 @@ sctp_handle_sack(struct mbuf *m, int off if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cum_ack)) { break; } - if (tp1->sent != SCTP_DATAGRAM_NR_MARKED) { + if (tp1->sent != SCTP_DATAGRAM_NR_ACKED) { if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) { asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--; #ifdef INVARIANTS Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 13:04:31 2013 (r252943) @@ -1948,6 +1948,7 @@ sctp_process_cookie_existing(struct mbuf sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_NOT_LOCKED); for (i = 0; i < stcb->asoc.streamoutcnt; i++) { + stcb->asoc.strmout[i].chunks_on_queues = 0; stcb->asoc.strmout[i].stream_no = i; stcb->asoc.strmout[i].next_sequence_send = 0; stcb->asoc.strmout[i].last_msg_incomplete = 0; Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 13:04:31 2013 (r252943) @@ -3513,8 +3513,9 @@ sctp_process_cmsgs_for_init(struct sctp_ stcb->asoc.pre_open_streams = stcb->asoc.streamoutcnt; } for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - stcb->asoc.strmout[i].next_sequence_send = 0; TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].chunks_on_queues = 0; + stcb->asoc.strmout[i].next_sequence_send = 0; 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); @@ -7494,6 +7495,7 @@ dont_do_it: *locked = 1; } asoc->chunks_on_out_queue++; + strq->chunks_on_queues++; TAILQ_INSERT_TAIL(&asoc->send_queue, chk, sctp_next); asoc->send_queue_cnt++; out_of: @@ -10153,7 +10155,7 @@ sctp_fill_in_rest: TAILQ_FOREACH(at, &asoc->sent_queue, sctp_next) { if ((at->sent != SCTP_FORWARD_TSN_SKIP) && - (at->sent != SCTP_DATAGRAM_NR_MARKED)) { + (at->sent != SCTP_DATAGRAM_NR_ACKED)) { /* no more to look at */ break; } @@ -11793,6 +11795,7 @@ sctp_send_str_reset_req(struct sctp_tcb 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].chunks_on_queues = oldstream[i].chunks_on_queues; stcb->asoc.strmout[i].next_sequence_send = oldstream[i].next_sequence_send; stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; stcb->asoc.strmout[i].stream_no = i; @@ -11813,8 +11816,9 @@ sctp_send_str_reset_req(struct sctp_tcb /* 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_send = 0x0; TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.strmout[i].chunks_on_queues = 0; + stcb->asoc.strmout[i].next_sequence_send = 0x0; 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); Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 13:04:31 2013 (r252943) @@ -4925,6 +4925,13 @@ sctp_free_assoc(struct sctp_inpcb *inp, } /* pending send queue SHOULD be empty */ TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { + if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { + asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; +#ifdef INVARIANTS + } else { + panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number); +#endif + } TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); if (chk->data) { if (so) { @@ -4949,7 +4956,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, } /* sent queue SHOULD be empty */ TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { - if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (chk->sent != SCTP_DATAGRAM_NR_ACKED) { if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; #ifdef INVARIANTS @@ -4977,6 +4984,13 @@ sctp_free_assoc(struct sctp_inpcb *inp, SCTP_DECR_CHK_COUNT(); /* sa_ignore FREED_MEMORY */ } +#ifdef INVARIANTS + for (i = 0; i < stcb->asoc.streamoutcnt; i++) { + if (stcb->asoc.strmout[i].chunks_on_queues > 0) { + panic("%u chunks left for stream %u.", stcb->asoc.strmout[i].chunks_on_queues, i); + } + } +#endif /* control queue MAY not be empty */ TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) { TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); Modified: stable/9/sys/netinet/sctp_timer.c ============================================================================== --- stable/9/sys/netinet/sctp_timer.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctp_timer.c Sun Jul 7 13:04:31 2013 (r252943) @@ -440,7 +440,7 @@ sctp_recover_sent_list(struct sctp_tcb * if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.TSN_seq)) { SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n", (void *)chk, chk->rec.data.TSN_seq, asoc->last_acked_seq); - if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (chk->sent != SCTP_DATAGRAM_NR_ACKED) { if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; } Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 12:57:45 2013 (r252942) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 13:04:31 2013 (r252943) @@ -1054,6 +1054,7 @@ sctp_init_asoc(struct sctp_inpcb *m, str */ asoc->strmout[i].next_sequence_send = 0x0; TAILQ_INIT(&asoc->strmout[i].outqueue); + asoc->strmout[i].chunks_on_queues = 0; asoc->strmout[i].stream_no = i; asoc->strmout[i].last_msg_incomplete = 0; asoc->ss_functions.sctp_ss_init_stream(&asoc->strmout[i], NULL); @@ -3727,7 +3728,7 @@ sctp_report_all_outbound(struct sctp_tcb TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); asoc->sent_queue_cnt--; - if (chk->sent != SCTP_DATAGRAM_NR_MARKED) { + if (chk->sent != SCTP_DATAGRAM_NR_ACKED) { if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) { asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--; #ifdef INVARIANTS From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:07:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C54579E3; Sun, 7 Jul 2013 13:07:43 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B6BBD13A4; Sun, 7 Jul 2013 13:07:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67D7hCi092625; Sun, 7 Jul 2013 13:07:43 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67D7gwQ092619; Sun, 7 Jul 2013 13:07:42 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071307.r67D7gwQ092619@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:07:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252944 - in stable/9/sys: netinet netinet6 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:07:43 -0000 Author: tuexen Date: Sun Jul 7 13:07:42 2013 New Revision: 252944 URL: http://svnweb.freebsd.org/changeset/base/252944 Log: MFC r243186: Add support for SCTP/UDP/IPV6. his completes the support of http://tools.ietf.org/html/draft-ietf-tsvwg-sctp-udp-encaps Modified: stable/9/sys/netinet/sctp_pcb.h stable/9/sys/netinet/sctp_sysctl.c stable/9/sys/netinet/sctputil.c stable/9/sys/netinet/sctputil.h stable/9/sys/netinet6/sctp6_usrreq.c stable/9/sys/netinet6/sctp6_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.h ============================================================================== --- stable/9/sys/netinet/sctp_pcb.h Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet/sctp_pcb.h Sun Jul 7 13:07:42 2013 (r252944) @@ -144,7 +144,12 @@ struct sctp_tagblock { struct sctp_epinfo { - struct socket *udp_tun_socket; +#ifdef INET + struct socket *udp4_tun_socket; +#endif +#ifdef INET6 + struct socket *udp6_tun_socket; +#endif struct sctpasochead *sctp_asochash; u_long hashasocmark; Modified: stable/9/sys/netinet/sctp_sysctl.c ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 13:07:42 2013 (r252944) @@ -549,8 +549,6 @@ skip: if ((var) < (min)) { (var) = (min); } \ else if ((var) > (max)) { (var) = (max); } -/* XXX: Remove the #if after tunneling over IPv6 works also on FreeBSD. */ -#if !defined(__FreeBSD__) || defined(INET) static int sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS) { @@ -582,8 +580,6 @@ out: return (error); } -#endif - static int sysctl_sctp_check(SYSCTL_HANDLER_ARGS) @@ -1067,12 +1063,9 @@ SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUT "Clear SCTP Logging buffer"); #endif -/* XXX: Remove the #if after tunneling over IPv6 works also on FreeBSD. */ -#if !defined(__FreeBSD__) || defined(INET) SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_UINT | CTLFLAG_RW, &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC); -#endif SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_UINT | CTLFLAG_RW, &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU", Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 13:07:42 2013 (r252944) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #ifdef INET6 +#include #endif #include #include @@ -48,6 +49,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #ifndef KTR_SCTP @@ -6769,24 +6773,15 @@ sctp_log_trace(uint32_t subsys, const ch } #endif -/* XXX: Remove the #ifdef after tunneling over IPv6 works also on FreeBSD. */ -#ifdef INET -/* We will need to add support - * to bind the ports and such here - * so we can do UDP tunneling. In - * the mean-time, we return error - */ -#include -#include -#include -#ifdef INET6 -#include -#endif - static void sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored) { struct ip *iph; + +#ifdef INET6 + struct ip6_hdr *ip6; + +#endif struct mbuf *sp, *last; struct udphdr *uhdr; uint16_t port; @@ -6836,10 +6831,10 @@ sctp_recv_udp_tunneled_packet(struct mbu #endif #ifdef INET6 case IPV6_VERSION >> 4: - /* Not yet supported. */ - goto out; + ip6 = mtod(m, struct ip6_hdr *); + ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - sizeof(struct udphdr)); + sctp6_input_with_port(&m, &off, port); break; - #endif default: goto out; @@ -6853,19 +6848,22 @@ out: void sctp_over_udp_stop(void) { - struct socket *sop; - /* * This function assumes sysctl caller holds sctp_sysctl_info_lock() * for writting! */ - if (SCTP_BASE_INFO(udp_tun_socket) == NULL) { - /* Nothing to do */ - return; +#ifdef INET + if (SCTP_BASE_INFO(udp4_tun_socket) != NULL) { + soclose(SCTP_BASE_INFO(udp4_tun_socket)); + SCTP_BASE_INFO(udp4_tun_socket) = NULL; } - sop = SCTP_BASE_INFO(udp_tun_socket); - soclose(sop); - SCTP_BASE_INFO(udp_tun_socket) = NULL; +#endif +#ifdef INET6 + if (SCTP_BASE_INFO(udp6_tun_socket) != NULL) { + soclose(SCTP_BASE_INFO(udp6_tun_socket)); + SCTP_BASE_INFO(udp6_tun_socket) = NULL; + } +#endif } int @@ -6873,53 +6871,83 @@ sctp_over_udp_start(void) { uint16_t port; int ret; + +#ifdef INET struct sockaddr_in sin; - struct socket *sop = NULL; - struct thread *th; - struct ucred *cred; +#endif +#ifdef INET6 + struct sockaddr_in6 sin6; + +#endif /* * This function assumes sysctl caller holds sctp_sysctl_info_lock() * for writting! */ port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); - if (port == 0) { + if (ntohs(port) == 0) { /* Must have a port set */ return (EINVAL); } - if (SCTP_BASE_INFO(udp_tun_socket) != NULL) { +#ifdef INET + if (SCTP_BASE_INFO(udp4_tun_socket) != NULL) { + /* Already running -- must stop first */ + return (EALREADY); + } +#endif +#ifdef INET6 + if (SCTP_BASE_INFO(udp6_tun_socket) != NULL) { /* Already running -- must stop first */ return (EALREADY); } - th = curthread; - cred = th->td_ucred; - if ((ret = socreate(PF_INET, &sop, - SOCK_DGRAM, IPPROTO_UDP, cred, th))) { +#endif +#ifdef INET + if ((ret = socreate(PF_INET, &SCTP_BASE_INFO(udp4_tun_socket), + SOCK_DGRAM, IPPROTO_UDP, + curthread->td_ucred, curthread))) { + sctp_over_udp_stop(); return (ret); } - SCTP_BASE_INFO(udp_tun_socket) = sop; - /* call the special UDP hook */ - ret = udp_set_kernel_tunneling(sop, sctp_recv_udp_tunneled_packet); - if (ret) { - goto exit_stage_left; - } - /* Ok we have a socket, bind it to the port */ - memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof(sin); + /* Call the special UDP hook. */ + if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp4_tun_socket), + sctp_recv_udp_tunneled_packet))) { + sctp_over_udp_stop(); + return (ret); + } + /* Ok, we have a socket, bind it to the port. */ + memset(&sin, 0, sizeof(struct sockaddr_in)); + sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_port = htons(port); - ret = sobind(sop, (struct sockaddr *)&sin, th); - if (ret) { - /* Close up we cant get the port */ -exit_stage_left: + if ((ret = sobind(SCTP_BASE_INFO(udp4_tun_socket), + (struct sockaddr *)&sin, curthread))) { sctp_over_udp_stop(); return (ret); } - /* - * Ok we should now get UDP packets directly to our input routine - * sctp_recv_upd_tunneled_packet(). - */ +#endif +#ifdef INET6 + if ((ret = socreate(PF_INET6, &SCTP_BASE_INFO(udp6_tun_socket), + SOCK_DGRAM, IPPROTO_UDP, + curthread->td_ucred, curthread))) { + sctp_over_udp_stop(); + return (ret); + } + /* Call the special UDP hook. */ + if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp6_tun_socket), + sctp_recv_udp_tunneled_packet))) { + sctp_over_udp_stop(); + return (ret); + } + /* Ok, we have a socket, bind it to the port. */ + memset(&sin6, 0, sizeof(struct sockaddr_in6)); + sin6.sin6_len = sizeof(struct sockaddr_in6); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + if ((ret = sobind(SCTP_BASE_INFO(udp6_tun_socket), + (struct sockaddr *)&sin6, curthread))) { + sctp_over_udp_stop(); + return (ret); + } +#endif return (0); } - -#endif Modified: stable/9/sys/netinet/sctputil.h ============================================================================== --- stable/9/sys/netinet/sctputil.h Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet/sctputil.h Sun Jul 7 13:07:42 2013 (r252944) @@ -323,13 +323,9 @@ do { \ } while (0) /* functions to start/stop udp tunneling */ -/* XXX: Remove the #ifdef after tunneling over IPv6 works also on FreeBSD. */ -#ifdef INET void sctp_over_udp_stop(void); int sctp_over_udp_start(void); -#endif - int sctp_soreceive(struct socket *so, struct sockaddr **psa, struct uio *uio, Modified: stable/9/sys/netinet6/sctp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 7 13:07:42 2013 (r252944) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); extern struct protosw inetsw[]; int -sctp6_input(struct mbuf **i_pak, int *offp, int proto) +sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port) { struct mbuf *m; int iphlen; @@ -84,7 +84,6 @@ sctp6_input(struct mbuf **i_pak, int *of #endif uint32_t mflowid; uint8_t use_mflowid; - uint16_t port = 0; iphlen = *offp; if (SCTP_GET_PKT_VRFID(*i_pak, vrf_id)) { @@ -195,6 +194,12 @@ out: } +int +sctp6_input(struct mbuf **i_pak, int *offp, int proto SCTP_UNUSED) +{ + return (sctp6_input_with_port(i_pak, offp, 0)); +} + static void sctp6_notify_mbuf(struct sctp_inpcb *inp, struct icmp6_hdr *icmp6, struct sctphdr *sh, struct sctp_tcb *stcb, struct sctp_nets *net) Modified: stable/9/sys/netinet6/sctp6_var.h ============================================================================== --- stable/9/sys/netinet6/sctp6_var.h Sun Jul 7 13:04:31 2013 (r252943) +++ stable/9/sys/netinet6/sctp6_var.h Sun Jul 7 13:07:42 2013 (r252944) @@ -42,6 +42,7 @@ SYSCTL_DECL(_net_inet6_sctp6); extern struct pr_usrreqs sctp6_usrreqs; int sctp6_input(struct mbuf **, int *, int); +int sctp6_input_with_port(struct mbuf **, int *, uint16_t); int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, struct proc *); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:09:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 48B7EB23; Sun, 7 Jul 2013 13:09:18 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3982E13AF; Sun, 7 Jul 2013 13:09:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67D9IO4092921; Sun, 7 Jul 2013 13:09:18 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67D9IRY092920; Sun, 7 Jul 2013 13:09:18 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071309.r67D9IRY092920@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:09:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252945 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:09:18 -0000 Author: tuexen Date: Sun Jul 7 13:09:17 2013 New Revision: 252945 URL: http://svnweb.freebsd.org/changeset/base/252945 Log: MFC r243300: Fix the handling of mapped IPv6 addresses in sctp_connectx(). Modified: stable/9/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 13:07:42 2013 (r252944) +++ stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 13:09:17 2013 (r252945) @@ -202,7 +202,6 @@ sctp_connectx(int sd, const struct socka return (-1); } if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)at)->sin6_addr)) { - len += sizeof(struct sockaddr_in); in6_sin6_2_sin((struct sockaddr_in *)cpto, (struct sockaddr_in6 *)at); cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in)); len += sizeof(struct sockaddr_in); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:10:32 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7DEE4D2E; Sun, 7 Jul 2013 13:10:32 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 602EC13BA; Sun, 7 Jul 2013 13:10:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67DAV0W093294; Sun, 7 Jul 2013 13:10:31 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67DAVui093293; Sun, 7 Jul 2013 13:10:31 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071310.r67DAVui093293@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:10:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252946 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:10:32 -0000 Author: tuexen Date: Sun Jul 7 13:10:31 2013 New Revision: 252946 URL: http://svnweb.freebsd.org/changeset/base/252946 Log: MFC r243302: Cleanup the code a bit, which improves the portability. Modified: stable/9/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 13:09:17 2013 (r252945) +++ stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 13:10:31 2013 (r252946) @@ -188,15 +188,18 @@ sctp_connectx(int sd, const struct socka cpto = ((caddr_t)buf + sizeof(int)); /* validate all the addresses and get the size */ for (i = 0; i < addrcnt; i++) { - if (at->sa_family == AF_INET) { + switch (at->sa_family) { + case AF_INET: if (at->sa_len != sizeof(struct sockaddr_in)) { errno = EINVAL; return (-1); } - memcpy(cpto, at, at->sa_len); - cpto = ((caddr_t)cpto + at->sa_len); - len += at->sa_len; - } else if (at->sa_family == AF_INET6) { + memcpy(cpto, at, sizeof(struct sockaddr_in)); + cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in)); + len += sizeof(struct sockaddr_in); + at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in)); + break; + case AF_INET6: if (at->sa_len != sizeof(struct sockaddr_in6)) { errno = EINVAL; return (-1); @@ -206,11 +209,13 @@ sctp_connectx(int sd, const struct socka cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in)); len += sizeof(struct sockaddr_in); } else { - memcpy(cpto, at, at->sa_len); - cpto = ((caddr_t)cpto + at->sa_len); - len += at->sa_len; + memcpy(cpto, at, sizeof(struct sockaddr_in6)); + cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6)); + len += sizeof(struct sockaddr_in6); } - } else { + at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in6)); + break; + default: errno = EINVAL; return (-1); } @@ -219,7 +224,6 @@ sctp_connectx(int sd, const struct socka errno = E2BIG; return (-1); } - at = (struct sockaddr *)((caddr_t)at + at->sa_len); cnt++; } /* do we have any? */ @@ -260,56 +264,57 @@ sctp_bindx(int sd, struct sockaddr *addr errno = EINVAL; return (-1); } - argsz = (sizeof(struct sockaddr_storage) + - sizeof(struct sctp_getaddresses)); - gaddrs = (struct sctp_getaddresses *)calloc(1, argsz); - if (gaddrs == NULL) { - errno = ENOMEM; - return (-1); - } /* First pre-screen the addresses */ sa = addrs; for (i = 0; i < addrcnt; i++) { - if (sa->sa_family == AF_INET) { - if (sa->sa_len != sizeof(struct sockaddr_in)) - goto out_error; + switch (sa->sa_family) { + case AF_INET: + if (sa->sa_len != sizeof(struct sockaddr_in)) { + errno = EINVAL; + return (-1); + } sin = (struct sockaddr_in *)sa; if (sin->sin_port) { /* non-zero port, check or save */ if (sport) { /* Check against our port */ if (sport != sin->sin_port) { - goto out_error; + errno = EINVAL; + return (-1); } } else { /* save off the port */ sport = sin->sin_port; } } - } else if (sa->sa_family == AF_INET6) { - if (sa->sa_len != sizeof(struct sockaddr_in6)) - goto out_error; + break; + case AF_INET6: + if (sa->sa_len != sizeof(struct sockaddr_in6)) { + errno = EINVAL; + return (-1); + } sin6 = (struct sockaddr_in6 *)sa; if (sin6->sin6_port) { /* non-zero port, check or save */ if (sport) { /* Check against our port */ if (sport != sin6->sin6_port) { - goto out_error; + errno = EINVAL; + return (-1); } } else { /* save off the port */ sport = sin6->sin6_port; } } - } else { - /* invalid address family specified */ - goto out_error; + break; + default: + /* Invalid address family specified. */ + errno = EINVAL; + return (-1); } - sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); } - sa = addrs; /* * Now if there was a port mentioned, assure that the first address * has that port to make sure it fails or succeeds correctly. @@ -318,20 +323,14 @@ sctp_bindx(int sd, struct sockaddr *addr sin = (struct sockaddr_in *)sa; sin->sin_port = sport; } + argsz = sizeof(struct sctp_getaddresses) + + sizeof(struct sockaddr_storage); + if ((gaddrs = (struct sctp_getaddresses *)malloc(argsz)) == NULL) { + errno = ENOMEM; + return (-1); + } + sa = addrs; for (i = 0; i < addrcnt; i++) { - if (sa->sa_family == AF_INET) { - if (sa->sa_len != sizeof(struct sockaddr_in)) - goto out_error; - } else if (sa->sa_family == AF_INET6) { - if (sa->sa_len != sizeof(struct sockaddr_in6)) - goto out_error; - } else { - /* invalid address family specified */ - out_error: - free(gaddrs); - errno = EINVAL; - return (-1); - } memset(gaddrs, 0, argsz); gaddrs->sget_assoc_id = 0; memcpy(gaddrs->addr, sa, sa->sa_len); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:13:42 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4B11CE80; Sun, 7 Jul 2013 13:13:42 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2D6B4144D; Sun, 7 Jul 2013 13:13:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67DDg4V095429; Sun, 7 Jul 2013 13:13:42 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67DDfaa095426; Sun, 7 Jul 2013 13:13:41 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071313.r67DDfaa095426@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:13:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252947 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:13:42 -0000 Author: tuexen Date: Sun Jul 7 13:13:41 2013 New Revision: 252947 URL: http://svnweb.freebsd.org/changeset/base/252947 Log: MFC r243516: Remove unused function. Modified: stable/9/sys/netinet/sctp_peeloff.c stable/9/sys/netinet/sctp_peeloff.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_peeloff.c ============================================================================== --- stable/9/sys/netinet/sctp_peeloff.c Sun Jul 7 13:10:31 2013 (r252946) +++ stable/9/sys/netinet/sctp_peeloff.c Sun Jul 7 13:13:41 2013 (r252947) @@ -151,103 +151,3 @@ sctp_do_peeloff(struct socket *head, str return (0); } - - -struct socket * -sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) -{ - struct socket *newso; - struct sctp_inpcb *inp, *n_inp; - struct sctp_tcb *stcb; - - SCTPDBG(SCTP_DEBUG_PEEL1, "SCTP peel-off called\n"); - inp = (struct sctp_inpcb *)head->so_pcb; - if (inp == NULL) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EFAULT); - *error = EFAULT; - return (NULL); - } - stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1); - if (stcb == NULL) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN); - *error = ENOTCONN; - return (NULL); - } - atomic_add_int(&stcb->asoc.refcnt, 1); - SCTP_TCB_UNLOCK(stcb); - CURVNET_SET(head->so_vnet); - newso = sonewconn(head, SS_ISCONNECTED - ); - CURVNET_RESTORE(); - if (newso == NULL) { - SCTPDBG(SCTP_DEBUG_PEEL1, "sctp_peeloff:sonewconn failed\n"); - SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOMEM); - *error = ENOMEM; - atomic_subtract_int(&stcb->asoc.refcnt, 1); - return (NULL); - - } - SCTP_TCB_LOCK(stcb); - atomic_subtract_int(&stcb->asoc.refcnt, 1); - n_inp = (struct sctp_inpcb *)newso->so_pcb; - SOCK_LOCK(head); - n_inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE | - SCTP_PCB_FLAGS_CONNECTED | - SCTP_PCB_FLAGS_IN_TCPPOOL | /* Turn on Blocking IO */ - (SCTP_PCB_COPY_FLAGS & inp->sctp_flags)); - n_inp->sctp_features = inp->sctp_features; - n_inp->sctp_frag_point = inp->sctp_frag_point; - n_inp->sctp_cmt_on_off = inp->sctp_cmt_on_off; - 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) - sctp_free_hmaclist(n_inp->sctp_ep.local_hmacs); - n_inp->sctp_ep.local_hmacs = - sctp_copy_hmaclist(inp->sctp_ep.local_hmacs); - if (n_inp->sctp_ep.local_auth_chunks) - sctp_free_chunklist(n_inp->sctp_ep.local_auth_chunks); - n_inp->sctp_ep.local_auth_chunks = - sctp_copy_chunklist(inp->sctp_ep.local_auth_chunks); - (void)sctp_copy_skeylist(&inp->sctp_ep.shared_keys, - &n_inp->sctp_ep.shared_keys); - - n_inp->sctp_socket = newso; - if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { - sctp_feature_off(n_inp, SCTP_PCB_FLAGS_AUTOCLOSE); - n_inp->sctp_ep.auto_close_time = 0; - sctp_timer_stop(SCTP_TIMER_TYPE_AUTOCLOSE, n_inp, stcb, NULL, - SCTP_FROM_SCTP_PEELOFF + SCTP_LOC_1); - } - /* Turn off any non-blocking semantic. */ - SCTP_CLEAR_SO_NBIO(newso); - newso->so_state |= SS_ISCONNECTED; - /* We remove it right away */ - -#ifdef SCTP_LOCK_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) { - sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); - } -#endif - TAILQ_REMOVE(&head->so_comp, newso, so_list); - head->so_qlen--; - SOCK_UNLOCK(head); - /* - * Now we must move it from one hash table to another and get the - * stcb in the right place. - */ - sctp_move_pcb_and_assoc(inp, n_inp, stcb); - atomic_add_int(&stcb->asoc.refcnt, 1); - SCTP_TCB_UNLOCK(stcb); - /* - * And now the final hack. We move data in the pending side i.e. - * head to the new socket buffer. Let the GRUBBING begin :-0 - */ - sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT); - atomic_subtract_int(&stcb->asoc.refcnt, 1); - return (newso); -} Modified: stable/9/sys/netinet/sctp_peeloff.h ============================================================================== --- stable/9/sys/netinet/sctp_peeloff.h Sun Jul 7 13:10:31 2013 (r252946) +++ stable/9/sys/netinet/sctp_peeloff.h Sun Jul 7 13:13:41 2013 (r252947) @@ -35,18 +35,9 @@ __FBSDID("$FreeBSD$"); #ifndef _NETINET_SCTP_PEELOFF_H_ #define _NETINET_SCTP_PEELOFF_H_ - - - - #if defined(_KERNEL) - int sctp_can_peel_off(struct socket *, sctp_assoc_t); int sctp_do_peeloff(struct socket *, struct socket *, sctp_assoc_t); -struct socket *sctp_get_peeloff(struct socket *, sctp_assoc_t, int *); - - #endif /* _KERNEL */ - -#endif +#endif /* _NETINET_SCTP_PEELOFF_H_ */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:15:56 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E9164FD2; Sun, 7 Jul 2013 13:15:56 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DB8C4146B; Sun, 7 Jul 2013 13:15:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67DFuCV095796; Sun, 7 Jul 2013 13:15:56 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67DFuFn095795; Sun, 7 Jul 2013 13:15:56 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071315.r67DFuFn095795@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:15:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252948 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:15:57 -0000 Author: tuexen Date: Sun Jul 7 13:15:56 2013 New Revision: 252948 URL: http://svnweb.freebsd.org/changeset/base/252948 Log: MFC r243558: Allow shutdown() to be used on fds returned from sctp_peeloff(). 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 Jul 7 13:13:41 2013 (r252947) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 13:15:56 2013 (r252948) @@ -971,7 +971,8 @@ sctp_shutdown(struct socket *so) } SCTP_INP_RLOCK(inp); /* For UDP model this is a invalid call */ - if (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) { + if (!((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { /* Restore the flags that the soshutdown took away. */ SOCKBUF_LOCK(&so->so_rcv); so->so_rcv.sb_state &= ~SBS_CANTRCVMORE; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:18:19 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8ECF227F; Sun, 7 Jul 2013 13:18:19 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 811451493; Sun, 7 Jul 2013 13:18:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67DIJkb096112; Sun, 7 Jul 2013 13:18:19 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67DIJbf096111; Sun, 7 Jul 2013 13:18:19 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071318.r67DIJbf096111@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:18:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252949 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:18:19 -0000 Author: tuexen Date: Sun Jul 7 13:18:19 2013 New Revision: 252949 URL: http://svnweb.freebsd.org/changeset/base/252949 Log: MFC r243564: Find the endpoint for an incoming packet also if the endpoint comes from sctp_peeloff(). Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 13:15:56 2013 (r252948) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 13:18:19 2013 (r252949) @@ -1226,7 +1226,8 @@ sctp_findassociation_ep_addr(struct sctp SCTP_TCB_UNLOCK(locked_tcb); } SCTP_INP_INFO_RLOCK(); - if (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { /*- * Now either this guy is our listener or it's the * connector. If it is the one that issued the connect, then From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 13:20:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 45FF941D; Sun, 7 Jul 2013 13:20:36 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 38D2C15CA; Sun, 7 Jul 2013 13:20:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67DKapb097887; Sun, 7 Jul 2013 13:20:36 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67DKac5097886; Sun, 7 Jul 2013 13:20:36 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071320.r67DKac5097886@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 13:20:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252950 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 13:20:36 -0000 Author: tuexen Date: Sun Jul 7 13:20:35 2013 New Revision: 252950 URL: http://svnweb.freebsd.org/changeset/base/252950 Log: MFC r243565: Add support for sctp_peeloff() also in the front states of the association. Modified: stable/9/sys/netinet/sctp_peeloff.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_peeloff.c ============================================================================== --- stable/9/sys/netinet/sctp_peeloff.c Sun Jul 7 13:18:19 2013 (r252949) +++ stable/9/sys/netinet/sctp_peeloff.c Sun Jul 7 13:20:35 2013 (r252950) @@ -74,9 +74,7 @@ sctp_can_peel_off(struct socket *head, s } state = SCTP_GET_STATE((&stcb->asoc)); if ((state == SCTP_STATE_EMPTY) || - (state == SCTP_STATE_INUSE) || - (state == SCTP_STATE_COOKIE_WAIT) || - (state == SCTP_STATE_COOKIE_ECHOED)) { + (state == SCTP_STATE_INUSE)) { SCTP_TCB_UNLOCK(stcb); SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN); return (ENOTCONN); @@ -105,9 +103,7 @@ sctp_do_peeloff(struct socket *head, str } state = SCTP_GET_STATE((&stcb->asoc)); if ((state == SCTP_STATE_EMPTY) || - (state == SCTP_STATE_INUSE) || - (state == SCTP_STATE_COOKIE_WAIT) || - (state == SCTP_STATE_COOKIE_ECHOED)) { + (state == SCTP_STATE_INUSE)) { SCTP_TCB_UNLOCK(stcb); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN); return (ENOTCONN); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 14:14:46 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 583C5A63; Sun, 7 Jul 2013 14:14:46 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 454011700; Sun, 7 Jul 2013 14:14:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67EEjuU013297; Sun, 7 Jul 2013 14:14:45 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67EEjh1013292; Sun, 7 Jul 2013 14:14:45 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201307071414.r67EEjh1013292@svn.freebsd.org> From: Lawrence Stewart Date: Sun, 7 Jul 2013 14:14:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252951 - in stable/9: share/man/man4 sys/modules/cc sys/modules/cc/cc_cdg sys/netinet/cc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 14:14:46 -0000 Author: lstewart Date: Sun Jul 7 14:14:44 2013 New Revision: 252951 URL: http://svnweb.freebsd.org/changeset/base/252951 Log: MFC r252504: Import an implementation of the CAIA Delay-Gradient (CDG) congestion control algorithm, which is based on the 2011 v0.1 patch release and described in the paper "Revisiting TCP Congestion Control using Delay Gradients" by David Hayes and Grenville Armitage. It is implemented as a kernel module compatible with the modular congestion control framework. CDG is a hybrid congestion control algorithm which reacts to both packet loss and inferred queuing delay. It attempts to operate as a delay-based algorithm where possible, but utilises heuristics to detect loss-based TCP cross traffic and will compete effectively as required. CDG is therefore incrementally deployable and suitable for use on shared networks. In collaboration with: David Hayes and Grenville Armitage Sponsored by: Cisco University Research Program and FreeBSD Foundation Added: stable/9/share/man/man4/cc_cdg.4 - copied unchanged from r252504, head/share/man/man4/cc_cdg.4 stable/9/sys/modules/cc/cc_cdg/ - copied from r252504, head/sys/modules/cc/cc_cdg/ stable/9/sys/netinet/cc/cc_cdg.c - copied unchanged from r252504, head/sys/netinet/cc/cc_cdg.c Modified: stable/9/share/man/man4/Makefile stable/9/sys/modules/cc/Makefile Directory Properties: stable/9/share/man/ (props changed) stable/9/share/man/man4/ (props changed) stable/9/sys/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/share/man/man4/Makefile ============================================================================== --- stable/9/share/man/man4/Makefile Sun Jul 7 13:20:35 2013 (r252950) +++ stable/9/share/man/man4/Makefile Sun Jul 7 14:14:44 2013 (r252951) @@ -76,6 +76,7 @@ MAN= aac.4 \ cardbus.4 \ carp.4 \ cas.4 \ + cc_cdg.4 \ cc_chd.4 \ cc_cubic.4 \ cc_hd.4 \ Copied: stable/9/share/man/man4/cc_cdg.4 (from r252504, head/share/man/man4/cc_cdg.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/share/man/man4/cc_cdg.4 Sun Jul 7 14:14:44 2013 (r252951, copy of r252504, head/share/man/man4/cc_cdg.4) @@ -0,0 +1,155 @@ +.\" +.\" Copyright (c) 2013 Swinburne University of Technology, Melbourne, Australia +.\" 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$ +.\" +.Dd July 2, 2013 +.Dt CC_CDG 4 +.Os +.Sh NAME +.Nm cc_cdg +.Nd CDG Congestion Control Algorithm +.Sh DESCRIPTION +CAIA-Delay Gradient (CDG) is a hybrid congestion control algorithm which reacts +to both packet loss and inferred queuing delay. +It attempts to operate as a delay-based algorithm where possible, but utilises +heuristics to detect loss-based TCP cross traffic and will compete effectively +as required. +CDG is therefore incrementally deployable and suitable for use on shared +networks. +.Pp +During delay-based operation, CDG uses a delay-gradient based probabilistic +backoff mechanism, and will also try to infer non congestion related +packet losses and avoid backing off when they occur. +During loss-based operation, CDG essentially reverts to +.Xr cc_newreno 4 Ns - Ns like +behaviour. +.Pp +CDG switches to loss-based operation when it detects that a configurable number +of consecutive delay-based backoffs have had no measurable effect. +It periodically attempts to return to delay-based operation, but will keep +switching back to loss-based operation as required. +.Sh MIB Variables +The algorithm exposes the following variables in the +.Va net.inet.tcp.cc.cdg +branch of the +.Xr sysctl 3 +MIB: +.Bl -tag -width ".Va exp_backoff_scale" +.It Va version +Current algorithm/implementation version number. +.It Va beta_delay +Delay-based window decrease factor as a percentage (on delay-based backoff, w = +w * beta_delay / 100). +Default is 70. +.It Va beta_loss +Loss-based window decrease factor as a percentage (on loss-based backoff, w = +w * beta_loss / 100). +Default is 50. +.It Va exp_backoff_scale +Scaling parameter for the probabilistic exponential backoff. +Default is 2. +.It Va smoothing_factor +Number of samples used for moving average smoothing (0 means no smoothing). +Default is 8. +.It Va loss_compete_consec_cong +Number of consecutive delay-gradient based congestion episodes which will +trigger loss-based CC compatibility. +Default is 5. +.It Va loss_compete_hold_backoff +Number of consecutive delay-gradient based congestion episodes to hold the +window backoff for loss-based CC compatibility. +Default is 5. +.It Va alpha_inc +If non-zero, this enables an experimental mode where CDG's window increase +factor (alpha) is increased by 1 MSS every +.Va alpha_inc +RTTs during congestion avoidance mode. +(Setting +.Va alpha_inc +to 1 results in the most aggressive growth of the window increase factor over +time. +Use higher +.Va alpha_inc +values for slower growth.) +Default is 0. +.El +.Sh SEE ALSO +.Xr cc_chd 4 , +.Xr cc_cubic 4 , +.Xr cc_hd 4 , +.Xr cc_htcp 4 , +.Xr cc_newreno 4 , +.Xr cc_vegas 4 , +.Xr h_ertt 4 , +.Xr mod_cc 4 , +.Xr tcp 4 , +.Xr khelp 9 , +.Xr mod_cc 9 +.Rs +.%A "D. A. Hayes" +.%A "G. Armitage" +.%T "Revisiting TCP Congestion Control using Delay Gradients" +.%J "Networking 2011 Proceedings, Part II" +.%D "May 2011" +.%P "328-341" +.Re +.Rs +.%A "N. Khademi" +.%A "G. Armitage" +.%T "Minimising RTT across homogeneous 802.11 WLANs with CAIA Delay-Gradient TCP (v0.1)" +.%R "CAIA Technical Report 121113A" +.%D "November 2012" +.%U "http://caia.swin.edu.au/reports/121113A/CAIA-TR-121113A.pdf" +.Re +.Sh ACKNOWLEDGEMENTS +Development and testing of this software were made possible in part by grants +from the FreeBSD Foundation and The Cisco University Research Program Fund, a +corporate advised fund of Silicon Valley Community Foundation. +.Sh HISTORY +The +.Nm +congestion control module first appeared in +.Fx 9.2 . +.Pp +The module was first released in 2011 by David Hayes whilst working on the +NewTCP research project at Swinburne University of Technology's Centre for +Advanced Internet Architectures, Melbourne, Australia. +More details are available at: +.Pp +http://caia.swin.edu.au/urp/newtcp/ +.Sh AUTHORS +.An -nosplit +The +.Nm +congestion control module was written by +.An David Hayes Aq david.hayes@ieee.org . +This manual page was written by +.An Lawrence Stewart Aq lstewart@FreeBSD.org +and +.An Grenville Armitage Aq garmitage@swin.edu.au . +.Sh BUGS +The underlying algorithm and parameter values are still a work in progress and +may not be optimal for some network scenarios. Modified: stable/9/sys/modules/cc/Makefile ============================================================================== --- stable/9/sys/modules/cc/Makefile Sun Jul 7 13:20:35 2013 (r252950) +++ stable/9/sys/modules/cc/Makefile Sun Jul 7 14:14:44 2013 (r252951) @@ -1,6 +1,7 @@ # $FreeBSD$ -SUBDIR= cc_chd \ +SUBDIR= cc_cdg \ + cc_chd \ cc_cubic \ cc_hd \ cc_htcp \ Copied: stable/9/sys/netinet/cc/cc_cdg.c (from r252504, head/sys/netinet/cc/cc_cdg.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/netinet/cc/cc_cdg.c Sun Jul 7 14:14:44 2013 (r252951, copy of r252504, head/sys/netinet/cc/cc_cdg.c) @@ -0,0 +1,695 @@ +/*- + * Copyright (c) 2009-2013 + * Swinburne University of Technology, Melbourne, Australia + * All rights reserved. + * + * This software was developed at the Centre for Advanced Internet + * Architectures, Swinburne University of Technology, by David Hayes, made + * possible in part by a gift from The Cisco University Research Program Fund, + * a corporate advised fund of Silicon Valley Community Foundation. Development + * and testing were further assisted by a grant from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 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. + */ + +/* + * CAIA Delay-Gradient (CDG) congestion control algorithm + * + * An implemention of the delay-gradient congestion control algorithm proposed + * in the following paper: + * + * D. A. Hayes and G. Armitage, "Revisiting TCP Congestion Control using Delay + * Gradients", in IFIP Networking, Valencia, Spain, 9-13 May 2011. + * + * Developed as part of the NewTCP research project at Swinburne University of + * Technology's Centre for Advanced Internet Architectures, Melbourne, + * Australia. More details are available at: + * http://caia.swin.edu.au/urp/newtcp/ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +#define CDG_VERSION "0.1" + +#define CAST_PTR_INT(X) (*((int*)(X))) + +#ifndef VIMAGE +#define vnet_sysctl_handle_uint(oidp, arg1, arg2, req) \ + sysctl_handle_int(oidp, arg1, arg2, req) +#endif + +/* Private delay-gradient induced congestion control signal. */ +#define CC_CDG_DELAY 0x01000000 + +/* NewReno window deflation factor on loss (as a percentage). */ +#define RENO_BETA 50 + +/* Queue states. */ +#define CDG_Q_EMPTY 1 +#define CDG_Q_RISING 2 +#define CDG_Q_FALLING 3 +#define CDG_Q_FULL 4 +#define CDG_Q_UNKNOWN 9999 + +/* Number of bit shifts used in probexp lookup table. */ +#define EXP_PREC 15 + +/* Largest gradient represented in probexp lookup table. */ +#define MAXGRAD 5 + +/* + * Delay Precision Enhance - number of bit shifts used for qtrend related + * integer arithmetic precision. + */ +#define D_P_E 7 + +struct qdiff_sample { + long qdiff; + STAILQ_ENTRY(qdiff_sample) qdiff_lnk; +}; + +struct cdg { + long max_qtrend; + long min_qtrend; + STAILQ_HEAD(minrtts_head, qdiff_sample) qdiffmin_q; + STAILQ_HEAD(maxrtts_head, qdiff_sample) qdiffmax_q; + long window_incr; + /* rttcount for window increase when in congestion avoidance */ + long rtt_count; + /* maximum measured rtt within an rtt period */ + int maxrtt_in_rtt; + /* maximum measured rtt within prev rtt period */ + int maxrtt_in_prevrtt; + /* minimum measured rtt within an rtt period */ + int minrtt_in_rtt; + /* minimum measured rtt within prev rtt period */ + int minrtt_in_prevrtt; + /* consecutive congestion episode counter */ + uint32_t consec_cong_cnt; + /* when tracking a new reno type loss window */ + uint32_t shadow_w; + /* maximum number of samples in the moving average queue */ + int sample_q_size; + /* number of samples in the moving average queue */ + int num_samples; + /* estimate of the queue state of the path */ + int queue_state; +}; + +/* + * Lookup table for: + * (1 - exp(-x)) << EXP_PREC, where x = [0,MAXGRAD] in 2^-7 increments + * + * Note: probexp[0] is set to 10 (not 0) as a safety for very low increase + * gradients. + */ +static const int probexp[641] = { + 10,255,508,759,1008,1255,1501,1744,1985,2225,2463,2698,2932,3165,3395,3624, + 3850,4075,4299,4520,4740,4958,5175,5389,5602,5814,6024,6232,6438,6643,6846, + 7048,7248,7447,7644,7839,8033,8226,8417,8606,8794,8981,9166,9350,9532,9713, + 9892,10070,10247,10422,10596,10769,10940,11110,11278,11445,11611,11776,11939, + 12101,12262,12422,12580,12737,12893,13048,13201,13354,13505,13655,13803,13951, + 14097,14243,14387,14530,14672,14813,14952,15091,15229,15365,15500,15635,15768, + 15900,16032,16162,16291,16419,16547,16673,16798,16922,17046,17168,17289,17410, + 17529,17648,17766,17882,17998,18113,18227,18340,18453,18564,18675,18784,18893, + 19001,19108,19215,19320,19425,19529,19632,19734,19835,19936,20036,20135,20233, + 20331,20427,20523,20619,20713,20807,20900,20993,21084,21175,21265,21355,21444, + 21532,21619,21706,21792,21878,21962,22046,22130,22213,22295,22376,22457,22537, + 22617,22696,22774,22852,22929,23006,23082,23157,23232,23306,23380,23453,23525, + 23597,23669,23739,23810,23879,23949,24017,24085,24153,24220,24286,24352,24418, + 24483,24547,24611,24675,24738,24800,24862,24924,24985,25045,25106,25165,25224, + 25283,25341,25399,25456,25513,25570,25626,25681,25737,25791,25846,25899,25953, + 26006,26059,26111,26163,26214,26265,26316,26366,26416,26465,26514,26563,26611, + 26659,26707,26754,26801,26847,26893,26939,26984,27029,27074,27118,27162,27206, + 27249,27292,27335,27377,27419,27460,27502,27543,27583,27624,27664,27703,27743, + 27782,27821,27859,27897,27935,27973,28010,28047,28084,28121,28157,28193,28228, + 28263,28299,28333,28368,28402,28436,28470,28503,28536,28569,28602,28634,28667, + 28699,28730,28762,28793,28824,28854,28885,28915,28945,28975,29004,29034,29063, + 29092,29120,29149,29177,29205,29232,29260,29287,29314,29341,29368,29394,29421, + 29447,29472,29498,29524,29549,29574,29599,29623,29648,29672,29696,29720,29744, + 29767,29791,29814,29837,29860,29882,29905,29927,29949,29971,29993,30014,30036, + 30057,30078,30099,30120,30141,30161,30181,30201,30221,30241,30261,30280,30300, + 30319,30338,30357,30376,30394,30413,30431,30449,30467,30485,30503,30521,30538, + 30555,30573,30590,30607,30624,30640,30657,30673,30690,30706,30722,30738,30753, + 30769,30785,30800,30815,30831,30846,30861,30876,30890,30905,30919,30934,30948, + 30962,30976,30990,31004,31018,31031,31045,31058,31072,31085,31098,31111,31124, + 31137,31149,31162,31174,31187,31199,31211,31223,31235,31247,31259,31271,31283, + 31294,31306,31317,31328,31339,31351,31362,31373,31383,31394,31405,31416,31426, + 31436,31447,31457,31467,31477,31487,31497,31507,31517,31527,31537,31546,31556, + 31565,31574,31584,31593,31602,31611,31620,31629,31638,31647,31655,31664,31673, + 31681,31690,31698,31706,31715,31723,31731,31739,31747,31755,31763,31771,31778, + 31786,31794,31801,31809,31816,31824,31831,31838,31846,31853,31860,31867,31874, + 31881,31888,31895,31902,31908,31915,31922,31928,31935,31941,31948,31954,31960, + 31967,31973,31979,31985,31991,31997,32003,32009,32015,32021,32027,32033,32038, + 32044,32050,32055,32061,32066,32072,32077,32083,32088,32093,32098,32104,32109, + 32114,32119,32124,32129,32134,32139,32144,32149,32154,32158,32163,32168,32173, + 32177,32182,32186,32191,32195,32200,32204,32209,32213,32217,32222,32226,32230, + 32234,32238,32242,32247,32251,32255,32259,32263,32267,32270,32274,32278,32282, + 32286,32290,32293,32297,32301,32304,32308,32311,32315,32318,32322,32325,32329, + 32332,32336,32339,32342,32346,32349,32352,32356,32359,32362,32365,32368,32371, + 32374,32377,32381,32384,32387,32389,32392,32395,32398,32401,32404,32407,32410, + 32412,32415,32418,32421,32423,32426,32429,32431,32434,32437,32439,32442,32444, + 32447,32449,32452,32454,32457,32459,32461,32464,32466,32469,32471,32473,32476, + 32478,32480,32482,32485,32487,32489,32491,32493,32495,32497,32500,32502,32504, + 32506,32508,32510,32512,32514,32516,32518,32520,32522,32524,32526,32527,32529, + 32531,32533,32535,32537,32538,32540,32542,32544,32545,32547}; + +static uma_zone_t qdiffsample_zone; + +static MALLOC_DEFINE(M_CDG, "cdg data", + "Per connection data required for the CDG congestion control algorithm"); + +static int ertt_id; + +static VNET_DEFINE(uint32_t, cdg_alpha_inc); +static VNET_DEFINE(uint32_t, cdg_beta_delay); +static VNET_DEFINE(uint32_t, cdg_beta_loss); +static VNET_DEFINE(uint32_t, cdg_smoothing_factor); +static VNET_DEFINE(uint32_t, cdg_exp_backoff_scale); +static VNET_DEFINE(uint32_t, cdg_consec_cong); +static VNET_DEFINE(uint32_t, cdg_hold_backoff); +#define V_cdg_alpha_inc VNET(cdg_alpha_inc) +#define V_cdg_beta_delay VNET(cdg_beta_delay) +#define V_cdg_beta_loss VNET(cdg_beta_loss) +#define V_cdg_smoothing_factor VNET(cdg_smoothing_factor) +#define V_cdg_exp_backoff_scale VNET(cdg_exp_backoff_scale) +#define V_cdg_consec_cong VNET(cdg_consec_cong) +#define V_cdg_hold_backoff VNET(cdg_hold_backoff) + +/* Function prototypes. */ +static int cdg_mod_init(void); +static void cdg_conn_init(struct cc_var *ccv); +static int cdg_cb_init(struct cc_var *ccv); +static void cdg_cb_destroy(struct cc_var *ccv); +static void cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type); +static void cdg_ack_received(struct cc_var *ccv, uint16_t ack_type); + +struct cc_algo cdg_cc_algo = { + .name = "cdg", + .mod_init = cdg_mod_init, + .ack_received = cdg_ack_received, + .cb_destroy = cdg_cb_destroy, + .cb_init = cdg_cb_init, + .conn_init = cdg_conn_init, + .cong_signal = cdg_cong_signal +}; + +/* Vnet created and being initialised. */ +static void +cdg_init_vnet(const void *unused __unused) +{ + + V_cdg_alpha_inc = 0; + V_cdg_beta_delay = 70; + V_cdg_beta_loss = 50; + V_cdg_smoothing_factor = 8; + V_cdg_exp_backoff_scale = 3; + V_cdg_consec_cong = 5; + V_cdg_hold_backoff = 5; +} + +static int +cdg_mod_init(void) +{ + VNET_ITERATOR_DECL(v); + + ertt_id = khelp_get_id("ertt"); + if (ertt_id <= 0) + return (EINVAL); + + qdiffsample_zone = uma_zcreate("cdg_qdiffsample", + sizeof(struct qdiff_sample), NULL, NULL, NULL, NULL, 0, 0); + + VNET_LIST_RLOCK(); + VNET_FOREACH(v) { + CURVNET_SET(v); + cdg_init_vnet(NULL); + CURVNET_RESTORE(); + } + VNET_LIST_RUNLOCK(); + + cdg_cc_algo.post_recovery = newreno_cc_algo.post_recovery; + cdg_cc_algo.after_idle = newreno_cc_algo.after_idle; + + return (0); +} + +static int +cdg_cb_init(struct cc_var *ccv) +{ + struct cdg *cdg_data; + + cdg_data = malloc(sizeof(struct cdg), M_CDG, M_NOWAIT); + if (cdg_data == NULL) + return (ENOMEM); + + cdg_data->shadow_w = 0; + cdg_data->max_qtrend = 0; + cdg_data->min_qtrend = 0; + cdg_data->queue_state = CDG_Q_UNKNOWN; + cdg_data->maxrtt_in_rtt = 0; + cdg_data->maxrtt_in_prevrtt = 0; + cdg_data->minrtt_in_rtt = INT_MAX; + cdg_data->minrtt_in_prevrtt = 0; + cdg_data->window_incr = 0; + cdg_data->rtt_count = 0; + cdg_data->consec_cong_cnt = 0; + cdg_data->sample_q_size = V_cdg_smoothing_factor; + cdg_data->num_samples = 0; + STAILQ_INIT(&cdg_data->qdiffmin_q); + STAILQ_INIT(&cdg_data->qdiffmax_q); + + ccv->cc_data = cdg_data; + + return (0); +} + +static void +cdg_conn_init(struct cc_var *ccv) +{ + struct cdg *cdg_data = ccv->cc_data; + + /* + * Initialise the shadow_cwnd in case we are competing with loss based + * flows from the start + */ + cdg_data->shadow_w = CCV(ccv, snd_cwnd); +} + +static void +cdg_cb_destroy(struct cc_var *ccv) +{ + struct cdg *cdg_data; + struct qdiff_sample *qds, *qds_n; + + cdg_data = ccv->cc_data; + + qds = STAILQ_FIRST(&cdg_data->qdiffmin_q); + while (qds != NULL) { + qds_n = STAILQ_NEXT(qds, qdiff_lnk); + uma_zfree(qdiffsample_zone,qds); + qds = qds_n; + } + + qds = STAILQ_FIRST(&cdg_data->qdiffmax_q); + while (qds != NULL) { + qds_n = STAILQ_NEXT(qds, qdiff_lnk); + uma_zfree(qdiffsample_zone,qds); + qds = qds_n; + } + + free(ccv->cc_data, M_CDG); +} + +static int +cdg_beta_handler(SYSCTL_HANDLER_ARGS) +{ + + if (req->newptr != NULL && + (CAST_PTR_INT(req->newptr) == 0 || CAST_PTR_INT(req->newptr) > 100)) + return (EINVAL); + + return (vnet_sysctl_handle_uint(oidp, arg1, arg2, req)); +} + +static int +cdg_exp_backoff_scale_handler(SYSCTL_HANDLER_ARGS) +{ + + if (req->newptr != NULL && CAST_PTR_INT(req->newptr) < 1) + return (EINVAL); + + return (vnet_sysctl_handle_uint(oidp, arg1, arg2, req)); +} + +static inline unsigned long +cdg_window_decrease(struct cc_var *ccv, unsigned long owin, unsigned int beta) +{ + + return ((ulmin(CCV(ccv, snd_wnd), owin) * beta) / 100); +} + +/* + * Window increase function + * This window increase function is independent of the initial window size + * to ensure small window flows are not discriminated against (i.e. fairness). + * It increases at 1pkt/rtt like Reno for alpha_inc rtts, and then 2pkts/rtt for + * the next alpha_inc rtts, etc. + */ +static void +cdg_window_increase(struct cc_var *ccv, int new_measurement) +{ + struct cdg *cdg_data; + int incr, s_w_incr; + + cdg_data = ccv->cc_data; + incr = s_w_incr = 0; + + if (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh)) { + /* Slow start. */ + incr = CCV(ccv, t_maxseg); + s_w_incr = incr; + cdg_data->window_incr = cdg_data->rtt_count = 0; + } else { + /* Congestion avoidance. */ + if (new_measurement) { + s_w_incr = CCV(ccv, t_maxseg); + if (V_cdg_alpha_inc == 0) { + incr = CCV(ccv, t_maxseg); + } else { + if (++cdg_data->rtt_count >= V_cdg_alpha_inc) { + cdg_data->window_incr++; + cdg_data->rtt_count = 0; + } + incr = CCV(ccv, t_maxseg) * + cdg_data->window_incr; + } + } + } + + if (cdg_data->shadow_w > 0) + cdg_data->shadow_w = ulmin(cdg_data->shadow_w + s_w_incr, + TCP_MAXWIN << CCV(ccv, snd_scale)); + + CCV(ccv, snd_cwnd) = ulmin(CCV(ccv, snd_cwnd) + incr, + TCP_MAXWIN << CCV(ccv, snd_scale)); +} + +static void +cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type) +{ + struct cdg *cdg_data = ccv->cc_data; + + switch(signal_type) { + case CC_CDG_DELAY: + CCV(ccv, snd_ssthresh) = cdg_window_decrease(ccv, + CCV(ccv, snd_cwnd), V_cdg_beta_delay); + CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); + CCV(ccv, snd_recover) = CCV(ccv, snd_max); + cdg_data->window_incr = cdg_data->rtt_count = 0; + ENTER_CONGRECOVERY(CCV(ccv, t_flags)); + break; + case CC_NDUPACK: + /* + * If already responding to congestion OR we have guessed no + * queue in the path is full. + */ + if (IN_CONGRECOVERY(CCV(ccv, t_flags)) || + cdg_data->queue_state < CDG_Q_FULL) { + CCV(ccv, snd_ssthresh) = CCV(ccv, snd_cwnd); + CCV(ccv, snd_recover) = CCV(ccv, snd_max); + } else { + /* + * Loss is likely to be congestion related. We have + * inferred a queue full state, so have shadow window + * react to loss as NewReno would. + */ + if (cdg_data->shadow_w > 0) + cdg_data->shadow_w = cdg_window_decrease(ccv, + cdg_data->shadow_w, RENO_BETA); + + CCV(ccv, snd_ssthresh) = ulmax(cdg_data->shadow_w, + cdg_window_decrease(ccv, CCV(ccv, snd_cwnd), + V_cdg_beta_loss)); + + cdg_data->window_incr = cdg_data->rtt_count = 0; + } + ENTER_RECOVERY(CCV(ccv, t_flags)); + break; + default: + newreno_cc_algo.cong_signal(ccv, signal_type); + break; + } +} + +/* + * Using a negative exponential probabilistic backoff so that sources with + * varying RTTs which share the same link will, on average, have the same + * probability of backoff over time. + * + * Prob_backoff = 1 - exp(-qtrend / V_cdg_exp_backoff_scale), where + * V_cdg_exp_backoff_scale is the average qtrend for the exponential backoff. + */ +static inline int +prob_backoff(long qtrend) +{ + int backoff, idx, p; + + backoff = (qtrend > ((MAXGRAD * V_cdg_exp_backoff_scale) << D_P_E)); + + if (!backoff) { + if (V_cdg_exp_backoff_scale > 1) + idx = (qtrend + V_cdg_exp_backoff_scale / 2) / + V_cdg_exp_backoff_scale; + else + idx = qtrend; + + /* Backoff probability proportional to rate of queue growth. */ + p = (INT_MAX / (1 << EXP_PREC)) * probexp[idx]; + backoff = (random() < p); + } + + return (backoff); +} + +static inline void +calc_moving_average(struct cdg *cdg_data, long qdiff_max, long qdiff_min) +{ + struct qdiff_sample *qds; + + ++cdg_data->num_samples; + if (cdg_data->num_samples > cdg_data->sample_q_size) { + /* Minimum RTT. */ + qds = STAILQ_FIRST(&cdg_data->qdiffmin_q); + cdg_data->min_qtrend = cdg_data->min_qtrend + + (qdiff_min - qds->qdiff) / cdg_data->sample_q_size; + STAILQ_REMOVE_HEAD(&cdg_data->qdiffmin_q, qdiff_lnk); + qds->qdiff = qdiff_min; + STAILQ_INSERT_TAIL(&cdg_data->qdiffmin_q, qds, qdiff_lnk); + + /* Maximum RTT. */ + qds = STAILQ_FIRST(&cdg_data->qdiffmax_q); + cdg_data->max_qtrend = cdg_data->max_qtrend + + (qdiff_max - qds->qdiff) / cdg_data->sample_q_size; + STAILQ_REMOVE_HEAD(&cdg_data->qdiffmax_q, qdiff_lnk); + qds->qdiff = qdiff_max; + STAILQ_INSERT_TAIL(&cdg_data->qdiffmax_q, qds, qdiff_lnk); + --cdg_data->num_samples; + } else { + qds = uma_zalloc(qdiffsample_zone, M_NOWAIT); + if (qds != NULL) { + cdg_data->min_qtrend = cdg_data->min_qtrend + + qdiff_min / cdg_data->sample_q_size; + qds->qdiff = qdiff_min; + STAILQ_INSERT_TAIL(&cdg_data->qdiffmin_q, qds, + qdiff_lnk); + } + + qds = uma_zalloc(qdiffsample_zone, M_NOWAIT); + if (qds) { + cdg_data->max_qtrend = cdg_data->max_qtrend + + qdiff_max / cdg_data->sample_q_size; + qds->qdiff = qdiff_max; + STAILQ_INSERT_TAIL(&cdg_data->qdiffmax_q, qds, + qdiff_lnk); + } + } +} + +static void +cdg_ack_received(struct cc_var *ccv, uint16_t ack_type) +{ + struct cdg *cdg_data; + struct ertt *e_t; + long qdiff_max, qdiff_min; + int congestion, new_measurement, slowstart; + + cdg_data = ccv->cc_data; + e_t = (struct ertt *)khelp_get_osd(CCV(ccv, osd), ertt_id); + new_measurement = e_t->flags & ERTT_NEW_MEASUREMENT; + congestion = 0; + cdg_data->maxrtt_in_rtt = imax(e_t->rtt, cdg_data->maxrtt_in_rtt); + cdg_data->minrtt_in_rtt = imin(e_t->rtt, cdg_data->minrtt_in_rtt); + + if (new_measurement) { + slowstart = (CCV(ccv, snd_cwnd) <= CCV(ccv, snd_ssthresh)); + /* + * Update smoothed gradient measurements. Since we are only + * using one measurement per RTT, use max or min rtt_in_rtt. + * This is also less noisy than a sample RTT measurement. Max + * RTT measurements can have trouble due to OS issues. + */ + if (cdg_data->maxrtt_in_prevrtt) { + qdiff_max = ((long)(cdg_data->maxrtt_in_rtt - + cdg_data->maxrtt_in_prevrtt) << D_P_E ); + qdiff_min = ((long)(cdg_data->minrtt_in_rtt - + cdg_data->minrtt_in_prevrtt) << D_P_E ); + + calc_moving_average(cdg_data, qdiff_max, qdiff_min); + + /* Probabilistic backoff with respect to gradient. */ + if (slowstart && qdiff_min > 0) + congestion = prob_backoff(qdiff_min); + else if (cdg_data->min_qtrend > 0) + congestion = prob_backoff(cdg_data->min_qtrend); + else if (slowstart && qdiff_max > 0) + congestion = prob_backoff(qdiff_max); + else if (cdg_data->max_qtrend > 0) + congestion = prob_backoff(cdg_data->max_qtrend); + + /* Update estimate of queue state. */ + if (cdg_data->min_qtrend > 0 && + cdg_data->max_qtrend <= 0) { + cdg_data->queue_state = CDG_Q_FULL; + } else if (cdg_data->min_qtrend >= 0 && + cdg_data->max_qtrend < 0) { + cdg_data->queue_state = CDG_Q_EMPTY; + cdg_data->shadow_w = 0; + } else if (cdg_data->min_qtrend > 0 && + cdg_data->max_qtrend > 0) { + cdg_data->queue_state = CDG_Q_RISING; + } else if (cdg_data->min_qtrend < 0 && + cdg_data->max_qtrend < 0) { + cdg_data->queue_state = CDG_Q_FALLING; + } + + if (cdg_data->min_qtrend < 0 || + cdg_data->max_qtrend < 0) + cdg_data->consec_cong_cnt = 0; + } + + cdg_data->minrtt_in_prevrtt = cdg_data->minrtt_in_rtt; + cdg_data->minrtt_in_rtt = INT_MAX; + cdg_data->maxrtt_in_prevrtt = cdg_data->maxrtt_in_rtt; + cdg_data->maxrtt_in_rtt = 0; + e_t->flags &= ~ERTT_NEW_MEASUREMENT; + } + + if (congestion) { + cdg_data->consec_cong_cnt++; + if (!IN_RECOVERY(CCV(ccv, t_flags))) { + if (cdg_data->consec_cong_cnt <= V_cdg_consec_cong) + cdg_cong_signal(ccv, CC_CDG_DELAY); + else + /* + * We have been backing off but the queue is not + * falling. Assume we are competing with + * loss-based flows and don't back off for the + * next V_cdg_hold_backoff RTT periods. + */ + if (cdg_data->consec_cong_cnt >= + V_cdg_consec_cong + V_cdg_hold_backoff) + cdg_data->consec_cong_cnt = 0; + + /* Won't see effect until 2nd RTT. */ + cdg_data->maxrtt_in_prevrtt = 0; + /* + * Resync shadow window in case we are competing with a + * loss based flow + */ + cdg_data->shadow_w = ulmax(CCV(ccv, snd_cwnd), + cdg_data->shadow_w); + } + } else if (ack_type == CC_ACK) + cdg_window_increase(ccv, new_measurement); +} + +/* When a vnet is created and being initialised, init the per-stack CDG vars. */ +VNET_SYSINIT(cdg_init_vnet, SI_SUB_PROTO_BEGIN, SI_ORDER_FIRST, + cdg_init_vnet, NULL); + +SYSCTL_DECL(_net_inet_tcp_cc_cdg); +SYSCTL_NODE(_net_inet_tcp_cc, OID_AUTO, cdg, CTLFLAG_RW, NULL, + "CAIA delay-gradient congestion control related settings"); + +SYSCTL_STRING(_net_inet_tcp_cc_cdg, OID_AUTO, version, + CTLFLAG_RD, CDG_VERSION, sizeof(CDG_VERSION) - 1, + "Current algorithm/implementation version number"); + +SYSCTL_VNET_UINT(_net_inet_tcp_cc_cdg, OID_AUTO, alpha_inc, + CTLFLAG_RW, &VNET_NAME(cdg_alpha_inc), 0, + "Increment the window increase factor alpha by 1 MSS segment every " + "alpha_inc RTTs during congestion avoidance mode."); + +SYSCTL_VNET_PROC(_net_inet_tcp_cc_cdg, OID_AUTO, beta_delay, + CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(cdg_beta_delay), 70, + &cdg_beta_handler, "IU", + "Delay-based window decrease factor as a percentage " + "(on delay-based backoff, w = w * beta_delay / 100)"); + +SYSCTL_VNET_PROC(_net_inet_tcp_cc_cdg, OID_AUTO, beta_loss, + CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(cdg_beta_loss), 50, + &cdg_beta_handler, "IU", + "Loss-based window decrease factor as a percentage " + "(on loss-based backoff, w = w * beta_loss / 100)"); + +SYSCTL_VNET_PROC(_net_inet_tcp_cc_cdg, OID_AUTO, exp_backoff_scale, + CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(cdg_exp_backoff_scale), 2, + &cdg_exp_backoff_scale_handler, "IU", + "Scaling parameter for the probabilistic exponential backoff"); + +SYSCTL_VNET_UINT(_net_inet_tcp_cc_cdg, OID_AUTO, smoothing_factor, + CTLFLAG_RW, &VNET_NAME(cdg_smoothing_factor), 8, + "Number of samples used for moving average smoothing (0 = no smoothing)"); + +SYSCTL_VNET_UINT(_net_inet_tcp_cc_cdg, OID_AUTO, loss_compete_consec_cong, + CTLFLAG_RW, &VNET_NAME(cdg_consec_cong), 5, + "Number of consecutive delay-gradient based congestion episodes which will " + "trigger loss based CC compatibility"); + +SYSCTL_VNET_UINT(_net_inet_tcp_cc_cdg, OID_AUTO, loss_compete_hold_backoff, + CTLFLAG_RW, &VNET_NAME(cdg_hold_backoff), 5, + "Number of consecutive delay-gradient based congestion episodes to hold " + "the window backoff for loss based CC compatibility"); + +DECLARE_CC_MODULE(cdg, &cdg_cc_algo); + +MODULE_DEPEND(cdg, ertt, 1, 1, 1); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:18:11 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 19E80519; Sun, 7 Jul 2013 15:18:11 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F092B1855; Sun, 7 Jul 2013 15:18:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67FIAuT031442; Sun, 7 Jul 2013 15:18:10 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67FIA8o031440; Sun, 7 Jul 2013 15:18:10 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071518.r67FIA8o031440@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:18:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252953 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:18:11 -0000 Author: tuexen Date: Sun Jul 7 15:18:09 2013 New Revision: 252953 URL: http://svnweb.freebsd.org/changeset/base/252953 Log: MFC r244021: Ensure that the padding of the last parameter of an INIT chunk is not included in the chunk length as required by RFC 4960. While there, cleanup sctp_send_initiate(). Modified: stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_output.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 14:20:00 2013 (r252952) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 15:18:09 2013 (r252953) @@ -1940,27 +1940,27 @@ sctp_is_address_in_scope(struct sctp_ifa } static struct mbuf * -sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa) +sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len) { struct sctp_paramhdr *parmh; struct mbuf *mret; - int len; + uint16_t plen; switch (ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - len = sizeof(struct sctp_ipv4addr_param); + plen = (uint16_t) sizeof(struct sctp_ipv4addr_param); break; #endif #ifdef INET6 case AF_INET6: - len = sizeof(struct sctp_ipv6addr_param); + plen = (uint16_t) sizeof(struct sctp_ipv6addr_param); break; #endif default: return (m); } - if (M_TRAILINGSPACE(m) >= len) { + if (M_TRAILINGSPACE(m) >= plen) { /* easy side we just drop it on the end */ parmh = (struct sctp_paramhdr *)(SCTP_BUF_AT(m, SCTP_BUF_LEN(m))); mret = m; @@ -1970,7 +1970,7 @@ sctp_add_addr_to_mbuf(struct mbuf *m, st while (SCTP_BUF_NEXT(mret) != NULL) { mret = SCTP_BUF_NEXT(mret); } - SCTP_BUF_NEXT(mret) = sctp_get_mbuf_for_msg(len, 0, M_DONTWAIT, 1, MT_DATA); + SCTP_BUF_NEXT(mret) = sctp_get_mbuf_for_msg(plen, 0, M_DONTWAIT, 1, MT_DATA); if (SCTP_BUF_NEXT(mret) == NULL) { /* We are hosed, can't add more addresses */ return (m); @@ -1989,9 +1989,9 @@ sctp_add_addr_to_mbuf(struct mbuf *m, st sin = (struct sockaddr_in *)&ifa->address.sin; ipv4p = (struct sctp_ipv4addr_param *)parmh; parmh->param_type = htons(SCTP_IPV4_ADDRESS); - parmh->param_length = htons(len); + parmh->param_length = htons(plen); ipv4p->addr = sin->sin_addr.s_addr; - SCTP_BUF_LEN(mret) += len; + SCTP_BUF_LEN(mret) += plen; break; } #endif @@ -2004,18 +2004,21 @@ sctp_add_addr_to_mbuf(struct mbuf *m, st sin6 = (struct sockaddr_in6 *)&ifa->address.sin6; ipv6p = (struct sctp_ipv6addr_param *)parmh; parmh->param_type = htons(SCTP_IPV6_ADDRESS); - parmh->param_length = htons(len); + parmh->param_length = htons(plen); memcpy(ipv6p->addr, &sin6->sin6_addr, sizeof(ipv6p->addr)); /* clear embedded scope in the address */ in6_clearscope((struct in6_addr *)ipv6p->addr); - SCTP_BUF_LEN(mret) += len; + SCTP_BUF_LEN(mret) += plen; break; } #endif default: return (m); } + if (len != NULL) { + *len += plen; + } return (mret); } @@ -2023,7 +2026,8 @@ sctp_add_addr_to_mbuf(struct mbuf *m, st struct mbuf * sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_scoping *scope, - struct mbuf *m_at, int cnt_inits_to) + struct mbuf *m_at, int cnt_inits_to, + uint16_t * padding_len, uint16_t * chunk_len) { struct sctp_vrf *vrf = NULL; int cnt, limit_out = 0, total_count; @@ -2103,7 +2107,15 @@ skip_count: scope->site_scope, 0) == 0) { continue; } - m_at = sctp_add_addr_to_mbuf(m_at, sctp_ifap); + if ((chunk_len != NULL) && + (padding_len != NULL) && + (*padding_len > 0)) { + memset(mtod(m_at, caddr_t)+*chunk_len, 0, *padding_len); + SCTP_BUF_LEN(m_at) += *padding_len; + *chunk_len += *padding_len; + *padding_len = 0; + } + m_at = sctp_add_addr_to_mbuf(m_at, sctp_ifap, chunk_len); if (limit_out) { cnt++; total_count++; @@ -2178,7 +2190,15 @@ skip_count: scope->site_scope, 0) == 0) { continue; } - m_at = sctp_add_addr_to_mbuf(m_at, laddr->ifa); + if ((chunk_len != NULL) && + (padding_len != NULL) && + (*padding_len > 0)) { + memset(mtod(m_at, caddr_t)+*chunk_len, 0, *padding_len); + SCTP_BUF_LEN(m_at) += *padding_len; + *chunk_len += *padding_len; + *padding_len = 0; + } + m_at = sctp_add_addr_to_mbuf(m_at, laddr->ifa, chunk_len); cnt++; if (cnt >= SCTP_ADDRESS_LIMIT) { break; @@ -4575,21 +4595,19 @@ sctp_send_initiate(struct sctp_inpcb *in #endif ) { - struct mbuf *m, *m_at, *mp_last; + struct sctp_scoping scp; + struct mbuf *m; struct sctp_nets *net; struct sctp_init_chunk *init; struct sctp_supported_addr_param *sup_addr; struct sctp_adaptation_layer_indication *ali; - struct sctp_ecn_supported_param *ecn; - struct sctp_prsctp_supported_param *prsctp; struct sctp_supported_chunk_types_param *pr_supported; + struct sctp_paramhdr *ph; int cnt_inits_to = 0; - int padval, ret; - int num_ext; - int p_len; + int ret; + uint16_t num_ext, chunk_len, padding_len, parameter_len; /* INIT's always go to the primary (and usually ONLY address) */ - mp_last = NULL; net = stcb->asoc.primary_destination; if (net == NULL) { net = TAILQ_FIRST(&stcb->asoc.nets); @@ -4606,15 +4624,12 @@ sctp_send_initiate(struct sctp_inpcb *in } SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT\n"); #ifdef INET6 - if (((struct sockaddr *)&(net->ro._l_addr))->sa_family == AF_INET6) { + if (net->ro._l_addr.sa.sa_family == AF_INET6) { /* * special hook, if we are sending to link local it will not * show up in our private address count. */ - struct sockaddr_in6 *sin6l; - - sin6l = &net->ro._l_addr.sin6; - if (IN6_IS_ADDR_LINKLOCAL(&sin6l->sin6_addr)) + if (IN6_IS_ADDR_LINKLOCAL(&net->ro._l_addr.sin6.sin6_addr)) cnt_inits_to = 1; } #endif @@ -4632,14 +4647,15 @@ sctp_send_initiate(struct sctp_inpcb *in SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - mbuf?\n"); return; } - SCTP_BUF_LEN(m) = sizeof(struct sctp_init_chunk); + chunk_len = (uint16_t) sizeof(struct sctp_init_chunk); + padding_len = 0; /* * assume peer supports asconf in order to be able to queue local * address changes while an INIT is in flight and before the assoc * is established. */ stcb->asoc.peer_supports_asconf = 1; - /* Now lets put the SCTP header in place */ + /* Now lets put the chunk header in place */ init = mtod(m, struct sctp_init_chunk *); /* now the chunk header */ init->ch.chunk_type = SCTP_INITIATION; @@ -4651,84 +4667,112 @@ sctp_send_initiate(struct sctp_inpcb *in /* set up some of the credits. */ init->init.a_rwnd = htonl(max(inp->sctp_socket ? SCTP_SB_LIMIT_RCV(inp->sctp_socket) : 0, SCTP_MINIMAL_RWND)); - init->init.num_outbound_streams = htons(stcb->asoc.pre_open_streams); init->init.num_inbound_streams = htons(stcb->asoc.max_inbound_streams); init->init.initial_tsn = htonl(stcb->asoc.init_seq_number); + +#if defined(INET) || defined(INET6) /* now the address restriction */ /* XXX Should we take the address family of the socket into account? */ - sup_addr = (struct sctp_supported_addr_param *)((caddr_t)init + - sizeof(*init)); + sup_addr = (struct sctp_supported_addr_param *)(mtod(m, caddr_t)+chunk_len); sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE); #ifdef INET6 #ifdef INET /* we support 2 types: IPv4/IPv6 */ - sup_addr->ph.param_length = htons(sizeof(struct sctp_paramhdr) + 2 * sizeof(uint16_t)); + parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + 2 * sizeof(uint16_t)); + sup_addr->ph.param_length = htons(parameter_len); sup_addr->addr_type[0] = htons(SCTP_IPV4_ADDRESS); sup_addr->addr_type[1] = htons(SCTP_IPV6_ADDRESS); + padding_len = 0; #else /* we support 1 type: IPv6 */ - sup_addr->ph.param_length = htons(sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); + parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); + sup_addr->ph.param_length = htons(parameter_len); sup_addr->addr_type[0] = htons(SCTP_IPV6_ADDRESS); sup_addr->addr_type[1] = htons(0); /* this is the padding */ + padding_len = (uint16_t) sizeof(uint16_t); #endif #else /* we support 1 type: IPv4 */ - sup_addr->ph.param_length = htons(sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); + parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); + sup_addr->ph.param_length = htons(parameter_len); sup_addr->addr_type[0] = htons(SCTP_IPV4_ADDRESS); sup_addr->addr_type[1] = htons(0); /* this is the padding */ + padding_len = (uint16_t) sizeof(uint16_t); #endif - SCTP_BUF_LEN(m) += sizeof(struct sctp_supported_addr_param); - /* adaptation layer indication parameter */ - ali = (struct sctp_adaptation_layer_indication *)((caddr_t)sup_addr + sizeof(struct sctp_supported_addr_param)); + chunk_len += parameter_len; +#endif + /* Adaptation layer indication parameter */ + /* XXX: Should we include this always? */ + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication); + ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len); ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); - ali->ph.param_length = htons(sizeof(*ali)); + ali->ph.param_length = htons(parameter_len); ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator); - SCTP_BUF_LEN(m) += sizeof(*ali); - ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali)); + chunk_len += parameter_len; if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) { - /* Add NAT friendly parameter */ - struct sctp_paramhdr *ph; - - ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); + /* Add NAT friendly parameter. */ + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + parameter_len = (uint16_t) sizeof(struct sctp_paramhdr); + ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len); ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); - ph->param_length = htons(sizeof(struct sctp_paramhdr)); - SCTP_BUF_LEN(m) += sizeof(struct sctp_paramhdr); - ecn = (struct sctp_ecn_supported_param *)((caddr_t)ph + sizeof(*ph)); + ph->param_length = htons(parameter_len); + chunk_len += parameter_len; } /* now any cookie time extensions */ if (stcb->asoc.cookie_preserve_req) { struct sctp_cookie_perserve_param *cookie_preserve; - cookie_preserve = (struct sctp_cookie_perserve_param *)(ecn); + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + parameter_len = (uint16_t) sizeof(struct sctp_cookie_perserve_param); + cookie_preserve = (struct sctp_cookie_perserve_param *)(mtod(m, caddr_t)+chunk_len); cookie_preserve->ph.param_type = htons(SCTP_COOKIE_PRESERVE); - cookie_preserve->ph.param_length = htons( - sizeof(*cookie_preserve)); + cookie_preserve->ph.param_length = htons(parameter_len); cookie_preserve->time = htonl(stcb->asoc.cookie_preserve_req); - SCTP_BUF_LEN(m) += sizeof(*cookie_preserve); - ecn = (struct sctp_ecn_supported_param *)( - (caddr_t)cookie_preserve + sizeof(*cookie_preserve)); stcb->asoc.cookie_preserve_req = 0; + chunk_len += parameter_len; } /* ECN parameter */ if (stcb->asoc.ecn_allowed == 1) { - ecn->ph.param_type = htons(SCTP_ECN_CAPABLE); - ecn->ph.param_length = htons(sizeof(*ecn)); - SCTP_BUF_LEN(m) += sizeof(*ecn); - prsctp = (struct sctp_prsctp_supported_param *)((caddr_t)ecn + - sizeof(*ecn)); - } else { - prsctp = (struct sctp_prsctp_supported_param *)((caddr_t)ecn); + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + parameter_len = (uint16_t) sizeof(struct sctp_paramhdr); + ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len); + ph->param_type = htons(SCTP_ECN_CAPABLE); + ph->param_length = htons(parameter_len); + chunk_len += parameter_len; + } + /* And now tell the peer we do support PR-SCTP. */ + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; } - /* And now tell the peer we do pr-sctp */ - prsctp->ph.param_type = htons(SCTP_PRSCTP_SUPPORTED); - prsctp->ph.param_length = htons(sizeof(*prsctp)); - SCTP_BUF_LEN(m) += sizeof(*prsctp); + parameter_len = (uint16_t) sizeof(struct sctp_paramhdr); + ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len); + ph->param_type = htons(SCTP_PRSCTP_SUPPORTED); + ph->param_length = htons(parameter_len); + chunk_len += parameter_len; /* And now tell the peer we do all the extensions */ - pr_supported = (struct sctp_supported_chunk_types_param *) - ((caddr_t)prsctp + sizeof(*prsctp)); + pr_supported = (struct sctp_supported_chunk_types_param *)(mtod(m, caddr_t)+chunk_len); pr_supported->ph.param_type = htons(SCTP_SUPPORTED_CHUNK_EXT); num_ext = 0; pr_supported->chunk_types[num_ext++] = SCTP_ASCONF; @@ -4742,99 +4786,94 @@ sctp_send_initiate(struct sctp_inpcb *in if (stcb->asoc.sctp_nr_sack_on_off == 1) { pr_supported->chunk_types[num_ext++] = SCTP_NR_SELECTIVE_ACK; } - p_len = sizeof(*pr_supported) + num_ext; - pr_supported->ph.param_length = htons(p_len); - bzero((caddr_t)pr_supported + p_len, SCTP_SIZE32(p_len) - p_len); - SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len); - + parameter_len = (uint16_t) sizeof(struct sctp_supported_chunk_types_param) + num_ext; + pr_supported->ph.param_length = htons(parameter_len); + padding_len = SCTP_SIZE32(parameter_len) - parameter_len; + chunk_len += parameter_len; /* add authentication parameters */ if (!SCTP_BASE_SYSCTL(sctp_auth_disable)) { - struct sctp_auth_random *randp; - struct sctp_auth_hmac_algo *hmacs; - struct sctp_auth_chunk_list *chunks; - /* attach RANDOM parameter, if available */ if (stcb->asoc.authinfo.random != NULL) { - randp = (struct sctp_auth_random *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); - p_len = sizeof(*randp) + stcb->asoc.authinfo.random_len; + struct sctp_auth_random *randp; + + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + randp = (struct sctp_auth_random *)(mtod(m, caddr_t)+chunk_len); + parameter_len = (uint16_t) sizeof(struct sctp_auth_random) + stcb->asoc.authinfo.random_len; /* random key already contains the header */ - bcopy(stcb->asoc.authinfo.random->key, randp, p_len); - /* zero out any padding required */ - bzero((caddr_t)randp + p_len, SCTP_SIZE32(p_len) - p_len); - SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len); + memcpy(randp, stcb->asoc.authinfo.random->key, parameter_len); + padding_len = SCTP_SIZE32(parameter_len) - parameter_len; + chunk_len += parameter_len; } /* add HMAC_ALGO parameter */ - hmacs = (struct sctp_auth_hmac_algo *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); - p_len = sctp_serialize_hmaclist(stcb->asoc.local_hmacs, - (uint8_t *) hmacs->hmac_ids); - if (p_len > 0) { - p_len += sizeof(*hmacs); + if ((stcb->asoc.local_hmacs != NULL) && + (stcb->asoc.local_hmacs->num_algo > 0)) { + struct sctp_auth_hmac_algo *hmacs; + + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + hmacs = (struct sctp_auth_hmac_algo *)(mtod(m, caddr_t)+chunk_len); + parameter_len = (uint16_t) (sizeof(struct sctp_auth_hmac_algo) + + stcb->asoc.local_hmacs->num_algo * sizeof(uint16_t)); hmacs->ph.param_type = htons(SCTP_HMAC_LIST); - hmacs->ph.param_length = htons(p_len); - /* zero out any padding required */ - bzero((caddr_t)hmacs + p_len, SCTP_SIZE32(p_len) - p_len); - SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len); + hmacs->ph.param_length = htons(parameter_len); + sctp_serialize_hmaclist(stcb->asoc.local_hmacs, (uint8_t *) hmacs->hmac_ids); + padding_len = SCTP_SIZE32(parameter_len) - parameter_len; + chunk_len += parameter_len; } /* add CHUNKS parameter */ - chunks = (struct sctp_auth_chunk_list *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); - p_len = sctp_serialize_auth_chunks(stcb->asoc.local_auth_chunks, - chunks->chunk_types); - if (p_len > 0) { - p_len += sizeof(*chunks); + if (sctp_auth_get_chklist_size(stcb->asoc.local_auth_chunks) > 0) { + struct sctp_auth_chunk_list *chunks; + + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + chunks = (struct sctp_auth_chunk_list *)(mtod(m, caddr_t)+chunk_len); + parameter_len = (uint16_t) (sizeof(struct sctp_auth_chunk_list) + + sctp_auth_get_chklist_size(stcb->asoc.local_auth_chunks)); chunks->ph.param_type = htons(SCTP_CHUNK_LIST); - chunks->ph.param_length = htons(p_len); - /* zero out any padding required */ - bzero((caddr_t)chunks + p_len, SCTP_SIZE32(p_len) - p_len); - SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len); + chunks->ph.param_length = htons(parameter_len); + sctp_serialize_auth_chunks(stcb->asoc.local_auth_chunks, chunks->chunk_types); + padding_len = SCTP_SIZE32(parameter_len) - parameter_len; + chunk_len += parameter_len; } } - /* now the addresses */ - { - struct sctp_scoping scp; - - /* - * To optimize this we could put the scoping stuff into a - * structure and remove the individual uint8's from the - * assoc structure. Then we could just sifa in the address - * within the stcb. But for now this is a quick hack to get - * the address stuff teased apart. - */ - - scp.ipv4_addr_legal = stcb->asoc.ipv4_addr_legal; - scp.ipv6_addr_legal = stcb->asoc.ipv6_addr_legal; - scp.loopback_scope = stcb->asoc.loopback_scope; - scp.ipv4_local_scope = stcb->asoc.ipv4_local_scope; - scp.local_scope = stcb->asoc.local_scope; - scp.site_scope = stcb->asoc.site_scope; - - sctp_add_addresses_to_i_ia(inp, stcb, &scp, m, cnt_inits_to); - } + SCTP_BUF_LEN(m) = chunk_len; - /* calulate the size and update pkt header and chunk header */ - p_len = 0; - for (m_at = m; m_at; m_at = SCTP_BUF_NEXT(m_at)) { - if (SCTP_BUF_NEXT(m_at) == NULL) - mp_last = m_at; - p_len += SCTP_BUF_LEN(m_at); - } - init->ch.chunk_length = htons(p_len); + /* now the addresses */ /* - * We sifa 0 here to NOT set IP_DF if its IPv4, we ignore the return - * here since the timer will drive a retranmission. - */ + * To optimize this we could put the scoping stuff into a structure + * and remove the individual uint8's from the assoc structure. Then + * we could just sifa in the address within the stcb. But for now + * this is a quick hack to get the address stuff teased apart. + */ + scp.ipv4_addr_legal = stcb->asoc.ipv4_addr_legal; + scp.ipv6_addr_legal = stcb->asoc.ipv6_addr_legal; + scp.loopback_scope = stcb->asoc.loopback_scope; + scp.ipv4_local_scope = stcb->asoc.ipv4_local_scope; + scp.local_scope = stcb->asoc.local_scope; + scp.site_scope = stcb->asoc.site_scope; + sctp_add_addresses_to_i_ia(inp, stcb, &scp, m, cnt_inits_to, &padding_len, &chunk_len); + + init->ch.chunk_length = htons(chunk_len); + if (padding_len > 0) { + struct mbuf *m_at, *mp_last; - /* I don't expect this to execute but we will be safe here */ - padval = p_len % 4; - if ((padval) && (mp_last)) { - /* - * The compiler worries that mp_last may not be set even - * though I think it is impossible :-> however we add - * mp_last here just in case. - */ - ret = sctp_add_pad_tombuf(mp_last, (4 - padval)); - if (ret) { - /* Houston we have a problem, no space */ + mp_last = NULL; + for (m_at = m; m_at; m_at = SCTP_BUF_NEXT(m_at)) { + if (SCTP_BUF_NEXT(m_at) == NULL) + mp_last = m_at; + } + if ((mp_last == NULL) || sctp_add_pad_tombuf(mp_last, padding_len)) { sctp_m_freem(m); return; } @@ -5753,7 +5792,7 @@ do_a_abort: /* I can have what I want :> */ initack->init.num_outbound_streams = htons(i_want); } - /* tell him his limt. */ + /* tell him his limit. */ initack->init.num_inbound_streams = htons(inp->sctp_ep.max_open_streams_intome); @@ -5869,7 +5908,7 @@ do_a_abort: scp.ipv4_local_scope = stc.ipv4_scope; scp.local_scope = stc.local_scope; scp.site_scope = stc.site_scope; - m_at = sctp_add_addresses_to_i_ia(inp, stcb, &scp, m_at, cnt_inits_to); + m_at = sctp_add_addresses_to_i_ia(inp, stcb, &scp, m_at, cnt_inits_to, NULL, NULL); } /* tack on the operational error if present */ Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Jul 7 14:20:00 2013 (r252952) +++ stable/9/sys/netinet/sctp_output.h Sun Jul 7 15:18:09 2013 (r252953) @@ -46,7 +46,8 @@ sctp_add_addresses_to_i_ia(struct sctp_i struct sctp_tcb *stcb, struct sctp_scoping *scope, struct mbuf *m_at, - int cnt_inits_to); + int cnt_inits_to, + uint16_t * padding_len, uint16_t * chunk_len); int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:47:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1D8AEB6A; Sun, 7 Jul 2013 15:47:45 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F3BDC1914; Sun, 7 Jul 2013 15:47:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67FlidZ039997; Sun, 7 Jul 2013 15:47:44 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67FlicC039996; Sun, 7 Jul 2013 15:47:44 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071547.r67FlicC039996@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:47:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252954 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:47:45 -0000 Author: tuexen Date: Sun Jul 7 15:47:44 2013 New Revision: 252954 URL: http://svnweb.freebsd.org/changeset/base/252954 Log: MFC r244026: Use correct padding of the ABORT chunk in case of an user initiated abort cause is used. 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 Jul 7 15:18:09 2013 (r252953) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 15:47:44 2013 (r252954) @@ -10733,45 +10733,50 @@ sctp_send_abort_tcb(struct sctp_tcb *stc #endif ) { - struct mbuf *m_abort; - struct mbuf *m_out = NULL, *m_end = NULL; - struct sctp_abort_chunk *abort = NULL; - int sz; - uint32_t auth_offset = 0; + struct mbuf *m_abort, *m, *m_last; + struct mbuf *m_out, *m_end = NULL; + struct sctp_abort_chunk *abort; struct sctp_auth_chunk *auth = NULL; struct sctp_nets *net; + uint32_t auth_offset = 0; + uint16_t cause_len, chunk_len, padding_len; + SCTP_TCB_LOCK_ASSERT(stcb); /*- * Add an AUTH chunk, if chunk requires it and save the offset into * the chain for AUTH */ if (sctp_auth_is_required_chunk(SCTP_ABORT_ASSOCIATION, stcb->asoc.peer_auth_chunks)) { - m_out = sctp_add_auth_chunk(m_out, &m_end, &auth, &auth_offset, + m_out = sctp_add_auth_chunk(NULL, &m_end, &auth, &auth_offset, stcb, SCTP_ABORT_ASSOCIATION); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); + } else { + m_out = NULL; } - SCTP_TCB_LOCK_ASSERT(stcb); m_abort = sctp_get_mbuf_for_msg(sizeof(struct sctp_abort_chunk), 0, M_DONTWAIT, 1, MT_HEADER); if (m_abort == NULL) { - /* no mbuf's */ - if (m_out) + if (m_out) { sctp_m_freem(m_out); + } + if (operr) { + sctp_m_freem(operr); + } return; } /* link in any error */ SCTP_BUF_NEXT(m_abort) = operr; - sz = 0; - if (operr) { - struct mbuf *n; - - n = operr; - while (n) { - sz += SCTP_BUF_LEN(n); - n = SCTP_BUF_NEXT(n); + cause_len = 0; + m_last = NULL; + for (m = operr; m; m = SCTP_BUF_NEXT(m)) { + cause_len += (uint16_t) SCTP_BUF_LEN(m); + if (SCTP_BUF_NEXT(m) == NULL) { + m_last = m; } } - SCTP_BUF_LEN(m_abort) = sizeof(*abort); + SCTP_BUF_LEN(m_abort) = sizeof(struct sctp_abort_chunk); + chunk_len = (uint16_t) sizeof(struct sctp_abort_chunk) + cause_len; + padding_len = SCTP_SIZE32(chunk_len) - chunk_len; if (m_out == NULL) { /* NO Auth chunk prepended, so reserve space in front */ SCTP_BUF_RESV_UF(m_abort, SCTP_MIN_OVERHEAD); @@ -10785,12 +10790,18 @@ sctp_send_abort_tcb(struct sctp_tcb *stc } else { net = stcb->asoc.primary_destination; } - /* fill in the ABORT chunk */ + /* Fill in the ABORT chunk header. */ abort = mtod(m_abort, struct sctp_abort_chunk *); abort->ch.chunk_type = SCTP_ABORT_ASSOCIATION; abort->ch.chunk_flags = 0; - abort->ch.chunk_length = htons(sizeof(*abort) + sz); - + abort->ch.chunk_length = htons(chunk_len); + /* Add padding, if necessary. */ + if (padding_len > 0) { + if ((m_last == NULL) || sctp_add_pad_tombuf(m_last, padding_len)) { + sctp_m_freem(m_out); + return; + } + } (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net, (struct sockaddr *)&net->ro._l_addr, m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:50:01 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 91FF8DA1; Sun, 7 Jul 2013 15:50:01 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8497E1925; Sun, 7 Jul 2013 15:50:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Fo1So040469; Sun, 7 Jul 2013 15:50:01 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67Fo1J1040468; Sun, 7 Jul 2013 15:50:01 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071550.r67Fo1J1040468@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:50:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252955 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:50:01 -0000 Author: tuexen Date: Sun Jul 7 15:50:01 2013 New Revision: 252955 URL: http://svnweb.freebsd.org/changeset/base/252955 Log: MFC r244033: Get it compiling without INET and INET6 support (mainly userland stack). 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 Jul 7 15:47:44 2013 (r252954) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 15:50:01 2013 (r252955) @@ -4599,7 +4599,11 @@ sctp_send_initiate(struct sctp_inpcb *in struct mbuf *m; struct sctp_nets *net; struct sctp_init_chunk *init; + +#if defined(INET) || defined(INET6) struct sctp_supported_addr_param *sup_addr; + +#endif struct sctp_adaptation_layer_indication *ali; struct sctp_supported_chunk_types_param *pr_supported; struct sctp_paramhdr *ph; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:52:37 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AB916FA; Sun, 7 Jul 2013 15:52:37 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9DBC1194A; Sun, 7 Jul 2013 15:52:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Fqbpb042538; Sun, 7 Jul 2013 15:52:37 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67FqbTw042536; Sun, 7 Jul 2013 15:52:37 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071552.r67FqbTw042536@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:52:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252957 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:52:37 -0000 Author: tuexen Date: Sun Jul 7 15:52:37 2013 New Revision: 252957 URL: http://svnweb.freebsd.org/changeset/base/252957 Log: MFC r244728: Fix a copy and paste error. 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 Jul 7 15:51:28 2013 (r252956) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 15:52:37 2013 (r252957) @@ -4955,7 +4955,7 @@ sctp_get_ifa_hash_val(struct sockaddr *a } #endif #ifdef INET6 - case INET6: + case AF_INET6: { struct sockaddr_in6 *sin6; uint32_t hash_of_addr; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:55:01 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D98F531A; Sun, 7 Jul 2013 15:55:01 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CC558195F; Sun, 7 Jul 2013 15:55:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Ft1HR043047; Sun, 7 Jul 2013 15:55:01 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67Ft1mD043046; Sun, 7 Jul 2013 15:55:01 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071555.r67Ft1mD043046@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:55:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252958 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:55:01 -0000 Author: tuexen Date: Sun Jul 7 15:55:01 2013 New Revision: 252958 URL: http://svnweb.freebsd.org/changeset/base/252958 Log: MFC r244729: Minor cleanups of debug messages. Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 15:52:37 2013 (r252957) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 15:55:01 2013 (r252958) @@ -2694,9 +2694,9 @@ sctp_inpcb_bind(struct socket *so, struc ip_inp = (struct inpcb *)so->so_pcb; #ifdef SCTP_DEBUG if (addr) { - SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port:%d\n", + SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port: %d\n", ntohs(((struct sockaddr_in *)addr)->sin_port)); - SCTPDBG(SCTP_DEBUG_PCB1, "Addr :"); + SCTPDBG(SCTP_DEBUG_PCB1, "Addr: "); SCTPDBG_ADDR(SCTP_DEBUG_PCB1, addr); } #endif From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 15:57:12 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D4FA94F7; Sun, 7 Jul 2013 15:57:12 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C7597196C; Sun, 7 Jul 2013 15:57:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67FvCuo043378; Sun, 7 Jul 2013 15:57:12 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67FvCZM043377; Sun, 7 Jul 2013 15:57:12 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071557.r67FvCZM043377@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 15:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252959 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 15:57:12 -0000 Author: tuexen Date: Sun Jul 7 15:57:12 2013 New Revision: 252959 URL: http://svnweb.freebsd.org/changeset/base/252959 Log: MFC r244730: Some cleanups. 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 Jul 7 15:55:01 2013 (r252958) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 15:57:12 2013 (r252959) @@ -547,27 +547,21 @@ try_again: static int sctp_bind(struct socket *so, struct sockaddr *addr, struct thread *p) { - struct sctp_inpcb *inp = NULL; - int error; + struct sctp_inpcb *inp; -#ifdef INET - if (addr && addr->sa_family != AF_INET) { - /* must be a v4 address! */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - return (EINVAL); - } -#endif /* INET6 */ - if (addr && (addr->sa_len != sizeof(struct sockaddr_in))) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - return (EINVAL); - } inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); return (EINVAL); } - error = sctp_inpcb_bind(so, addr, NULL, p); - return (error); + if (addr != NULL) { + if ((addr->sa_family != AF_INET) || + (addr->sa_len != sizeof(struct sockaddr_in))) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + return (EINVAL); + } + } + return (sctp_inpcb_bind(so, addr, NULL, p)); } #endif From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:01:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 50B2B7B1; Sun, 7 Jul 2013 16:01:02 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3341719AA; Sun, 7 Jul 2013 16:01:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67G12q7045721; Sun, 7 Jul 2013 16:01:02 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67G10kl045701; Sun, 7 Jul 2013 16:01:00 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071601.r67G10kl045701@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:01:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252960 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:01:02 -0000 Author: tuexen Date: Sun Jul 7 16:01:00 2013 New Revision: 252960 URL: http://svnweb.freebsd.org/changeset/base/252960 Log: MFC r246588: Fix a bug where HEARTBEATs were still sent in SHUTDOWN_SENT or SHUTDOWN_ACK_SENT state. While there, make the corresponding code consistent. Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_timer.c stable/9/sys/netinet/sctp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 16:01:00 2013 (r252960) @@ -4262,19 +4262,19 @@ again: (asoc->stream_queue_cnt == 0)) { struct sctp_nets *netp; - if (asoc->alternate) { - netp = asoc->alternate; - } else { - netp = asoc->primary_destination; - } if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { goto abort_out_now; } SCTP_STAT_DECR_GAUGE32(sctps_currestab); SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); - sctp_send_shutdown_ack(stcb, netp); sctp_stop_timers_for_shutdown(stcb); + if (asoc->alternate) { + netp = asoc->alternate; + } else { + netp = asoc->primary_destination; + } + sctp_send_shutdown_ack(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, netp); } @@ -4973,11 +4973,6 @@ sctp_handle_sack(struct mbuf *m, int off } else { struct sctp_nets *netp; - if (asoc->alternate) { - netp = asoc->alternate; - } else { - netp = asoc->primary_destination; - } if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); @@ -4985,6 +4980,11 @@ sctp_handle_sack(struct mbuf *m, int off SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); sctp_stop_timers_for_shutdown(stcb); + if (asoc->alternate) { + netp = asoc->alternate; + } else { + netp = asoc->primary_destination; + } sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); @@ -4996,19 +4996,19 @@ sctp_handle_sack(struct mbuf *m, int off (asoc->stream_queue_cnt == 0)) { struct sctp_nets *netp; - if (asoc->alternate) { - netp = asoc->alternate; - } else { - netp = asoc->primary_destination; - } if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { goto abort_out_now; } SCTP_STAT_DECR_GAUGE32(sctps_currestab); SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); - sctp_send_shutdown_ack(stcb, netp); sctp_stop_timers_for_shutdown(stcb); + if (asoc->alternate) { + netp = asoc->alternate; + } else { + netp = asoc->primary_destination; + } + sctp_send_shutdown_ack(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, netp); return; Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 16:01:00 2013 (r252960) @@ -956,7 +956,6 @@ sctp_handle_shutdown(struct sctp_shutdow } else { /* no outstanding data to send, so move on... */ /* send SHUTDOWN-ACK */ - sctp_send_shutdown_ack(stcb, net); /* move to SHUTDOWN-ACK-SENT state */ if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { @@ -965,6 +964,7 @@ sctp_handle_shutdown(struct sctp_shutdow SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); sctp_stop_timers_for_shutdown(stcb); + sctp_send_shutdown_ack(stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, net); } Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:01:00 2013 (r252960) @@ -6574,12 +6574,13 @@ sctp_sendall_iterator(struct sctp_inpcb * only send SHUTDOWN the first time * through */ - sctp_send_shutdown(stcb, net); if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + sctp_send_shutdown(stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, @@ -13092,18 +13093,19 @@ dataless_eof: (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) { struct sctp_nets *netp; - if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; - } else { - netp = stcb->asoc.primary_destination; - } /* only send SHUTDOWN the first time through */ - sctp_send_shutdown(stcb, netp); if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (stcb->asoc.alternate) { + netp = stcb->asoc.alternate; + } else { + netp = stcb->asoc.primary_destination; + } + sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:01:00 2013 (r252960) @@ -3332,22 +3332,23 @@ sctp_inpcb_free(struct sctp_inpcb *inp, (SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) { struct sctp_nets *netp; - if (asoc->asoc.alternate) { - netp = asoc->asoc.alternate; - } else { - netp = asoc->asoc.primary_destination; - } /* * there is nothing queued to send, * so I send shutdown */ - sctp_send_shutdown(asoc, netp); if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(&asoc->asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(&asoc->asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(asoc); + if (asoc->asoc.alternate) { + netp = asoc->asoc.alternate; + } else { + netp = asoc->asoc.primary_destination; + } + sctp_send_shutdown(asoc, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, asoc->sctp_ep, asoc, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, Modified: stable/9/sys/netinet/sctp_timer.c ============================================================================== --- stable/9/sys/netinet/sctp_timer.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_timer.c Sun Jul 7 16:01:00 2013 (r252960) @@ -1560,18 +1560,19 @@ sctp_autoclose_timer(struct sctp_inpcb * /* only send SHUTDOWN 1st time thru */ struct sctp_nets *netp; - if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; - } else { - netp = stcb->asoc.primary_destination; - } - sctp_send_shutdown(stcb, netp); if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (stcb->asoc.alternate) { + netp = stcb->asoc.alternate; + } else { + netp = stcb->asoc.primary_destination; + } + sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 15:57:12 2013 (r252959) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:01:00 2013 (r252960) @@ -794,25 +794,24 @@ sctp_disconnect(struct socket *so) /* only send SHUTDOWN 1st time thru */ struct sctp_nets *netp; - if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; - } else { - netp = stcb->asoc.primary_destination; - } - sctp_stop_timers_for_shutdown(stcb); - sctp_send_shutdown(stcb, netp); - sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (stcb->asoc.alternate) { + netp = stcb->asoc.alternate; + } else { + netp = stcb->asoc.primary_destination; + } + sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, netp); - + sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); } } else { /* @@ -1014,24 +1013,24 @@ sctp_shutdown(struct socket *so) /* only send SHUTDOWN the first time through */ struct sctp_nets *netp; - if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; - } else { - netp = stcb->asoc.primary_destination; - } - sctp_stop_timers_for_shutdown(stcb); - sctp_send_shutdown(stcb, netp); - sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { SCTP_STAT_DECR_GAUGE32(sctps_currestab); } SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (stcb->asoc.alternate) { + netp = stcb->asoc.alternate; + } else { + netp = stcb->asoc.primary_destination; + } + sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, netp); + sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); } } else { /* From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:04:00 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C7D969ED; Sun, 7 Jul 2013 16:04:00 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B907C19CF; Sun, 7 Jul 2013 16:04:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67G40XG046290; Sun, 7 Jul 2013 16:04:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67G3wSR046267; Sun, 7 Jul 2013 16:03:58 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071603.r67G3wSR046267@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:03:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252961 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:04:00 -0000 Author: tuexen Date: Sun Jul 7 16:03:58 2013 New Revision: 252961 URL: http://svnweb.freebsd.org/changeset/base/252961 Log: MFC r246595: Cleanup the handling of address scopes. Announce in the INIT/INIT-ACK only the supported address types. While there, do some whitespace cleanups. Modified: stable/9/sys/netinet/sctp.h stable/9/sys/netinet/sctp_asconf.c 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.c stable/9/sys/netinet/sctp_structs.h stable/9/sys/netinet/sctp_sysctl.c stable/9/sys/netinet/sctp_usrreq.c stable/9/sys/netinet/sctputil.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp.h ============================================================================== --- stable/9/sys/netinet/sctp.h Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp.h Sun Jul 7 16:03:58 2013 (r252961) @@ -500,12 +500,12 @@ struct sctp_error_unrecognized_chunk { #define SCTP_PCB_FLAGS_SOCKET_GONE 0x10000000 #define SCTP_PCB_FLAGS_SOCKET_ALLGONE 0x20000000 #define SCTP_PCB_FLAGS_SOCKET_CANT_READ 0x40000000 + /* flags to copy to new PCB */ #define SCTP_PCB_COPY_FLAGS (SCTP_PCB_FLAGS_BOUNDALL|\ SCTP_PCB_FLAGS_WAKEINPUT|\ SCTP_PCB_FLAGS_BOUND_V6) - /* * PCB Features (in sctp_features bitmask) */ Modified: stable/9/sys/netinet/sctp_asconf.c ============================================================================== --- stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_asconf.c Sun Jul 7 16:03:58 2013 (r252961) @@ -1916,7 +1916,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb * return; } if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - if (stcb->asoc.local_scope == 0) { + if (stcb->asoc.scope.local_scope == 0) { return; } /* is it the right link local scope? */ @@ -1924,7 +1924,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb * return; } } - if (stcb->asoc.site_scope == 0 && + if (stcb->asoc.scope.site_scope == 0 && IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) { return; } @@ -1948,7 +1948,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb * /* we skip unspecifed addresses */ return; } - if (stcb->asoc.ipv4_local_scope == 0 && + if (stcb->asoc.scope.ipv4_local_scope == 0 && IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { return; } @@ -2106,7 +2106,7 @@ sctp_asconf_iterator_stcb(struct sctp_in continue; } if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - if (stcb->asoc.local_scope == 0) { + if (stcb->asoc.scope.local_scope == 0) { continue; } /* is it the right link local scope? */ @@ -2135,7 +2135,7 @@ sctp_asconf_iterator_stcb(struct sctp_in /* we skip unspecifed addresses */ continue; } - if (stcb->asoc.ipv4_local_scope == 0 && + if (stcb->asoc.scope.ipv4_local_scope == 0 && IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { continue; } @@ -2198,13 +2198,7 @@ sctp_asconf_iterator_stcb(struct sctp_in } } else { /* Need to check scopes for this guy */ - if (sctp_is_address_in_scope(ifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) { continue; } } @@ -2437,7 +2431,7 @@ sctp_find_valid_localaddr(struct sctp_tc return (NULL); } LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { - if (stcb->asoc.loopback_scope == 0 && + if (stcb->asoc.scope.loopback_scope == 0 && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { /* Skip if loopback_scope not set */ continue; @@ -2446,7 +2440,7 @@ sctp_find_valid_localaddr(struct sctp_tc switch (sctp_ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - if (stcb->asoc.ipv4_addr_legal) { + if (stcb->asoc.scope.ipv4_addr_legal) { struct sockaddr_in *sin; sin = (struct sockaddr_in *)&sctp_ifa->address.sa; @@ -2454,7 +2448,7 @@ sctp_find_valid_localaddr(struct sctp_tc /* skip unspecifed addresses */ continue; } - if (stcb->asoc.ipv4_local_scope == 0 && + if (stcb->asoc.scope.ipv4_local_scope == 0 && IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) continue; @@ -2473,7 +2467,7 @@ sctp_find_valid_localaddr(struct sctp_tc #endif #ifdef INET6 case AF_INET6: - if (stcb->asoc.ipv6_addr_legal) { + if (stcb->asoc.scope.ipv6_addr_legal) { struct sockaddr_in6 *sin6; if (sctp_ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { @@ -2487,10 +2481,10 @@ sctp_find_valid_localaddr(struct sctp_tc */ continue; } - if (stcb->asoc.local_scope == 0 && + if (stcb->asoc.scope.local_scope == 0 && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) continue; - if (stcb->asoc.site_scope == 0 && + if (stcb->asoc.scope.site_scope == 0 && IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) continue; Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 16:03:58 2013 (r252961) @@ -2130,13 +2130,13 @@ sctp_process_cookie_new(struct mbuf *m, asoc = &stcb->asoc; /* get scope variables out of cookie */ - asoc->ipv4_local_scope = cookie->ipv4_scope; - asoc->site_scope = cookie->site_scope; - asoc->local_scope = cookie->local_scope; - asoc->loopback_scope = cookie->loopback_scope; + asoc->scope.ipv4_local_scope = cookie->ipv4_scope; + asoc->scope.site_scope = cookie->site_scope; + asoc->scope.local_scope = cookie->local_scope; + asoc->scope.loopback_scope = cookie->loopback_scope; - if ((asoc->ipv4_addr_legal != cookie->ipv4_addr_legal) || - (asoc->ipv6_addr_legal != cookie->ipv6_addr_legal)) { + if ((asoc->scope.ipv4_addr_legal != cookie->ipv4_addr_legal) || + (asoc->scope.ipv6_addr_legal != cookie->ipv6_addr_legal)) { struct mbuf *op_err; /* Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:03:58 2013 (r252961) @@ -1863,15 +1863,10 @@ struct sack_track sack_array[256] = { int sctp_is_address_in_scope(struct sctp_ifa *ifa, - int ipv4_addr_legal, - int ipv6_addr_legal, - int loopback_scope, - int ipv4_local_scope, - int local_scope SCTP_UNUSED,/* XXX */ - int site_scope, + struct sctp_scoping *scope, int do_update) { - if ((loopback_scope == 0) && + if ((scope->loopback_scope == 0) && (ifa->ifn_p) && SCTP_IFN_IS_IFT_LOOP(ifa->ifn_p)) { /* * skip loopback if not in scope * @@ -1881,7 +1876,7 @@ sctp_is_address_in_scope(struct sctp_ifa switch (ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - if (ipv4_addr_legal) { + if (scope->ipv4_addr_legal) { struct sockaddr_in *sin; sin = (struct sockaddr_in *)&ifa->address.sin; @@ -1889,7 +1884,7 @@ sctp_is_address_in_scope(struct sctp_ifa /* not in scope , unspecified */ return (0); } - if ((ipv4_local_scope == 0) && + if ((scope->ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) { /* private address not in scope */ return (0); @@ -1901,7 +1896,7 @@ sctp_is_address_in_scope(struct sctp_ifa #endif #ifdef INET6 case AF_INET6: - if (ipv6_addr_legal) { + if (scope->ipv6_addr_legal) { struct sockaddr_in6 *sin6; /* @@ -1924,7 +1919,7 @@ sctp_is_address_in_scope(struct sctp_ifa (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))) { return (0); } - if ((site_scope == 0) && + if ((scope->site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { return (0); } @@ -2063,13 +2058,7 @@ sctp_add_addresses_to_i_ia(struct sctp_i if (sctp_is_addr_restricted(stcb, sctp_ifap)) { continue; } - if (sctp_is_address_in_scope(sctp_ifap, - scope->ipv4_addr_legal, - scope->ipv6_addr_legal, - scope->loopback_scope, - scope->ipv4_local_scope, - scope->local_scope, - scope->site_scope, 1) == 0) { + if (sctp_is_address_in_scope(sctp_ifap, scope, 1) == 0) { continue; } cnt++; @@ -2099,12 +2088,7 @@ skip_count: continue; } if (sctp_is_address_in_scope(sctp_ifap, - scope->ipv4_addr_legal, - scope->ipv6_addr_legal, - scope->loopback_scope, - scope->ipv4_local_scope, - scope->local_scope, - scope->site_scope, 0) == 0) { + scope, 0) == 0) { continue; } if ((chunk_len != NULL) && @@ -2157,12 +2141,7 @@ skip_count: continue; } if (sctp_is_address_in_scope(laddr->ifa, - scope->ipv4_addr_legal, - scope->ipv6_addr_legal, - scope->loopback_scope, - scope->ipv4_local_scope, - scope->local_scope, - scope->site_scope, 1) == 0) { + scope, 1) == 0) { continue; } cnt++; @@ -2182,12 +2161,7 @@ skip_count: continue; } if (sctp_is_address_in_scope(laddr->ifa, - scope->ipv4_addr_legal, - scope->ipv6_addr_legal, - scope->loopback_scope, - scope->ipv4_local_scope, - scope->local_scope, - scope->site_scope, 0) == 0) { + scope, 0) == 0) { continue; } if ((chunk_len != NULL) && @@ -2801,13 +2775,7 @@ sctp_select_nth_preferred_addr_from_ifn_ } #endif if (stcb) { - if (sctp_is_address_in_scope(ifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) { continue; } if (((non_asoc_addr_ok == 0) && @@ -2853,13 +2821,7 @@ sctp_count_num_preferred_boundall(struct continue; } if (stcb) { - if (sctp_is_address_in_scope(ifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) { continue; } if (((non_asoc_addr_ok == 0) && @@ -3055,13 +3017,7 @@ again_with_private_addresses_allowed: continue; } if (stcb) { - if (sctp_is_address_in_scope(sifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + if (sctp_is_address_in_scope(sifa, &stcb->asoc.scope, 0) == 0) { SCTPDBG(SCTP_DEBUG_OUTPUT2, "NOT in scope\n"); sifa = NULL; continue; @@ -3108,13 +3064,7 @@ plan_d: if (sifa == NULL) continue; if (stcb) { - if (sctp_is_address_in_scope(sifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + if (sctp_is_address_in_scope(sifa, &stcb->asoc.scope, 0) == 0) { sifa = NULL; continue; } @@ -3135,12 +3085,12 @@ plan_d: } } #ifdef INET - if ((retried == 0) && (stcb->asoc.ipv4_local_scope == 0)) { - stcb->asoc.ipv4_local_scope = 1; + if ((retried == 0) && (stcb->asoc.scope.ipv4_local_scope == 0)) { + stcb->asoc.scope.ipv4_local_scope = 1; retried = 1; goto again_with_private_addresses_allowed; } else if (retried == 1) { - stcb->asoc.ipv4_local_scope = 0; + stcb->asoc.scope.ipv4_local_scope = 0; } #endif out: @@ -3169,12 +3119,7 @@ out: } if (stcb) { if (sctp_is_address_in_scope(tmp_sifa, - stcb->asoc.ipv4_addr_legal, - stcb->asoc.ipv6_addr_legal, - stcb->asoc.loopback_scope, - stcb->asoc.ipv4_local_scope, - stcb->asoc.local_scope, - stcb->asoc.site_scope, 0) == 0) { + &stcb->asoc.scope, 0) == 0) { continue; } if (((non_asoc_addr_ok == 0) && @@ -4595,7 +4540,6 @@ sctp_send_initiate(struct sctp_inpcb *in #endif ) { - struct sctp_scoping scp; struct mbuf *m; struct sctp_nets *net; struct sctp_init_chunk *init; @@ -4675,37 +4619,29 @@ sctp_send_initiate(struct sctp_inpcb *in init->init.num_inbound_streams = htons(stcb->asoc.max_inbound_streams); init->init.initial_tsn = htonl(stcb->asoc.init_seq_number); -#if defined(INET) || defined(INET6) - /* now the address restriction */ - /* XXX Should we take the address family of the socket into account? */ - sup_addr = (struct sctp_supported_addr_param *)(mtod(m, caddr_t)+chunk_len); - sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE); -#ifdef INET6 -#ifdef INET - /* we support 2 types: IPv4/IPv6 */ - parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + 2 * sizeof(uint16_t)); - sup_addr->ph.param_length = htons(parameter_len); - sup_addr->addr_type[0] = htons(SCTP_IPV4_ADDRESS); - sup_addr->addr_type[1] = htons(SCTP_IPV6_ADDRESS); - padding_len = 0; -#else - /* we support 1 type: IPv6 */ - parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); - sup_addr->ph.param_length = htons(parameter_len); - sup_addr->addr_type[0] = htons(SCTP_IPV6_ADDRESS); - sup_addr->addr_type[1] = htons(0); /* this is the padding */ - padding_len = (uint16_t) sizeof(uint16_t); -#endif -#else - /* we support 1 type: IPv4 */ - parameter_len = (uint16_t) (sizeof(struct sctp_paramhdr) + sizeof(uint16_t)); - sup_addr->ph.param_length = htons(parameter_len); - sup_addr->addr_type[0] = htons(SCTP_IPV4_ADDRESS); - sup_addr->addr_type[1] = htons(0); /* this is the padding */ - padding_len = (uint16_t) sizeof(uint16_t); -#endif - chunk_len += parameter_len; -#endif + if (stcb->asoc.scope.ipv4_addr_legal || stcb->asoc.scope.ipv6_addr_legal) { + uint8_t i; + + parameter_len = (uint16_t) sizeof(struct sctp_paramhdr); + if (stcb->asoc.scope.ipv4_addr_legal) { + parameter_len += (uint16_t) sizeof(uint16_t); + } + if (stcb->asoc.scope.ipv6_addr_legal) { + parameter_len += (uint16_t) sizeof(uint16_t); + } + sup_addr = (struct sctp_supported_addr_param *)(mtod(m, caddr_t)+chunk_len); + sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE); + sup_addr->ph.param_length = htons(parameter_len); + i = 0; + if (stcb->asoc.scope.ipv4_addr_legal) { + sup_addr->addr_type[i++] = htons(SCTP_IPV4_ADDRESS); + } + if (stcb->asoc.scope.ipv6_addr_legal) { + sup_addr->addr_type[i++] = htons(SCTP_IPV6_ADDRESS); + } + padding_len = 4 - 2 * i; + chunk_len += parameter_len; + } /* Adaptation layer indication parameter */ /* XXX: Should we include this always? */ if (padding_len > 0) { @@ -4860,13 +4796,7 @@ sctp_send_initiate(struct sctp_inpcb *in * we could just sifa in the address within the stcb. But for now * this is a quick hack to get the address stuff teased apart. */ - scp.ipv4_addr_legal = stcb->asoc.ipv4_addr_legal; - scp.ipv6_addr_legal = stcb->asoc.ipv6_addr_legal; - scp.loopback_scope = stcb->asoc.loopback_scope; - scp.ipv4_local_scope = stcb->asoc.ipv4_local_scope; - scp.local_scope = stcb->asoc.local_scope; - scp.site_scope = stcb->asoc.site_scope; - sctp_add_addresses_to_i_ia(inp, stcb, &scp, m, cnt_inits_to, &padding_len, &chunk_len); + sctp_add_addresses_to_i_ia(inp, stcb, &stcb->asoc.scope, m, cnt_inits_to, &padding_len, &chunk_len); init->ch.chunk_length = htons(chunk_len); if (padding_len > 0) { @@ -5507,24 +5437,16 @@ do_a_abort: */ stc.site_scope = stc.local_scope = stc.loopback_scope = 0; if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - struct inpcb *in_inp; - - /* Its a V6 socket */ - in_inp = (struct inpcb *)inp; stc.ipv6_addr_legal = 1; - /* Now look at the binding flag to see if V4 will be legal */ - if (SCTP_IPV6_V6ONLY(in_inp) == 0) { - stc.ipv4_addr_legal = 1; - } else { - /* V4 addresses are NOT legal on the association */ + if (SCTP_IPV6_V6ONLY(inp)) { stc.ipv4_addr_legal = 0; + } else { + stc.ipv4_addr_legal = 1; } } else { - /* Its a V4 socket, no - V6 */ - stc.ipv4_addr_legal = 1; stc.ipv6_addr_legal = 0; + stc.ipv4_addr_legal = 1; } - #ifdef SCTP_DONT_DO_PRIVADDR_SCOPE stc.ipv4_scope = 1; #else @@ -5629,10 +5551,10 @@ do_a_abort: #endif - stc.loopback_scope = asoc->loopback_scope; - stc.ipv4_scope = asoc->ipv4_local_scope; - stc.site_scope = asoc->site_scope; - stc.local_scope = asoc->local_scope; + stc.loopback_scope = asoc->scope.loopback_scope; + stc.ipv4_scope = asoc->scope.ipv4_local_scope; + stc.site_scope = asoc->scope.site_scope; + stc.local_scope = asoc->scope.local_scope; #ifdef INET6 /* Why do we not consider IPv4 LL addresses? */ TAILQ_FOREACH(lnet, &asoc->nets, sctp_next) { Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_output.h Sun Jul 7 16:03:58 2013 (r252961) @@ -55,13 +55,9 @@ int sctp_is_addr_restricted(struct sctp_ int sctp_is_address_in_scope(struct sctp_ifa *ifa, - int ipv4_addr_legal, - int ipv6_addr_legal, - int loopback_scope, - int ipv4_local_scope, - int local_scope, - int site_scope, + struct sctp_scoping *scope, int do_update); + int sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa); Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:03:58 2013 (r252961) @@ -94,11 +94,10 @@ sctp_fill_pcbinfo(struct sctp_pcbinfo *s spcb->readq_count = SCTP_BASE_INFO(ipi_count_readq); spcb->stream_oque = SCTP_BASE_INFO(ipi_count_strmoq); spcb->free_chunks = SCTP_BASE_INFO(ipi_free_chunks); - SCTP_INP_INFO_RUNLOCK(); } -/* +/*- * Addresses are added to VRF's (Virtual Router's). For BSD we * have only the default VRF 0. We maintain a hash list of * VRF's. Each VRF has its own list of sctp_ifn's. Each of @@ -214,7 +213,6 @@ sctp_find_ifn(void *ifn, uint32_t ifn_in } - struct sctp_vrf * sctp_find_vrf(uint32_t vrf_id) { @@ -230,6 +228,7 @@ sctp_find_vrf(uint32_t vrf_id) return (NULL); } + void sctp_free_vrf(struct sctp_vrf *vrf) { @@ -245,6 +244,7 @@ sctp_free_vrf(struct sctp_vrf *vrf) } } + void sctp_free_ifn(struct sctp_ifn *sctp_ifnp) { @@ -258,6 +258,7 @@ sctp_free_ifn(struct sctp_ifn *sctp_ifnp } } + void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu) { @@ -283,6 +284,7 @@ sctp_free_ifa(struct sctp_ifa *sctp_ifap } } + static void sctp_delete_ifn(struct sctp_ifn *sctp_ifnp, int hold_addr_lock) { @@ -305,12 +307,13 @@ sctp_delete_ifn(struct sctp_ifn *sctp_if sctp_free_ifn(sctp_ifnp); } + void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index) { struct sctp_vrf *vrf; - struct sctp_ifa *sctp_ifap = NULL; + struct sctp_ifa *sctp_ifap; SCTP_IPI_ADDR_RLOCK(); vrf = sctp_find_vrf(vrf_id); @@ -348,12 +351,13 @@ out: SCTP_IPI_ADDR_RUNLOCK(); } + void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index) { struct sctp_vrf *vrf; - struct sctp_ifa *sctp_ifap = NULL; + struct sctp_ifa *sctp_ifap; SCTP_IPI_ADDR_RLOCK(); vrf = sctp_find_vrf(vrf_id); @@ -391,6 +395,7 @@ out: SCTP_IPI_ADDR_RUNLOCK(); } + /*- * Add an ifa to an ifn. * Register the interface as necessary. @@ -428,6 +433,7 @@ sctp_add_ifa_to_ifn(struct sctp_ifn *sct } } + /*- * Remove an ifa from its ifn. * If no more addresses exist, remove the ifn too. Otherwise, re-register @@ -479,6 +485,7 @@ sctp_remove_ifa_from_ifn(struct sctp_ifa } } + struct sctp_ifa * sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, uint32_t ifn_type, const char *if_name, void *ifa, @@ -1027,6 +1034,7 @@ sctp_tcb_special_locate(struct sctp_inpc return (NULL); } + static int sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) { @@ -1036,19 +1044,12 @@ sctp_does_stcb_own_this_addr(struct sctp struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; - loopback_scope = stcb->asoc.loopback_scope; - ipv4_local_scope = stcb->asoc.ipv4_local_scope; - local_scope = stcb->asoc.local_scope; - site_scope = stcb->asoc.site_scope; - ipv4_addr_legal = ipv6_addr_legal = 0; - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ipv6_addr_legal = 1; - if (SCTP_IPV6_V6ONLY(stcb->sctp_ep) == 0) { - ipv4_addr_legal = 1; - } - } else { - ipv4_addr_legal = 1; - } + loopback_scope = stcb->asoc.scope.loopback_scope; + ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; + local_scope = stcb->asoc.scope.local_scope; + site_scope = stcb->asoc.scope.site_scope; + ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; + ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; SCTP_IPI_ADDR_RLOCK(); vrf = sctp_find_vrf(stcb->asoc.vrf_id); @@ -1183,6 +1184,7 @@ sctp_does_stcb_own_this_addr(struct sctp return (0); } + /* * rules for use * @@ -1471,11 +1473,11 @@ null_return: return (NULL); } + /* * Find an association for a specific endpoint using the association id given * out in the COMM_UP notification */ - struct sctp_tcb * sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock) { @@ -1536,6 +1538,9 @@ sctp_findassociation_ep_asocid(struct sc } +/* + * Endpoint probe expects that the INP_INFO is locked. + */ static struct sctp_inpcb * sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head, uint16_t lport, uint32_t vrf_id) @@ -1552,12 +1557,8 @@ sctp_endpoint_probe(struct sockaddr *nam struct sockaddr_in6 *intf_addr6; #endif - int fnd; - /* - * Endpoint probe expects that the INP_INFO is locked. - */ #ifdef INET sin = NULL; #endif @@ -1893,6 +1894,7 @@ sctp_pcb_findep(struct sockaddr *nam, in return (inp); } + /* * Find an association for an endpoint with the pointer to whom you want to * send to and the endpoint pointer. The address can be IPv4 or IPv6. We may @@ -2144,6 +2146,7 @@ sctp_findassoc_by_vtag(struct sockaddr * return (NULL); } + /* * Find an association with the pointer to the inbound IP packet. This can be * a IPv4 or IPv6 packet. @@ -3743,13 +3746,13 @@ sctp_add_remote_addr(struct sctp_tcb *st stcb->ipv4_local_scope = 1; #else if (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { - stcb->asoc.ipv4_local_scope = 1; + stcb->asoc.scope.ipv4_local_scope = 1; } #endif /* SCTP_DONT_DO_PRIVADDR_SCOPE */ } else { /* Validate the address is in scope */ if ((IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) && - (stcb->asoc.ipv4_local_scope == 0)) { + (stcb->asoc.scope.ipv4_local_scope == 0)) { addr_inscope = 0; } } @@ -3770,10 +3773,10 @@ sctp_add_remote_addr(struct sctp_tcb *st sin6->sin6_len = sizeof(struct sockaddr_in6); if (set_scope) { if (sctp_is_address_on_local_host(newaddr, stcb->asoc.vrf_id)) { - stcb->asoc.loopback_scope = 1; - stcb->asoc.local_scope = 0; - stcb->asoc.ipv4_local_scope = 1; - stcb->asoc.site_scope = 1; + stcb->asoc.scope.loopback_scope = 1; + stcb->asoc.scope.local_scope = 0; + stcb->asoc.scope.ipv4_local_scope = 1; + stcb->asoc.scope.site_scope = 1; } else if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { /* * If the new destination is a @@ -3785,26 +3788,26 @@ sctp_add_remote_addr(struct sctp_tcb *st * also be on our private network * for v4 too. */ - stcb->asoc.ipv4_local_scope = 1; - stcb->asoc.site_scope = 1; + stcb->asoc.scope.ipv4_local_scope = 1; + stcb->asoc.scope.site_scope = 1; } else if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) { /* * If the new destination is * SITE_LOCAL then we must have site * scope in common. */ - stcb->asoc.site_scope = 1; + stcb->asoc.scope.site_scope = 1; } } else { /* Validate the address is in scope */ if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) && - (stcb->asoc.loopback_scope == 0)) { + (stcb->asoc.scope.loopback_scope == 0)) { addr_inscope = 0; } else if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && - (stcb->asoc.local_scope == 0)) { + (stcb->asoc.scope.local_scope == 0)) { addr_inscope = 0; } else if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) && - (stcb->asoc.site_scope == 0)) { + (stcb->asoc.scope.site_scope == 0)) { addr_inscope = 0; } } @@ -3839,10 +3842,10 @@ sctp_add_remote_addr(struct sctp_tcb *st } net->addr_is_local = sctp_is_address_on_local_host(newaddr, stcb->asoc.vrf_id); if (net->addr_is_local && ((set_scope || (from == SCTP_ADDR_IS_CONFIRMED)))) { - stcb->asoc.loopback_scope = 1; - stcb->asoc.ipv4_local_scope = 1; - stcb->asoc.local_scope = 0; - stcb->asoc.site_scope = 1; + stcb->asoc.scope.loopback_scope = 1; + stcb->asoc.scope.ipv4_local_scope = 1; + stcb->asoc.scope.local_scope = 0; + stcb->asoc.scope.site_scope = 1; addr_inscope = 1; } net->failure_threshold = stcb->asoc.def_net_failure; @@ -6071,7 +6074,7 @@ sctp_load_addresses_from_init(struct sct switch (sa->sa_family) { #ifdef INET case AF_INET: - if (stcb->asoc.ipv4_addr_legal) { + if (stcb->asoc.scope.ipv4_addr_legal) { if (sctp_add_remote_addr(stcb, sa, NULL, SCTP_DONOT_SETSCOPE, SCTP_LOAD_ADDR_2)) { return (-1); } @@ -6080,7 +6083,7 @@ sctp_load_addresses_from_init(struct sct #endif #ifdef INET6 case AF_INET6: - if (stcb->asoc.ipv6_addr_legal) { + if (stcb->asoc.scope.ipv6_addr_legal) { if (sctp_add_remote_addr(stcb, sa, NULL, SCTP_DONOT_SETSCOPE, SCTP_LOAD_ADDR_3)) { return (-2); } @@ -6127,7 +6130,7 @@ sctp_load_addresses_from_init(struct sct } #ifdef INET if (ptype == SCTP_IPV4_ADDRESS) { - if (stcb->asoc.ipv4_addr_legal) { + if (stcb->asoc.scope.ipv4_addr_legal) { struct sctp_ipv4addr_param *p4, p4_buf; /* ok get the v4 address and check/add */ @@ -6213,7 +6216,7 @@ sctp_load_addresses_from_init(struct sct #endif #ifdef INET6 if (ptype == SCTP_IPV6_ADDRESS) { - if (stcb->asoc.ipv6_addr_legal) { + if (stcb->asoc.scope.ipv6_addr_legal) { /* ok get the v6 address and check/add */ struct sctp_ipv6addr_param *p6, p6_buf; Modified: stable/9/sys/netinet/sctp_structs.h ============================================================================== --- stable/9/sys/netinet/sctp_structs.h Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_structs.h Sun Jul 7 16:03:58 2013 (r252961) @@ -1177,17 +1177,7 @@ struct sctp_association { */ uint8_t peer_supports_pktdrop; - /* Do we allow V6/V4? */ - uint8_t ipv4_addr_legal; - uint8_t ipv6_addr_legal; - /* Address scoping flags */ - /* scope value for IPv4 */ - uint8_t ipv4_local_scope; - /* scope values for IPv6 */ - uint8_t local_scope; - uint8_t site_scope; - /* loopback scope */ - uint8_t loopback_scope; + struct sctp_scoping scope; /* flags to handle send alternate net tracking */ uint8_t used_alt_onsack; uint8_t used_alt_asconfack; Modified: stable/9/sys/netinet/sctp_sysctl.c ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 16:03:58 2013 (r252961) @@ -197,29 +197,29 @@ copy_out_local_addresses(struct sctp_inp /* Turn on all the appropriate scope */ if (stcb) { /* use association specific values */ - loopback_scope = stcb->asoc.loopback_scope; - ipv4_local_scope = stcb->asoc.ipv4_local_scope; - local_scope = stcb->asoc.local_scope; - site_scope = stcb->asoc.site_scope; + loopback_scope = stcb->asoc.scope.loopback_scope; + ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; + local_scope = stcb->asoc.scope.local_scope; + site_scope = stcb->asoc.scope.site_scope; + ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; + ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; } else { - /* use generic values for endpoints */ + /* Use generic values for endpoints. */ loopback_scope = 1; ipv4_local_scope = 1; local_scope = 1; site_scope = 1; - } - - /* use only address families of interest */ - if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ipv6_addr_legal = 1; - if (SCTP_IPV6_V6ONLY(inp)) { - ipv4_addr_legal = 0; + if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { + ipv6_addr_legal = 1; + if (SCTP_IPV6_V6ONLY(inp)) { + ipv4_addr_legal = 0; + } else { + ipv4_addr_legal = 1; + } } else { + ipv6_addr_legal = 0; ipv4_addr_legal = 1; } - } else { - ipv4_addr_legal = 1; - ipv6_addr_legal = 0; } /* neither Mac OS X nor FreeBSD support mulitple routing functions */ Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:03:58 2013 (r252961) @@ -1143,23 +1143,29 @@ sctp_fill_up_addresses_vrf(struct sctp_i if (stcb) { /* Turn on all the appropriate scope */ - loopback_scope = stcb->asoc.loopback_scope; - ipv4_local_scope = stcb->asoc.ipv4_local_scope; - local_scope = stcb->asoc.local_scope; - site_scope = stcb->asoc.site_scope; + loopback_scope = stcb->asoc.scope.loopback_scope; + ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; + local_scope = stcb->asoc.scope.local_scope; + site_scope = stcb->asoc.scope.site_scope; + ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; + ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; } else { - /* Turn on ALL scope, since we look at the EP */ - loopback_scope = ipv4_local_scope = local_scope = - site_scope = 1; - } - ipv4_addr_legal = ipv6_addr_legal = 0; - if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ipv6_addr_legal = 1; - if (SCTP_IPV6_V6ONLY(inp) == 0) { + /* Use generic values for endpoints. */ + loopback_scope = 1; + ipv4_local_scope = 1; + local_scope = 1; + site_scope = 1; + if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { + ipv6_addr_legal = 1; + if (SCTP_IPV6_V6ONLY(inp)) { + ipv4_addr_legal = 0; + } else { + ipv4_addr_legal = 1; + } + } else { + ipv6_addr_legal = 0; ipv4_addr_legal = 1; } - } else { - ipv4_addr_legal = 1; } vrf = sctp_find_vrf(vrf_id); if (vrf == NULL) { @@ -1298,8 +1304,21 @@ sctp_fill_up_addresses_vrf(struct sctp_i } if (sctp_fill_user_address(sas, &laddr->ifa->address.sa)) continue; - - ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; + switch (laddr->ifa->address.sa.sa_family) { +#ifdef INET + case AF_INET: + ((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport; + break; +#endif +#ifdef INET6 + case AF_INET6: + ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; + break; +#endif + default: + /* TSNH */ + break; + } sas = (struct sockaddr_storage *)((caddr_t)sas + laddr->ifa->address.sa.sa_len); actual += laddr->ifa->address.sa.sa_len; @@ -5948,7 +5967,7 @@ sctp_connect(struct socket *so, struct s error = EINVAL; goto out_now; } -#endif /* INET6 */ +#endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == SCTP_PCB_FLAGS_UNBOUND) { /* Bind a ephemeral port */ @@ -6242,8 +6261,8 @@ sctp_accept(struct socket *so, struct so return (ENOMEM); sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); - sin->sin_port = ((struct sockaddr_in *)&store)->sin_port; - sin->sin_addr = ((struct sockaddr_in *)&store)->sin_addr; + sin->sin_port = store.sin.sin_port; + sin->sin_addr = store.sin.sin_addr; *addr = (struct sockaddr *)sin; break; } @@ -6258,9 +6277,8 @@ sctp_accept(struct socket *so, struct so return (ENOMEM); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); - sin6->sin6_port = ((struct sockaddr_in6 *)&store)->sin6_port; - - sin6->sin6_addr = ((struct sockaddr_in6 *)&store)->sin6_addr; + sin6->sin6_port = store.sin6.sin6_port; + sin6->sin6_addr = store.sin6.sin6_addr; if ((error = sa6_recoverscope(sin6)) != 0) { SCTP_FREE_SONAME(sin6); return (error); Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 7 16:01:00 2013 (r252960) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 16:03:58 2013 (r252961) @@ -878,7 +878,7 @@ sctp_select_a_tag(struct sctp_inpcb *inp } int -sctp_init_asoc(struct sctp_inpcb *m, struct sctp_tcb *stcb, +sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint32_t override_tag, uint32_t vrf_id) { struct sctp_association *asoc; @@ -899,23 +899,23 @@ sctp_init_asoc(struct sctp_inpcb *m, str asoc = &stcb->asoc; /* init all variables to a known value. */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:05:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6F28BB39; Sun, 7 Jul 2013 16:05:36 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4713119DF; Sun, 7 Jul 2013 16:05:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67G5a6C046617; Sun, 7 Jul 2013 16:05:36 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67G5acL046616; Sun, 7 Jul 2013 16:05:36 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071605.r67G5acL046616@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:05:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252962 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:05:36 -0000 Author: tuexen Date: Sun Jul 7 16:05:35 2013 New Revision: 252962 URL: http://svnweb.freebsd.org/changeset/base/252962 Log: MFC r246629: Improve code style. No functional change. Modified: stable/9/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 16:03:58 2013 (r252961) +++ stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 16:05:35 2013 (r252962) @@ -583,36 +583,36 @@ sctp_sendmsg(int s, if ((tolen > 0) && ((to == NULL) || (tolen < sizeof(struct sockaddr)))) { errno = EINVAL; - return -1; + return (-1); } if (to && (tolen > 0)) { if (to->sa_family == AF_INET) { if (tolen != sizeof(struct sockaddr_in)) { errno = EINVAL; - return -1; + return (-1); } if ((to->sa_len > 0) && (to->sa_len != sizeof(struct sockaddr_in))) { errno = EINVAL; - return -1; + return (-1); } memcpy(&addr, to, sizeof(struct sockaddr_in)); addr.in.sin_len = sizeof(struct sockaddr_in); } else if (to->sa_family == AF_INET6) { if (tolen != sizeof(struct sockaddr_in6)) { errno = EINVAL; - return -1; + return (-1); } if ((to->sa_len > 0) && (to->sa_len != sizeof(struct sockaddr_in6))) { errno = EINVAL; - return -1; + return (-1); } memcpy(&addr, to, sizeof(struct sockaddr_in6)); addr.in6.sin6_len = sizeof(struct sockaddr_in6); } else { errno = EAFNOSUPPORT; - return -1; + return (-1); } who = (struct sockaddr *)&addr; } @@ -836,7 +836,7 @@ sctp_sendmsgx(int sd, sinfo.sinfo_ssn = stream_no; sinfo.sinfo_timetolive = timetolive; sinfo.sinfo_context = context; - return sctp_sendx(sd, msg, len, addrs, addrcnt, &sinfo, 0); + return (sctp_sendx(sd, msg, len, addrs, addrcnt, &sinfo, 0)); } ssize_t From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:08:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 030F0D5F; Sun, 7 Jul 2013 16:08:35 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E632419F7; Sun, 7 Jul 2013 16:08:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67G8Yg2047189; Sun, 7 Jul 2013 16:08:34 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67G8YkF047188; Sun, 7 Jul 2013 16:08:34 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071608.r67G8YkF047188@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252963 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:08:35 -0000 Author: tuexen Date: Sun Jul 7 16:08:34 2013 New Revision: 252963 URL: http://svnweb.freebsd.org/changeset/base/252963 Log: MFC r246635: Make sure that received packets for removed addresses are handled consistently. While there, make variable names consistent. Modified: stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:05:35 2013 (r252962) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:08:34 2013 (r252963) @@ -824,6 +824,160 @@ out_now: } +static int +sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) +{ + int loopback_scope, ipv4_local_scope, local_scope, site_scope; + int ipv4_addr_legal, ipv6_addr_legal; + struct sctp_vrf *vrf; + struct sctp_ifn *sctp_ifn; + struct sctp_ifa *sctp_ifa; + + loopback_scope = stcb->asoc.scope.loopback_scope; + ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; + local_scope = stcb->asoc.scope.local_scope; + site_scope = stcb->asoc.scope.site_scope; + ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; + ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; + + SCTP_IPI_ADDR_RLOCK(); + vrf = sctp_find_vrf(stcb->asoc.vrf_id); + if (vrf == NULL) { + /* no vrf, no addresses */ + SCTP_IPI_ADDR_RUNLOCK(); + return (0); + } + if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { + LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { + if ((loopback_scope == 0) && + SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { + continue; + } + LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { + if (sctp_is_addr_restricted(stcb, sctp_ifa) && + (!sctp_is_addr_pending(stcb, sctp_ifa))) { + /* + * We allow pending addresses, where + * we have sent an asconf-add to be + * considered valid. + */ + continue; + } + switch (sctp_ifa->address.sa.sa_family) { +#ifdef INET + case AF_INET: + if (ipv4_addr_legal) { + struct sockaddr_in *sin, + *rsin; + + sin = &sctp_ifa->address.sin; + rsin = (struct sockaddr_in *)to; + if ((ipv4_local_scope == 0) && + IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { + continue; + } + if (sin->sin_addr.s_addr == rsin->sin_addr.s_addr) { + SCTP_IPI_ADDR_RUNLOCK(); + return (1); + } + } + break; +#endif +#ifdef INET6 + case AF_INET6: + if (ipv6_addr_legal) { + struct sockaddr_in6 *sin6, + *rsin6; + + sin6 = &sctp_ifa->address.sin6; + rsin6 = (struct sockaddr_in6 *)to; + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + if (local_scope == 0) + continue; + if (sin6->sin6_scope_id == 0) { + if (sa6_recoverscope(sin6) != 0) + continue; + } + } + if ((site_scope == 0) && + (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { + continue; + } + if (SCTP6_ARE_ADDR_EQUAL(sin6, rsin6)) { + SCTP_IPI_ADDR_RUNLOCK(); + return (1); + } + } + break; +#endif + default: + /* TSNH */ + break; + } + } + } + } else { + struct sctp_laddr *laddr; + + LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list, sctp_nxt_addr) { + if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) { + SCTPDBG(SCTP_DEBUG_PCB1, "ifa being deleted\n"); + continue; + } + if (sctp_is_addr_restricted(stcb, laddr->ifa) && + (!sctp_is_addr_pending(stcb, laddr->ifa))) { + /* + * We allow pending addresses, where we have + * sent an asconf-add to be considered + * valid. + */ + continue; + } + if (laddr->ifa->address.sa.sa_family != to->sa_family) { + continue; + } + switch (to->sa_family) { +#ifdef INET + case AF_INET: + { + struct sockaddr_in *sin, *rsin; + + sin = (struct sockaddr_in *)&laddr->ifa->address.sin; + rsin = (struct sockaddr_in *)to; + if (sin->sin_addr.s_addr == rsin->sin_addr.s_addr) { + SCTP_IPI_ADDR_RUNLOCK(); + return (1); + } + break; + } +#endif +#ifdef INET6 + case AF_INET6: + { + struct sockaddr_in6 *sin6, *rsin6; + + sin6 = (struct sockaddr_in6 *)&laddr->ifa->address.sin6; + rsin6 = (struct sockaddr_in6 *)to; + if (SCTP6_ARE_ADDR_EQUAL(sin6, rsin6)) { + SCTP_IPI_ADDR_RUNLOCK(); + return (1); + } + break; + } + +#endif + default: + /* TSNH */ + break; + } + + } + } + SCTP_IPI_ADDR_RUNLOCK(); + return (0); +} + + static struct sctp_tcb * sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, struct sockaddr *to, struct sctp_nets **netp, uint32_t vrf_id) @@ -906,7 +1060,6 @@ sctp_tcb_special_locate(struct sctp_inpc if (laddr->ifa->address.sa.sa_family == to->sa_family) { /* see if it matches */ - #ifdef INET if (from->sa_family == AF_INET) { struct sockaddr_in *intf_addr, @@ -949,13 +1102,18 @@ sctp_tcb_special_locate(struct sctp_inpc * Ok if we hit here the ep has the address, does it hold * the tcb? */ - + /* XXX: Why don't we TAILQ_FOREACH through sctp_asoc_list? */ stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb == NULL) { SCTP_INP_RUNLOCK(inp); continue; } SCTP_TCB_LOCK(stcb); + if (!sctp_does_stcb_own_this_addr(stcb, to)) { + SCTP_TCB_UNLOCK(stcb); + SCTP_INP_RUNLOCK(inp); + continue; + } if (stcb->rport != rport) { /* remote port does not match. */ SCTP_TCB_UNLOCK(stcb); @@ -967,6 +1125,11 @@ sctp_tcb_special_locate(struct sctp_inpc SCTP_INP_RUNLOCK(inp); continue; } + if (!sctp_does_stcb_own_this_addr(stcb, to)) { + SCTP_TCB_UNLOCK(stcb); + SCTP_INP_RUNLOCK(inp); + continue; + } /* Does this TCB have a matching address? */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -1035,156 +1198,6 @@ sctp_tcb_special_locate(struct sctp_inpc } -static int -sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) -{ - int loopback_scope, ipv4_local_scope, local_scope, site_scope; - int ipv4_addr_legal, ipv6_addr_legal; - struct sctp_vrf *vrf; - struct sctp_ifn *sctp_ifn; - struct sctp_ifa *sctp_ifa; - - loopback_scope = stcb->asoc.scope.loopback_scope; - ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; - local_scope = stcb->asoc.scope.local_scope; - site_scope = stcb->asoc.scope.site_scope; - ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; - ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; - - SCTP_IPI_ADDR_RLOCK(); - vrf = sctp_find_vrf(stcb->asoc.vrf_id); - if (vrf == NULL) { - /* no vrf, no addresses */ - SCTP_IPI_ADDR_RUNLOCK(); - return (0); - } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { - LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { - if ((loopback_scope == 0) && - SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { - continue; - } - LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { - if (sctp_is_addr_restricted(stcb, sctp_ifa) && - (!sctp_is_addr_pending(stcb, sctp_ifa))) { - /* - * We allow pending addresses, where - * we have sent an asconf-add to be - * considered valid. - */ - continue; - } - switch (sctp_ifa->address.sa.sa_family) { -#ifdef INET - case AF_INET: - if (ipv4_addr_legal) { - struct sockaddr_in *sin, - *rsin; - - sin = &sctp_ifa->address.sin; - rsin = (struct sockaddr_in *)to; - if ((ipv4_local_scope == 0) && - IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { - continue; - } - if (sin->sin_addr.s_addr == rsin->sin_addr.s_addr) { - SCTP_IPI_ADDR_RUNLOCK(); - return (1); - } - } - break; -#endif -#ifdef INET6 - case AF_INET6: - if (ipv6_addr_legal) { - struct sockaddr_in6 *sin6, - *rsin6; - - sin6 = &sctp_ifa->address.sin6; - rsin6 = (struct sockaddr_in6 *)to; - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - if (local_scope == 0) - continue; - if (sin6->sin6_scope_id == 0) { - if (sa6_recoverscope(sin6) != 0) - continue; - } - } - if ((site_scope == 0) && - (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { - continue; - } - if (SCTP6_ARE_ADDR_EQUAL(sin6, rsin6)) { - SCTP_IPI_ADDR_RUNLOCK(); - return (1); - } - } - break; -#endif - default: - /* TSNH */ - break; - } - } - } - } else { - struct sctp_laddr *laddr; - - LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list, sctp_nxt_addr) { - if (sctp_is_addr_restricted(stcb, laddr->ifa) && - (!sctp_is_addr_pending(stcb, laddr->ifa))) { - /* - * We allow pending addresses, where we have - * sent an asconf-add to be considered - * valid. - */ - continue; - } - if (laddr->ifa->address.sa.sa_family != to->sa_family) { - continue; - } - switch (to->sa_family) { -#ifdef INET - case AF_INET: - { - struct sockaddr_in *sin, *rsin; - - sin = (struct sockaddr_in *)&laddr->ifa->address.sin; - rsin = (struct sockaddr_in *)to; - if (sin->sin_addr.s_addr == rsin->sin_addr.s_addr) { - SCTP_IPI_ADDR_RUNLOCK(); - return (1); - } - break; - } -#endif -#ifdef INET6 - case AF_INET6: - { - struct sockaddr_in6 *sin6, *rsin6; - - sin6 = (struct sockaddr_in6 *)&laddr->ifa->address.sin6; - rsin6 = (struct sockaddr_in6 *)to; - if (SCTP6_ARE_ADDR_EQUAL(sin6, rsin6)) { - SCTP_IPI_ADDR_RUNLOCK(); - return (1); - } - break; - } - -#endif - default: - /* TSNH */ - break; - } - - } - } - SCTP_IPI_ADDR_RUNLOCK(); - return (0); -} - - /* * rules for use * @@ -1906,20 +1919,20 @@ sctp_findassociation_addr_sa(struct sock uint32_t vrf_id) { struct sctp_inpcb *inp = NULL; - struct sctp_tcb *retval; + struct sctp_tcb *stcb; SCTP_INP_INFO_RLOCK(); if (find_tcp_pool) { if (inp_p != NULL) { - retval = sctp_tcb_special_locate(inp_p, from, to, netp, + stcb = sctp_tcb_special_locate(inp_p, from, to, netp, vrf_id); } else { - retval = sctp_tcb_special_locate(&inp, from, to, netp, + stcb = sctp_tcb_special_locate(&inp, from, to, netp, vrf_id); } - if (retval != NULL) { + if (stcb != NULL) { SCTP_INP_INFO_RUNLOCK(); - return (retval); + return (stcb); } } inp = sctp_pcb_findep(to, 0, 1, vrf_id); @@ -1927,7 +1940,6 @@ sctp_findassociation_addr_sa(struct sock *inp_p = inp; } SCTP_INP_INFO_RUNLOCK(); - if (inp == NULL) { return (NULL); } @@ -1938,13 +1950,13 @@ sctp_findassociation_addr_sa(struct sock * inbound packet side. */ if (inp_p != NULL) { - retval = sctp_findassociation_ep_addr(inp_p, from, netp, to, + stcb = sctp_findassociation_ep_addr(inp_p, from, netp, to, NULL); } else { - retval = sctp_findassociation_ep_addr(&inp, from, netp, to, + stcb = sctp_findassociation_ep_addr(&inp, from, netp, to, NULL); } - return retval; + return (stcb); } @@ -1959,7 +1971,7 @@ sctp_findassociation_special_addr(struct struct sockaddr *dst) { struct sctp_paramhdr *phdr, parm_buf; - struct sctp_tcb *retval; + struct sctp_tcb *stcb; uint32_t ptype, plen; #ifdef INET @@ -1984,7 +1996,7 @@ sctp_findassociation_special_addr(struct sin6.sin6_port = sh->src_port; #endif - retval = NULL; + stcb = NULL; offset += sizeof(struct sctp_init_chunk); phdr = sctp_get_next_param(m, offset, &parm_buf, sizeof(parm_buf)); @@ -2009,10 +2021,10 @@ sctp_findassociation_special_addr(struct p4 = (struct sctp_ipv4addr_param *)phdr; memcpy(&sin4.sin_addr, &p4->addr, sizeof(p4->addr)); /* look it up */ - retval = sctp_findassociation_ep_addr(inp_p, + stcb = sctp_findassociation_ep_addr(inp_p, (struct sockaddr *)&sin4, netp, dst, NULL); - if (retval != NULL) { - return (retval); + if (stcb != NULL) { + return (stcb); } } #endif @@ -2030,10 +2042,10 @@ sctp_findassociation_special_addr(struct p6 = (struct sctp_ipv6addr_param *)phdr; memcpy(&sin6.sin6_addr, &p6->addr, sizeof(p6->addr)); /* look it up */ - retval = sctp_findassociation_ep_addr(inp_p, + stcb = sctp_findassociation_ep_addr(inp_p, (struct sockaddr *)&sin6, netp, dst, NULL); - if (retval != NULL) { - return (retval); + if (stcb != NULL) { + return (stcb); } } #endif @@ -2158,15 +2170,15 @@ sctp_findassociation_addr(struct mbuf *m struct sctp_inpcb **inp_p, struct sctp_nets **netp, uint32_t vrf_id) { int find_tcp_pool; - struct sctp_tcb *retval; + struct sctp_tcb *stcb; struct sctp_inpcb *inp; if (sh->v_tag) { /* we only go down this path if vtag is non-zero */ - retval = sctp_findassoc_by_vtag(src, dst, ntohl(sh->v_tag), + stcb = sctp_findassoc_by_vtag(src, dst, ntohl(sh->v_tag), inp_p, netp, sh->src_port, sh->dest_port, 0, vrf_id, 0); - if (retval) { - return (retval); + if (stcb) { + return (stcb); } } find_tcp_pool = 0; @@ -2178,15 +2190,15 @@ sctp_findassociation_addr(struct mbuf *m find_tcp_pool = 1; } if (inp_p) { - retval = sctp_findassociation_addr_sa(src, dst, inp_p, netp, + stcb = sctp_findassociation_addr_sa(src, dst, inp_p, netp, find_tcp_pool, vrf_id); inp = *inp_p; } else { - retval = sctp_findassociation_addr_sa(src, dst, &inp, netp, + stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp, find_tcp_pool, vrf_id); } - SCTPDBG(SCTP_DEBUG_PCB1, "retval:%p inp:%p\n", (void *)retval, (void *)inp); - if (retval == NULL && inp) { + SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp); + if (stcb == NULL && inp) { /* Found a EP but not this address */ if ((ch->chunk_type == SCTP_INITIATION) || (ch->chunk_type == SCTP_INITIATION_ACK)) { @@ -2204,15 +2216,15 @@ sctp_findassociation_addr(struct mbuf *m } return (NULL); } - retval = sctp_findassociation_special_addr(m, + stcb = sctp_findassociation_special_addr(m, offset, sh, &inp, netp, dst); if (inp_p != NULL) { *inp_p = inp; } } } - SCTPDBG(SCTP_DEBUG_PCB1, "retval is %p\n", (void *)retval); - return (retval); + SCTPDBG(SCTP_DEBUG_PCB1, "stcb is %p\n", (void *)stcb); + return (stcb); } /* From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:11:14 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 89701F25; Sun, 7 Jul 2013 16:11:14 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7B7511A19; Sun, 7 Jul 2013 16:11:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GBEBN049391; Sun, 7 Jul 2013 16:11:14 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GBDOY049386; Sun, 7 Jul 2013 16:11:13 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071611.r67GBDOY049386@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:11:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252964 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:11:14 -0000 Author: tuexen Date: Sun Jul 7 16:11:13 2013 New Revision: 252964 URL: http://svnweb.freebsd.org/changeset/base/252964 Log: MFC r246674: Don't send kernel provided information in the User Initiated ABORT cause, since the user can also provide this kind of information. So the receiver doesn't know who provided the information. While there: Fix a bug where the stack would send a malformed ABORT chunk when using a send() call with SCTP_ABORT|SCT_SENDALL flags. Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 16:08:34 2013 (r252963) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 16:11:13 2013 (r252964) @@ -4221,19 +4221,15 @@ again: abort_out_now: *abort_now = 1; /* XXX */ - oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + oper = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (oper) { struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(oper) = sizeof(struct sctp_paramhdr) + - sizeof(uint32_t); + SCTP_BUF_LEN(oper) = sizeof(struct sctp_paramhdr); ph = mtod(oper, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(oper)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_INDATA + SCTP_LOC_24); } stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; sctp_abort_an_association(stcb->sctp_ep, stcb, oper, SCTP_SO_NOT_LOCKED); @@ -4953,19 +4949,15 @@ sctp_handle_sack(struct mbuf *m, int off abort_out_now: *abort_now = 1; /* XXX */ - oper = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + oper = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (oper) { struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(oper) = sizeof(struct sctp_paramhdr) + - sizeof(uint32_t); + SCTP_BUF_LEN(oper) = sizeof(struct sctp_paramhdr); ph = mtod(oper, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(oper)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_INDATA + SCTP_LOC_31); } stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_31; sctp_abort_an_association(stcb->sctp_ep, stcb, oper, SCTP_SO_NOT_LOCKED); Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:08:34 2013 (r252963) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:11:13 2013 (r252964) @@ -6442,7 +6442,7 @@ sctp_sendall_iterator(struct sctp_inpcb if (m) { ph = mtod(m, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); - ph->param_length = htons(ca->sndlen); + ph->param_length = htons(sizeof(struct sctp_paramhdr) + ca->sndlen); } /* * We add one here to keep the assoc from @@ -12498,7 +12498,7 @@ sctp_lower_sosend(struct socket *so, /* now move forward the data pointer */ ph = mtod(mm, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); - ph->param_length = htons((sizeof(struct sctp_paramhdr) + tot_out)); + ph->param_length = htons(sizeof(struct sctp_paramhdr) + tot_out); ph++; SCTP_BUF_LEN(mm) = tot_out + sizeof(struct sctp_paramhdr); if (top == NULL) { Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:08:34 2013 (r252963) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:11:13 2013 (r252964) @@ -3308,22 +3308,16 @@ sctp_inpcb_free(struct sctp_inpcb *inp, /* Left with Data unread */ struct mbuf *op_err; - op_err = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (op_err) { /* Fill in the user initiated abort */ struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(op_err) = - sizeof(struct sctp_paramhdr) + sizeof(uint32_t); - ph = mtod(op_err, - struct sctp_paramhdr *); - ph->param_type = htons( - SCTP_CAUSE_USER_INITIATED_ABT); + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); + ph = mtod(op_err, struct sctp_paramhdr *); + ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(op_err)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_PCB + SCTP_LOC_3); } asoc->sctp_ep->last_abort_code = SCTP_FROM_SCTP_PCB + SCTP_LOC_3; sctp_send_abort_tcb(asoc, op_err, SCTP_SO_LOCKED); @@ -3395,7 +3389,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, struct mbuf *op_err; abort_anyway: - op_err = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (op_err) { /* @@ -3403,18 +3397,11 @@ sctp_inpcb_free(struct sctp_inpcb *inp, * initiated abort */ struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(op_err) = - (sizeof(struct sctp_paramhdr) + - sizeof(uint32_t)); - ph = mtod(op_err, - struct sctp_paramhdr *); - ph->param_type = htons( - SCTP_CAUSE_USER_INITIATED_ABT); + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); + ph = mtod(op_err, struct sctp_paramhdr *); + ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(op_err)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_PCB + SCTP_LOC_5); } asoc->sctp_ep->last_abort_code = SCTP_FROM_SCTP_PCB + SCTP_LOC_5; sctp_send_abort_tcb(asoc, op_err, SCTP_SO_LOCKED); @@ -3478,23 +3465,17 @@ sctp_inpcb_free(struct sctp_inpcb *inp, if ((SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_COOKIE_WAIT) && ((asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0)) { struct mbuf *op_err; - uint32_t *ippp; - op_err = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (op_err) { /* Fill in the user initiated abort */ struct sctp_paramhdr *ph; - SCTP_BUF_LEN(op_err) = (sizeof(struct sctp_paramhdr) + - sizeof(uint32_t)); + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); ph = mtod(op_err, struct sctp_paramhdr *); - ph->param_type = htons( - SCTP_CAUSE_USER_INITIATED_ABT); + ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(op_err)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_PCB + SCTP_LOC_7); - } asoc->sctp_ep->last_abort_code = SCTP_FROM_SCTP_PCB + SCTP_LOC_7; sctp_send_abort_tcb(asoc, op_err, SCTP_SO_LOCKED); Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:08:34 2013 (r252963) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:11:13 2013 (r252964) @@ -854,7 +854,7 @@ sctp_disconnect(struct socket *so) struct mbuf *op_err; abort_anyway: - op_err = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (op_err) { /* @@ -862,17 +862,11 @@ sctp_disconnect(struct socket *so) * initiated abort */ struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(op_err) = - (sizeof(struct sctp_paramhdr) + sizeof(uint32_t)); - ph = mtod(op_err, - struct sctp_paramhdr *); - ph->param_type = htons( - SCTP_CAUSE_USER_INITIATED_ABT); + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); + ph = mtod(op_err, struct sctp_paramhdr *); + ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(op_err)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_USRREQ + SCTP_LOC_4); } stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_4; sctp_send_abort_tcb(stcb, op_err, SCTP_SO_LOCKED); @@ -1069,22 +1063,16 @@ sctp_shutdown(struct socket *so) struct mbuf *op_err; abort_anyway: - op_err = sctp_get_mbuf_for_msg((sizeof(struct sctp_paramhdr) + sizeof(uint32_t)), + op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_DONTWAIT, 1, MT_DATA); if (op_err) { /* Fill in the user initiated abort */ struct sctp_paramhdr *ph; - uint32_t *ippp; - SCTP_BUF_LEN(op_err) = - sizeof(struct sctp_paramhdr) + sizeof(uint32_t); - ph = mtod(op_err, - struct sctp_paramhdr *); - ph->param_type = htons( - SCTP_CAUSE_USER_INITIATED_ABT); + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); + ph = mtod(op_err, struct sctp_paramhdr *); + ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); ph->param_length = htons(SCTP_BUF_LEN(op_err)); - ippp = (uint32_t *) (ph + 1); - *ippp = htonl(SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6); } stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6; sctp_abort_an_association(stcb->sctp_ep, stcb, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:13:55 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E91B8227; Sun, 7 Jul 2013 16:13:55 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB4591A2D; Sun, 7 Jul 2013 16:13:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GDttt049909; Sun, 7 Jul 2013 16:13:55 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GDtaj049903; Sun, 7 Jul 2013 16:13:55 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071613.r67GDtaj049903@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:13:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252966 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:13:56 -0000 Author: tuexen Date: Sun Jul 7 16:13:54 2013 New Revision: 252966 URL: http://svnweb.freebsd.org/changeset/base/252966 Log: MFC r246687: Send the adaptation layer indication only if set by the user. Modified: stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_pcb.h stable/9/sys/netinet/sctp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:12:22 2013 (r252965) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:13:54 2013 (r252966) @@ -4643,19 +4643,19 @@ sctp_send_initiate(struct sctp_inpcb *in chunk_len += parameter_len; } /* Adaptation layer indication parameter */ - /* XXX: Should we include this always? */ - if (padding_len > 0) { - memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); - chunk_len += padding_len; - padding_len = 0; + if (inp->sctp_ep.adaptation_layer_indicator_provided) { + if (padding_len > 0) { + memset(mtod(m, caddr_t)+chunk_len, 0, padding_len); + chunk_len += padding_len; + padding_len = 0; + } + parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication); + ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len); + ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); + ali->ph.param_length = htons(parameter_len); + ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator); + chunk_len += parameter_len; } - parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication); - ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len); - ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); - ali->ph.param_length = htons(parameter_len); - ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator); - chunk_len += parameter_len; - if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) { /* Add NAT friendly parameter. */ if (padding_len > 0) { @@ -5723,12 +5723,16 @@ do_a_abort: htons(inp->sctp_ep.max_open_streams_intome); /* adaptation layer indication parameter */ - ali = (struct sctp_adaptation_layer_indication *)((caddr_t)initack + sizeof(*initack)); - ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); - ali->ph.param_length = htons(sizeof(*ali)); - ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator); - SCTP_BUF_LEN(m) += sizeof(*ali); - ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali)); + if (inp->sctp_ep.adaptation_layer_indicator_provided) { + ali = (struct sctp_adaptation_layer_indication *)((caddr_t)initack + sizeof(*initack)); + ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); + ali->ph.param_length = htons(sizeof(*ali)); + ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator); + SCTP_BUF_LEN(m) += sizeof(*ali); + ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali)); + } else { + ecn = (struct sctp_ecn_supported_param *)((caddr_t)initack + sizeof(*initack)); + } /* ECN parameter */ if (((asoc != NULL) && (asoc->ecn_allowed == 1)) || Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:12:22 2013 (r252965) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:13:54 2013 (r252966) @@ -2516,7 +2516,8 @@ sctp_inpcb_alloc(struct socket *so, uint m->pre_open_stream_count = SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default); /* Add adaptation cookie */ - m->adaptation_layer_indicator = 0x504C5253; + m->adaptation_layer_indicator = 0; + m->adaptation_layer_indicator_provided = 0; /* seed random number generator */ m->random_counter = 1; Modified: stable/9/sys/netinet/sctp_pcb.h ============================================================================== --- stable/9/sys/netinet/sctp_pcb.h Sun Jul 7 16:12:22 2013 (r252965) +++ stable/9/sys/netinet/sctp_pcb.h Sun Jul 7 16:13:54 2013 (r252966) @@ -323,6 +323,7 @@ struct sctp_pcb { int auto_close_time; uint32_t initial_sequence_debug; uint32_t adaptation_layer_indicator; + uint8_t adaptation_layer_indicator_provided; uint32_t store_at; uint32_t max_burst; uint32_t fr_max_burst; Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:12:22 2013 (r252965) +++ stable/9/sys/netinet/sctp_usrreq.c Sun Jul 7 16:13:54 2013 (r252966) @@ -4617,6 +4617,7 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(adap_bits, optval, struct sctp_setadaptation, optsize); SCTP_INP_WLOCK(inp); inp->sctp_ep.adaptation_layer_indicator = adap_bits->ssb_adaptation_ind; + inp->sctp_ep.adaptation_layer_indicator_provided = 1; SCTP_INP_WUNLOCK(inp); break; } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:16:33 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0F4C436F; Sun, 7 Jul 2013 16:16:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0174E1A3D; Sun, 7 Jul 2013 16:16:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GGW6l050327; Sun, 7 Jul 2013 16:16:32 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GGWpv050326; Sun, 7 Jul 2013 16:16:32 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071616.r67GGWpv050326@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:16:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252967 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:16:33 -0000 Author: tuexen Date: Sun Jul 7 16:16:32 2013 New Revision: 252967 URL: http://svnweb.freebsd.org/changeset/base/252967 Log: MFC r247412: Fix a potential race in returning setting errno when an association goes down. Reported by Mozilla in https://bugzilla.mozilla.org/show_bug.cgi?id=845513 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 Jul 7 16:13:54 2013 (r252966) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 16:16:32 2013 (r252967) @@ -2678,6 +2678,7 @@ set_error: if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && ((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) { + SOCK_LOCK(stcb->sctp_socket); if (from_peer) { if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) { SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNREFUSED); @@ -2709,7 +2710,7 @@ set_error: if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && ((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) { - socantrcvmore(stcb->sctp_socket); + socantrcvmore_locked(stcb->sctp_socket); } sorwakeup(stcb->sctp_socket); sowwakeup(stcb->sctp_socket); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:25:39 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E06B2723; Sun, 7 Jul 2013 16:25:39 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B83CB1AAD; Sun, 7 Jul 2013 16:25:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GPd5A053306; Sun, 7 Jul 2013 16:25:39 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GPdi1053304; Sun, 7 Jul 2013 16:25:39 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071625.r67GPdi1053304@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:25:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252968 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:25:40 -0000 Author: tuexen Date: Sun Jul 7 16:25:39 2013 New Revision: 252968 URL: http://svnweb.freebsd.org/changeset/base/252968 Log: MFC r248172: Return an error if sctp_peeloff() fails because a socket can't be allocated. sctp_peeloff() uses sonewconn() also in cases where listen() wasn't called. So honor this use case. Modified: stable/9/sys/kern/uipc_socket.c stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_socket.c ============================================================================== --- stable/9/sys/kern/uipc_socket.c Sun Jul 7 16:16:32 2013 (r252967) +++ stable/9/sys/kern/uipc_socket.c Sun Jul 7 16:25:39 2013 (r252968) @@ -136,6 +136,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -505,8 +506,12 @@ sonewconn(struct socket *head, int conns /* * The accept socket may be tearing down but we just * won a race on the ACCEPT_LOCK. + * However, if sctp_peeloff() is called on a 1-to-many + * style socket, the SO_ACCEPTCONN doesn't need to be set. */ - if (!(head->so_options & SO_ACCEPTCONN)) { + if (!(head->so_options & SO_ACCEPTCONN) && + ((head->so_proto->pr_protocol != IPPROTO_SCTP) || + (head->so_type != SOCK_SEQPACKET))) { SOCK_LOCK(so); so->so_head = NULL; sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */ Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Sun Jul 7 16:16:32 2013 (r252967) +++ stable/9/sys/kern/uipc_syscalls.c Sun Jul 7 16:25:39 2013 (r252968) @@ -2372,8 +2372,10 @@ sys_sctp_peeloff(td, uap) CURVNET_SET(head->so_vnet); so = sonewconn(head, SS_ISCONNECTED); - if (so == NULL) + if (so == NULL) { + error = ENOMEM; goto noconnection; + } /* * Before changing the flags on the socket, we have to bump the * reference count. Otherwise, if the protocol calls sofree(), From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:29:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9C138AF8; Sun, 7 Jul 2013 16:29:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8E46E1AD1; Sun, 7 Jul 2013 16:29:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GTGbu053817; Sun, 7 Jul 2013 16:29:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GTGCK053816; Sun, 7 Jul 2013 16:29:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071629.r67GTGCK053816@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:29:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252969 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:29:16 -0000 Author: tuexen Date: Sun Jul 7 16:29:16 2013 New Revision: 252969 URL: http://svnweb.freebsd.org/changeset/base/252969 Log: MFC r248953: Add a macro for checking for IPv4 link local addresses. Modified: stable/9/sys/netinet/sctp_constants.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_constants.h ============================================================================== --- stable/9/sys/netinet/sctp_constants.h Sun Jul 7 16:25:39 2013 (r252968) +++ stable/9/sys/netinet/sctp_constants.h Sun Jul 7 16:29:16 2013 (r252969) @@ -997,6 +997,10 @@ __FBSDID("$FreeBSD$"); (((uint8_t *)&(a)->s_addr)[2] == 0) && \ (((uint8_t *)&(a)->s_addr)[3] == 1)) +#define IN4_ISLINKLOCAL_ADDRESS(a) \ + ((((uint8_t *)&(a)->s_addr)[0] == 169) && \ + (((uint8_t *)&(a)->s_addr)[1] == 254)) + #if defined(_KERNEL) #define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x)) From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:31:08 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 28C0FC33; Sun, 7 Jul 2013 16:31:08 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 097941ADD; Sun, 7 Jul 2013 16:31:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GV81f055744; Sun, 7 Jul 2013 16:31:08 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GV8lq055743; Sun, 7 Jul 2013 16:31:08 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071631.r67GV8lq055743@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:31:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252970 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:31:08 -0000 Author: tuexen Date: Sun Jul 7 16:31:07 2013 New Revision: 252970 URL: http://svnweb.freebsd.org/changeset/base/252970 Log: MFC r249333: Remove the number of addresses restriction from sctp_connectx(). Remove unused code. While there, do some cleanup of the code. Modified: stable/9/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 16:29:16 2013 (r252969) +++ stable/9/lib/libc/net/sctp_sys_calls.c Sun Jul 7 16:31:07 2013 (r252970) @@ -48,8 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #ifndef IN6_IS_ADDR_V4MAPPED #define IN6_IS_ADDR_V4MAPPED(a) \ ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ @@ -57,77 +55,8 @@ __FBSDID("$FreeBSD$"); (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) #endif - -#define SCTP_CONTROL_VEC_SIZE_SND 8192 #define SCTP_CONTROL_VEC_SIZE_RCV 16384 -#define SCTP_STACK_BUF_SIZE 2048 - -#ifdef SCTP_DEBUG_PRINT_ADDRESS - -#define SCTP_STRING_BUF_SZ 256 - -static void -SCTPPrintAnAddress(struct sockaddr *a) -{ - char stringToPrint[SCTP_STRING_BUF_SZ]; - u_short prt; - char *srcaddr, *txt; - - if (a == NULL) { - printf("NULL\n"); - return; - } - if (a->sa_family == AF_INET) { - srcaddr = (char *)&((struct sockaddr_in *)a)->sin_addr; - txt = "IPv4 Address: "; - prt = ntohs(((struct sockaddr_in *)a)->sin_port); - } else if (a->sa_family == AF_INET6) { - srcaddr = (char *)&((struct sockaddr_in6 *)a)->sin6_addr; - prt = ntohs(((struct sockaddr_in6 *)a)->sin6_port); - txt = "IPv6 Address: "; - } else if (a->sa_family == AF_LINK) { - int i; - char tbuf[SCTP_STRING_BUF_SZ]; - u_char adbuf[SCTP_STRING_BUF_SZ]; - struct sockaddr_dl *dl; - - dl = (struct sockaddr_dl *)a; - strncpy(tbuf, dl->sdl_data, dl->sdl_nlen); - tbuf[dl->sdl_nlen] = 0; - printf("Intf:%s (len:%d)Interface index:%d type:%x(%d) ll-len:%d ", - tbuf, - dl->sdl_nlen, - dl->sdl_index, - dl->sdl_type, - dl->sdl_type, - dl->sdl_alen - ); - memcpy(adbuf, LLADDR(dl), dl->sdl_alen); - for (i = 0; i < dl->sdl_alen; i++) { - printf("%2.2x", adbuf[i]); - if (i < (dl->sdl_alen - 1)) - printf(":"); - } - printf("\n"); - return; - } else { - return; - } - if (inet_ntop(a->sa_family, srcaddr, stringToPrint, sizeof(stringToPrint))) { - if (a->sa_family == AF_INET6) { - printf("%s%s:%d scope:%d\n", - txt, stringToPrint, prt, - ((struct sockaddr_in6 *)a)->sin6_scope_id); - } else { - printf("%s%s:%d\n", txt, stringToPrint, prt); - } - - } else { - printf("%s unprintable?\n", txt); - } -} -#endif /* SCTP_DEBUG_PRINT_ADDRESS */ static void in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) @@ -171,11 +100,10 @@ int sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt, sctp_assoc_t * id) { - char buf[SCTP_STACK_BUF_SIZE]; + char *buf; int i, ret, cnt, *aa; char *cpto; const struct sockaddr *at; - sctp_assoc_t *p_id; size_t len = sizeof(int); /* validate the address count and list */ @@ -183,24 +111,29 @@ sctp_connectx(int sd, const struct socka errno = EINVAL; return (-1); } + if ((buf = malloc(sizeof(int) + (size_t)addrcnt * sizeof(struct sockaddr_in6))) == NULL) { + errno = E2BIG; + return (-1); + } at = addrs; cnt = 0; - cpto = ((caddr_t)buf + sizeof(int)); + cpto = buf + sizeof(int); /* validate all the addresses and get the size */ for (i = 0; i < addrcnt; i++) { switch (at->sa_family) { case AF_INET: if (at->sa_len != sizeof(struct sockaddr_in)) { + free(buf); errno = EINVAL; return (-1); } memcpy(cpto, at, sizeof(struct sockaddr_in)); cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in)); len += sizeof(struct sockaddr_in); - at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in)); break; case AF_INET6: if (at->sa_len != sizeof(struct sockaddr_in6)) { + free(buf); errno = EINVAL; return (-1); } @@ -213,31 +146,20 @@ sctp_connectx(int sd, const struct socka cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6)); len += sizeof(struct sockaddr_in6); } - at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in6)); break; default: + free(buf); errno = EINVAL; return (-1); } - if (len > (sizeof(buf) - sizeof(int))) { - /* Never enough memory */ - errno = E2BIG; - return (-1); - } - cnt++; - } - /* do we have any? */ - if (cnt == 0) { - errno = EINVAL; - return (-1); + at = (struct sockaddr *)((caddr_t)at + at->sa_len); } aa = (int *)buf; - *aa = cnt; + *aa = addrcnt; ret = setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X, (void *)buf, (socklen_t) len); - if ((ret == 0) && id) { - p_id = (sctp_assoc_t *) buf; - *id = *p_id; + if ((ret == 0) && (id != NULL)) { + *id = *(sctp_assoc_t *) buf; } return (ret); } @@ -345,7 +267,6 @@ sctp_bindx(int sd, struct sockaddr *addr return (0); } - int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) { @@ -471,9 +392,9 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, void sctp_freepaddrs(struct sockaddr *addrs) { - /* Take away the hidden association id */ void *fr_addr; + /* Take away the hidden association id */ fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t)); /* Now free it */ free(fr_addr); @@ -534,15 +455,14 @@ sctp_getladdrs(int sd, sctp_assoc_t id, void sctp_freeladdrs(struct sockaddr *addrs) { - /* Take away the hidden association id */ void *fr_addr; + /* Take away the hidden association id */ fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t)); /* Now free it */ free(fr_addr); } - ssize_t sctp_sendmsg(int s, const void *data, @@ -568,11 +488,10 @@ sctp_sendmsg(int s, return (syscall(SYS_sctp_generic_sendmsg, s, data, len, to, tolen, &sinfo, 0)); #else - ssize_t sz; struct msghdr msg; - struct sctp_sndrcvinfo *s_info; + struct sctp_sndrcvinfo *sinfo; struct iovec iov; - char controlVector[SCTP_CONTROL_VEC_SIZE_RCV]; + char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))]; struct cmsghdr *cmsg; struct sockaddr *who = NULL; union { @@ -585,8 +504,9 @@ sctp_sendmsg(int s, errno = EINVAL; return (-1); } - if (to && (tolen > 0)) { - if (to->sa_family == AF_INET) { + if ((to != NULL) && (tolen > 0)) { + switch (to->sa_family) { + case AF_INET: if (tolen != sizeof(struct sockaddr_in)) { errno = EINVAL; return (-1); @@ -598,7 +518,8 @@ sctp_sendmsg(int s, } memcpy(&addr, to, sizeof(struct sockaddr_in)); addr.in.sin_len = sizeof(struct sockaddr_in); - } else if (to->sa_family == AF_INET6) { + break; + case AF_INET6: if (tolen != sizeof(struct sockaddr_in6)) { errno = EINVAL; return (-1); @@ -610,7 +531,8 @@ sctp_sendmsg(int s, } memcpy(&addr, to, sizeof(struct sockaddr_in6)); addr.in6.sin6_len = sizeof(struct sockaddr_in6); - } else { + break; + default: errno = EAFNOSUPPORT; return (-1); } @@ -628,26 +550,21 @@ sctp_sendmsg(int s, } msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = (caddr_t)controlVector; - - cmsg = (struct cmsghdr *)controlVector; - + msg.msg_control = cmsgbuf; + msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); - s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); - - s_info->sinfo_stream = stream_no; - s_info->sinfo_ssn = 0; - s_info->sinfo_flags = flags; - s_info->sinfo_ppid = ppid; - s_info->sinfo_context = context; - s_info->sinfo_assoc_id = 0; - s_info->sinfo_timetolive = timetolive; - errno = 0; - msg.msg_controllen = cmsg->cmsg_len; - sz = sendmsg(s, &msg, 0); - return (sz); + sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); + sinfo->sinfo_stream = stream_no; + sinfo->sinfo_ssn = 0; + sinfo->sinfo_flags = flags; + sinfo->sinfo_ppid = ppid; + sinfo->sinfo_context = context; + sinfo->sinfo_assoc_id = 0; + sinfo->sinfo_timetolive = timetolive; + return (sendmsg(s, &msg, 0)); #endif } @@ -662,12 +579,11 @@ sctp_getassocid(int sd, struct sockaddr siz = sizeof(sp); memset(&sp, 0, sizeof(sp)); memcpy((caddr_t)&sp.spinfo_address, sa, sa->sa_len); - errno = 0; if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_PEER_ADDR_INFO, &sp, &siz) != 0) { + /* We depend on the fact that 0 can never be returned */ return ((sctp_assoc_t) 0); } - /* We depend on the fact that 0 can never be returned */ return (sp.spinfo_assoc_id); } @@ -683,11 +599,9 @@ sctp_send(int sd, const void *data, size return (syscall(SYS_sctp_generic_sendmsg, sd, data, len, to, 0, sinfo, flags)); #else - ssize_t sz; struct msghdr msg; struct iovec iov; - struct sctp_sndrcvinfo *s_info; - char controlVector[SCTP_CONTROL_VEC_SIZE_SND]; + char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))]; struct cmsghdr *cmsg; if (sinfo == NULL) { @@ -697,24 +611,18 @@ sctp_send(int sd, const void *data, size iov.iov_base = (char *)data; iov.iov_len = len; - msg.msg_name = 0; + msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = (caddr_t)controlVector; - - cmsg = (struct cmsghdr *)controlVector; - + msg.msg_control = cmsgbuf; + msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); - s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); - /* copy in the data */ - *s_info = *sinfo; - errno = 0; - msg.msg_controllen = cmsg->cmsg_len; - sz = sendmsg(sd, &msg, flags); - return (sz); + memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo)); + return (sendmsg(sd, &msg, flags)); #endif } @@ -856,11 +764,10 @@ sctp_recvmsg(int s, return (syscall(SYS_sctp_generic_recvmsg, s, &iov, 1, from, fromlen, sinfo, msg_flags)); #else - struct sctp_sndrcvinfo *s_info; ssize_t sz; struct msghdr msg; struct iovec iov; - char controlVector[SCTP_CONTROL_VEC_SIZE_RCV]; + char cmsgbuf[SCTP_CONTROL_VEC_SIZE_RCV]; struct cmsghdr *cmsg; if (msg_flags == NULL) { @@ -877,52 +784,38 @@ sctp_recvmsg(int s, msg.msg_namelen = *fromlen; msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = (caddr_t)controlVector; - msg.msg_controllen = sizeof(controlVector); - errno = 0; + msg.msg_control = cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); sz = recvmsg(s, &msg, *msg_flags); *msg_flags = msg.msg_flags; if (sz <= 0) { return (sz); } - s_info = NULL; if (sinfo) { sinfo->sinfo_assoc_id = 0; } - if ((msg.msg_controllen) && sinfo) { + if ((msg.msg_controllen > 0) && (sinfo != NULL)) { /* * parse through and see if we find the sctp_sndrcvinfo (if * the user wants it). */ - cmsg = (struct cmsghdr *)controlVector; - while (cmsg) { - if ((cmsg->cmsg_len == 0) || (cmsg->cmsg_len > msg.msg_controllen)) { + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if (cmsg->cmsg_level != IPPROTO_SCTP) { + continue; + } + if (cmsg->cmsg_type == SCTP_SNDRCV) { + memcpy(sinfo, CMSG_DATA(cmsg), sizeof(struct sctp_sndrcvinfo)); break; } - if (cmsg->cmsg_level == IPPROTO_SCTP) { - if (cmsg->cmsg_type == SCTP_SNDRCV) { - /* Got it */ - s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); - /* Copy it to the user */ - if (sinfo) - *sinfo = *s_info; - break; - } else if (cmsg->cmsg_type == SCTP_EXTRCV) { - /* - * Got it, presumably the user has - * asked for this extra info, so the - * structure holds more room :-D - */ - s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); - /* Copy it to the user */ - if (sinfo) { - memcpy(sinfo, s_info, sizeof(struct sctp_extrcvinfo)); - } - break; - - } + if (cmsg->cmsg_type == SCTP_EXTRCV) { + /* + * Let's hope that the user provided enough + * enough memory. At least he asked for more + * information. + */ + memcpy(sinfo, CMSG_DATA(cmsg), sizeof(struct sctp_extrcvinfo)); + break; } - cmsg = CMSG_NXTHDR(&msg, cmsg); } } return (sz); @@ -940,10 +833,10 @@ sctp_recvv(int sd, unsigned int *infotype, int *flags) { - char ctlbuf[SCTP_CONTROL_VEC_SIZE_RCV]; + char cmsgbuf[SCTP_CONTROL_VEC_SIZE_RCV]; struct msghdr msg; struct cmsghdr *cmsg; - ssize_t n; + ssize_t ret; struct sctp_rcvinfo *rcvinfo; struct sctp_nxtinfo *nxtinfo; @@ -964,12 +857,11 @@ sctp_recvv(int sd, } msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = iovlen; - msg.msg_control = ctlbuf; - msg.msg_controllen = sizeof(ctlbuf); - errno = 0; - n = recvmsg(sd, &msg, *flags); + msg.msg_control = cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); + ret = recvmsg(sd, &msg, *flags); *flags = msg.msg_flags; - if ((n > 0) && + if ((ret > 0) && (msg.msg_controllen > 0) && (infotype != NULL) && (infolen != NULL) && @@ -982,41 +874,44 @@ sctp_recvv(int sd, } if (cmsg->cmsg_type == SCTP_RCVINFO) { rcvinfo = (struct sctp_rcvinfo *)CMSG_DATA(cmsg); + if (nxtinfo != NULL) { + break; + } else { + continue; + } } if (cmsg->cmsg_type == SCTP_NXTINFO) { nxtinfo = (struct sctp_nxtinfo *)CMSG_DATA(cmsg); - } - if (rcvinfo && nxtinfo) { - break; + if (rcvinfo != NULL) { + break; + } else { + continue; + } } } - if (rcvinfo) { - if (nxtinfo) { - if (*infolen >= sizeof(struct sctp_recvv_rn)) { - struct sctp_recvv_rn *rn_info; - - rn_info = (struct sctp_recvv_rn *)info; - rn_info->recvv_rcvinfo = *rcvinfo; - rn_info->recvv_nxtinfo = *nxtinfo; - *infolen = (socklen_t) sizeof(struct sctp_recvv_rn); - *infotype = SCTP_RECVV_RN; - } - } else { - if (*infolen >= sizeof(struct sctp_rcvinfo)) { - memcpy(info, rcvinfo, sizeof(struct sctp_rcvinfo)); - *infolen = (socklen_t) sizeof(struct sctp_rcvinfo); - *infotype = SCTP_RECVV_RCVINFO; - } + if (rcvinfo != NULL) { + if ((nxtinfo != NULL) && (*infolen >= sizeof(struct sctp_recvv_rn))) { + struct sctp_recvv_rn *rn_info; + + rn_info = (struct sctp_recvv_rn *)info; + rn_info->recvv_rcvinfo = *rcvinfo; + rn_info->recvv_nxtinfo = *nxtinfo; + *infolen = (socklen_t) sizeof(struct sctp_recvv_rn); + *infotype = SCTP_RECVV_RN; + } else if (*infolen >= sizeof(struct sctp_rcvinfo)) { + memcpy(info, rcvinfo, sizeof(struct sctp_rcvinfo)); + *infolen = (socklen_t) sizeof(struct sctp_rcvinfo); + *infotype = SCTP_RECVV_RCVINFO; } - } else if (nxtinfo) { - if (*infolen >= sizeof(struct sctp_rcvinfo)) { + } else if (nxtinfo != NULL) { + if (*infolen >= sizeof(struct sctp_nxtinfo)) { memcpy(info, nxtinfo, sizeof(struct sctp_nxtinfo)); *infolen = (socklen_t) sizeof(struct sctp_nxtinfo); *infotype = SCTP_RECVV_NXTINFO; } } } - return (n); + return (ret); } ssize_t @@ -1241,7 +1136,4 @@ sctp_peeloff(int sd, sctp_assoc_t assoc_ #endif - -#undef SCTP_CONTROL_VEC_SIZE_SND #undef SCTP_CONTROL_VEC_SIZE_RCV -#undef SCTP_STACK_BUF_SIZE From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:51:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BB0BE316; Sun, 7 Jul 2013 16:51:18 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 932EA1BA8; Sun, 7 Jul 2013 16:51:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GpIRr061514; Sun, 7 Jul 2013 16:51:18 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GpIRW061512; Sun, 7 Jul 2013 16:51:18 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071651.r67GpIRW061512@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:51:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252971 - in stable/9/sys: netinet netinet6 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:51:18 -0000 Author: tuexen Date: Sun Jul 7 16:51:17 2013 New Revision: 252971 URL: http://svnweb.freebsd.org/changeset/base/252971 Log: MFC r250466: Honor the net.inet6.ip6.v6only sysctl variable and the IPV6_V6ONLY socket option for SCTP sockets in the same way as for UDP or TCP sockets. Modified: stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet6/sctp6_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:31:07 2013 (r252970) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 16:51:17 2013 (r252971) @@ -2376,8 +2376,13 @@ sctp_inpcb_alloc(struct socket *so, uint inp->sctp_socket = so; inp->ip_inp.inp.inp_socket = so; #ifdef INET6 - if (MODULE_GLOBAL(ip6_auto_flowlabel)) { - inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL; + if (INP_SOCKAF(so) == AF_INET6) { + if (MODULE_GLOBAL(ip6_auto_flowlabel)) { + inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL; + } + if (MODULE_GLOBAL(ip6_v6only)) { + inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY; + } } #endif inp->sctp_associd_counter = 1; Modified: stable/9/sys/netinet6/sctp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 7 16:31:07 2013 (r252970) +++ stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 7 16:51:17 2013 (r252971) @@ -787,18 +787,11 @@ sctp6_send(struct socket *so, int flags, } } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - if (!MODULE_GLOBAL(ip6_v6only)) { - struct sockaddr_in sin; + struct sockaddr_in sin; - /* convert v4-mapped into v4 addr and send */ - in6_sin6_2_sin(&sin, sin6); - return (sctp_sendm(so, flags, m, (struct sockaddr *)&sin, - control, p)); - } else { - /* mapped addresses aren't enabled */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); - return (EINVAL); - } + /* convert v4-mapped into v4 addr and send */ + in6_sin6_2_sin(&sin, sin6); + return (sctp_sendm(so, flags, m, (struct sockaddr *)&sin, control, p)); } #endif /* INET */ connected_type: @@ -932,17 +925,9 @@ sctp6_connect(struct socket *so, struct } } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - if (!MODULE_GLOBAL(ip6_v6only)) { - /* convert v4-mapped into v4 addr */ - in6_sin6_2_sin((struct sockaddr_in *)&ss, sin6); - addr = (struct sockaddr *)&ss; - } else { - /* mapped addresses aren't enabled */ - SCTP_INP_RUNLOCK(inp); - SCTP_ASOC_CREATE_UNLOCK(inp); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); - return (EINVAL); - } + /* convert v4-mapped into v4 addr */ + in6_sin6_2_sin((struct sockaddr_in *)&ss, sin6); + addr = (struct sockaddr *)&ss; } #endif /* INET */ /* Now do we connect? */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:53:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3496352F; Sun, 7 Jul 2013 16:53:45 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1F8F31BCD; Sun, 7 Jul 2013 16:53:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GriJu061819; Sun, 7 Jul 2013 16:53:44 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GriEK061818; Sun, 7 Jul 2013 16:53:44 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071653.r67GriEK061818@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:53:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252972 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:53:45 -0000 Author: tuexen Date: Sun Jul 7 16:53:44 2013 New Revision: 252972 URL: http://svnweb.freebsd.org/changeset/base/252972 Log: MFC r250754: Don't send an ABORT chunk with verification 0. 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 Jul 7 16:51:17 2013 (r252971) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 7 16:53:44 2013 (r252972) @@ -10669,6 +10669,7 @@ sctp_send_abort_tcb(struct sctp_tcb *stc struct sctp_abort_chunk *abort; struct sctp_auth_chunk *auth = NULL; struct sctp_nets *net; + uint32_t vtag; uint32_t auth_offset = 0; uint16_t cause_len, chunk_len, padding_len; @@ -10724,7 +10725,14 @@ sctp_send_abort_tcb(struct sctp_tcb *stc /* Fill in the ABORT chunk header. */ abort = mtod(m_abort, struct sctp_abort_chunk *); abort->ch.chunk_type = SCTP_ABORT_ASSOCIATION; - abort->ch.chunk_flags = 0; + if (stcb->asoc.peer_vtag == 0) { + /* This happens iff the assoc is in COOKIE-WAIT state. */ + vtag = stcb->asoc.my_vtag; + abort->ch.chunk_flags = SCTP_HAD_NO_TCB; + } else { + vtag = stcb->asoc.peer_vtag; + abort->ch.chunk_flags = 0; + } abort->ch.chunk_length = htons(chunk_len); /* Add padding, if necessary. */ if (padding_len > 0) { @@ -10736,7 +10744,7 @@ sctp_send_abort_tcb(struct sctp_tcb *stc (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net, (struct sockaddr *)&net->ro._l_addr, m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0, - stcb->sctp_ep->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), + stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag), stcb->asoc.primary_destination->port, NULL, 0, 0, so_locked); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:55:57 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C8648670; Sun, 7 Jul 2013 16:55:57 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BA8551BE0; Sun, 7 Jul 2013 16:55:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GtvSo062180; Sun, 7 Jul 2013 16:55:57 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GtvaE062179; Sun, 7 Jul 2013 16:55:57 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071655.r67GtvaE062179@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:55:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252973 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:55:57 -0000 Author: tuexen Date: Sun Jul 7 16:55:57 2013 New Revision: 252973 URL: http://svnweb.freebsd.org/changeset/base/252973 Log: MFC r250756: Set errno to ETIMEDOUT if an SCTP association times out during setup. 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 Jul 7 16:53:44 2013 (r252972) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 16:55:57 2013 (r252973) @@ -2688,8 +2688,14 @@ set_error: stcb->sctp_socket->so_error = ECONNRESET; } } else { - SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNABORTED); - stcb->sctp_socket->so_error = ECONNABORTED; + if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) || + (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) { + SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ETIMEDOUT); + stcb->sctp_socket->so_error = ETIMEDOUT; + } else { + SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNABORTED); + stcb->sctp_socket->so_error = ECONNABORTED; + } } } /* Wake ANY sleepers */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 16:59:33 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C95F77E0; Sun, 7 Jul 2013 16:59:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A16051BF7; Sun, 7 Jul 2013 16:59:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GxXgc062615; Sun, 7 Jul 2013 16:59:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GxX4k062614; Sun, 7 Jul 2013 16:59:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071659.r67GxX4k062614@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:59:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252974 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 16:59:33 -0000 Author: tuexen Date: Sun Jul 7 16:59:33 2013 New Revision: 252974 URL: http://svnweb.freebsd.org/changeset/base/252974 Log: MFC r251054: Remove redundant checks. 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 Jul 7 16:55:57 2013 (r252973) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 16:59:33 2013 (r252974) @@ -3536,8 +3536,8 @@ sctp_ulp_notify(uint32_t notification, s if (stcb->sctp_socket->so_rcv.sb_state & SBS_CANTRCVMORE) { return; } - if (stcb && ((stcb->asoc.state & SCTP_STATE_COOKIE_WAIT) || - (stcb->asoc.state & SCTP_STATE_COOKIE_ECHOED))) { + if ((stcb->asoc.state & SCTP_STATE_COOKIE_WAIT) || + (stcb->asoc.state & SCTP_STATE_COOKIE_ECHOED)) { if ((notification == SCTP_NOTIFY_INTERFACE_DOWN) || (notification == SCTP_NOTIFY_INTERFACE_UP) || (notification == SCTP_NOTIFY_INTERFACE_CONFIRMED)) { @@ -3611,16 +3611,16 @@ sctp_ulp_notify(uint32_t notification, s break; } case SCTP_NOTIFY_ASSOC_LOC_ABORTED: - if ((stcb) && (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) || - ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED))) { + if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) || + ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) { sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 0, so_locked); } else { sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 0, so_locked); } break; case SCTP_NOTIFY_ASSOC_REM_ABORTED: - if ((stcb) && (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) || - ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED))) { + if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) || + ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) { sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 1, so_locked); } else { sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 1, so_locked); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 17:01:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 599AC95A; Sun, 7 Jul 2013 17:01:36 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4BAB11C11; Sun, 7 Jul 2013 17:01:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67H1a7e064733; Sun, 7 Jul 2013 17:01:36 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67H1ZvW064731; Sun, 7 Jul 2013 17:01:35 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071701.r67H1ZvW064731@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 17:01:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252975 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 17:01:36 -0000 Author: tuexen Date: Sun Jul 7 17:01:35 2013 New Revision: 252975 URL: http://svnweb.freebsd.org/changeset/base/252975 Log: MFC r251248: Use LIST_EMPTY when appropriate. 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 Jul 7 16:59:33 2013 (r252974) +++ stable/9/sys/netinet/sctputil.c Sun Jul 7 17:01:35 2013 (r252975) @@ -3973,7 +3973,7 @@ sctp_abort_an_association(struct sctp_in if (stcb == NULL) { /* Got to have a TCB */ if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { - if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { + if (LIST_EMPTY(&inp->sctp_asoc_list)) { sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_DIRECTLY_NOCMPSET); } @@ -4028,7 +4028,7 @@ sctp_handle_ootb(struct mbuf *m, int iph SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue); /* Generate a TO address for future reference */ if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { - if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { + if (LIST_EMPTY(&inp->sctp_asoc_list)) { sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_DIRECTLY_NOCMPSET); } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 17:04:24 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 95A91BB4; Sun, 7 Jul 2013 17:04:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 876E91C30; Sun, 7 Jul 2013 17:04:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67H4OPV065292; Sun, 7 Jul 2013 17:04:24 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67H4NWq065288; Sun, 7 Jul 2013 17:04:23 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071704.r67H4NWq065288@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 17:04:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252976 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 17:04:24 -0000 Author: tuexen Date: Sun Jul 7 17:04:23 2013 New Revision: 252976 URL: http://svnweb.freebsd.org/changeset/base/252976 Log: MFC r252585: Code cleanups. Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_indata.h stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_pcb.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 7 17:01:35 2013 (r252975) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 7 17:04:23 2013 (r252976) @@ -1729,7 +1729,6 @@ sctp_process_a_data_chunk(struct sctp_tc sctp_alloc_a_readq(stcb, control); sctp_build_readq_entry_mac(control, stcb, asoc->context, net, tsn, protocol_id, - stcb->asoc.context, strmno, strmseq, chunk_flags, dmbuf); @@ -1857,7 +1856,6 @@ failed_pdapi_express_del: sctp_alloc_a_readq(stcb, control); sctp_build_readq_entry_mac(control, stcb, asoc->context, net, tsn, protocol_id, - stcb->asoc.context, strmno, strmseq, chunk_flags, dmbuf); Modified: stable/9/sys/netinet/sctp_indata.h ============================================================================== --- stable/9/sys/netinet/sctp_indata.h Sun Jul 7 17:01:35 2013 (r252975) +++ stable/9/sys/netinet/sctp_indata.h Sun Jul 7 17:04:23 2013 (r252976) @@ -47,14 +47,14 @@ sctp_build_readq_entry(struct sctp_tcb * struct mbuf *dm); -#define sctp_build_readq_entry_mac(_ctl, in_it, a, net, tsn, ppid, context, stream_no, stream_seq, flags, dm) do { \ +#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, stream_no, stream_seq, flags, dm) do { \ if (_ctl) { \ atomic_add_int(&((net)->ref_count), 1); \ (_ctl)->sinfo_stream = stream_no; \ (_ctl)->sinfo_ssn = stream_seq; \ (_ctl)->sinfo_flags = (flags << 8); \ (_ctl)->sinfo_ppid = ppid; \ - (_ctl)->sinfo_context = a; \ + (_ctl)->sinfo_context = context; \ (_ctl)->sinfo_timetolive = 0; \ (_ctl)->sinfo_tsn = tsn; \ (_ctl)->sinfo_cumtsn = tsn; \ Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:01:35 2013 (r252975) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:04:23 2013 (r252976) @@ -1028,12 +1028,13 @@ sctp_handle_shutdown_ack(struct sctp_shu SCTP_SOCKET_UNLOCK(so, 1); #endif } - /* are the queues empty? */ +#ifdef INVARIANTS if (!TAILQ_EMPTY(&asoc->send_queue) || !TAILQ_EMPTY(&asoc->sent_queue) || !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) { - sctp_report_all_outbound(stcb, 0, 0, SCTP_SO_NOT_LOCKED); + panic("Queues are not empty when handling SHUTDOWN-ACK"); } +#endif /* stop the timer */ sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_9); /* send SHUTDOWN-COMPLETE */ @@ -1875,9 +1876,14 @@ sctp_process_cookie_existing(struct mbuf cookie->tie_tag_peer_vtag != 0) { struct sctpasochead *head; +#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + struct socket *so; + +#endif + if (asoc->peer_supports_nat) { /* - * This is a gross gross hack. just call the + * This is a gross gross hack. Just call the * cookie_new code since we are allowing a duplicate * association. I hope this works... */ @@ -1939,6 +1945,10 @@ sctp_process_cookie_existing(struct mbuf asoc->mapping_array_size); } SCTP_TCB_UNLOCK(stcb); +#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + so = SCTP_INP_SO(stcb->sctp_ep); + SCTP_SOCKET_LOCK(so, 1); +#endif SCTP_INP_INFO_WLOCK(); SCTP_INP_WLOCK(stcb->sctp_ep); SCTP_TCB_LOCK(stcb); @@ -1946,7 +1956,7 @@ sctp_process_cookie_existing(struct mbuf /* send up all the data */ SCTP_TCB_SEND_LOCK(stcb); - sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_NOT_LOCKED); + sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_LOCKED); for (i = 0; i < stcb->asoc.streamoutcnt; i++) { stcb->asoc.strmout[i].chunks_on_queues = 0; stcb->asoc.strmout[i].stream_no = i; @@ -1968,11 +1978,15 @@ sctp_process_cookie_existing(struct mbuf */ LIST_INSERT_HEAD(head, stcb, sctp_asocs); - /* process the INIT info (peer's info) */ SCTP_TCB_SEND_UNLOCK(stcb); SCTP_INP_WUNLOCK(stcb->sctp_ep); SCTP_INP_INFO_WUNLOCK(); - +#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + SCTP_SOCKET_UNLOCK(so, 1); +#endif + asoc->total_flight = 0; + asoc->total_flight_count = 0; + /* process the INIT info (peer's info) */ retval = sctp_process_init(init_cp, stcb); if (retval < 0) { if (how_indx < sizeof(asoc->cookie_how)) @@ -3196,13 +3210,14 @@ sctp_handle_shutdown_complete(struct sct /* notify upper layer protocol */ if (stcb->sctp_socket) { sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); - /* are the queues empty? they should be */ - if (!TAILQ_EMPTY(&asoc->send_queue) || - !TAILQ_EMPTY(&asoc->sent_queue) || - !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) { - sctp_report_all_outbound(stcb, 0, 0, SCTP_SO_NOT_LOCKED); - } } +#ifdef INVARIANTS + if (!TAILQ_EMPTY(&asoc->send_queue) || + !TAILQ_EMPTY(&asoc->sent_queue) || + !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) { + panic("Queues are not empty when handling SHUTDOWN-COMPLETE"); + } +#endif /* stop the timer */ sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_22); SCTP_STAT_INCR_COUNTER32(sctps_shutdown); @@ -3491,18 +3506,13 @@ sctp_reset_in_stream(struct sctp_tcb *st } static void -sctp_reset_out_streams(struct sctp_tcb *stcb, int number_entries, uint16_t * list) +sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list) { - int i; + uint32_t i; + uint16_t temp; - if (number_entries == 0) { - for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - stcb->asoc.strmout[i].next_sequence_send = 0; - } - } else if (number_entries) { + if (number_entries > 0) { for (i = 0; i < number_entries; i++) { - uint16_t temp; - temp = ntohs(list[i]); if (temp >= stcb->asoc.streamoutcnt) { /* no such stream */ @@ -3510,6 +3520,10 @@ sctp_reset_out_streams(struct sctp_tcb * } stcb->asoc.strmout[temp].next_sequence_send = 0; } + } else { + for (i = 0; i < stcb->asoc.streamoutcnt; i++) { + stcb->asoc.strmout[i].next_sequence_send = 0; + } } sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_SEND, stcb, number_entries, (void *)list, SCTP_SO_NOT_LOCKED); } @@ -3596,7 +3610,7 @@ sctp_handle_stream_reset_response(struct struct sctp_association *asoc = &stcb->asoc; struct sctp_tmit_chunk *chk; struct sctp_stream_reset_out_request *srparam; - int number_entries; + uint32_t number_entries; if (asoc->stream_reset_outstanding == 0) { /* duplicate */ Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 17:01:35 2013 (r252975) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 17:04:23 2013 (r252976) @@ -4451,23 +4451,21 @@ sctp_delete_from_timewait(uint32_t tag, int i; chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; - if (!LIST_EMPTY(chain)) { - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && - (twait_block->vtag_block[i].rport == rport)) { - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - found = 1; - break; - } - } - if (found) + LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { + for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { + if ((twait_block->vtag_block[i].v_tag == tag) && + (twait_block->vtag_block[i].lport == lport) && + (twait_block->vtag_block[i].rport == rport)) { + twait_block->vtag_block[i].tv_sec_at_expire = 0; + twait_block->vtag_block[i].v_tag = 0; + twait_block->vtag_block[i].lport = 0; + twait_block->vtag_block[i].rport = 0; + found = 1; break; + } } + if (found) + break; } } @@ -4481,19 +4479,17 @@ sctp_is_in_timewait(uint32_t tag, uint16 SCTP_INP_INFO_WLOCK(); chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; - if (!LIST_EMPTY(chain)) { - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && - (twait_block->vtag_block[i].rport == rport)) { - found = 1; - break; - } - } - if (found) + LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { + for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { + if ((twait_block->vtag_block[i].v_tag == tag) && + (twait_block->vtag_block[i].lport == lport) && + (twait_block->vtag_block[i].rport == rport)) { + found = 1; break; + } } + if (found) + break; } SCTP_INP_INFO_WUNLOCK(); return (found); @@ -4515,42 +4511,40 @@ sctp_add_vtag_to_timewait(uint32_t tag, (void)SCTP_GETTIME_TIMEVAL(&now); chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; set = 0; - if (!LIST_EMPTY(chain)) { + LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { /* Block(s) present, lets find space, and expire on the fly */ - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == 0) && - !set) { - twait_block->vtag_block[i].tv_sec_at_expire = - now.tv_sec + time; + for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { + if ((twait_block->vtag_block[i].v_tag == 0) && + !set) { + twait_block->vtag_block[i].tv_sec_at_expire = + now.tv_sec + time; + twait_block->vtag_block[i].v_tag = tag; + twait_block->vtag_block[i].lport = lport; + twait_block->vtag_block[i].rport = rport; + set = 1; + } else if ((twait_block->vtag_block[i].v_tag) && + ((long)twait_block->vtag_block[i].tv_sec_at_expire < now.tv_sec)) { + /* Audit expires this guy */ + twait_block->vtag_block[i].tv_sec_at_expire = 0; + twait_block->vtag_block[i].v_tag = 0; + twait_block->vtag_block[i].lport = 0; + twait_block->vtag_block[i].rport = 0; + if (set == 0) { + /* Reuse it for my new tag */ + twait_block->vtag_block[i].tv_sec_at_expire = now.tv_sec + time; twait_block->vtag_block[i].v_tag = tag; twait_block->vtag_block[i].lport = lport; twait_block->vtag_block[i].rport = rport; set = 1; - } else if ((twait_block->vtag_block[i].v_tag) && - ((long)twait_block->vtag_block[i].tv_sec_at_expire < now.tv_sec)) { - /* Audit expires this guy */ - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - if (set == 0) { - /* Reuse it for my new tag */ - twait_block->vtag_block[i].tv_sec_at_expire = now.tv_sec + time; - twait_block->vtag_block[i].v_tag = tag; - twait_block->vtag_block[i].lport = lport; - twait_block->vtag_block[i].rport = rport; - set = 1; - } } } - if (set) { - /* - * We only do up to the block where we can - * place our tag for audits - */ - break; - } + } + if (set) { + /* + * We only do up to the block where we can place our + * tag for audits + */ + break; } } /* Need to add a new block to chain */ @@ -6700,30 +6694,28 @@ skip_vtag_check: chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; /* Now what about timed wait ? */ - if (!LIST_EMPTY(chain)) { + LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { /* * Block(s) are present, lets see if we have this tag in the * list */ - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if (twait_block->vtag_block[i].v_tag == 0) { - /* not used */ - continue; - } else if ((long)twait_block->vtag_block[i].tv_sec_at_expire < - now->tv_sec) { - /* Audit expires this guy */ - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - } else if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && - (twait_block->vtag_block[i].rport == rport)) { - /* Bad tag, sorry :< */ - SCTP_INP_INFO_RUNLOCK(); - return (0); - } + for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { + if (twait_block->vtag_block[i].v_tag == 0) { + /* not used */ + continue; + } else if ((long)twait_block->vtag_block[i].tv_sec_at_expire < + now->tv_sec) { + /* Audit expires this guy */ + twait_block->vtag_block[i].tv_sec_at_expire = 0; + twait_block->vtag_block[i].v_tag = 0; + twait_block->vtag_block[i].lport = 0; + twait_block->vtag_block[i].rport = 0; + } else if ((twait_block->vtag_block[i].v_tag == tag) && + (twait_block->vtag_block[i].lport == lport) && + (twait_block->vtag_block[i].rport == rport)) { + /* Bad tag, sorry :< */ + SCTP_INP_INFO_RUNLOCK(); + return (0); } } } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 17:06:33 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 845ECCF7; Sun, 7 Jul 2013 17:06:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 767E61C40; Sun, 7 Jul 2013 17:06:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67H6XaU065697; Sun, 7 Jul 2013 17:06:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67H6XrS065696; Sun, 7 Jul 2013 17:06:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071706.r67H6XrS065696@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 17:06:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252977 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 17:06:33 -0000 Author: tuexen Date: Sun Jul 7 17:06:33 2013 New Revision: 252977 URL: http://svnweb.freebsd.org/changeset/base/252977 Log: MFC r252718: When processing an incoming ABORT, SHUTDOWN_COMPLETE or ERROR (NAT related) chunk, take always the T-bit into account, when checking the verification tag. Modified: stable/9/sys/netinet/sctp_input.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:04:23 2013 (r252976) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:06:33 2013 (r252977) @@ -4568,8 +4568,10 @@ __attribute__((noinline)) if ((ch->chunk_type == SCTP_ABORT_ASSOCIATION) || (ch->chunk_type == SCTP_SHUTDOWN_COMPLETE) || (ch->chunk_type == SCTP_PACKET_DROPPED)) { - if ((vtag_in == asoc->my_vtag) || - ((ch->chunk_flags & SCTP_HAD_NO_TCB) && + /* Take the T-bit always into account. */ + if ((((ch->chunk_flags & SCTP_HAD_NO_TCB) == 0) && + (vtag_in == asoc->my_vtag)) || + (((ch->chunk_flags & SCTP_HAD_NO_TCB) == SCTP_HAD_NO_TCB) && (vtag_in == asoc->peer_vtag))) { /* this is valid */ } else { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 17:09:01 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 05925E48; Sun, 7 Jul 2013 17:09:01 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EB5811C57; Sun, 7 Jul 2013 17:09:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67H90Tu066131; Sun, 7 Jul 2013 17:09:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67H8x1B066116; Sun, 7 Jul 2013 17:08:59 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071708.r67H8x1B066116@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 17:08:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252978 - stable/9/sys/netinet X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 17:09:01 -0000 Author: tuexen Date: Sun Jul 7 17:08:59 2013 New Revision: 252978 URL: http://svnweb.freebsd.org/changeset/base/252978 Log: MFC r252779: Fix a bug were only 2048 streams where usable even though more than 2048 streams were negotiated on the wire. While there, remove the hard coded limit of 2048 streams. Modified: stable/9/sys/netinet/sctp_constants.h stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_pcb.c stable/9/sys/netinet/sctp_sysctl.c stable/9/sys/netinet/sctp_sysctl.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_constants.h ============================================================================== --- stable/9/sys/netinet/sctp_constants.h Sun Jul 7 17:06:33 2013 (r252977) +++ stable/9/sys/netinet/sctp_constants.h Sun Jul 7 17:08:59 2013 (r252978) @@ -521,9 +521,6 @@ __FBSDID("$FreeBSD$"); /* How long a cookie lives in milli-seconds */ #define SCTP_DEFAULT_COOKIE_LIFE 60000 -/* resource limit of streams */ -#define MAX_SCTP_STREAMS 2048 - /* Maximum the mapping array will grow to (TSN mapping array) */ #define SCTP_MAPPING_ARRAY 512 @@ -658,6 +655,7 @@ __FBSDID("$FreeBSD$"); /* How many streams I request initally by default */ #define SCTP_OSTREAM_INITIAL 10 +#define SCTP_ISTREAM_INITIAL 2048 /* * How many smallest_mtu's need to increase before a window update sack is Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:06:33 2013 (r252977) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 7 17:08:59 2013 (r252978) @@ -389,9 +389,10 @@ sctp_process_init(struct sctp_init_chunk } SCTP_FREE(asoc->strmin, SCTP_M_STRMI); } - asoc->streamincnt = ntohs(init->num_outbound_streams); - if (asoc->streamincnt > MAX_SCTP_STREAMS) { - asoc->streamincnt = MAX_SCTP_STREAMS; + if (asoc->max_inbound_streams > ntohs(init->num_outbound_streams)) { + asoc->streamincnt = ntohs(init->num_outbound_streams); + } else { + asoc->streamincnt = asoc->max_inbound_streams; } SCTP_MALLOC(asoc->strmin, struct sctp_stream_in *, asoc->streamincnt * sizeof(struct sctp_stream_in), SCTP_M_STRMI); @@ -403,11 +404,6 @@ sctp_process_init(struct sctp_init_chunk for (i = 0; i < asoc->streamincnt; i++) { asoc->strmin[i].stream_no = i; asoc->strmin[i].last_sequence_delivered = 0xffff; - /* - * U-stream ranges will be set when the cookie is unpacked. - * Or for the INIT sender they are un set (if pr-sctp not - * supported) when the INIT-ACK arrives. - */ TAILQ_INIT(&asoc->strmin[i].inqueue); asoc->strmin[i].delivery_started = 0; } Modified: stable/9/sys/netinet/sctp_pcb.c ============================================================================== --- stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 17:06:33 2013 (r252977) +++ stable/9/sys/netinet/sctp_pcb.c Sun Jul 7 17:08:59 2013 (r252978) @@ -2503,9 +2503,6 @@ sctp_inpcb_alloc(struct socket *so, uint m->initial_rto = SCTP_BASE_SYSCTL(sctp_rto_initial_default); m->initial_init_rto_max = SCTP_BASE_SYSCTL(sctp_init_rto_max_default); m->sctp_sack_freq = SCTP_BASE_SYSCTL(sctp_sack_freq_default); - - m->max_open_streams_intome = MAX_SCTP_STREAMS; - m->max_init_times = SCTP_BASE_SYSCTL(sctp_init_rtx_max_default); m->max_send_times = SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default); m->def_net_failure = SCTP_BASE_SYSCTL(sctp_path_rtx_max_default); @@ -2517,6 +2514,7 @@ sctp_inpcb_alloc(struct socket *so, uint m->sctp_default_cc_module = SCTP_BASE_SYSCTL(sctp_default_cc_module); m->sctp_default_ss_module = SCTP_BASE_SYSCTL(sctp_default_ss_module); + m->max_open_streams_intome = SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default); /* number of streams to pre-open on a association */ m->pre_open_stream_count = SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default); Modified: stable/9/sys/netinet/sctp_sysctl.c ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 17:06:33 2013 (r252977) +++ stable/9/sys/netinet/sctp_sysctl.c Sun Jul 7 17:08:59 2013 (r252978) @@ -81,6 +81,7 @@ sctp_init_sysctls() SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT; SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT; SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT; + SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT; SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT; SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT; /* EY */ @@ -623,6 +624,7 @@ sysctl_sctp_check(SYSCTL_HANDLER_ARGS) RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_path_pf_threshold), SCTPCTL_PATH_PF_THRESHOLD_MIN, SCTPCTL_PATH_PF_THRESHOLD_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX); + RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), SCTPCTL_INCOMING_STREAMS_MIN, SCTPCTL_INCOMING_STREAMS_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX); /* EY */ @@ -965,6 +967,10 @@ SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUT &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU", SCTPCTL_ADD_MORE_ON_OUTPUT_DESC); +SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, incoming_streams, CTLTYPE_UINT | CTLFLAG_RW, + &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sysctl_sctp_check, "IU", + SCTPCTL_INCOMING_STREAMS_DESC); + SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_UINT | CTLFLAG_RW, &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU", SCTPCTL_OUTGOING_STREAMS_DESC); Modified: stable/9/sys/netinet/sctp_sysctl.h ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.h Sun Jul 7 17:06:33 2013 (r252977) +++ stable/9/sys/netinet/sctp_sysctl.h Sun Jul 7 17:08:59 2013 (r252978) @@ -72,6 +72,7 @@ struct sctp_sysctl { uint32_t sctp_path_rtx_max_default; uint32_t sctp_path_pf_threshold; uint32_t sctp_add_more_threshold; + uint32_t sctp_nr_incoming_streams_default; uint32_t sctp_nr_outgoing_streams_default; uint32_t sctp_cmt_on_off; uint32_t sctp_cmt_use_dac; @@ -322,6 +323,12 @@ struct sctp_sysctl { #define SCTPCTL_ADD_MORE_ON_OUTPUT_MAX 0xFFFFFFFF #define SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT SCTP_DEFAULT_ADD_MORE +/* incoming_streams: Default number of incoming streams */ +#define SCTPCTL_INCOMING_STREAMS_DESC "Default number of incoming streams" +#define SCTPCTL_INCOMING_STREAMS_MIN 1 +#define SCTPCTL_INCOMING_STREAMS_MAX 65535 +#define SCTPCTL_INCOMING_STREAMS_DEFAULT SCTP_ISTREAM_INITIAL + /* outgoing_streams: Default number of outgoing streams */ #define SCTPCTL_OUTGOING_STREAMS_DESC "Default number of outgoing streams" #define SCTPCTL_OUTGOING_STREAMS_MIN 1 From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 19:05:37 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5F84ACE6; Sun, 7 Jul 2013 19:05:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4FB1D10C9; Sun, 7 Jul 2013 19:05:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67J5bTm001669; Sun, 7 Jul 2013 19:05:37 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67J5aqL001660; Sun, 7 Jul 2013 19:05:36 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201307071905.r67J5aqL001660@svn.freebsd.org> From: Dimitry Andric Date: Sun, 7 Jul 2013 19:05:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252993 - in stable/9/contrib/llvm: include/llvm/CodeGen lib/CodeGen lib/CodeGen/SelectionDAG X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 19:05:37 -0000 Author: dim Date: Sun Jul 7 19:05:35 2013 New Revision: 252993 URL: http://svnweb.freebsd.org/changeset/base/252993 Log: MFC r252720: Pull in r185594 from llvm trunk: Add MachineBasicBlock::addLiveIn(). This function adds a live-in physical register to an MBB and ensures that it is copied to a virtual register immediately. Pull in r185615 from llvm trunk: Live-in copies go *after* EH_LABELs. This will soon be tested by exception handling working at all. Pull in r185617 from llvm trunk: Simplify landing pad lowering. Stop using the ISD::EXCEPTIONADDR and ISD::EHSELECTION when lowering landing pad arguments. These nodes were previously legalized into CopyFromReg nodes, but that never worked properly because the CopyFromReg node weren't guaranteed to be scheduled at the top of the basic block. This meant the exception pointer and selector registers could be clobbered before being copied to a virtual register. This patch copies the two physical registers to virtual registers at the beginning of the basic block, and lowers the landingpad instruction directly to two CopyFromReg nodes reading the *virtual* registers. This is safe because virtual registers don't get clobbered. A future patch will remove the ISD::EXCEPTIONADDR and ISD::EHSELECTION nodes. Together, these changes fix llvm PR 16038 ('qt4 webcore file results in "Bad machine code: Using an undefined physical register"'), and should make it possible again to compile the www/qt4-webkit port again on the i386 arch, without using a CPUTYPE=i686 or higher setting. Modified: stable/9/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h stable/9/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h stable/9/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Directory Properties: stable/9/contrib/llvm/ (props changed) Modified: stable/9/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h ============================================================================== --- stable/9/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h Sun Jul 7 19:04:10 2013 (r252992) +++ stable/9/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h Sun Jul 7 19:05:35 2013 (r252993) @@ -115,6 +115,11 @@ public: /// there's no other convenient place for it to live right now. std::vector > PHINodesToUpdate; + /// If the current MBB is a landing pad, the exception pointer and exception + /// selector registers are copied into these virtual registers by + /// SelectionDAGISel::PrepareEHLandingPad(). + unsigned ExceptionPointerVirtReg, ExceptionSelectorVirtReg; + explicit FunctionLoweringInfo(const TargetLowering &TLI); /// set - Initialize this FunctionLoweringInfo with the given Function Modified: stable/9/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h ============================================================================== --- stable/9/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h Sun Jul 7 19:04:10 2013 (r252992) +++ stable/9/contrib/llvm/include/llvm/CodeGen/MachineBasicBlock.h Sun Jul 7 19:05:35 2013 (r252993) @@ -296,6 +296,11 @@ public: /// is an error to add the same register to the same set more than once. void addLiveIn(unsigned Reg) { LiveIns.push_back(Reg); } + /// Add PhysReg as live in to this block, and ensure that there is a copy of + /// PhysReg to a virtual register of class RC. Return the virtual register + /// that is a copy of the live in PhysReg. + unsigned addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC); + /// removeLiveIn - Remove the specified register from the live in set. /// void removeLiveIn(unsigned Reg); Modified: stable/9/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp Sun Jul 7 19:04:10 2013 (r252992) +++ stable/9/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp Sun Jul 7 19:05:35 2013 (r252993) @@ -19,6 +19,7 @@ #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SlotIndexes.h" @@ -341,6 +342,38 @@ bool MachineBasicBlock::isLiveIn(unsigne return I != livein_end(); } +unsigned +MachineBasicBlock::addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC) { + assert(getParent() && "MBB must be inserted in function"); + assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) && "Expected physreg"); + assert(RC && "Register class is required"); + assert((isLandingPad() || this == &getParent()->front()) && + "Only the entry block and landing pads can have physreg live ins"); + + bool LiveIn = isLiveIn(PhysReg); + iterator I = SkipPHIsAndLabels(begin()), E = end(); + MachineRegisterInfo &MRI = getParent()->getRegInfo(); + const TargetInstrInfo &TII = *getParent()->getTarget().getInstrInfo(); + + // Look for an existing copy. + if (LiveIn) + for (;I != E && I->isCopy(); ++I) + if (I->getOperand(1).getReg() == PhysReg) { + unsigned VirtReg = I->getOperand(0).getReg(); + if (!MRI.constrainRegClass(VirtReg, RC)) + llvm_unreachable("Incompatible live-in register class."); + return VirtReg; + } + + // No luck, create a virtual register. + unsigned VirtReg = MRI.createVirtualRegister(RC); + BuildMI(*this, I, DebugLoc(), TII.get(TargetOpcode::COPY), VirtReg) + .addReg(PhysReg, RegState::Kill); + if (!LiveIn) + addLiveIn(PhysReg); + return VirtReg; +} + void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) { getParent()->splice(NewAfter, this); } Modified: stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Jul 7 19:04:10 2013 (r252992) +++ stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Jul 7 19:05:35 2013 (r252993) @@ -1910,33 +1910,25 @@ void SelectionDAGBuilder::visitLandingPa SmallVector ValueVTs; ComputeValueVTs(TLI, LP.getType(), ValueVTs); + assert(ValueVTs.size() == 2 && "Only two-valued landingpads are supported"); - // Insert the EXCEPTIONADDR instruction. - assert(FuncInfo.MBB->isLandingPad() && - "Call to eh.exception not in landing pad!"); - SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + // Get the two live-in registers as SDValues. The physregs have already been + // copied into virtual registers. SDValue Ops[2]; - Ops[0] = DAG.getRoot(); - SDValue Op1 = DAG.getNode(ISD::EXCEPTIONADDR, getCurDebugLoc(), VTs, Ops, 1); - SDValue Chain = Op1.getValue(1); - - // Insert the EHSELECTION instruction. - VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); - Ops[0] = Op1; - Ops[1] = Chain; - SDValue Op2 = DAG.getNode(ISD::EHSELECTION, getCurDebugLoc(), VTs, Ops, 2); - Chain = Op2.getValue(1); - Op2 = DAG.getSExtOrTrunc(Op2, getCurDebugLoc(), MVT::i32); + Ops[0] = DAG.getZExtOrTrunc( + DAG.getCopyFromReg(DAG.getEntryNode(), getCurDebugLoc(), + FuncInfo.ExceptionPointerVirtReg, TLI.getPointerTy()), + getCurDebugLoc(), ValueVTs[0]); + Ops[1] = DAG.getZExtOrTrunc( + DAG.getCopyFromReg(DAG.getEntryNode(), getCurDebugLoc(), + FuncInfo.ExceptionSelectorVirtReg, TLI.getPointerTy()), + getCurDebugLoc(), ValueVTs[1]); - Ops[0] = Op1; - Ops[1] = Op2; + // Merge into one. SDValue Res = DAG.getNode(ISD::MERGE_VALUES, getCurDebugLoc(), DAG.getVTList(&ValueVTs[0], ValueVTs.size()), &Ops[0], 2); - - std::pair RetPair = std::make_pair(Res, Chain); - setValue(&LP, RetPair.first); - DAG.setRoot(RetPair.second); + setValue(&LP, Res); } /// handleSmallSwitchCaseRange - Emit a series of specific tests (suitable for Modified: stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp ============================================================================== --- stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Jul 7 19:04:10 2013 (r252992) +++ stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Jul 7 19:05:35 2013 (r252993) @@ -827,12 +827,13 @@ void SelectionDAGISel::PrepareEHLandingP .addSym(Label); // Mark exception register as live in. - unsigned Reg = TLI.getExceptionPointerRegister(); - if (Reg) MBB->addLiveIn(Reg); + const TargetRegisterClass *PtrRC = TLI.getRegClassFor(TLI.getPointerTy()); + if (unsigned Reg = TLI.getExceptionPointerRegister()) + FuncInfo->ExceptionPointerVirtReg = MBB->addLiveIn(Reg, PtrRC); // Mark exception selector register as live in. - Reg = TLI.getExceptionSelectorRegister(); - if (Reg) MBB->addLiveIn(Reg); + if (unsigned Reg = TLI.getExceptionSelectorRegister()) + FuncInfo->ExceptionSelectorVirtReg = MBB->addLiveIn(Reg, PtrRC); } /// isFoldedOrDeadInstruction - Return true if the specified instruction is @@ -970,6 +971,8 @@ void SelectionDAGISel::SelectAllBasicBlo FuncInfo->InsertPt = FuncInfo->MBB->getFirstNonPHI(); // Setup an EH landing-pad block. + FuncInfo->ExceptionPointerVirtReg = 0; + FuncInfo->ExceptionSelectorVirtReg = 0; if (FuncInfo->MBB->isLandingPad()) PrepareEHLandingPad(); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 19:13:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CD250FA5; Sun, 7 Jul 2013 19:13:36 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BABDD1104; Sun, 7 Jul 2013 19:13:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67JDaCL004663; Sun, 7 Jul 2013 19:13:36 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67JDZR1004651; Sun, 7 Jul 2013 19:13:35 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201307071913.r67JDZR1004651@svn.freebsd.org> From: Devin Teske Date: Sun, 7 Jul 2013 19:13:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252995 - in stable/9/usr.sbin: . bsdconfig bsdconfig/console bsdconfig/console/include bsdconfig/diskmgmt bsdconfig/diskmgmt/include bsdconfig/docsinstall bsdconfig/docsinstall/include... X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 19:13:36 -0000 Author: dteske Date: Sun Jul 7 19:13:34 2013 New Revision: 252995 URL: http://svnweb.freebsd.org/changeset/base/252995 Log: MFC bsdconfig(8) and sysrc(8) from HEAD. (shazam!) Added: stable/9/usr.sbin/bsdconfig/ stable/9/usr.sbin/bsdconfig/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/bsdconfig (contents, props changed) stable/9/usr.sbin/bsdconfig/bsdconfig.8 (contents, props changed) stable/9/usr.sbin/bsdconfig/console/ stable/9/usr.sbin/bsdconfig/console/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/console/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/console/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/console/console (contents, props changed) stable/9/usr.sbin/bsdconfig/console/font (contents, props changed) stable/9/usr.sbin/bsdconfig/console/include/ stable/9/usr.sbin/bsdconfig/console/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/console/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/console/keymap (contents, props changed) stable/9/usr.sbin/bsdconfig/console/repeat (contents, props changed) stable/9/usr.sbin/bsdconfig/console/saver (contents, props changed) stable/9/usr.sbin/bsdconfig/console/screenmap (contents, props changed) stable/9/usr.sbin/bsdconfig/console/ttys (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/ stable/9/usr.sbin/bsdconfig/diskmgmt/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/diskmgmt (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/include/ stable/9/usr.sbin/bsdconfig/diskmgmt/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/diskmgmt/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/ stable/9/usr.sbin/bsdconfig/docsinstall/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/docsinstall (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/include/ stable/9/usr.sbin/bsdconfig/docsinstall/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/docsinstall/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/ stable/9/usr.sbin/bsdconfig/dot/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/dot (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/include/ stable/9/usr.sbin/bsdconfig/dot/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/dot/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/examples/ stable/9/usr.sbin/bsdconfig/examples/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/examples/browse_packages.sh (contents, props changed) stable/9/usr.sbin/bsdconfig/examples/bsdconfigrc (contents, props changed) stable/9/usr.sbin/bsdconfig/fdisk/ stable/9/usr.sbin/bsdconfig/include/ stable/9/usr.sbin/bsdconfig/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/include/bsdconfig.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/include/media.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/include/network_device.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/include/options.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/include/tcp.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/include/usage.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/ stable/9/usr.sbin/bsdconfig/mouse/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/disable (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/enable (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/flags (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/include/ stable/9/usr.sbin/bsdconfig/mouse/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/mouse (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/port (contents, props changed) stable/9/usr.sbin/bsdconfig/mouse/type (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/ stable/9/usr.sbin/bsdconfig/networking/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/defaultrouter (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/devices (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/hostname (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/include/ stable/9/usr.sbin/bsdconfig/networking/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/nameservers (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/networking (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/ stable/9/usr.sbin/bsdconfig/networking/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/common.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/device.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/hostname.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/ipaddr.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/media.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/netmask.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/resolv.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/routing.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/networking/share/services.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/ stable/9/usr.sbin/bsdconfig/packages/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/include/ stable/9/usr.sbin/bsdconfig/packages/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/packages/packages (contents, props changed) stable/9/usr.sbin/bsdconfig/password/ stable/9/usr.sbin/bsdconfig/password/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/password/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/password/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/password/include/ stable/9/usr.sbin/bsdconfig/password/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/password/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/password/password (contents, props changed) stable/9/usr.sbin/bsdconfig/password/share/ stable/9/usr.sbin/bsdconfig/password/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/password/share/password.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/security/ stable/9/usr.sbin/bsdconfig/security/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/security/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/security/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/security/include/ stable/9/usr.sbin/bsdconfig/security/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/security/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/security/include/securelevel.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/security/kern_securelevel (contents, props changed) stable/9/usr.sbin/bsdconfig/security/security (contents, props changed) stable/9/usr.sbin/bsdconfig/share/ stable/9/usr.sbin/bsdconfig/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/share/common.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/device.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/dialog.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/ stable/9/usr.sbin/bsdconfig/share/media/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/any.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/cdrom.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/common.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/directory.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/dos.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/floppy.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/ftp.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/http.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/httpproxy.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/network.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/nfs.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/options.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/tcpip.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/ufs.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/media/usb.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/mustberoot.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/packages/ stable/9/usr.sbin/bsdconfig/share/packages/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/share/packages/categories.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/packages/index.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/packages/packages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/script.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/strings.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/struct.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/sysrc.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/share/variable.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/ stable/9/usr.sbin/bsdconfig/startup/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/include/ stable/9/usr.sbin/bsdconfig/startup/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/misc (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/rcadd (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/rcconf (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/rcdelete (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/rcedit (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/rcvar (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/share/ stable/9/usr.sbin/bsdconfig/startup/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/share/rcconf.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/share/rcedit.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/share/rcvar.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/startup/startup (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/ stable/9/usr.sbin/bsdconfig/timezone/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/include/ stable/9/usr.sbin/bsdconfig/timezone/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/ stable/9/usr.sbin/bsdconfig/timezone/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/continents.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/countries.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/iso3166.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/menus.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/share/zones.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/timezone/timezone (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/ stable/9/usr.sbin/bsdconfig/ttys/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/include/ stable/9/usr.sbin/bsdconfig/ttys/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/ttys/ttys (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/ stable/9/usr.sbin/bsdconfig/usermgmt/INDEX (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/USAGE (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/groupadd (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/groupdel (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/groupedit (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/groupinput (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/include/ stable/9/usr.sbin/bsdconfig/usermgmt/include/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/include/messages.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/include/usermgmt.hlp (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/share/ stable/9/usr.sbin/bsdconfig/usermgmt/share/Makefile (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/share/group_input.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/share/user_input.subr (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/useradd (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/userdel (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/useredit (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/userinput (contents, props changed) stable/9/usr.sbin/bsdconfig/usermgmt/usermgmt (contents, props changed) stable/9/usr.sbin/sysrc/ stable/9/usr.sbin/sysrc/Makefile (contents, props changed) stable/9/usr.sbin/sysrc/sysrc (contents, props changed) stable/9/usr.sbin/sysrc/sysrc.8 (contents, props changed) Modified: stable/9/usr.sbin/Makefile Modified: stable/9/usr.sbin/Makefile ============================================================================== --- stable/9/usr.sbin/Makefile Sun Jul 7 19:07:00 2013 (r252994) +++ stable/9/usr.sbin/Makefile Sun Jul 7 19:13:34 2013 (r252995) @@ -7,6 +7,7 @@ SUBDIR= adduser \ arp \ bootparamd \ burncd \ + bsdconfig \ bsdinstall \ cdcontrol \ chkgrp \ @@ -80,6 +81,7 @@ SUBDIR= adduser \ snapinfo \ spray \ syslogd \ + sysrc \ tcpdchk \ tcpdmatch \ tcpdrop \ Added: stable/9/usr.sbin/bsdconfig/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/Makefile Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,32 @@ +# $FreeBSD$ + +SUBDIR= console \ + diskmgmt \ + docsinstall \ + dot \ + examples \ + include \ + mouse \ + networking \ + packages \ + password \ + security \ + share \ + startup \ + timezone \ + ttys \ + usermgmt + +FILESDIR= ${LIBEXECDIR}/bsdconfig +FILES= USAGE + +SCRIPTS= bsdconfig + +MAN= bsdconfig.8 + +beforeinstall: + mkdir -p ${DESTDIR}${FILESDIR} + mkdir -p ${DESTDIR}${SCRIPTSDIR} + mkdir -p ${DESTDIR}${MANDIR}8 + +.include Added: stable/9/usr.sbin/bsdconfig/USAGE ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/USAGE Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,47 @@ +# Copyright (c) 2012 Ron McDowell +# Copyright (c) 2012-2013 Devin Teske +# 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$ + +Usage: + @PROGRAM_NAME@ [-h] + @PROGRAM_NAME@ command [-h] + @PROGRAM_NAME@ [OPTIONS] [command [OPTIONS]] + +OPTIONS: + -d Provide lots of debugging info on standard-out when running. + -D file Send debugging info to file. If file begins with a plus-sign + debug info is sent to both standard-out and file (minus the + leading plus). + -f file Load file as script and then exit. If multiple occurrences, + program will only exit after last occurrence. If file is a + single dash (`-'), @PROGRAM_NAME@ reads from standard input. + -h Print this usage statement and exit. + -S Secure X11 mode (implies `-X'). As root, always prompt-for + and validate sudo(8) username/password before starting. + -X Use Xdialog(1) in place of dialog(1). + +COMMANDS: +@COMMAND_LIST@ Added: stable/9/usr.sbin/bsdconfig/bsdconfig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/bsdconfig Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,429 @@ +#!/bin/sh +#- +# Copyright (c) 2012 Ron McDowell +# Copyright (c) 2012-2013 Devin Teske +# 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$ +# +############################################################ INCLUDES + +# When common.subr is included, it automatically scans "$@" for `-d' and/or +# `-D file' arguments to conditionally enable debugging. Similarly, when +# dialog.subr is included, it automatically scans "$@" for `-X' and/or `-S'. +# To prevent this scanning from becoming confused by extra options, define +# any/all extra arguments to use in the optstring to getopts when scanning +# for dedicated options such as those described. +# +# NOTE: This needs to be declared before including `common.subr'. +# NOTE: You really only need to list flags that require an argument as unknown +# flags are silently accepted unless they take an argument (in which case +# the following argument will terminate option processing unless it looks +# like a flag). +# +GETOPTS_EXTRA="f:" + +BSDCFG_SHARE="/usr/share/bsdconfig" +. $BSDCFG_SHARE/common.subr || exit 1 +f_dprintf "%s: loading includes..." "$0" +f_include $BSDCFG_SHARE/dialog.subr +f_include $BSDCFG_SHARE/mustberoot.subr +f_include $BSDCFG_SHARE/strings.subr + +BSDCFG_LIBE="/usr/libexec/bsdconfig" +f_include_lang $BSDCFG_LIBE/include/messages.subr + +BSDCONFIG_HELPFILE=$BSDCFG_LIBE/include/bsdconfig.hlp +USAGE_HELPFILE=$BSDCFG_LIBE/include/usage.hlp + +############################################################ CONFIGURATION + +# +# Alternate `local' libexec directory for add-on modules (e.g., from ports) +# +BSDCFG_LOCAL_LIBE="/usr/local/libexec/bsdconfig" + +############################################################ FUNCTIONS + +# usage +# +# display usage and exit +# +usage() +{ + local index="INDEX" + local cmd_list # Calculated below + + cd $BSDCFG_LIBE + # No need to preserve CWD (headed toward exit) + + # Test for language-specific indices + f_quietly ls */"$index.${LANG:-$LC_ALL}" && + index="$index.${LANG:-$LC_ALL}" + + cmd_list=$( + awk '/^menu_selection="/ { + sub(/\|.*/, "") + sub(/^menu_selection="/, "") + print + }' */$index | sort + ) + + local alt_cmd_list # Calculated below (if $BSDCFG_LOCAL_LIBE exists) + if f_quietly cd $BSDCFG_LOCAL_LIBE; then + # No need to preserve CWD (headed toward exit) + + # Test for language-specific indices + f_quietly ls */"$index.${LANG:-$LC_ALL}" && + index="$index.${LANG:-$LC_ALL}" + + alt_cmd_list=$( + awk '/^menu_selection="/ { + sub(/\|.*/, "") + sub(/^menu_selection="/, "") + print + }' */$index 2> /dev/null | sort + ) + + # Conflate lists, removing duplicates + cmd_list=$( printf "%s\n%s\n" \ + "$cmd_list" "$alt_cmd_list" | sort -u ) + fi + + # + # Determine the longest command-length (in characters) + # + local longest_cmd + longest_cmd=$( echo "$cmd_list" | f_longest_line_length ) + f_dprintf "longest_cmd=[%s]" "$longest_cmd" + + # + # Determine the maximum width of terminal/console + # + local max_size="$( stty size 2> /dev/null )" + : ${max_size:="24 80"} + local max_width="${max_size#*[$IFS]}" + f_dprintf "max_width=[%s]" "$max_width" + + # + # Using the longest command-length as the width of a single column, + # determine if we can use more than one column to display commands. + # + local x=$longest_cmd ncols=1 + x=$(( $x + 8 )) # Accomodate leading tab character + x=$(( $x + 3 + $longest_cmd )) # Preload end of next column + while [ $x -lt $max_width ]; do + ncols=$(( $ncols + 1 )) + x=$(( $x + 3 + $longest_cmd )) + done + f_dprintf "ncols=[%u] x=[%u]" $ncols $x + + # + # Re-format the command-list into multiple columns + # + cmd_list=$( eval "$( echo "$cmd_list" | + awk -v ncols=$ncols -v size=$longest_cmd ' + BEGIN { + n = 0 + row_item[1] = "" + } + function print_row() + { + fmt = "printf \"\\t%-" size "s" + for (i = 1; i < cur_col; i++) + fmt = fmt " %-" size "s" + fmt = fmt "\\n\"" + printf "%s", fmt + for (i = 1; i <= cur_col; i++) + printf " \"%s\"", row_item[i] + print "" + } + { + n++ + cur_col = (( n - 1 ) % ncols ) + 1 + printf "f_dprintf \"row_item[%u]=[%%s]\" \"%s\"\n", + cur_col, $0 + row_item[cur_col] = $0 + if ( cur_col == ncols ) print_row() + } + END { + if ( cur_col < ncols ) print_row() + }' )" + ) + + f_usage $BSDCFG_LIBE/USAGE \ + "PROGRAM_NAME" "$pgm" \ + "COMMAND_LIST" "$cmd_list" + + # Never reached +} + +# dialog_menu_main +# +# Display the dialog(1)-based application main menu. +# +dialog_menu_main() +{ + local title="$DIALOG_TITLE" + local btitle="$DIALOG_BACKTITLE" + local prompt="$msg_menu_text" + local menu_list=" + 'X' '$msg_exit' '$msg_exit_bsdconfig' + '1' '$msg_usage' '$msg_quick_start_how_to_use_this_menu_system' + " # END-QUOTE + local defaultitem= # Calculated below + local hline= + + # + # Pick up the base modules (directories named `[0-9][0-9][0-9].*') + # + local menuitem menu_title menu_help menu_selection index=2 + for menuitem in $( cd $BSDCFG_LIBE && ls -d [0-9][0-9][0-9].* ); do + [ -f "$BSDCFG_LIBE/$menuitem/INDEX" ] || continue + [ $index -lt ${#DIALOG_MENU_TAGS} ] || break + + menu_program= menu_title= menu_help= + f_include_lang $BSDCFG_LIBE/$menuitem/INDEX + [ "$menu_program" ] || continue + + case "$menu_program" in + /*) : already fully qualified ;; + *) menu_program="$menuitem/$menu_program" + esac + + tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 ) + setvar "menu_program$tag" "$menu_program" + + f_shell_escape "$menu_title" menu_title + f_shell_escape "$menu_help" menu_help + menu_list="$menu_list '$tag' '$menu_title' '$menu_help'" + + index=$(( $index + 1 )) + done + + # + # Process the `local' libexec sources. + # + # Whereas modules in $BSDCFG_LIBE must be named [0-9][0-9][0-9].* + # modules in $BSDCFG_LOCAL_LIBE should NOT be named this way (making it + # more practical for port-maintainers). + # + # This also has the fortunate side-effect of making the de-duplication + # effort rather simple (because so-called `base' modules must be named + # differently than add-on modules). + # + local separator_added= + for menuitem in $( cd "$BSDCFG_LOCAL_LIBE" 2> /dev/null && ls -d * ) + do + # Skip the module if it looks like a `base' module + case "$menuitem" in [0-9][0-9][0-9].*) continue;; esac + + [ -f "$BSDCFG_LOCAL_LIBE/$menuitem/INDEX" ] || continue + [ $index -lt ${#DIALOG_MENU_TAGS} ] || break + + menu_program= menu_title= menu_help= + f_include_lang $BSDCFG_LOCAL_LIBE/$menuitem/INDEX || continue + [ "$menu_program" ] || continue + + if [ ! "$separator_added" ]; then + menu_list="$menu_list '-' '-' ''" + separator_added=1 + fi + + case "$menu_program" in + /*) : already fully qualified ;; + *) menu_program="$BSDCFG_LOCAL_LIBE/$menuitem/$menu_program" + esac + + tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 ) + setvar "menu_program$tag" "$menu_program" + + f_shell_escape "$menu_title" menu_title + f_shell_escape "$menu_help" menu_help + menu_list="$menu_list '$tag' '$menu_title' '$menu_help'" + + index=$(( $index + 1 )) + done + + local height width rows + eval f_dialog_menu_with_help_size height width rows \ + \"\$title\" \ + \"\$btitle\" \ + \"\$prompt\" \ + \"\$hline\" \ + $menu_list + + # Obtain default-item from previously stored selection + f_dialog_default_fetch defaultitem + + local menu_choice + menu_choice=$( eval $DIALOG \ + --clear \ + --title \"\$title\" \ + --backtitle \"\$btitle\" \ + --hline \"\$hline\" \ + --item-help \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_exit_bsdconfig\" \ + --help-button \ + --help-label \"\$msg_help\" \ + ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$defaultitem\" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD + ) + local retval=$? + f_dialog_data_sanitize menu_choice + f_dialog_menutag_store "$menu_choice" + + # Only update default-item on success + [ $retval -eq 0 ] && f_dialog_default_store "$menu_choice" + + return $retval +} + +############################################################ MAIN + +# +# If $0 is not "bsdconfig", interpret it either as a keyword to a menuitem or +# as a valid resword (see script.subr for additional details about reswords). +# +if [ "$pgm" != "bsdconfig" ]; then + if indexfile=$( f_index_file "$pgm" ) && + cmd=$( f_index_menusel_command "$indexfile" "$pgm" ) + then + f_dprintf "pgm=[%s] indexfile=[%s] cmd=[%s]" \ + "$pgm" "$indexfile" "$cmd" + exec "$cmd" "$@" || exit 1 + else + f_include $BSDCFG_SHARE/script.subr + for resword in $RESWORDS; do + [ "$pgm" = "$resword" ] || continue + # Found a match + f_dprintf "pgm=[%s] A valid resWord!" "$pgm" + f_dispatch $resword + exit $? + done + fi +fi + +# +# Process command-line arguments +# +scripts_loaded=0 +while getopts f:h$GETOPTS_STDARGS flag; do + case "$flag" in + f) [ $scripts_loaded -eq 0 ] && f_include $BSDCFG_SHARE/script.subr + f_script_load "$OPTARG" + scripts_loaded=$(( $scripts_loaded + 1 )) ;; + h|\?) usage ;; + esac +done +shift $(( $OPTIND -1 )) + +# If we've loaded any scripts, do not continue any further +[ $scripts_loaded -gt 0 ] && exit + +# +# Initialize +# +f_dialog_title "$msg_main_menu" + +[ "$SECURE" ] && f_mustberoot_init + +# Incorporate rc-file if it exists +[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" + +# +# If a non-option argument was passed, process it as a menuitem selection... +# +if [ "$1" ]; then + # + # ...unless it's a long-option for usage. + # + case "$1" in -help|--help|-\?) + usage + # Not reached + esac + + # + # Find the INDEX (possibly i18n) claiming this keyword and get the + # command to execute from the menu_selection line. + # + if ! { indexfile=$( f_index_file "$1" ) && + cmd=$( f_index_menusel_command "$indexfile" "$1" ) + }; then + # no matches, display usage (which shows valid keywords) + f_err "%s: %s: $msg_not_found\n" "$pgm" "$1" + usage + # Not reached + fi + + shift + exec $cmd ${USE_XDIALOG:+-X} "$@" || exit 1 + # Not reached +fi + +# +# Launch application main menu +# +while :; do + dialog_menu_main + retval=$? + f_dialog_menutag_fetch mtag + f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" + + if [ $retval -eq 2 ]; then + # The Help button was pressed + f_show_help "$BSDCONFIG_HELPFILE" + continue + elif [ $retval -ne 0 ]; then + f_die + fi + + case "$mtag" in + X) break ;; + 1) # Usage + f_show_help "$USAGE_HELPFILE" + continue + esac + + # Anything else is a dynamically loaded menuitem + + f_getvar menu_program$mtag menu_program + case "$menu_program" in + /*) cmd="$menu_program" ;; + *) cmd="$BSDCFG_LIBE/$menu_program" + esac + f_dprintf "cmd=[%s]" "$cmd" + $cmd ${USE_XDIALOG:+-X} +done + +exit $SUCCESS + +################################################################################ +# END +################################################################################ Added: stable/9/usr.sbin/bsdconfig/bsdconfig.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/bsdconfig.8 Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,243 @@ +.\" Copyright (c) 2012 Ron McDowell +.\" Copyright (c) 2012-2013 Devin Teske +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd Jun 5, 2013 +.Dt BSDCONFIG 8 +.Os +.Sh NAME +.Nm bsdconfig +.Nd system configuration utility +.Sh SYNOPSIS +.Nm +.Op Fl h +.Nm +.Ar command +.Op Fl h +.Nm +.Op OPTIONS +.Op command Op OPTIONS +.Sh DESCRIPTION +.Nm +is used to set up many system configuration settings, both for new systems, as +well as changing configuration settings of existing systems. +.Pp +.Nm +optionally takes a command as an argument. +If invoked with no arguments, it will bring up an interactive menu listing the +available modules. +.Pp +The following options are available: +.Bl -tag -width indent+ +.It Fl d +Provide lots of debugging info on standard-out when running. +.It Fl D Ar file +Send debugging info to file. +If file begins with a plus-sign debug info is sent to both standard-out and +file (minus the leading plus). +.It Fl f Ar file +Load +.Ar file +as script and then exit. +If multiple occurrences, program will only exit after last occurrence. +If +.Ar file +is a single dash +.Pq Sq Fl , +.Nm +reads from standard input. +.It Fl h +Print usage statement and exit. +.It Fl S +Secure X11 mode +.Pq implies Fl X . +As root, always prompt-for and validate +.Xr sudo 8 +username/password before starting. +.It Fl X +Use +.Xr Xdialog 1 +in place of +.Xr dialog 1 . +.El +.Sh COMMANDS +The following commands +.Pq sorted alphabetically +are currently included in the base +.Nm +program, with more to be added soon. +Other commands can be added, as detailed below in the +.Cm ADDING COMMANDS +section, and once added, will appear in the master menu as well as in the +.Cm -h +listing. +.Bl -tag -width ".Cm syscons_screenmap" +.It Cm console +Utilities to customize the behavior of the system console. +.It Cm defaultrouter +Shortcut to the Default Router/Gateway menu under networking. +.It Cm diskmgmt +Manage disk partitions and/or labels. +Executes +.Xr sade 8 . +.It Cm docsinstall +Executes the +.Cm bsdinstall docsinstall +sub-utility to allow installation/re-installation of the FreeBSD Documentation +set(s). +.It Cm dot +Generate a graphviz +.Xr dot 1 +language file +.Pq printed on stdout +visualizing the +.Nm +menu, include, and shortcut structure relationships. +See +.Dq bsdconfig dot -h +for more details. +.It Cm groupadd +Shortcut to the Add Groups menu under groupmgmt. +.It Cm groupdel +Shortcut to the Delete Groups menu under groupmgmt. +.It Cm groupedit +Shortcut to the Edit/View Groups menu under groupmgmt. +.It Cm groupmgmt +Utilities to Add/Change/View/Delete Group Accounts. +.It Cm hostname +Shortcut to the Hostname/Domain menu under networking. +.It Cm kern_securelevel +Shortcut to the kern.securelevel menu under security. +.It Cm mouse +Utilities for configuring, exploring, and enabling console mouse support. +.It Cm mouse_disable +Shortcut to the Disable menu under mouse. +.It Cm mouse_enable +Shortcut to the Enable menu under mouse. +.It Cm mouse_flags +Shortcut to the Flags menu under mouse. +.It Cm mouse_port +Shortcut to the Port menu under mouse. +.It Cm mouse_type +Shortcut to the Type menu under mouse. +.It Cm nameservers +Shortcut to the DNS Nameservers menu under networking. +.It Cm netdev +Shortcut to the Network Interfaces menu under networking. +.It Cm networking +Utilities to set/change Hostname/Domain, Network Interfaces, Default +Router/Gateway, and DNS Nameservers. +.It Cm packages +Browse, install, uninstall, or re-install packaged software. +.It Cm password +Set the system administrator +.Pq root +password. +.It Cm security +Configure various system security settings. +.It Cm startup +Configure various aspects of system startup. +.It Cm startup_misc +Shortcut to the Miscellaneous Startup Services menu under startup. +.It Cm startup_rcadd +Shortcut to the Add New menu under the View/Edit Startup Configuration menu +(startup_rcconf) of startup. +.It Cm startup_rcconf +Shortcut to the View/Edit Startup Configuration menu under startup. +.It Cm startup_rcdelete +Shortcut to the Delete menu under the View/Edit Startup Configuration menu +(startup_rcconf) of startup. +.It Cm startup_rcvar +Shortcut to the Toggle Startup Services menu under startup. +.It Cm syscons_font +Shortcut to the Font menu under console. +.It Cm syscons_keymap +Shortcut to the Keymap menu under console. +.It Cm syscons_repeat +Shortcut to the Repeat menu under console. +.It Cm syscons_saver +Shortcut to the Saver menu under console. +.It Cm syscons_screenmap +Shortcut to the Screenmap menu under console. +.It Cm syscons_ttys +Shortcut to the Ttys menu under console. +.It Cm timezone +Set the regional timezone of the local machine. +.It Cm ttys +Edit the +.Xr ttys 5 +database with your favorite editor. +.It Cm useradd +Shortcut to the Add Users menu under usermgmt. +.It Cm userdel +Shortcut to the Delete Users menu under usermgmt. +.It Cm useredit +Shortcut to the Edit/View Users menu under usermgmt. +.It Cm usermgmt +Utilities to Add/Edit/View/Delete User Accounts. +.El +.Sh INTERNATIONALIZATION +i18n features are built into +.Nm +and language-specific translation files will be added as they become available. +In the absence of language-specific translation files, the default +.Pq en_US.ISO8859-1 +files will be used. +.Sh ADDING COMMANDS +To be documented later. +Document menu_selection="command|*" syntax of INDEX files. +.Sh ENVIRONMENT VARIABLES +The following environment variables affect the execution of +.Nm : +.Bl -tag -width ".Ev LC_ALL" +.It Ev LANG +If LANG is set, messages and index information will be read from files named +messages.$LANG and INDEX.$LANG and fall back to files named messages and INDEX +if messages.$LANG and INDEX.$LANG do not exist. +LANG takes precedence over LC_ALL. +.It Ev LC_ALL +If LC_ALL is set, messages and index information will be read from files named +messages.$LC_ALL and INDEX.$LC_ALL and fall back to files named messages and +INDEX if messages.$LC_ALL and INDEX.$LC_ALL do not exist. +.El +.Sh FILES +/usr/share/examples/bsdconfig/bsdconfigrc can be copied to $HOME/.bsdconfigrc +and customized as needed. +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr bsdinstall 8 +.Sh HISTORY +.Nm +first appeared in +.Fx 9.2 . +.Sh AUTHORS +.An Ron McDowell +.An Devin Teske Aq dteske@FreeBSD.org +.Sh BUGS +The docsinstall and diskmgmt modules call bsdinstall. +Bugs found in these modules should be considered those of bsdinstall, not +.Nm . Added: stable/9/usr.sbin/bsdconfig/console/INDEX ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/console/INDEX Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,63 @@ +# Copyright (c) 2012 Ron McDowell +# Copyright (c) 2012 Devin Teske +# 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$ + +# +# Title that will be shown in the bsdconfig menu. +# +menu_title="Console" + +# +# A short descriptive line shown at the bottom of the bsdconfig menu. keep it +# short because any line longer than the terminal width will be truncated. +# +menu_help="Customize system console behavior" + +# +# Two-part variable that defines an action to take when `keyword' is passed on +# a bsdconfig command line. Variable takes the form "keyword|command" and +# multiple occurrences of the variable (with different `keyword's, or different +# `keyword's AND `command's) are allowed. If `command' begins with a '/' then +# the full path to the program is needed. If `command' begins with anything +# else it is a path relative to the directory this INDEX file is in. `keyword' +# can be i18n'ed but `command' is the name of a script. +# +menu_selection="console|console" +menu_selection="syscons_font|font" +menu_selection="syscons_keymap|keymap" +menu_selection="syscons_repeat|repeat" +menu_selection="syscons_saver|saver" +menu_selection="syscons_screenmap|screenmap" +menu_selection="syscons_ttys|ttys" + +# +# ------------ Items below this line do NOT need i18n translation ------------ +# +# Name of the program to be run when this menu choice is selected. If it begins +# with a '/' then the full path to the program is needed. If it begins with +# anything else it is a path relative to the directory this INDEX file is in. +# +menu_program="console" Added: stable/9/usr.sbin/bsdconfig/console/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/console/Makefile Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +NO_OBJ= + +SUBDIR= include + +FILESDIR= ${LIBEXECDIR}/bsdconfig/080.console +FILES= INDEX USAGE + +SCRIPTSDIR= ${FILESDIR} +SCRIPTS= console font keymap repeat saver screenmap ttys + +beforeinstall: + mkdir -p ${DESTDIR}${FILESDIR} + +.include Added: stable/9/usr.sbin/bsdconfig/console/USAGE ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/console/USAGE Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,37 @@ +# Copyright (c) 2012-2013 Devin Teske +# 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$ + +Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS] + +OPTIONS: + -d Provide lots of debugging info on standard-out when running. + -D file Send debugging info to file. If file begins with a plus-sign + debug info is sent to both standard-out and file (minus the + leading plus). + -h Print this usage statement and exit. + -S Secure X11 mode (implies `-X'). As root, always prompt-for + and validate sudo(8) username/password before starting. + -X Use Xdialog(1) in place of dialog(1). Added: stable/9/usr.sbin/bsdconfig/console/console ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/usr.sbin/bsdconfig/console/console Sun Jul 7 19:13:34 2013 (r252995) @@ -0,0 +1,146 @@ +#!/bin/sh +#- +# Copyright (c) 2012-2013 Devin Teske +# 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$ +# +############################################################ INCLUDES + +BSDCFG_SHARE="/usr/share/bsdconfig" +. $BSDCFG_SHARE/common.subr || exit 1 +f_dprintf "%s: loading includes..." "$0" +f_include $BSDCFG_SHARE/dialog.subr +f_include $BSDCFG_SHARE/mustberoot.subr + +BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" +f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr + +ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) +[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" + +############################################################ FUNCTIONS + +# dialog_menu_main +# +# Display the dialog(1)-based application main menu. +# +dialog_menu_main() +{ + local prompt="$msg_console_menu_text" + local menu_list=" + 'X $msg_exit' '$msg_exit_this_menu' + '2 $msg_font' '$msg_choose_alternate_screen_font' + '3 $msg_keymap' '$msg_choose_alternate_keyboard_map' + '4 $msg_repeat' '$msg_set_repeat_rate' + '5 $msg_saver' '$msg_configure_screen_saver' + '6 $msg_screenmap' '$msg_choose_alternate_screenmap' + '7 $msg_ttys' '$msg_choose_console_terminal_type' + " # END-QUOTE + local defaultitem= # Calculated below + local hline="$hline_configure_system_console_settings" + + local height width rows + eval f_dialog_menu_size height width rows \ + \"\$DIALOG_TITLE\" \ + \"\$DIALOG_BACKTITLE\" \ + \"\$prompt\" \ + \"\$hline\" \ + $menu_list + + # Obtain default-item from previously stored selection + f_dialog_default_fetch defaultitem + + local menu_choice + menu_choice=$( eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD + ) + local retval=$? + f_dialog_data_sanitize menu_choice + f_dialog_menutag_store "$menu_choice" + f_dialog_default_store "$menu_choice" *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 7 22:27:38 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1C33418E; Sun, 7 Jul 2013 22:27:38 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0D4741996; Sun, 7 Jul 2013 22:27:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67MRbig061196; Sun, 7 Jul 2013 22:27:37 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67MRaIh061187; Sun, 7 Jul 2013 22:27:36 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201307072227.r67MRaIh061187@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 7 Jul 2013 22:27:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r253010 - stable/9/contrib/tzdata X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 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, 07 Jul 2013 22:27:38 -0000 Author: edwin Date: Sun Jul 7 22:27:36 2013 New Revision: 253010 URL: http://svnweb.freebsd.org/changeset/base/253010 Log: MFC of tzdata2013d, 253009 - Morocco: announced that the year's Ramadan daylight-savings transitions would be 2013-07-07 and 2013-08-10. - Israel: As of 2013, DST starts at 02:00 on the Friday before the last Sunday in March. DST ends at 02:00 on the first Sunday after October 1, unless it occurs on the second day of the Jewish Rosh Hashana holiday, in which case DST ends a day later (i.e. at 02:00 the first Monday after October 2). [Rosh Hashana holidays are factored in until 2100.] Modified: stable/9/contrib/tzdata/africa stable/9/contrib/tzdata/asia stable/9/contrib/tzdata/australasia stable/9/contrib/tzdata/europe stable/9/contrib/tzdata/southamerica stable/9/contrib/tzdata/zone.tab Directory Properties: stable/9/contrib/tzdata/ (props changed) Modified: stable/9/contrib/tzdata/africa ============================================================================== --- stable/9/contrib/tzdata/africa Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/africa Sun Jul 7 22:27:36 2013 (r253010) @@ -852,12 +852,18 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 J # announced that year's Ramadan daylight-saving transitions would be # 2012-07-20 and 2012-08-20; see # . -# + +# From Andrew Paprocki (2013-07-02): +# Morocco announced that the year's Ramadan daylight-savings +# transitions would be 2013-07-07 and 2013-08-10; see: +# http://www.maroc.ma/en/news/morocco-suspends-daylight-saving-time-july-7-aug10 + +# From Paul Eggert (2013-07-03): # To estimate what the Moroccan government will do in future years, -# transition dates for 2013 through 2021 were determined by running +# transition dates for 2014 through 2021 were determined by running # the following program under GNU Emacs 24.3: # -# (let ((islamic-year 1434)) +# (let ((islamic-year 1435)) # (while (< islamic-year 1444) # (let ((a # (calendar-gregorian-from-absolute @@ -910,8 +916,8 @@ Rule Morocco 2012 2019 - Apr lastSun 2: Rule Morocco 2012 max - Sep lastSun 3:00 0 - Rule Morocco 2012 only - Jul 20 3:00 0 - Rule Morocco 2012 only - Aug 20 2:00 1:00 S -Rule Morocco 2013 only - Jul 9 3:00 0 - -Rule Morocco 2013 only - Aug 8 2:00 1:00 S +Rule Morocco 2013 only - Jul 7 3:00 0 - +Rule Morocco 2013 only - Aug 10 2:00 1:00 S Rule Morocco 2014 only - Jun 29 3:00 0 - Rule Morocco 2014 only - Jul 29 2:00 1:00 S Rule Morocco 2015 only - Jun 18 3:00 0 - Modified: stable/9/contrib/tzdata/asia ============================================================================== --- stable/9/contrib/tzdata/asia Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/asia Sun Jul 7 22:27:36 2013 (r253010) @@ -1212,39 +1212,21 @@ Rule Zion 2011 only - Oct 2 2:00 0 S Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D Rule Zion 2012 only - Sep 23 2:00 0 S -# From Ephraim Silverberg (2012-10-18): -# Yesterday, the Interior Ministry Committee, after more than a year -# past, approved sending the proposed June 2011 changes to the Time -# Decree Law back to the Knesset for second and third (final) votes -# before the upcoming elections on Jan. 22, 2013. Hence, although the -# changes are not yet law, they are expected to be so before February 2013. -# -# As of 2013, DST starts at 02:00 on the Friday before the last Sunday in March. -# DST ends at 02:00 on the first Sunday after October 1, unless it occurs on the -# second day of the Jewish Rosh Hashana holiday, in which case DST ends a day -# later (i.e. at 02:00 the first Monday after October 2). -# [Rosh Hashana holidays are factored in until 2100.] - -# From Ephraim Silverberg (2012-11-05): -# The Knesset passed today (in second and final readings) the amendment to the -# Time Decree Law making the changes ... law. +# From Ephraim Silverberg (2013-06-27): +# On June 23, 2013, the Israeli government approved changes to the +# Time Decree Law. The next day, the changes passed the First Reading +# in the Knesset. The law is expected to pass the Second and Third +# (final) Readings by the beginning of September 2013. +# +# As of 2013, DST starts at 02:00 on the Friday before the last Sunday +# in March. DST ends at 02:00 on the last Sunday of October. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D -Rule Zion 2013 2026 - Oct Sun>=2 2:00 0 S -Rule Zion 2027 only - Oct Mon>=3 2:00 0 S -Rule Zion 2028 max - Oct Sun>=2 2:00 0 S -# The following rules are commented out for now, as they break older -# versions of zic that support only signed 32-bit timestamps, i.e., -# through 2038-01-19 03:14:07 UTC. -#Rule Zion 2028 2053 - Oct Sun>=2 2:00 0 S -#Rule Zion 2054 only - Oct Mon>=3 2:00 0 S -#Rule Zion 2055 2080 - Oct Sun>=2 2:00 0 S -#Rule Zion 2081 only - Oct Mon>=3 2:00 0 S -#Rule Zion 2082 max - Oct Sun>=2 2:00 0 S +Rule Zion 2013 max - Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Jerusalem 2:20:56 - LMT 1880 +Zone Asia/Jerusalem 2:20:54 - LMT 1880 2:20:40 - JMT 1918 # Jerusalem Mean Time? 2:00 Zion I%sT @@ -2547,8 +2529,8 @@ Rule Syria 2006 only - Sep 22 0:00 0 - Rule Syria 2007 only - Mar lastFri 0:00 1:00 S # From Jesper Norgard (2007-10-27): # The sister center ICARDA of my work CIMMYT is confirming that Syria DST will -# not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or -# rather Midnight between Thursday and Friday. This does make more sence than +# not take place 1st November at 0:00 o'clock but 1st November at 24:00 or +# rather Midnight between Thursday and Friday. This does make more sense than # having it between Wednesday and Thursday (two workdays in Syria) since the # weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now # it is implemented at midnight of the last workday before weekend... Modified: stable/9/contrib/tzdata/australasia ============================================================================== --- stable/9/contrib/tzdata/australasia Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/australasia Sun Jul 7 22:27:36 2013 (r253010) @@ -230,10 +230,16 @@ Zone Australia/Lord_Howe 10:36:20 - LMT # - Macquarie Island will stay on UTC+11 for winter and therefore not # switch back from daylight savings time when other parts of Australia do # on 4 April. +# +# From Arthur David Olson (2013-05-23): +# The 1919 transition is overspecified below so pre-2013 zics +# will produce a binary file with an EST-type as the first 32-bit type; +# this is required for correct handling of times before 1916 by +# pre-2013 versions of localtime. Zone Antarctica/Macquarie 0 - zzz 1899 Nov 10:00 - EST 1916 Oct 1 2:00 10:00 1:00 EST 1917 Feb - 10:00 Aus EST 1919 Apr + 10:00 Aus EST 1919 Apr 1 0:00s 0 - zzz 1948 Mar 25 10:00 Aus EST 1967 10:00 AT EST 2010 Apr 4 3:00 @@ -1475,12 +1481,12 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # From Paul Eggert (2000-01-08): # IATA SSIM (1999-09) says DST ends 0100 local time. Go with McDow. -# From the BBC World Service (1998-10-31 11:32 UTC): +# From the BBC World Service in +# http://news.bbc.co.uk/2/hi/asia-pacific/205226.stm (1998-10-31 16:03 UTC): # The Fijiian government says the main reasons for the time change is to -# improve productivity and reduce road accidents. But correspondents say it -# also hopes the move will boost Fiji's ability to compete with other pacific -# islands in the effort to attract tourists to witness the dawning of the new -# millenium. +# improve productivity and reduce road accidents.... [T]he move is also +# intended to boost Fiji's ability to attract tourists to witness the dawning +# of the new millennium. # http://www.fiji.gov.fj/press/2000_09/2000_09_13-05.shtml (2000-09-13) # reports that Fiji has discontinued DST. @@ -1625,7 +1631,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Shanks & Pottenger say the transition was on 1968-10-01; go with Mundell. # From Eric Ulevik (1999-05-03): -# Tonga's director of tourism, who is also secretary of the National Millenium +# Tonga's director of tourism, who is also secretary of the National Millennium # Committee, has a plan to get Tonga back in front. # He has proposed a one-off move to tropical daylight saving for Tonga from # October to March, which has won approval in principle from the Tongan Modified: stable/9/contrib/tzdata/europe ============================================================================== --- stable/9/contrib/tzdata/europe Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/europe Sun Jul 7 22:27:36 2013 (r253010) @@ -523,7 +523,7 @@ Rule C-Eur 1944 only - Oct 2 2:00s 0 - # It seems that Paris, Monaco, Rule France, Rule Belgium all agree on # 2:00 standard time, e.g. 3:00 local time. However there are no # countries that use C-Eur rules in September 1945, so the only items -# affected are apparently these ficticious zones that translates acronyms +# affected are apparently these fictitious zones that translate acronyms # CET and MET: # # Zone CET 1:00 C-Eur CE%sT @@ -2779,9 +2779,9 @@ Link Europe/Istanbul Asia/Istanbul # Ist # Ukraine # -# From Igor Karpov, who works for the Ukranian Ministry of Justice, +# From Igor Karpov, who works for the Ukrainian Ministry of Justice, # via Garrett Wollman (2003-01-27): -# BTW, I've found the official document on this matter. It's goverment +# BTW, I've found the official document on this matter. It's government # regulations number 509, May 13, 1996. In my poor translation it says: # "Time in Ukraine is set to second timezone (Kiev time). Each last Sunday # of March at 3am the time is changing to 4am and each last Sunday of @@ -2815,7 +2815,7 @@ Link Europe/Istanbul Asia/Istanbul # Ist # time this year after all. # # From Udo Schwedt (2011-10-18): -# As far as I understand, the recent change to the Ukranian time zone +# As far as I understand, the recent change to the Ukrainian time zone # (Europe/Kiev) to introduce permanent daylight saving time (similar # to Russia) was reverted today: # Modified: stable/9/contrib/tzdata/southamerica ============================================================================== --- stable/9/contrib/tzdata/southamerica Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/southamerica Sun Jul 7 22:27:36 2013 (r253010) @@ -971,7 +971,7 @@ Rule Brazil 2007 only - Feb 25 0:00 0 - # adopted by the same states as before. Rule Brazil 2007 only - Oct Sun>=8 0:00 1:00 S # From Frederico A. C. Neves (2008-09-10): -# Acording to this decree +# According to this decree # # http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm # @@ -1203,7 +1203,7 @@ Zone America/Rio_Branco -4:31:12 - LMT 1 # http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651 # # -# This is not yet reflected in the offical "cambio de hora" site, but +# This is not yet reflected in the official "cambio de hora" site, but # probably will be soon: # # http://www.horaoficial.cl/cambio.htm Modified: stable/9/contrib/tzdata/zone.tab ============================================================================== --- stable/9/contrib/tzdata/zone.tab Sun Jul 7 22:23:59 2013 (r253009) +++ stable/9/contrib/tzdata/zone.tab Sun Jul 7 22:27:36 2013 (r253010) @@ -1,18 +1,21 @@ -#
+# TZ zone descriptions
+#
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
-# TZ zone descriptions
-#
-# From Paul Eggert (1996-08-05):
+# From Paul Eggert (2013-05-27):
 #
 # This file contains a table with the following columns:
 # 1.  ISO 3166 2-character country code.  See /usr/share/misc/iso3166.
+#     This identifies a country that overlaps the zone.  The country may
+#     overlap other zones and the zone may overlap other countries.
 # 2.  Latitude and longitude of the zone's principal location
 #     in ISO 6709 sign-degrees-minutes-seconds format,
 #     either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
 #     first latitude (+ is north), then longitude (+ is east).
+#     This location need not lie within the column-1 country.
 # 3.  Zone name used in value of TZ environment variable.
+#     Please see the 'Theory' file for how zone names are chosen.
 # 4.  Comments; present if and only if the country has multiple rows.
 #
 # Columns are separated by a single tab.
@@ -22,6 +25,10 @@
 #
 # Lines beginning with `#' are comments.
 #
+# This table is intended as an aid for users, to help them select time
+# zone data appropriate for their practical needs.  It is not intended
+# to take or endorse any position on legal or territorial claims.
+#
 #country-
 #code	coordinates	TZ			comments
 AD	+4230+00131	Europe/Andorra
@@ -216,7 +223,7 @@ ID	-0002+10920	Asia/Pontianak	west & cen
 ID	-0507+11924	Asia/Makassar	east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
 ID	-0232+14042	Asia/Jayapura	west New Guinea (Irian Jaya) & Malukus (Moluccas)
 IE	+5320-00615	Europe/Dublin
-IL	+3146+03514	Asia/Jerusalem
+IL	+314650+0351326	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
 IN	+2232+08822	Asia/Kolkata
 IO	-0720+07225	Indian/Chagos

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 01:46:12 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id A884E360;
 Mon,  8 Jul 2013 01:46:12 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 99CF41FBD;
 Mon,  8 Jul 2013 01:46:12 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r681kCV0020190;
 Mon, 8 Jul 2013 01:46:12 GMT (envelope-from gjb@svn.freebsd.org)
Received: (from gjb@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r681kC5l020188;
 Mon, 8 Jul 2013 01:46:12 GMT (envelope-from gjb@svn.freebsd.org)
Message-Id: <201307080146.r681kC5l020188@svn.freebsd.org>
From: Glen Barber 
Date: Mon, 8 Jul 2013 01:46:12 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253019 - stable/9/release
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 01:46:12 -0000

Author: gjb
Date: Mon Jul  8 01:46:11 2013
New Revision: 253019
URL: http://svnweb.freebsd.org/changeset/base/253019

Log:
  MFC r252846:
  
   - Add SRC_FORCE_CHECKOUT configuration option to force svn to checkout
     the src/ tree into a directory that contains files/directories, such
     as a case where a custom kernel configuration file is specified.
  
   - Allow specification of multiple KERNCONFs to pass to 'make release'.
  
   - Move evaluation of NODOCS/NOPORTS earlier, and set based on how the
     release process expects these options to be evaluated.
  
   - Wrap KERNCONF specification in double quotes, and use 'eval' so multiple
     kernel configurations do not cause the build to fail in strange ways.
  
   - Set WITHOUT_X11 for the port build flags for the documentation toolchain
     build.  Also run 'clean distclean' targets during port build.
  
  PR:		180192
  MFC after:	3 days
  Approved by:	kib (mentor, implicit)

Modified:
  stable/9/release/release.conf.sample
  stable/9/release/release.sh
Directory Properties:
  stable/9/release/   (props changed)

Modified: stable/9/release/release.conf.sample
==============================================================================
--- stable/9/release/release.conf.sample	Mon Jul  8 01:29:09 2013	(r253018)
+++ stable/9/release/release.conf.sample	Mon Jul  8 01:46:11 2013	(r253019)
@@ -14,6 +14,9 @@ SRCBRANCH="base/stable/9"
 DOCBRANCH="doc/head"
 PORTBRANCH="ports/head"
 
+## Run svn co --force for src checkout.
+#SRC_FORCE_CHECKOUT=yes
+
 ## Set the src/, ports/, and doc/ revisions.
 SRCREVISION="-rHEAD"
 DOCREVISION="-rHEAD"
@@ -23,6 +26,8 @@ PORTREVISION="-rHEAD"
 #TARGET="amd64"
 #TARGET_ARCH="amd64"
 #KERNEL="GENERIC"
+## Multiple kernels may be set.
+#KERNEL="GENERIC XENHVM"
 
 ## Set to specify a custom make.conf and/or src.conf
 #MAKE_CONF="/etc/local/make.conf"

Modified: stable/9/release/release.sh
==============================================================================
--- stable/9/release/release.sh	Mon Jul  8 01:29:09 2013	(r253018)
+++ stable/9/release/release.sh	Mon Jul  8 01:46:11 2013	(r253019)
@@ -45,6 +45,10 @@ SRCBRANCH="base/head"
 DOCBRANCH="doc/head"
 PORTBRANCH="ports/head"
 
+# Sometimes one needs to checkout src with --force svn option.
+# If custom kernel configs copied to src tree before checkout, e.g.
+SRC_FORCE_CHECKOUT=
+
 # The default src/, doc/, and ports/ revisions.
 SRCREVISION="-rHEAD"
 DOCREVISION="-rHEAD"
@@ -109,6 +113,25 @@ while getopts c: opt; do
 done
 shift $(($OPTIND - 1))
 
+# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
+# is required to build the documentation set.
+if [ "x${NOPORTS}" != "x" ] && [ "x${NODOC}" = "x" ]; then
+	echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
+	echo "            and NOPORTS is set."
+	NODOC=yes
+fi
+
+# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
+# The release makefile verifies definedness of NOPORTS/NODOC variables
+# instead of their values.
+DOCPORTS=
+if [ "x${NOPORTS}" != "x" ]; then
+ DOCPORTS="NOPORTS=yes "
+fi
+if [ "x${NODOC}" != "x" ]; then
+ DOCPORTS="${DOCPORTS}NODOC=yes"
+fi
+
 # The aggregated build-time flags based upon variables defined within
 # this file, unless overridden by release.conf.  In most cases, these
 # will not need to be changed.
@@ -118,16 +141,14 @@ CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD
 CHROOT_IMAKEFLAGS="${CONF_FILES}"
 CHROOT_DMAKEFLAGS="${CONF_FILES}"
 RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
-RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=${KERNEL} ${ARCH_FLAGS} ${CONF_FILES}"
-RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=${KERNEL} ${CONF_FILES} \
-	NODOC=${NODOC} NOPORTS=${NOPORTS}"
-
-# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
-# is required to build the documentation set.
-if [ "x${NOPORTS}" != "x" ] && [ "x${NODOC}" = "x" ]; then
-	echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
-	echo "            and NOPORTS is set."
-	NODOC=1
+RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
+RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
+	${DOCPORTS}"
+
+# Force src checkout if configured
+FORCE_SRC_KEY=
+if [ "x${SRC_FORCE_CHECKOUT}" != "x" ]; then
+ FORCE_SRC_KEY="--force"
 fi
 
 if [ ! ${CHROOTDIR} ]; then
@@ -144,7 +165,7 @@ set -e # Everything must succeed
 
 mkdir -p ${CHROOTDIR}/usr
 
-svn co ${SVNROOT}/${SRCBRANCH} ${CHROOTDIR}/usr/src $SRCREVISION
+svn co ${FORCE_SRC_KEY} ${SVNROOT}/${SRCBRANCH} ${CHROOTDIR}/usr/src $SRCREVISION
 if [ "x${NODOC}" = "x" ]; then
 	svn co ${SVNROOT}/${DOCBRANCH} ${CHROOTDIR}/usr/doc $DOCREVISION
 fi
@@ -164,10 +185,10 @@ trap "umount ${CHROOTDIR}/dev" EXIT # Cl
 build_doc_ports() {
 	## Trick the ports 'run-autotools-fixup' target to do the right thing.
 	_OSVERSION=$(sysctl -n kern.osreldate)
-	if [ -d ${CHROOTDIR}/usr/doc ] && [ "x${NODOC}" != "x" ]; then
-		PBUILD_FLAGS="OSVERSION=${_OSVERSION} WITHOUT_JADETEX=yes BATCH=yes"
+	if [ -d ${CHROOTDIR}/usr/doc ] && [ "x${NODOC}" = "x" ]; then
+		PBUILD_FLAGS="OSVERSION=${_OSVERSION} WITHOUT_JADETEX=yes WITHOUT_X11=yes BATCH=yes"
 		chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
-			${PBUILD_FLAGS} install
+			${PBUILD_FLAGS} install clean distclean
 	fi
 }
 
@@ -191,11 +212,11 @@ if [ "x${RELSTRING}" = "x" ]; then
 	RELSTRING="$(chroot ${CHROOTDIR} uname -s)-${OSRELEASE}-${TARGET_ARCH}"
 fi
 
-chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
-chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
-chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
+eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
+eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
+eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
 	release RELSTRING=${RELSTRING}
-chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
+eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
 	install DESTDIR=/R RELSTRING=${RELSTRING}
 
 cd ${CHROOTDIR}/R

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 01:53:29 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 1033)
 id 4D0E1D34; Mon,  8 Jul 2013 01:53:29 +0000 (UTC)
Date: Mon, 8 Jul 2013 01:53:29 +0000
From: Alexey Dokuchaev 
To: Michael Tuexen 
Subject: Re: svn commit: r252928 - stable/9/sys/netinet
Message-ID: <20130708015329.GD24353@FreeBSD.org>
References: <201307071136.r67BalXW064645@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201307071136.r67BalXW064645@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
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 01:53:29 -0000

On Sun, Jul 07, 2013 at 11:36:47AM +0000, Michael Tuexen wrote:
> Author: tuexen
> Date: Sun Jul  7 11:36:46 2013
> New Revision: 252928
> URL: http://svnweb.freebsd.org/changeset/base/252928
> 
> Log:
>   MFC r240158:
>   Get rid of a gcc'ism.

Neat trick!  I should use it more. ;-)  Hope Clang will uphold it one day.

./danfe

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 13:24:18 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id E28F86E3;
 Mon,  8 Jul 2013 13:24:18 +0000 (UTC)
 (envelope-from andre@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id C2FCA10DB;
 Mon,  8 Jul 2013 13:24:18 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68DOImb079827;
 Mon, 8 Jul 2013 13:24:18 GMT (envelope-from andre@svn.freebsd.org)
Received: (from andre@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68DOIIT079823;
 Mon, 8 Jul 2013 13:24:18 GMT (envelope-from andre@svn.freebsd.org)
Message-Id: <201307081324.r68DOIIT079823@svn.freebsd.org>
From: Andre Oppermann 
Date: Mon, 8 Jul 2013 13:24:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253035 - stable/9/sys/kern
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 13:24:19 -0000

Author: andre
Date: Mon Jul  8 13:24:18 2013
New Revision: 253035
URL: http://svnweb.freebsd.org/changeset/base/253035

Log:
  MFC r241726:
  
   Move UMA socket zone initialization from uipc_domain.c to uipc_socket.c
   into one place next to its other related functions to avoid confusion.
  
  MFC r241729:
  
   Move socket UMA zone initialization functionality together into
   one place.
  
  MFC r241779:
  
   Tidy up somaxconn (accept queue limit) and related functions
   and move it together into one place.

Modified:
  stable/9/sys/kern/uipc_domain.c
  stable/9/sys/kern/uipc_socket.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/uipc_domain.c
==============================================================================
--- stable/9/sys/kern/uipc_domain.c	Mon Jul  8 13:22:58 2013	(r253034)
+++ stable/9/sys/kern/uipc_domain.c	Mon Jul  8 13:24:18 2013	(r253035)
@@ -239,28 +239,11 @@ domain_add(void *data)
 	mtx_unlock(&dom_mtx);
 }
 
-static void
-socket_zone_change(void *tag)
-{
-
-	uma_zone_set_max(socket_zone, maxsockets);
-}
-
 /* ARGSUSED*/
 static void
 domaininit(void *dummy)
 {
 
-	/*
-	 * Before we do any setup, make sure to initialize the
-	 * zone allocator we get struct sockets from.
-	 */
-	socket_zone = uma_zcreate("socket", sizeof(struct socket), NULL, NULL,
-	    NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
-	uma_zone_set_max(socket_zone, maxsockets);
-	EVENTHANDLER_REGISTER(maxsockets_change, socket_zone_change, NULL,
-		EVENTHANDLER_PRI_FIRST);
-
 	if (max_linkhdr < 16)		/* XXX */
 		max_linkhdr = 16;
 

Modified: stable/9/sys/kern/uipc_socket.c
==============================================================================
--- stable/9/sys/kern/uipc_socket.c	Mon Jul  8 13:22:58 2013	(r253034)
+++ stable/9/sys/kern/uipc_socket.c	Mon Jul  8 13:24:18 2013	(r253035)
@@ -175,11 +175,8 @@ static struct filterops sowrite_filtops 
 	.f_event = filt_sowrite,
 };
 
-uma_zone_t socket_zone;
 so_gen_t	so_gencnt;	/* generation count for sockets */
 
-int	maxsockets;
-
 MALLOC_DEFINE(M_SONAME, "soname", "socket name");
 MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
 
@@ -187,15 +184,37 @@ MALLOC_DEFINE(M_PCB, "pcb", "protocol co
 	VNET_ASSERT(curvnet != NULL,					\
 	    ("%s:%d curvnet is NULL, so=%p", __func__, __LINE__, (so)));
 
+/*
+ * Limit on the number of connections in the listen queue waiting
+ * for accept(2).
+ */
 static int somaxconn = SOMAXCONN;
-static int sysctl_somaxconn(SYSCTL_HANDLER_ARGS);
-/* XXX: we dont have SYSCTL_USHORT */
+
+static int
+sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
+{
+	int error;
+	int val;
+
+	val = somaxconn;
+	error = sysctl_handle_int(oidp, &val, 0, req);
+	if (error || !req->newptr )
+		return (error);
+
+	if (val < 1 || val > USHRT_MAX)
+		return (EINVAL);
+
+	somaxconn = val;
+	return (0);
+}
 SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn, CTLTYPE_UINT | CTLFLAG_RW,
-    0, sizeof(int), sysctl_somaxconn, "I", "Maximum pending socket connection "
-    "queue size");
+    0, sizeof(int), sysctl_somaxconn, "I",
+    "Maximum listen socket pending connection accept queue size");
+
 static int numopensockets;
 SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,
     &numopensockets, 0, "Number of open sockets");
+
 #ifdef ZERO_COPY_SOCKETS
 /* These aren't static because they're used in other files. */
 int so_zero_copy_send = 1;
@@ -229,6 +248,45 @@ MTX_SYSINIT(so_global_mtx, &so_global_mt
 SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC");
 
 /*
+ * Initialize the socket subsystem and set up the socket
+ * memory allocator.
+ */
+uma_zone_t socket_zone;
+int	maxsockets;
+
+static void
+socket_zone_change(void *tag)
+{
+
+	uma_zone_set_max(socket_zone, maxsockets);
+}
+
+static void
+socket_init(void *tag)
+{
+
+        socket_zone = uma_zcreate("socket", sizeof(struct socket), NULL, NULL,
+            NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
+        uma_zone_set_max(socket_zone, maxsockets);
+        EVENTHANDLER_REGISTER(maxsockets_change, socket_zone_change, NULL,
+                EVENTHANDLER_PRI_FIRST);
+}
+SYSINIT(socket, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, socket_init, NULL);
+
+/*
+ * Initialise maxsockets.  This SYSINIT must be run after
+ * tunable_mbinit().
+ */
+static void
+init_maxsockets(void *ignored)
+{
+
+	TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets);
+	maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
+}
+SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL);
+
+/*
  * Sysctl to get and set the maximum global sockets limit.  Notify protocols
  * of the change so that they can update their dependent limits as required.
  */
@@ -252,25 +310,11 @@ sysctl_maxsockets(SYSCTL_HANDLER_ARGS)
 	}
 	return (error);
 }
-
 SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW,
     &maxsockets, 0, sysctl_maxsockets, "IU",
     "Maximum number of sockets avaliable");
 
 /*
- * Initialise maxsockets.  This SYSINIT must be run after
- * tunable_mbinit().
- */
-static void
-init_maxsockets(void *ignored)
-{
-
-	TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets);
-	maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
-}
-SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL);
-
-/*
  * Socket operation routines.  These routines are called by the routines in
  * sys_socket.c or from a system process, and implement the semantics of
  * socket operations by switching out to the protocol specific routines.
@@ -3296,24 +3340,6 @@ socheckuid(struct socket *so, uid_t uid)
 	return (0);
 }
 
-static int
-sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
-{
-	int error;
-	int val;
-
-	val = somaxconn;
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr )
-		return (error);
-
-	if (val < 1 || val > USHRT_MAX)
-		return (EINVAL);
-
-	somaxconn = val;
-	return (0);
-}
-
 /*
  * These functions are used by protocols to notify the socket layer (and its
  * consumers) of state changes in the sockets driven by protocol-side events.

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 15:54:44 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 07D70309;
 Mon,  8 Jul 2013 15:54:44 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id DCD7919C1;
 Mon,  8 Jul 2013 15:54:43 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68FshFD023937;
 Mon, 8 Jul 2013 15:54:43 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68Fscuf023906;
 Mon, 8 Jul 2013 15:54:38 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307081554.r68Fscuf023906@svn.freebsd.org>
From: Alexander Motin 
Date: Mon, 8 Jul 2013 15:54:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253037 - in stable/9/sys: cam cam/ata cam/ctl cam/scsi
 dev/aac dev/arcmsr dev/ata dev/ciss dev/firewire dev/hpt27xx dev/hptiop
 dev/hptrr dev/isci dev/iscsi/initiator dev/isp dev/mfi de...
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 15:54:44 -0000

Author: mav
Date: Mon Jul  8 15:54:38 2013
New Revision: 253037
URL: http://svnweb.freebsd.org/changeset/base/253037

Log:
  MFC r249468:
  Stop abusing xpt_periph in random plases that really have no periph related
  to CCB, for example, bus scanning.  NULL value is fine in such cases and it
  is correctly logged in debug messages as "noperiph".  If at some point we
  need some real XPT periphs (alike to pmpX now), quite likely they will be
  per-bus, and not a single global instance as xpt_periph now.

Modified:
  stable/9/sys/cam/ata/ata_xpt.c
  stable/9/sys/cam/cam_xpt.c
  stable/9/sys/cam/ctl/ctl_frontend_cam_sim.c
  stable/9/sys/cam/scsi/scsi_xpt.c
  stable/9/sys/dev/aac/aac_cam.c
  stable/9/sys/dev/arcmsr/arcmsr.c
  stable/9/sys/dev/ata/atapi-cam.c
  stable/9/sys/dev/ciss/ciss.c
  stable/9/sys/dev/firewire/sbp.c
  stable/9/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
  stable/9/sys/dev/hptiop/hptiop.c
  stable/9/sys/dev/hptrr/hptrr_osm_bsd.c
  stable/9/sys/dev/isci/isci_controller.c
  stable/9/sys/dev/isci/isci_domain.c
  stable/9/sys/dev/isci/isci_remote_device.c
  stable/9/sys/dev/iscsi/initiator/isc_cam.c
  stable/9/sys/dev/isp/isp_freebsd.c
  stable/9/sys/dev/mfi/mfi_cam.c
  stable/9/sys/dev/mly/mly.c
  stable/9/sys/dev/mps/mps_sas.c
  stable/9/sys/dev/mpt/mpt_cam.c
  stable/9/sys/dev/mpt/mpt_raid.c
  stable/9/sys/dev/twa/tw_osl_cam.c
  stable/9/sys/dev/tws/tws_cam.c
  stable/9/sys/dev/virtio/scsi/virtio_scsi.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/dev/isp/   (props changed)

Modified: stable/9/sys/cam/ata/ata_xpt.c
==============================================================================
--- stable/9/sys/cam/ata/ata_xpt.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/cam/ata/ata_xpt.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1445,7 +1445,7 @@ done:
 		scan_info->counter = (scan_info->counter + 1 ) %
 		    (scan_info->cpi->max_target + 1);
 scan_next:
-		status = xpt_create_path(&path, xpt_periph,
+		status = xpt_create_path(&path, NULL,
 		    scan_info->request_ccb->ccb_h.path_id,
 		    scan_info->counter, 0);
 		if (status != CAM_REQ_CMP) {
@@ -1503,7 +1503,7 @@ ata_scan_lun(struct cam_periph *periph, 
 			    "can't continue\n");
 			return;
 		}
-		status = xpt_create_path(&new_path, xpt_periph,
+		status = xpt_create_path(&new_path, NULL,
 					  path->bus->path_id,
 					  path->target->target_id,
 					  path->device->lun_id);

Modified: stable/9/sys/cam/cam_xpt.c
==============================================================================
--- stable/9/sys/cam/cam_xpt.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/cam/cam_xpt.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -497,7 +497,7 @@ xptdoioctl(struct cdev *dev, u_long cmd,
 			 * Create a path using the bus, target, and lun the
 			 * user passed in.
 			 */
-			if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			if (xpt_create_path(&ccb->ccb_h.path, NULL,
 					    inccb->ccb_h.path_id,
 					    inccb->ccb_h.target_id,
 					    inccb->ccb_h.target_lun) !=
@@ -533,7 +533,7 @@ xptdoioctl(struct cdev *dev, u_long cmd,
 			 * Create a path using the bus, target, and lun the
 			 * user passed in.
 			 */
-			if (xpt_create_path(&ccb.ccb_h.path, xpt_periph,
+			if (xpt_create_path(&ccb.ccb_h.path, NULL,
 					    inccb->ccb_h.path_id,
 					    inccb->ccb_h.target_id,
 					    inccb->ccb_h.target_lun) !=
@@ -3062,7 +3062,7 @@ xpt_action_default(union ccb *start_ccb)
 			CAM_SIM_LOCK(xpt_path_sim(start_ccb->ccb_h.path));
 		}
 		if (start_ccb->cdbg.flags != CAM_DEBUG_NONE) {
-			if (xpt_create_path(&cam_dpath, xpt_periph,
+			if (xpt_create_path(&cam_dpath, NULL,
 					    start_ccb->ccb_h.path_id,
 					    start_ccb->ccb_h.target_id,
 					    start_ccb->ccb_h.target_lun) !=
@@ -4862,7 +4862,7 @@ xpt_config(void *arg)
 
 	/* Setup debugging path */
 	if (cam_dflags != CAM_DEBUG_NONE) {
-		if (xpt_create_path_unlocked(&cam_dpath, xpt_periph,
+		if (xpt_create_path_unlocked(&cam_dpath, NULL,
 				    CAM_DEBUG_BUS, CAM_DEBUG_TARGET,
 				    CAM_DEBUG_LUN) != CAM_REQ_CMP) {
 			printf("xpt_config: xpt_create_path() failed for debug"

Modified: stable/9/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- stable/9/sys/cam/ctl/ctl_frontend_cam_sim.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/cam/ctl/ctl_frontend_cam_sim.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -316,7 +316,7 @@ cfcs_onoffline(void *arg, int online)
 		goto bailout;
 	}
 
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+	if (xpt_create_path(&ccb->ccb_h.path, NULL,
 			    cam_sim_path(softc->sim), CAM_TARGET_WILDCARD,
 			    CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		printf("%s: can't allocate path for rescan\n", __func__);

Modified: stable/9/sys/cam/scsi/scsi_xpt.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_xpt.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/cam/scsi/scsi_xpt.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1934,7 +1934,7 @@ scsi_scan_bus(struct cam_periph *periph,
 			if (i == initiator_id)
 				continue;
 
-			status = xpt_create_path(&path, xpt_periph,
+			status = xpt_create_path(&path, NULL,
 						 request_ccb->ccb_h.path_id,
 						 i, 0);
 			if (status != CAM_REQ_CMP) {
@@ -2135,7 +2135,7 @@ scsi_scan_bus(struct cam_periph *periph,
 				xpt_free_ccb(request_ccb);
 				break;
 			}
-			status = xpt_create_path(&path, xpt_periph,
+			status = xpt_create_path(&path, NULL,
 			    scan_info->request_ccb->ccb_h.path_id,
 			    scan_info->counter, 0);
 			if (status != CAM_REQ_CMP) {
@@ -2158,7 +2158,7 @@ scsi_scan_bus(struct cam_periph *periph,
 			request_ccb->crcn.flags =
 			    scan_info->request_ccb->crcn.flags;
 		} else {
-			status = xpt_create_path(&path, xpt_periph,
+			status = xpt_create_path(&path, NULL,
 						 path_id, target_id, lun_id);
 			/*
 			 * Free the old request path- we're done with it. We
@@ -2231,7 +2231,7 @@ scsi_scan_lun(struct cam_periph *periph,
 			    "can't continue\n");
 			return;
 		}
-		status = xpt_create_path(&new_path, xpt_periph,
+		status = xpt_create_path(&new_path, NULL,
 					  path->bus->path_id,
 					  path->target->target_id,
 					  path->device->lun_id);

Modified: stable/9/sys/dev/aac/aac_cam.c
==============================================================================
--- stable/9/sys/dev/aac/aac_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/aac/aac_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -129,7 +129,7 @@ aac_cam_rescan(struct aac_softc *sc, uin
 			return;
 		}
 
-		if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+		if (xpt_create_path(&ccb->ccb_h.path, NULL,
 		    cam_sim_path(camsc->sim),
 		    target_id, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 			xpt_free_ccb(ccb);

Modified: stable/9/sys/dev/arcmsr/arcmsr.c
==============================================================================
--- stable/9/sys/dev/arcmsr/arcmsr.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/arcmsr/arcmsr.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1600,7 +1600,8 @@ static void	arcmsr_rescan_lun(struct Ada
 
 	if ((ccb = (union ccb *)xpt_alloc_ccb_nowait()) == NULL)
  		return;
-	if (xpt_create_path(&path, xpt_periph, cam_sim_path(acb->psim), target, lun) != CAM_REQ_CMP)
+	if (xpt_create_path(&path, NULL, cam_sim_path(acb->psim), target, lun)
+	    != CAM_REQ_CMP)
 	{
 		xpt_free_ccb(ccb);
 		return;

Modified: stable/9/sys/dev/ata/atapi-cam.c
==============================================================================
--- stable/9/sys/dev/ata/atapi-cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/ata/atapi-cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -825,7 +825,7 @@ cam_rescan(struct cam_sim *sim)
     ccb = xpt_alloc_ccb_nowait();
     if (ccb == NULL)
 	return;
-    if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sim),
+    if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(sim),
 			CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 	xpt_free_ccb(ccb);
 	return;

Modified: stable/9/sys/dev/ciss/ciss.c
==============================================================================
--- stable/9/sys/dev/ciss/ciss.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/ciss/ciss.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -2913,7 +2913,7 @@ ciss_cam_rescan_target(struct ciss_softc
 	return;
     }
 
-    if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+    if (xpt_create_path(&ccb->ccb_h.path, NULL,
 	    cam_sim_path(sc->ciss_cam_sim[bus]),
 	    target, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 	ciss_printf(sc, "rescan failed (can't create path)\n");

Modified: stable/9/sys/dev/firewire/sbp.c
==============================================================================
--- stable/9/sys/dev/firewire/sbp.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/firewire/sbp.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1086,7 +1086,7 @@ END_DEBUG
 	sbp_xfer_free(xfer);
 
 	if (sdev->path == NULL)
-		xpt_create_path(&sdev->path, xpt_periph,
+		xpt_create_path(&sdev->path, NULL,
 			cam_sim_path(target->sbp->sim),
 			target->target_id, sdev->lun_id);
 
@@ -2039,7 +2039,7 @@ END_DEBUG
 	if (xpt_bus_register(sbp->sim, dev, /*bus*/0) != CAM_SUCCESS)
 		goto fail;
 
-	if (xpt_create_path(&sbp->path, xpt_periph, cam_sim_path(sbp->sim),
+	if (xpt_create_path(&sbp->path, NULL, cam_sim_path(sbp->sim),
 	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_bus_deregister(cam_sim_path(sbp->sim));
 		goto fail;

Modified: stable/9/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
==============================================================================
--- stable/9/sys/dev/hpt27xx/hpt27xx_osm_bsd.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/hpt27xx/hpt27xx_osm_bsd.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1347,7 +1347,7 @@ static int	hpt_rescan_bus(void)
 		{
 			return(ENOMEM);
 		}
-		if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(vbus_ext->sim),
+		if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(vbus_ext->sim),
 			CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP)	
 		{
 			xpt_free_ccb(ccb);

Modified: stable/9/sys/dev/hptiop/hptiop.c
==============================================================================
--- stable/9/sys/dev/hptiop/hptiop.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/hptiop/hptiop.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1437,7 +1437,7 @@ static int  hptiop_rescan_bus(struct hpt
 
 	if ((ccb = xpt_alloc_ccb()) == NULL)
 		return(ENOMEM);
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(hba->sim),
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(hba->sim),
 		CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_free_ccb(ccb);
 		return(EIO);

Modified: stable/9/sys/dev/hptrr/hptrr_osm_bsd.c
==============================================================================
--- stable/9/sys/dev/hptrr/hptrr_osm_bsd.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/hptrr/hptrr_osm_bsd.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1355,7 +1355,7 @@ static int	hpt_rescan_bus(void)
 	ldm_for_each_vbus(vbus, vbus_ext) {
 		if ((ccb = xpt_alloc_ccb()) == NULL)
 			return(ENOMEM);
-		if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+		if (xpt_create_path(&ccb->ccb_h.path, NULL,
 		    cam_sim_path(vbus_ext->sim),
 		    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 			xpt_free_ccb(ccb);

Modified: stable/9/sys/dev/isci/isci_controller.c
==============================================================================
--- stable/9/sys/dev/isci/isci_controller.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/isci/isci_controller.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -539,7 +539,7 @@ void isci_controller_domain_discovery_co
 			 */
 			union ccb *ccb = xpt_alloc_ccb_nowait();
 
-			xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			xpt_create_path(&ccb->ccb_h.path, NULL,
 			    cam_sim_path(isci_controller->sim),
 			    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 

Modified: stable/9/sys/dev/isci/isci_domain.c
==============================================================================
--- stable/9/sys/dev/isci/isci_domain.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/isci/isci_domain.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -300,7 +300,7 @@ scif_cb_domain_device_removed(SCI_CONTRO
 
 	isci_controller->remote_device[isci_remote_device->index] = NULL;
 
-	xpt_create_path(&ccb->ccb_h.path, xpt_periph, path,
+	xpt_create_path(&ccb->ccb_h.path, NULL, path,
 	    isci_remote_device->index, CAM_LUN_WILDCARD);
 
 	xpt_rescan(ccb);

Modified: stable/9/sys/dev/isci/isci_remote_device.c
==============================================================================
--- stable/9/sys/dev/isci/isci_remote_device.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/isci/isci_remote_device.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -83,7 +83,7 @@ scif_cb_remote_device_ready(SCI_CONTROLL
 			 */
 			union ccb *ccb = xpt_alloc_ccb_nowait();
 
-			xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			xpt_create_path(&ccb->ccb_h.path, NULL,
 			    cam_sim_path(isci_controller->sim),
 			    isci_remote_device->index, CAM_LUN_WILDCARD);
 
@@ -262,7 +262,7 @@ isci_remote_device_freeze_lun_queue(stru
 	if (!(remote_device->frozen_lun_mask & (1 << lun))) {
 		struct cam_path *path;
 
-		xpt_create_path(&path, xpt_periph,
+		xpt_create_path(&path, NULL,
 		    cam_sim_path(remote_device->domain->controller->sim),
 		    remote_device->index, lun);
 		xpt_freeze_devq(path, 1);
@@ -279,7 +279,7 @@ isci_remote_device_release_lun_queue(str
 		struct cam_path *path;
 
 		remote_device->frozen_lun_mask &= ~(1 << lun);
-		xpt_create_path(&path, xpt_periph,
+		xpt_create_path(&path, NULL,
 		    cam_sim_path(remote_device->domain->controller->sim),
 		    remote_device->index, lun);
 		xpt_release_devq(path, 1, TRUE);

Modified: stable/9/sys/dev/iscsi/initiator/isc_cam.c
==============================================================================
--- stable/9/sys/dev/iscsi/initiator/isc_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/iscsi/initiator/isc_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -150,7 +150,7 @@ ic_scan(isc_session_t *sp)
      sp->flags |= ISC_SCANWAIT;
 
      CAM_LOCK(sp);
-     if(xpt_create_path(&sp->cam_path, xpt_periph, cam_sim_path(sp->cam_sim),
+     if(xpt_create_path(&sp->cam_path, NULL, cam_sim_path(sp->cam_sim),
 			0, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 	  xdebug("can't create cam path");
 	  CAM_UNLOCK(sp);

Modified: stable/9/sys/dev/isp/isp_freebsd.c
==============================================================================
--- stable/9/sys/dev/isp/isp_freebsd.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/isp/isp_freebsd.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -4556,7 +4556,8 @@ isp_make_here(ispsoftc_t *isp, int chan,
 		isp_prt(isp, ISP_LOGWARN, "Chan %d unable to alloc CCB for rescan", chan);
 		return;
 	}
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(fc->sim), tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(fc->sim),
+	    tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		isp_prt(isp, ISP_LOGWARN, "unable to create path for rescan");
 		xpt_free_ccb(ccb);
 		return;

Modified: stable/9/sys/dev/mfi/mfi_cam.c
==============================================================================
--- stable/9/sys/dev/mfi/mfi_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/mfi/mfi_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -318,7 +318,7 @@ mfip_cam_rescan(struct mfi_softc *sc, ui
 
 	sim = camsc->sim;
 	mtx_lock(&sc->mfi_io_lock);
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sim),
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(sim),
 	    tid, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_free_ccb(ccb);
 		mtx_unlock(&sc->mfi_io_lock);

Modified: stable/9/sys/dev/mly/mly.c
==============================================================================
--- stable/9/sys/dev/mly/mly.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/mly/mly.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -2026,7 +2026,7 @@ mly_cam_rescan_btl(struct mly_softc *sc,
 	mly_printf(sc, "rescan failed (can't allocate CCB)\n");
 	return;
     }
-    if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, 
+    if (xpt_create_path(&ccb->ccb_h.path, NULL,
 	    cam_sim_path(sc->mly_cam_sim[bus]), target, 0) != CAM_REQ_CMP) {
 	mly_printf(sc, "rescan failed (can't create path)\n");
 	xpt_free_ccb(ccb);

Modified: stable/9/sys/dev/mps/mps_sas.c
==============================================================================
--- stable/9/sys/dev/mps/mps_sas.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/mps/mps_sas.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -271,7 +271,7 @@ mpssas_rescan_target(struct mps_softc *s
 		return;
 	}
 
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, pathid,
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid,
 		            targetid, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		mps_dprint(sc, MPS_FAULT, "unable to create path for rescan\n");
 		xpt_free_ccb(ccb);
@@ -3318,7 +3318,7 @@ mpssas_check_eedp(struct mpssas_softc *s
 				return;
 			}
 
-			if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			if (xpt_create_path(&ccb->ccb_h.path, NULL,
 			    pathid, targetid, lunid) != CAM_REQ_CMP) {
 				mps_dprint(sc, MPS_FAULT, "Unable to create "
 				    "path for EEDP support\n");

Modified: stable/9/sys/dev/mpt/mpt_cam.c
==============================================================================
--- stable/9/sys/dev/mpt/mpt_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/mpt/mpt_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -2364,7 +2364,7 @@ mpt_cam_event(struct mpt_softc *mpt, req
 			break;
 		}
 
-		if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, pathid,
+		if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid,
 		    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 			mpt_prt(mpt, "unable to create path for rescan\n");
 			xpt_free_ccb(ccb);
@@ -2512,7 +2512,7 @@ mpt_cam_event(struct mpt_softc *mpt, req
 				    "unable to alloc CCB for rescan\n");
 				break;
 			}
-			if (xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			if (xpt_create_path(&ccb->ccb_h.path, NULL,
 			    cam_sim_path(sim), psdsc->TargetID,
 			    CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 				mpt_prt(mpt,

Modified: stable/9/sys/dev/mpt/mpt_raid.c
==============================================================================
--- stable/9/sys/dev/mpt/mpt_raid.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/mpt/mpt_raid.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -705,7 +705,7 @@ mpt_raid_thread(void *arg)
 			ccb = xpt_alloc_ccb();
 
 			MPT_LOCK(mpt);
-			error = xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+			error = xpt_create_path(&ccb->ccb_h.path, NULL,
 			    cam_sim_path(mpt->phydisk_sim),
 			    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 			if (error != CAM_REQ_CMP) {
@@ -1662,7 +1662,7 @@ mpt_raid_set_vol_queue_depth(struct mpt_
 
 		mpt->raid_rescan = 0;
 
-		error = xpt_create_path(&path, xpt_periph,
+		error = xpt_create_path(&path, NULL,
 					cam_sim_path(mpt->sim),
 					mpt_vol->config_page->VolumeID,
 					/*lun*/0);

Modified: stable/9/sys/dev/twa/tw_osl_cam.c
==============================================================================
--- stable/9/sys/dev/twa/tw_osl_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/twa/tw_osl_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -488,7 +488,7 @@ tw_osli_request_bus_scan(struct twa_soft
 	if ((ccb = xpt_alloc_ccb()) == NULL)
 		return(ENOMEM);
 	mtx_lock(sc->sim_lock);
-	if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sc->sim),
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(sc->sim),
 	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_free_ccb(ccb);
 		mtx_unlock(sc->sim_lock);

Modified: stable/9/sys/dev/tws/tws_cam.c
==============================================================================
--- stable/9/sys/dev/tws/tws_cam.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/tws/tws_cam.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -221,7 +221,7 @@ tws_bus_scan(struct tws_softc *sc)
     if ((ccb = xpt_alloc_ccb()) == NULL)
 		    return(ENOMEM);
 
-    if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sc->sim),
+    if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(sc->sim),
                   CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
         xpt_free_ccb(ccb);
         return(EIO);

Modified: stable/9/sys/dev/virtio/scsi/virtio_scsi.c
==============================================================================
--- stable/9/sys/dev/virtio/scsi/virtio_scsi.c	Mon Jul  8 15:28:09 2013	(r253036)
+++ stable/9/sys/dev/virtio/scsi/virtio_scsi.c	Mon Jul  8 15:54:38 2013	(r253037)
@@ -1702,7 +1702,7 @@ vtscsi_execute_rescan(struct vtscsi_soft
 		return;
 	}
 
-	status = xpt_create_path(&ccb->ccb_h.path, xpt_periph,
+	status = xpt_create_path(&ccb->ccb_h.path, NULL,
 	    cam_sim_path(sc->vtscsi_sim), target_id, lun_id);
 	if (status != CAM_REQ_CMP) {
 		xpt_free_ccb(ccb);

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 15:59:12 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 09407517;
 Mon,  8 Jul 2013 15:59:12 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id EECEC19F4;
 Mon,  8 Jul 2013 15:59:11 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68FxBIt024590;
 Mon, 8 Jul 2013 15:59:11 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68FxBxs024589;
 Mon, 8 Jul 2013 15:59:11 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307081559.r68FxBxs024589@svn.freebsd.org>
From: Alexander Motin 
Date: Mon, 8 Jul 2013 15:59:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253038 - stable/9/sys/cam/ctl
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 15:59:12 -0000

Author: mav
Date: Mon Jul  8 15:59:11 2013
New Revision: 253038
URL: http://svnweb.freebsd.org/changeset/base/253038

Log:
  MFC r252569:
  Fix NULL-deference kernel panic on attempt of destroying non-existing
  ramdisk-backed CTL LUN.

Modified:
  stable/9/sys/cam/ctl/ctl_backend_ramdisk.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/ctl/ctl_backend_ramdisk.c
==============================================================================
--- stable/9/sys/cam/ctl/ctl_backend_ramdisk.c	Mon Jul  8 15:54:38 2013	(r253037)
+++ stable/9/sys/cam/ctl/ctl_backend_ramdisk.c	Mon Jul  8 15:59:11 2013	(r253038)
@@ -441,6 +441,9 @@ ctl_backend_ramdisk_rm(struct ctl_be_ram
 		snprintf(req->error_str, sizeof(req->error_str),
 			 "%s: error %d returned from ctl_invalidate_lun() for "
 			 "LUN %d", __func__, retval, params->lun_id);
+		mtx_lock(&softc->lock);
+		be_lun->flags &= ~CTL_BE_RAMDISK_LUN_WAITING;
+		mtx_unlock(&softc->lock);
 		goto bailout_error;
 	}
 
@@ -475,14 +478,6 @@ ctl_backend_ramdisk_rm(struct ctl_be_ram
 	return (retval);
 
 bailout_error:
-
-	/*
-	 * Don't leave the waiting flag set.
-	 */
-	mtx_lock(&softc->lock);
-	be_lun->flags &= ~CTL_BE_RAMDISK_LUN_WAITING;
-	mtx_unlock(&softc->lock);
-
 	req->status = CTL_LUN_ERROR;
 
 	return (0);

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 16:02:04 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 256D67AC;
 Mon,  8 Jul 2013 16:02:04 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 167911A24;
 Mon,  8 Jul 2013 16:02:04 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68G23ic026882;
 Mon, 8 Jul 2013 16:02:03 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68G23Ai026881;
 Mon, 8 Jul 2013 16:02:03 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307081602.r68G23Ai026881@svn.freebsd.org>
From: Alexander Motin 
Date: Mon, 8 Jul 2013 16:02:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253039 - stable/9/sys/cam/scsi
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 16:02:04 -0000

Author: mav
Date: Mon Jul  8 16:02:03 2013
New Revision: 253039
URL: http://svnweb.freebsd.org/changeset/base/253039

Log:
  MFC r252204, r252250:
  Add bunch of names for Seagate and HGST vennor-specififc ASC/ASCQ codes.

Modified:
  stable/9/sys/cam/scsi/scsi_all.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_all.c	Mon Jul  8 15:59:11 2013	(r253038)
+++ stable/9/sys/cam/scsi/scsi_all.c	Mon Jul  8 16:02:03 2013	(r253039)
@@ -737,6 +737,172 @@ static struct asc_table_entry sony_mo_en
 	     "Logical unit not ready, cause not reportable") }
 };
 
+static struct asc_table_entry hgst_entries[] = {
+	{ SST(0x04, 0xF0, SS_RDEF,
+	    "Vendor Unique - Logical Unit Not Ready") },
+	{ SST(0x0A, 0x01, SS_RDEF,
+	    "Unrecovered Super Certification Log Write Error") },
+	{ SST(0x0A, 0x02, SS_RDEF,
+	    "Unrecovered Super Certification Log Read Error") },
+	{ SST(0x15, 0x03, SS_RDEF,
+	    "Unrecovered Sector Error") },
+	{ SST(0x3E, 0x04, SS_RDEF,
+	    "Unrecovered Self-Test Hard-Cache Test Fail") },
+	{ SST(0x3E, 0x05, SS_RDEF,
+	    "Unrecovered Self-Test OTF-Cache Fail") },
+	{ SST(0x40, 0x00, SS_RDEF,
+	    "Unrecovered SAT No Buffer Overflow Error") },
+	{ SST(0x40, 0x01, SS_RDEF,
+	    "Unrecovered SAT Buffer Overflow Error") },
+	{ SST(0x40, 0x02, SS_RDEF,
+	    "Unrecovered SAT No Buffer Overflow With ECS Fault") },
+	{ SST(0x40, 0x03, SS_RDEF,
+	    "Unrecovered SAT Buffer Overflow With ECS Fault") },
+	{ SST(0x40, 0x81, SS_RDEF,
+	    "DRAM Failure") },
+	{ SST(0x44, 0x0B, SS_RDEF,
+	    "Vendor Unique - Internal Target Failure") },
+	{ SST(0x44, 0xF2, SS_RDEF,
+	    "Vendor Unique - Internal Target Failure") },
+	{ SST(0x44, 0xF6, SS_RDEF,
+	    "Vendor Unique - Internal Target Failure") },
+	{ SST(0x44, 0xF9, SS_RDEF,
+	    "Vendor Unique - Internal Target Failure") },
+	{ SST(0x44, 0xFA, SS_RDEF,
+	    "Vendor Unique - Internal Target Failure") },
+	{ SST(0x5D, 0x22, SS_RDEF,
+	    "Extreme Over-Temperature Warning") },
+	{ SST(0x5D, 0x50, SS_RDEF,
+	    "Load/Unload cycle Count Warning") },
+	{ SST(0x81, 0x00, SS_RDEF,
+	    "Vendor Unique - Internal Logic Error") },
+	{ SST(0x85, 0x00, SS_RDEF,
+	    "Vendor Unique - Internal Key Seed Error") },
+};
+
+static struct asc_table_entry seagate_entries[] = {
+	{ SST(0x04, 0xF0, SS_RDEF,
+	    "Logical Unit Not Ready, super certify in Progress") },
+	{ SST(0x08, 0x86, SS_RDEF,
+	    "Write Fault Data Corruption") },
+	{ SST(0x09, 0x0D, SS_RDEF,
+	    "Tracking Failure") },
+	{ SST(0x09, 0x0E, SS_RDEF,
+	    "ETF Failure") },
+	{ SST(0x0B, 0x5D, SS_RDEF,
+	    "Pre-SMART Warning") },
+	{ SST(0x0B, 0x85, SS_RDEF,
+	    "5V Voltage Warning") },
+	{ SST(0x0B, 0x8C, SS_RDEF,
+	    "12V Voltage Warning") },
+	{ SST(0x0C, 0xFF, SS_RDEF,
+	    "Write Error - Too many error recovery revs") },
+	{ SST(0x11, 0xFF, SS_RDEF,
+	    "Unrecovered Read Error - Too many error recovery revs") },
+	{ SST(0x19, 0x0E, SS_RDEF,
+	    "Fewer than 1/2 defect list copies") },
+	{ SST(0x20, 0xF3, SS_RDEF,
+	    "Illegal CDB linked to skip mask cmd") },
+	{ SST(0x24, 0xF0, SS_RDEF,
+	    "Illegal byte in CDB, LBA not matching") },
+	{ SST(0x24, 0xF1, SS_RDEF,
+	    "Illegal byte in CDB, LEN not matching") },
+	{ SST(0x24, 0xF2, SS_RDEF,
+	    "Mask not matching transfer length") },
+	{ SST(0x24, 0xF3, SS_RDEF,
+	    "Drive formatted without plist") },
+	{ SST(0x26, 0x95, SS_RDEF,
+	    "Invalid Field Parameter - CAP File") },
+	{ SST(0x26, 0x96, SS_RDEF,
+	    "Invalid Field Parameter - RAP File") },
+	{ SST(0x26, 0x97, SS_RDEF,
+	    "Invalid Field Parameter - TMS Firmware Tag") },
+	{ SST(0x26, 0x98, SS_RDEF,
+	    "Invalid Field Parameter - Check Sum") },
+	{ SST(0x26, 0x99, SS_RDEF,
+	    "Invalid Field Parameter - Firmware Tag") },
+	{ SST(0x29, 0x08, SS_RDEF,
+	    "Write Log Dump data") },
+	{ SST(0x29, 0x09, SS_RDEF,
+	    "Write Log Dump data") },
+	{ SST(0x29, 0x0A, SS_RDEF,
+	    "Reserved disk space") },
+	{ SST(0x29, 0x0B, SS_RDEF,
+	    "SDBP") },
+	{ SST(0x29, 0x0C, SS_RDEF,
+	    "SDBP") },
+	{ SST(0x31, 0x91, SS_RDEF,
+	    "Format Corrupted World Wide Name (WWN) is Invalid") },
+	{ SST(0x32, 0x03, SS_RDEF,
+	    "Defect List - Length exceeds Command Allocated Length") },
+	{ SST(0x33, 0x00, SS_RDEF,
+	    "Flash not ready for access") },
+	{ SST(0x3F, 0x70, SS_RDEF,
+	    "Invalid RAP block") },
+	{ SST(0x3F, 0x71, SS_RDEF,
+	    "RAP/ETF mismatch") },
+	{ SST(0x3F, 0x90, SS_RDEF,
+	    "Invalid CAP block") },
+	{ SST(0x3F, 0x91, SS_RDEF,
+	    "World Wide Name (WWN) Mismatch") },
+	{ SST(0x40, 0x01, SS_RDEF,
+	    "DRAM Parity Error") },
+	{ SST(0x40, 0x02, SS_RDEF,
+	    "DRAM Parity Error") },
+	{ SST(0x42, 0x0A, SS_RDEF,
+	    "Loopback Test") },
+	{ SST(0x42, 0x0B, SS_RDEF,
+	    "Loopback Test") },
+	{ SST(0x44, 0xF2, SS_RDEF,
+	    "Compare error during data integrity check") },
+	{ SST(0x44, 0xF6, SS_RDEF,
+	    "Unrecoverable error during data integrity check") },
+	{ SST(0x47, 0x80, SS_RDEF,
+	    "Fibre Channel Sequence Error") },
+	{ SST(0x4E, 0x01, SS_RDEF,
+	    "Information Unit Too Short") },
+	{ SST(0x80, 0x00, SS_RDEF,
+	    "General Firmware Error / Command Timeout") },
+	{ SST(0x80, 0x01, SS_RDEF,
+	    "Command Timeout") },
+	{ SST(0x80, 0x02, SS_RDEF,
+	    "Command Timeout") },
+	{ SST(0x80, 0x80, SS_RDEF,
+	    "FC FIFO Error During Read Transfer") },
+	{ SST(0x80, 0x81, SS_RDEF,
+	    "FC FIFO Error During Write Transfer") },
+	{ SST(0x80, 0x82, SS_RDEF,
+	    "DISC FIFO Error During Read Transfer") },
+	{ SST(0x80, 0x83, SS_RDEF,
+	    "DISC FIFO Error During Write Transfer") },
+	{ SST(0x80, 0x84, SS_RDEF,
+	    "LBA Seeded LRC Error on Read") },
+	{ SST(0x80, 0x85, SS_RDEF,
+	    "LBA Seeded LRC Error on Write") },
+	{ SST(0x80, 0x86, SS_RDEF,
+	    "IOEDC Error on Read") },
+	{ SST(0x80, 0x87, SS_RDEF,
+	    "IOEDC Error on Write") },
+	{ SST(0x80, 0x88, SS_RDEF,
+	    "Host Parity Check Failed") },
+	{ SST(0x80, 0x89, SS_RDEF,
+	    "IOEDC error on read detected by formatter") },
+	{ SST(0x80, 0x8A, SS_RDEF,
+	    "Host Parity Errors / Host FIFO Initialization Failed") },
+	{ SST(0x80, 0x8B, SS_RDEF,
+	    "Host Parity Errors") },
+	{ SST(0x80, 0x8C, SS_RDEF,
+	    "Host Parity Errors") },
+	{ SST(0x80, 0x8D, SS_RDEF,
+	    "Host Parity Errors") },
+	{ SST(0x81, 0x00, SS_RDEF,
+	    "LA Check Failed") },
+	{ SST(0x82, 0x00, SS_RDEF,
+	    "Internal client detected insufficient buffer") },
+	{ SST(0x84, 0x00, SS_RDEF,
+	    "Scheduled Diagnostic And Repair") },
+};
+
 static struct scsi_sense_quirk_entry sense_quirk_table[] = {
 	{
 		/*
@@ -759,6 +925,26 @@ static struct scsi_sense_quirk_entry sen
 		sizeof(sony_mo_entries)/sizeof(struct asc_table_entry),
 		/*sense key entries*/NULL,
 		sony_mo_entries
+	},
+	{
+		/*
+		 * HGST vendor-specific error codes
+		 */
+		{T_DIRECT, SIP_MEDIA_FIXED, "HGST", "*", "*"},
+		/*num_sense_keys*/0,
+		sizeof(hgst_entries)/sizeof(struct asc_table_entry),
+		/*sense key entries*/NULL,
+		hgst_entries
+	},
+	{
+		/*
+		 * SEAGATE vendor-specific error codes
+		 */
+		{T_DIRECT, SIP_MEDIA_FIXED, "SEAGATE", "*", "*"},
+		/*num_sense_keys*/0,
+		sizeof(seagate_entries)/sizeof(struct asc_table_entry),
+		/*sense key entries*/NULL,
+		seagate_entries
 	}
 };
 

From owner-svn-src-stable-9@FreeBSD.ORG  Mon Jul  8 17:20:05 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 8FDD5BE2;
 Mon,  8 Jul 2013 17:20:05 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 808411DB1;
 Mon,  8 Jul 2013 17:20:05 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68HK5kR048859;
 Mon, 8 Jul 2013 17:20:05 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r68HK5Sk048858;
 Mon, 8 Jul 2013 17:20:05 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307081720.r68HK5Sk048858@svn.freebsd.org>
From: Alexander Motin 
Date: Mon, 8 Jul 2013 17:20:05 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253041 - stable/9/sys/dev/ata/chipsets
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 08 Jul 2013 17:20:05 -0000

Author: mav
Date: Mon Jul  8 17:20:05 2013
New Revision: 253041
URL: http://svnweb.freebsd.org/changeset/base/253041

Log:
  MFC r252203:
  Add test for SATA registers writability and skip using them if it failed.
  
  There are some systems reported, where PCI BAR(5), used for SATA registers
  access, is present, but not functional.  Attempt to use it brakes devices
  detection logic.  Try to detect those cases on attach by setting and testing
  some bits in SControl register.  If bits are unsettable, fallback to legacy
  ATA without hot-plug detection, speed control/reporting, etc.

Modified:
  stable/9/sys/dev/ata/chipsets/ata-intel.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/ata/chipsets/ata-intel.c
==============================================================================
--- stable/9/sys/dev/ata/chipsets/ata-intel.c	Mon Jul  8 16:03:18 2013	(r253040)
+++ stable/9/sys/dev/ata/chipsets/ata-intel.c	Mon Jul  8 17:20:05 2013	(r253041)
@@ -73,6 +73,7 @@ static int ata_intel_sata_cscr_write(dev
     int reg, u_int32_t result);
 static int ata_intel_sata_sidpr_write(device_t dev, int port,
     int reg, u_int32_t result);
+static int ata_intel_sata_sidpr_test(device_t dev);
 static int ata_intel_31244_ch_attach(device_t dev);
 static int ata_intel_31244_ch_detach(device_t dev);
 static int ata_intel_31244_status(device_t dev);
@@ -417,22 +418,20 @@ ata_intel_ch_attach(device_t dev)
 		}
 		if (ch->flags & ATA_SATA) {
 			if ((ctlr->chip->cfg1 & INTEL_ICH5)) {
-				ch->flags |= ATA_PERIODIC_POLL;
-				ch->hw.status = ata_intel_sata_status;
 				ch->hw.pm_read = ata_intel_sata_cscr_read;
 				ch->hw.pm_write = ata_intel_sata_cscr_write;
 			} else if (ctlr->r_res2) {
-				ch->flags |= ATA_PERIODIC_POLL;
-				ch->hw.status = ata_intel_sata_status;
 				if ((ctlr->chip->cfg1 & INTEL_ICH7)) {
 					ch->hw.pm_read = ata_intel_sata_ahci_read;
 					ch->hw.pm_write = ata_intel_sata_ahci_write;
-				} else {
+				} else if (ata_intel_sata_sidpr_test(dev)) {
 					ch->hw.pm_read = ata_intel_sata_sidpr_read;
 					ch->hw.pm_write = ata_intel_sata_sidpr_write;
 				};
 			}
 			if (ch->hw.pm_write != NULL) {
+				ch->flags |= ATA_PERIODIC_POLL;
+				ch->hw.status = ata_intel_sata_status;
 				ata_sata_scr_write(ch, 0,
 				    ATA_SERROR, 0xffffffff);
 				if ((ch->flags & ATA_NO_SLAVE) == 0) {
@@ -836,6 +835,32 @@ ata_intel_sata_sidpr_write(device_t dev,
 }
 
 static int
+ata_intel_sata_sidpr_test(device_t dev)
+{
+	struct ata_channel *ch = device_get_softc(dev);
+	int port;
+	uint32_t val;
+
+	port = (ch->flags & ATA_NO_SLAVE) ? 0 : 1;
+	for (; port >= 0; port--) {
+		ata_intel_sata_sidpr_read(dev, port, ATA_SCONTROL, &val);
+		if ((val & ATA_SC_IPM_MASK) ==
+		    (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER))
+			return (1);
+		val |= ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER;
+		ata_intel_sata_sidpr_write(dev, port, ATA_SCONTROL, val);
+		ata_intel_sata_sidpr_read(dev, port, ATA_SCONTROL, &val);
+		if ((val & ATA_SC_IPM_MASK) ==
+		    (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER))
+			return (1);
+	}
+	if (bootverbose)
+		device_printf(dev,
+		    "SControl registers are not functional: %08x\n", val);
+	return (0);
+}
+
+static int
 ata_intel_31244_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));

From owner-svn-src-stable-9@FreeBSD.ORG  Tue Jul  9 07:51:11 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id CB9FA502;
 Tue,  9 Jul 2013 07:51:11 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id BE1E81E64;
 Tue,  9 Jul 2013 07:51:11 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697pBhR002093;
 Tue, 9 Jul 2013 07:51:11 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r697pBX3002091;
 Tue, 9 Jul 2013 07:51:11 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307090751.r697pBX3002091@svn.freebsd.org>
From: Hiroki Sato 
Date: Tue, 9 Jul 2013 07:51:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253059 - in stable/9/sys/dev/usb: . quirk
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 09 Jul 2013 07:51:11 -0000

Author: hrs
Date: Tue Jul  9 07:51:11 2013
New Revision: 253059
URL: http://svnweb.freebsd.org/changeset/base/253059

Log:
  MFC r252501:
  
  Add Planex MZK-UE150N.
  
  Submitted by:	Yusuke Tanaka

Modified:
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/usbdevs
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- stable/9/sys/dev/usb/quirk/usb_quirk.c	Tue Jul  9 07:08:36 2013	(r253058)
+++ stable/9/sys/dev/usb/quirk/usb_quirk.c	Tue Jul  9 07:51:11 2013	(r253059)
@@ -94,6 +94,7 @@ static struct usb_quirk_entry usb_quirks
 	USB_QUIRK(SILICONPORTALS, YAPPHONE, 0x100, 0x100, UQ_AU_INP_ASYNC),
 	USB_QUIRK(LOGITECH, UN53B, 0x0000, 0xffff, UQ_NO_STRINGS),
 	USB_QUIRK(ELSA, MODEM1, 0x0000, 0xffff, UQ_CFG_INDEX_1),
+	USB_QUIRK(PLANEX2, MZKUE150N, 0x0000, 0xffff, UQ_CFG_INDEX_1),
 	/* Quirks for printer devices */
 	USB_QUIRK(HP, 895C, 0x0000, 0xffff, UQ_BROKEN_BIDIR),
 	USB_QUIRK(HP, 880C, 0x0000, 0xffff, UQ_BROKEN_BIDIR),

Modified: stable/9/sys/dev/usb/usbdevs
==============================================================================
--- stable/9/sys/dev/usb/usbdevs	Tue Jul  9 07:08:36 2013	(r253058)
+++ stable/9/sys/dev/usb/usbdevs	Tue Jul  9 07:51:11 2013	(r253059)
@@ -3271,6 +3271,7 @@ product PLANEX2 GW_US54GXS	0x5303	GW-US5
 product PLANEX2 GWUS54HP	0xab01	GW-US54HP
 product PLANEX2 GWUS300MINIS	0xab24	GW-US300MiniS
 product PLANEX2	RT3070		0xab25	RT3070
+product PLANEX2 MZKUE150N	0xab2f	MZK-UE150N
 product PLANEX2 GWUS54MINI2	0xab50	GW-US54Mini2
 product PLANEX2 GWUS54SG	0xc002	GW-US54SG
 product PLANEX2 GWUS54GZL	0xc007	GW-US54GZL

From owner-svn-src-stable-9@FreeBSD.ORG  Tue Jul  9 07:59:48 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 54997980;
 Tue,  9 Jul 2013 07:59:48 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 45AC51EB2;
 Tue,  9 Jul 2013 07:59:48 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697xmm7003323;
 Tue, 9 Jul 2013 07:59:48 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r697xmCr003322;
 Tue, 9 Jul 2013 07:59:48 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307090759.r697xmCr003322@svn.freebsd.org>
From: Hiroki Sato 
Date: Tue, 9 Jul 2013 07:59:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253062 - stable/9/sbin/ifconfig
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 09 Jul 2013 07:59:48 -0000

Author: hrs
Date: Tue Jul  9 07:59:47 2013
New Revision: 253062
URL: http://svnweb.freebsd.org/changeset/base/253062

Log:
  MFC 252408, 252557:
  
  Do not display a warning message in a jail without AF_INET6 support.

Modified:
  stable/9/sbin/ifconfig/af_nd6.c
Directory Properties:
  stable/9/sbin/ifconfig/   (props changed)

Modified: stable/9/sbin/ifconfig/af_nd6.c
==============================================================================
--- stable/9/sbin/ifconfig/af_nd6.c	Tue Jul  9 07:57:10 2013	(r253061)
+++ stable/9/sbin/ifconfig/af_nd6.c	Tue Jul  9 07:59:47 2013	(r253062)
@@ -148,7 +148,7 @@ nd6_status(int s)
 	memset(&nd, 0, sizeof(nd));
 	strncpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
 	if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-		if (errno != EPROTONOSUPPORT)
+		if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
 			warn("socket(AF_INET6, SOCK_DGRAM)");
 		return;
 	}

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 00:31:29 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 89E22AE2;
 Wed, 10 Jul 2013 00:31:29 +0000 (UTC)
 (envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 640C018D7;
 Wed, 10 Jul 2013 00:31:29 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A0VTMX006223;
 Wed, 10 Jul 2013 00:31:29 GMT
 (envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6A0VTLC006222;
 Wed, 10 Jul 2013 00:31:29 GMT
 (envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201307100031.r6A0VTLC006222@svn.freebsd.org>
From: Rick Macklem 
Date: Wed, 10 Jul 2013 00:31:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253124 - stable/9/sys/fs/nfsclient
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 00:31:29 -0000

Author: rmacklem
Date: Wed Jul 10 00:31:28 2013
New Revision: 253124
URL: http://svnweb.freebsd.org/changeset/base/253124

Log:
  MFC: r252528
  A problem with the old NFS client where large writes to large files
  would sometimes result in a corrupted file was reported via email.
  This problem appears to have been caused by r251719 (reverting
  r251719 fixed the problem). Although I have not been able to
  reproduce this problem, I suspect it is caused by another thread
  increasing np->n_size after the mtx_unlock(&np->n_mtx) but before
  the vnode_pager_setsize() call. Since the np->n_mtx mutex serializes
  updates to np->n_size, doing the vnode_pager_setsize() with the
  mutex locked appears to avoid the problem.
  Unfortunately, vnode_pager_setsize() where the new size is smaller,
  cannot be called with a mutex held.
  This patch returns the semantics to be close to pre-r251719 (actually
  pre-r248567, r248581, r248567 for the new client) such that the call to
  vnode_pager_setsize() is only delayed until after the mutex is
  unlocked when np->n_size is shrinking. Since the file is growing
  when being written, I believe this will fix the corruption.
  A better solution might be to replace the mutex with a sleep lock,
  but that is a non-trivial conversion, so this fix is hoped to be
  sufficient in the meantime.
  
  Tested by:	remy.nonnenmacher@activnetworks.com

Modified:
  stable/9/sys/fs/nfsclient/nfs_clport.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clport.c	Tue Jul  9 23:54:43 2013	(r253123)
+++ stable/9/sys/fs/nfsclient/nfs_clport.c	Wed Jul 10 00:31:28 2013	(r253124)
@@ -439,6 +439,7 @@ nfscl_loadattrcache(struct vnode **vpp, 
 				vap->va_size = np->n_size;
 				np->n_attrstamp = 0;
 				KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
+				vnode_pager_setsize(vp, np->n_size);
 			} else if (np->n_flag & NMODIFIED) {
 				/*
 				 * We've modified the file: Use the larger
@@ -450,12 +451,22 @@ nfscl_loadattrcache(struct vnode **vpp, 
 					np->n_size = vap->va_size;
 					np->n_flag |= NSIZECHANGED;
 				}
+				vnode_pager_setsize(vp, np->n_size);
+			} else if (vap->va_size < np->n_size) {
+				/*
+				 * When shrinking the size, the call to
+				 * vnode_pager_setsize() cannot be done
+				 * with the mutex held, so delay it until
+				 * after the mtx_unlock call.
+				 */
+				nsize = np->n_size = vap->va_size;
+				np->n_flag |= NSIZECHANGED;
+				setnsize = 1;
 			} else {
 				np->n_size = vap->va_size;
 				np->n_flag |= NSIZECHANGED;
+				vnode_pager_setsize(vp, np->n_size);
 			}
-			setnsize = 1;
-			nsize = vap->va_size;
 		} else {
 			np->n_size = vap->va_size;
 		}

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 01:26:23 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 7AEEE5F8;
 Wed, 10 Jul 2013 01:26:23 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 6D65A1A84;
 Wed, 10 Jul 2013 01:26:23 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A1QNBC022371;
 Wed, 10 Jul 2013 01:26:23 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6A1QNem022370;
 Wed, 10 Jul 2013 01:26:23 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307100126.r6A1QNem022370@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Wed, 10 Jul 2013 01:26:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253126 - stable/9/sys/dev/bge
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 01:26:23 -0000

Author: yongari
Date: Wed Jul 10 01:26:22 2013
New Revision: 253126
URL: http://svnweb.freebsd.org/changeset/base/253126

Log:
  MFC r252227:
    Don't blidly clear GPIOs configuration. Just use firmware configured
    one.  This change also fixes non-working traffic LED on BCM57780.

Modified:
  stable/9/sys/dev/bge/if_bge.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/bge/if_bge.c
==============================================================================
--- stable/9/sys/dev/bge/if_bge.c	Wed Jul 10 00:36:02 2013	(r253125)
+++ stable/9/sys/dev/bge/if_bge.c	Wed Jul 10 01:26:22 2013	(r253126)
@@ -2401,7 +2401,7 @@ bge_blockinit(struct bge_softc *sc)
 	DELAY(40);
 
 	/* Set misc. local control, enable interrupts on attentions */
-	CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN);
+	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN);
 
 #ifdef notdef
 	/* Assert GPIO pins for PHY reset */

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 01:29:51 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id E871396B;
 Wed, 10 Jul 2013 01:29:51 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id DB8911AA6;
 Wed, 10 Jul 2013 01:29:51 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A1TpLM022881;
 Wed, 10 Jul 2013 01:29:51 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6A1Tprw022876;
 Wed, 10 Jul 2013 01:29:51 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307100129.r6A1Tprw022876@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Wed, 10 Jul 2013 01:29:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253128 - stable/9/sys/dev/bce
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 01:29:52 -0000

Author: yongari
Date: Wed Jul 10 01:29:51 2013
New Revision: 253128
URL: http://svnweb.freebsd.org/changeset/base/253128

Log:
  MFC r252402:
    Fix triggering false watchdog timeout when controller is in PAUSE
    state.  Previously it used to check if controller has sent a
    PAUSE frame to the remote peer.

Modified:
  stable/9/sys/dev/bce/if_bce.c
  stable/9/sys/dev/bce/if_bcereg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/bce/if_bce.c
==============================================================================
--- stable/9/sys/dev/bce/if_bce.c	Wed Jul 10 01:27:05 2013	(r253127)
+++ stable/9/sys/dev/bce/if_bce.c	Wed Jul 10 01:29:51 2013	(r253128)
@@ -2077,10 +2077,12 @@ bce_miibus_statchg(device_t dev)
 		DBPRINT(sc, BCE_INFO_PHY,
 		    "%s(): Enabling RX flow control.\n", __FUNCTION__);
 		BCE_SETBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_RX_MODE_FLOW_EN);
+		sc->bce_flags |= BCE_USING_RX_FLOW_CONTROL;
 	} else {
 		DBPRINT(sc, BCE_INFO_PHY,
 		    "%s(): Disabling RX flow control.\n", __FUNCTION__);
 		BCE_CLRBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_RX_MODE_FLOW_EN);
+		sc->bce_flags &= ~BCE_USING_RX_FLOW_CONTROL;
 	}
 
 	if ((IFM_OPTIONS(media_active) & IFM_ETH_TXPAUSE) != 0) {
@@ -7828,18 +7830,42 @@ bce_ioctl(struct ifnet *ifp, u_long comm
 static void
 bce_watchdog(struct bce_softc *sc)
 {
+	uint32_t status;
+
 	DBENTER(BCE_EXTREME_SEND);
 
 	BCE_LOCK_ASSERT(sc);
 
+	status = 0;
 	/* If the watchdog timer hasn't expired then just exit. */
 	if (sc->watchdog_timer == 0 || --sc->watchdog_timer)
 		goto bce_watchdog_exit;
 
+	status = REG_RD(sc, BCE_EMAC_RX_STATUS);
 	/* If pause frames are active then don't reset the hardware. */
-	/* ToDo: Should we reset the timer here? */
-	if (REG_RD(sc, BCE_EMAC_TX_STATUS) & BCE_EMAC_TX_STATUS_XOFFED)
-		goto bce_watchdog_exit;
+	if ((sc->bce_flags & BCE_USING_RX_FLOW_CONTROL) != 0) {
+		if ((status & BCE_EMAC_RX_STATUS_FFED) != 0) {
+			/*
+			 * If link partner has us in XOFF state then wait for
+			 * the condition to clear.
+			 */
+			sc->watchdog_timer = BCE_TX_TIMEOUT;
+			goto bce_watchdog_exit;
+		} else if ((status & BCE_EMAC_RX_STATUS_FF_RECEIVED) != 0 &&
+			(status & BCE_EMAC_RX_STATUS_N_RECEIVED) != 0) {
+			/*
+			 * If we're not currently XOFF'ed but have recently
+			 * been XOFF'd/XON'd then assume that's delaying TX
+			 * this time around.
+			 */
+			sc->watchdog_timer = BCE_TX_TIMEOUT;
+			goto bce_watchdog_exit;
+		}
+		/*
+		 * Any other condition is unexpected and the controller
+		 * should be reset.
+		 */
+	}
 
 	BCE_PRINTF("%s(%d): Watchdog timeout occurred, resetting!\n",
 	    __FILE__, __LINE__);
@@ -7863,6 +7889,7 @@ bce_watchdog(struct bce_softc *sc)
 	sc->bce_ifp->if_oerrors++;
 
 bce_watchdog_exit:
+	REG_WR(sc, BCE_EMAC_RX_STATUS, status);
 	DBEXIT(BCE_EXTREME_SEND);
 }
 

Modified: stable/9/sys/dev/bce/if_bcereg.h
==============================================================================
--- stable/9/sys/dev/bce/if_bcereg.h	Wed Jul 10 01:27:05 2013	(r253127)
+++ stable/9/sys/dev/bce/if_bcereg.h	Wed Jul 10 01:29:51 2013	(r253128)
@@ -6466,6 +6466,7 @@ struct bce_softc
 #define BCE_USING_MSIX_FLAG			0x00000100
 #define BCE_PCIE_FLAG				0x00000200
 #define BCE_USING_TX_FLOW_CONTROL		0x00000400
+#define BCE_USING_RX_FLOW_CONTROL		0x00000800
 
 	/* Controller capability flags. */
 	u32			bce_cap_flags;

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 01:32:58 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id E639EDCB;
 Wed, 10 Jul 2013 01:32:58 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id BEC8B1AD8;
 Wed, 10 Jul 2013 01:32:58 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A1WwWU025099;
 Wed, 10 Jul 2013 01:32:58 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6A1WwTC025097;
 Wed, 10 Jul 2013 01:32:58 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307100132.r6A1WwTC025097@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Wed, 10 Jul 2013 01:32:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253130 - stable/9/sys/dev/bge
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 01:32:59 -0000

Author: yongari
Date: Wed Jul 10 01:32:58 2013
New Revision: 253130
URL: http://svnweb.freebsd.org/changeset/base/253130

Log:
  MFC r252404:
    Fix triggering false watchdog timeout as done in bce(4) when
    controller is in PAUSE state.

Modified:
  stable/9/sys/dev/bge/if_bge.c
  stable/9/sys/dev/bge/if_bgereg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/bge/if_bge.c
==============================================================================
--- stable/9/sys/dev/bge/if_bge.c	Wed Jul 10 01:30:35 2013	(r253129)
+++ stable/9/sys/dev/bge/if_bge.c	Wed Jul 10 01:32:58 2013	(r253130)
@@ -5296,7 +5296,7 @@ bge_start_locked(struct ifnet *ifp)
 		/*
 		 * Set a timeout in case the chip goes out to lunch.
 		 */
-		sc->bge_timer = 5;
+		sc->bge_timer = BGE_TX_TIMEOUT;
 	}
 }
 
@@ -5801,12 +5801,40 @@ static void
 bge_watchdog(struct bge_softc *sc)
 {
 	struct ifnet *ifp;
+	uint32_t status;
 
 	BGE_LOCK_ASSERT(sc);
 
 	if (sc->bge_timer == 0 || --sc->bge_timer)
 		return;
 
+	/* If pause frames are active then don't reset the hardware. */
+	if ((CSR_READ_4(sc, BGE_RX_MODE) & BGE_RXMODE_FLOWCTL_ENABLE) != 0) {
+		status = CSR_READ_4(sc, BGE_RX_STS);
+		if ((status & BGE_RXSTAT_REMOTE_XOFFED) != 0) {
+			/*
+			 * If link partner has us in XOFF state then wait for
+			 * the condition to clear.
+			 */
+			CSR_WRITE_4(sc, BGE_RX_STS, status);
+			sc->bge_timer = BGE_TX_TIMEOUT;
+			return;
+		} else if ((status & BGE_RXSTAT_RCVD_XOFF) != 0 &&
+		    (status & BGE_RXSTAT_RCVD_XON) != 0) {
+			/*
+			 * If link partner has us in XOFF state then wait for
+			 * the condition to clear.
+			 */
+			CSR_WRITE_4(sc, BGE_RX_STS, status);
+			sc->bge_timer = BGE_TX_TIMEOUT;
+			return;
+		}
+		/*
+		 * Any other condition is unexpected and the controller
+		 * should be reset.
+		 */
+	}
+
 	ifp = sc->bge_ifp;
 
 	if_printf(ifp, "watchdog timeout -- resetting\n");

Modified: stable/9/sys/dev/bge/if_bgereg.h
==============================================================================
--- stable/9/sys/dev/bge/if_bgereg.h	Wed Jul 10 01:30:35 2013	(r253129)
+++ stable/9/sys/dev/bge/if_bgereg.h	Wed Jul 10 01:32:58 2013	(r253130)
@@ -2928,6 +2928,7 @@ struct bge_dmamap_arg {
 #define	BGE_HWREV_TIGON_II	0x02
 #define	BGE_TIMEOUT		100000
 #define	BGE_TXCONS_UNSET		0xFFFF	/* impossible value */
+#define	BGE_TX_TIMEOUT		5
 
 struct bge_bcom_hack {
 	int			reg;

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 04:51:08 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id A65741DB;
 Wed, 10 Jul 2013 04:51:08 +0000 (UTC)
 (envelope-from bryanv@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 89ACF1275;
 Wed, 10 Jul 2013 04:51:08 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A4p8pp087662;
 Wed, 10 Jul 2013 04:51:08 GMT (envelope-from bryanv@svn.freebsd.org)
Received: (from bryanv@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6A4p74F087655;
 Wed, 10 Jul 2013 04:51:07 GMT (envelope-from bryanv@svn.freebsd.org)
Message-Id: <201307100451.r6A4p74F087655@svn.freebsd.org>
From: Bryan Venteicher 
Date: Wed, 10 Jul 2013 04:51:07 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253132 - in stable/9/sys/dev/virtio: . balloon block
 network pci scsi
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 04:51:08 -0000

Author: bryanv
Date: Wed Jul 10 04:51:07 2013
New Revision: 253132
URL: http://svnweb.freebsd.org/changeset/base/253132

Log:
  MFC VirtIO r252702,r252703,r252704,r252706,r252707,r252708,r252709
  
  This brings in several bug fixes and better conformance with various
  aspects of the spec that have changed.
  
  r252702: Convert VirtIO to use ithreads instead of taskqueues
  r252703: Block driver bug fixes and spec changes
  r252704: Balloon driver improvements
  r252706: Minor network driver improvements
  r252707: Minor misc VirtIO changes
  r252708: PCI driver bug fixes and cleanup
  r252709: Fix SCSI driver lock not owned panic

Modified:
  stable/9/sys/dev/virtio/balloon/virtio_balloon.c
  stable/9/sys/dev/virtio/block/virtio_blk.c
  stable/9/sys/dev/virtio/block/virtio_blk.h
  stable/9/sys/dev/virtio/network/if_vtnet.c
  stable/9/sys/dev/virtio/network/if_vtnetvar.h
  stable/9/sys/dev/virtio/pci/virtio_pci.c
  stable/9/sys/dev/virtio/scsi/virtio_scsi.c
  stable/9/sys/dev/virtio/scsi/virtio_scsivar.h
  stable/9/sys/dev/virtio/virtio.c
  stable/9/sys/dev/virtio/virtio.h
  stable/9/sys/dev/virtio/virtio_bus_if.m
  stable/9/sys/dev/virtio/virtio_if.m
  stable/9/sys/dev/virtio/virtqueue.c
  stable/9/sys/dev/virtio/virtqueue.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/virtio/balloon/virtio_balloon.c
==============================================================================
--- stable/9/sys/dev/virtio/balloon/virtio_balloon.c	Wed Jul 10 01:33:49 2013	(r253131)
+++ stable/9/sys/dev/virtio/balloon/virtio_balloon.c	Wed Jul 10 04:51:07 2013	(r253132)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011, Bryan Venteicher 
+ * Copyright (c) 2011, Bryan Venteicher 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ struct vtballoon_softc {
 	uint32_t		 vtballoon_current_npages;
 	TAILQ_HEAD(,vm_page)	 vtballoon_pages;
 
-	struct proc		*vtballoon_kproc;
+	struct thread		*vtballoon_td;
 	uint32_t		*vtballoon_page_frames;
 	int			 vtballoon_timeout;
 };
@@ -90,7 +90,7 @@ static int	vtballoon_config_change(devic
 static void	vtballoon_negotiate_features(struct vtballoon_softc *);
 static int	vtballoon_alloc_virtqueues(struct vtballoon_softc *);
 
-static int	vtballoon_vq_intr(void *);
+static void	vtballoon_vq_intr(void *);
 
 static void	vtballoon_inflate(struct vtballoon_softc *, int);
 static void	vtballoon_deflate(struct vtballoon_softc *, int);
@@ -127,9 +127,9 @@ CTASSERT(VTBALLOON_PAGES_PER_REQUEST * s
 
 #define VTBALLOON_MTX(_sc)		&(_sc)->vtballoon_mtx
 #define VTBALLOON_LOCK_INIT(_sc, _name)	mtx_init(VTBALLOON_MTX((_sc)), _name, \
-					    "VirtIO Balloon Lock", MTX_SPIN)
-#define VTBALLOON_LOCK(_sc)		mtx_lock_spin(VTBALLOON_MTX((_sc)))
-#define VTBALLOON_UNLOCK(_sc)		mtx_unlock_spin(VTBALLOON_MTX((_sc)))
+					    "VirtIO Balloon Lock", MTX_DEF)
+#define VTBALLOON_LOCK(_sc)		mtx_lock(VTBALLOON_MTX((_sc)))
+#define VTBALLOON_UNLOCK(_sc)		mtx_unlock(VTBALLOON_MTX((_sc)))
 #define VTBALLOON_LOCK_DESTROY(_sc)	mtx_destroy(VTBALLOON_MTX((_sc)))
 
 static device_method_t vtballoon_methods[] = {
@@ -206,10 +206,10 @@ vtballoon_attach(device_t dev)
 		goto fail;
 	}
 
-	error = kproc_create(vtballoon_thread, sc, &sc->vtballoon_kproc,
+	error = kthread_add(vtballoon_thread, sc, NULL, &sc->vtballoon_td,
 	    0, 0, "virtio_balloon");
 	if (error) {
-		device_printf(dev, "cannot create balloon kproc\n");
+		device_printf(dev, "cannot create balloon kthread\n");
 		goto fail;
 	}
 
@@ -230,15 +230,14 @@ vtballoon_detach(device_t dev)
 
 	sc = device_get_softc(dev);
 
-	if (sc->vtballoon_kproc != NULL) {
+	if (sc->vtballoon_td != NULL) {
 		VTBALLOON_LOCK(sc);
 		sc->vtballoon_flags |= VTBALLOON_FLAG_DETACH;
 		wakeup_one(sc);
-		msleep_spin(sc->vtballoon_kproc, VTBALLOON_MTX(sc),
-		    "vtbdth", 0);
+		msleep(sc->vtballoon_td, VTBALLOON_MTX(sc), 0, "vtbdth", 0);
 		VTBALLOON_UNLOCK(sc);
 
-		sc->vtballoon_kproc = NULL;
+		sc->vtballoon_td = NULL;
 	}
 
 	if (device_is_attached(dev)) {
@@ -300,7 +299,7 @@ vtballoon_alloc_virtqueues(struct vtball
 	return (virtio_alloc_virtqueues(dev, 0, nvqs, vq_info));
 }
 
-static int
+static void
 vtballoon_vq_intr(void *xsc)
 {
 	struct vtballoon_softc *sc;
@@ -310,8 +309,6 @@ vtballoon_vq_intr(void *xsc)
 	VTBALLOON_LOCK(sc);
 	wakeup_one(sc);
 	VTBALLOON_UNLOCK(sc);
-
-	return (1);
 }
 
 static void
@@ -322,28 +319,26 @@ vtballoon_inflate(struct vtballoon_softc
 	int i;
 
 	vq = sc->vtballoon_inflate_vq;
-	m = NULL;
 
 	if (npages > VTBALLOON_PAGES_PER_REQUEST)
 		npages = VTBALLOON_PAGES_PER_REQUEST;
-	KASSERT(npages > 0, ("balloon doesn't need inflating?"));
 
 	for (i = 0; i < npages; i++) {
-		if ((m = vtballoon_alloc_page(sc)) == NULL)
+		if ((m = vtballoon_alloc_page(sc)) == NULL) {
+			sc->vtballoon_timeout = VTBALLOON_LOWMEM_TIMEOUT;
 			break;
+		}
 
 		sc->vtballoon_page_frames[i] =
 		    VM_PAGE_TO_PHYS(m) >> VIRTIO_BALLOON_PFN_SHIFT;
 
-		KASSERT(m->queue == PQ_NONE, ("allocated page on queue"));
+		KASSERT(m->queue == PQ_NONE,
+		    ("%s: allocated page %p on queue", __func__, m));
 		TAILQ_INSERT_TAIL(&sc->vtballoon_pages, m, pageq);
 	}
 
 	if (i > 0)
 		vtballoon_send_page_frames(sc, vq, i);
-
-	if (m == NULL)
-		sc->vtballoon_timeout = VTBALLOON_LOWMEM_TIMEOUT;
 }
 
 static void
@@ -359,11 +354,10 @@ vtballoon_deflate(struct vtballoon_softc
 
 	if (npages > VTBALLOON_PAGES_PER_REQUEST)
 		npages = VTBALLOON_PAGES_PER_REQUEST;
-	KASSERT(npages > 0, ("balloon doesn't need deflating?"));
 
 	for (i = 0; i < npages; i++) {
 		m = TAILQ_FIRST(&sc->vtballoon_pages);
-		KASSERT(m != NULL, ("no more pages to deflate"));
+		KASSERT(m != NULL, ("%s: no more pages to deflate", __func__));
 
 		sc->vtballoon_page_frames[i] =
 		    VM_PAGE_TO_PHYS(m) >> VIRTIO_BALLOON_PFN_SHIFT;
@@ -385,7 +379,9 @@ vtballoon_deflate(struct vtballoon_softc
 	KASSERT((TAILQ_EMPTY(&sc->vtballoon_pages) &&
 	    sc->vtballoon_current_npages == 0) ||
 	    (!TAILQ_EMPTY(&sc->vtballoon_pages) &&
-	    sc->vtballoon_current_npages != 0), ("balloon empty?"));
+	    sc->vtballoon_current_npages != 0),
+	    ("%s: bogus page count %d", __func__,
+	    sc->vtballoon_current_npages));
 }
 
 static void
@@ -413,7 +409,7 @@ vtballoon_send_page_frames(struct vtball
 	 */
 	VTBALLOON_LOCK(sc);
 	while ((c = virtqueue_dequeue(vq, NULL)) == NULL)
-		msleep_spin(sc, VTBALLOON_MTX(sc), "vtbspf", 0);
+		msleep(sc, VTBALLOON_MTX(sc), 0, "vtbspf", 0);
 	VTBALLOON_UNLOCK(sc);
 
 	KASSERT(c == vq, ("unexpected balloon operation response"));
@@ -512,7 +508,7 @@ vtballoon_sleep(struct vtballoon_softc *
 		if (current < desired && timeout == 0)
 			break;
 
-		msleep_spin(sc, VTBALLOON_MTX(sc), "vtbslp", timeout);
+		msleep(sc, VTBALLOON_MTX(sc), 0, "vtbslp", timeout);
 	}
 	VTBALLOON_UNLOCK(sc);
 
@@ -544,7 +540,7 @@ vtballoon_thread(void *xsc)
 		}
 	}
 
-	kproc_exit(0);
+	kthread_exit();
 }
 
 static void

Modified: stable/9/sys/dev/virtio/block/virtio_blk.c
==============================================================================
--- stable/9/sys/dev/virtio/block/virtio_blk.c	Wed Jul 10 01:33:49 2013	(r253131)
+++ stable/9/sys/dev/virtio/block/virtio_blk.c	Wed Jul 10 04:51:07 2013	(r253132)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011, Bryan Venteicher 
+ * Copyright (c) 2011, Bryan Venteicher 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,10 +36,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -62,6 +62,12 @@ struct vtblk_request {
 	TAILQ_ENTRY(vtblk_request)	 vbr_link;
 };
 
+enum vtblk_cache_mode {
+	VTBLK_CACHE_WRITETHROUGH,
+	VTBLK_CACHE_WRITEBACK,
+	VTBLK_CACHE_MAX
+};
+
 struct vtblk_softc {
 	device_t		 vtblk_dev;
 	struct mtx		 vtblk_mtx;
@@ -73,6 +79,7 @@ struct vtblk_softc {
 #define VTBLK_FLAG_SUSPEND	0x0008
 #define VTBLK_FLAG_DUMPING	0x0010
 #define VTBLK_FLAG_BARRIER	0x0020
+#define VTBLK_FLAG_WC_CONFIG	0x0040
 
 	struct virtqueue	*vtblk_vq;
 	struct sglist		*vtblk_sglist;
@@ -85,11 +92,9 @@ struct vtblk_softc {
 				 vtblk_req_ready;
 	struct vtblk_request	*vtblk_req_ordered;
 
-	struct taskqueue	*vtblk_tq;
-	struct task		 vtblk_intr_task;
-
 	int			 vtblk_max_nsegs;
 	int			 vtblk_request_count;
+	enum vtblk_cache_mode	 vtblk_write_cache;
 
 	struct vtblk_request	 vtblk_dump_request;
 };
@@ -102,8 +107,9 @@ static struct virtio_feature_desc vtblk_
 	{ VIRTIO_BLK_F_RO,		"ReadOnly"	},
 	{ VIRTIO_BLK_F_BLK_SIZE,	"BlockSize"	},
 	{ VIRTIO_BLK_F_SCSI,		"SCSICmds"	},
-	{ VIRTIO_BLK_F_FLUSH,		"FlushCmd"	},
+	{ VIRTIO_BLK_F_WCE,		"WriteCache"	},
 	{ VIRTIO_BLK_F_TOPOLOGY,	"Topology"	},
+	{ VIRTIO_BLK_F_CONFIG_WCE,	"ConfigWCE"	},
 
 	{ 0, NULL }
 };
@@ -116,6 +122,7 @@ static int	vtblk_detach(device_t);
 static int	vtblk_suspend(device_t);
 static int	vtblk_resume(device_t);
 static int	vtblk_shutdown(device_t);
+static int	vtblk_config_change(device_t);
 
 static int	vtblk_open(struct disk *);
 static int	vtblk_close(struct disk *);
@@ -128,6 +135,10 @@ static void	vtblk_negotiate_features(str
 static int	vtblk_maximum_segments(struct vtblk_softc *,
 		    struct virtio_blk_config *);
 static int	vtblk_alloc_virtqueue(struct vtblk_softc *);
+static void	vtblk_set_write_cache(struct vtblk_softc *, int);
+static int	vtblk_write_cache_enabled(struct vtblk_softc *sc,
+		    struct virtio_blk_config *);
+static int	vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS);
 static void	vtblk_alloc_disk(struct vtblk_softc *,
 		    struct virtio_blk_config *);
 static void	vtblk_create_disk(struct vtblk_softc *);
@@ -138,11 +149,12 @@ static struct vtblk_request * vtblk_bio_
 static int	vtblk_execute_request(struct vtblk_softc *,
 		    struct vtblk_request *);
 
-static int	vtblk_vq_intr(void *);
-static void	vtblk_intr_task(void *, int);
+static void	vtblk_vq_intr(void *);
 
 static void	vtblk_stop(struct vtblk_softc *);
 
+static void	vtblk_read_config(struct vtblk_softc *,
+		    struct virtio_blk_config *);
 static void	vtblk_get_ident(struct vtblk_softc *);
 static void	vtblk_prepare_dump(struct vtblk_softc *);
 static int	vtblk_write_dump(struct vtblk_softc *, void *, off_t, size_t);
@@ -167,9 +179,14 @@ static void	vtblk_enqueue_ready(struct v
 static int	vtblk_request_error(struct vtblk_request *);
 static void	vtblk_finish_bio(struct bio *, int);
 
+static void	vtblk_setup_sysctl(struct vtblk_softc *);
+static int	vtblk_tunable_int(struct vtblk_softc *, const char *, int);
+
 /* Tunables. */
 static int vtblk_no_ident = 0;
 TUNABLE_INT("hw.vtblk.no_ident", &vtblk_no_ident);
+static int vtblk_writecache_mode = -1;
+TUNABLE_INT("hw.vtblk.writecache_mode", &vtblk_writecache_mode);
 
 /* Features desired/implemented by this driver. */
 #define VTBLK_FEATURES \
@@ -179,13 +196,14 @@ TUNABLE_INT("hw.vtblk.no_ident", &vtblk_
      VIRTIO_BLK_F_GEOMETRY		| \
      VIRTIO_BLK_F_RO			| \
      VIRTIO_BLK_F_BLK_SIZE		| \
-     VIRTIO_BLK_F_FLUSH			| \
+     VIRTIO_BLK_F_WCE			| \
+     VIRTIO_BLK_F_CONFIG_WCE		| \
      VIRTIO_RING_F_INDIRECT_DESC)
 
 #define VTBLK_MTX(_sc)		&(_sc)->vtblk_mtx
 #define VTBLK_LOCK_INIT(_sc, _name) \
 				mtx_init(VTBLK_MTX((_sc)), (_name), \
-				    "VTBLK Lock", MTX_DEF)
+				    "VirtIO Block Lock", MTX_DEF)
 #define VTBLK_LOCK(_sc)		mtx_lock(VTBLK_MTX((_sc)))
 #define VTBLK_UNLOCK(_sc)	mtx_unlock(VTBLK_MTX((_sc)))
 #define VTBLK_LOCK_DESTROY(_sc)	mtx_destroy(VTBLK_MTX((_sc)))
@@ -211,6 +229,9 @@ static device_method_t vtblk_methods[] =
 	DEVMETHOD(device_resume,	vtblk_resume),
 	DEVMETHOD(device_shutdown,	vtblk_shutdown),
 
+	/* VirtIO methods. */
+	DEVMETHOD(virtio_config_change,	vtblk_config_change),
+
 	DEVMETHOD_END
 };
 
@@ -284,10 +305,13 @@ vtblk_attach(device_t dev)
 		sc->vtblk_flags |= VTBLK_FLAG_READONLY;
 	if (virtio_with_feature(dev, VIRTIO_BLK_F_BARRIER))
 		sc->vtblk_flags |= VTBLK_FLAG_BARRIER;
+	if (virtio_with_feature(dev, VIRTIO_BLK_F_CONFIG_WCE))
+		sc->vtblk_flags |= VTBLK_FLAG_WC_CONFIG;
+
+	vtblk_setup_sysctl(sc);
 
 	/* Get local copy of config. */
-	virtio_read_device_config(dev, 0, &blkcfg,
-	    sizeof(struct virtio_blk_config));
+	vtblk_read_config(sc, &blkcfg);
 
 	/*
 	 * With the current sglist(9) implementation, it is not easy
@@ -333,24 +357,12 @@ vtblk_attach(device_t dev)
 
 	vtblk_alloc_disk(sc, &blkcfg);
 
-	TASK_INIT(&sc->vtblk_intr_task, 0, vtblk_intr_task, sc);
-	sc->vtblk_tq = taskqueue_create_fast("vtblk_taskq", M_NOWAIT,
-	    taskqueue_thread_enqueue, &sc->vtblk_tq);
-	if (sc->vtblk_tq == NULL) {
-		error = ENOMEM;
-		device_printf(dev, "cannot allocate taskqueue\n");
-		goto fail;
-	}
-
 	error = virtio_setup_intr(dev, INTR_TYPE_BIO | INTR_ENTROPY);
 	if (error) {
 		device_printf(dev, "cannot setup virtqueue interrupt\n");
 		goto fail;
 	}
 
-	taskqueue_start_threads(&sc->vtblk_tq, 1, PI_DISK, "%s taskq",
-	    device_get_nameunit(dev));
-
 	vtblk_create_disk(sc);
 
 	virtqueue_enable_intr(sc->vtblk_vq);
@@ -375,12 +387,6 @@ vtblk_detach(device_t dev)
 		vtblk_stop(sc);
 	VTBLK_UNLOCK(sc);
 
-	if (sc->vtblk_tq != NULL) {
-		taskqueue_drain(sc->vtblk_tq, &sc->vtblk_intr_task);
-		taskqueue_free(sc->vtblk_tq);
-		sc->vtblk_tq = NULL;
-	}
-
 	vtblk_drain(sc);
 
 	if (sc->vtblk_disk != NULL) {
@@ -441,6 +447,13 @@ vtblk_shutdown(device_t dev)
 }
 
 static int
+vtblk_config_change(device_t dev)
+{
+
+	return (0);
+}
+
+static int
 vtblk_open(struct disk *dp)
 {
 	struct vtblk_softc *sc;
@@ -541,8 +554,8 @@ vtblk_strategy(struct bio *bp)
 		max_nsegs = sc->vtblk_max_nsegs - VTBLK_MIN_SEGMENTS;
 
 		KASSERT(nsegs <= max_nsegs,
-		    ("bio %p spanned too many segments: %d, max: %d",
-		    bp, nsegs, max_nsegs));
+		    ("%s: bio %p spanned too many segments: %d, max: %d",
+		    __func__, bp, nsegs, max_nsegs));
 	}
 #endif
 
@@ -606,6 +619,59 @@ vtblk_alloc_virtqueue(struct vtblk_softc
 }
 
 static void
+vtblk_set_write_cache(struct vtblk_softc *sc, int wc)
+{
+
+	/* Set either writeback (1) or writethrough (0) mode. */
+	virtio_write_dev_config_1(sc->vtblk_dev,
+	    offsetof(struct virtio_blk_config, writeback), wc);
+}
+
+static int
+vtblk_write_cache_enabled(struct vtblk_softc *sc,
+    struct virtio_blk_config *blkcfg)
+{
+	int wc;
+
+	if (sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) {
+		wc = vtblk_tunable_int(sc, "writecache_mode",
+		    vtblk_writecache_mode);
+		if (wc >= 0 && wc < VTBLK_CACHE_MAX)
+			vtblk_set_write_cache(sc, wc);
+		else
+			wc = blkcfg->writeback;
+	} else
+		wc = virtio_with_feature(sc->vtblk_dev, VIRTIO_BLK_F_WCE);
+
+	return (wc);
+}
+
+static int
+vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	struct vtblk_softc *sc;
+	int wc, error;
+
+	sc = oidp->oid_arg1;
+	wc = sc->vtblk_write_cache;
+
+	error = sysctl_handle_int(oidp, &wc, 0, req);
+	if (error || req->newptr == NULL)
+		return (error);
+	if ((sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) == 0)
+		return (EPERM);
+	if (wc < 0 || wc >= VTBLK_CACHE_MAX)
+		return (EINVAL);
+
+	VTBLK_LOCK(sc);
+	sc->vtblk_write_cache = wc;
+	vtblk_set_write_cache(sc, sc->vtblk_write_cache);
+	VTBLK_UNLOCK(sc);
+
+	return (0);
+}
+
+static void
 vtblk_alloc_disk(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg)
 {
 	device_t dev;
@@ -621,6 +687,11 @@ vtblk_alloc_disk(struct vtblk_softc *sc,
 	dp->d_name = VTBLK_DISK_NAME;
 	dp->d_unit = device_get_unit(dev);
 	dp->d_drv1 = sc;
+	dp->d_flags = DISKFLAG_CANFLUSHCACHE;
+	dp->d_hba_vendor = virtio_get_vendor(dev);
+	dp->d_hba_device = virtio_get_device(dev);
+	dp->d_hba_subvendor = virtio_get_subvendor(dev);
+	dp->d_hba_subdevice = virtio_get_subdevice(dev);
 
 	if ((sc->vtblk_flags & VTBLK_FLAG_READONLY) == 0)
 		dp->d_dump = vtblk_dump;
@@ -656,8 +727,18 @@ vtblk_alloc_disk(struct vtblk_softc *sc,
 		dp->d_fwheads = blkcfg->geometry.heads;
 	}
 
-	if (virtio_with_feature(dev, VIRTIO_BLK_F_FLUSH))
-		dp->d_flags |= DISKFLAG_CANFLUSHCACHE;
+	if (virtio_with_feature(dev, VIRTIO_BLK_F_TOPOLOGY)) {
+		dp->d_stripesize = dp->d_sectorsize *
+		    (1 << blkcfg->topology.physical_block_exp);
+		dp->d_stripeoffset = (dp->d_stripesize -
+		    blkcfg->topology.alignment_offset * dp->d_sectorsize) %
+		    dp->d_stripesize;
+	}
+
+	if (vtblk_write_cache_enabled(sc, blkcfg) != 0)
+		sc->vtblk_write_cache = VTBLK_CACHE_WRITEBACK;
+	else
+		sc->vtblk_write_cache = VTBLK_CACHE_WRITETHROUGH;
 }
 
 static void
@@ -765,8 +846,7 @@ vtblk_bio_request(struct vtblk_softc *sc
 		req->vbr_hdr.sector = bp->bio_offset / 512;
 		break;
 	default:
-		panic("%s: bio with unhandled cmd: %d", __FUNCTION__,
-		    bp->bio_cmd);
+		panic("%s: bio with unhandled cmd: %d", __func__, bp->bio_cmd);
 	}
 
 	return (req);
@@ -809,14 +889,13 @@ vtblk_execute_request(struct vtblk_softc
 	}
 
 	sglist_reset(sg);
-
 	sglist_append(sg, &req->vbr_hdr, sizeof(struct virtio_blk_outhdr));
 
 	if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
 		error = sglist_append(sg, bp->bio_data, bp->bio_bcount);
 		if (error || sg->sg_nseg == sg->sg_maxseg)
 			panic("%s: data buffer too big bio:%p error:%d",
-			    __FUNCTION__, bp, error);
+			    __func__, bp, error);
 
 		/* BIO_READ means the host writes into our buffer. */
 		if (bp->bio_cmd == BIO_READ)
@@ -834,28 +913,16 @@ vtblk_execute_request(struct vtblk_softc
 	return (error);
 }
 
-static int
-vtblk_vq_intr(void *xsc)
-{
-	struct vtblk_softc *sc;
-
-	sc = xsc;
-
-	virtqueue_disable_intr(sc->vtblk_vq);
-	taskqueue_enqueue_fast(sc->vtblk_tq, &sc->vtblk_intr_task);
-
-	return (1);
-}
-
 static void
-vtblk_intr_task(void *arg, int pending)
+vtblk_vq_intr(void *xsc)
 {
 	struct vtblk_softc *sc;
 	struct virtqueue *vq;
 
-	sc = arg;
+	sc = xsc;
 	vq = sc->vtblk_vq;
 
+again:
 	VTBLK_LOCK(sc);
 	if (sc->vtblk_flags & VTBLK_FLAG_DETACH) {
 		VTBLK_UNLOCK(sc);
@@ -872,9 +939,7 @@ vtblk_intr_task(void *arg, int pending)
 	if (virtqueue_enable_intr(vq) != 0) {
 		virtqueue_disable_intr(vq);
 		VTBLK_UNLOCK(sc);
-		taskqueue_enqueue_fast(sc->vtblk_tq,
-		    &sc->vtblk_intr_task);
-		return;
+		goto again;
 	}
 
 	VTBLK_UNLOCK(sc);
@@ -888,6 +953,37 @@ vtblk_stop(struct vtblk_softc *sc)
 	virtio_stop(sc->vtblk_dev);
 }
 
+#define VTBLK_GET_CONFIG(_dev, _feature, _field, _cfg)			\
+	if (virtio_with_feature(_dev, _feature)) {			\
+		virtio_read_device_config(_dev,				\
+		    offsetof(struct virtio_blk_config, _field),		\
+		    &(_cfg)->_field, sizeof((_cfg)->_field));		\
+	}
+
+static void
+vtblk_read_config(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg)
+{
+	device_t dev;
+
+	dev = sc->vtblk_dev;
+
+	bzero(blkcfg, sizeof(struct virtio_blk_config));
+
+	/* The capacity is always available. */
+	virtio_read_device_config(dev, offsetof(struct virtio_blk_config,
+	    capacity), &blkcfg->capacity, sizeof(blkcfg->capacity));
+
+	/* Read the configuration if the feature was negotiated. */
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_SIZE_MAX, size_max, blkcfg);
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_SEG_MAX, seg_max, blkcfg);
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_GEOMETRY, geometry, blkcfg);
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_BLK_SIZE, blk_size, blkcfg);
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_TOPOLOGY, topology, blkcfg);
+	VTBLK_GET_CONFIG(dev, VIRTIO_BLK_F_CONFIG_WCE, writeback, blkcfg);
+}
+
+#undef VTBLK_GET_CONFIG
+
 static void
 vtblk_get_ident(struct vtblk_softc *sc)
 {
@@ -899,7 +995,7 @@ vtblk_get_ident(struct vtblk_softc *sc)
 	dp = sc->vtblk_disk;
 	len = MIN(VIRTIO_BLK_ID_BYTES, DISK_IDENT_SIZE);
 
-	if (vtblk_no_ident != 0)
+	if (vtblk_tunable_int(sc, "no_ident", vtblk_no_ident) != 0)
 		return;
 
 	req = vtblk_dequeue_request(sc);
@@ -949,8 +1045,10 @@ vtblk_prepare_dump(struct vtblk_softc *s
 	 */
 	vtblk_drain_vq(sc, 1);
 
-	if (virtio_reinit(dev, sc->vtblk_features) != 0)
-		panic("cannot reinit VirtIO block device during dump");
+	if (virtio_reinit(dev, sc->vtblk_features) != 0) {
+		panic("%s: cannot reinit VirtIO block device during dump",
+		    device_get_nameunit(dev));
+	}
 
 	virtqueue_disable_intr(vq);
 	virtio_reinit_complete(dev);
@@ -1003,7 +1101,6 @@ static int
 vtblk_poll_request(struct vtblk_softc *sc, struct vtblk_request *req)
 {
 	struct virtqueue *vq;
-	struct vtblk_request *r;
 	int error;
 
 	vq = sc->vtblk_vq;
@@ -1016,14 +1113,12 @@ vtblk_poll_request(struct vtblk_softc *s
 		return (error);
 
 	virtqueue_notify(vq);
-
-	r = virtqueue_poll(vq, NULL);
-	KASSERT(r == req, ("unexpected request response: %p/%p", r, req));
+	virtqueue_poll(vq, NULL);
 
 	error = vtblk_request_error(req);
 	if (error && bootverbose) {
 		device_printf(sc->vtblk_dev,
-		    "%s: IO error: %d\n", __FUNCTION__, error);
+		    "%s: IO error: %d\n", __func__, error);
 	}
 
 	return (error);
@@ -1154,7 +1249,7 @@ vtblk_free_requests(struct vtblk_softc *
 	struct vtblk_request *req;
 
 	KASSERT(TAILQ_EMPTY(&sc->vtblk_req_ready),
-	    ("ready requests left on queue"));
+	    ("%s: ready requests left on queue", __func__));
 
 	while ((req = vtblk_dequeue_request(sc)) != NULL) {
 		sc->vtblk_request_count--;
@@ -1162,7 +1257,7 @@ vtblk_free_requests(struct vtblk_softc *
 	}
 
 	KASSERT(sc->vtblk_request_count == 0,
-	    ("leaked requests: %d", sc->vtblk_request_count));
+	    ("%s: leaked %d requests", __func__, sc->vtblk_request_count));
 }
 
 static struct vtblk_request *
@@ -1236,3 +1331,33 @@ vtblk_finish_bio(struct bio *bp, int err
 
 	biodone(bp);
 }
+
+static void
+vtblk_setup_sysctl(struct vtblk_softc *sc)
+{
+	device_t dev;
+	struct sysctl_ctx_list *ctx;
+	struct sysctl_oid *tree;
+	struct sysctl_oid_list *child;
+
+	dev = sc->vtblk_dev;
+	ctx = device_get_sysctl_ctx(dev);
+	tree = device_get_sysctl_tree(dev);
+	child = SYSCTL_CHILDREN(tree);
+
+	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "writecache_mode",
+	    CTLTYPE_INT | CTLFLAG_RW, sc, 0, vtblk_write_cache_sysctl,
+	    "I", "Write cache mode (writethrough (0) or writeback (1))");
+}
+
+static int
+vtblk_tunable_int(struct vtblk_softc *sc, const char *knob, int def)
+{
+	char path[64];
+
+	snprintf(path, sizeof(path),
+	    "hw.vtblk.%d.%s", device_get_unit(sc->vtblk_dev), knob);
+	TUNABLE_INT_FETCH(path, &def);
+
+	return (def);
+}

Modified: stable/9/sys/dev/virtio/block/virtio_blk.h
==============================================================================
--- stable/9/sys/dev/virtio/block/virtio_blk.h	Wed Jul 10 01:33:49 2013	(r253131)
+++ stable/9/sys/dev/virtio/block/virtio_blk.h	Wed Jul 10 04:51:07 2013	(r253132)
@@ -39,8 +39,9 @@
 #define VIRTIO_BLK_F_RO		0x0020	/* Disk is read-only */
 #define VIRTIO_BLK_F_BLK_SIZE	0x0040	/* Block size of disk is available*/
 #define VIRTIO_BLK_F_SCSI	0x0080	/* Supports scsi command passthru */
-#define VIRTIO_BLK_F_FLUSH	0x0200	/* Cache flush command support */
+#define VIRTIO_BLK_F_WCE	0x0200	/* Writeback mode enabled after reset */
 #define VIRTIO_BLK_F_TOPOLOGY	0x0400	/* Topology information is available */
+#define VIRTIO_BLK_F_CONFIG_WCE 0x0800	/* Writeback mode available in config */
 
 #define VIRTIO_BLK_ID_BYTES	20	/* ID string length */
 
@@ -51,15 +52,27 @@ struct virtio_blk_config {
 	uint32_t size_max;
 	/* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
 	uint32_t seg_max;
-	/* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
+	/* Geometry of the device (if VIRTIO_BLK_F_GEOMETRY) */
 	struct virtio_blk_geometry {
 		uint16_t cylinders;
 		uint8_t heads;
 		uint8_t sectors;
 	} geometry;
 
-	/* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
+	/* Block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
 	uint32_t blk_size;
+
+	/* Topology of the device (if VIRTIO_BLK_F_TOPOLOGY) */
+	struct virtio_blk_topology {
+		uint8_t physical_block_exp;
+		uint8_t alignment_offset;
+		uint16_t min_io_size;
+		uint16_t opt_io_size;
+	} topology;
+
+	/* Writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */
+	uint8_t writeback;
+
 } __packed;
 
 /*

Modified: stable/9/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- stable/9/sys/dev/virtio/network/if_vtnet.c	Wed Jul 10 01:33:49 2013	(r253131)
+++ stable/9/sys/dev/virtio/network/if_vtnet.c	Wed Jul 10 04:51:07 2013	(r253132)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011, Bryan Venteicher 
+ * Copyright (c) 2011, Bryan Venteicher 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -97,7 +96,6 @@ static void	vtnet_set_hwaddr(struct vtne
 static int	vtnet_is_link_up(struct vtnet_softc *);
 static void	vtnet_update_link_status(struct vtnet_softc *);
 static void	vtnet_watchdog(struct vtnet_softc *);
-static void	vtnet_config_change_task(void *, int);
 static int	vtnet_change_mtu(struct vtnet_softc *, int);
 static int	vtnet_ioctl(struct ifnet *, u_long, caddr_t);
 
@@ -123,8 +121,7 @@ static int	vtnet_rx_csum(struct vtnet_so
 		    struct virtio_net_hdr *);
 static int	vtnet_rxeof_merged(struct vtnet_softc *, struct mbuf *, int);
 static int	vtnet_rxeof(struct vtnet_softc *, int, int *);
-static void	vtnet_rx_intr_task(void *, int);
-static int	vtnet_rx_vq_intr(void *);
+static void	vtnet_rx_vq_intr(void *);
 
 static void	vtnet_txeof(struct vtnet_softc *);
 static struct mbuf * vtnet_tx_offload(struct vtnet_softc *, struct mbuf *,
@@ -135,8 +132,7 @@ static int	vtnet_encap(struct vtnet_soft
 static void	vtnet_start_locked(struct ifnet *);
 static void	vtnet_start(struct ifnet *);
 static void	vtnet_tick(void *);
-static void	vtnet_tx_intr_task(void *, int);
-static int	vtnet_tx_vq_intr(void *);
+static void	vtnet_tx_vq_intr(void *);
 
 static void	vtnet_stop(struct vtnet_softc *);
 static int	vtnet_reinit(struct vtnet_softc *);
@@ -427,19 +423,6 @@ vtnet_attach(device_t dev)
 	ifp->if_capabilities |= IFCAP_POLLING;
 #endif
 
-	TASK_INIT(&sc->vtnet_rx_intr_task, 0, vtnet_rx_intr_task, sc);
-	TASK_INIT(&sc->vtnet_tx_intr_task, 0, vtnet_tx_intr_task, sc);
-	TASK_INIT(&sc->vtnet_cfgchg_task, 0, vtnet_config_change_task, sc);
-
-	sc->vtnet_tq = taskqueue_create_fast("vtnet_taskq", M_NOWAIT,
-	    taskqueue_thread_enqueue, &sc->vtnet_tq);
-	if (sc->vtnet_tq == NULL) {
-		error = ENOMEM;
-		device_printf(dev, "cannot allocate taskqueue\n");
-		ether_ifdetach(ifp);
-		goto fail;
-	}
-
 	error = virtio_setup_intr(dev, INTR_TYPE_NET);
 	if (error) {
 		device_printf(dev, "cannot setup virtqueue interrupts\n");
@@ -447,9 +430,6 @@ vtnet_attach(device_t dev)
 		goto fail;
 	}
 
-	taskqueue_start_threads(&sc->vtnet_tq, 1, PI_NET, "%s taskq",
-	    device_get_nameunit(dev));
-
 	/*
 	 * Device defaults to promiscuous mode for backwards
 	 * compatibility. Turn it off if possible.
@@ -495,18 +475,10 @@ vtnet_detach(device_t dev)
 		VTNET_UNLOCK(sc);
 
 		callout_drain(&sc->vtnet_tick_ch);
-		taskqueue_drain(taskqueue_fast, &sc->vtnet_cfgchg_task);
 
 		ether_ifdetach(ifp);
 	}
 
-	if (sc->vtnet_tq != NULL) {
-		taskqueue_drain(sc->vtnet_tq, &sc->vtnet_rx_intr_task);
-		taskqueue_drain(sc->vtnet_tq, &sc->vtnet_tx_intr_task);
-		taskqueue_free(sc->vtnet_tq);
-		sc->vtnet_tq = NULL;
-	}
-
 	if (sc->vtnet_vlan_attach != NULL) {
 		EVENTHANDLER_DEREGISTER(vlan_config, sc->vtnet_vlan_attach);
 		sc->vtnet_vlan_attach = NULL;
@@ -590,9 +562,11 @@ vtnet_config_change(device_t dev)
 
 	sc = device_get_softc(dev);
 
-	taskqueue_enqueue_fast(taskqueue_fast, &sc->vtnet_cfgchg_task);
+	VTNET_LOCK(sc);
+	vtnet_update_link_status(sc);
+	VTNET_UNLOCK(sc);
 
-	return (1);
+	return (0);
 }
 
 static void
@@ -788,18 +762,6 @@ vtnet_watchdog(struct vtnet_softc *sc)
 	vtnet_init_locked(sc);
 }
 
-static void
-vtnet_config_change_task(void *arg, int pending)
-{
-	struct vtnet_softc *sc;
-
-	sc = arg;
-
-	VTNET_LOCK(sc);
-	vtnet_update_link_status(sc);
-	VTNET_UNLOCK(sc);
-}
-
 static int
 vtnet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
@@ -1705,15 +1667,16 @@ vtnet_rxeof(struct vtnet_softc *sc, int 
 }
 
 static void
-vtnet_rx_intr_task(void *arg, int pending)
+vtnet_rx_vq_intr(void *xsc)
 {
 	struct vtnet_softc *sc;
 	struct ifnet *ifp;
 	int more;
 
-	sc = arg;
+	sc = xsc;
 	ifp = sc->vtnet_ifp;
 
+again:
 	VTNET_LOCK(sc);
 
 #ifdef DEVICE_POLLING
@@ -1730,31 +1693,15 @@ vtnet_rx_intr_task(void *arg, int pendin
 	}
 
 	more = vtnet_rxeof(sc, sc->vtnet_rx_process_limit, NULL);
-	if (!more && vtnet_enable_rx_intr(sc) != 0) {
-		vtnet_disable_rx_intr(sc);
-		more = 1;
-	}
-
-	VTNET_UNLOCK(sc);
-
-	if (more) {
+	if (more || vtnet_enable_rx_intr(sc) != 0) {
+		if (!more)
+			vtnet_disable_rx_intr(sc);
 		sc->vtnet_stats.rx_task_rescheduled++;
-		taskqueue_enqueue_fast(sc->vtnet_tq,
-		    &sc->vtnet_rx_intr_task);
+		VTNET_UNLOCK(sc);
+		goto again;
 	}
-}
-
-static int
-vtnet_rx_vq_intr(void *xsc)
-{
-	struct vtnet_softc *sc;
-
-	sc = xsc;
 
-	vtnet_disable_rx_intr(sc);
-	taskqueue_enqueue_fast(sc->vtnet_tq, &sc->vtnet_rx_intr_task);
-
-	return (1);
+	VTNET_UNLOCK(sc);
 }
 
 static void
@@ -1800,7 +1747,6 @@ vtnet_tx_offload(struct vtnet_softc *sc,
 	uint8_t ip_proto, gso_type;
 
 	ifp = sc->vtnet_ifp;
-	M_ASSERTPKTHDR(m);
 
 	ip_offset = sizeof(struct ether_header);
 	if (m->m_len < ip_offset) {
@@ -1918,7 +1864,7 @@ vtnet_enqueue_txbuf(struct vtnet_softc *
 	sglist_init(&sg, VTNET_MAX_TX_SEGS, segs);
 	error = sglist_append(&sg, &txhdr->vth_uhdr, sc->vtnet_hdr_size);
 	KASSERT(error == 0 && sg.sg_nseg == 1,
-	    ("cannot add header to sglist"));
+	    ("%s: cannot add header to sglist error %d", __func__, error));
 
 again:
 	error = sglist_append_mbuf(&sg, m);
@@ -1955,6 +1901,7 @@ vtnet_encap(struct vtnet_softc *sc, stru
 	int error;
 
 	m = *m_head;
+	M_ASSERTPKTHDR(m);
 
 	txhdr = uma_zalloc(vtnet_tx_header_zone, M_NOWAIT | M_ZERO);
 	if (txhdr == NULL) {
@@ -2077,14 +2024,15 @@ vtnet_tick(void *xsc)
 }
 
 static void
-vtnet_tx_intr_task(void *arg, int pending)
+vtnet_tx_vq_intr(void *xsc)
 {
 	struct vtnet_softc *sc;
 	struct ifnet *ifp;
 
-	sc = arg;
+	sc = xsc;
 	ifp = sc->vtnet_ifp;
 
+again:
 	VTNET_LOCK(sc);
 
 #ifdef DEVICE_POLLING
@@ -2109,26 +2057,12 @@ vtnet_tx_intr_task(void *arg, int pendin
 		vtnet_disable_tx_intr(sc);
 		sc->vtnet_stats.tx_task_rescheduled++;
 		VTNET_UNLOCK(sc);
-		taskqueue_enqueue_fast(sc->vtnet_tq, &sc->vtnet_tx_intr_task);
-		return;
+		goto again;
 	}
 
 	VTNET_UNLOCK(sc);
 }
 
-static int
-vtnet_tx_vq_intr(void *xsc)
-{
-	struct vtnet_softc *sc;
-
-	sc = xsc;
-
-	vtnet_disable_tx_intr(sc);
-	taskqueue_enqueue_fast(sc->vtnet_tq, &sc->vtnet_tx_intr_task);
-
-	return (1);
-}
-
 static void
 vtnet_stop(struct vtnet_softc *sc)
 {

Modified: stable/9/sys/dev/virtio/network/if_vtnetvar.h
==============================================================================
--- stable/9/sys/dev/virtio/network/if_vtnetvar.h	Wed Jul 10 01:33:49 2013	(r253131)
+++ stable/9/sys/dev/virtio/network/if_vtnetvar.h	Wed Jul 10 04:51:07 2013	(r253132)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011, Bryan Venteicher 
+ * Copyright (c) 2011, Bryan Venteicher 
  * All rights reserved.

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

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:06:35 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id E474DEA2;
 Wed, 10 Jul 2013 14:06:35 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id D62171FF6;
 Wed, 10 Jul 2013 14:06:35 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AE6Z9H058230;
 Wed, 10 Jul 2013 14:06:35 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AE6Zog058229;
 Wed, 10 Jul 2013 14:06:35 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101406.r6AE6Zog058229@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:06:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253152 - stable/9/lib/libfetch
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:06:36 -0000

Author: des
Date: Wed Jul 10 14:06:35 2013
New Revision: 253152
URL: http://svnweb.freebsd.org/changeset/base/253152

Log:
  MFH (r252375): remove useless side effect which triggers a clang bug.

Modified:
  stable/9/lib/libfetch/fetch.c
Directory Properties:
  stable/9/lib/libfetch/   (props changed)

Modified: stable/9/lib/libfetch/fetch.c
==============================================================================
--- stable/9/lib/libfetch/fetch.c	Wed Jul 10 12:51:30 2013	(r253151)
+++ stable/9/lib/libfetch/fetch.c	Wed Jul 10 14:06:35 2013	(r253152)
@@ -376,7 +376,7 @@ fetchParseURL(const char *URL)
 
 		/* password */
 		if (*q == ':')
-			q = fetch_pctdecode(u->pwd, ++q, URL_PWDLEN);
+			q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN);
 
 		p++;
 	} else {

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:11:14 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 69203E2;
 Wed, 10 Jul 2013 14:11:14 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 5A5901048;
 Wed, 10 Jul 2013 14:11:14 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AEBEb1060693;
 Wed, 10 Jul 2013 14:11:14 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AEBEXc060692;
 Wed, 10 Jul 2013 14:11:14 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101411.r6AEBEXc060692@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:11:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253153 - stable/9/contrib/openpam/lib
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:11:14 -0000

Author: des
Date: Wed Jul 10 14:11:13 2013
New Revision: 253153
URL: http://svnweb.freebsd.org/changeset/base/253153

Log:
  MFH (r249479): OPENPAM_DEBUG enables debugging but does not turn it on

Modified:
  stable/9/contrib/openpam/lib/openpam_log.c
Directory Properties:
  stable/9/contrib/openpam/   (props changed)

Modified: stable/9/contrib/openpam/lib/openpam_log.c
==============================================================================
--- stable/9/contrib/openpam/lib/openpam_log.c	Wed Jul 10 14:06:35 2013	(r253152)
+++ stable/9/contrib/openpam/lib/openpam_log.c	Wed Jul 10 14:11:13 2013	(r253153)
@@ -49,11 +49,7 @@
 
 #include "openpam_impl.h"
 
-#ifdef OPENPAM_DEBUG
-int openpam_debug = 1;
-#else
 int openpam_debug = 0;
-#endif
 
 #if !defined(openpam_log)
 

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:11:51 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id C6B2E1D0;
 Wed, 10 Jul 2013 14:11:51 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id B930B1052;
 Wed, 10 Jul 2013 14:11:51 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AEBpqb060822;
 Wed, 10 Jul 2013 14:11:51 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AEBpXS060821;
 Wed, 10 Jul 2013 14:11:51 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101411.r6AEBpXS060821@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:11:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253154 - stable/9/lib/libpam
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:11:51 -0000

Author: des
Date: Wed Jul 10 14:11:51 2013
New Revision: 253154
URL: http://svnweb.freebsd.org/changeset/base/253154

Log:
  MFH (r249479): OPENPAM_DEBUG enables debugging but does not turn it on

Modified:
  stable/9/lib/libpam/Makefile.inc
Directory Properties:
  stable/9/lib/libpam/   (props changed)

Modified: stable/9/lib/libpam/Makefile.inc
==============================================================================
--- stable/9/lib/libpam/Makefile.inc	Wed Jul 10 14:11:13 2013	(r253153)
+++ stable/9/lib/libpam/Makefile.inc	Wed Jul 10 14:11:51 2013	(r253154)
@@ -24,9 +24,7 @@
 #
 # $FreeBSD$
 
-.ifdef PAM_DEBUG
-DEBUG_FLAGS+=	-DDEBUG
-.endif
+CFLAGS+=	-DOPENPAM_DEBUG
 
 SHLIB_MAJOR=	5
 PAM_MOD_DIR=	${LIBDIR}

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:13:39 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 2EC11385;
 Wed, 10 Jul 2013 14:13:39 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 10C1F1074;
 Wed, 10 Jul 2013 14:13:39 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AEDc9o061145;
 Wed, 10 Jul 2013 14:13:38 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AEDccN061139;
 Wed, 10 Jul 2013 14:13:38 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101413.r6AEDccN061139@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:13:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253155 - stable/9/sbin/fsck_ffs
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:13:39 -0000

Author: des
Date: Wed Jul 10 14:13:37 2013
New Revision: 253155
URL: http://svnweb.freebsd.org/changeset/base/253155

Log:
  MFH (r250056,r250057): add -Z option to zero unused blocks.

Modified:
  stable/9/sbin/fsck_ffs/fsck.h
  stable/9/sbin/fsck_ffs/fsck_ffs.8
  stable/9/sbin/fsck_ffs/fsutil.c
  stable/9/sbin/fsck_ffs/main.c
  stable/9/sbin/fsck_ffs/pass5.c
Directory Properties:
  stable/9/sbin/fsck_ffs/   (props changed)

Modified: stable/9/sbin/fsck_ffs/fsck.h
==============================================================================
--- stable/9/sbin/fsck_ffs/fsck.h	Wed Jul 10 14:11:51 2013	(r253154)
+++ stable/9/sbin/fsck_ffs/fsck.h	Wed Jul 10 14:13:37 2013	(r253155)
@@ -74,6 +74,7 @@
 #define	MINBUFS		10	/* minimum number of buffers required */
 #define	MAXBUFS		40	/* maximum space to allocate to buffers */
 #define	INOBUFSIZE	64*1024	/* size of buffer to read inodes in pass1 */
+#define	ZEROBUFSIZE	(dev_bsize * 128) /* size of zero buffer used by -Z */
 
 union dinode {
 	struct ufs1_dinode dp1;
@@ -306,7 +307,8 @@ char	yflag;			/* assume a yes response *
 int	bkgrdflag;		/* use a snapshot to run on an active system */
 int	bflag;			/* location of alternate super block */
 int	debug;			/* output debugging info */
-int	Eflag;			/* zero out empty data blocks */
+int	Eflag;			/* delete empty data blocks */
+int	Zflag;			/* zero empty data blocks */
 int	inoopt;			/* trim out unused inodes */
 char	ckclean;		/* only do work if not cleanly unmounted */
 int	cvtlevel;		/* convert to newer file system format */
@@ -402,6 +404,7 @@ int		blread(int fd, char *buf, ufs2_dadd
 void		bufinit(void);
 void		blwrite(int fd, char *buf, ufs2_daddr_t blk, long size);
 void		blerase(int fd, ufs2_daddr_t blk, long size);
+void		blzero(int fd, ufs2_daddr_t blk, long size);
 void		cacheino(union dinode *dp, ino_t inumber);
 void		catch(int);
 void		catchquit(int);

Modified: stable/9/sbin/fsck_ffs/fsck_ffs.8
==============================================================================
--- stable/9/sbin/fsck_ffs/fsck_ffs.8	Wed Jul 10 14:11:51 2013	(r253154)
+++ stable/9/sbin/fsck_ffs/fsck_ffs.8	Wed Jul 10 14:13:37 2013	(r253155)
@@ -38,7 +38,7 @@
 .Nd file system consistency check and interactive repair
 .Sh SYNOPSIS
 .Nm
-.Op Fl BEFfnpry
+.Op Fl BEFfnpryZ
 .Op Fl b Ar block
 .Op Fl c Ar level
 .Op Fl m Ar mode
@@ -275,6 +275,15 @@ Assume a yes response to all questions a
 .Nm ;
 this should be used with great caution as this is a free license
 to continue after essentially unlimited trouble has been encountered.
+.It Fl Z
+Similar to
+.Fl E ,
+but overwrites unused blocks with zeroes.
+If both
+.Fl E
+and
+.Fl Z
+are specified, blocks are first zeroed and then erased.
 .El
 .Pp
 Inconsistencies checked are as follows:

Modified: stable/9/sbin/fsck_ffs/fsutil.c
==============================================================================
--- stable/9/sbin/fsck_ffs/fsutil.c	Wed Jul 10 14:11:51 2013	(r253154)
+++ stable/9/sbin/fsck_ffs/fsutil.c	Wed Jul 10 14:13:37 2013	(r253155)
@@ -617,6 +617,35 @@ blerase(int fd, ufs2_daddr_t blk, long s
 	return;
 }
 
+void
+blzero(int fd, ufs2_daddr_t blk, long size)
+{
+	static char *zero;
+	off_t offset, len;
+
+	if (fd < 0)
+		return;
+	len = ZEROBUFSIZE;
+	if (zero == NULL) {
+		zero = calloc(len, 1);
+		if (zero == NULL)
+			errx(EEXIT, "cannot allocate buffer pool");
+	}
+	offset = blk * dev_bsize;
+	if (lseek(fd, offset, 0) < 0)
+		rwerror("SEEK BLK", blk);
+	while (size > 0) {
+		if (size > len)
+			size = len;
+		else
+			len = size;
+		if (write(fd, zero, len) != len)
+			rwerror("WRITE BLK", blk);
+		blk += len / dev_bsize;
+		size -= len;
+	}
+}
+
 /*
  * Verify cylinder group's magic number and other parameters.  If the
  * test fails, offer an option to rebuild the whole cylinder group.

Modified: stable/9/sbin/fsck_ffs/main.c
==============================================================================
--- stable/9/sbin/fsck_ffs/main.c	Wed Jul 10 14:11:51 2013	(r253154)
+++ stable/9/sbin/fsck_ffs/main.c	Wed Jul 10 14:13:37 2013	(r253155)
@@ -82,7 +82,7 @@ main(int argc, char *argv[])
 	sync();
 	skipclean = 1;
 	inoopt = 0;
-	while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npry")) != -1) {
+	while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npryZ")) != -1) {
 		switch (ch) {
 		case 'b':
 			skipclean = 0;
@@ -147,6 +147,10 @@ main(int argc, char *argv[])
 			nflag = 0;
 			break;
 
+		case 'Z':
+			Zflag++;
+			break;
+
 		default:
 			usage();
 		}

Modified: stable/9/sbin/fsck_ffs/pass5.c
==============================================================================
--- stable/9/sbin/fsck_ffs/pass5.c	Wed Jul 10 14:11:51 2013	(r253154)
+++ stable/9/sbin/fsck_ffs/pass5.c	Wed Jul 10 14:13:37 2013	(r253155)
@@ -252,7 +252,7 @@ pass5(void)
 			frags = 0;
 			for (j = 0; j < fs->fs_frag; j++) {
 				if (testbmap(d + j)) {
-					if (Eflag && start != -1) {
+					if ((Eflag || Zflag) && start != -1) {
 						clear_blocks(start, d + j - 1);
 						start = -1;
 					}
@@ -274,7 +274,7 @@ pass5(void)
 				ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
 			}
 		}
-		if (Eflag && start != -1)
+		if ((Eflag || Zflag) && start != -1)
 			clear_blocks(start, d - 1);
 		if (fs->fs_contigsumsize > 0) {
 			int32_t *sump = cg_clustersum(newcg);
@@ -581,11 +581,16 @@ check_maps(
 	}
 }
 
-static void clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end)
+static void
+clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end)
 {
 
 	if (debug)
 		printf("Zero frags %jd to %jd\n", start, end);
-	blerase(fswritefd, fsbtodb(&sblock, start),
-	    lfragtosize(&sblock, end - start + 1));
+	if (Zflag)
+		blzero(fswritefd, fsbtodb(&sblock, start),
+		    lfragtosize(&sblock, end - start + 1));
+	if (Eflag)
+		blerase(fswritefd, fsbtodb(&sblock, start),
+		    lfragtosize(&sblock, end - start + 1));
 }

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:14:49 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 0211B4D8;
 Wed, 10 Jul 2013 14:14:49 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id E6D9A1089;
 Wed, 10 Jul 2013 14:14:48 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AEEmlf061365;
 Wed, 10 Jul 2013 14:14:48 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AEEmGx061361;
 Wed, 10 Jul 2013 14:14:48 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101414.r6AEEmGx061361@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:14:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253156 - stable/9/usr.sbin/jls
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:14:49 -0000

Author: des
Date: Wed Jul 10 14:14:48 2013
New Revision: 253156
URL: http://svnweb.freebsd.org/changeset/base/253156

Log:
  MFH (r250736): add -N option to list jail name instead of number

Modified:
  stable/9/usr.sbin/jls/jls.8
  stable/9/usr.sbin/jls/jls.c
Directory Properties:
  stable/9/usr.sbin/jls/   (props changed)

Modified: stable/9/usr.sbin/jls/jls.8
==============================================================================
--- stable/9/usr.sbin/jls/jls.8	Wed Jul 10 14:13:37 2013	(r253155)
+++ stable/9/usr.sbin/jls/jls.8	Wed Jul 10 14:14:48 2013	(r253156)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 8, 2009
+.Dd July 20, 2012
 .Dt JLS 8
 .Os
 .Sh NAME
@@ -33,7 +33,7 @@
 .Nd "list jails"
 .Sh SYNOPSIS
 .Nm
-.Op Fl dhnqsv
+.Op Fl dhNnqsv
 .Op Fl j Ar jail
 .Op Ar parameter ...
 .Sh DESCRIPTION
@@ -71,6 +71,10 @@ Print a header line containing the param
 If no parameters are given on the command line,
 .Va all
 is assumed.
+.It Fl N
+In the standard display mode, print each jail's name instead of its
+numeric ID.
+If the jail does not have a name, the numeric ID is printed instead.
 .It Fl n
 Print parameters in
 .Dq name=value

Modified: stable/9/usr.sbin/jls/jls.c
==============================================================================
--- stable/9/usr.sbin/jls/jls.c	Wed Jul 10 14:13:37 2013	(r253155)
+++ stable/9/usr.sbin/jls/jls.c	Wed Jul 10 14:14:48 2013	(r253156)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #define	PRINT_QUOTED	0x08
 #define	PRINT_SKIP	0x10
 #define	PRINT_VERBOSE	0x20
+#define	PRINT_JAIL_NAME	0x40
 
 static struct jailparam *params;
 static int *param_parent;
@@ -82,7 +83,7 @@ main(int argc, char **argv)
 
 	jname = NULL;
 	pflags = jflags = jid = 0;
-	while ((c = getopt(argc, argv, "adj:hnqsv")) >= 0)
+	while ((c = getopt(argc, argv, "adj:hNnqsv")) >= 0)
 		switch (c) {
 		case 'a':
 		case 'd':
@@ -99,6 +100,9 @@ main(int argc, char **argv)
 			pflags = (pflags & ~(PRINT_SKIP | PRINT_VERBOSE)) |
 			    PRINT_HEADER;
 			break;
+		case 'N':
+			pflags |= PRINT_JAIL_NAME;
+			break;
 		case 'n':
 			pflags = (pflags & ~PRINT_VERBOSE) | PRINT_NAMEVAL;
 			break;
@@ -115,7 +119,7 @@ main(int argc, char **argv)
 			    PRINT_VERBOSE;
 			break;
 		default:
-			errx(1, "usage: jls [-dhnqv] [-j jail] [param ...]");
+			errx(1, "usage: jls [-dhNnqv] [-j jail] [param ...]");
 		}
 
 #ifdef INET6
@@ -149,7 +153,10 @@ main(int argc, char **argv)
 #endif
 		} else {
 			pflags |= PRINT_DEFAULT;
-			add_param("jid", NULL, (size_t)0, NULL, JP_USER);
+			if (pflags & PRINT_JAIL_NAME)
+				add_param("name", NULL, (size_t)0, NULL, JP_USER);
+			else
+				add_param("jid", NULL, (size_t)0, NULL, JP_USER);
 #ifdef INET
 			if (ip4_ok)
 				add_param("ip4.addr", NULL, (size_t)0, NULL,
@@ -192,8 +199,12 @@ main(int argc, char **argv)
 		       "        CPUSetID\n"
 		       "        IP Address(es)\n");
 	else if (pflags & PRINT_DEFAULT)
-		printf("   JID  IP Address      "
-		       "Hostname                      Path\n");
+		if (pflags & PRINT_JAIL_NAME)
+			printf(" JID             IP Address      "
+			    "Hostname                      Path\n");
+		else
+			printf("   JID  IP Address      "
+			    "Hostname                      Path\n");
 	else if (pflags & PRINT_HEADER) {
 		for (i = spc = 0; i < nparams; i++)
 			if (params[i].jp_flags & JP_USER) {
@@ -397,9 +408,12 @@ print_jail(int pflags, int jflags)
 			n++;
 		}
 #endif
-	} else if (pflags & PRINT_DEFAULT)
-		printf("%6d  %-15.15s %-29.29s %.74s\n",
-		    *(int *)params[0].jp_value,
+	} else if (pflags & PRINT_DEFAULT) {
+		if (pflags & PRINT_JAIL_NAME)
+			printf(" %-15s ", (char *)params[0].jp_value);
+		else
+			printf("%6d  ", *(int *)params[0].jp_value);
+		printf("%-15.15s %-29.29s %.74s\n",
 #ifdef INET
 		    (!ip4_ok || params[1].jp_valuelen == 0) ? "-"
 		    : inet_ntoa(*(struct in_addr *)params[1].jp_value),
@@ -410,7 +424,7 @@ print_jail(int pflags, int jflags)
 		    (char *)params[1].jp_value,
 		    (char *)params[2].jp_value);
 #endif
-	else {
+	} else {
 		param_values = alloca(nparams * sizeof(*param_values));
 		for (i = 0; i < nparams; i++) {
 			if (!(params[i].jp_flags & JP_USER))

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 14:16:40 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 40117639;
 Wed, 10 Jul 2013 14:16:40 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 31F3610A2;
 Wed, 10 Jul 2013 14:16:40 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AEGeta061662;
 Wed, 10 Jul 2013 14:16:40 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AEGeW6061661;
 Wed, 10 Jul 2013 14:16:40 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307101416.r6AEGeW6061661@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Wed, 10 Jul 2013 14:16:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253157 - stable/9/usr.sbin/pw
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 14:16:40 -0000

Author: des
Date: Wed Jul 10 14:16:39 2013
New Revision: 253157
URL: http://svnweb.freebsd.org/changeset/base/253157

Log:
  MFH (r252556): allow setting expiry to current date / time
  MFH (r252688): fall back to sha512 if passwd_format is not set

Modified:
  stable/9/usr.sbin/pw/pw_user.c
Directory Properties:
  stable/9/usr.sbin/pw/   (props changed)

Modified: stable/9/usr.sbin/pw/pw_user.c
==============================================================================
--- stable/9/usr.sbin/pw/pw_user.c	Wed Jul 10 14:14:48 2013	(r253156)
+++ stable/9/usr.sbin/pw/pw_user.c	Wed Jul 10 14:16:39 2013	(r253157)
@@ -494,8 +494,6 @@ pw_user(struct userconf * cnf, int mode,
 				time_t          now = time(NULL);
 				time_t          expire = parse_date(now, arg->val);
 
-				if (now == expire)
-					errx(EX_DATAERR, "invalid password change date `%s'", arg->val);
 				if (pwd->pw_change != expire) {
 					pwd->pw_change = expire;
 					edited = 1;
@@ -514,8 +512,6 @@ pw_user(struct userconf * cnf, int mode,
 				time_t          now = time(NULL);
 				time_t          expire = parse_date(now, arg->val);
 
-				if (now == expire)
-					errx(EX_DATAERR, "invalid account expiry date `%s'", arg->val);
 				if (pwd->pw_expire != expire) {
 					pwd->pw_expire = expire;
 					edited = 1;
@@ -558,7 +554,7 @@ pw_user(struct userconf * cnf, int mode,
 
 			lc = login_getpwclass(pwd);
 			if (lc == NULL ||
-			    login_setcryptfmt(lc, "md5", NULL) == NULL)
+			    login_setcryptfmt(lc, "sha512", NULL) == NULL)
 				warn("setting crypt(3) format");
 			login_close(lc);
 			pwd->pw_passwd = pw_password(cnf, args, pwd->pw_name);

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 17:16:11 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 97E0E4DC;
 Wed, 10 Jul 2013 17:16:11 +0000 (UTC)
 (envelope-from sbruno@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 6F6321EB2;
 Wed, 10 Jul 2013 17:16:11 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AHGBEb015627;
 Wed, 10 Jul 2013 17:16:11 GMT (envelope-from sbruno@svn.freebsd.org)
Received: (from sbruno@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AHGBK6015626;
 Wed, 10 Jul 2013 17:16:11 GMT (envelope-from sbruno@svn.freebsd.org)
Message-Id: <201307101716.r6AHGBK6015626@svn.freebsd.org>
From: Sean Bruno 
Date: Wed, 10 Jul 2013 17:16:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253160 - stable/9/sys/dev/ciss
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 17:16:11 -0000

Author: sbruno
Date: Wed Jul 10 17:16:10 2013
New Revision: 253160
URL: http://svnweb.freebsd.org/changeset/base/253160

Log:
  Jump on the 9.2r MFC bonanza and update ciss(4)
  
  r250031
   - zero a data structure for notifications
  
  r250022 r249977 r249947 r249908
   - handle cases of controllers advertising an sg_list of less than
     CISS_MAX_SG_ELEMENTS.  Fixes ciss(4) ZMR cases.

Modified:
  stable/9/sys/dev/ciss/ciss.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/ciss/ciss.c
==============================================================================
--- stable/9/sys/dev/ciss/ciss.c	Wed Jul 10 16:28:24 2013	(r253159)
+++ stable/9/sys/dev/ciss/ciss.c	Wed Jul 10 17:16:10 2013	(r253160)
@@ -2487,6 +2487,7 @@ ciss_preen_command(struct ciss_request *
     cc->header.sg_total = 0;
     cc->header.host_tag = cr->cr_tag << 2;
     cc->header.host_tag_zeroes = 0;
+    bzero(&(cc->sg[0]), CISS_COMMAND_ALLOC_SIZE - sizeof(struct ciss_command));
     cmdphys = cr->cr_ccphys;
     cc->error_info.error_info_address = cmdphys + sizeof(struct ciss_command);
     cc->error_info.error_info_length = CISS_COMMAND_ALLOC_SIZE - sizeof(struct ciss_command);
@@ -2985,6 +2986,7 @@ ciss_cam_action(struct cam_sim *sim, uni
     case XPT_PATH_INQ:
     {
 	struct ccb_pathinq	*cpi = &ccb->cpi;
+	int			sg_length;
 
 	debug(1, "XPT_PATH_INQ %d:%d:%d", cam_sim_bus(sim), ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
 
@@ -3005,7 +3007,22 @@ ciss_cam_action(struct cam_sim *sim, uni
 	cpi->transport_version = 2;
 	cpi->protocol = PROTO_SCSI;
 	cpi->protocol_version = SCSI_REV_2;
-	cpi->maxio = (CISS_MAX_SG_ELEMENTS - 1) * PAGE_SIZE;
+	if (sc->ciss_cfg->max_sg_length == 0) {
+		sg_length = 17;
+	} else {
+	/* XXX Fix for ZMR cards that advertise max_sg_length == 32
+	 * Confusing bit here. max_sg_length is usually a power of 2. We always
+	 * need to subtract 1 to account for partial pages. Then we need to 
+	 * align on a valid PAGE_SIZE so we round down to the nearest power of 2. 
+	 * Add 1 so we can then subtract it out in the assignment to maxio.
+	 * The reason for all these shenanigans is to create a maxio value that
+	 * creates IO operations to volumes that yield consistent operations
+	 * with good performance.
+	 */
+		sg_length = sc->ciss_cfg->max_sg_length - 1;
+		sg_length = (1 << (fls(sg_length) - 1)) + 1;
+	}
+	cpi->maxio = (min(CISS_MAX_SG_ELEMENTS, sg_length) - 1) * PAGE_SIZE;
 	ccb->ccb_h.status = CAM_REQ_CMP;
 	break;
     }

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 18:27:15 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 7E01F6E4;
 Wed, 10 Jul 2013 18:27:15 +0000 (UTC)
 (envelope-from brooks@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 6EDC312AE;
 Wed, 10 Jul 2013 18:27:15 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AIRFuY037246;
 Wed, 10 Jul 2013 18:27:15 GMT (envelope-from brooks@svn.freebsd.org)
Received: (from brooks@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AIRFCX037245;
 Wed, 10 Jul 2013 18:27:15 GMT (envelope-from brooks@svn.freebsd.org)
Message-Id: <201307101827.r6AIRFCX037245@svn.freebsd.org>
From: Brooks Davis 
Date: Wed, 10 Jul 2013 18:27:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253164 - stable/9
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 18:27:15 -0000

Author: brooks
Date: Wed Jul 10 18:27:14 2013
New Revision: 253164
URL: http://svnweb.freebsd.org/changeset/base/253164

Log:
  MFC r251765:
  
  Simplify the hierarchy target's logic.[0]
  
  Run hierarchy with WORLDTMP in the path so it works when it is invoked
  directly.  Such use is nearly alwasy wrong but appears to be common.[1]
  
  PR:		conf/178209 [0], conf/178547 [1]
  Submitted by:	Garrett Cooper  [0]

Modified:
  stable/9/Makefile.inc1   (contents, props changed)

Modified: stable/9/Makefile.inc1
==============================================================================
--- stable/9/Makefile.inc1	Wed Jul 10 18:19:48 2013	(r253163)
+++ stable/9/Makefile.inc1	Wed Jul 10 18:27:14 2013	(r253164)
@@ -268,6 +268,13 @@ WMAKEENV=	${CROSSENV} \
 		VERSION="${VERSION}" \
 		INSTALL="sh ${.CURDIR}/tools/install.sh" \
 		PATH=${TMPPATH}
+
+# make hierarchy
+HMAKE=		PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE}
+.if defined(NO_ROOT)
+HMAKE+=		PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
+.endif
+
 .if ${MK_CDDL} == "no"
 WMAKEENV+=	NO_CTF=1
 .endif
@@ -1288,12 +1295,7 @@ cross-tools:
 # hierarchy - ensure that all the needed directories are present
 #
 hierarchy hier:
-.if defined(NO_ROOT)
-	cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \
-	    -DNO_ROOT METALOG=${METALOG} distrib-dirs
-.else
-	cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
-.endif
+	cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
 
 #
 # libraries - build all libraries, and install them under ${DESTDIR}.

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 18:58:43 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 56E3C10E;
 Wed, 10 Jul 2013 18:58:43 +0000 (UTC)
 (envelope-from Andre.Albsmeier@siemens.com)
Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28])
 by mx1.freebsd.org (Postfix) with ESMTP id BF2EB1489;
 Wed, 10 Jul 2013 18:58:42 +0000 (UTC)
Received: from mail1.siemens.de (localhost [127.0.0.1])
 by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id r6AIwY1h012066;
 Wed, 10 Jul 2013 20:58:34 +0200
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130])
 by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id r6AIwY9L028997;
 Wed, 10 Jul 2013 20:58:34 +0200
Received: (from localhost)
 by curry.mchp.siemens.de (8.14.7/8.14.7) id r6AIwYcr044910;
Date: Wed, 10 Jul 2013 20:58:33 +0200
From: Andre Albsmeier 
To: "Kenneth D. Merry" 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130710185833.GA83135@bali>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali>
 <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali>
 <20130710184915.GA28790@nargothrond.kdm.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20130710184915.GA28790@nargothrond.kdm.org>
X-Echelon: 
X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses!
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 18:58:43 -0000

On Wed, 10-Jul-2013 at 20:49:15 +0200, Kenneth D. Merry wrote:
> On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> > On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > > Author: ken
> > > > > Date: Tue Jun 25 21:43:49 2013
> > > > > New Revision: 252214
> > > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > > 
> > > > Hi Ken,
> > > > 
> > > > > Log:
> > > > >   MFC: 249658, 249701
> > > > > 
> > > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > > 
> > > > >   This allows mapping a tape drive in a changer (as reported by
> > > > >   'chio status') to a sa(4) driver instance by comparing the
> > > > >   serial numbers.
> > > > > 
> > > > >   The designators can be ASCII (which is printed out directly), binary
> > > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > > >   explanation and example UTF-8 printing code.
> > > > > 
> > > > >   chio.h:               Modify the changer_element_status structure to add new
> > > > >                 fields and definitions from the SMC3r16 spec.
> > > > > 
> > > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > > >                 define a new CHIOGSTATUS ioctl.
> > > > > 
> > > > >                 Clean up some tab/space issues.
> > > > > 
> > > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > > >                 if it is supplied by a device.
> > > > > 
> > > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > > >                 ELEMENT STATUS command structure.
> > > > > 
> > > > >                 Add a read_element_status_device_id structure
> > > > >                 for the data fields in the new standard. Add new
> > > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > > >                 and address data from either SCSI-2 or newer devices.
> > > > > 
> > > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > > >                 ELEMENT STATUS data.
> > > > > 
> > > > >                 Add new arguments to scsi_read_element_status() to
> > > > >                 allow the user to request the DVCID and CURDATA bits.
> > > > 
> > > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > > 
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > > 
> > > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > > this workaround to make it work again until a better solution is available:
> > > > 
> > > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > > @@ -1245,8 +1245,8 @@
> > > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > > >  				 /* voltag */ want_voltags,
> > > >  				 /* sea */ softc->sc_firsts[chet],
> > > > -				 /* dvcid */ 1,
> > > > -				 /* curdata */ 1,
> > > > +				 /* dvcid */ 0,
> > > > +				 /* curdata */ 0,
> > > >  				 /* count */ 1,
> > > >  				 /* data_ptr */ data,
> > > >  				 /* dxfer_len */ 1024,
> > > > @@ -1284,8 +1284,8 @@
> > > >  				 /* voltag */ want_voltags,
> > > >  				 /* sea */ softc->sc_firsts[chet]
> > > >  				 + cesr->cesr_element_base,
> > > > -				 /* dvcid */ 1,
> > > > -				 /* curdata */ 1,
> > > > +				 /* dvcid */ 0,
> > > > +				 /* curdata */ 0,
> > > >  				 /* count */ cesr->cesr_element_count,
> > > >  				 /* data_ptr */ data,
> > > >  				 /* dxfer_len */ size,
> > > > 
> > > > 	-Andre
> > > 
> > > Oops, sorry.
> > > 
> > > We need to check the SCSI version to see whether to set those bits, and
> > > also fall back in case it doesn't work.
> > > 
> > > I am on vacation and have very spotty net access.  I can't do anything
> > > about it until I get back next week.
> > > 
> > > Justin and Alan (CCed) can work on the fix, though.
> > 
> > Take your time, for me it's working right now
> > with the above patch...
> 
> Okay, I'm back and can take a look at this.

Welcome back ;-)

> 
> Can you send me:

Sure, I am happy to help.

> 
> camcontrol inquiry ch0 -v

pass17:  Removable Changer SCSI-2 device 
pass17: Serial Number 0021009613
pass17: 3.300MB/s transfers

> camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"

0 0 0 0 0 0 0 0 

> 
> I want to see what SCSI version this changer reports.  The second command
> will print out the SCSI version descriptors, if any, that the changer
> reports.

In case you need more info just drop me a note.

Thanks for looking into this.

	-Andre

> 
> Ken
> -- 
> Kenneth Merry
> ken@FreeBSD.ORG
> 

-- 
ech`echo xiun | tr nu oc | sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 19:18:58 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 118E4776;
 Wed, 10 Jul 2013 19:18:58 +0000 (UTC) (envelope-from ken@kdm.org)
Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81])
 by mx1.freebsd.org (Postfix) with ESMTP id 8DD50169A;
 Wed, 10 Jul 2013 19:18:57 +0000 (UTC)
Received: from nargothrond.kdm.org (localhost [127.0.0.1])
 by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id r6AInGCX029433;
 Wed, 10 Jul 2013 12:49:16 -0600 (MDT)
 (envelope-from ken@nargothrond.kdm.org)
Received: (from ken@localhost)
 by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id r6AInFvT029432;
 Wed, 10 Jul 2013 12:49:15 -0600 (MDT) (envelope-from ken)
Date: Wed, 10 Jul 2013 12:49:15 -0600
From: "Kenneth D. Merry" 
To: Andre Albsmeier 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130710184915.GA28790@nargothrond.kdm.org>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali> <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20130703054349.GA13656@bali>
User-Agent: Mutt/1.4.2i
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 19:18:58 -0000

On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > Author: ken
> > > > Date: Tue Jun 25 21:43:49 2013
> > > > New Revision: 252214
> > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > 
> > > Hi Ken,
> > > 
> > > > Log:
> > > >   MFC: 249658, 249701
> > > > 
> > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > 
> > > >   This allows mapping a tape drive in a changer (as reported by
> > > >   'chio status') to a sa(4) driver instance by comparing the
> > > >   serial numbers.
> > > > 
> > > >   The designators can be ASCII (which is printed out directly), binary
> > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > >   explanation and example UTF-8 printing code.
> > > > 
> > > >   chio.h:               Modify the changer_element_status structure to add new
> > > >                 fields and definitions from the SMC3r16 spec.
> > > > 
> > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > >                 define a new CHIOGSTATUS ioctl.
> > > > 
> > > >                 Clean up some tab/space issues.
> > > > 
> > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > >                 if it is supplied by a device.
> > > > 
> > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > >                 ELEMENT STATUS command structure.
> > > > 
> > > >                 Add a read_element_status_device_id structure
> > > >                 for the data fields in the new standard. Add new
> > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > >                 and address data from either SCSI-2 or newer devices.
> > > > 
> > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > >                 ELEMENT STATUS data.
> > > > 
> > > >                 Add new arguments to scsi_read_element_status() to
> > > >                 allow the user to request the DVCID and CURDATA bits.
> > > 
> > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > 
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > 
> > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > this workaround to make it work again until a better solution is available:
> > > 
> > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > @@ -1245,8 +1245,8 @@
> > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > >  				 /* voltag */ want_voltags,
> > >  				 /* sea */ softc->sc_firsts[chet],
> > > -				 /* dvcid */ 1,
> > > -				 /* curdata */ 1,
> > > +				 /* dvcid */ 0,
> > > +				 /* curdata */ 0,
> > >  				 /* count */ 1,
> > >  				 /* data_ptr */ data,
> > >  				 /* dxfer_len */ 1024,
> > > @@ -1284,8 +1284,8 @@
> > >  				 /* voltag */ want_voltags,
> > >  				 /* sea */ softc->sc_firsts[chet]
> > >  				 + cesr->cesr_element_base,
> > > -				 /* dvcid */ 1,
> > > -				 /* curdata */ 1,
> > > +				 /* dvcid */ 0,
> > > +				 /* curdata */ 0,
> > >  				 /* count */ cesr->cesr_element_count,
> > >  				 /* data_ptr */ data,
> > >  				 /* dxfer_len */ size,
> > > 
> > > 	-Andre
> > 
> > Oops, sorry.
> > 
> > We need to check the SCSI version to see whether to set those bits, and
> > also fall back in case it doesn't work.
> > 
> > I am on vacation and have very spotty net access.  I can't do anything
> > about it until I get back next week.
> > 
> > Justin and Alan (CCed) can work on the fix, though.
> 
> Take your time, for me it's working right now
> with the above patch...

Okay, I'm back and can take a look at this.

Can you send me:

camcontrol inquiry ch0 -v
camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"

I want to see what SCSI version this changer reports.  The second command
will print out the SCSI version descriptors, if any, that the changer
reports.

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 19:42:08 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 83609F4B;
 Wed, 10 Jul 2013 19:42:08 +0000 (UTC)
 (envelope-from trociny@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 5B8EB17A4;
 Wed, 10 Jul 2013 19:42:08 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AJg8hY060410;
 Wed, 10 Jul 2013 19:42:08 GMT (envelope-from trociny@svn.freebsd.org)
Received: (from trociny@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AJg8PH060409;
 Wed, 10 Jul 2013 19:42:08 GMT (envelope-from trociny@svn.freebsd.org)
Message-Id: <201307101942.r6AJg8PH060409@svn.freebsd.org>
From: Mikolaj Golub 
Date: Wed, 10 Jul 2013 19:42:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253166 - stable/9/lib/libkvm
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 19:42:08 -0000

Author: trociny
Date: Wed Jul 10 19:42:07 2013
New Revision: 253166
URL: http://svnweb.freebsd.org/changeset/base/253166

Log:
  Direct commit to stable branch to fix ABI breakage:
  
  In r227839, when removing libkvm dependency on procfs(5),
  kvm_uread() function, used for reading from /proc/pid/mem, was
  removed too. This change broke ABI.
  
  Bring kvm_uread() back so that the ABI is kept. In head soname is
  going to be bumped instead.
  
  Reported by:	rmh
  Discussed on:	arch
  Suggested by:	jilles

Modified:
  stable/9/lib/libkvm/kvm_proc.c

Modified: stable/9/lib/libkvm/kvm_proc.c
==============================================================================
--- stable/9/lib/libkvm/kvm_proc.c	Wed Jul 10 19:15:59 2013	(r253165)
+++ stable/9/lib/libkvm/kvm_proc.c	Wed Jul 10 19:42:07 2013	(r253166)
@@ -712,3 +712,55 @@ kvm_getenvv(kvm_t *kd, const struct kinf
 {
 	return (kvm_argv(kd, kp, 1, nchr));
 }
+
+/*
+ * Read from user space.  The user context is given by p.
+ */
+ssize_t
+kvm_uread(kvm_t *kd, const struct kinfo_proc *kp, u_long uva, char *buf,
+	size_t len)
+{
+	char *cp;
+	char procfile[MAXPATHLEN];
+	ssize_t amount;
+	int fd;
+
+	if (!ISALIVE(kd)) {
+		_kvm_err(kd, kd->program,
+		    "cannot read user space from dead kernel");
+		return (0);
+	}
+
+	sprintf(procfile, "/proc/%d/mem", kp->ki_pid);
+	fd = open(procfile, O_RDONLY, 0);
+	if (fd < 0) {
+		_kvm_err(kd, kd->program, "cannot open %s", procfile);
+		return (0);
+	}
+
+	cp = buf;
+	while (len > 0) {
+		errno = 0;
+		if (lseek(fd, (off_t)uva, 0) == -1 && errno != 0) {
+			_kvm_err(kd, kd->program, "invalid address (%lx) in %s",
+			    uva, procfile);
+			break;
+		}
+		amount = read(fd, cp, len);
+		if (amount < 0) {
+			_kvm_syserr(kd, kd->program, "error reading %s",
+			    procfile);
+			break;
+		}
+		if (amount == 0) {
+			_kvm_err(kd, kd->program, "EOF reading %s", procfile);
+			break;
+		}
+		cp += amount;
+		uva += amount;
+		len -= amount;
+	}
+
+	close(fd);
+	return ((ssize_t)(cp - buf));
+}

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 20:20:24 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 716E5E00;
 Wed, 10 Jul 2013 20:20:24 +0000 (UTC)
 (envelope-from dteske@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 630EA19C9;
 Wed, 10 Jul 2013 20:20:24 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AKKOoV072130;
 Wed, 10 Jul 2013 20:20:24 GMT (envelope-from dteske@svn.freebsd.org)
Received: (from dteske@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AKKONv072129;
 Wed, 10 Jul 2013 20:20:24 GMT (envelope-from dteske@svn.freebsd.org)
Message-Id: <201307102020.r6AKKONv072129@svn.freebsd.org>
From: Devin Teske 
Date: Wed, 10 Jul 2013 20:20:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253168 - stable/9/usr.sbin/bsdconfig/share
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 20:20:24 -0000

Author: dteske
Date: Wed Jul 10 20:20:23 2013
New Revision: 253168
URL: http://svnweb.freebsd.org/changeset/base/253168

Log:
  MFC r253121: Adjust comments to fit within 80-columns.

Modified:
  stable/9/usr.sbin/bsdconfig/share/dialog.subr

Modified: stable/9/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- stable/9/usr.sbin/bsdconfig/share/dialog.subr	Wed Jul 10 19:44:43 2013	(r253167)
+++ stable/9/usr.sbin/bsdconfig/share/dialog.subr	Wed Jul 10 20:20:23 2013	(r253168)
@@ -195,8 +195,8 @@ f_dialog_line_sanitize()
 # argument is NULL, the current title is returned.
 #
 # Each time this function is called, a backup of the current values is made
-# allowing a one-time (single-level) restoration of the previous title using the
-# f_dialog_title_restore() function (below).
+# allowing a one-time (single-level) restoration of the previous title using
+# the f_dialog_title_restore() function (below).
 #
 f_dialog_title()
 {

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 20:22:31 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 9E1AEFDF;
 Wed, 10 Jul 2013 20:22:31 +0000 (UTC)
 (envelope-from dteske@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 8FC9819E4;
 Wed, 10 Jul 2013 20:22:31 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AKMVY4072463;
 Wed, 10 Jul 2013 20:22:31 GMT (envelope-from dteske@svn.freebsd.org)
Received: (from dteske@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AKMVCd072462;
 Wed, 10 Jul 2013 20:22:31 GMT (envelope-from dteske@svn.freebsd.org)
Message-Id: <201307102022.r6AKMVCd072462@svn.freebsd.org>
From: Devin Teske 
Date: Wed, 10 Jul 2013 20:22:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253169 - stable/9/usr.sbin/bsdconfig/share
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 20:22:31 -0000

Author: dteske
Date: Wed Jul 10 20:22:31 2013
New Revision: 253169
URL: http://svnweb.freebsd.org/changeset/base/253169

Log:
  MFC r253118: Fix conditional (der should match the comment above it).
  MFC r253117:
  
  Do two things: First, don't obscure the backtitle. Second, read ~/.dialogrc
  if it exists to determine if use_shadow is true (ON) or false (OFF).
  
  The purpose of determining the value of use_shadow is to know how many lines
  to subtract from the maximum height value in assuring that the backtitle is
  not obscured.
  
  The detriment of obscuring the backtitle is that it provides information
  that is not easily obtained elsewhere. That is the command-line shortcut
  used to access the current menu. As you navigate from one dialog to the
  next, invariably transparently corssing module boundaries, the backtitle
  represents the command-line argument used to get there. Obscuring this
  information with a widget that is too-tall and/or too-wide would see that
  data go unnoticed (leaving few other ways to get that information in the
  same helpful context).
  
  So despite the fact that this change reduces the standard maximum height for
  all widgets, there is a trap-door to prevent this calculation. If you want
  to utilize the full screen height on the terminal (remember, this adjustment
  is not made for Xdialog(1)) you can set $NO_BACKTITLE to 1 (or any non-NULL
  value for that matter) and this calculation will be skipped. You will be
  able to draw a widget that partially obscures the backtitle if-necessary.

Modified:
  stable/9/usr.sbin/bsdconfig/share/dialog.subr

Modified: stable/9/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- stable/9/usr.sbin/bsdconfig/share/dialog.subr	Wed Jul 10 20:20:23 2013	(r253168)
+++ stable/9/usr.sbin/bsdconfig/share/dialog.subr	Wed Jul 10 20:22:31 2013	(r253169)
@@ -292,7 +292,31 @@ f_dialog_max_size()
 		__max_size=$( stty size 2> /dev/null ) # usually "24 80"
 		: ${__max_size:=$DEFAULT_TERMINAL_SIZE}
 	fi
-	[ "$__var_height" ] && setvar "$__var_height" "${__max_size%%[$IFS]*}"
+	if [ "$__var_height" ]; then
+		local __height="${__max_size%%[$IFS]*}"
+		#
+		# If we're not using Xdialog(1), we should assume that $DIALOG
+		# will render --backtitle behind the widget. In such a case, we
+		# should prevent a widget from obscuring the backtitle (unless
+		# $NO_BACKTITLE is set and non-NULL, allowing a trap-door).
+		#
+		if [ ! "$USE_XDIALOG" ] && [ ! "$NO_BACKTITLE" ]; then
+			#
+			# If use_shadow (in ~/.dialogrc) is OFF, we need to
+			# subtract 4, otherwise 5. However, don't check this
+			# every time, rely on an initialization variable set
+			# by f_dialog_init().
+			#
+			local __adjust=5
+			[ "$NO_SHADOW" ] && __adjust=4
+
+			# Don't adjust height if already too small (allowing
+			# obscured backtitle for small values of __height).
+			[ ${__height:-0} -gt 11 ] &&
+				__height=$(( $__height - $__adjust ))
+		fi
+		setvar "$__var_height" "$__height"
+	fi
 	[ "$__var_width" ] && setvar "$__var_width" "${__max_size##*[$IFS]}"
 }
 
@@ -1999,6 +2023,12 @@ f_dialog_menutag2index_with_help()
 # 	              that (while running as root) sudo(8) authentication is
 # 	              required to proceed.
 #
+# Also reads ~/.dialogrc for the following information:
+#
+# 	NO_SHADOW     Either NULL or Non-NULL. If use_shadow is OFF (case-
+# 	              insensitive) in ~/.dialogrc this is set to "1" (otherwise
+# 	              unset).
+#
 f_dialog_init()
 {
 	DIALOG_SELF_INITIALIZE=
@@ -2058,6 +2088,22 @@ f_dialog_init()
 	fi
 
 	#
+	# Read ~/.dialogrc (unless using Xdialog(1)) for properties
+	#
+	if [ -f ~/.dialogrc -a ! "$USE_XDIALOG" ]; then
+		eval "$(
+			awk -v param=use_shadow -v expect=OFF \
+			    -v set="NO_SHADOW=1" '
+			!/^[[:space:]]*(#|$)/ && \
+			tolower($1) ~ "^"param"(=|$)" && \
+			/[^#]*=/ {
+				sub(/^[^=]*=[[:space:]]*/, "")
+				if ( toupper($1) == expect ) print set";"
+			}' ~/.dialogrc
+		)"
+	fi
+
+	#
 	# If we're already running as root but we got there by way of sudo(8)
 	# and we have X11, we should merge the xauth(1) credentials from our
 	# original user.

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 20:56:04 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id C1080DB3;
 Wed, 10 Jul 2013 20:56:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id B2B871B6F;
 Wed, 10 Jul 2013 20:56:04 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AKu4ji081652;
 Wed, 10 Jul 2013 20:56:04 GMT (envelope-from pfg@svn.freebsd.org)
Received: (from pfg@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AKu4dP081651;
 Wed, 10 Jul 2013 20:56:04 GMT (envelope-from pfg@svn.freebsd.org)
Message-Id: <201307102056.r6AKu4dP081651@svn.freebsd.org>
From: "Pedro F. Giffuni" 
Date: Wed, 10 Jul 2013 20:56:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253170 - stable/9/sys/fs/ext2fs
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 20:56:04 -0000

Author: pfg
Date: Wed Jul 10 20:56:04 2013
New Revision: 253170
URL: http://svnweb.freebsd.org/changeset/base/253170

Log:
  MFC	r252956:
  
  Implement SEEK_HOLE/SEEK_DATA for ext2fs.

Modified:
  stable/9/sys/fs/ext2fs/ext2_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_vnops.c	Wed Jul 10 20:22:31 2013	(r253169)
+++ stable/9/sys/fs/ext2fs/ext2_vnops.c	Wed Jul 10 20:56:04 2013	(r253170)
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -94,6 +95,7 @@ static vop_close_t	ext2_close;
 static vop_create_t	ext2_create;
 static vop_fsync_t	ext2_fsync;
 static vop_getattr_t	ext2_getattr;
+static vop_ioctl_t	ext2_ioctl;
 static vop_link_t	ext2_link;
 static vop_mkdir_t	ext2_mkdir;
 static vop_mknod_t	ext2_mknod;
@@ -124,6 +126,7 @@ struct vop_vector ext2_vnodeops = {
 	.vop_fsync =		ext2_fsync,
 	.vop_getattr =		ext2_getattr,
 	.vop_inactive =		ext2_inactive,
+	.vop_ioctl =		ext2_ioctl,
 	.vop_link =		ext2_link,
 	.vop_lookup =		vfs_cache_lookup,
 	.vop_mkdir =		ext2_mkdir,
@@ -1433,6 +1436,9 @@ ext2_pathconf(struct vop_pathconf_args *
 	case _PC_NO_TRUNC:
 		*ap->a_retval = 1;
 		return (0);
+	case _PC_MIN_HOLE_SIZE:
+		*ap->a_retval = ap->a_vp->v_mount->mnt_stat.f_iosize;
+		return(0);
 	default:
 		return (EINVAL);
 	}
@@ -1707,6 +1713,20 @@ ext2_read(struct vop_read_args *ap)
 	return (error);
 }
 
+static int
+ext2_ioctl(struct vop_ioctl_args *ap)
+{
+
+	switch (ap->a_command) {
+	case FIOSEEKDATA:
+	case FIOSEEKHOLE:
+		return (vn_bmap_seekhole(ap->a_vp, ap->a_command,
+		    (off_t *)ap->a_data, ap->a_cred));
+	default:
+		return (ENOTTY);
+	}
+}
+
 /*
  * Vnode op for writing.
  */

From owner-svn-src-stable-9@FreeBSD.ORG  Wed Jul 10 21:05:03 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id E876FF0;
 Wed, 10 Jul 2013 21:05:03 +0000 (UTC) (envelope-from pfg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id C04E71BDB;
 Wed, 10 Jul 2013 21:05:03 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AL53IV084691;
 Wed, 10 Jul 2013 21:05:03 GMT (envelope-from pfg@svn.freebsd.org)
Received: (from pfg@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AL535O084689;
 Wed, 10 Jul 2013 21:05:03 GMT (envelope-from pfg@svn.freebsd.org)
Message-Id: <201307102105.r6AL535O084689@svn.freebsd.org>
From: "Pedro F. Giffuni" 
Date: Wed, 10 Jul 2013 21:05:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253171 - stable/9/usr.bin/sed
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 10 Jul 2013 21:05:04 -0000

Author: pfg
Date: Wed Jul 10 21:05:03 2013
New Revision: 253171
URL: http://svnweb.freebsd.org/changeset/base/253171

Log:
  MFC	r252231:
  
  sed: use getline() instead of fgetln().
  
  In BSD, fgetln() available in libc but in Illumos the Solaris port had to
  include it internally. It also seems to have caused problems [1].
  
  Aid portability by using getline() instead.

Modified:
  stable/9/usr.bin/sed/main.c
Directory Properties:
  stable/9/usr.bin/sed/   (props changed)

Modified: stable/9/usr.bin/sed/main.c
==============================================================================
--- stable/9/usr.bin/sed/main.c	Wed Jul 10 20:56:04 2013	(r253170)
+++ stable/9/usr.bin/sed/main.c	Wed Jul 10 21:05:03 2013	(r253171)
@@ -1,4 +1,5 @@
 /*-
+ * Copyright (c) 2013 Johann 'Myrkraverk' Oskarsson.
  * Copyright (c) 1992 Diomidis Spinellis.
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -57,6 +58,7 @@ static const char sccsid[] = "@(#)main.c
 #include 
 #include 
 #include 
+#define _WITH_GETLINE
 #include 
 #include 
 #include 
@@ -307,8 +309,9 @@ int
 mf_fgets(SPACE *sp, enum e_spflag spflag)
 {
 	struct stat sb;
-	size_t len;
-	char *p;
+	ssize_t len;
+	static char *p = NULL;
+	static size_t plen = 0;
 	int c;
 	static int firstfile;
 
@@ -424,13 +427,13 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
 	 * We are here only when infile is open and we still have something
 	 * to read from it.
 	 *
-	 * Use fgetln so that we can handle essentially infinite input data.
-	 * Can't use the pointer into the stdio buffer as the process space
-	 * because the ungetc() can cause it to move.
+	 * Use getline() so that we can handle essentially infinite input
+	 * data.  The p and plen are static so each invocation gives
+	 * getline() the same buffer which is expanded as needed.
 	 */
-	p = fgetln(infile, &len);
-	if (ferror(infile))
-		errx(1, "%s: %s", fname, strerror(errno ? errno : EIO));
+	len = getline(&p, &plen, infile);
+	if (len == -1)
+		err(1, "%s", fname);
 	if (len != 0 && p[len - 1] == '\n')
 		len--;
 	cspace(sp, p, len, spflag);

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 01:30:25 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 5A80AF8F;
 Thu, 11 Jul 2013 01:30:25 +0000 (UTC)
 (envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 3284A17E6;
 Thu, 11 Jul 2013 01:30:25 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B1UPYF063635;
 Thu, 11 Jul 2013 01:30:25 GMT
 (envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B1UP6h063634;
 Thu, 11 Jul 2013 01:30:25 GMT
 (envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201307110130.r6B1UP6h063634@svn.freebsd.org>
From: Rick Macklem 
Date: Thu, 11 Jul 2013 01:30:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253177 - stable/9/sys/nfsclient
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 01:30:25 -0000

Author: rmacklem
Date: Thu Jul 11 01:30:24 2013
New Revision: 253177
URL: http://svnweb.freebsd.org/changeset/base/253177

Log:
  MFC: r252673
  A problem with the old NFS client where large writes to large files
  would sometimes result in a corrupted file was reported via email.
  This problem appears to have been caused by r251719 (reverting
  r251719 fixed the problem). Although I have not been able to
  reproduce this problem, I suspect it is caused by another thread
  increasing np->n_size after the mtx_unlock(&np->n_mtx) but before
  the vnode_pager_setsize() call. Since the np->n_mtx mutex serializes
  updates to np->n_size, doing the vnode_pager_setsize() with the
  mutex locked appears to avoid the problem.
  Unfortunately, vnode_pager_setsize() where the new size is smaller,
  cannot be called with a mutex held.
  This patch returns the semantics to be close to pre-r251719 such that the
  call to the vnode_pager_setsize() is only delayed until after the mutex is
  unlocked when np->n_size is shrinking. Since the file is growing
  when being written, I believe this will fix the corruption.
  
  Tested by:	remy.nonnenmacher@activnetworks.com

Modified:
  stable/9/sys/nfsclient/nfs_subs.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/nfsclient/nfs_subs.c
==============================================================================
--- stable/9/sys/nfsclient/nfs_subs.c	Wed Jul 10 23:14:24 2013	(r253176)
+++ stable/9/sys/nfsclient/nfs_subs.c	Thu Jul 11 01:30:24 2013	(r253177)
@@ -595,6 +595,7 @@ nfs_loadattrcache(struct vnode **vpp, st
 				vap->va_size = np->n_size;
 				np->n_attrstamp = 0;
 				KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
+				vnode_pager_setsize(vp, np->n_size);
 			} else if (np->n_flag & NMODIFIED) {
 				/*
 				 * We've modified the file: Use the larger
@@ -606,12 +607,22 @@ nfs_loadattrcache(struct vnode **vpp, st
 					np->n_size = vap->va_size;
 					np->n_flag |= NSIZECHANGED;
 				}
+				vnode_pager_setsize(vp, np->n_size);
+			} else if (vap->va_size < np->n_size) {
+				/*
+				 * When shrinking the size, the call to
+				 * vnode_pager_setsize() cannot be done
+				 * with the mutex held, so delay it until
+				 * after the mtx_unlock call.
+				 */
+				nsize = np->n_size = vap->va_size;
+				np->n_flag |= NSIZECHANGED;
+				setnsize = 1;
 			} else {
 				np->n_size = vap->va_size;
 				np->n_flag |= NSIZECHANGED;
+				vnode_pager_setsize(vp, np->n_size);
 			}
-			setnsize = 1;
-			nsize = vap->va_size;
 		} else {
 			np->n_size = vap->va_size;
 		}

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 03:49:16 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 2C894924;
 Thu, 11 Jul 2013 03:49:16 +0000 (UTC)
 (envelope-from bryanv@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0D1391E47;
 Thu, 11 Jul 2013 03:49:16 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B3nFKT007356;
 Thu, 11 Jul 2013 03:49:15 GMT (envelope-from bryanv@svn.freebsd.org)
Received: (from bryanv@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B3nF3x007351;
 Thu, 11 Jul 2013 03:49:15 GMT (envelope-from bryanv@svn.freebsd.org)
Message-Id: <201307110349.r6B3nF3x007351@svn.freebsd.org>
From: Bryan Venteicher 
Date: Thu, 11 Jul 2013 03:49:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253180 - stable/9/share/man/man4
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 03:49:16 -0000

Author: bryanv
Date: Thu Jul 11 03:49:14 2013
New Revision: 253180
URL: http://svnweb.freebsd.org/changeset/base/253180

Log:
  MFC VirtIO r252703,r252707
  
  r252703: Document new cache write mode tunables/sysctl
  r252707: Minor cleanup and use my FreeBSD.org email
  
  Also change the release where first appeared closer to reality.

Modified:
  stable/9/share/man/man4/virtio.4
  stable/9/share/man/man4/virtio_balloon.4
  stable/9/share/man/man4/virtio_blk.4
  stable/9/share/man/man4/virtio_scsi.4
  stable/9/share/man/man4/vtnet.4
Directory Properties:
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/virtio.4
==============================================================================
--- stable/9/share/man/man4/virtio.4	Thu Jul 11 03:44:06 2013	(r253179)
+++ stable/9/share/man/man4/virtio.4	Thu Jul 11 03:49:14 2013	(r253180)
@@ -53,10 +53,10 @@ This emulation is often inefficient.
 .Pp
 VirtIO defines an interface for efficient I/O between the hypervisor and VM.
 The
-.Xr virtio 4
+.Nm
 module provides a shared memory transport called a virtqueue.
 The
-.Xr virtio_pci 4
+.Xr virtio_pci
 device driver represents an emulated PCI device that the hypervisor makes
 available to the VM.
 This device provides the probing, configuration, and 
@@ -89,9 +89,9 @@ device driver.
 .Xr vtnet 4
 .Sh HISTORY
 Support for VirtIO first appeared in
-.Fx 9.0 .
+.Fx 9.2 .
 .Sh AUTHORS
 .An -nosplit
 .Fx
 support for VirtIO was first added by
-.An Bryan Venteicher Aq bryanv@daemoninthecloset.org .
+.An Bryan Venteicher Aq bryanv@FreeBSD.org .

Modified: stable/9/share/man/man4/virtio_balloon.4
==============================================================================
--- stable/9/share/man/man4/virtio_balloon.4	Thu Jul 11 03:44:06 2013	(r253179)
+++ stable/9/share/man/man4/virtio_balloon.4	Thu Jul 11 03:49:14 2013	(r253180)
@@ -59,6 +59,6 @@ The hypervisor can later signal the ball
 The
 .Nm
 driver was written by
-.An Bryan Venteicher Aq bryanv@daemoninthecloset.org .
+.An Bryan Venteicher Aq bryanv@FreeBSD.org .
 It first appeared in
-.Fx 9.0 .
+.Fx 9.2 .

Modified: stable/9/share/man/man4/virtio_blk.4
==============================================================================
--- stable/9/share/man/man4/virtio_blk.4	Thu Jul 11 03:44:06 2013	(r253179)
+++ stable/9/share/man/man4/virtio_blk.4	Thu Jul 11 03:49:14 2013	(r253180)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 22, 2012
+.Dd July 2, 2013
 .Dt VIRTIO_BLK 4
 .Os
 .Sh NAME
@@ -53,11 +53,33 @@ Tunables can be set at the
 .Xr loader 8
 prompt before booting the kernel or stored in
 .Xr loader.conf 5 .
-.Bl -tag -width "xxxxxx"
+.Bl -tag -width indent
 .It Va hw.vtblk.no_ident
-This tunable disables retrieving the device identification string
-from the hypervisor.
+.It Va hw.vtblk. Ns Ar X Ns Va .no_ident
+.Pp
+These tunables disable retrieving the device identification string
+from the hypervisor either globally or per-device.
 The default value is 0.
+.It Va hw.vtblk.writecache_mode
+.It Va hw.vtblk. Ns Ar X Ns Va .writecache_mode
+.Pp
+These tunables determine the write cache mode globally or per-device.
+The mode can changed only if the ConfigWCE feature is negotiated.
+Set to 0 for writethrough mode, 1 for writeback mode, and -1 to leave
+it as-is.
+The default value is to leave as-is.
+.El
+.Sh SYSCTL VARIABLES
+The following variables are available as
+.Xr sysctl 8
+variables.
+.Bl -tag -width indent
+.It Va dev.vtblk. Ns Ar X Ns Va .writecache_mode
+.Pp
+The write cache mode of the device can be either writethrough (0) or
+writeback (1).
+If the ConfigWCE feature is negotiated, the write cache mode can
+be toggled between writethrough and writeback.
 .El
 .Sh SEE ALSO
 .Xr virtio 4
@@ -65,6 +87,6 @@ The default value is 0.
 The
 .Nm
 driver was written by
-.An Bryan Venteicher Aq bryanv@daemoninthecloset.org .
+.An Bryan Venteicher Aq bryanv@FreeBSD.org .
 It first appeared in
-.Fx 9.0 .
+.Fx 9.2 .

Modified: stable/9/share/man/man4/virtio_scsi.4
==============================================================================
--- stable/9/share/man/man4/virtio_scsi.4	Thu Jul 11 03:44:06 2013	(r253179)
+++ stable/9/share/man/man4/virtio_scsi.4	Thu Jul 11 03:49:14 2013	(r253180)
@@ -87,6 +87,6 @@ Enable tracing prints.
 The
 .Nm
 driver was written by
-.An Bryan Venteicher Aq bryanv@daemoninthecloset.org .
+.An Bryan Venteicher Aq bryanv@FreeBSD.org .
 It first appeared in
-.Fx 10.0 .
+.Fx 9.2 .

Modified: stable/9/share/man/man4/vtnet.4
==============================================================================
--- stable/9/share/man/man4/vtnet.4	Thu Jul 11 03:44:06 2013	(r253179)
+++ stable/9/share/man/man4/vtnet.4	Thu Jul 11 03:49:14 2013	(r253180)
@@ -89,9 +89,9 @@ The default value is 0.
 The
 .Nm
 driver was written by
-.An Bryan Venteicher Aq bryanv@daemoninthecloset.org .
+.An Bryan Venteicher Aq bryanv@FreeBSD.org .
 It first appeared in
-.Fx 9.0 .
+.Fx 9.2 .
 .Sh CAVEATS
 The
 .Nm

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 04:47:44 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 92EA8714;
 Thu, 11 Jul 2013 04:47:44 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 85E8F1FEB;
 Thu, 11 Jul 2013 04:47:44 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B4liJq024732;
 Thu, 11 Jul 2013 04:47:44 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B4liXR024731;
 Thu, 11 Jul 2013 04:47:44 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201307110447.r6B4liXR024731@svn.freebsd.org>
From: Konstantin Belousov 
Date: Thu, 11 Jul 2013 04:47:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253183 - stable/9/sys/fs/nullfs
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 04:47:44 -0000

Author: kib
Date: Thu Jul 11 04:47:44 2013
New Revision: 253183
URL: http://svnweb.freebsd.org/changeset/base/253183

Log:
  MFC r252714:
  The tvp vnode on rename is usually unlinked.  Drop the cached null
  vnode for tvp to allow the free of the lower vnode, if needed.
  
  PR:	kern/180236

Modified:
  stable/9/sys/fs/nullfs/null_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/nullfs/null_vnops.c
==============================================================================
--- stable/9/sys/fs/nullfs/null_vnops.c	Thu Jul 11 03:57:53 2013	(r253182)
+++ stable/9/sys/fs/nullfs/null_vnops.c	Thu Jul 11 04:47:44 2013	(r253183)
@@ -554,6 +554,7 @@ null_rename(struct vop_rename_args *ap)
 	struct vnode *fvp = ap->a_fvp;
 	struct vnode *fdvp = ap->a_fdvp;
 	struct vnode *tvp = ap->a_tvp;
+	struct null_node *tnn;
 
 	/* Check for cross-device rename. */
 	if ((fvp->v_mount != tdvp->v_mount) ||
@@ -568,7 +569,11 @@ null_rename(struct vop_rename_args *ap)
 		vrele(fvp);
 		return (EXDEV);
 	}
-	
+
+	if (tvp != NULL) {
+		tnn = VTONULL(tvp);
+		tnn->null_flags |= NULLV_DROP;
+	}
 	return (null_bypass((struct vop_generic_args *)ap));
 }
 

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 04:57:08 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id DC39A9EC;
 Thu, 11 Jul 2013 04:57:08 +0000 (UTC)
 (envelope-from alfred@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id CDDF9103B;
 Thu, 11 Jul 2013 04:57:08 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B4v8TQ027533;
 Thu, 11 Jul 2013 04:57:08 GMT (envelope-from alfred@svn.freebsd.org)
Received: (from alfred@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B4v8WZ027532;
 Thu, 11 Jul 2013 04:57:08 GMT (envelope-from alfred@svn.freebsd.org)
Message-Id: <201307110457.r6B4v8WZ027532@svn.freebsd.org>
From: Alfred Perlstein 
Date: Thu, 11 Jul 2013 04:57:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253184 - stable/9/sys/kern
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 04:57:08 -0000

Author: alfred
Date: Thu Jul 11 04:57:08 2013
New Revision: 253184
URL: http://svnweb.freebsd.org/changeset/base/253184

Log:
  Fix for lost software interrupts/cam lockup.
  
  MFC: 252683

Modified:
  stable/9/sys/kern/kern_intr.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_intr.c
==============================================================================
--- stable/9/sys/kern/kern_intr.c	Thu Jul 11 04:47:44 2013	(r253183)
+++ stable/9/sys/kern/kern_intr.c	Thu Jul 11 04:57:08 2013	(r253184)
@@ -841,7 +841,7 @@ ok:
 		 * again and remove this handler if it has already passed
 		 * it on the list.
 		 */
-		ie->ie_thread->it_need = 1;
+		atomic_store_rel_int(&ie->ie_thread->it_need, 1);
 	} else
 		TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
 	thread_unlock(ie->ie_thread->it_thread);
@@ -912,7 +912,7 @@ intr_event_schedule_thread(struct intr_e
 	 * running.  Then, lock the thread and see if we actually need to
 	 * put it on the runqueue.
 	 */
-	it->it_need = 1;
+	atomic_store_rel_int(&it->it_need, 1);
 	thread_lock(td);
 	if (TD_AWAITING_INTR(td)) {
 		CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -990,7 +990,7 @@ ok:
 		 * again and remove this handler if it has already passed
 		 * it on the list.
 		 */
-		it->it_need = 1;
+		atomic_store_rel_int(&it->it_need, 1);
 	} else
 		TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
 	thread_unlock(it->it_thread);
@@ -1066,7 +1066,7 @@ intr_event_schedule_thread(struct intr_e
 	 * running.  Then, lock the thread and see if we actually need to
 	 * put it on the runqueue.
 	 */
-	it->it_need = 1;
+	atomic_store_rel_int(&it->it_need, 1);
 	thread_lock(td);
 	if (TD_AWAITING_INTR(td)) {
 		CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
@@ -1256,7 +1256,7 @@ intr_event_execute_handlers(struct proc 
 		 * interrupt threads always invoke all of their handlers.
 		 */
 		if (ie->ie_flags & IE_SOFT) {
-			if (!ih->ih_need)
+			if (atomic_load_acq_int(&ih->ih_need) == 0)
 				continue;
 			else
 				atomic_store_rel_int(&ih->ih_need, 0);
@@ -1358,7 +1358,7 @@ ithread_loop(void *arg)
 		 * we are running, it will set it_need to note that we
 		 * should make another pass.
 		 */
-		while (ithd->it_need) {
+		while (atomic_load_acq_int(&ithd->it_need) != 0) {
 			/*
 			 * This might need a full read and write barrier
 			 * to make sure that this write posts before any
@@ -1377,7 +1377,8 @@ ithread_loop(void *arg)
 		 * set again, so we have to check it again.
 		 */
 		thread_lock(td);
-		if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
+		if ((atomic_load_acq_int(&ithd->it_need) == 0) &&
+		    !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
 			TD_SET_IWAIT(td);
 			ie->ie_count = 0;
 			mi_switch(SW_VOL | SWT_IWAIT, NULL);
@@ -1538,7 +1539,7 @@ ithread_loop(void *arg)
 		 * we are running, it will set it_need to note that we
 		 * should make another pass.
 		 */
-		while (ithd->it_need) {
+		while (atomic_load_acq_int(&ithd->it_need) != 0) {
 			/*
 			 * This might need a full read and write barrier
 			 * to make sure that this write posts before any
@@ -1560,7 +1561,8 @@ ithread_loop(void *arg)
 		 * set again, so we have to check it again.
 		 */
 		thread_lock(td);
-		if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
+		if ((atomic_load_acq_int(&ithd->it_need) == 0) &&
+		    !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
 			TD_SET_IWAIT(td);
 			ie->ie_count = 0;
 			mi_switch(SW_VOL | SWT_IWAIT, NULL);

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 06:48:54 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 131A9D57;
 Thu, 11 Jul 2013 06:48:54 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0446D15BA;
 Thu, 11 Jul 2013 06:48:54 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B6mrCN061112;
 Thu, 11 Jul 2013 06:48:53 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B6mrUX061111;
 Thu, 11 Jul 2013 06:48:53 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201307110648.r6B6mrUX061111@svn.freebsd.org>
From: Dimitry Andric 
Date: Thu, 11 Jul 2013 06:48:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253192 - stable/9/contrib/llvm/lib/CodeGen/SelectionDAG
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 06:48:54 -0000

Author: dim
Date: Thu Jul 11 06:48:53 2013
New Revision: 253192
URL: http://svnweb.freebsd.org/changeset/base/253192

Log:
  MFC r253042:
  
  Pull in r185616 from llvm trunk:
  
    FastISel can only append to basic blocks.
  
    Compute the insertion point from the end of the basic block instead of
    skipping labels from the front.
  
    This caused failures in landing pads when live-in copies where inserted
    before instruction selection.
  
  I missed this change in r252720; without it, certain compilation flags
  can cause exception labels to not be generated, but still referenced,
  leading to link errors.
  
  Reported by:	zeising

Modified:
  stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Directory Properties:
  stable/9/contrib/llvm/   (props changed)

Modified: stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
==============================================================================
--- stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp	Thu Jul 11 05:58:28 2013	(r253191)
+++ stable/9/contrib/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp	Thu Jul 11 06:48:53 2013	(r253192)
@@ -75,15 +75,12 @@ STATISTIC(NumFastIselDead, "Number of de
 void FastISel::startNewBlock() {
   LocalValueMap.clear();
 
+  // Instructions are appended to FuncInfo.MBB. If the basic block already
+  // contains labels or copies, use the last instruction as the last local
+  // value.
   EmitStartPt = 0;
-
-  // Advance the emit start point past any EH_LABEL instructions.
-  MachineBasicBlock::iterator
-    I = FuncInfo.MBB->begin(), E = FuncInfo.MBB->end();
-  while (I != E && I->getOpcode() == TargetOpcode::EH_LABEL) {
-    EmitStartPt = I;
-    ++I;
-  }
+  if (!FuncInfo.MBB->empty())
+    EmitStartPt = &FuncInfo.MBB->back();
   LastLocalValue = EmitStartPt;
 }
 

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 07:14:52 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 1C735A28;
 Thu, 11 Jul 2013 07:14:52 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0E9F01705;
 Thu, 11 Jul 2013 07:14:52 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B7EpW6069623;
 Thu, 11 Jul 2013 07:14:51 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B7EpBu069621;
 Thu, 11 Jul 2013 07:14:51 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307110714.r6B7EpBu069621@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 11 Jul 2013 07:14:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253193 - stable/9/sys/dev/sound/pci/hda
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 07:14:52 -0000

Author: mav
Date: Thu Jul 11 07:14:51 2013
New Revision: 253193
URL: http://svnweb.freebsd.org/changeset/base/253193

Log:
  MFC r253036:
  Add quirk to configure headphones redirection on ASUS UX31A laptop.

Modified:
  stable/9/sys/dev/sound/pci/hda/hdaa_patches.c
  stable/9/sys/dev/sound/pci/hda/hdac.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/sound/pci/hda/hdaa_patches.c
==============================================================================
--- stable/9/sys/dev/sound/pci/hda/hdaa_patches.c	Thu Jul 11 06:48:53 2013	(r253192)
+++ stable/9/sys/dev/sound/pci/hda/hdaa_patches.c	Thu Jul 11 07:14:51 2013	(r253193)
@@ -363,6 +363,13 @@ hdac_pin_patch(struct hdaa_widget *w)
 			patch = "as=1 seq=15";
 			break;
 		}
+	} else if (id == HDA_CODEC_ALC269 &&
+	    subid == ASUS_UX31A_SUBVENDOR) {
+		switch (nid) {
+		case 33:
+			patch = "as=1 seq=15";
+			break;
+		}
 	}
 
 	if (patch != NULL)

Modified: stable/9/sys/dev/sound/pci/hda/hdac.h
==============================================================================
--- stable/9/sys/dev/sound/pci/hda/hdac.h	Thu Jul 11 06:48:53 2013	(r253192)
+++ stable/9/sys/dev/sound/pci/hda/hdac.h	Thu Jul 11 07:14:51 2013	(r253193)
@@ -198,6 +198,7 @@
 #define ASUS_F3JC_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1338)
 #define ASUS_G2K_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1339)
 #define ASUS_A7T_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x13c2)
+#define ASUS_UX31A_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1517)
 #define ASUS_W2J_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1971)
 #define ASUS_M5200_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1993)
 #define ASUS_P5PL2_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x817f)

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 07:17:04 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 94F43B82;
 Thu, 11 Jul 2013 07:17:04 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 87628171D;
 Thu, 11 Jul 2013 07:17:04 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B7H4l1069981;
 Thu, 11 Jul 2013 07:17:04 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B7H45d069979;
 Thu, 11 Jul 2013 07:17:04 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307110717.r6B7H45d069979@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 11 Jul 2013 07:17:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253194 - stable/9/sys/dev/ahci
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 07:17:04 -0000

Author: mav
Date: Thu Jul 11 07:17:03 2013
New Revision: 253194
URL: http://svnweb.freebsd.org/changeset/base/253194

Log:
  MFC r253069, r253074:
  Add one more ID of Marvell SATA controller.
  Add ID for Marvell 88SE9215 AHCI SATA controller.

Modified:
  stable/9/sys/dev/ahci/ahci.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/ahci/ahci.c
==============================================================================
--- stable/9/sys/dev/ahci/ahci.c	Thu Jul 11 07:14:51 2013	(r253193)
+++ stable/9/sys/dev/ahci/ahci.c	Thu Jul 11 07:17:03 2013	(r253194)
@@ -234,6 +234,8 @@ static struct {
 	{0x91301b4b, 0x00, "Marvell 88SE9130",  AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG},
 	{0x91721b4b, 0x00, "Marvell 88SE9172",	AHCI_Q_NOBSYRES},
 	{0x91821b4b, 0x00, "Marvell 88SE9182",	AHCI_Q_NOBSYRES},
+	{0x91a01b4b, 0x00, "Marvell 88SE91Ax",	AHCI_Q_NOBSYRES},
+	{0x92151b4b, 0x00, "Marvell 88SE9215",  AHCI_Q_NOBSYRES},
 	{0x92201b4b, 0x00, "Marvell 88SE9220",  AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG},
 	{0x92301b4b, 0x00, "Marvell 88SE9230",  AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG},
 	{0x92351b4b, 0x00, "Marvell 88SE9235",  AHCI_Q_NOBSYRES},

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 08:18:01 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id DF3DDDA9;
 Thu, 11 Jul 2013 08:18:01 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id D00351A14;
 Thu, 11 Jul 2013 08:18:01 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B8I1Gx087769;
 Thu, 11 Jul 2013 08:18:01 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B8I1a4087767;
 Thu, 11 Jul 2013 08:18:01 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307110818.r6B8I1a4087767@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Thu, 11 Jul 2013 08:18:01 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253195 - stable/9/sys/dev/bge
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 08:18:02 -0000

Author: yongari
Date: Thu Jul 11 08:18:00 2013
New Revision: 253195
URL: http://svnweb.freebsd.org/changeset/base/253195

Log:
  MFC r245870:
    bge_attach() can fail before attaching mii(4). So make sure to check
    bge_miibus before detaching mii(4).

Modified:
  stable/9/sys/dev/bge/if_bge.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/bge/if_bge.c
==============================================================================
--- stable/9/sys/dev/bge/if_bge.c	Thu Jul 11 07:17:03 2013	(r253194)
+++ stable/9/sys/dev/bge/if_bge.c	Thu Jul 11 08:18:00 2013	(r253195)
@@ -3911,9 +3911,9 @@ bge_detach(device_t dev)
 	if (sc->bge_tq)
 		taskqueue_drain(sc->bge_tq, &sc->bge_intr_task);
 
-	if (sc->bge_flags & BGE_FLAG_TBI) {
+	if (sc->bge_flags & BGE_FLAG_TBI)
 		ifmedia_removeall(&sc->bge_ifmedia);
-	} else {
+	else if (sc->bge_miibus != NULL) {
 		bus_generic_detach(dev);
 		device_delete_child(dev, sc->bge_miibus);
 	}

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 08:41:46 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 5E12F7DF;
 Thu, 11 Jul 2013 08:41:46 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 4EBC21B18;
 Thu, 11 Jul 2013 08:41:46 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B8fkfA096553;
 Thu, 11 Jul 2013 08:41:46 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B8fkCs096552;
 Thu, 11 Jul 2013 08:41:46 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307110841.r6B8fkCs096552@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Thu, 11 Jul 2013 08:41:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253197 - stable/9/sys/dev/bge
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 08:41:46 -0000

Author: yongari
Date: Thu Jul 11 08:41:45 2013
New Revision: 253197
URL: http://svnweb.freebsd.org/changeset/base/253197

Log:
  MFC r245867:
    For 57765 class controllers, set low watermark max receive frames to 1.

Modified:
  stable/9/sys/dev/bge/if_bge.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/bge/if_bge.c
==============================================================================
--- stable/9/sys/dev/bge/if_bge.c	Thu Jul 11 08:18:46 2013	(r253196)
+++ stable/9/sys/dev/bge/if_bge.c	Thu Jul 11 08:41:45 2013	(r253197)
@@ -5453,7 +5453,7 @@ bge_init_locked(struct bge_softc *sc)
 	 * this number of frames, it will drop subsequent incoming
 	 * frames until the MBUF High Watermark is reached.
 	 */
-	if (sc->bge_asicrev == BGE_ASICREV_BCM57765)
+	if (BGE_IS_57765_PLUS(sc))
 		CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 1);
 	else
 		CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2);

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 09:10:18 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 70C05268;
 Thu, 11 Jul 2013 09:10:18 +0000 (UTC) (envelope-from smh@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 62F4C1C9C;
 Thu, 11 Jul 2013 09:10:18 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B9AIZJ003895;
 Thu, 11 Jul 2013 09:10:18 GMT (envelope-from smh@svn.freebsd.org)
Received: (from smh@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B9AIXV003892;
 Thu, 11 Jul 2013 09:10:18 GMT (envelope-from smh@svn.freebsd.org)
Message-Id: <201307110910.r6B9AIXV003892@svn.freebsd.org>
From: Steven Hartland 
Date: Thu, 11 Jul 2013 09:10:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253200 - in stable/9/sys/cam: ata scsi
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 09:10:18 -0000

Author: smh
Date: Thu Jul 11 09:10:17 2013
New Revision: 253200
URL: http://svnweb.freebsd.org/changeset/base/253200

Log:
  MFC r253091:
  Added 4K QUIRK for OCZ Vertex 4 SSDs

Modified:
  stable/9/sys/cam/ata/ata_da.c
  stable/9/sys/cam/scsi/scsi_da.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/ata/ata_da.c
==============================================================================
--- stable/9/sys/cam/ata/ata_da.c	Thu Jul 11 08:50:30 2013	(r253199)
+++ stable/9/sys/cam/ata/ata_da.c	Thu Jul 11 09:10:17 2013	(r253200)
@@ -398,6 +398,14 @@ static struct ada_quirk_entry ada_quirk_
 	},
 	{
 		/*
+		 * OCZ Vertex 4 SSDs
+		 * 4k optimised & trim only works in 4k requests + 4k aligned
+		 */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-VERTEX4*", "*" },
+		/*quirks*/ADA_Q_4K
+	},
+	{
+		/*
 		 * Samsung 830 Series SSDs
 		 * 4k optimised
 		 */

Modified: stable/9/sys/cam/scsi/scsi_da.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_da.c	Thu Jul 11 08:50:30 2013	(r253199)
+++ stable/9/sys/cam/scsi/scsi_da.c	Thu Jul 11 09:10:17 2013	(r253200)
@@ -1032,6 +1032,14 @@ static struct da_quirk_entry da_quirk_ta
 	},
 	{
 		/*
+		 * OCZ Vertex 4 SSDs
+		 * 4k optimised & trim only works in 4k requests + 4k aligned
+		 */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-VERTEX4*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/*
 		 * Samsung 830 Series SSDs
 		 * 4k optimised & trim only works in 4k requests + 4k aligned
 		 */

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 09:27:57 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 808BD87B;
 Thu, 11 Jul 2013 09:27:57 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 588D21D85;
 Thu, 11 Jul 2013 09:27:57 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B9RvuW009550;
 Thu, 11 Jul 2013 09:27:57 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6B9Ru7B009547;
 Thu, 11 Jul 2013 09:27:56 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201307110927.r6B9Ru7B009547@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 11 Jul 2013 09:27:56 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253202 - in stable/9/etc: defaults periodic/daily
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 09:27:57 -0000

Author: mav
Date: Thu Jul 11 09:27:56 2013
New Revision: 253202
URL: http://svnweb.freebsd.org/changeset/base/253202

Log:
  Partially MFC r249095:
  Add period script for graid(8) monitoring.

Added:
  stable/9/etc/periodic/daily/401.status-graid
     - copied unchanged from r249095, head/etc/periodic/daily/401.status-graid
Modified:
  stable/9/etc/defaults/periodic.conf
  stable/9/etc/periodic/daily/Makefile
Directory Properties:
  stable/9/etc/   (props changed)

Modified: stable/9/etc/defaults/periodic.conf
==============================================================================
--- stable/9/etc/defaults/periodic.conf	Thu Jul 11 09:13:05 2013	(r253201)
+++ stable/9/etc/defaults/periodic.conf	Thu Jul 11 09:27:56 2013	(r253202)
@@ -94,6 +94,9 @@ daily_news_expire_enable="YES"				# Run 
 daily_status_disks_enable="YES"				# Check disk status
 daily_status_disks_df_flags="-l -h"		# df(1) flags for check
 
+# 401.status-graid
+daily_status_graid_enable="NO"				# Check graid(8)
+
 # 404.status-zfs
 daily_status_zfs_enable="NO"				# Check ZFS
 daily_status_zfs_zpool_list_enable="YES"		# List ZFS pools

Copied: stable/9/etc/periodic/daily/401.status-graid (from r249095, head/etc/periodic/daily/401.status-graid)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/etc/periodic/daily/401.status-graid	Thu Jul 11 09:27:56 2013	(r253202, copy of r249095, head/etc/periodic/daily/401.status-graid)
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# If there is a global system configuration file, suck it in.
+#
+if [ -r /etc/defaults/periodic.conf ]
+then
+    . /etc/defaults/periodic.conf
+    source_periodic_confs
+fi
+
+case "$daily_status_graid_enable" in
+    [Yy][Ee][Ss])
+	echo
+	echo 'Checking status of graid(8) devices:'
+
+	if graid status; then
+		components="$(graid status -s | fgrep -v OPTIMAL)"
+		if [ "${components}" ]; then
+			rc=3
+		else
+			rc=0
+		fi
+	else
+		rc=2
+	fi
+	;;
+
+    *)  rc=0;;
+esac
+
+exit $rc

Modified: stable/9/etc/periodic/daily/Makefile
==============================================================================
--- stable/9/etc/periodic/daily/Makefile	Thu Jul 11 09:13:05 2013	(r253201)
+++ stable/9/etc/periodic/daily/Makefile	Thu Jul 11 09:27:56 2013	(r253202)
@@ -10,6 +10,7 @@ FILES=	100.clean-disks \
 	220.backup-pkgdb \
 	330.news \
 	400.status-disks \
+	401.status-graid \
 	405.status-ata-raid \
 	406.status-gmirror \
 	407.status-graid3 \

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 12:42:46 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id D9ECFC84;
 Thu, 11 Jul 2013 12:42:46 +0000 (UTC) (envelope-from avg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id CC54A1A7A;
 Thu, 11 Jul 2013 12:42:46 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BCgkoA067426;
 Thu, 11 Jul 2013 12:42:46 GMT (envelope-from avg@svn.freebsd.org)
Received: (from avg@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BCgkxs067425;
 Thu, 11 Jul 2013 12:42:46 GMT (envelope-from avg@svn.freebsd.org)
Message-Id: <201307111242.r6BCgkxs067425@svn.freebsd.org>
From: Andriy Gapon 
Date: Thu, 11 Jul 2013 12:42:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253203 - stable/9/sys/kern
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 12:42:46 -0000

Author: avg
Date: Thu Jul 11 12:42:46 2013
New Revision: 253203
URL: http://svnweb.freebsd.org/changeset/base/253203

Log:
  MFC r253077: should_yield: protect from td_swvoltick being uninitialized
  or too stale

Modified:
  stable/9/sys/kern/kern_synch.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_synch.c
==============================================================================
--- stable/9/sys/kern/kern_synch.c	Thu Jul 11 09:27:56 2013	(r253202)
+++ stable/9/sys/kern/kern_synch.c	Thu Jul 11 12:42:46 2013	(r253203)
@@ -578,7 +578,7 @@ int
 should_yield(void)
 {
 
-	return (ticks - curthread->td_swvoltick >= hogticks);
+	return ((unsigned int)(ticks - curthread->td_swvoltick) >= hogticks);
 }
 
 void

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 12:47:07 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 461C1F51;
 Thu, 11 Jul 2013 12:47:07 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 37E271AB6;
 Thu, 11 Jul 2013 12:47:07 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BCl7Ge068116;
 Thu, 11 Jul 2013 12:47:07 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BCl6gq068114;
 Thu, 11 Jul 2013 12:47:06 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307111247.r6BCl6gq068114@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Thu, 11 Jul 2013 12:47:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253205 - stable/9/usr.bin/newgrp
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 12:47:07 -0000

Author: des
Date: Thu Jul 11 12:47:06 2013
New Revision: 253205
URL: http://svnweb.freebsd.org/changeset/base/253205

Log:
  MFH (r246553): document and explain need for setuid bit.
  
  PR:		docs/167741

Modified:
  stable/9/usr.bin/newgrp/newgrp.1
  stable/9/usr.bin/newgrp/newgrp.c
Directory Properties:
  stable/9/usr.bin/newgrp/   (props changed)

Modified: stable/9/usr.bin/newgrp/newgrp.1
==============================================================================
--- stable/9/usr.bin/newgrp/newgrp.1	Thu Jul 11 12:46:35 2013	(r253204)
+++ stable/9/usr.bin/newgrp/newgrp.1	Thu Jul 11 12:47:06 2013	(r253205)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 23, 2002
+.Dd February 8, 2013
 .Dt NEWGRP 1
 .Os
 .Sh NAME
@@ -90,6 +90,15 @@ A
 utility appeared in
 .At v6 .
 .Sh BUGS
+For security reasons, the
+.Nm
+utility is normally installed without the setuid bit.
+To enable it, run the following command:
+.Bd -literal -offset indent
+chmod u+s /usr/bin/newgrp
+.Ed
+.Pp
 Group passwords are inherently insecure as there is no way to stop
-users obtaining the crypted passwords from the group database.
+users obtaining the password hash from the group database.
 Their use is discouraged.
+Instead, users should simply be added to the necessary groups.

Modified: stable/9/usr.bin/newgrp/newgrp.c
==============================================================================
--- stable/9/usr.bin/newgrp/newgrp.c	Thu Jul 11 12:46:35 2013	(r253204)
+++ stable/9/usr.bin/newgrp/newgrp.c	Thu Jul 11 12:47:06 2013	(r253205)
@@ -73,7 +73,8 @@ main(int argc, char *argv[])
 {
 	int ch, login;
 
-	euid = geteuid();
+	if ((euid = geteuid()) != 0)
+		warnx("need root permissions to function properly, check setuid bit");
 	if (seteuid(getuid()) < 0)
 		err(1, "seteuid");
 

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 12:49:13 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 7A46430B;
 Thu, 11 Jul 2013 12:49:13 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 668591B05;
 Thu, 11 Jul 2013 12:49:13 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BCnDKY068414;
 Thu, 11 Jul 2013 12:49:13 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BCnDuc068413;
 Thu, 11 Jul 2013 12:49:13 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307111249.r6BCnDuc068413@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Thu, 11 Jul 2013 12:49:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253206 - stable/9/share/man/man5
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 12:49:13 -0000

Author: des
Date: Thu Jul 11 12:49:12 2013
New Revision: 253206
URL: http://svnweb.freebsd.org/changeset/base/253206

Log:
  MFH (r246552): mention newgrp(1) and how to change the group password.
  
  PR:		docs/167741

Modified:
  stable/9/share/man/man5/group.5
Directory Properties:
  stable/9/share/man/man5/   (props changed)

Modified: stable/9/share/man/man5/group.5
==============================================================================
--- stable/9/share/man/man5/group.5	Thu Jul 11 12:47:06 2013	(r253205)
+++ stable/9/share/man/man5/group.5	Thu Jul 11 12:49:12 2013	(r253206)
@@ -32,7 +32,7 @@
 .\"     From: @(#)group.5	8.3 (Berkeley) 4/19/94
 .\" $FreeBSD$
 .\"
-.Dd September 29, 1994
+.Dd February 8, 2013
 .Dt GROUP 5
 .Os
 .Sh NAME
@@ -139,6 +139,7 @@ may still have this limit.
 .It Pa /etc/group
 .El
 .Sh SEE ALSO
+.Xr newgrp 1 ,
 .Xr passwd 1 ,
 .Xr setgroups 2 ,
 .Xr crypt 3 ,
@@ -156,9 +157,14 @@ file format appeared in
 .At v6 .
 Support for comments first appeared in
 .Fx 3.0 .
-.Sh BUGS
+.Sh IMPLEMENTATION NOTES
 The
 .Xr passwd 1
 command does not change the
 .Nm
 passwords.
+The
+.Xr pw 8
+utility's
+.Cm groupmod
+command should be used instead.

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 15:45:52 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 597078FD;
 Thu, 11 Jul 2013 15:45:52 +0000 (UTC)
 (envelope-from wblock@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 48C1B1685;
 Thu, 11 Jul 2013 15:45:52 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BFjqdd022502;
 Thu, 11 Jul 2013 15:45:52 GMT (envelope-from wblock@svn.freebsd.org)
Received: (from wblock@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BFjpWO022498;
 Thu, 11 Jul 2013 15:45:51 GMT (envelope-from wblock@svn.freebsd.org)
Message-Id: <201307111545.r6BFjpWO022498@svn.freebsd.org>
From: Warren Block 
Date: Thu, 11 Jul 2013 15:45:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253211 - in stable/9: sbin/geom/class/part sbin/reboot
 sys/boot/i386/gptboot
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 15:45:52 -0000

Author: wblock (doc committer)
Date: Thu Jul 11 15:45:51 2013
New Revision: 253211
URL: http://svnweb.freebsd.org/changeset/base/253211

Log:
  MFC r245910,r247370,r249371,r252492,r252586:
  
  r252586:
  
  Add descriptions to the FILES list, fix some mdoc complaints, move the
  "neither" entry out of the table in BOOTING.
  
  r252492:
  
  Add a new gptboot(8) man page.  Factor out the redundant information
  in gpart(8) and boot(8), adding references to gptboot(8) in both.
  
  r249371:
  
  Remove kernel options from the SYNOPSIS. They are already documented in the
  geom(4) manual page SYNOPSIS.
  
  r247370:
  
  Fix typo in EFI GPT GUID.
  
  r245910:
  
  Expand description of how gptboot and gptzfsboot choose a partition for
  booting.

Added:
  stable/9/sys/boot/i386/gptboot/gptboot.8
     - copied, changed from r252492, head/sys/boot/i386/gptboot/gptboot.8
Modified:
  stable/9/sbin/geom/class/part/gpart.8
  stable/9/sbin/reboot/boot_i386.8
  stable/9/sys/boot/i386/gptboot/Makefile
Directory Properties:
  stable/9/sbin/geom/class/part/   (props changed)
  stable/9/sbin/reboot/   (props changed)
  stable/9/sys/boot/i386/gptboot/   (props changed)

Modified: stable/9/sbin/geom/class/part/gpart.8
==============================================================================
--- stable/9/sbin/geom/class/part/gpart.8	Thu Jul 11 15:29:25 2013	(r253210)
+++ stable/9/sbin/geom/class/part/gpart.8	Thu Jul 11 15:45:51 2013	(r253211)
@@ -24,40 +24,13 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 3, 2013
+.Dd July 1, 2013
 .Dt GPART 8
 .Os
 .Sh NAME
 .Nm gpart
 .Nd "control utility for the disk partitioning GEOM class"
 .Sh SYNOPSIS
-To add support for the disk partitioning GEOM class,
-place one or more of the following
-lines in the kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "options GEOM_PART_APM"
-.Cd "options GEOM_PART_BSD"
-.Cd "options GEOM_PART_GPT"
-.Cd "options GEOM_PART_LDM"
-.Cd "options GEOM_PART_MBR"
-.Cd "options GEOM_PART_EBR"
-.Cd "options GEOM_PART_EBR_COMPAT"
-.Cd "options GEOM_PART_PC98"
-.Cd "options GEOM_PART_VTOC8"
-.Ed
-.Pp
-These options provide support for the various types of partitioning
-schemes supported by the
-.Ns Nm
-utility.
-See
-.Sx "PARTITIONING SCHEMES"
-below for more details.
-.Pp
-Usage of the
-.Ns Nm
-utility:
-.Pp
 .\" ==== ADD ====
 .Nm
 .Cm add
@@ -583,7 +556,7 @@ The system partition for computers that 
 Interface (EFI).
 In such cases, the GPT partitioning scheme is used and the
 actual partition type for the system partition can also be specified as
-.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
+.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b" .
 .It Cm freebsd
 A
 .Fx
@@ -672,14 +645,12 @@ The scheme-specific attributes for GPT:
 When set, the
 .Nm gptboot
 stage 1 boot loader will try to boot the system from this partition.
-Multiple partitions might be marked with the
+Multiple partitions can be marked with the
 .Cm bootme
 attribute.
-In such scenario the
-.Nm gptboot
-will try all
-.Cm bootme
-partitions one by one, until the next boot stage is successfully entered.
+See
+.Xr gptboot 8
+for more details.
 .It Cm bootonce
 Setting this attribute automatically sets the
 .Cm bootme
@@ -687,49 +658,14 @@ attribute.
 When set, the
 .Nm gptboot
 stage 1 boot loader will try to boot the system from this partition only once.
-Partitions with both
-.Cm bootonce
-and
-.Cm bootme
-attributes are tried before partitions with only the
-.Cm bootme
-attribute.
-Before
-.Cm bootonce
-partition is tried, the
-.Nm gptboot
-removes the
-.Cm bootme
-attribute and tries to execute the next boot stage.
-If it fails, the
-.Cm bootonce
-attribute that is now alone is replaced with the
-.Cm bootfailed
-attribute.
-If the execution of the next boot stage succeeds, but the system is not fully
-booted, the
-.Nm gptboot
-will look for
-.Cm bootonce
-attributes alone (without the
-.Cm bootme
-attribute) on the next system boot and will replace those with the
-.Cm bootfailed
-attribute.
-If the system is fully booted, the
-.Pa /etc/rc.d/gptboot
-start-up script will look for partition with the
-.Cm bootonce
-attribute alone, will remove the attribute and log that the system was
-successfully booted from this partition.
-There should be at most one
-.Cm bootonce
-partition when system is successfully booted.
-Multiple partitions might be marked with the
+Multiple partitions can be marked with the
 .Cm bootonce
 and
 .Cm bootme
 attribute pairs.
+See
+.Xr gptboot 8
+for more details.
 .It Cm bootfailed
 This attribute should not be manually managed.
 It is managed by the
@@ -737,14 +673,9 @@ It is managed by the
 stage 1 boot loader and the
 .Pa /etc/rc.d/gptboot
 start-up script.
-This attribute is used to mark partitions that had the
-.Cm bootonce
-attribute set, but we failed to boot from them.
-Once we successfully boot, the
-.Pa /etc/rc.d/gptboot
-script will log all the partitions we failed to boot from and will remove the
-.Cm bootfailed
-attributes.
+See
+.Xr gptboot 8
+for more details.
 .El
 .Pp
 The scheme-specific attributes for MBR:
@@ -807,34 +738,52 @@ Both types of bootstrap code are used to
 First, a protective MBR is embedded into the first disk sector from the
 .Pa /boot/pmbr
 image.
-It searches the GPT
+It searches through the GPT for a
 .Cm freebsd-boot
 partition (see the
 .Sx "PARTITION TYPES"
-section) in the GPT and runs the next bootstrap stage from it.
+section) and runs the next bootstrap stage from it.
 The
 .Cm freebsd-boot
 partition should be smaller than 545 KB.
+It can be located either before or after other
+.Fx
+partitions on the disk.
 There are two variants of bootstrap code to write to this partition:
 .Pa /boot/gptboot
 and
 .Pa /boot/gptzfsboot .
+.Pp
+.Pa /boot/gptboot
+is used to boot from UFS partitions.
+.Cm gptboot
+searches through
+.Cm freebsd-ufs
+partitions in the GPT and selects one to boot based on the
+.Cm bootonce
+and
+.Cm bootme
+attributes.
+If neither attribute is found,
 .Pa /boot/gptboot
-is used to boot from UFS.
-It searches
+boots from the first
 .Cm freebsd-ufs
-GPT partitions and starts
+partition.
 .Pa /boot/loader
 .Pq the third bootstrap stage
-if found.
-The
+is loaded from the first partition that matches these conditions.
+See
+.Xr gptboot 8
+for more information.
+.Pp
 .Pa /boot/gptzfsboot
 is used to boot from ZFS.
-It searches
+It searches through the GPT for
 .Cm freebsd-zfs
-GPT partitions and starts
+partitions, trying to detect ZFS pools.
+After all pools are detected,
 .Pa /boot/zfsloader
-if found.
+is started from the first one found.
 .Pp
 The VTOC8 scheme does not support embedding bootstrap code.
 Instead, the 8 KBytes bootstrap code image
@@ -945,7 +894,7 @@ The GEOM PART class can detect the same 
 different GEOM providers, and some of them will be marked as corrupt.
 Be careful when choosing a provider for recovery.
 If you choose incorrectly you can destroy the metadata of another GEOM class,
-e.g.\& GEOM MIRROR or GEOM LABEL.
+e.g.,\& GEOM MIRROR or GEOM LABEL.
 .Sh SYSCTL VARIABLES
 The following
 .Xr sysctl 8
@@ -1115,7 +1064,8 @@ and
 .Xr dd 1 ,
 .Xr geom 4 ,
 .Xr boot0cfg 8 ,
-.Xr geom 8
+.Xr geom 8 ,
+.Xr gptboot 8
 .Sh HISTORY
 The
 .Nm

Modified: stable/9/sbin/reboot/boot_i386.8
==============================================================================
--- stable/9/sbin/reboot/boot_i386.8	Thu Jul 11 15:29:25 2013	(r253210)
+++ stable/9/sbin/reboot/boot_i386.8	Thu Jul 11 15:45:51 2013	(r253211)
@@ -36,7 +36,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 4, 2010
+.Dd July 1, 2013
 .Dt BOOT 8 i386
 .Os
 .Sh NAME
@@ -352,6 +352,7 @@ requirement has not been adhered to.
 .Xr bsdlabel 8 ,
 .Xr btxld 8 ,
 .Xr config 8 ,
+.Xr gptboot 8 ,
 .Xr halt 8 ,
 .Xr loader 8 ,
 .Xr nextboot 8 ,

Modified: stable/9/sys/boot/i386/gptboot/Makefile
==============================================================================
--- stable/9/sys/boot/i386/gptboot/Makefile	Thu Jul 11 15:29:25 2013	(r253210)
+++ stable/9/sys/boot/i386/gptboot/Makefile	Thu Jul 11 15:45:51 2013	(r253211)
@@ -3,6 +3,7 @@
 .PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
 
 FILES=		gptboot
+MAN=		gptboot.8
 
 NM?=		nm
 

Copied and modified: stable/9/sys/boot/i386/gptboot/gptboot.8 (from r252492, head/sys/boot/i386/gptboot/gptboot.8)
==============================================================================
--- head/sys/boot/i386/gptboot/gptboot.8	Mon Jul  1 22:38:36 2013	(r252492, copy source)
+++ stable/9/sys/boot/i386/gptboot/gptboot.8	Thu Jul 11 15:45:51 2013	(r253211)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 1, 2013
+.Dd July 3, 2013
 .Dt GPTBOOT 8
 .Os
 .Sh NAME
@@ -147,7 +147,8 @@ Middle priority: booting is attempted fr
 partitions with the
 .Cm bootme
 attribute.
-.It neither
+.El
+.Pp
 If neither
 .Cm bootonce
 nor
@@ -156,7 +157,6 @@ attributes are found on any partitions, 
 first
 .Cm freebsd-ufs
 partition on the disk.
-.El
 .Sh POST-BOOT ACTIONS
 The startup script
 .Pa /etc/rc.d/gptboot
@@ -181,9 +181,12 @@ The
 attribute is cleared from the partition that successfully booted.
 There is normally only one of these.
 .Sh FILES
-.Bl -tag -width /boot/loader -compact
+.Bl -tag -width /boot/gptboot -compact
 .It Pa /boot/gptboot
+bootcode binary
 .It Pa /boot.config
+parameters for the boot blocks
+.Pq optional
 .El
 .Sh EXAMPLES
 .Nm
@@ -223,7 +226,6 @@ attribute:
 .Bd -literal -offset indent
 gpart set -a bootonce -i 2 ada0
 .Ed
-.Pp
 .Sh SEE ALSO
 .Xr boot.config 5 ,
 .Xr rc.conf 5 ,

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 15:53:20 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 82826E73;
 Thu, 11 Jul 2013 15:53:20 +0000 (UTC)
 (envelope-from wblock@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 5AD7016F6;
 Thu, 11 Jul 2013 15:53:20 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BFrKra025020;
 Thu, 11 Jul 2013 15:53:20 GMT (envelope-from wblock@svn.freebsd.org)
Received: (from wblock@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BFrK5J025019;
 Thu, 11 Jul 2013 15:53:20 GMT (envelope-from wblock@svn.freebsd.org)
Message-Id: <201307111553.r6BFrK5J025019@svn.freebsd.org>
From: Warren Block 
Date: Thu, 11 Jul 2013 15:53:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253212 - stable/9/usr.sbin/powerd
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 15:53:20 -0000

Author: wblock (doc committer)
Date: Thu Jul 11 15:53:19 2013
New Revision: 253212
URL: http://svnweb.freebsd.org/changeset/base/253212

Log:
  MFC r252696:
  
  Put the power modes in a list to make them easier to find.

Modified:
  stable/9/usr.sbin/powerd/powerd.8
Directory Properties:
  stable/9/usr.sbin/powerd/   (props changed)

Modified: stable/9/usr.sbin/powerd/powerd.8
==============================================================================
--- stable/9/usr.sbin/powerd/powerd.8	Thu Jul 11 15:45:51 2013	(r253211)
+++ stable/9/usr.sbin/powerd/powerd.8	Thu Jul 11 15:53:19 2013	(r253212)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 21, 2009
+.Dd July 4, 2013
 .Dt POWERD 8
 .Os
 .Sh NAME
@@ -47,27 +47,43 @@ The
 .Nm
 utility monitors the system state and sets various power control options
 accordingly.
-It offers four modes (maximum, minimum, adaptive and hiadaptive) that can be
-individually selected while on AC power or batteries.
-The modes maximum, minimum, adaptive and hiadaptive may be abbreviated
-max, min, adp, hadp.
-.Pp
-Maximum mode chooses the highest performance values.
-Minimum mode selects the lowest performance values to get the most power
-savings.
-Adaptive mode attempts to strike a balance by degrading performance when
-the system appears idle and increasing it when the system is busy.
+It offers power-saving modes that can be
+individually selected for operation on AC power or batteries.
+.Bl -tag -width ".Ar hiadaptive"
+.It Ar maximum
+Choose the highest performance values.
+May be abbreviated as
+.Ar max .
+.It Ar minimum
+Choose the lowest performance values to get the most power savings.
+May be abbreviated as
+.Ar min .
+.It Ar adaptive
+Attempt to strike a balance by degrading performance when the system
+appears idle and increasing it when the system is busy.
 It offers a good balance between a small performance loss for greatly
 increased power savings.
-Hiadaptive mode is like adaptive mode, but tuned for systems where
-performance and interactivity are more important than power consumption.
-It increases frequency faster, reduces the frequency less aggressively and
+May be abbreviated as
+.Ar adp .
+.It Ar hiadaptive
+Like
+.Ar adaptive
+mode, but tuned for systems where performance and interactivity are
+more important than power consumption.
+It increases frequency faster, reduces frequency less aggressively, and
 will maintain full frequency for longer.
-The default mode is adaptive for battery power and hiadaptive for the rest.
+May be abbreviated as
+.Ar hadp .
+.El
+.Pp
+The default mode is
+.Ar adaptive
+for battery power and
+.Ar hiadaptive
+for the rest.
 .Pp
-The
 .Nm
-utility recognizes the following runtime options:
+recognizes these runtime options:
 .Bl -tag -width ".Fl r Ar percent"
 .It Fl a Ar mode
 Selects the

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 15:55:58 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 5FCACFD8;
 Thu, 11 Jul 2013 15:55:58 +0000 (UTC)
 (envelope-from wblock@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 39CCE1715;
 Thu, 11 Jul 2013 15:55:58 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BFtw4C025468;
 Thu, 11 Jul 2013 15:55:58 GMT (envelope-from wblock@svn.freebsd.org)
Received: (from wblock@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BFtwUD025467;
 Thu, 11 Jul 2013 15:55:58 GMT (envelope-from wblock@svn.freebsd.org)
Message-Id: <201307111555.r6BFtwUD025467@svn.freebsd.org>
From: Warren Block 
Date: Thu, 11 Jul 2013 15:55:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253213 - stable/9/usr.sbin/powerd
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 15:55:58 -0000

Author: wblock (doc committer)
Date: Thu Jul 11 15:55:57 2013
New Revision: 253213
URL: http://svnweb.freebsd.org/changeset/base/253213

Log:
  MFC r252713:
  
  Whitespace fixes: remove tabs on blank links, spaces following content,
  tabs after spaces.

Modified:
  stable/9/usr.sbin/powerd/powerd.c
Directory Properties:
  stable/9/usr.sbin/powerd/   (props changed)

Modified: stable/9/usr.sbin/powerd/powerd.c
==============================================================================
--- stable/9/usr.sbin/powerd/powerd.c	Thu Jul 11 15:53:19 2013	(r253212)
+++ stable/9/usr.sbin/powerd/powerd.c	Thu Jul 11 15:55:57 2013	(r253213)
@@ -153,7 +153,7 @@ read_usage_times(int *load)
 	error = sysctl(cp_times_mib, 2, cp_times, &cp_times_len, NULL, 0);
 	if (error)
 		return (error);
-		
+
 	if (load) {
 		*load = 0;
 		for (cpu = 0; cpu < ncpus; cpu++) {
@@ -164,7 +164,7 @@ read_usage_times(int *load)
 			}
 			if (total == 0)
 				continue;
-			*load += 100 - (cp_times[cpu * CPUSTATES + CP_IDLE] - 
+			*load += 100 - (cp_times[cpu * CPUSTATES + CP_IDLE] -
 			    cp_times_old[cpu * CPUSTATES + CP_IDLE]) * 100 / total;
 		}
 	}
@@ -235,7 +235,7 @@ get_freq(void)
 {
 	size_t len;
 	int curfreq;
-	
+
 	len = sizeof(curfreq);
 	if (sysctl(freq_mib, 4, &curfreq, &len, NULL, 0) != 0) {
 		if (vflag)
@@ -261,7 +261,7 @@ static int
 get_freq_id(int freq, int *freqs, int numfreqs)
 {
 	int i = 1;
-	
+
 	while (i < numfreqs) {
 		if (freqs[i] < freq)
 			break;
@@ -716,7 +716,7 @@ main(int argc, char * argv[])
 				idle = 0;
 				if (set_freq(freq) != 0) {
 					warn("error setting CPU freq %d",
-				    	    freq);
+					    freq);
 					continue;
 				}
 			}
@@ -729,7 +729,7 @@ main(int argc, char * argv[])
 				warn("read_usage_times() failed");
 			continue;
 		}
-		
+
 		if (mode == MODE_ADAPTIVE) {
 			if (load > cpu_running_mark) {
 				if (load > 95 || load > cpu_running_mark * 2)
@@ -740,7 +740,7 @@ main(int argc, char * argv[])
 					freq = freqs[0];
 			} else if (load < cpu_idle_mark &&
 			    curfreq * load < freqs[get_freq_id(
-			    freq * 7 / 8, freqs, numfreqs)] * 
+			    freq * 7 / 8, freqs, numfreqs)] *
 			    cpu_running_mark) {
 				freq = freq * 7 / 8;
 				if (freq < freqs[numfreqs - 1])
@@ -756,7 +756,7 @@ main(int argc, char * argv[])
 					freq = freqs[0] * 2;
 			} else if (load < cpu_idle_mark / 2 &&
 			    curfreq * load < freqs[get_freq_id(
-			    freq * 31 / 32, freqs, numfreqs)] * 
+			    freq * 31 / 32, freqs, numfreqs)] *
 			    cpu_running_mark / 2) {
 				freq = freq * 31 / 32;
 				if (freq < freqs[numfreqs - 1])

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 19:04:20 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 3B54BEF0;
 Thu, 11 Jul 2013 19:04:20 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 2A0641FBD;
 Thu, 11 Jul 2013 19:04:20 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BJ4JVt084599;
 Thu, 11 Jul 2013 19:04:19 GMT (envelope-from gjb@svn.freebsd.org)
Received: (from gjb@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BJ4Jd4084596;
 Thu, 11 Jul 2013 19:04:19 GMT (envelope-from gjb@svn.freebsd.org)
Message-Id: <201307111904.r6BJ4Jd4084596@svn.freebsd.org>
From: Glen Barber 
Date: Thu, 11 Jul 2013 19:04:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253216 - in stable/9: gnu/usr.bin/groff/tmac sys/conf
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 19:04:20 -0000

Author: gjb
Date: Thu Jul 11 19:04:19 2013
New Revision: 253216
URL: http://svnweb.freebsd.org/changeset/base/253216

Log:
  - Set stable/9 branch to -PRERELEASE status.
  - Add 9.2 mdoc(7) macro.
  
  Approved by:	re (implicit)
  Approved by:	kib (mentor)

Modified:
  stable/9/gnu/usr.bin/groff/tmac/mdoc.local
  stable/9/sys/conf/newvers.sh

Modified: stable/9/gnu/usr.bin/groff/tmac/mdoc.local
==============================================================================
--- stable/9/gnu/usr.bin/groff/tmac/mdoc.local	Thu Jul 11 17:41:04 2013	(r253215)
+++ stable/9/gnu/usr.bin/groff/tmac/mdoc.local	Thu Jul 11 19:04:19 2013	(r253216)
@@ -44,13 +44,14 @@
 .ds doc-str-Lb-librtld_db  Run-time Linker Debugging Library (librtld_db, \-lrtld_db)
 .
 .\" Default .Os value
-.ds doc-default-operating-system FreeBSD\~9.1
+.ds doc-default-operating-system FreeBSD\~9.2
 .
 .\" FreeBSD releases not found in doc-common
 .ds doc-operating-system-FreeBSD-7.4    7.4
 .ds doc-operating-system-FreeBSD-8.3    8.3
 .ds doc-operating-system-FreeBSD-8.4    8.4
 .ds doc-operating-system-FreeBSD-9.1    9.1
+.ds doc-operating-system-FreeBSD-9.2    9.2
 .ds doc-operating-system-FreeBSD-10.0   10.0
 .
 .\" Definitions not (yet) in doc-syms

Modified: stable/9/sys/conf/newvers.sh
==============================================================================
--- stable/9/sys/conf/newvers.sh	Thu Jul 11 17:41:04 2013	(r253215)
+++ stable/9/sys/conf/newvers.sh	Thu Jul 11 19:04:19 2013	(r253216)
@@ -31,8 +31,8 @@
 # $FreeBSD$
 
 TYPE="FreeBSD"
-REVISION="9.1"
-BRANCH="STABLE"
+REVISION="9.2"
+BRANCH="PRERELEASE"
 if [ "X${BRANCH_OVERRIDE}" != "X" ]; then
 	BRANCH=${BRANCH_OVERRIDE}
 fi

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 19:18:13 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id E4C4157D;
 Thu, 11 Jul 2013 19:18:13 +0000 (UTC) (envelope-from pfg@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id BAE201043;
 Thu, 11 Jul 2013 19:18:13 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BJIDiS088389;
 Thu, 11 Jul 2013 19:18:13 GMT (envelope-from pfg@svn.freebsd.org)
Received: (from pfg@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BJIDR7088388;
 Thu, 11 Jul 2013 19:18:13 GMT (envelope-from pfg@svn.freebsd.org)
Message-Id: <201307111918.r6BJIDR7088388@svn.freebsd.org>
From: "Pedro F. Giffuni" 
Date: Thu, 11 Jul 2013 19:18:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253218 - stable/9/sys/fs/ext2fs
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 19:18:14 -0000

Author: pfg
Date: Thu Jul 11 19:18:13 2013
New Revision: 253218
URL: http://svnweb.freebsd.org/changeset/base/253218

Log:
  MFC	r253050:
  
  Enhancement when writing an entire block of a file (from UFS r231313).
  
  This change first attempts the uiomove() to the newly allocated
  (and dirty) buffer and only zeros it if the uiomove() fails. The
  effect is to eliminate the gratuitous zeroing of the buffer in
  the usual case where the uiomove() successfully fills it.

Modified:
  stable/9/sys/fs/ext2fs/ext2_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_vnops.c	Thu Jul 11 19:09:31 2013	(r253217)
+++ stable/9/sys/fs/ext2fs/ext2_vnops.c	Thu Jul 11 19:18:13 2013	(r253218)
@@ -1817,15 +1817,6 @@ ext2_write(struct vop_write_args *ap)
 		if (error != 0)
 			break;
 
-		/*
-		 * If the buffer is not valid and we did not clear garbage
-		 * out above, we have to do so here even though the write
-		 * covers the entire buffer in order to avoid a mmap()/write
-		 * race where another process may see the garbage prior to
-		 * the uiomove() for a write replacing it.
-		 */
-		if ((bp->b_flags & B_CACHE) == 0 && fs->e2fs_bsize <= xfersize)
-			vfs_bio_clrbuf(bp);
 		if ((ioflag & (IO_SYNC|IO_INVAL)) == (IO_SYNC|IO_INVAL))
 			bp->b_flags |= B_NOCACHE;
 		if (uio->uio_offset + xfersize > ip->i_size)
@@ -1836,6 +1827,26 @@ ext2_write(struct vop_write_args *ap)
 
 		error =
 		    uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
+		/*
+		 * If the buffer is not already filled and we encounter an
+		 * error while trying to fill it, we have to clear out any
+		 * garbage data from the pages instantiated for the buffer.
+		 * If we do not, a failed uiomove() during a write can leave
+		 * the prior contents of the pages exposed to a userland mmap.
+		 *
+		 * Note that we need only clear buffers with a transfer size
+		 * equal to the block size because buffers with a shorter
+		 * transfer size were cleared above by the call to ext2_balloc()
+		 * with the BA_CLRBUF flag set.
+		 *
+		 * If the source region for uiomove identically mmaps the
+		 * buffer, uiomove() performed the NOP copy, and the buffer
+		 * content remains valid because the page fault handler
+		 * validated the pages.
+		 */
+		if (error != 0 && (bp->b_flags & B_CACHE) == 0 &&
+		    fs->e2fs_bsize == xfersize)
+			vfs_bio_clrbuf(bp);
 		if (ioflag & (IO_VMIO|IO_DIRECT)) {
 			bp->b_flags |= B_RELBUF;
 		}

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 20:09:47 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 4EBAE6A3;
 Thu, 11 Jul 2013 20:09:47 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 261991222;
 Thu, 11 Jul 2013 20:09:47 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BK9l7x003675;
 Thu, 11 Jul 2013 20:09:47 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BK9kD0003673;
 Thu, 11 Jul 2013 20:09:46 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201307112009.r6BK9kD0003673@svn.freebsd.org>
From: Dimitry Andric 
Date: Thu, 11 Jul 2013 20:09:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253220 - stable/9/share/mk
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 20:09:47 -0000

Author: dim
Date: Thu Jul 11 20:09:46 2013
New Revision: 253220
URL: http://svnweb.freebsd.org/changeset/base/253220

Log:
  MFC r240966 (by brooks)
  
  Add a COMPILER_FEATURES variable that is set in bsd.compiler.mk.
  
  When the compiler is clang add c++11 to COMPILER_FEATURES.
  
  When the compiler supports c++11, default to building libc++.  This will
  not impact the compliation of programs, but will make it easier for
  users with clang compiled systems to test libc++ by passing -stdlib=libc++
  to their c++ compliations.

Modified:
  stable/9/share/mk/bsd.compiler.mk
  stable/9/share/mk/bsd.own.mk
Directory Properties:
  stable/9/share/   (props changed)
  stable/9/share/mk/   (props changed)

Modified: stable/9/share/mk/bsd.compiler.mk
==============================================================================
--- stable/9/share/mk/bsd.compiler.mk	Thu Jul 11 19:34:16 2013	(r253219)
+++ stable/9/share/mk/bsd.compiler.mk	Thu Jul 11 20:09:46 2013	(r253220)
@@ -19,3 +19,9 @@ COMPILER_TYPE:=	clang
 .  undef _COMPILER_VERSION
 . endif
 .endif
+
+.if ${COMPILER_TYPE} == "clang"
+COMPILER_FEATURES=	c++11
+.else
+COMPILER_FEATURES=
+.endif

Modified: stable/9/share/mk/bsd.own.mk
==============================================================================
--- stable/9/share/mk/bsd.own.mk	Thu Jul 11 19:34:16 2013	(r253219)
+++ stable/9/share/mk/bsd.own.mk	Thu Jul 11 20:09:46 2013	(r253220)
@@ -447,7 +447,6 @@ __DEFAULT_NO_OPTIONS = \
     HESIOD \
     ICONV \
     IDEA \
-    LIBCPLUSPLUS \
     NMTREE \
     OFED \
     OPENSSH_NONE_CIPHER \
@@ -603,10 +602,6 @@ MK_CLANG_FULL:= no
 MK_CLANG_IS_CC:= no
 .endif
 
-MK_LIBCPLUSPLUS?= no
-
-MK_LIBCPLUSPLUS?= no
-
 #
 # Set defaults for the MK_*_SUPPORT variables.
 #
@@ -660,6 +655,33 @@ MK_${vv:H}:=	${MK_${vv:T}}
 .endif
 .endfor
 
+#
+# MK_* options that default to "yes" if the compiler is a C++11 compiler.
+#
+.include 
+.for var in \
+    LIBCPLUSPLUS
+.if defined(WITH_${var}) && defined(WITHOUT_${var})
+.error WITH_${var} and WITHOUT_${var} can't both be set.
+.endif
+.if defined(MK_${var})
+.error MK_${var} can't be set by a user.
+.endif
+.if ${COMPILER_FEATURES:Mc++11}
+.if defined(WITHOUT_${var})
+MK_${var}:=	no
+.else
+MK_${var}:=	yes
+.endif
+.else
+.if defined(WITH_${var})
+MK_${var}:=	yes
+.else
+MK_${var}:=	no
+.endif
+.endif
+.endfor
+
 .if ${MK_CTF} != "no"
 CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
 .elif defined(.PARSEDIR) || ${MAKE_VERSION} >= 9201210220

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 20:53:40 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 2F52F52A;
 Thu, 11 Jul 2013 20:53:40 +0000 (UTC) (envelope-from ken@kdm.org)
Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81])
 by mx1.freebsd.org (Postfix) with ESMTP id C05A71480;
 Thu, 11 Jul 2013 20:53:39 +0000 (UTC)
Received: from nargothrond.kdm.org (localhost [127.0.0.1])
 by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id r6BKrXlE026127;
 Thu, 11 Jul 2013 14:53:33 -0600 (MDT)
 (envelope-from ken@nargothrond.kdm.org)
Received: (from ken@localhost)
 by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id r6BKrWHN026126;
 Thu, 11 Jul 2013 14:53:32 -0600 (MDT) (envelope-from ken)
Date: Thu, 11 Jul 2013 14:53:32 -0600
From: "Kenneth D. Merry" 
To: Andre Albsmeier 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130711205332.GA26100@nargothrond.kdm.org>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali> <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali> <20130710184915.GA28790@nargothrond.kdm.org>
 <20130710185833.GA83135@bali>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20130710185833.GA83135@bali>
User-Agent: Mutt/1.4.2i
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 20:53:40 -0000

On Wed, Jul 10, 2013 at 20:58:33 +0200, Andre Albsmeier wrote:
> On Wed, 10-Jul-2013 at 20:49:15 +0200, Kenneth D. Merry wrote:
> > On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> > > On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > > > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > > > Author: ken
> > > > > > Date: Tue Jun 25 21:43:49 2013
> > > > > > New Revision: 252214
> > > > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > > > 
> > > > > Hi Ken,
> > > > > 
> > > > > > Log:
> > > > > >   MFC: 249658, 249701
> > > > > > 
> > > > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > > > 
> > > > > >   This allows mapping a tape drive in a changer (as reported by
> > > > > >   'chio status') to a sa(4) driver instance by comparing the
> > > > > >   serial numbers.
> > > > > > 
> > > > > >   The designators can be ASCII (which is printed out directly), binary
> > > > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > > > >   explanation and example UTF-8 printing code.
> > > > > > 
> > > > > >   chio.h:               Modify the changer_element_status structure to add new
> > > > > >                 fields and definitions from the SMC3r16 spec.
> > > > > > 
> > > > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > > > >                 define a new CHIOGSTATUS ioctl.
> > > > > > 
> > > > > >                 Clean up some tab/space issues.
> > > > > > 
> > > > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > > > >                 if it is supplied by a device.
> > > > > > 
> > > > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > > > >                 ELEMENT STATUS command structure.
> > > > > > 
> > > > > >                 Add a read_element_status_device_id structure
> > > > > >                 for the data fields in the new standard. Add new
> > > > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > > > >                 and address data from either SCSI-2 or newer devices.
> > > > > > 
> > > > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > > > >                 ELEMENT STATUS data.
> > > > > > 
> > > > > >                 Add new arguments to scsi_read_element_status() to
> > > > > >                 allow the user to request the DVCID and CURDATA bits.
> > > > > 
> > > > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > > > 
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > > > 
> > > > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > > > this workaround to make it work again until a better solution is available:
> > > > > 
> > > > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > > > @@ -1245,8 +1245,8 @@
> > > > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > > > >  				 /* voltag */ want_voltags,
> > > > >  				 /* sea */ softc->sc_firsts[chet],
> > > > > -				 /* dvcid */ 1,
> > > > > -				 /* curdata */ 1,
> > > > > +				 /* dvcid */ 0,
> > > > > +				 /* curdata */ 0,
> > > > >  				 /* count */ 1,
> > > > >  				 /* data_ptr */ data,
> > > > >  				 /* dxfer_len */ 1024,
> > > > > @@ -1284,8 +1284,8 @@
> > > > >  				 /* voltag */ want_voltags,
> > > > >  				 /* sea */ softc->sc_firsts[chet]
> > > > >  				 + cesr->cesr_element_base,
> > > > > -				 /* dvcid */ 1,
> > > > > -				 /* curdata */ 1,
> > > > > +				 /* dvcid */ 0,
> > > > > +				 /* curdata */ 0,
> > > > >  				 /* count */ cesr->cesr_element_count,
> > > > >  				 /* data_ptr */ data,
> > > > >  				 /* dxfer_len */ size,
> > > > > 
> > > > > 	-Andre
> > > > 
> > > > Oops, sorry.
> > > > 
> > > > We need to check the SCSI version to see whether to set those bits, and
> > > > also fall back in case it doesn't work.
> > > > 
> > > > I am on vacation and have very spotty net access.  I can't do anything
> > > > about it until I get back next week.
> > > > 
> > > > Justin and Alan (CCed) can work on the fix, though.
> > > 
> > > Take your time, for me it's working right now
> > > with the above patch...
> > 
> > Okay, I'm back and can take a look at this.
> 
> Welcome back ;-)
> 
> > 
> > Can you send me:
> 
> Sure, I am happy to help.
> 
> > 
> > camcontrol inquiry ch0 -v
> 
> pass17:  Removable Changer SCSI-2 device 
> pass17: Serial Number 0021009613
> pass17: 3.300MB/s transfers
> 
> > camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"
> 
> 0 0 0 0 0 0 0 0 

Okay, that was helpful, thanks!

> > 
> > I want to see what SCSI version this changer reports.  The second command
> > will print out the SCSI version descriptors, if any, that the changer
> > reports.
> 
> In case you need more info just drop me a note.
> 
> Thanks for looking into this.

Can you try the attached patch, and see how it works for you?

It defaults to not setting those bits for changers that claim to be SCSI-2
or below.  And if a SCSI-3 or higher changer returns an Illegal Request
type error, it will retry with the bits cleared to see whether that works.

I also bumped the read element status timeout after some testing with a
Spectra T-380.

The patch is against head, but stable/9 shouldn't be much different.

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 21:33:05 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 3B5B9D51;
 Thu, 11 Jul 2013 21:33:05 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 2BE3C1728;
 Thu, 11 Jul 2013 21:33:05 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BLX5xC029462;
 Thu, 11 Jul 2013 21:33:05 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BLX3DC029448;
 Thu, 11 Jul 2013 21:33:03 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201307112133.r6BLX3DC029448@svn.freebsd.org>
From: Dimitry Andric 
Date: Thu, 11 Jul 2013 21:33:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253222 - in stable/9/contrib: libc++/include libc++/src
 libcxxrt
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 21:33:05 -0000

Author: dim
Date: Thu Jul 11 21:33:03 2013
New Revision: 253222
URL: http://svnweb.freebsd.org/changeset/base/253222

Log:
  MFC r253159 (by theraven):
  
  Import new libcxxrt / libc++.  This brings some bug fixes, including a
  potential race condition for static initialisers.

Modified:
  stable/9/contrib/libc++/include/__bit_reference
  stable/9/contrib/libc++/include/__config
  stable/9/contrib/libc++/include/__functional_base
  stable/9/contrib/libc++/include/__hash_table
  stable/9/contrib/libc++/include/__locale
  stable/9/contrib/libc++/include/__split_buffer
  stable/9/contrib/libc++/include/__std_stream
  stable/9/contrib/libc++/include/__tree
  stable/9/contrib/libc++/include/algorithm
  stable/9/contrib/libc++/include/atomic
  stable/9/contrib/libc++/include/deque
  stable/9/contrib/libc++/include/forward_list
  stable/9/contrib/libc++/include/functional
  stable/9/contrib/libc++/include/future
  stable/9/contrib/libc++/include/istream
  stable/9/contrib/libc++/include/iterator
  stable/9/contrib/libc++/include/list
  stable/9/contrib/libc++/include/locale
  stable/9/contrib/libc++/include/map
  stable/9/contrib/libc++/include/memory
  stable/9/contrib/libc++/include/random
  stable/9/contrib/libc++/include/regex
  stable/9/contrib/libc++/include/string
  stable/9/contrib/libc++/include/type_traits
  stable/9/contrib/libc++/include/unordered_map
  stable/9/contrib/libc++/include/utility
  stable/9/contrib/libc++/include/vector
  stable/9/contrib/libc++/src/debug.cpp
  stable/9/contrib/libc++/src/hash.cpp
  stable/9/contrib/libc++/src/iostream.cpp
  stable/9/contrib/libc++/src/locale.cpp
  stable/9/contrib/libc++/src/stdexcept.cpp
  stable/9/contrib/libc++/src/string.cpp
  stable/9/contrib/libc++/src/thread.cpp
  stable/9/contrib/libcxxrt/atomic.h
  stable/9/contrib/libcxxrt/auxhelper.cc
  stable/9/contrib/libcxxrt/cxxabi.h
  stable/9/contrib/libcxxrt/dwarf_eh.h
  stable/9/contrib/libcxxrt/exception.cc
  stable/9/contrib/libcxxrt/guard.cc
  stable/9/contrib/libcxxrt/memory.cc
Directory Properties:
  stable/9/contrib/libc++/   (props changed)
  stable/9/contrib/libcxxrt/   (props changed)

Modified: stable/9/contrib/libc++/include/__bit_reference
==============================================================================
--- stable/9/contrib/libc++/include/__bit_reference	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__bit_reference	Thu Jul 11 21:33:03 2013	(r253222)
@@ -333,7 +333,7 @@ __fill_n_false(__bit_iterator<_Cp, false
     }
     // do middle whole words
     __storage_type __nw = __n / __bits_per_word;
-    _VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type));
+    _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type));
     __n -= __nw * __bits_per_word;
     // do last partial word
     if (__n > 0)
@@ -363,7 +363,7 @@ __fill_n_true(__bit_iterator<_Cp, false>
     }
     // do middle whole words
     __storage_type __nw = __n / __bits_per_word;
-    _VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type));
+    _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type));
     __n -= __nw * __bits_per_word;
     // do last partial word
     if (__n > 0)
@@ -430,7 +430,9 @@ __copy_aligned(__bit_iterator<_Cp, _IsCo
         // __first.__ctz_ == 0;
         // do middle words
         __storage_type __nw = __n / __bits_per_word;
-        _VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type));
+        _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
+                       _VSTD::__to_raw_pointer(__first.__seg_),
+                       __nw * sizeof(__storage_type));
         __n -= __nw * __bits_per_word;
         __result.__seg_ += __nw;
         // do last word
@@ -569,7 +571,9 @@ __copy_backward_aligned(__bit_iterator<_
         __storage_type __nw = __n / __bits_per_word;
         __result.__seg_ -= __nw;
         __last.__seg_ -= __nw;
-        _VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type));
+        _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
+                       _VSTD::__to_raw_pointer(__last.__seg_),
+                       __nw * sizeof(__storage_type));
         __n -= __nw * __bits_per_word;
         // do last word
         if (__n > 0)
@@ -870,6 +874,7 @@ struct __bit_array
 {
     typedef typename _Cp::difference_type difference_type;
     typedef typename _Cp::__storage_type  __storage_type;
+    typedef typename _Cp::__storage_pointer __storage_pointer;
     typedef typename _Cp::iterator        iterator;
     static const unsigned __bits_per_word = _Cp::__bits_per_word;
     static const unsigned _Np = 4;
@@ -880,9 +885,15 @@ struct __bit_array
     _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
         {return static_cast(_Np * __bits_per_word);}
     _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
-    _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);}
-    _LIBCPP_INLINE_VISIBILITY iterator end()   {return iterator(__word_ + __size_ / __bits_per_word,
-                                                  static_cast(__size_ % __bits_per_word));}
+    _LIBCPP_INLINE_VISIBILITY iterator begin()
+    {
+        return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
+    }
+    _LIBCPP_INLINE_VISIBILITY iterator end()
+    {
+        return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
+                                                  static_cast(__size_ % __bits_per_word));
+    }
 };
 
 template 

Modified: stable/9/contrib/libc++/include/__config
==============================================================================
--- stable/9/contrib/libc++/include/__config	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__config	Thu Jul 11 21:33:03 2013	(r253222)
@@ -56,6 +56,18 @@
 # endif  // __LONG_LONG_SUPPORTED
 #endif  // __FreeBSD__
 
+#ifdef __NetBSD__
+# include 
+#  if _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 1
+#   define _LIBCPP_BIG_ENDIAN    0
+# else  // _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 0
+#   define _LIBCPP_BIG_ENDIAN    1
+# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_HAS_QUICK_EXIT
+#endif  // __NetBSD__
+
 #ifdef _WIN32
 #  define _LIBCPP_LITTLE_ENDIAN 1
 #  define _LIBCPP_BIG_ENDIAN    0
@@ -135,6 +147,10 @@
 
 #endif // _WIN32
 
+#ifndef __has_attribute
+#define __has_attribute(__x) 0
+#endif
+
 #ifndef _LIBCPP_HIDDEN
 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
 #endif
@@ -212,7 +228,9 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
 #endif
 
+#if !(__has_feature(cxx_defaulted_functions))
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#endif  // !(__has_feature(cxx_defaulted_functions))
 
 #if !(__has_feature(cxx_deleted_functions))
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
@@ -272,10 +290,20 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #endif
 
-#if defined(__FreeBSD__) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#elif defined(__linux__)
+#include 
+#if __GLIBC_PREREQ(2, 15)
 #define _LIBCPP_HAS_QUICK_EXIT
+#endif
+#if __GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
 #endif
+#endif
+#endif
 
 #if (__has_feature(cxx_noexcept))
 #  define _NOEXCEPT noexcept
@@ -418,8 +446,14 @@ template  struct __static_asse
 #define _LIBCPP_CONSTEXPR constexpr
 #endif
 
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_DEFAULT {}
+#else
+#define _LIBCPP_DEFAULT = default;
+#endif
+
 #ifdef __GNUC__
-#define _NOALIAS __attribute__((malloc))
+#define _NOALIAS __attribute__((__malloc__))
 #else
 #define _NOALIAS
 #endif
@@ -451,7 +485,7 @@ template  struct __static_asse
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 #ifdef __FreeBSD__
@@ -476,6 +510,14 @@ template  struct __static_asse
 #   endif
 #endif
 
+#ifndef _LIBCPP_STD_VER
+#  if  __cplusplus <= 201103L
+#    define _LIBCPP_STD_VER 11
+#  else
+#    define _LIBCPP_STD_VER 13  // current year, or date of c++14 ratification
+#  endif
+#endif  // _LIBCPP_STD_VER
+
 #ifdef _LIBCPP_DEBUG2
 #   include <__debug>
 #else

Modified: stable/9/contrib/libc++/include/__functional_base
==============================================================================
--- stable/9/contrib/libc++/include/__functional_base	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__functional_base	Thu Jul 11 21:33:03 2013	(r253222)
@@ -292,7 +292,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_
 
 // bullets 1 and 2
 
-template 
+template 
 inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
@@ -301,7 +302,8 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&& 
     return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
 }
 
-template 
+template 
 inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
@@ -312,7 +314,8 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&& 
 
 // bullets 3 and 4
 
-template 
+template 
 inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0)
@@ -321,7 +324,8 @@ __invoke(_Fp&& __f, _A0&& __a0)
     return _VSTD::forward<_A0>(__a0).*__f;
 }
 
-template 
+template 
 inline _LIBCPP_INLINE_VISIBILITY
 auto
 __invoke(_Fp&& __f, _A0&& __a0)

Modified: stable/9/contrib/libc++/include/__hash_table
==============================================================================
--- stable/9/contrib/libc++/include/__hash_table	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__hash_table	Thu Jul 11 21:33:03 2013	(r253222)
@@ -33,7 +33,6 @@ template 
 struct __hash_node_base
 {
     typedef __hash_node_base __first_node;
- //   typedef _NodePtr pointer;
 
     _NodePtr    __next_;
 
@@ -111,7 +110,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
         reference operator*() const {return __node_->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-        pointer operator->() const {return _VSTD::addressof(__node_->__value_);}
+        pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_iterator& operator++()
@@ -189,7 +188,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
         reference operator*() const {return __node_->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-        pointer operator->() const {return _VSTD::addressof(__node_->__value_);}
+        pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_const_iterator& operator++()
@@ -255,7 +254,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
         reference operator*() const {return __node_->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-        pointer operator->() const {return &__node_->__value_;}
+        pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_local_iterator& operator++()
@@ -345,7 +344,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
         reference operator*() const {return __node_->__value_;}
     _LIBCPP_INLINE_VISIBILITY
-        pointer operator->() const {return &__node_->__value_;}
+        pointer operator->() const {return pointer_traits::pointer_to(__node_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __hash_const_local_iterator& operator++()
@@ -505,8 +504,15 @@ public:
                                                      __node_allocator;
     typedef allocator_traits<__node_allocator>       __node_traits;
     typedef typename __node_traits::pointer          __node_pointer;
-    typedef typename __node_traits::const_pointer    __node_const_pointer;
+    typedef typename __node_traits::pointer          __node_const_pointer;
     typedef __hash_node_base<__node_pointer>         __first_node;
+    typedef typename pointer_traits<__node_pointer>::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+            rebind<__first_node>
+#else
+            rebind<__first_node>::other
+#endif
+                                                     __node_base_pointer;
 
 private:
 
@@ -558,9 +564,9 @@ public:
 
 public:
     typedef __hash_iterator<__node_pointer>                   iterator;
-    typedef __hash_const_iterator<__node_const_pointer>       const_iterator;
+    typedef __hash_const_iterator<__node_pointer>             const_iterator;
     typedef __hash_local_iterator<__node_pointer>             local_iterator;
-    typedef __hash_const_local_iterator<__node_const_pointer> const_local_iterator;
+    typedef __hash_const_local_iterator<__node_pointer>       const_local_iterator;
 
     __hash_table()
         _NOEXCEPT_(
@@ -706,7 +712,7 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     size_type max_bucket_count() const _NOEXCEPT
-        {return __bucket_list_.get_deleter().__alloc().max_size();}
+        {return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());}
     size_type bucket_size(size_type __n) const;
     _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
     {
@@ -807,6 +813,9 @@ private:
 
     void __deallocate(__node_pointer __np) _NOEXCEPT;
     __node_pointer __detach() _NOEXCEPT;
+
+    template  friend class _LIBCPP_TYPE_VIS unordered_map;
+    template  friend class _LIBCPP_TYPE_VIS unordered_multimap;
 };
 
 template 
@@ -893,7 +902,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     if (size() > 0)
     {
         __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
-            static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
         __u.__p1_.first().__next_ = nullptr;
         __u.size() = 0;
     }
@@ -917,7 +926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
             __p1_.first().__next_ = __u.__p1_.first().__next_;
             __u.__p1_.first().__next_ = nullptr;
             __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
-                static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+                static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
             size() = __u.size();
             __u.size() = 0;
         }
@@ -1014,7 +1023,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     if (size() > 0)
     {
         __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
-            static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
         __u.__p1_.first().__next_ = nullptr;
         __u.size() = 0;
     }
@@ -1236,7 +1245,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
         __node_pointer __pn = __bucket_list_[__chash];
         if (__pn == nullptr)
         {
-            __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+            __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
             __nd->__next_ = __pn->__next_;
             __pn->__next_ = __nd;
             // fix up __bucket_list_
@@ -1274,7 +1283,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     __node_pointer __pn = __bucket_list_[__chash];
     if (__pn == nullptr)
     {
-        __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+        __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
         __cp->__next_ = __pn->__next_;
         __pn->__next_ = __cp;
         // fix up __bucket_list_
@@ -1322,7 +1331,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 {
     if (__p != end() && key_eq()(*__p, __cp->__value_))
     {
-        __node_pointer __np = const_cast<__node_pointer>(__p.__node_);
+        __node_pointer __np = __p.__node_;
         __cp->__hash_ = __np->__hash_;
         size_type __bc = bucket_count();
         if (size()+1 > __bc * max_load_factor() || __bc == 0)
@@ -1380,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
         __node_pointer __pn = __bucket_list_[__chash];
         if (__pn == nullptr)
         {
-            __pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+            __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
             __h->__next_ = __pn->__next_;
             __pn->__next_ = __h.get();
             // fix up __bucket_list_
@@ -1542,7 +1551,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     {
         for (size_type __i = 0; __i < __nbc; ++__i)
             __bucket_list_[__i] = nullptr;
-        __node_pointer __pp(static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())));
+        __node_pointer __pp(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())));
         __node_pointer __cp = __pp->__next_;
         if (__cp != nullptr)
         {
@@ -1700,7 +1709,7 @@ template ::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
 {
-    __node_pointer __np = const_cast<__node_pointer>(__p.__node_);
+    __node_pointer __np = __p.__node_;
     iterator __r(__np);
     ++__r;
     remove(__p);
@@ -1717,7 +1726,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
         ++__first;
         erase(__p);
     }
-    __node_pointer __np = const_cast<__node_pointer>(__last.__node_);
+    __node_pointer __np = __last.__node_;
     return iterator (__np);
 }
 
@@ -1757,7 +1766,7 @@ typename __hash_table<_Tp, _Hash, _Equal
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
 {
     // current node
-    __node_pointer __cn = const_cast<__node_pointer>(__p.__node_);
+    __node_pointer __cn = __p.__node_;
     size_type __bc = bucket_count();
     size_t __chash = __constrain_hash(__cn->__hash_, __bc);
     // find previous node
@@ -1767,7 +1776,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     // Fix up __bucket_list_
         // if __pn is not in same bucket (before begin is not in same bucket) &&
         //    if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
-    if (__pn == _VSTD::addressof(__p1_.first()) || __constrain_hash(__pn->__hash_, __bc) != __chash)
+    if (__pn == static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()))
+                            || __constrain_hash(__pn->__hash_, __bc) != __chash)
     {
         if (__cn->__next_ == nullptr || __constrain_hash(__cn->__next_->__hash_, __bc) != __chash)
             __bucket_list_[__chash] = nullptr;
@@ -1907,10 +1917,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
     __p3_.swap(__u.__p3_);
     if (size() > 0)
         __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
-            static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
     if (__u.size() > 0)
         __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] =
-            static_cast<__node_pointer>(_VSTD::addressof(__u.__p1_.first()));
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first()));
 }
 
 template 

Modified: stable/9/contrib/libc++/include/__locale
==============================================================================
--- stable/9/contrib/libc++/include/__locale	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__locale	Thu Jul 11 21:33:03 2013	(r253222)
@@ -339,12 +339,12 @@ public:
     static const mask punct  = _PUNCT;
     static const mask xdigit = _HEX;
     static const mask blank  = _BLANK;
-#elif (defined(__APPLE__) || defined(__FreeBSD__)) || defined(EMSCRIPTEN)
+#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
 #ifdef __APPLE__
     typedef __uint32_t mask;
 #elif defined(__FreeBSD__)
     typedef unsigned long mask;
-#elif defined(EMSCRIPTEN)
+#elif defined(EMSCRIPTEN) ||  defined(__NetBSD__)
     typedef unsigned short mask;
 #endif
     static const mask space  = _CTYPE_S;
@@ -356,7 +356,11 @@ public:
     static const mask digit  = _CTYPE_D;
     static const mask punct  = _CTYPE_P;
     static const mask xdigit = _CTYPE_X;
+# if defined(__NetBSD__)
+    static const mask blank  = _CTYPE_BL;
+# else
     static const mask blank  = _CTYPE_B;
+# endif
 #elif defined(__sun__)
     typedef unsigned int mask;
     static const mask space  = _ISSPACE;
@@ -596,6 +600,10 @@ public:
     static const int* __classic_upper_table() _NOEXCEPT;
     static const int* __classic_lower_table() _NOEXCEPT;
 #endif
+#if defined(__NetBSD__)
+    static const short* __classic_upper_table() _NOEXCEPT;
+    static const short* __classic_lower_table() _NOEXCEPT;
+#endif
 
 protected:
     ~ctype();

Modified: stable/9/contrib/libc++/include/__split_buffer
==============================================================================
--- stable/9/contrib/libc++/include/__split_buffer	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__split_buffer	Thu Jul 11 21:33:03 2013	(r253222)
@@ -290,7 +290,7 @@ void
 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
 {
     while (__begin_ != __new_begin)
-        __alloc_traits::destroy(__alloc(), __begin_++);
+        __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
 }
 
 template 
@@ -307,7 +307,7 @@ void
 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
 {
     while (__new_last != __end_)
-        __alloc_traits::destroy(__alloc(), --__end_);
+        __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
 }
 
 template 
@@ -320,7 +320,7 @@ __split_buffer<_Tp, _Allocator>::__destr
 
 template 
 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
-    : __end_cap_(0, __a)
+    : __end_cap_(nullptr, __a)
 {
     __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
     __begin_ = __end_ = __first_ + __start;
@@ -331,21 +331,21 @@ template 
 _LIBCPP_INLINE_VISIBILITY inline
 __split_buffer<_Tp, _Allocator>::__split_buffer()
     _NOEXCEPT_(is_nothrow_default_constructible::value)
-    : __first_(0), __begin_(0), __end_(0), __end_cap_(0)
+    : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
 {
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
-    : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
+    : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
 {
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
-    : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
+    : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
 {
 }
 

Modified: stable/9/contrib/libc++/include/__std_stream
==============================================================================
--- stable/9/contrib/libc++/include/__std_stream	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__std_stream	Thu Jul 11 21:33:03 2013	(r253222)
@@ -55,6 +55,8 @@ private:
     const codecvt* __cv_;
     state_type* __st_;
     int __encoding_;
+    int_type __last_consumed_;
+    bool __last_consumed_is_next_;
     bool __always_noconv_;
 
     __stdinbuf(const __stdinbuf&);
@@ -66,7 +68,9 @@ private:
 template 
 __stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
     : __file_(__fp),
-      __st_(__st)
+      __st_(__st),
+      __last_consumed_(traits_type::eof()),
+      __last_consumed_is_next_(false)
 {
     imbue(this->getloc());
 }
@@ -100,6 +104,16 @@ template 
 typename __stdinbuf<_CharT>::int_type
 __stdinbuf<_CharT>::__getchar(bool __consume)
 {
+    if (__last_consumed_is_next_)
+    {
+        int_type __result = __last_consumed_;
+        if (__consume)
+        {
+            __last_consumed_ = traits_type::eof();
+            __last_consumed_is_next_ = false;
+        }
+        return __result;
+    }
     char __extbuf[__limit];
     int __nread = _VSTD::max(1, __encoding_);
     for (int __i = 0; __i < __nread; ++__i)
@@ -154,6 +168,8 @@ __stdinbuf<_CharT>::__getchar(bool __con
                 return traits_type::eof();
         }
     }
+    else
+        __last_consumed_ = traits_type::to_int_type(__1buf);
     return traits_type::to_int_type(__1buf);
 }
 
@@ -162,28 +178,41 @@ typename __stdinbuf<_CharT>::int_type
 __stdinbuf<_CharT>::pbackfail(int_type __c)
 {
     if (traits_type::eq_int_type(__c, traits_type::eof()))
-        return __c;
-    char __extbuf[__limit];
-    char* __enxt;
-    const char_type __ci = traits_type::to_char_type(__c);
-    const char_type* __inxt;
-    switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
-                              __extbuf, __extbuf + sizeof(__extbuf), __enxt))
     {
-    case _VSTD::codecvt_base::ok:
-        break;
-    case _VSTD::codecvt_base::noconv:
-        __extbuf[0] = static_cast(__c);
-        __enxt = __extbuf + 1;
-        break;
-    case codecvt_base::partial:
-    case codecvt_base::error:
-        return traits_type::eof();
+        if (!__last_consumed_is_next_)
+        {
+            __c = __last_consumed_;
+            __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
+                                                                 traits_type::eof());
+        }
+        return __c;
     }
-    while (__enxt > __extbuf)
-        if (ungetc(*--__enxt, __file_) == EOF)
+    if (__last_consumed_is_next_)
+    {
+        char __extbuf[__limit];
+        char* __enxt;
+        const char_type __ci = traits_type::to_char_type(__last_consumed_);
+        const char_type* __inxt;
+        switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
+                                  __extbuf, __extbuf + sizeof(__extbuf), __enxt))
+        {
+        case _VSTD::codecvt_base::ok:
+            break;
+        case _VSTD::codecvt_base::noconv:
+            __extbuf[0] = static_cast(__last_consumed_);
+            __enxt = __extbuf + 1;
+            break;
+        case codecvt_base::partial:
+        case codecvt_base::error:
             return traits_type::eof();
- return traits_type::not_eof(__c);
+        }
+        while (__enxt > __extbuf)
+            if (ungetc(*--__enxt, __file_) == EOF)
+                return traits_type::eof();
+    }
+    __last_consumed_ = __c;
+    __last_consumed_is_next_ = true;
+    return __c;
 }
 
 // __stdoutbuf
@@ -234,30 +263,31 @@ __stdoutbuf<_CharT>::overflow(int_type _
     char_type __1buf;
     if (!traits_type::eq_int_type(__c, traits_type::eof()))
     {
-        this->setp(&__1buf, &__1buf+1);
-        *this->pptr() = traits_type::to_char_type(__c);
-        this->pbump(1);
+        __1buf = traits_type::to_char_type(__c);
         if (__always_noconv_)
         {
-            if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
+            if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
                 return traits_type::eof();
         }
         else
         {
             char* __extbe = __extbuf;
             codecvt_base::result __r;
+            char_type* pbase = &__1buf;
+            char_type* pptr = pbase + 1;
+            char_type* epptr = pptr;
             do
             {
                 const char_type* __e;
-                __r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
+                __r = __cv_->out(*__st_, pbase, pptr, __e,
                                         __extbuf,
                                         __extbuf + sizeof(__extbuf),
                                         __extbe);
-                if (__e == this->pbase())
+                if (__e == pbase)
                     return traits_type::eof();
                 if (__r == codecvt_base::noconv)
                 {
-                    if (fwrite(this->pbase(), 1, 1, __file_) != 1)
+                    if (fwrite(pbase, 1, 1, __file_) != 1)
                         return traits_type::eof();
                 }
                 else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
@@ -267,15 +297,13 @@ __stdoutbuf<_CharT>::overflow(int_type _
                         return traits_type::eof();
                     if (__r == codecvt_base::partial)
                     {
-                        this->setp((char_type*)__e, this->pptr());
-                        this->pbump(static_cast(this->epptr() - this->pbase()));
+                        pbase = (char_type*)__e;
                     }
                 }
                 else
                     return traits_type::eof();
             } while (__r == codecvt_base::partial);
         }
-        this->setp(0, 0);
     }
     return traits_type::not_eof(__c);
 }

Modified: stable/9/contrib/libc++/include/__tree
==============================================================================
--- stable/9/contrib/libc++/include/__tree	Thu Jul 11 20:33:57 2013	(r253221)
+++ stable/9/contrib/libc++/include/__tree	Thu Jul 11 21:33:03 2013	(r253222)
@@ -644,7 +644,8 @@ public:
     _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {}
 
     _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
-    _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+        {return pointer_traits::pointer_to(__ptr_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __tree_iterator& operator++()
@@ -686,7 +687,7 @@ class _LIBCPP_TYPE_VIS __tree_const_iter
 {
     typedef _ConstNodePtr                                         __node_pointer;
     typedef typename pointer_traits<__node_pointer>::element_type __node;
-    typedef const typename __node::base                           __node_base;
+    typedef typename __node::base                                 __node_base;
     typedef typename pointer_traits<__node_pointer>::template
 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
             rebind<__node_base>
@@ -729,7 +730,8 @@ public:
         : __ptr_(__p.__ptr_) {}
 
     _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
-    _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+        {return pointer_traits::pointer_to(__ptr_->__value_);}
 
     _LIBCPP_INLINE_VISIBILITY
     __tree_const_iterator& operator++()
@@ -779,8 +781,10 @@ public:
     typedef typename __alloc_traits::size_type       size_type;
     typedef typename __alloc_traits::difference_type difference_type;
 
-    typedef __tree_node __node;
-    typedef __tree_node_base __node_base;
+    typedef typename __alloc_traits::void_pointer  __void_pointer;
+
+    typedef __tree_node __node;
+    typedef __tree_node_base<__void_pointer>        __node_base;
     typedef typename __alloc_traits::template
 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
             rebind_alloc<__node>
@@ -790,9 +794,9 @@ public:
                                                      __node_allocator;
     typedef allocator_traits<__node_allocator>       __node_traits;
     typedef typename __node_traits::pointer          __node_pointer;
-    typedef typename __node_traits::const_pointer    __node_const_pointer;
+    typedef typename __node_traits::pointer          __node_const_pointer;
     typedef typename __node_base::pointer            __node_base_pointer;
-    typedef typename __node_base::const_pointer      __node_base_const_pointer;
+    typedef typename __node_base::pointer            __node_base_const_pointer;
 private:
     typedef typename __node_base::base __end_node_t;
     typedef typename pointer_traits<__node_pointer>::template
@@ -804,9 +808,9 @@ private:
                                                      __end_node_ptr;
     typedef typename pointer_traits<__node_pointer>::template
 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-            rebind
+            rebind<__end_node_t>
 #else
-            rebind::other
+            rebind<__end_node_t>::other
 #endif
                                                      __end_node_const_ptr;
 
@@ -828,7 +832,7 @@ public:
     {
         return static_cast<__node_const_pointer>
                (
-                   pointer_traits<__end_node_const_ptr>::pointer_to(__pair1_.first())
+                   pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))
                );
     }
     _LIBCPP_INLINE_VISIBILITY
@@ -865,7 +869,7 @@ public:
         {return static_cast<__node_const_pointer>(__end_node()->__left_);}
 
     typedef __tree_iterator             iterator;
-    typedef __tree_const_iterator const_iterator;
+    typedef __tree_const_iterator const_iterator;
 
     explicit __tree(const value_compare& __comp)
         _NOEXCEPT_(
@@ -1102,6 +1106,9 @@ private:
 
     __node_pointer __detach();
     static __node_pointer __detach(__node_pointer);
+
+    template  friend class _LIBCPP_TYPE_VIS map;
+    template  friend class _LIBCPP_TYPE_VIS multimap;
 };
 
 template 
@@ -1161,7 +1168,7 @@ __tree<_Tp, _Compare, _Allocator>::__det
 {
     if (__cache->__parent_ == nullptr)
         return nullptr;
-    if (__tree_is_left_child(__cache))
+    if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
     {
         __cache->__parent_->__left_ = nullptr;
         __cache = static_cast<__node_pointer>(__cache->__parent_);
@@ -1294,7 +1301,7 @@ __tree<_Tp, _Compare, _Allocator>::__tre
         __begin_node() = __end_node();
     else
     {
-        __end_node()->__left_->__parent_ = __end_node();
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
         __t.__begin_node() = __t.__end_node();
         __t.__end_node()->__left_ = nullptr;
         __t.size() = 0;
@@ -1314,7 +1321,7 @@ __tree<_Tp, _Compare, _Allocator>::__tre
         {
             __begin_node() = __t.__begin_node();
             __end_node()->__left_ = __t.__end_node()->__left_;
-            __end_node()->__left_->__parent_ = __end_node();
+            __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
             size() = __t.size();
             __t.__begin_node() = __t.__end_node();
             __t.__end_node()->__left_ = nullptr;
@@ -1342,7 +1349,7 @@ __tree<_Tp, _Compare, _Allocator>::__mov
         __begin_node() = __end_node();
     else
     {
-        __end_node()->__left_->__parent_ = __end_node();
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
         __t.__begin_node() = __t.__end_node();
         __t.__end_node()->__left_ = nullptr;
         __t.size() = 0;
@@ -1447,11 +1454,11 @@ __tree<_Tp, _Compare, _Allocator>::swap(
     if (size() == 0)
         __begin_node() = __end_node();
     else
-        __end_node()->__left_->__parent_ = __end_node();
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
     if (__t.size() == 0)
         __t.__begin_node() = __t.__end_node();
     else
-        __t.__end_node()->__left_->__parent_ = __t.__end_node();
+        __t.__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__t.__end_node());
 }
 
 template 
@@ -1483,7 +1490,7 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__right_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__right_;
                 }
             }
@@ -1493,13 +1500,13 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__left_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__left_;
                 }
             }
         }
     }
-    __parent = __end_node();
+    __parent = static_cast<__node_base_pointer>(__end_node());
     return __parent->__left_;
 }
 
@@ -1522,7 +1529,7 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__left_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__left_;
                 }
             }
@@ -1532,13 +1539,13 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__right_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__right_;
                 }
             }
         }
     }
-    __parent = __end_node();
+    __parent = static_cast<__node_base_pointer>(__end_node());
     return __parent->__left_;
 }
 
@@ -1563,12 +1570,12 @@ __tree<_Tp, _Compare, _Allocator>::__fin
             // *prev(__hint) <= __v <= *__hint
             if (__hint.__ptr_->__left_ == nullptr)
             {
-                __parent = const_cast<__node_pointer&>(__hint.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
                 return __parent->__left_;
             }
             else
             {
-                __parent = const_cast<__node_pointer&>(__prior.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__prior.__ptr_);
                 return __parent->__right_;
             }
         }
@@ -1600,7 +1607,7 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__left_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__left_;
                 }
             }
@@ -1610,18 +1617,18 @@ __tree<_Tp, _Compare, _Allocator>::__fin
                     __nd = static_cast<__node_pointer>(__nd->__right_);
                 else
                 {
-                    __parent = __nd;
+                    __parent = static_cast<__node_base_pointer>(__nd);
                     return __parent->__right_;
                 }
             }
             else
             {
-                __parent = __nd;
+                __parent = static_cast<__node_base_pointer>(__nd);
                 return __parent;
             }
         }
     }
-    __parent = __end_node();
+    __parent = static_cast<__node_base_pointer>(__end_node());
     return __parent->__left_;
 }
 
@@ -1648,12 +1655,12 @@ __tree<_Tp, _Compare, _Allocator>::__fin
             // *prev(__hint) < __v < *__hint
             if (__hint.__ptr_->__left_ == nullptr)
             {
-                __parent = const_cast<__node_pointer&>(__hint.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
                 return __parent->__left_;
             }
             else
             {
-                __parent = const_cast<__node_pointer&>(__prior.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__prior.__ptr_);
                 return __parent->__right_;
             }
         }
@@ -1669,12 +1676,12 @@ __tree<_Tp, _Compare, _Allocator>::__fin
             // *__hint < __v < *_VSTD::next(__hint)
             if (__hint.__ptr_->__right_ == nullptr)
             {
-                __parent = const_cast<__node_pointer&>(__hint.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
                 return __parent->__right_;
             }
             else
             {
-                __parent = const_cast<__node_pointer&>(__next.__ptr_);
+                __parent = static_cast<__node_base_pointer>(__next.__ptr_);
                 return __parent->__left_;
             }
         }
@@ -1682,7 +1689,7 @@ __tree<_Tp, _Compare, _Allocator>::__fin
         return __find_equal(__parent, __v);
     }
     // else __v == *__hint
-    __parent = const_cast<__node_pointer&>(__hint.__ptr_);
+    __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
     return __parent;
 }
 
@@ -1729,7 +1736,7 @@ __tree<_Tp, _Compare, _Allocator>::__emp
     bool __inserted = false;
     if (__child == nullptr)
     {
-        __insert_node_at(__parent, __child, __h.get());
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
         __r = __h.release();
         __inserted = true;
     }
@@ -1747,7 +1754,7 @@ __tree<_Tp, _Compare, _Allocator>::__emp
     __node_pointer __r = static_cast<__node_pointer>(__child);
     if (__child == nullptr)
     {
-        __insert_node_at(__parent, __child, __h.get());
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
         __r = __h.release();
     }
     return iterator(__r);
@@ -1761,7 +1768,7 @@ __tree<_Tp, _Compare, _Allocator>::__emp
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
     __node_base_pointer __parent;
     __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
-    __insert_node_at(__parent, __child, __h.get());
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
     return iterator(static_cast<__node_pointer>(__h.release()));
 }
 
@@ -1774,7 +1781,7 @@ __tree<_Tp, _Compare, _Allocator>::__emp
     __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);

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

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 22:02:13 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id E3A5F5E3;
 Thu, 11 Jul 2013 22:02:13 +0000 (UTC) (envelope-from ken@kdm.org)
Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81])
 by mx1.freebsd.org (Postfix) with ESMTP id 7CF851861;
 Thu, 11 Jul 2013 22:02:13 +0000 (UTC)
Received: from nargothrond.kdm.org (localhost [127.0.0.1])
 by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id r6BM2C22030411;
 Thu, 11 Jul 2013 16:02:12 -0600 (MDT)
 (envelope-from ken@nargothrond.kdm.org)
Received: (from ken@localhost)
 by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id r6BM2B7W030410;
 Thu, 11 Jul 2013 16:02:11 -0600 (MDT) (envelope-from ken)
Date: Thu, 11 Jul 2013 16:02:11 -0600
From: "Kenneth D. Merry" 
To: Andre Albsmeier 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130711220211.GA30392@nargothrond.kdm.org>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali> <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali> <20130710184915.GA28790@nargothrond.kdm.org>
 <20130710185833.GA83135@bali> <20130711205332.GA26100@nargothrond.kdm.org>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="9amGYk9869ThD9tj"
Content-Disposition: inline
In-Reply-To: <20130711205332.GA26100@nargothrond.kdm.org>
User-Agent: Mutt/1.4.2i
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 22:02:14 -0000


--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Jul 11, 2013 at 14:53:32 -0600, Kenneth D. Merry wrote:
> On Wed, Jul 10, 2013 at 20:58:33 +0200, Andre Albsmeier wrote:
> > On Wed, 10-Jul-2013 at 20:49:15 +0200, Kenneth D. Merry wrote:
> > > On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> > > > On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > > > > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > > > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > > > > Author: ken
> > > > > > > Date: Tue Jun 25 21:43:49 2013
> > > > > > > New Revision: 252214
> > > > > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > > > > 
> > > > > > Hi Ken,
> > > > > > 
> > > > > > > Log:
> > > > > > >   MFC: 249658, 249701
> > > > > > > 
> > > > > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > > > > 
> > > > > > >   This allows mapping a tape drive in a changer (as reported by
> > > > > > >   'chio status') to a sa(4) driver instance by comparing the
> > > > > > >   serial numbers.
> > > > > > > 
> > > > > > >   The designators can be ASCII (which is printed out directly), binary
> > > > > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > > > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > > > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > > > > >   explanation and example UTF-8 printing code.
> > > > > > > 
> > > > > > >   chio.h:               Modify the changer_element_status structure to add new
> > > > > > >                 fields and definitions from the SMC3r16 spec.
> > > > > > > 
> > > > > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > > > > >                 define a new CHIOGSTATUS ioctl.
> > > > > > > 
> > > > > > >                 Clean up some tab/space issues.
> > > > > > > 
> > > > > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > > > > >                 if it is supplied by a device.
> > > > > > > 
> > > > > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > > > > >                 ELEMENT STATUS command structure.
> > > > > > > 
> > > > > > >                 Add a read_element_status_device_id structure
> > > > > > >                 for the data fields in the new standard. Add new
> > > > > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > > > > >                 and address data from either SCSI-2 or newer devices.
> > > > > > > 
> > > > > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > > > > >                 ELEMENT STATUS data.
> > > > > > > 
> > > > > > >                 Add new arguments to scsi_read_element_status() to
> > > > > > >                 allow the user to request the DVCID and CURDATA bits.
> > > > > > 
> > > > > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > > > > 
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > > > > 
> > > > > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > > > > this workaround to make it work again until a better solution is available:
> > > > > > 
> > > > > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > > > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > > > > @@ -1245,8 +1245,8 @@
> > > > > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > > > > >  				 /* voltag */ want_voltags,
> > > > > >  				 /* sea */ softc->sc_firsts[chet],
> > > > > > -				 /* dvcid */ 1,
> > > > > > -				 /* curdata */ 1,
> > > > > > +				 /* dvcid */ 0,
> > > > > > +				 /* curdata */ 0,
> > > > > >  				 /* count */ 1,
> > > > > >  				 /* data_ptr */ data,
> > > > > >  				 /* dxfer_len */ 1024,
> > > > > > @@ -1284,8 +1284,8 @@
> > > > > >  				 /* voltag */ want_voltags,
> > > > > >  				 /* sea */ softc->sc_firsts[chet]
> > > > > >  				 + cesr->cesr_element_base,
> > > > > > -				 /* dvcid */ 1,
> > > > > > -				 /* curdata */ 1,
> > > > > > +				 /* dvcid */ 0,
> > > > > > +				 /* curdata */ 0,
> > > > > >  				 /* count */ cesr->cesr_element_count,
> > > > > >  				 /* data_ptr */ data,
> > > > > >  				 /* dxfer_len */ size,
> > > > > > 
> > > > > > 	-Andre
> > > > > 
> > > > > Oops, sorry.
> > > > > 
> > > > > We need to check the SCSI version to see whether to set those bits, and
> > > > > also fall back in case it doesn't work.
> > > > > 
> > > > > I am on vacation and have very spotty net access.  I can't do anything
> > > > > about it until I get back next week.
> > > > > 
> > > > > Justin and Alan (CCed) can work on the fix, though.
> > > > 
> > > > Take your time, for me it's working right now
> > > > with the above patch...
> > > 
> > > Okay, I'm back and can take a look at this.
> > 
> > Welcome back ;-)
> > 
> > > 
> > > Can you send me:
> > 
> > Sure, I am happy to help.
> > 
> > > 
> > > camcontrol inquiry ch0 -v
> > 
> > pass17:  Removable Changer SCSI-2 device 
> > pass17: Serial Number 0021009613
> > pass17: 3.300MB/s transfers
> > 
> > > camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"
> > 
> > 0 0 0 0 0 0 0 0 
> 
> Okay, that was helpful, thanks!
> 
> > > 
> > > I want to see what SCSI version this changer reports.  The second command
> > > will print out the SCSI version descriptors, if any, that the changer
> > > reports.
> > 
> > In case you need more info just drop me a note.
> > 
> > Thanks for looking into this.
> 
> Can you try the attached patch, and see how it works for you?
> 
> It defaults to not setting those bits for changers that claim to be SCSI-2
> or below.  And if a SCSI-3 or higher changer returns an Illegal Request
> type error, it will retry with the bits cleared to see whether that works.
> 
> I also bumped the read element status timeout after some testing with a
> Spectra T-380.
> 
> The patch is against head, but stable/9 shouldn't be much different.

Oops, here is the patch.

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG

--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="scsi_ch.c.read_element_status.20130711.txt"

==== //depot/users/kenm/FreeBSD-test4/sys/cam/scsi/scsi_ch.c#6 - /usr/home/kenm/perforce4/kenm/FreeBSD-test4/sys/cam/scsi/scsi_ch.c ====
*** /tmp/tmp.49464.18	Thu Jul 11 14:45:15 2013
--- /usr/home/kenm/perforce4/kenm/FreeBSD-test4/sys/cam/scsi/scsi_ch.c	Thu Jul 11 14:43:14 2013
***************
*** 102,108 ****
  static const u_int32_t	CH_TIMEOUT_MOVE_MEDIUM               = 100000;
  static const u_int32_t	CH_TIMEOUT_EXCHANGE_MEDIUM           = 100000;
  static const u_int32_t	CH_TIMEOUT_POSITION_TO_ELEMENT       = 100000;
! static const u_int32_t	CH_TIMEOUT_READ_ELEMENT_STATUS       = 10000;
  static const u_int32_t	CH_TIMEOUT_SEND_VOLTAG		     = 10000;
  static const u_int32_t	CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000;
  
--- 102,108 ----
  static const u_int32_t	CH_TIMEOUT_MOVE_MEDIUM               = 100000;
  static const u_int32_t	CH_TIMEOUT_EXCHANGE_MEDIUM           = 100000;
  static const u_int32_t	CH_TIMEOUT_POSITION_TO_ELEMENT       = 100000;
! static const u_int32_t	CH_TIMEOUT_READ_ELEMENT_STATUS       = 60000;
  static const u_int32_t	CH_TIMEOUT_SEND_VOLTAG		     = 10000;
  static const u_int32_t	CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000;
  
***************
*** 122,133 ****
  
  typedef enum {
  	CH_Q_NONE	= 0x00,
! 	CH_Q_NO_DBD	= 0x01
  } ch_quirks;
  
  #define CH_Q_BIT_STRING	\
  	"\020"		\
! 	"\001NO_DBD"
  
  #define ccb_state	ppriv_field0
  #define ccb_bp		ppriv_ptr1
--- 122,135 ----
  
  typedef enum {
  	CH_Q_NONE	= 0x00,
! 	CH_Q_NO_DBD	= 0x01,
! 	CH_Q_NO_DVCID	= 0x02
  } ch_quirks;
  
  #define CH_Q_BIT_STRING	\
  	"\020"		\
! 	"\001NO_DBD"	\
! 	"\002NO_DVCID"
  
  #define ccb_state	ppriv_field0
  #define ccb_bp		ppriv_ptr1
***************
*** 396,401 ****
--- 398,411 ----
  	periph->softc = softc;
  	softc->quirks = CH_Q_NONE;
  
+ 	/*
+ 	 * The DVCID and CURDATA bits were not introduced until the SMC
+ 	 * spec.  If this device claims SCSI-2 or earlier support, then it
+ 	 * very likely does not support these bits.
+ 	 */
+ 	if (cgd->inq_data.version <= SCSI_REV_2)
+ 		softc->quirks |= CH_Q_NO_DVCID;
+ 
  	bzero(&cpi, sizeof(cpi));
  	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
  	cpi.ccb_h.func_code = XPT_PATH_INQ;
***************
*** 1208,1213 ****
--- 1218,1225 ----
  	caddr_t data = NULL;
  	size_t size, desclen;
  	int avail, i, error = 0;
+ 	int curdata, dvcid, sense_flags;
+ 	int try_no_dvcid = 0;
  	struct changer_element_status *user_data = NULL;
  	struct ch_softc *softc;
  	union ccb *ccb;
***************
*** 1239,1252 ****
  	cam_periph_lock(periph);
  	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
  
  	scsi_read_element_status(&ccb->csio,
  				 /* retries */ 1,
  				 /* cbfcnp */ chdone,
  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
  				 /* voltag */ want_voltags,
  				 /* sea */ softc->sc_firsts[chet],
! 				 /* dvcid */ 1,
! 				 /* curdata */ 1,
  				 /* count */ 1,
  				 /* data_ptr */ data,
  				 /* dxfer_len */ 1024,
--- 1251,1281 ----
  	cam_periph_lock(periph);
  	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
  
+ 	sense_flags = SF_RETRY_UA;
+ 	if (softc->quirks & CH_Q_NO_DVCID) {
+ 		dvcid = 0;
+ 		curdata = 0;
+ 	} else {
+ 		dvcid = 1;
+ 		curdata = 1;
+ 		/*
+ 		 * Don't print anything for an Illegal Request, because
+ 		 * these flags can cause some changers to complain.  We'll
+ 		 * retry without them if we get an error.
+ 		 */
+ 		sense_flags |= SF_QUIET_IR;
+ 	}
+ 
+ retry_einval:
+ 
  	scsi_read_element_status(&ccb->csio,
  				 /* retries */ 1,
  				 /* cbfcnp */ chdone,
  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
  				 /* voltag */ want_voltags,
  				 /* sea */ softc->sc_firsts[chet],
! 				 /* dvcid */ dvcid,
! 				 /* curdata */ curdata,
  				 /* count */ 1,
  				 /* data_ptr */ data,
  				 /* dxfer_len */ 1024,
***************
*** 1254,1262 ****
  				 /* timeout */ CH_TIMEOUT_READ_ELEMENT_STATUS);
  
  	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
! 				  /*sense_flags*/ SF_RETRY_UA,
  				  softc->device_stats);
  
  	if (error)
  		goto done;
  	cam_periph_unlock(periph);
--- 1283,1320 ----
  				 /* timeout */ CH_TIMEOUT_READ_ELEMENT_STATUS);
  
  	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
! 				  /*sense_flags*/ sense_flags,
  				  softc->device_stats);
  
+ 	/*
+ 	 * An Illegal Request sense key (only used if there is no asc/ascq)
+ 	 * or 0x24,0x00 for an ASC/ASCQ both map to EINVAL.  If dvcid or
+ 	 * curdata are set (we set both or neither), try turning them off
+ 	 * and see if the command is successful.
+ 	 */
+ 	if ((error == EINVAL)
+ 	 && (dvcid || curdata))  {
+ 		dvcid = 0;
+ 		curdata = 0;
+ 		error = 0;
+ 		/* At this point we want to report any Illegal Request */
+ 		sense_flags &= ~SF_QUIET_IR;
+ 		try_no_dvcid = 1;
+ 		goto retry_einval;
+ 	}
+ 
+ 	/*
+ 	 * In this case, we tried a read element status with dvcid and
+ 	 * curdata set, and it failed.  We retried without those bits, and
+ 	 * it succeeded.  Suggest to the user that he set a quirk, so we
+ 	 * don't go through the retry process the first time in the future.
+ 	 * This should only happen on changers that claim SCSI-3 or higher,
+ 	 * but don't support these bits.
+ 	 */
+ 	if ((try_no_dvcid != 0)
+ 	 && (error == 0))
+ 		softc->quirks |= CH_Q_NO_DVCID;
+ 
  	if (error)
  		goto done;
  	cam_periph_unlock(periph);
***************
*** 1284,1291 ****
  				 /* voltag */ want_voltags,
  				 /* sea */ softc->sc_firsts[chet]
  				 + cesr->cesr_element_base,
! 				 /* dvcid */ 1,
! 				 /* curdata */ 1,
  				 /* count */ cesr->cesr_element_count,
  				 /* data_ptr */ data,
  				 /* dxfer_len */ size,
--- 1342,1349 ----
  				 /* voltag */ want_voltags,
  				 /* sea */ softc->sc_firsts[chet]
  				 + cesr->cesr_element_base,
! 				 /* dvcid */ dvcid,
! 				 /* curdata */ curdata,
  				 /* count */ cesr->cesr_element_count,
  				 /* data_ptr */ data,
  				 /* dxfer_len */ size,

--9amGYk9869ThD9tj--

From owner-svn-src-stable-9@FreeBSD.ORG  Thu Jul 11 22:15:15 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 1FDECA5B;
 Thu, 11 Jul 2013 22:15:15 +0000 (UTC)
 (envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 1145C18FB;
 Thu, 11 Jul 2013 22:15:15 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BMFEfr041623;
 Thu, 11 Jul 2013 22:15:14 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BMFEjb041622;
 Thu, 11 Jul 2013 22:15:14 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201307112215.r6BMFEjb041622@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Thu, 11 Jul 2013 22:15:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253223 - stable/9/bin/test
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 11 Jul 2013 22:15:15 -0000

Author: jilles
Date: Thu Jul 11 22:15:14 2013
New Revision: 253223
URL: http://svnweb.freebsd.org/changeset/base/253223

Log:
  MFC r251211: test(1): Add information about replacing -nt/-ot.

Modified:
  stable/9/bin/test/test.1
Directory Properties:
  stable/9/bin/test/   (props changed)

Modified: stable/9/bin/test/test.1
==============================================================================
--- stable/9/bin/test/test.1	Thu Jul 11 21:33:03 2013	(r253222)
+++ stable/9/bin/test/test.1	Thu Jul 11 22:15:14 2013	(r253223)
@@ -331,6 +331,20 @@ missing.
 .It >1
 An error occurred.
 .El
+.Sh EXAMPLES
+Implement
+.Li test FILE1 -nt FILE2
+using only
+.Tn POSIX
+functionality:
+.Pp
+.Dl test -n \&"$(find -L -- FILE1 -prune -newer FILE2 2>/dev/null)\&"
+.Pp
+This can be modified using non-standard
+.Xr find 1
+primaries like
+.Cm -newerca
+to compare other timestamps.
 .Sh COMPATIBILITY
 For compatibility with some other implementations,
 the
@@ -341,7 +355,9 @@ with the same meaning.
 .Sh SEE ALSO
 .Xr builtin 1 ,
 .Xr expr 1 ,
+.Xr find 1 ,
 .Xr sh 1 ,
+.Xr stat 1 ,
 .Xr symlink 7
 .Sh STANDARDS
 The

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 00:40:50 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 6005E2D1;
 Fri, 12 Jul 2013 00:40:50 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 41CE21F6E;
 Fri, 12 Jul 2013 00:40:50 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C0eoqJ084379;
 Fri, 12 Jul 2013 00:40:50 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C0enbB084376;
 Fri, 12 Jul 2013 00:40:49 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120040.r6C0enbB084376@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 00:40:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253227 - in stable/9: etc etc/rc.d share/man/man5
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 00:40:50 -0000

Author: hrs
Date: Fri Jul 12 00:40:49 2013
New Revision: 253227
URL: http://svnweb.freebsd.org/changeset/base/253227

Log:
  MFC 230453, 230726, 252015, 252426:
  
  - ipv6_enable + ipv6_gateway_enable should unset ACCEPT_RTADV by default for
    backward compatibility.
  
  - Configurations in ipv6_prefix_IF should be recognized even if there is no
    ifconfig_IF_ipv6.
  
  - DAD wait should be performed at once, not on a per-interface basis, if
    possible.  This fixes an issue that a system with a lot of IPv6-capable
    interfaces takes too long for booting.
  
  - Add CIDR notation support like 192.168.1-2.10-16/24 to $ifconfig_IF_aliasN.
    This is an extended version of ipv4_addr_IF which supports both IPv4 and
    IPv6, and multiple range specifications.  To avoid to generate too many
    addresses, the maximum number of the generated addresses is currently
    limited to 31.
  
  - Add $ifconfig_IF_aliases, which accepts multiple IP aliases in a variable.
  
  - ipv6_prefix_IF now supports !/64 prefix length.  In addition to the old
    64-bit format (2001:db8:1:1), a full 128-bit format like 2001:db8:1:1::/64
    is supported.
  
  - Replace ifconfig command with $IFCONFIG_CMD variable to support
    a dry-run mode in the future.
  
  - Remove IP aliases before removing all of IPv4 addresses when doing
    "rc.d/netif down".
  
  - Add a DAD wait to network6_getladdr() because it is possible to fail to
    configure an EUI64 address when ipv6_prefix_IF is specified.

Modified:
  stable/9/etc/network.subr
  stable/9/etc/rc.d/netif
  stable/9/share/man/man5/rc.conf.5
Directory Properties:
  stable/9/etc/   (props changed)
  stable/9/etc/rc.d/   (props changed)
  stable/9/share/man/man5/   (props changed)

Modified: stable/9/etc/network.subr
==============================================================================
--- stable/9/etc/network.subr	Thu Jul 11 23:35:51 2013	(r253226)
+++ stable/9/etc/network.subr	Fri Jul 12 00:40:49 2013	(r253227)
@@ -24,6 +24,10 @@
 #
 # $FreeBSD$
 #
+IFCONFIG_CMD="/sbin/ifconfig"
+
+# Maximum number of addresses expanded from a address range specification.
+_IPEXPANDMAX=31
 
 #
 # Subroutines commonly used from network startup scripts.
@@ -94,7 +98,7 @@ ifconfig_up()
 	# ifconfig_IF
 	ifconfig_args=`ifconfig_getargs $1`
 	if [ -n "${ifconfig_args}" ]; then
-		eval ifconfig $1 ${ifconfig_args}
+		eval ${IFCONFIG_CMD} $1 ${ifconfig_args}
 		_cfg=0
 	fi
 
@@ -122,7 +126,7 @@ ifconfig_up()
 		esac
 
 		if [ -n "${_ipv6_opts}" ]; then
-			ifconfig $1 inet6 ${_ipv6_opts}
+			${IFCONFIG_CMD} $1 inet6 ${_ipv6_opts}
 		fi
 
 		# ifconfig_IF_ipv6
@@ -136,24 +140,35 @@ ifconfig_up()
 				ifconfig_args="inet6 ${ifconfig_args}"
 			;;
 			esac
-			ifconfig $1 inet6 -ifdisabled
-			eval ifconfig $1 ${ifconfig_args}
+			${IFCONFIG_CMD} $1 inet6 -ifdisabled
+			eval ${IFCONFIG_CMD} $1 ${ifconfig_args}
+			_cfg=0
+		fi
+
+		# $ipv6_prefix_IF will be handled in
+		# ipv6_prefix_hostid_addr_common().
+		ifconfig_args=`get_if_var $1 ipv6_prefix_IF`
+		if [ -n "${ifconfig_args}" ]; then
+			${IFCONFIG_CMD} $1 inet6 -ifdisabled
 			_cfg=0
 		fi
 
-		# backward compatiblity: $ipv6_ifconfig_IF
+		# backward compatibility: $ipv6_ifconfig_IF
 		ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF`
 		if [ -n "${ifconfig_args}" ]; then
 			warn "\$ipv6_ifconfig_$1 is obsolete." \
 			    "  Use ifconfig_$1_ipv6 instead."
-			ifconfig $1 inet6 -ifdisabled
-			eval ifconfig $1 inet6 ${ifconfig_args}
+			${IFCONFIG_CMD} $1 inet6 -ifdisabled
+			eval ${IFCONFIG_CMD} $1 inet6 ${ifconfig_args}
 			_cfg=0
 		fi
 	fi
 
+	ifalias $1 link alias
+	ifalias $1 ether alias
+
 	if [ ${_cfg} -eq 0 ]; then
-		ifconfig $1 up
+		${IFCONFIG_CMD} $1 up
 	fi
 
 	if wpaif $1; then
@@ -166,7 +181,7 @@ ifconfig_up()
 
 	if dhcpif $1; then
 		if [ $_cfg -ne 0 ] ; then
-			ifconfig $1 up
+			${IFCONFIG_CMD} $1 up
 		fi
 		if syncdhcpif $1; then
 			/etc/rc.d/dhclient start $1
@@ -200,7 +215,7 @@ ifconfig_down()
 	fi
 
 	if ifexists $1; then
-		ifconfig $1 down
+		${IFCONFIG_CMD} $1 down
 		_cfg=0
 	fi
 
@@ -420,6 +435,9 @@ afexists()
 			return 1
 		fi
 		;;
+	link|ether)
+		return 0
+		;;
 	*)
 		err 1 "afexists(): Unsupported address family: $_af"
 		;;
@@ -559,7 +577,7 @@ ipv6_autoconfif()
 ifexists()
 {
 	[ -z "$1" ] && return 1
-	ifconfig -n $1 > /dev/null 2>&1
+	${IFCONFIG_CMD} -n $1 > /dev/null 2>&1
 }
 
 # ipv4_up if
@@ -574,11 +592,10 @@ ipv4_up()
 	if [ "${_if}" = "lo0" ]; then
 		ifconfig_args=`get_if_var ${_if} ifconfig_IF`
 		if [ -z "${ifconfig_args}" ]; then
-			ifconfig ${_if} inet 127.0.0.1/8 alias
+			${IFCONFIG_CMD} ${_if} inet 127.0.0.1/8 alias
 		fi
 	fi
-	ifalias_up ${_if} inet && _ret=0
-	ipv4_addrs_common ${_if} alias && _ret=0
+	ifalias ${_if} inet alias && _ret=0
 
 	return $_ret
 }
@@ -595,7 +612,7 @@ ipv6_up()
 		return 0
 	fi
 
-	ifalias_up ${_if} inet6 && _ret=0
+	ifalias ${_if} inet6 alias && _ret=0
 	ipv6_prefix_hostid_addr_common ${_if} alias && _ret=0
 	ipv6_accept_rtadv_up ${_if} && _ret=0
 
@@ -615,7 +632,9 @@ ipv4_down()
 	_ifs="^"
 	_ret=1
 
-	inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`"
+	ifalias ${_if} inet -alias && _ret=0
+
+	inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet ' | tr "\n" "$_ifs"`"
 
 	oldifs="$IFS"
 	IFS="$_ifs"
@@ -626,15 +645,12 @@ ipv4_down()
 		_inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'`
 
 		IFS="$oldifs"
-		ifconfig ${_if} ${_inet} delete
+		${IFCONFIG_CMD} ${_if} ${_inet} delete
 		IFS="$_ifs"
 		_ret=0
 	done
 	IFS="$oldifs"
 
-	ifalias_down ${_if} inet && _ret=0
-	ipv4_addrs_common ${_if} -alias && _ret=0
-
 	return $_ret
 }
 
@@ -653,9 +669,9 @@ ipv6_down()
 
 	ipv6_accept_rtadv_down ${_if} && _ret=0
 	ipv6_prefix_hostid_addr_common ${_if} -alias && _ret=0
-	ifalias_down ${_if} inet6 && _ret=0
+	ifalias ${_if} inet6 -alias && _ret=0
 
-	inetList="`ifconfig ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`"
+	inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`"
 
 	oldifs="$IFS"
 	IFS="$_ifs"
@@ -666,7 +682,7 @@ ipv6_down()
 		_inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'`
 
 		IFS="$oldifs"
-		ifconfig ${_if} ${_inet6} -alias
+		${IFCONFIG_CMD} ${_if} ${_inet6} -alias
 		IFS="$_ifs"
 		_ret=0
 	done
@@ -675,234 +691,356 @@ ipv6_down()
 	return $_ret
 }
 
-# ipv4_addrs_common if action
-#	Evaluate the ifconfig_if_ipv4 arguments for interface $if and
-#	use $action to add or remove IPv4 addresses from $if.
-ipv4_addrs_common()
-{
-	local _ret _if _action _cidr _cidr_addr
-	local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
-	_ret=1
-	_if=$1
-	_action=$2
-
-	# get ipv4-addresses
-	cidr_addr=`get_if_var $_if ipv4_addrs_IF`
-
-	for _cidr in ${cidr_addr}; do
-		_ipaddr=${_cidr%%/*}
-		_netmask="/"${_cidr##*/}
-		_range=${_ipaddr##*.}
-		_ipnet=${_ipaddr%.*}
-		_iplow=${_range%-*}
-		_iphigh=${_range#*-}
-
-		# clear netmask when removing aliases
-		if [ "${_action}" = "-alias" ]; then
-			_netmask=""
-		fi
-
-		_ipcount=${_iplow}
-		while [ "${_ipcount}" -le "${_iphigh}" ]; do
-			eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
-			_ipcount=$((${_ipcount}+1))
-			_ret=0
-
-			# only the first ipaddr in a subnet need the real netmask
-			if [ "${_action}" != "-alias" ]; then
-				_netmask="/32"
-			fi
-		done
-	done
-
-	return $_ret
-}
-
-# ifalias_up if af
-#	Configure aliases for network interface $if.
+# ifalias if af action
+#	Configure or remove aliases for network interface $if.
 #	It returns 0 if at least one alias was configured or
-#	1 if there were none.
+#	removed, or 1 if there were none.
 #
-ifalias_up()
+ifalias()
 {
 	local _ret
 	_ret=1
 
+	afexists $2 || return $_ret
+
 	case "$2" in
-	inet)
-		_ret=`ifalias_ipv4_up "$1"`
-		;;
-	inet6)
-		_ret=`ifalias_ipv6_up "$1"`
+	inet|inet6|link|ether)
+		ifalias_af_common $1 $2 $3 && _ret=0
 		;;
 	esac
 
 	return $_ret
 }
 
-# ifalias_ipv4_up if
-#	Helper function for ifalias_up().  Handles IPv4.
+# ifalias_expand_addr af action addr
+#	Expand address range ("N-M") specification in addr.
+#	"addr" must not include an address-family keyword.
+#	The results will include an address-family keyword.
 #
-ifalias_ipv4_up()
+ifalias_expand_addr()
 {
-	local _ret alias ifconfig_args
-	_ret=1
-
-	# ifconfig_IF_aliasN which starts with "inet"
-	alias=0
-	while : ; do
-		ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		inet\ *)
-			ifconfig $1 ${ifconfig_args} alias && _ret=0
-			;;
-		inet6\ *)
-			;;
-		"")
-			break
-			;;
-		*)
-			warn "\$ifconfig_$1_alias${alias} needs " \
-			    "\"inet\" keyword for an IPv4 address."
-			ifconfig $1 ${ifconfig_args} alias && _ret=0
-			;;
-		esac
-		alias=$((${alias} + 1))
-	done
 
-	return $_ret
+	afexists $1 || return
+	ifalias_expand_addr_$1 $2 $3
 }
 
-# ifalias_ipv6_up if
-#	Helper function for ifalias_up().  Handles IPv6.
+# ifalias_expand_addr_inet action addr
+#	Helper function for ifalias_expand_addr().  Handles IPv4.
 #
-ifalias_ipv6_up()
+ifalias_expand_addr_inet()
 {
-	local _ret alias ifconfig_args
-	_ret=1
+	local _action _arg _cidr _cidr_addr
+	local _ipaddr _plen _range _iphead _iptail _iplow _iphigh _ipcount
+	local _retstr _c
+	_action=$1
+	_arg=$2
+	_retstr=
 
-	# ifconfig_IF_aliasN which starts with "inet6"
-	alias=0
-	while : ; do
-		ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		inet6\ *)
-			ifconfig $1 ${ifconfig_args} alias && _ret=0
-			;;
-		"")
-			break
-			;;
+	case $_action:$_arg in
+	*:*--*)		return ;;			# invalid
+	tmp:*)		echo $_arg && return ;;		# already expanded
+	tmp:*-*)	_action="alias"	;;		# to be expanded
+	*:*-*)		;;				# to be expanded
+	*:*)		echo inet $_arg && return ;;	# already expanded
+	esac
+
+	for _cidr in $_arg; do
+		_ipaddr=${_cidr%%/*}
+		_plen=${_cidr##*/}
+		# When subnet prefix length is not specified, use /32.
+		case $_plen in
+		$_ipaddr)	_plen=32 ;;	# "/" character not found
 		esac
-		alias=$((${alias} + 1))
-	done
 
-	# backward compatibility: ipv6_ifconfig_IF_aliasN.
-	alias=0
-	while : ; do
-		ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		"")
-			break
+		OIFS=$IFS
+		IFS=. set -- $_ipaddr
+		_range=
+		_iphead=
+		_iptail=
+		for _c in $@; do
+			case $_range:$_c in
+			:[0-9]*-[0-9]*)
+				_range=$_c
 			;;
-		*)
-			ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0
-			warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
-			    "  Use ifconfig_$1_aliasN instead."
+			:*)
+				_iphead="${_iphead}${_iphead:+.}${_c}"
 			;;
-		esac
-		alias=$((${alias} + 1))
+			*:*)
+				_iptail="${_iptail}${_iptail:+.}${_c}"
+			;;
+			esac
+		done
+		IFS=$OIFS
+		_iplow=${_range%-*}
+		_iphigh=${_range#*-}
+
+		# clear netmask when removing aliases
+		if [ "$_action" = "-alias" ]; then
+			_plen=""
+		fi
+
+		_ipcount=$_iplow
+		while [ "$_ipcount" -le "$_iphigh" ]; do
+			_retstr="${_retstr} ${_iphead}${_iphead:+.}${_ipcount}${_iptail:+.}${_iptail}${_plen:+/}${_plen}"
+			if [ $_ipcount -gt $(($_iplow + $_IPEXPANDMAX)) ]; then
+				warn "Range specification is too large (${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_iphigh}${_iptail:+.}${_iptail}).  ${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_ipcount}${_iptail:+.}${_iptail} was processed."
+				break
+			else
+				_ipcount=$(($_ipcount + 1))
+			fi
+			# Forcibly set /32 for remaining aliases.
+			_plen=32
+		done
 	done
 
-	return $_ret
+	for _c in $_retstr; do
+		ifalias_expand_addr_inet $_action $_c
+	done
 }
 
-# ifalias_down if af
-#	Remove aliases for network interface $if.
-#	It returns 0 if at least one alias was removed or
-#	1 if there were none.
+# ifalias_expand_addr_inet6 action addr
+#	Helper function for ifalias_expand_addr().  Handles IPv6.
 #
-ifalias_down()
-{
-	local _ret
-	_ret=1
-
-	case "$2" in
-	inet)
-		_ret=`ifalias_ipv4_down "$1"`
-		;;
-	inet6)
-		_ret=`ifalias_ipv6_down "$1"`
-		;;
+ifalias_expand_addr_inet6()
+{
+	local _action _arg _cidr _cidr_addr
+	local _ipaddr _plen _ipleft _ipright _iplow _iphigh _ipcount
+	local _ipv4part
+	local _retstr _c
+	_action=$1
+	_arg=$2
+	_retstr=
+
+	case $_action:$_arg in
+	*:*--*)		return ;;			# invalid
+	tmp:*)		echo $_arg && return ;;
+	tmp:*-*)	_action="alias"	;;
+	*:*-*)		;;
+	*:*)		echo inet6 $_arg && return ;;
 	esac
 
-	return $_ret
+	for _cidr in $_arg; do
+		_ipaddr="${_cidr%%/*}"
+		_plen="${_cidr##*/}"
+
+		case $_action:$_ipaddr:$_cidr in
+		-alias:*:*)		unset _plen ;;
+		*:$_cidr:$_ipaddr)	unset _plen ;;
+		esac
+
+		if [ "${_ipaddr%:*.*.*.*}" = "$_ipaddr" ]; then
+			# Handle !v4mapped && !v4compat addresses.
+
+			# The default prefix length is 64.
+			case $_ipaddr:$_cidr in
+			$_cidr:$_ipaddr)	_plen="64" ;;
+			esac
+			_ipleft=${_ipaddr%-*}
+			_ipright=${_ipaddr#*-}
+			_iplow=${_ipleft##*:}
+			_iphigh=${_ipright%%:*}
+			_ipleft=${_ipleft%:*}
+			_ipright=${_ipright#*:}
+
+			if [ "$_iphigh" = "$_ipright" ]; then
+				unset _ipright
+			else
+				_ipright=:$_ipright
+			fi
+
+			if [ -n "$_iplow" -a -n "$_iphigh" ]; then
+				_iplow=$((0x$_iplow))
+				_iphigh=$((0x$_iphigh))
+				_ipcount=$_iplow
+				while [ $_ipcount -le $_iphigh ]; do
+					_r=`printf "%s:%04x%s%s" \
+					    $_ipleft $_ipcount $_ipright \
+					    ${_plen:+/}$_plen`
+					_retstr="$_retstr $_r"
+					if [ $_ipcount -gt $(($_iplow + $_IPEXPANDMAX)) ]
+					then
+						warn "Range specification is too large $(printf '(%s:%04x%s-%s:%04x%s)' $_ipleft $_iplow $_ipright $_ipleft $_iphigh $_ipright). $(printf '%s:%04x%s-%s:%04x%s' $_ipleft $_iplow $_ipright $_ipleft $_ipcount $_ipright) was processed."
+						break
+					else
+						_ipcount=$(($_ipcount + 1))
+					fi
+				done
+			else
+				_retstr="${_ipaddr}${_plen:+/}${_plen}"
+			fi
+
+			for _c in $_retstr; do
+				ifalias_expand_addr_inet6 $_action $_c
+			done
+		else
+			# v4mapped/v4compat should handle as an IPv4 alias
+			_ipv4part=${_ipaddr##*:}
+
+			# Adjust prefix length if any.  If not, set the
+			# default prefix length as 32.
+			case $_ipaddr:$_cidr in
+			$_cidr:$_ipaddr)	_plen=32 ;;
+			*)			_plen=$(($_plen - 96)) ;;
+			esac
+
+			_retstr=`ifalias_expand_addr_inet \
+			    tmp ${_ipv4part}${_plen:+/}${_plen}`
+			for _c in $_retstr; do
+				ifalias_expand_addr_inet $_action $_c
+			done
+		fi
+	done
 }
 
-# ifalias_ipv4_down if
-#	Helper function for ifalias_down().  Handles IPv4.
+# ifalias_af_common_handler if af action args
+#	Helper function for ifalias_af_common().
 #
-ifalias_ipv4_down()
+ifalias_af_common_handler()
 {
-	local _ret alias ifconfig_args
+	local _ret _if _af _action _args _c _tmpargs
+
 	_ret=1
+	_if=$1
+	_af=$2
+	_action=$3
+	shift 3
+	_args=$*
+
+	case $_args in
+	${_af}\ *)	;;
+	*)	return	;;
+	esac
 
-	# ifconfig_IF_aliasN which starts with "inet"
-	alias=0
-	while : ; do
-		ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		inet\ *)
-			ifconfig $1 ${ifconfig_args} -alias && _ret=0
+	# link(ether) does not support address removal.
+	case $_af:$_action in
+	link:-alias|ether:-alias)	return ;;
+	esac
+
+	_tmpargs=
+	for _c in $_args; do
+		case $_c in
+		${_af})
+			case $_tmpargs in
+			${_af}\ *-*)
+				ifalias_af_common_handler $_if $_af $_action \
+				`ifalias_expand_addr $_af $_action ${_tmpargs#${_af}\ }`
 			;;
-		"")
-			break
+			${_af}\ *)
+				${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0
 			;;
+			esac
+			_tmpargs=$_af
+		;;
+		*)
+			_tmpargs="$_tmpargs $_c"
+		;;
 		esac
-		alias=$((${alias} + 1))
 	done
+	# Process the last component if any.
+	if [ -n "$_tmpargs}" ]; then
+		case $_tmpargs in
+		${_af}\ *-*)
+			ifalias_af_common_handler $_if $_af $_action \
+			`ifalias_expand_addr $_af $_action ${_tmpargs#${_af}\ }`
+		;;
+		${_af}\ *)
+			${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0
+		;;
+		esac
+	fi
 
 	return $_ret
 }
 
-# ifalias_ipv6_down if
-#	Helper function for ifalias_down().  Handles IPv6.
+# ifalias_af_common if af action
+#	Helper function for ifalias().
 #
-ifalias_ipv6_down()
+ifalias_af_common()
 {
-	local _ret alias ifconfig_args
+	local _ret _if _af _action alias ifconfig_args _aliasn _c _tmpargs _iaf
+
 	_ret=1
+	_aliasn=
+	_if=$1
+	_af=$2
+	_action=$3
 
-	# ifconfig_IF_aliasN which starts with "inet6"
+	# ifconfig_IF_aliasN which starts with $_af
 	alias=0
 	while : ; do
-		ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		inet6\ *)
-			ifconfig $1 ${ifconfig_args} -alias && _ret=0
+		ifconfig_args=`get_if_var $_if ifconfig_IF_alias${alias}`
+		_iaf=
+		case $ifconfig_args in
+		inet\ *)	_iaf=inet ;;
+		inet6\ *)	_iaf=inet6 ;;
+		ipx\ *)		_iaf=ipx ;;
+		link\ *)	_iaf=link ;;
+		ether\ *)	_iaf=ether ;;
+		esac
+
+		case ${_af}:${_action}:${_iaf}:"${ifconfig_args}" in
+		${_af}:*:${_af}:*)
+			_aliasn="$_aliasn $ifconfig_args"
 			;;
-		"")
+		${_af}:*:"":"")
 			break
 			;;
+		inet:alias:"":*)
+			_aliasn="$_aliasn inet $ifconfig_args"
+			warn "\$ifconfig_${_if}_alias${alias} needs " \
+			    "\"inet\" keyword for an IPv4 address."
 		esac
-		alias=$((${alias} + 1))
+		alias=$(($alias + 1))
 	done
 
 	# backward compatibility: ipv6_ifconfig_IF_aliasN.
-	alias=0
-	while : ; do
-		ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
-		case "${ifconfig_args}" in
-		"")
-			break
+	case $_af in
+	inet6)
+		alias=0
+		while : ; do
+			ifconfig_args=`get_if_var $_if ipv6_ifconfig_IF_alias${alias}`
+			case ${_action}:"${ifconfig_args}" in
+			*:"")
+				break
+			;;
+			alias:*)
+				_aliasn="${_aliasn} inet6 ${ifconfig_args}"
+				warn "\$ipv6_ifconfig_${_if}_alias${alias} " \
+				    "is obsolete.  Use ifconfig_$1_aliasN " \
+				    "instead."
 			;;
-		*)
-			ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0
-			warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
-			    "  Use ifconfig_$1_aliasN instead."
+			esac
+			alias=$(($alias + 1))
+		done
+	esac
+
+	# backward compatibility: ipv4_addrs_IF.
+	for _tmpargs in `get_if_var $_if ipv4_addrs_IF`; do
+		_aliasn="$_aliasn inet $_tmpargs"
+	done
+
+	# Handle ifconfig_IF_aliases, ifconfig_IF_aliasN, and the others.
+	_tmpargs=
+	for _c in `get_if_var $_if ifconfig_IF_aliases` $_aliasn; do
+		case $_c in
+		inet|inet6|ipx|link|ether)
+			case $_tmpargs in
+			${_af}\ *)
+				eval ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0
 			;;
+			esac
+			_tmpargs=$_c
+		;;
+		*)
+			_tmpargs="$_tmpargs $_c"
 		esac
-		alias=$((${alias} + 1))
 	done
+	# Process the last component
+	case $_tmpargs in
+	${_af}\ *)
+		ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0
+	;;
+	esac
 
 	return $_ret
 }
@@ -923,14 +1061,32 @@ ipv6_prefix_hostid_addr_common()
 		hostid=${hostid%\%*}
 
 		for j in ${prefix}; do
-			address=$j\:${hostid}
-			ifconfig ${_if} inet6 ${address} prefixlen 64 ${_action}
+			# The default prefixlen is 64.
+			plen=${j#*/}
+			case $j:$plen in
+			$plen:$j)	plen=64 ;;
+			*)		j=${j%/*} ;;
+			esac
+
+			# Normalize the last part by removing ":"
+			j=${j%:*}
+			j=${j%:}
+			OIFS=$IFS; IFS=":"; set -- $j; nj=$#; IFS=$OIFS
+			OIFS=$IFS; IFS=":"; set -- $hostid; nh=$#; IFS=$OIFS
+			if [ $(($nj + $nh)) -eq 8 ]; then
+				address=$j\:$hostid
+			else
+				address=$j\::$hostid
+			fi
+
+			${IFCONFIG_CMD} ${_if} inet6 ${address} \
+				prefixlen $plen ${_action}
 
 			# if I am a router, add subnet router
 			# anycast address (RFC 2373).
 			if checkyesno ipv6_gateway_enable; then
-				ifconfig ${_if} inet6 $j:: prefixlen 64 \
-					${_action} anycast
+				${IFCONFIG_CMD} ${_if} inet6 $j:: \
+					prefixlen $plen ${_action} anycast
 			fi
 		done
 	fi
@@ -942,7 +1098,7 @@ ipv6_prefix_hostid_addr_common()
 ipv6_accept_rtadv_up()
 {
 	if ipv6_autoconfif $1; then
-		ifconfig $1 inet6 accept_rtadv up
+		${IFCONFIG_CMD} $1 inet6 accept_rtadv up
 		if ! checkyesno rtsold_enable; then
 			rtsol ${rtsol_flags} $1
 		fi
@@ -954,7 +1110,7 @@ ipv6_accept_rtadv_up()
 ipv6_accept_rtadv_down()
 {
 	if ipv6_autoconfif $1; then
-		ifconfig $1 inet6 -accept_rtadv
+		${IFCONFIG_CMD} $1 inet6 -accept_rtadv
 	fi
 }
 
@@ -999,7 +1155,7 @@ clone_up()
 
 	# create_args_IF
 	for ifn in ${cloned_interfaces}; do
-		ifconfig ${ifn} create `get_if_var ${ifn} create_args_IF`
+		${IFCONFIG_CMD} ${ifn} create `get_if_var ${ifn} create_args_IF`
 		if [ $? -eq 0 ]; then
 			_list="${_list}${_prefix}${ifn}"
 			[ -z "$_prefix" ] && _prefix=' '
@@ -1019,7 +1175,7 @@ clone_down()
 	_list=
 
 	for ifn in ${cloned_interfaces}; do
-		ifconfig -n ${ifn} destroy
+		${IFCONFIG_CMD} -n ${ifn} destroy
 		if [ $? -eq 0 ]; then
 			_list="${_list}${_prefix}${ifn}"
 			[ -z "$_prefix" ] && _prefix=' '
@@ -1046,16 +1202,16 @@ childif_create()
 		debug_flags="`get_if_var $child wlandebug_IF`"
 
 		if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then
-			ifconfig $child create ${create_args} && cfg=0
+			${IFCONFIG_CMD} $child create ${create_args} && cfg=0
 			if [ -n "${debug_flags}" ]; then
 				wlandebug -i $child ${debug_flags}
 			fi
 		else
-			i=`ifconfig wlan create ${create_args}`
+			i=`${IFCONFIG_CMD} wlan create ${create_args}`
 			if [ -n "${debug_flags}" ]; then
 				wlandebug -i $i ${debug_flags}
 			fi
-			ifconfig $i name $child && cfg=0
+			${IFCONFIG_CMD} $i name $child && cfg=0
 		fi
 		if autoif $child; then
 			ifn_start $child
@@ -1073,14 +1229,14 @@ childif_create()
 		if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
 			child="${ifn}.${child}"
 			create_args=`get_if_var $child create_args_IF`
-			ifconfig $child create ${create_args} && cfg=0
+			${IFCONFIG_CMD} $child create ${create_args} && cfg=0
 		else
 			create_args="vlandev $ifn `get_if_var $child create_args_IF`"
 			if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
-				ifconfig $child create ${create_args} && cfg=0
+				${IFCONFIG_CMD} $child create ${create_args} && cfg=0
 			else
-				i=`ifconfig vlan create ${create_args}`
-				ifconfig $i name $child && cfg=0
+				i=`${IFCONFIG_CMD} vlan create ${create_args}`
+				${IFCONFIG_CMD} $i name $child && cfg=0
 			fi
 		fi
 		if autoif $child; then
@@ -1104,7 +1260,7 @@ childif_destroy()
 		if ! ifexists $child; then
 			continue
 		fi
-		ifconfig -n $child destroy && cfg=0
+		${IFCONFIG_CMD} -n $child destroy && cfg=0
 	done
 
 	child_vlans=`get_if_var $ifn vlans_IF`
@@ -1115,7 +1271,7 @@ childif_destroy()
 		if ! ifexists $child; then
 			continue
 		fi
-		ifconfig -n $child destroy && cfg=0
+		${IFCONFIG_CMD} -n $child destroy && cfg=0
 	done
 
 	return ${cfg}
@@ -1162,13 +1318,13 @@ gif_up()
 			;;
 		*)
 			if expr $i : 'gif[0-9][0-9]*$' >/dev/null 2>&1; then
-				ifconfig $i create >/dev/null 2>&1
+				${IFCONFIG_CMD} $i create >/dev/null 2>&1
 			else
-				gif=`ifconfig gif create`
-				ifconfig $gif name $i
+				gif=`${IFCONFIG_CMD} gif create`
+				${IFCONFIG_CMD} $gif name $i
 			fi
-			ifconfig $i tunnel ${peers}
-			ifconfig $i up
+			${IFCONFIG_CMD} $i tunnel ${peers}
+			${IFCONFIG_CMD} $i up
 			;;
 		esac
 	done
@@ -1234,7 +1390,7 @@ ipx_up()
 	# ifconfig_IF_ipx
 	ifconfig_args=`_ifconfig_getargs $ifn ipx`
 	if [ -n "${ifconfig_args}" ]; then
-		ifconfig ${ifn} ${ifconfig_args}
+		${IFCONFIG_CMD} ${ifn} ${ifconfig_args}
 		return 0
 	fi
 
@@ -1251,7 +1407,7 @@ ipx_down()
 	_if=$1
 	_ifs="^"
 	_ret=1
-	ipxList="`ifconfig ${_if} | grep 'ipx ' | tr "\n" "$_ifs"`"
+	ipxList="`${IFCONFIG_CMD} ${_if} | grep 'ipx ' | tr "\n" "$_ifs"`"
 	oldifs="$IFS"
 
 	IFS="$_ifs"
@@ -1262,7 +1418,7 @@ ipx_down()
 		_ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'`
 
 		IFS="$oldifs"
-		ifconfig ${_if} ${_ipx} delete
+		${IFCONFIG_CMD} ${_if} ${_ipx} delete
 		IFS="$_ifs"
 		_ret=0
 	done
@@ -1279,10 +1435,10 @@ ifnet_rename()
 	local _if _ifname
 
 	# ifconfig_IF_name
-	for _if in `ifconfig -l`; do
+	for _if in `${IFCONFIG_CMD} -l`; do
 		_ifname=`get_if_var $_if ifconfig_IF_name`
 		if [ ! -z "$_ifname" ]; then
-			ifconfig $_if name $_ifname
+			${IFCONFIG_CMD} $_if name $_ifname
 		fi
 	done
 
@@ -1314,7 +1470,7 @@ list_net_interfaces()
 	_tmplist=
 	case ${network_interfaces} in
 	[Aa][Uu][Tt][Oo])
-		_autolist="`ifconfig -l`"
+		_autolist="`${IFCONFIG_CMD} -l`"
 		_lo=
 		for _if in ${_autolist} ; do
 			if autoif $_if; then
@@ -1422,7 +1578,7 @@ is_wired_interface()
 {
 	local media
 
-	case `ifconfig $1 2>/dev/null` in
+	case `${IFCONFIG_CMD} $1 2>/dev/null` in
 	*media:?Ethernet*) media=Ethernet ;;
 	esac
 
@@ -1434,25 +1590,27 @@ is_wired_interface()
 #	If flag is defined, tentative ones will be excluded.
 network6_getladdr()
 {
-	local proto addr rest
-	ifconfig $1 2>/dev/null | while read proto addr rest; do
-		case ${proto} in
-		inet6)
-			case ${addr} in
-			fe80::*)
-				if [ -z "$2" ]; then
-					echo ${addr}
-					return
-				fi
-				case ${rest} in
-				*tentative*)
-					continue
-					;;
-				*)
-					echo ${addr}
-					return
-				esac
-			esac
+	local _if _flag proto addr rest
+	_if=$1
+	_flag=$2
+
+	${IFCONFIG_CMD} $_if 2>/dev/null | while read proto addr rest; do
+		case "${proto}/${addr}/${_flag}/${rest}" in
+		inet6/fe80::*//*)
+			echo ${addr}
+		;;
+		inet6/fe80:://*tentative*)	# w/o flag
+			sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
+			network6_getladdr $_if $_flags
+		;;
+		inet6/fe80::/*/*tentative*)	# w/ flag
+			echo ${addr}
+		;;
+		*)
+			continue
+		;;
 		esac
+
+		return
 	done
 }

Modified: stable/9/etc/rc.d/netif
==============================================================================
--- stable/9/etc/rc.d/netif	Thu Jul 11 23:35:51 2013	(r253226)
+++ stable/9/etc/rc.d/netif	Fri Jul 12 00:40:49 2013	(r253227)
@@ -123,16 +123,28 @@ network_common()
 		_cooked_list="`list_net_interfaces`"
 	fi
 
+	_dadwait=
 	_fail=
 	_ok=
 	for ifn in ${_cooked_list}; do
 		if ${_func} ${ifn} $2; then
 			_ok="${_ok} ${ifn}"
+			if ipv6if ${ifn}; then
+				_dadwait=1
+			fi
 		else
 			_fail="${_fail} ${ifn}"
 		fi
 	done
 
+	# inet6 address configuration needs sleep for DAD.
+	case ${_func}:${_dadwait} in
+	ifn_start:1)
+		sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
+		sleep 1
+	;;
+	esac
+
 	_str=
 	if [ -n "${_ok}" ]; then
 		case ${_func} in

Modified: stable/9/share/man/man5/rc.conf.5
==============================================================================
--- stable/9/share/man/man5/rc.conf.5	Thu Jul 11 23:35:51 2013	(r253226)
+++ stable/9/share/man/man5/rc.conf.5	Fri Jul 12 00:40:49 2013	(r253227)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 22, 2012
+.Dd June 20, 2013
 .Dt RC.CONF 5
 .Os
 .Sh NAME

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

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:06:08 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 9B5E98A7;
 Fri, 12 Jul 2013 01:06:08 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 8D78C1035;
 Fri, 12 Jul 2013 01:06:08 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C168mw091225;
 Fri, 12 Jul 2013 01:06:08 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C168EJ091224;
 Fri, 12 Jul 2013 01:06:08 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120106.r6C168EJ091224@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:06:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253230 - stable/9/usr.sbin/ifmcstat
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:06:08 -0000

Author: hrs
Date: Fri Jul 12 01:06:08 2013
New Revision: 253230
URL: http://svnweb.freebsd.org/changeset/base/253230

Log:
  MFC 243441:
  
  Support a flag for ALLOW/BLOCK in source-specific multicast (RFC 4604).

Modified:
  stable/9/usr.sbin/ifmcstat/ifmcstat.c
Directory Properties:
  stable/9/usr.sbin/ifmcstat/   (props changed)

Modified: stable/9/usr.sbin/ifmcstat/ifmcstat.c
==============================================================================
--- stable/9/usr.sbin/ifmcstat/ifmcstat.c	Fri Jul 12 00:59:03 2013	(r253229)
+++ stable/9/usr.sbin/ifmcstat/ifmcstat.c	Fri Jul 12 01:06:08 2013	(r253230)
@@ -751,7 +751,7 @@ in6_ifinfo(struct mld_ifinfo *mli)
 		printf("mldv?(%d)", mli->mli_version);
 		break;
 	}
-	printb(" flags", mli->mli_flags, "\020\1SILENT");
+	printb(" flags", mli->mli_flags, "\020\1SILENT\2USEALLOW");
 	if (mli->mli_version == MLD_VERSION_2) {
 		printf(" rv %u qi %u qri %u uri %u",
 		    mli->mli_rv, mli->mli_qi, mli->mli_qri, mli->mli_uri);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:08:13 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 5A99D9E7;
 Fri, 12 Jul 2013 01:08:13 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 4C0451041;
 Fri, 12 Jul 2013 01:08:13 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C18DPs091607;
 Fri, 12 Jul 2013 01:08:13 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C18Dhi091606;
 Fri, 12 Jul 2013 01:08:13 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120108.r6C18Dhi091606@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:08:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253231 - stable/9/etc
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:08:13 -0000

Author: hrs
Date: Fri Jul 12 01:08:12 2013
New Revision: 253231
URL: http://svnweb.freebsd.org/changeset/base/253231

Log:
  MFC 243324:
  
  Do not put "already running" message when rc_quiet=yes.
  
  PR:	bin/165477

Modified:
  stable/9/etc/rc.subr
Directory Properties:
  stable/9/etc/   (props changed)

Modified: stable/9/etc/rc.subr
==============================================================================
--- stable/9/etc/rc.subr	Fri Jul 12 01:06:08 2013	(r253230)
+++ stable/9/etc/rc.subr	Fri Jul 12 01:08:12 2013	(r253231)
@@ -742,7 +742,10 @@ run_rc_command()
 
 		start)
 			if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
-				echo 1>&2 "${name} already running? (pid=$rc_pid)."
+				if [ -z "$rc_quiet" ]; then
+					echo 1>&2 "${name} already running? " \
+					    "(pid=$rc_pid)."
+				fi
 				return 1
 			fi
 

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:12:28 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id BD52DB5D;
 Fri, 12 Jul 2013 01:12:28 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id ADC7A1066;
 Fri, 12 Jul 2013 01:12:28 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1CSVv094033;
 Fri, 12 Jul 2013 01:12:28 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1CSgL094032;
 Fri, 12 Jul 2013 01:12:28 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120112.r6C1CSgL094032@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:12:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253232 - stable/9/etc/rc.d
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:12:28 -0000

Author: hrs
Date: Fri Jul 12 01:12:28 2013
New Revision: 253232
URL: http://svnweb.freebsd.org/changeset/base/253232

Log:
  MFC 242301:
  
  Load ipdivert.ko when natd_enable=YES.
  
  PR:	conf/167566

Modified:
  stable/9/etc/rc.d/ipfw
Directory Properties:
  stable/9/etc/rc.d/   (props changed)

Modified: stable/9/etc/rc.d/ipfw
==============================================================================
--- stable/9/etc/rc.d/ipfw	Fri Jul 12 01:08:12 2013	(r253231)
+++ stable/9/etc/rc.d/ipfw	Fri Jul 12 01:12:28 2013	(r253232)
@@ -25,11 +25,11 @@ ipfw_prestart()
 	if checkyesno dummynet_enable; then
 		required_modules="$required_modules dummynet"
 	fi
-
+	if checkyesno natd_enable; then
+		required_modules="$required_modules ipdivert"
+	fi
 	if checkyesno firewall_nat_enable; then
-		if ! checkyesno natd_enable; then
-			required_modules="$required_modules ipfw_nat"
-		fi
+		required_modules="$required_modules ipfw_nat"
 	fi
 }
 

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:16:20 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 5903ACBE;
 Fri, 12 Jul 2013 01:16:20 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 30292107F;
 Fri, 12 Jul 2013 01:16:20 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1GKsa094698;
 Fri, 12 Jul 2013 01:16:20 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1GJio094696;
 Fri, 12 Jul 2013 01:16:19 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120116.r6C1GJio094696@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:16:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253233 - in stable/9: etc share/man/man5
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:16:20 -0000

Author: hrs
Date: Fri Jul 12 01:16:19 2013
New Revision: 253233
URL: http://svnweb.freebsd.org/changeset/base/253233

Log:
  MFC 242184:
  
  Add setfib(1) support for services as _fib in rc.conf.

Modified:
  stable/9/etc/rc.subr
  stable/9/share/man/man5/rc.conf.5
Directory Properties:
  stable/9/etc/   (props changed)
  stable/9/share/man/man5/   (props changed)

Modified: stable/9/etc/rc.subr
==============================================================================
--- stable/9/etc/rc.subr	Fri Jul 12 01:12:28 2013	(r253232)
+++ stable/9/etc/rc.subr	Fri Jul 12 01:16:19 2013	(r253233)
@@ -503,6 +503,8 @@ check_startmsgs()
 #				NOTE:	$flags from the parent environment
 #					can be used to override this.
 #
+#	${name}_fib	n	Routing table number to run ${command} with.
+#
 #	${name}_nice	n	Nice level to run ${command} at.
 #
 #	${name}_user	n	User to run ${command} as, using su(1) if not
@@ -681,7 +683,8 @@ run_rc_command()
 	fi
 	eval _chdir=\$${name}_chdir	_chroot=\$${name}_chroot \
 	    _nice=\$${name}_nice	_user=\$${name}_user \
-	    _group=\$${name}_group	_groups=\$${name}_groups
+	    _group=\$${name}_group	_groups=\$${name}_groups \
+	    _fib=\$${name}_fib
 
 	if [ -n "$_user" ]; then	# unset $_user if running as that user
 		if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -765,11 +768,13 @@ run_rc_command()
 			if [ -n "$_chroot" ]; then
 				_doit="\
 ${_nice:+nice -n $_nice }\
+${_fib:+setfib -F $_fib }\
 chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
 $_chroot $command $rc_flags $command_args"
 			else
 				_doit="\
 ${_chdir:+cd $_chdir && }\
+${_fib:+setfib -F $_fib }\
 $command $rc_flags $command_args"
 				if [ -n "$_user" ]; then
 				    _doit="su -m $_user -c 'sh -c \"$_doit\"'"

Modified: stable/9/share/man/man5/rc.conf.5
==============================================================================
--- stable/9/share/man/man5/rc.conf.5	Fri Jul 12 01:12:28 2013	(r253232)
+++ stable/9/share/man/man5/rc.conf.5	Fri Jul 12 01:16:19 2013	(r253233)
@@ -168,6 +168,27 @@ If set to
 .Dq Li NO ,
 no swapfile is installed, otherwise the value is used as the full
 pathname to a file to use for additional swap space.
+.It Ao Ar name Ac Ns Va _chroot
+.Pq Vt str
+.Xr chroot
+to this directory before running the service.
+.It Ao Ar name Ac Ns Va _user
+.Pq Vt str
+Run the service under this user account.
+.It Ao Ar name Ac Ns Va _group
+.Pq Vt str
+Run the chrooted service under this system group. Unlike the _user
+setting, this setting has no effect if the service is not chrooted.
+.It Ao Ar name Ac Ns Va _fib
+.Pq Vt int
+The
+.Xr setfib 1
+value to run the service under.
+.It Ao Ar name Ac Ns Va _nice
+.Pq Vt int
+The
+.Xr nice 1
+value to run the service under.
 .It Va apm_enable
 .Pq Vt bool
 If set to

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:23:42 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 1E201EE6;
 Fri, 12 Jul 2013 01:23:42 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0F90210BA;
 Fri, 12 Jul 2013 01:23:42 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1NgrU097361;
 Fri, 12 Jul 2013 01:23:42 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1NfTV097357;
 Fri, 12 Jul 2013 01:23:41 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120123.r6C1NfTV097357@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:23:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253234 - in stable/9: etc/rc.d sbin/route
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:23:42 -0000

Author: hrs
Date: Fri Jul 12 01:23:41 2013
New Revision: 253234
URL: http://svnweb.freebsd.org/changeset/base/253234

Log:
  MFC 243185, 243188, 243212:
  
  Add -fib modifier to specify FIB number.  The FIB number can be in a
  comma-separated list and/or range specification:
  
   # route add -inet 192.0.2.0/24 198.51.100.1 -fib 1,3-5,6
  
  Although all of the subcommands supports the modifier, "monitor" does not
  support the list or range specification at this moment.

Modified:
  stable/9/etc/rc.d/routing
  stable/9/sbin/route/keywords
  stable/9/sbin/route/route.8
  stable/9/sbin/route/route.c
Directory Properties:
  stable/9/etc/rc.d/   (props changed)
  stable/9/sbin/route/   (props changed)

Modified: stable/9/etc/rc.d/routing
==============================================================================
--- stable/9/etc/rc.d/routing	Fri Jul 12 01:16:19 2013	(r253233)
+++ stable/9/etc/rc.d/routing	Fri Jul 12 01:23:41 2013	(r253234)
@@ -137,29 +137,20 @@ static_inet()
 
 static_inet6()
 {
-	local _action i fibs
+	local _action fibmod fibs
 	_action=$1
 
 	# get the number of FIBs supported.
-	fibs=`sysctl -n net.fibs`
-	: ${fibs:=1}
+	fibs=$((`${SYSCTL_N} net.fibs` - 1))
+	if [ "$fibs" -gt 0 ]; then
+		fibmod="-fib 0-$fibs"
+	else
+		fibmod=
+	fi
 
 	# disallow "internal" addresses to appear on the wire
-	route ${_action} -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
-	route ${_action} -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
-	i=1
-	if test ${i} -lt ${fibs}; then
-		printf "Also installing reject routes for FIBs"
-		while test ${i} -lt ${fibs}; do
-			setfib -F ${i} route -q ${_action} \
-			    -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
-			setfib -F ${i} route -q ${_action} \
-			    -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
-			printf " %d" ${i}
-			i=$((i + 1))
-		done
-		printf "\n"
-	fi
+	route ${_action} -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}
+	route ${_action} -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}
 
 	case ${ipv6_defaultrouter} in
 	[Nn][Oo] | '')
@@ -231,21 +222,8 @@ static_inet6()
 	# for the host case, you will allow to omit the identifiers.
 	# Under this configuration, the packets will go to the default
 	# interface.
-	route ${_action} -inet6 fe80:: -prefixlen 10 ::1 -reject
-	route ${_action} -inet6 ff02:: -prefixlen 16 ::1 -reject
-	i=1
-	if test ${i} -lt ${fibs}; then
-		printf "Also installing reject routes for FIBs"
-		while test ${i} -lt ${fibs}; do
-			setfib -F ${i} route -q ${_action} \
-			    -inet6 fe80:: -prefixlen 10 ::1 -reject
-			setfib -F ${i} route -q ${_action} \
-			    -inet6 ff02:: -prefixlen 16 ::1 -reject
-			printf " %d" ${i}
-			i=$((i + 1))
-		done
-		printf "\n"
-	fi
+	route ${_action} -inet6 fe80:: -prefixlen 10 ::1 -reject ${fibmod}
+	route ${_action} -inet6 ff02:: -prefixlen 16 ::1 -reject ${fibmod}
 
 	case ${ipv6_default_interface} in
 	'')

Modified: stable/9/sbin/route/keywords
==============================================================================
--- stable/9/sbin/route/keywords	Fri Jul 12 01:16:19 2013	(r253233)
+++ stable/9/sbin/route/keywords	Fri Jul 12 01:23:41 2013	(r253234)
@@ -10,6 +10,7 @@ del
 delete
 dst
 expire
+fib
 flush
 gateway
 genmask

Modified: stable/9/sbin/route/route.8
==============================================================================
--- stable/9/sbin/route/route.8	Fri Jul 12 01:16:19 2013	(r253233)
+++ stable/9/sbin/route/route.8	Fri Jul 12 01:23:41 2013	(r253234)
@@ -28,7 +28,7 @@
 .\"     @(#)route.8	8.3 (Berkeley) 3/19/94
 .\" $FreeBSD$
 .\"
-.Dd October 2, 2005
+.Dd November 17, 2012
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -114,16 +114,14 @@ The monitor command has the syntax:
 .Bd -ragged -offset indent -compact
 .Nm
 .Op Fl n
-.Cm monitor
+.Cm monitor Op Fl fib Ar number
 .Ed
 .Pp
 The flush command has the syntax:
 .Pp
 .Bd -ragged -offset indent -compact
 .Nm
-.Op Fl n
-.Cm flush
-.Op Ar family
+.Oo Fl n Cm flush Oc Oo Ar family Oc Op Fl fib Ar number
 .Ed
 .Pp
 If the
@@ -140,6 +138,11 @@ or
 .Fl inet
 modifiers, only routes having destinations with addresses in the
 delineated family will be deleted.
+When a
+.Fl fib
+option is specified, the operation will be applied to
+the specified FIB
+.Pq routing table .
 .Pp
 The other commands have the following syntax:
 .Pp
@@ -150,6 +153,7 @@ The other commands have the following sy
 .Op Fl net No \&| Fl host
 .Ar destination gateway
 .Op Ar netmask
+.Op Fl fib Ar number
 .Ed
 .Pp
 where
@@ -206,9 +210,15 @@ A
 .Ar destination
 of
 .Ar default
-is a synonym for
-.Fl net Li 0.0.0.0 ,
-which is the default route.
+is a synonym for the default route.
+For
+.Li IPv4
+it is
+.Fl net Fl inet Li 0.0.0.0 ,
+and for
+.Li IPv6
+it is
+.Fl net Fl inet6 Li :: .
 .Pp
 If the destination is directly reachable
 via an interface requiring
@@ -310,6 +320,33 @@ specify that all ensuing metrics may be 
 .Fl lockrest
 meta-modifier.
 .Pp
+The optional modifier
+.Fl fib Ar number
+specifies that the command will be applied to a non-default FIB.
+The
+.Ar number
+must be smaller than the
+.Va net.fibs
+.Xr sysctl 8
+MIB.
+When this modifier is not specified,
+or a negative number is specified,
+the default FIB shown in the
+.Va net.my_fibnum
+.Xr sysctl 8
+MIB will be used.
+.Pp
+The
+.Ar number
+allows multiple FIBs by a comma-separeted list and/or range
+specification.
+The
+.Qq Fl fib Li 2,4,6
+means the FIB number 2, 4, and 6.
+The
+.Qq Fl fib Li 1,3-5,6
+means the 1, 3, 4, 5, and 6.
+.Pp
 In a
 .Cm change
 or

Modified: stable/9/sbin/route/route.c
==============================================================================
--- stable/9/sbin/route/route.c	Fri Jul 12 01:16:19 2013	(r253233)
+++ stable/9/sbin/route/route.c	Fri Jul 12 01:23:41 2013	(r253234)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -77,7 +78,6 @@ struct keytab {
 	{0, 0}
 };
 
-struct	ortentry route;
 union	sockunion {
 	struct	sockaddr sa;
 	struct	sockaddr_in sin;
@@ -99,11 +99,14 @@ int	locking, lockrest, debugonly;
 struct	rt_metrics rt_metrics;
 u_long  rtm_inits;
 uid_t	uid;
+static int	defaultfib;
+static int	numfibs;
 
 static int	atalk_aton(const char *, struct at_addr *);
 static char	*atalk_ntoa(struct at_addr);
 static void	bprintf(FILE *, int, u_char *);
 static void	flushroutes(int argc, char *argv[]);
+static int	flushroutes_fib(int);
 static int	getaddr(int, char *, struct hostent **);
 static int	keyword(const char *);
 static void	inet_makenetandmask(u_long, struct sockaddr_in *, u_long);
@@ -112,21 +115,36 @@ static int inet6_makenetandmask(struct s
 #endif
 static void	interfaces(void);
 static void	mask_addr(void);
-static void	monitor(void);
+static void	monitor(int, char*[]);
 static const char	*netname(struct sockaddr *);
 static void	newroute(int, char **);
+static int	newroute_fib(int, char *, int);
 static void	pmsg_addrs(char *, int, size_t);
 static void	pmsg_common(struct rt_msghdr *, size_t);
 static int	prefixlen(const char *);
-static void	print_getmsg(struct rt_msghdr *, int);
+static void	print_getmsg(struct rt_msghdr *, int, int);
 static void	print_rtmsg(struct rt_msghdr *, size_t);
 static const char	*routename(struct sockaddr *);
-static int	rtmsg(int, int);
+static int	rtmsg(int, int, int);
 static void	set_metric(char *, int);
+static int	set_sofib(int);
+static int	set_procfib(int);
 static void	sockaddr(char *, struct sockaddr *);
 static void	sodump(sup, const char *);
 extern	char *iso_ntoa(void);
 
+struct fibl {
+	TAILQ_ENTRY(fibl)	fl_next;
+
+	int	fl_num;
+	int	fl_error;
+	int	fl_errno;
+};
+TAILQ_HEAD(fibl_head_t, fibl) fibl_head;
+
+static int	fiboptlist_csv(const char *, struct fibl_head_t *);
+static int	fiboptlist_range(const char *, struct fibl_head_t *);
+
 static void usage(const char *) __dead2;
 
 void
@@ -144,6 +162,7 @@ int
 main(int argc, char **argv)
 {
 	int ch;
+	size_t len;
 
 	if (argc < 2)
 		usage(NULL);
@@ -180,6 +199,17 @@ main(int argc, char **argv)
 		s = socket(PF_ROUTE, SOCK_RAW, 0);
 	if (s < 0)
 		err(EX_OSERR, "socket");
+
+	len = sizeof(numfibs);
+	if (sysctlbyname("net.fibs", (void *)&numfibs, &len, NULL, 0) == -1)
+		numfibs = -1;
+
+	len = sizeof(defaultfib);
+	if (numfibs != -1 &&
+	    sysctlbyname("net.my_fibnum", (void *)&defaultfib, &len, NULL,
+		0) == -1)
+		defaultfib = -1;
+
 	if (*argv != NULL)
 		switch (keyword(*argv)) {
 		case K_GET:
@@ -195,7 +225,7 @@ main(int argc, char **argv)
 			/* NOTREACHED */
 
 		case K_MONITOR:
-			monitor();
+			monitor(argc, argv);
 			/* NOTREACHED */
 
 		case K_FLUSH:
@@ -207,6 +237,124 @@ main(int argc, char **argv)
 	/* NOTREACHED */
 }
 
+static int
+set_sofib(int fib)
+{
+
+	if (fib < 0)
+		return (0);
+	return (setsockopt(s, SOL_SOCKET, SO_SETFIB, (void *)&fib,
+	    sizeof(fib)));
+}
+
+static int
+set_procfib(int fib)
+{
+	
+	if (fib < 0)
+		return (0);
+	return (setfib(fib));
+}
+
+static int
+fiboptlist_range(const char *arg, struct fibl_head_t *flh)
+{
+	struct fibl *fl;
+	char *str, *token, *endptr;
+	int fib[2], i, error;
+
+	str = strdup(arg);
+	error = 0;
+	i = 0;
+	while ((token = strsep(&str, "-")) != NULL) {
+		switch (i) {
+		case 0:
+		case 1:
+			fib[i] = strtol(token, &endptr, 0);
+			if (*endptr != '\0' || (fib[i] == 0 &&
+			    (errno == EINVAL || errno == ERANGE)))
+				error = 1;
+			break;
+		default:
+			error = 1;
+		}
+		if (error)
+			goto fiboptlist_range_ret;
+		i++;
+	}
+	if (fib[0] >= fib[1]) {
+		error = 1;
+		goto fiboptlist_range_ret;
+	}
+	for (i = fib[0]; i <= fib[1]; i++) {
+		fl = calloc(1, sizeof(*fl));
+		if (fl == NULL) {
+			error = 1;
+			goto fiboptlist_range_ret;
+		}
+		fl->fl_num = i;
+		TAILQ_INSERT_TAIL(flh, fl, fl_next);
+	}
+fiboptlist_range_ret:
+	free(str);
+	return (error);
+}
+
+#define	ALLSTRLEN	64
+static int
+fiboptlist_csv(const char *arg, struct fibl_head_t *flh)
+{
+	struct fibl *fl;
+	char *str, *token, *endptr;
+	int fib, error;
+
+	if (strcmp("all", arg) == 0) {
+		str = calloc(1, ALLSTRLEN);
+		if (str == NULL) {
+			error = 1;
+			goto fiboptlist_csv_ret;
+		}
+		if (numfibs > 1)
+			snprintf(str, ALLSTRLEN - 1, "%d-%d", 0, numfibs - 1);
+		else
+			snprintf(str, ALLSTRLEN - 1, "%d", 0);
+	} else if (strcmp("default", arg) == 0) {
+		str = calloc(1, ALLSTRLEN);
+		if (str == NULL) {
+			error = 1;
+			goto fiboptlist_csv_ret;
+		}
+		snprintf(str, ALLSTRLEN - 1, "%d", defaultfib);
+	} else
+		str = strdup(arg);
+
+	error = 0;
+	while ((token = strsep(&str, ",")) != NULL) {
+		if (*token != '-' && strchr(token, '-') != NULL) {
+			error = fiboptlist_range(token, flh);
+			if (error)
+				goto fiboptlist_csv_ret;
+		} else {
+			fib = strtol(token, &endptr, 0);
+			if (*endptr != '\0' || (fib == 0 &&
+			    (errno == EINVAL || errno == ERANGE))) {
+				error = 1;
+				goto fiboptlist_csv_ret;
+			}
+			fl = calloc(1, sizeof(*fl));
+			if (fl == NULL) {
+				error = 1;
+				goto fiboptlist_csv_ret;
+			}
+			fl->fl_num = fib;
+			TAILQ_INSERT_TAIL(flh, fl, fl_next);
+		}
+	}
+fiboptlist_csv_ret:
+	free(str);
+	return (error);
+}
+
 /*
  * Purge all entries in the routing tables not
  * associated with network interfaces.
@@ -214,38 +362,71 @@ main(int argc, char **argv)
 static void
 flushroutes(int argc, char *argv[])
 {
-	size_t needed;
-	int mib[6], rlen, seqno, count = 0;
-	char *buf, *next, *lim;
-	struct rt_msghdr *rtm;
+	struct fibl *fl;
+	int error;
 
 	if (uid != 0 && !debugonly) {
 		errx(EX_NOPERM, "must be root to alter routing table");
 	}
 	shutdown(s, SHUT_RD); /* Don't want to read back our messages */
-	if (argc > 1) {
+
+	TAILQ_INIT(&fibl_head);
+	while (argc > 1) {
+		argc--;
 		argv++;
-		if (argc == 2 && **argv == '-')
-		    switch (keyword(*argv + 1)) {
-			case K_INET:
-				af = AF_INET;
-				break;
+		if (**argv != '-')
+			usage(*argv);
+		switch (keyword(*argv + 1)) {
+		case K_INET:
+			af = AF_INET;
+			break;
 #ifdef INET6
-			case K_INET6:
-				af = AF_INET6;
-				break;
+		case K_INET6:
+			af = AF_INET6;
+			break;
 #endif
-			case K_ATALK:
-				af = AF_APPLETALK;
-				break;
-			case K_LINK:
-				af = AF_LINK;
-				break;
-			default:
-				goto bad;
-		} else
-bad:			usage(*argv);
+		case K_ATALK:
+			af = AF_APPLETALK;
+			break;
+		case K_LINK:
+			af = AF_LINK;
+			break;
+		case K_FIB:
+			if (!--argc)
+				usage(*argv);
+			error = fiboptlist_csv(*++argv, &fibl_head);
+			if (error)
+				usage(*argv);
+			break;
+		default:
+			usage(*argv);
+		}
 	}
+	if (TAILQ_EMPTY(&fibl_head)) {
+		error = fiboptlist_csv("default", &fibl_head);
+		if (error)
+			errx(EX_OSERR, "fiboptlist_csv failed.");
+	}
+	TAILQ_FOREACH(fl, &fibl_head, fl_next)
+		flushroutes_fib(fl->fl_num);
+}
+
+static int
+flushroutes_fib(int fib)
+{
+	struct rt_msghdr *rtm;
+	size_t needed;
+	char *buf, *next, *lim;
+	int mib[6], rlen, seqno, count = 0;
+	int error;
+
+	error = set_sofib(fib);
+	error += set_procfib(fib);
+	if (error) {
+		warn("fib number %d is ignored", fib);
+		return (error);
+	}
+
 retry:
 	mib[0] = CTL_NET;
 	mib[1] = PF_ROUTE;
@@ -303,13 +484,17 @@ retry:
 			print_rtmsg(rtm, rlen);
 		else {
 			struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
-			(void) printf("%-20.20s ", rtm->rtm_flags & RTF_HOST ?
+
+			printf("%-20.20s ", rtm->rtm_flags & RTF_HOST ?
 			    routename(sa) : netname(sa));
 			sa = (struct sockaddr *)(SA_SIZE(sa) + (char *)sa);
-			(void) printf("%-20.20s ", routename(sa));
-			(void) printf("done\n");
+			printf("%-20.20s ", routename(sa));
+			if (fib >= 0)
+				printf("-fib %-3d ", fib);
+			printf("done\n");
 		}
 	}
+	return (error);
 }
 
 const char *
@@ -573,18 +758,32 @@ set_metric(char *value, int key)
 	*valp = atoi(value);
 }
 
+#define	F_ISHOST	0x01
+#define	F_FORCENET	0x02
+#define	F_FORCEHOST	0x04
+#define	F_PROXY		0x08
+#define	F_INTERFACE	0x10
+
 static void
 newroute(int argc, char **argv)
 {
+	struct hostent *hp;
+	struct fibl *fl;
 	char *cmd;
-	const char *dest = "", *gateway = "", *errmsg;
-	int ishost = 0, proxy = 0, ret, attempts, oerrno, flags = RTF_STATIC;
-	int key;
-	struct hostent *hp = 0;
+	const char *dest, *gateway, *errmsg;
+	int key, error, flags, nrflags, fibnum;
 
 	if (uid != 0) {
 		errx(EX_NOPERM, "must be root to alter routing table");
 	}
+
+	dest = NULL;
+	gateway = NULL;
+	flags = RTF_STATIC;
+	nrflags = 0;
+	hp = NULL;
+	TAILQ_INIT(&fibl_head);
+
 	cmd = argv[0];
 	if (*cmd != 'g' && *cmd != 's')
 		shutdown(s, SHUT_RD); /* Don't want to read back our messages */
@@ -616,7 +815,7 @@ newroute(int argc, char **argv)
 				break;
 			case K_IFACE:
 			case K_INTERFACE:
-				iflag++;
+				nrflags |= F_INTERFACE;
 				break;
 			case K_NOSTATIC:
 				flags &= ~RTF_STATIC;
@@ -628,7 +827,7 @@ newroute(int argc, char **argv)
 				lockrest = 1;
 				break;
 			case K_HOST:
-				forcehost++;
+				nrflags |= F_FORCEHOST;
 				break;
 			case K_REJECT:
 				flags |= RTF_REJECT;
@@ -643,7 +842,7 @@ newroute(int argc, char **argv)
 				flags |= RTF_PROTO2;
 				break;
 			case K_PROXY:
-				proxy = 1;
+				nrflags |= F_PROXY;
 				break;
 			case K_XRESOLVE:
 				flags |= RTF_XRESOLVE;
@@ -657,6 +856,13 @@ newroute(int argc, char **argv)
 			case K_NOSTICK:
 				flags &= ~RTF_STICKY;
 				break;
+			case K_FIB:
+				if (!--argc)
+					usage(NULL);
+				error = fiboptlist_csv(*++argv, &fibl_head);
+				if (error)
+					usage(NULL);
+				break;
 			case K_IFA:
 				if (!--argc)
 					usage(NULL);
@@ -680,7 +886,8 @@ newroute(int argc, char **argv)
 			case K_DST:
 				if (!--argc)
 					usage(NULL);
-				ishost = getaddr(RTA_DST, *++argv, &hp);
+				if (getaddr(RTA_DST, *++argv, &hp))
+					nrflags |= F_ISHOST;
 				dest = *argv;
 				break;
 			case K_NETMASK:
@@ -689,17 +896,17 @@ newroute(int argc, char **argv)
 				(void) getaddr(RTA_NETMASK, *++argv, 0);
 				/* FALLTHROUGH */
 			case K_NET:
-				forcenet++;
+				nrflags |= F_FORCENET;
 				break;
 			case K_PREFIXLEN:
 				if (!--argc)
 					usage(NULL);
 				if (prefixlen(*++argv) == -1) {
-					forcenet = 0;
-					ishost = 1;
+					nrflags &= ~F_FORCENET;
+					nrflags |= F_ISHOST;
 				} else {
-					forcenet = 1;
-					ishost = 0;
+					nrflags |= F_FORCENET;
+					nrflags &= ~F_ISHOST;
 				}
 				break;
 			case K_MTU:
@@ -721,18 +928,20 @@ newroute(int argc, char **argv)
 		} else {
 			if ((rtm_addrs & RTA_DST) == 0) {
 				dest = *argv;
-				ishost = getaddr(RTA_DST, *argv, &hp);
+				if (getaddr(RTA_DST, *argv, &hp))
+					nrflags |= F_ISHOST;
 			} else if ((rtm_addrs & RTA_GATEWAY) == 0) {
 				gateway = *argv;
 				(void) getaddr(RTA_GATEWAY, *argv, &hp);
 			} else {
 				(void) getaddr(RTA_NETMASK, *argv, 0);
-				forcenet = 1;
+				nrflags |= F_FORCENET;
 			}
 		}
 	}
-	if (forcehost) {
-		ishost = 1;
+
+	if (nrflags & F_FORCEHOST) {
+		nrflags |= F_ISHOST;
 #ifdef INET6
 		if (af == AF_INET6) {
 			rtm_addrs &= ~RTA_NETMASK;
@@ -740,71 +949,125 @@ newroute(int argc, char **argv)
 		}
 #endif
 	}
-	if (forcenet)
-		ishost = 0;
+	if (nrflags & F_FORCENET)
+		nrflags &= ~F_ISHOST;
 	flags |= RTF_UP;
-	if (ishost)
+	if (nrflags & F_ISHOST)
 		flags |= RTF_HOST;
-	if (iflag == 0)
+	if ((nrflags & F_INTERFACE) == 0)
 		flags |= RTF_GATEWAY;
-	if (proxy) {
+	if (nrflags & F_PROXY) {
 		so_dst.sinarp.sin_other = SIN_PROXY;
 		flags |= RTF_ANNOUNCE;
 	}
-	for (attempts = 1; ; attempts++) {
-		errno = 0;
-		if ((ret = rtmsg(*cmd, flags)) == 0)
-			break;
-		if (errno != ENETUNREACH && errno != ESRCH)
-			break;
-		if (af == AF_INET && *gateway != '\0' &&
-		    hp != NULL && hp->h_addr_list[1] != NULL) {
-			hp->h_addr_list++;
-			memmove(&so_gate.sin.sin_addr, hp->h_addr_list[0],
-			    MIN((size_t)hp->h_length,
-			    sizeof(so_gate.sin.sin_addr)));
-		} else
-			break;
+	if (dest == NULL)
+		dest = "";
+	if (gateway == NULL)
+		gateway = "";
+
+	if (TAILQ_EMPTY(&fibl_head)) {
+		error = fiboptlist_csv("default", &fibl_head);
+		if (error)
+			errx(EX_OSERR, "fiboptlist_csv failed.");
+	}
+	error = 0;
+	TAILQ_FOREACH(fl, &fibl_head, fl_next) {
+		fl->fl_error = newroute_fib(fl->fl_num, cmd, flags);
+		if (fl->fl_error)
+			fl->fl_errno = errno;
+		error += fl->fl_error;
 	}
 	if (*cmd == 'g' || *cmd == 's')
-		exit(ret != 0);
+		exit(error);
+
+	error = 0;
 	if (!qflag) {
-		oerrno = errno;
-		(void) printf("%s %s %s", cmd, ishost? "host" : "net", dest);
-		if (*gateway) {
-			(void) printf(": gateway %s", gateway);
-			if (attempts > 1 && ret == 0 && af == AF_INET)
-			    (void) printf(" (%s)",
-				inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr));
+		fibnum = 0;
+		TAILQ_FOREACH(fl, &fibl_head, fl_next) {
+			if (fl->fl_error == 0)
+				fibnum++;
+		}
+		if (fibnum > 0) {
+			int firstfib = 1;
+
+			printf("%s %s %s", cmd,
+			    (nrflags & F_ISHOST) ? "host" : "net", dest);
+			if (*gateway)
+				printf(": gateway %s", gateway);
+
+			if (numfibs > 1) {
+				TAILQ_FOREACH(fl, &fibl_head, fl_next) {
+					if (fl->fl_error == 0
+					    && fl->fl_num >= 0) {
+						if (firstfib) {
+							printf(" fib ");
+							firstfib = 0;
+						}
+						printf("%d", fl->fl_num);
+						if (fibnum-- > 1)
+							printf(",");
+					}
+				}
+			}
+			printf("\n");
 		}
-		if (ret == 0) {
-			(void) printf("\n");
-		} else {
-			switch (oerrno) {
-			case ESRCH:
-				errmsg = "not in table";
-				break;
-			case EBUSY:
-				errmsg = "entry in use";
-				break;
-			case ENOBUFS:
-				errmsg = "not enough memory";
-				break;
-			case EADDRINUSE:
-				/* handle recursion avoidance in rt_setgate() */
-				errmsg = "gateway uses the same route";
-				break;
-			case EEXIST:
-				errmsg = "route already in table";
-				break;
-			default:
-				errmsg = strerror(oerrno);
-				break;
+
+		fibnum = 0;
+		TAILQ_FOREACH(fl, &fibl_head, fl_next) {
+			if (fl->fl_error != 0) {
+				printf("%s %s %s", cmd, (nrflags & F_ISHOST)
+				    ? "host" : "net", dest);
+				if (*gateway)
+					printf(": gateway %s", gateway);
+
+				if (fl->fl_num >= 0)
+					printf(" fib %d", fl->fl_num);
+
+				switch (fl->fl_errno) {
+				case ESRCH:
+					errmsg = "not in table";
+					break;
+				case EBUSY:
+					errmsg = "entry in use";
+					break;
+				case ENOBUFS:
+					errmsg = "not enough memory";
+					break;
+				case EADDRINUSE:
+					/*
+					 * handle recursion avoidance
+					 * in rt_setgate()
+					 */
+					errmsg = "gateway uses the same route";
+					break;
+				case EEXIST:
+					errmsg = "route already in table";
+					break;
+				default:
+					errmsg = strerror(fl->fl_errno);
+					break;
+				}
+				printf(": %s\n", errmsg);
+				error = 1;
 			}
-			(void) printf(": %s\n", errmsg);
 		}
 	}
-	exit(ret != 0);
+	exit(error);
+}
+
+static int
+newroute_fib(int fib, char *cmd, int flags)
+{
+	int error;
+
+	error = set_sofib(fib);
+	if (error) {
+		warn("fib number %d is ignored", fib);
+		return (error);
+	}
+
+	error = rtmsg(*cmd, flags, fib);
+	return (error);
 }
 
 static void
@@ -1165,10 +1428,33 @@ retry2:
 }
 
 static void
-monitor(void)
+monitor(int argc, char *argv[])
 {
-	int n;
-	char msg[2048];
+	int n, fib, error;
+	char msg[2048], *endptr;
+
+	fib = defaultfib;
+	while (argc > 1) {
+		argc--;
+		argv++;
+		if (**argv != '-')
+			usage(*argv);
+		switch (keyword(*argv + 1)) {
+		case K_FIB:
+			if (!--argc)
+				usage(*argv);
+			fib = strtol(*++argv, &endptr, 0);
+			if (*endptr != '\0' || (fib == 0 &&
+			    (errno == EINVAL || errno == ERANGE)))
+				usage(*argv);
+			break;
+		default:
+			usage(*argv);
+		}
+	}
+	error = set_sofib(fib);
+	if (error)
+		errx(EX_USAGE, "invalid fib number: %d", fib);
 
 	verbose = 1;
 	if (debugonly) {
@@ -1190,7 +1476,7 @@ struct {
 } m_rtmsg;
 
 static int
-rtmsg(int cmd, int flags)
+rtmsg(int cmd, int flags, int fib)
 {
 	static int seq;
 	int rlen;
@@ -1253,7 +1539,7 @@ rtmsg(int cmd, int flags)
 		if (l < 0)
 			warn("read from routing socket");
 		else
-			print_getmsg(&rtm, l);
+			print_getmsg(&rtm, l, fib);
 	}
 #undef rtm
 	return (0);
@@ -1431,7 +1717,7 @@ badlen:
 }
 
 static void
-print_getmsg(struct rt_msghdr *rtm, int msglen)
+print_getmsg(struct rt_msghdr *rtm, int msglen, int fib)
 {
 	struct sockaddr *dst = NULL, *gate = NULL, *mask = NULL;
 	struct sockaddr_dl *ifp = NULL;
@@ -1491,6 +1777,8 @@ print_getmsg(struct rt_msghdr *rtm, int 
 	}
 	if (gate && rtm->rtm_flags & RTF_GATEWAY)
 		(void)printf("    gateway: %s\n", routename(gate));
+	if (fib >= 0)
+		(void)printf("        fib: %u\n", (unsigned int)fib);
 	if (ifp)
 		(void)printf("  interface: %.*s\n",
 		    ifp->sdl_nlen, ifp->sdl_data);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:25:25 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 60359C8;
 Fri, 12 Jul 2013 01:25:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 51EC110D0;
 Fri, 12 Jul 2013 01:25:25 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1PPGP097657;
 Fri, 12 Jul 2013 01:25:25 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1PPlG097656;
 Fri, 12 Jul 2013 01:25:25 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120125.r6C1PPlG097656@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:25:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253235 - stable/9/sbin/route
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:25:25 -0000

Author: hrs
Date: Fri Jul 12 01:25:24 2013
New Revision: 253235
URL: http://svnweb.freebsd.org/changeset/base/253235

Log:
  MFC 244325:
  
  - Fix strtol() error handling.
  - Add a range condition of given FIB number and the related error messages.
  - Fix free() problem.

Modified:
  stable/9/sbin/route/route.c
Directory Properties:
  stable/9/sbin/route/   (props changed)

Modified: stable/9/sbin/route/route.c
==============================================================================
--- stable/9/sbin/route/route.c	Fri Jul 12 01:23:41 2013	(r253234)
+++ stable/9/sbin/route/route.c	Fri Jul 12 01:25:24 2013	(r253235)
@@ -260,19 +260,25 @@ static int
 fiboptlist_range(const char *arg, struct fibl_head_t *flh)
 {
 	struct fibl *fl;
-	char *str, *token, *endptr;
+	char *str0, *str, *token, *endptr;
 	int fib[2], i, error;
 
-	str = strdup(arg);
+	str0 = str = strdup(arg);
 	error = 0;
 	i = 0;
 	while ((token = strsep(&str, "-")) != NULL) {
 		switch (i) {
 		case 0:
 		case 1:
+			errno = 0;
 			fib[i] = strtol(token, &endptr, 0);
-			if (*endptr != '\0' || (fib[i] == 0 &&
-			    (errno == EINVAL || errno == ERANGE)))
+			if (errno == 0) {
+				if (*endptr != '\0' ||
+				    fib[i] < 0 ||
+				    (numfibs != -1 && fib[i] > numfibs - 1)) 
+					errno = EINVAL;
+			}
+			if (errno)
 				error = 1;
 			break;
 		default:
@@ -296,7 +302,7 @@ fiboptlist_range(const char *arg, struct
 		TAILQ_INSERT_TAIL(flh, fl, fl_next);
 	}
 fiboptlist_range_ret:
-	free(str);
+	free(str0);
 	return (error);
 }
 
@@ -305,7 +311,7 @@ static int
 fiboptlist_csv(const char *arg, struct fibl_head_t *flh)
 {
 	struct fibl *fl;
-	char *str, *token, *endptr;
+	char *str0, *str, *token, *endptr;
 	int fib, error;
 
 	if (strcmp("all", arg) == 0) {
@@ -319,14 +325,14 @@ fiboptlist_csv(const char *arg, struct f
 		else
 			snprintf(str, ALLSTRLEN - 1, "%d", 0);
 	} else if (strcmp("default", arg) == 0) {
-		str = calloc(1, ALLSTRLEN);
+		str0 = str = calloc(1, ALLSTRLEN);
 		if (str == NULL) {
 			error = 1;
 			goto fiboptlist_csv_ret;
 		}
 		snprintf(str, ALLSTRLEN - 1, "%d", defaultfib);
 	} else
-		str = strdup(arg);
+		str0 = str = strdup(arg);
 
 	error = 0;
 	while ((token = strsep(&str, ",")) != NULL) {
@@ -335,9 +341,15 @@ fiboptlist_csv(const char *arg, struct f
 			if (error)
 				goto fiboptlist_csv_ret;
 		} else {
+			errno = 0;
 			fib = strtol(token, &endptr, 0);
-			if (*endptr != '\0' || (fib == 0 &&
-			    (errno == EINVAL || errno == ERANGE))) {
+			if (errno == 0) {
+				if (*endptr != '\0' ||
+				    fib < 0 ||
+				    (numfibs != -1 && fib > numfibs - 1))
+					errno = EINVAL;
+			}
+			if (errno) {
 				error = 1;
 				goto fiboptlist_csv_ret;
 			}
@@ -351,7 +363,7 @@ fiboptlist_csv(const char *arg, struct f
 		}
 	}
 fiboptlist_csv_ret:
-	free(str);
+	free(str0);
 	return (error);
 }
 
@@ -396,7 +408,7 @@ flushroutes(int argc, char *argv[])
 				usage(*argv);
 			error = fiboptlist_csv(*++argv, &fibl_head);
 			if (error)
-				usage(*argv);
+				errx(EX_USAGE, "invalid fib number: %s", *argv);
 			break;
 		default:
 			usage(*argv);
@@ -861,7 +873,8 @@ newroute(int argc, char **argv)
 					usage(NULL);
 				error = fiboptlist_csv(*++argv, &fibl_head);
 				if (error)
-					usage(NULL);
+					errx(EX_USAGE,
+					    "invalid fib number: %s", *argv);
 				break;
 			case K_IFA:
 				if (!--argc)
@@ -1443,10 +1456,16 @@ monitor(int argc, char *argv[])
 		case K_FIB:
 			if (!--argc)
 				usage(*argv);
+			errno = 0;
 			fib = strtol(*++argv, &endptr, 0);
-			if (*endptr != '\0' || (fib == 0 &&
-			    (errno == EINVAL || errno == ERANGE)))
-				usage(*argv);
+			if (errno == 0) {
+				if (*endptr != '\0' ||
+				    fib < 0 ||
+				    (numfibs != -1 && fib > numfibs - 1))
+					errno = EINVAL;
+			}
+			if (errno)
+				errx(EX_USAGE, "invalid fib number: %s", *argv);
 			break;
 		default:
 			usage(*argv);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:27:12 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 7C230222;
 Fri, 12 Jul 2013 01:27:12 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 6E3D110E5;
 Fri, 12 Jul 2013 01:27:12 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1RC93097925;
 Fri, 12 Jul 2013 01:27:12 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1RCOE097924;
 Fri, 12 Jul 2013 01:27:12 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120127.r6C1RCOE097924@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:27:12 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253236 - stable/9/sbin/route
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:27:12 -0000

Author: hrs
Date: Fri Jul 12 01:27:11 2013
New Revision: 253236
URL: http://svnweb.freebsd.org/changeset/base/253236

Log:
  MFC 245168:
  
  Fix -iface and -interface modifiers.

Modified:
  stable/9/sbin/route/route.c
Directory Properties:
  stable/9/sbin/route/   (props changed)

Modified: stable/9/sbin/route/route.c
==============================================================================
--- stable/9/sbin/route/route.c	Fri Jul 12 01:25:24 2013	(r253235)
+++ stable/9/sbin/route/route.c	Fri Jul 12 01:27:11 2013	(r253236)
@@ -94,7 +94,7 @@ typedef union sockunion *sup;
 int	pid, rtm_addrs;
 int	s;
 int	forcehost, forcenet, doflush, nflag, af, qflag, tflag;
-int	iflag, verbose, aflen = sizeof (struct sockaddr_in);
+int	verbose, aflen = sizeof (struct sockaddr_in);
 int	locking, lockrest, debugonly;
 struct	rt_metrics rt_metrics;
 u_long  rtm_inits;
@@ -107,7 +107,7 @@ static char	*atalk_ntoa(struct at_addr);
 static void	bprintf(FILE *, int, u_char *);
 static void	flushroutes(int argc, char *argv[]);
 static int	flushroutes_fib(int);
-static int	getaddr(int, char *, struct hostent **);
+static int	getaddr(int, char *, struct hostent **, int);
 static int	keyword(const char *);
 static void	inet_makenetandmask(u_long, struct sockaddr_in *, u_long);
 #ifdef INET6
@@ -879,34 +879,34 @@ newroute(int argc, char **argv)
 			case K_IFA:
 				if (!--argc)
 					usage(NULL);
-				(void) getaddr(RTA_IFA, *++argv, 0);
+				getaddr(RTA_IFA, *++argv, 0, nrflags);
 				break;
 			case K_IFP:
 				if (!--argc)
 					usage(NULL);
-				(void) getaddr(RTA_IFP, *++argv, 0);
+				getaddr(RTA_IFP, *++argv, 0, nrflags);
 				break;
 			case K_GENMASK:
 				if (!--argc)
 					usage(NULL);
-				(void) getaddr(RTA_GENMASK, *++argv, 0);
+				getaddr(RTA_GENMASK, *++argv, 0, nrflags);
 				break;
 			case K_GATEWAY:
 				if (!--argc)
 					usage(NULL);
-				(void) getaddr(RTA_GATEWAY, *++argv, 0);
+				getaddr(RTA_GATEWAY, *++argv, 0, nrflags);
 				break;
 			case K_DST:
 				if (!--argc)
 					usage(NULL);
-				if (getaddr(RTA_DST, *++argv, &hp))
+				if (getaddr(RTA_DST, *++argv, &hp, nrflags))
 					nrflags |= F_ISHOST;
 				dest = *argv;
 				break;
 			case K_NETMASK:
 				if (!--argc)
 					usage(NULL);
-				(void) getaddr(RTA_NETMASK, *++argv, 0);
+				getaddr(RTA_NETMASK, *++argv, 0, nrflags);
 				/* FALLTHROUGH */
 			case K_NET:
 				nrflags |= F_FORCENET;
@@ -941,13 +941,13 @@ newroute(int argc, char **argv)
 		} else {
 			if ((rtm_addrs & RTA_DST) == 0) {
 				dest = *argv;
-				if (getaddr(RTA_DST, *argv, &hp))
+				if (getaddr(RTA_DST, *argv, &hp, nrflags))
 					nrflags |= F_ISHOST;
 			} else if ((rtm_addrs & RTA_GATEWAY) == 0) {
 				gateway = *argv;
-				(void) getaddr(RTA_GATEWAY, *argv, &hp);
+				getaddr(RTA_GATEWAY, *argv, &hp, nrflags);
 			} else {
-				(void) getaddr(RTA_NETMASK, *argv, 0);
+				getaddr(RTA_NETMASK, *argv, 0, nrflags);
 				nrflags |= F_FORCENET;
 			}
 		}
@@ -1166,7 +1166,7 @@ inet6_makenetandmask(struct sockaddr_in6
  * returning 1 if a host address, 0 if a network address.
  */
 static int
-getaddr(int which, char *str, struct hostent **hpp)
+getaddr(int which, char *str, struct hostent **hpp, int nrflags)
 {
 	sup su;
 	struct hostent *hp;
@@ -1187,7 +1187,7 @@ getaddr(int which, char *str, struct hos
 		break;
 	case RTA_GATEWAY:
 		su = &so_gate;
-		if (iflag) {
+		if (nrflags & F_INTERFACE) {
 			struct ifaddrs *ifap, *ifa;
 			struct sockaddr_dl *sdl = NULL;
 
@@ -1247,7 +1247,7 @@ getaddr(int which, char *str, struct hos
 #if 0
 			bzero(su, sizeof(*su));	/* for readability */
 #endif
-			getaddr(RTA_NETMASK, str, 0);
+			getaddr(RTA_NETMASK, str, 0, nrflags);
 			break;
 #if 0
 		case RTA_NETMASK:

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:29:58 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 1D6B237F;
 Fri, 12 Jul 2013 01:29:58 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0FFA01106;
 Fri, 12 Jul 2013 01:29:58 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1TvQQ098281;
 Fri, 12 Jul 2013 01:29:57 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1Tvnu098280;
 Fri, 12 Jul 2013 01:29:57 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120129.r6C1Tvnu098280@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:29:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253237 - stable/9/sbin/route
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:29:58 -0000

Author: hrs
Date: Fri Jul 12 01:29:57 2013
New Revision: 253237
URL: http://svnweb.freebsd.org/changeset/base/253237

Log:
  MFC 251581:
  
  Fix a bug that the gateway address was not shown when a -gateway modifier
  was used.

Modified:
  stable/9/sbin/route/route.c
Directory Properties:
  stable/9/sbin/route/   (props changed)

Modified: stable/9/sbin/route/route.c
==============================================================================
--- stable/9/sbin/route/route.c	Fri Jul 12 01:27:11 2013	(r253236)
+++ stable/9/sbin/route/route.c	Fri Jul 12 01:29:57 2013	(r253237)
@@ -895,6 +895,7 @@ newroute(int argc, char **argv)
 				if (!--argc)
 					usage(NULL);
 				getaddr(RTA_GATEWAY, *++argv, 0, nrflags);
+				gateway = *argv;
 				break;
 			case K_DST:
 				if (!--argc)

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:34:26 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id F379657D;
 Fri, 12 Jul 2013 01:34:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id D745E112B;
 Fri, 12 Jul 2013 01:34:25 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1YPT1000695;
 Fri, 12 Jul 2013 01:34:25 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1YPr5000692;
 Fri, 12 Jul 2013 01:34:25 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120134.r6C1YPr5000692@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:34:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253238 - in stable/9: etc/rc.d share/man/man5
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:34:26 -0000

Author: hrs
Date: Fri Jul 12 01:34:24 2013
New Revision: 253238
URL: http://svnweb.freebsd.org/changeset/base/253238

Log:
  MFC 251584:
  
  Add :ifname modifier to specify interface-specific routes into
  {,ipv6_}static_routes and rc.d/routing.  For example:
  
   static_routes="foo bar:em0"
   route_foo="-net 10.0.0.0/24 -gateway 192.168.2.1"
   route_bar="-net 192.168.1.0/24 -gateway 192.168.0.2"
  
  At boot time, all of the static routes are installed as before.
  The differences are:
  
  - "/etc/rc.d/netif start/stop " now configures static routes
    with : if any.
  - "/etc/rc.d/routing start/stop  " works as well.   cannot be
    omitted when  is specified, but a keyword "any" or "all" can be used
    for  and .

Modified:
  stable/9/etc/rc.d/netif
  stable/9/etc/rc.d/routing
  stable/9/share/man/man5/rc.conf.5
Directory Properties:
  stable/9/etc/rc.d/   (props changed)
  stable/9/share/man/man5/   (props changed)

Modified: stable/9/etc/rc.d/netif
==============================================================================
--- stable/9/etc/rc.d/netif	Fri Jul 12 01:29:57 2013	(r253237)
+++ stable/9/etc/rc.d/netif	Fri Jul 12 01:34:24 2013	(r253238)
@@ -46,6 +46,8 @@ set_rcvar_obsolete ipv6_prefer
 
 network_start()
 {
+	local _if
+
 	# Set the list of interfaces to work on.
 	#
 	cmdifn=$*
@@ -81,16 +83,29 @@ network_start()
 	if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
 		/etc/rc.d/bridge start $cmdifn
 	fi
+	if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then
+		for _if in $cmdifn; do
+			/etc/rc.d/routing start any $_if
+		done
+	fi
 }
 
 network_stop()
 {
+	local _if
+
 	# Set the list of interfaces to work on.
 	#
 	cmdifn=$*
 
 	# Deconfigure the interface(s)
 	network_common ifn_stop
+
+	if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then
+		for _if in $cmdifn; do
+			/etc/rc.d/routing stop any $_if
+		done
+	fi
 }
 
 # network_common routine

Modified: stable/9/etc/rc.d/routing
==============================================================================
--- stable/9/etc/rc.d/routing	Fri Jul 12 01:29:57 2013	(r253237)
+++ stable/9/etc/rc.d/routing	Fri Jul 12 01:34:24 2013	(r253238)
@@ -19,56 +19,73 @@ extra_commands="options static"
 static_cmd="routing_start static"
 options_cmd="routing_start options"
 
-afcheck()
-{
-	case $_af in
-	""|inet|inet6|ipx|atm)
-		;;
-	*)
-		err 1 "Unsupported address family: $_af."
-		;;
-	esac
-}
+ROUTE_CMD="/sbin/route"
 
 routing_start()
 {
-	local _cmd _af _a
+	local _cmd _af _if _a
 	_cmd=$1
 	_af=$2
+	_if=$3
 
-	afcheck
+	case $_if in
+	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
+	esac
 
 	case $_af in
 	inet|inet6|ipx|atm)
-		setroutes $_cmd $_af
+		if afexists $_af; then
+			setroutes $_cmd $_af $_if
+		else
+			err 1 "Unsupported address family: $_af."
+		fi
 		;;
-	"")
+	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
 		for _a in inet inet6 ipx atm; do
-			afexists $_a && setroutes $_cmd $_a
+			afexists $_a && setroutes $_cmd $_a $_if
 		done
 		;;
+	*)
+		err 1 "Unsupported address family: $_af."
+		;;
 	esac
 }
 
 routing_stop()
 {
-	local _af _a
+	local _af _if _a
 	_af=$1
+	_if=$2
 
-	afcheck
+	case $_if in
+	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
+	esac
 
 	case $_af in
 	inet|inet6|ipx|atm)
-		eval static_${_af} delete
-		eval routing_stop_${_af}
+		if afexists $_af; then
+			eval static_${_af} delete $_if 
+			# When $_if is specified, do not flush routes.
+			if ! [ -n "$_if" ]; then
+				eval routing_stop_${_af}
+			fi
+		else
+			err 1 "Unsupported address family: $_af."
+		fi
 		;;
-	"")
+	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
 		for _a in inet inet6 ipx atm; do
 			afexists $_a || continue
-			eval static_${_a} delete
-			eval routing_stop_${_a}
+			eval static_${_a} delete $_if
+			# When $_if is specified, do not flush routes.
+			if ! [ -n "$_if" ]; then
+				eval routing_stop_${_a}
+			fi
 		done
 		;;
+	*)
+		err 1 "Unsupported address family: $_af."
+		;;
 	esac
 }
 
@@ -76,13 +93,13 @@ setroutes()
 {
 	case $1 in
 	static)
-		static_$2 add
+		static_$2 add $3
 		;;
 	options)
 		options_$2
 		;;
 	doall)
-		static_$2 add
+		static_$2 add $3
 		options_$2
 		;;
 	esac
@@ -90,14 +107,14 @@ setroutes()
 
 routing_stop_inet()
 {
-	route -n flush -inet
+	${ROUTE_CMD} -n flush -inet
 }
 
 routing_stop_inet6()
 {
 	local i
 
-	route -n flush -inet6
+	${ROUTE_CMD} -n flush -inet6
 	for i in ${ipv6_network_interfaces}; do
 		ifconfig $i inet6 -defaultif
 	done
@@ -115,30 +132,47 @@ routing_stop_ipx()
 
 static_inet()
 {
-	local _action
+	local _action _if _skip
 	_action=$1
+	_if=$2
 
+	# Add default route.
 	case ${defaultrouter} in
 	[Nn][Oo] | '')
 		;;
 	*)
-		static_routes="default ${static_routes}"
-		route_default="default ${defaultrouter}"
+		static_routes="_default ${static_routes}"
+		route__default="default ${defaultrouter}"
 		;;
 	esac
 
+	# Install configured routes.
 	if [ -n "${static_routes}" ]; then
 		for i in ${static_routes}; do
-			route_args=`get_if_var $i route_IF`
-			route ${_action} ${route_args}
+			_skip=0
+			if [ -n "$_if" ]; then
+				case $i in
+				*:$_if)	;;
+				*)	_skip=1 ;;
+				esac
+			fi
+			if [ $_skip = 0 ]; then
+				route_args=`get_if_var ${i%:*} route_IF`
+				if [ -n "$route_args" ]; then
+					${ROUTE_CMD} ${_action} ${route_args}
+				else
+					warn "route_${i%:*} not found."
+				fi
+			fi
 		done
 	fi
 }
 
 static_inet6()
 {
-	local _action fibmod fibs
+	local _action _if _skip fibmod fibs
 	_action=$1
+	_if=$2
 
 	# get the number of FIBs supported.
 	fibs=$((`${SYSCTL_N} net.fibs` - 1))
@@ -148,58 +182,74 @@ static_inet6()
 		fibmod=
 	fi
 
+	# Add pre-defined static routes first.
+	ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}"
+	ipv6_static_routes="_lla _llma ${ipv6_static_routes}"
+
 	# disallow "internal" addresses to appear on the wire
-	route ${_action} -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}
-	route ${_action} -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}
+	ipv6_route__v4mapped="::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
+	ipv6_route__v4compat="::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
 
+	# Disallow link-local unicast packets without outgoing scope
+	# identifiers.  However, if you set "ipv6_default_interface",
+	# for the host case, you will allow to omit the identifiers.
+	# Under this configuration, the packets will go to the default
+	# interface.
+	ipv6_route__lla="fe80:: -prefixlen 10 ::1 -reject ${fibmod}"
+	ipv6_route__llma="ff02:: -prefixlen 16 ::1 -reject ${fibmod}"
+
+	# Add default route.
 	case ${ipv6_defaultrouter} in
 	[Nn][Oo] | '')
 		;;
 	*)
-		ipv6_static_routes="default ${ipv6_static_routes}"
-		ipv6_route_default="default ${ipv6_defaultrouter}"
+		ipv6_static_routes="_default ${ipv6_static_routes}"
+		ipv6_route__default="default ${ipv6_defaultrouter}"
 		;;
 	esac
 
+	# Install configured routes.
 	if [ -n "${ipv6_static_routes}" ]; then
 		for i in ${ipv6_static_routes}; do
-			ipv6_route_args=`get_if_var $i ipv6_route_IF`
-			route ${_action} -inet6 ${ipv6_route_args}
+			_skip=0
+			if [ -n "$_if" ]; then
+				case $i in
+				*:$_if)	;;
+				*)	_skip=1 ;;
+				esac
+			fi
+			if [ $_skip = 0 ]; then
+				ipv6_route_args=`get_if_var ${i%:*} ipv6_route_IF`
+				if [ -n "$ipv6_route_args" ]; then
+					${ROUTE_CMD} ${_action} \
+						-inet6 ${ipv6_route_args}
+				else
+					warn "route_${i%:*} not found"
+				fi
+			fi
 		done
 	fi
 
-	# Fixup $ipv6_network_interfaces
-	case ${ipv6_network_interfaces} in
-	[Nn][Oo][Nn][Ee])
-		ipv6_network_interfaces=''
-		;;
-	esac
+	# Install the "default interface" to kernel, which will be used
+	# as the default route when there's no router.
 
+	# Disable installing the default interface when we act
+	# as router to avoid conflict between the default
+	# router list and the manual configured default route.
 	if checkyesno ipv6_gateway_enable; then
-		for i in ${ipv6_network_interfaces}; do
-
-			laddr=`network6_getladdr $i exclude_tentative`
-			case ${laddr} in
-			'')
-				;;
-			*)
-				ipv6_working_interfaces="$i \
-				    ${ipv6_working_interfaces}"
-				;;
-			esac
-		done
-		ipv6_network_interfaces=${ipv6_working_interfaces}
+		return
 	fi
 
-	# Install the "default interface" to kernel, which will be used
-	# as the default route when there's no router.
 	case "${ipv6_default_interface}" in
 	[Nn][Oo] | [Nn][Oo][Nn][Ee])
-		ipv6_default_interface=""
+		return
 		;;
 	[Aa][Uu][Tt][Oo] | "")
 		for i in ${ipv6_network_interfaces}; do
 			case $i in
+			[Nn][Oo][Nn][Ee])
+				return
+				;;
 			lo0|faith[0-9]*)
 				continue
 				;;
@@ -217,27 +267,8 @@ static_inet6()
 		;;
 	esac
 
-	# Disallow link-local unicast packets without outgoing scope
-	# identifiers.  However, if you set "ipv6_default_interface",
-	# for the host case, you will allow to omit the identifiers.
-	# Under this configuration, the packets will go to the default
-	# interface.
-	route ${_action} -inet6 fe80:: -prefixlen 10 ::1 -reject ${fibmod}
-	route ${_action} -inet6 ff02:: -prefixlen 16 ::1 -reject ${fibmod}
-
-	case ${ipv6_default_interface} in
-	'')
-		;;
-	*)
-		# Disable installing the default interface when we act
-		# as router to avoid conflict between the default
-		# router list and the manual configured default route.
-		if ! checkyesno ipv6_gateway_enable; then
-			ifconfig ${ipv6_default_interface} inet6 defaultif
-			sysctl net.inet6.ip6.use_defaultzone=1
-		fi
-		;;
-	esac
+	ifconfig ${ipv6_default_interface} inet6 defaultif
+	sysctl net.inet6.ip6.use_defaultzone=1
 }
 
 static_atm()
@@ -248,7 +279,11 @@ static_atm()
 	if [ -n "${natm_static_routes}" ]; then
 		for i in ${natm_static_routes}; do
 			route_args=`get_if_var $i route_IF`
-			atmconfig natm ${_action} ${route_args}
+			if [ -n "$route_args" ]; then
+				atmconfig natm ${_action} ${route_args}
+			else
+				warn "route_${i} not found."
+			fi
 		done
 	fi
 }

Modified: stable/9/share/man/man5/rc.conf.5
==============================================================================
--- stable/9/share/man/man5/rc.conf.5	Fri Jul 12 01:29:57 2013	(r253237)
+++ stable/9/share/man/man5/rc.conf.5	Fri Jul 12 01:34:24 2013	(r253238)
@@ -2704,10 +2704,18 @@ whose contents will later be passed to a
 operation.
 For example:
 .Bd -literal
-static_routes="mcast gif0local"
+static_routes="ext mcast:gif0 gif0local:gif0"
+route_ext="-net 10.0.0.0/24 -gateway 192.168.0.1"
 route_mcast="-net 224.0.0.0/4 -iface gif0"
 route_gif0local="-host 169.254.1.1 -iface lo0"
 .Ed
+.Pp
+When an
+.Ar element
+is in the form of
+.Li name:ifname ,
+the route is specific to the interface
+.Li ifname .
 .It Va ipv6_static_routes
 .Pq Vt str
 The IPv6 equivalent of

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:52:33 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id A9F13803;
 Fri, 12 Jul 2013 01:52:33 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 9B52611A5;
 Fri, 12 Jul 2013 01:52:33 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1qXDV006239;
 Fri, 12 Jul 2013 01:52:33 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1qVdS006230;
 Fri, 12 Jul 2013 01:52:31 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120152.r6C1qVdS006230@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:52:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253239 - in stable/9: share/man/man4 sys/net sys/netinet6
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:52:33 -0000

Author: hrs
Date: Fri Jul 12 01:52:31 2013
New Revision: 253239
URL: http://svnweb.freebsd.org/changeset/base/253239

Log:
  MFC 232379, 252511, 252548, 253060:
  
  - Allow to configure net.inet6.ip6.{accept_rtadv,no_radr} by the
    loader tunables as well because they have to be configured before
    interface initialization for AF_INET6.
  
  - Allow ND6_IFF_AUTO_LINKLOCAL for IFT_BRIDGE.  An interface with IFT_BRIDGE
    is initialized with !ND6_IFF_AUTO_LINKLOCAL && !ND6_IFF_ACCEPT_RTADV
    regardless of net.inet6.ip6.accept_rtadv and net.inet6.ip6.auto_linklocal.
    To configure an autoconfigured link-local address (RFC 4862), the
    following rc.conf(5) configuration can be used:
  
     ifconfig_bridge0_ipv6="inet6 auto_linklocal"
  
  - if_bridge(4) now removes IPv6 addresses on a member interface to be
    added when the parent interface or one of the existing member
    interfaces has an IPv6 address.  if_bridge(4) merges each link-local
    scope zone which the member interfaces form respectively, so it causes
    address scope violation.  Removal of the IPv6 addresses prevents it.
  
  - if_lagg(4) now removes IPv6 addresses on a member interfaces
    unconditionally.
  
  - Set reasonable flags to non-IPv6-capable interfaces.

Modified:
  stable/9/share/man/man4/bridge.4
  stable/9/sys/net/if_bridge.c
  stable/9/sys/net/if_lagg.c
  stable/9/sys/netinet6/in6.c
  stable/9/sys/netinet6/in6_ifattach.c
  stable/9/sys/netinet6/in6_var.h
  stable/9/sys/netinet6/ip6_input.c
  stable/9/sys/netinet6/nd6.c
Directory Properties:
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/share/man/man4/bridge.4
==============================================================================
--- stable/9/share/man/man4/bridge.4	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/share/man/man4/bridge.4	Fri Jul 12 01:52:31 2013	(r253239)
@@ -35,7 +35,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 9, 2010
+.Dd July 3, 2013
 .Dt IF_BRIDGE 4
 .Os
 .Sh NAME
@@ -142,6 +142,79 @@ This can be used to multiplex the input 
 stream.
 This is useful for reconstructing the traffic for network taps
 that transmit the RX/TX signals out through two separate interfaces.
+.Sh IPV6 SUPPORT
+.Nm
+supports the
+.Li AF_INET6
+address family on bridge interfaces.
+The following
+.Xr rc.conf 5
+variable configures an IPv6 link-local address on
+.Li bridge0
+interface: 
+.Bd -literal -offset indent
+ifconfig_bridge0_ipv6="up"
+.Ed
+.Pp
+or in a more explicit manner:
+.Bd -literal -offset indent
+ifconfig_bridge0_ipv6="inet6 auto_linklocal"
+.Ed
+.Pp
+However, the
+.Li AF_INET6
+address family has a concept of scope zone.
+Bridging multiple interfaces change the zone configuration because
+multiple links are merged to each other and form a new single link
+while the member interfaces still work individually.
+This means each member interface still has a separate link-local scope
+zone and the
+.Nm
+interface has another single,
+aggregated link-local scope zone at the same time.
+This situation is clearly against the description
+.Qq zones of the same scope cannot overlap
+in Section 5,
+RFC 4007.
+Although it works in most cases,
+it can cause some conterintuitive or undesirable behavior in some
+edge cases when both of the
+.Nm
+interface and one of the member interface have an IPv6 address
+and applications use both of them.
+.Pp
+To prevent this situation,
+.Nm
+checks whether an link-local scoped IPv6 address is configured on
+a member interface to be added and the 
+.Nm
+interface.
+When the
+.Nm
+interface has IPv6 addresses,
+IPv6 addresses on the member interface will be automatically removed
+before the interface is added.
+When both
+.Nm
+interface and the existing member interfaces do not have one,
+adding an interface with IPv6 addresses as a new member interface is allowed.
+These means only one interface in the link-local scope zone where the
+.Nm
+interface forms can have link-local scoped IPv6 addresses.
+.Pp
+Note that
+.Li ACCEPT_RTADV
+and
+.Li AUTO_LINKLOCAL
+interface flag are not enabled by default on
+.Nm
+interface even when
+.Va net.inet6.ip6.accept_rtadv
+and/or
+.Va net.inet6.ip6.auto_linklocal
+is set to
+.Li 1 .
+.Ed
 .Sh SPANNING TREE
 The
 .Nm

Modified: stable/9/sys/net/if_bridge.c
==============================================================================
--- stable/9/sys/net/if_bridge.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/net/if_bridge.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -119,6 +119,7 @@ __FBSDID("$FreeBSD$");
 #ifdef INET6
 #include 
 #include 
+#include 
 #endif
 #if defined(INET) || defined(INET6)
 #include 
@@ -1041,14 +1042,6 @@ bridge_ioctl_add(struct bridge_softc *sc
 	if (ifs->if_bridge != NULL)
 		return (EBUSY);
 
-	bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO);
-	if (bif == NULL)
-		return (ENOMEM);
-
-	bif->bif_ifp = ifs;
-	bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
-	bif->bif_savedcaps = ifs->if_capenable;
-
 	switch (ifs->if_type) {
 	case IFT_ETHER:
 	case IFT_L2VLAN:
@@ -1056,20 +1049,95 @@ bridge_ioctl_add(struct bridge_softc *sc
 		/* permitted interface types */
 		break;
 	default:
-		error = EINVAL;
-		goto out;
+		return (EINVAL);
 	}
 
+#ifdef INET6
+	/*
+	 * Two valid inet6 addresses with link-local scope must not be
+	 * on the parent interface and the member interfaces at the
+	 * same time.  This restriction is needed to prevent violation
+	 * of link-local scope zone.  Attempts to add a member
+	 * interface which has inet6 addresses when the parent has
+	 * inet6 triggers removal of all inet6 addresses on the member
+	 * interface.
+	 */
+
+	/* Check if the parent interface has a link-local scope addr. */
+	if (in6ifa_llaonifp(sc->sc_ifp) != NULL) {
+		/*
+		 * If any, remove all inet6 addresses from the member
+		 * interfaces.
+		 */
+		BRIDGE_XLOCK(sc);
+		LIST_FOREACH(bif, &sc->sc_iflist, bif_next) {
+ 			if (in6ifa_llaonifp(bif->bif_ifp)) {
+				BRIDGE_UNLOCK(sc);
+				in6_ifdetach(bif->bif_ifp);
+				BRIDGE_LOCK(sc);
+				if_printf(sc->sc_ifp,
+				    "IPv6 addresses on %s have been removed "
+				    "before adding it as a member to prevent "
+				    "IPv6 address scope violation.\n",
+				    bif->bif_ifp->if_xname);
+			}
+		}
+		BRIDGE_XDROP(sc);
+		if (in6ifa_llaonifp(ifs)) {
+			BRIDGE_UNLOCK(sc);
+			in6_ifdetach(ifs);
+			BRIDGE_LOCK(sc);
+			if_printf(sc->sc_ifp,
+			    "IPv6 addresses on %s have been removed "
+			    "before adding it as a member to prevent "
+			    "IPv6 address scope violation.\n",
+			    ifs->if_xname);
+		}
+	} else {
+		struct in6_ifaddr *ia6_m, *ia6_s;
+		/*
+		 * If not, check whether one of the existing member
+		 * interfaces have inet6 address.  If any, remove
+		 * inet6 addresses on the interface to be added.
+		 */
+		ia6_m = NULL;
+		BRIDGE_XLOCK(sc);
+		LIST_FOREACH(bif, &sc->sc_iflist, bif_next) {
+			ia6_m = in6ifa_llaonifp(bif->bif_ifp);
+			if (ia6_m != NULL)
+				break;
+		}
+		BRIDGE_XDROP(sc);
+		ia6_s = in6ifa_llaonifp(ifs);
+
+		if (ia6_m != NULL && ia6_s != NULL) {
+			BRIDGE_UNLOCK(sc);
+			in6_ifdetach(ifs);
+			BRIDGE_LOCK(sc);
+			if_printf(sc->sc_ifp, "IPv6 addresses on %s have "
+				  "been removed before adding it as a member "
+				  "to prevent IPv6 address scope violation.\n",
+				  ifs->if_xname);
+		}
+	}
+#endif
 	/* Allow the first Ethernet member to define the MTU */
 	if (LIST_EMPTY(&sc->sc_iflist))
 		sc->sc_ifp->if_mtu = ifs->if_mtu;
 	else if (sc->sc_ifp->if_mtu != ifs->if_mtu) {
 		if_printf(sc->sc_ifp, "invalid MTU: %lu(%s) != %lu\n",
 		    ifs->if_mtu, ifs->if_xname, sc->sc_ifp->if_mtu);
-		error = EINVAL;
-		goto out;
+		return (EINVAL);
 	}
 
+	bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO);
+	if (bif == NULL)
+		return (ENOMEM);
+
+	bif->bif_ifp = ifs;
+	bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
+	bif->bif_savedcaps = ifs->if_capenable;
+
 	/*
 	 * Assign the interface's MAC address to the bridge if it's the first
 	 * member and the MAC address of the bridge has not been changed from
@@ -1104,12 +1172,10 @@ bridge_ioctl_add(struct bridge_softc *sc
 			BRIDGE_LOCK(sc);
 			break;
 	}
-	if (error)
-		bridge_delete_member(sc, bif, 0);
-out:
+
 	if (error) {
-		if (bif != NULL)
-			free(bif, M_DEVBUF);
+		bridge_delete_member(sc, bif, 0);
+		free(bif, M_DEVBUF);
 	}
 	return (error);
 }
@@ -3473,7 +3539,7 @@ bridge_fragment(struct ifnet *ifp, struc
 				continue;
 			}
 			bcopy(eh, mtod(m0, caddr_t), ETHER_HDR_LEN);
-		} else 
+		} else
 			m_freem(m);
 	}
 

Modified: stable/9/sys/net/if_lagg.c
==============================================================================
--- stable/9/sys/net/if_lagg.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/net/if_lagg.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -63,6 +63,8 @@ __FBSDID("$FreeBSD$");
 
 #ifdef INET6
 #include 
+#include 
+#include 
 #endif
 
 #include 
@@ -532,6 +534,34 @@ lagg_port_create(struct lagg_softc *sc, 
 	if (ifp->if_type != IFT_ETHER)
 		return (EPROTONOSUPPORT);
 
+#ifdef INET6
+	/*
+	 * The member interface should not have inet6 address because
+	 * two interfaces with a valid link-local scope zone must not be
+	 * merged in any form.  This restriction is needed to
+	 * prevent violation of link-local scope zone.  Attempts to
+	 * add a member interface which has inet6 addresses triggers
+	 * removal of all inet6 addresses on the member interface.
+	 */
+	SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) {
+		if (in6ifa_llaonifp(lp->lp_ifp)) {
+			in6_ifdetach(lp->lp_ifp);
+			if_printf(sc->sc_ifp,
+			    "IPv6 addresses on %s have been removed "
+			    "before adding it as a member to prevent "
+			    "IPv6 address scope violation.\n",
+			    lp->lp_ifp->if_xname);
+		}
+	}
+	if (in6ifa_llaonifp(ifp)) {
+		in6_ifdetach(ifp);
+		if_printf(sc->sc_ifp,
+		    "IPv6 addresses on %s have been removed "
+		    "before adding it as a member to prevent "
+		    "IPv6 address scope violation.\n",
+		    ifp->if_xname);
+	}
+#endif
 	/* Allow the first Ethernet member to define the MTU */
 	if (SLIST_EMPTY(&sc->sc_ports))
 		sc->sc_ifp->if_mtu = ifp->if_mtu;

Modified: stable/9/sys/netinet6/in6.c
==============================================================================
--- stable/9/sys/netinet6/in6.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/netinet6/in6.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -1961,6 +1961,32 @@ in6ifa_ifpwithaddr(struct ifnet *ifp, st
 }
 
 /*
+ * Find a link-local scoped address on ifp and return it if any.
+ */
+struct in6_ifaddr *
+in6ifa_llaonifp(struct ifnet *ifp)
+{
+	struct sockaddr_in6 *sin6;
+	struct ifaddr *ifa;
+
+	if (ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)
+		return (NULL);
+	if_addr_rlock(ifp);
+	TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+		if (ifa->ifa_addr->sa_family != AF_INET6)
+			continue;
+		sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
+		if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) ||
+		    IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr) ||
+		    IN6_IS_ADDR_MC_NODELOCAL(&sin6->sin6_addr))
+			break;
+	}
+	if_addr_runlock(ifp);
+
+	return ((struct in6_ifaddr *)ifa);
+}
+
+/*
  * Convert IP6 address to printable (loggable) representation. Caller
  * has to make sure that ip6buf is at least INET6_ADDRSTRLEN long.
  */

Modified: stable/9/sys/netinet6/in6_ifattach.c
==============================================================================
--- stable/9/sys/netinet6/in6_ifattach.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/netinet6/in6_ifattach.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -266,6 +266,7 @@ found:
 
 	/* get EUI64 */
 	switch (ifp->if_type) {
+	case IFT_BRIDGE:
 	case IFT_ETHER:
 	case IFT_L2VLAN:
 	case IFT_FDDI:
@@ -727,7 +728,8 @@ in6_ifattach(struct ifnet *ifp, struct i
 	switch (ifp->if_type) {
 	case IFT_PFLOG:
 	case IFT_PFSYNC:
-	case IFT_CARP:
+		ND_IFINFO(ifp)->flags &= ~ND6_IFF_AUTO_LINKLOCAL;
+		ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED;
 		return;
 	}
 
@@ -735,7 +737,6 @@ in6_ifattach(struct ifnet *ifp, struct i
 	 * quirks based on interface type
 	 */
 	switch (ifp->if_type) {
-#ifdef IFT_STF
 	case IFT_STF:
 		/*
 		 * 6to4 interface is a very special kind of beast.
@@ -743,8 +744,8 @@ in6_ifattach(struct ifnet *ifp, struct i
 		 * linklocals for 6to4 interface, but there's no use and
 		 * it is rather harmful to have one.
 		 */
-		goto statinit;
-#endif
+		ND_IFINFO(ifp)->flags &= ~ND6_IFF_AUTO_LINKLOCAL;
+		break;
 	default:
 		break;
 	}
@@ -778,8 +779,7 @@ in6_ifattach(struct ifnet *ifp, struct i
 	/*
 	 * assign a link-local address, if there's none.
 	 */
-	if (ifp->if_type != IFT_BRIDGE &&
-	    !(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
+	if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
 	    ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) {
 		int error;
 
@@ -796,10 +796,6 @@ in6_ifattach(struct ifnet *ifp, struct i
 			ifa_free(&ia->ia_ifa);
 	}
 
-#ifdef IFT_STF			/* XXX */
-statinit:
-#endif
-
 	/* update dynamically. */
 	if (V_in6_maxmtu < ifp->if_mtu)
 		V_in6_maxmtu = ifp->if_mtu;

Modified: stable/9/sys/netinet6/in6_var.h
==============================================================================
--- stable/9/sys/netinet6/in6_var.h	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/netinet6/in6_var.h	Fri Jul 12 01:52:31 2013	(r253239)
@@ -765,6 +765,7 @@ void	in6_setmaxmtu(void);
 int	in6_if2idlen(struct ifnet *);
 struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
 struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
+struct in6_ifaddr *in6ifa_llaonifp(struct ifnet *);
 char	*ip6_sprintf(char *, const struct in6_addr *);
 int	in6_addr2zoneid(struct ifnet *, struct in6_addr *, u_int32_t *);
 int	in6_matchlen(struct in6_addr *, struct in6_addr *);

Modified: stable/9/sys/netinet6/ip6_input.c
==============================================================================
--- stable/9/sys/netinet6/ip6_input.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/netinet6/ip6_input.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -166,6 +166,8 @@ ip6_init(void)
 
 	TUNABLE_INT_FETCH("net.inet6.ip6.auto_linklocal",
 	    &V_ip6_auto_linklocal);
+	TUNABLE_INT_FETCH("net.inet6.ip6.accept_rtadv", &V_ip6_accept_rtadv);
+	TUNABLE_INT_FETCH("net.inet6.ip6.no_radr", &V_ip6_no_radr);
 
 	TAILQ_INIT(&V_in6_ifaddrhead);
 

Modified: stable/9/sys/netinet6/nd6.c
==============================================================================
--- stable/9/sys/netinet6/nd6.c	Fri Jul 12 01:34:24 2013	(r253238)
+++ stable/9/sys/netinet6/nd6.c	Fri Jul 12 01:52:31 2013	(r253239)
@@ -184,13 +184,25 @@ nd6_ifattach(struct ifnet *ifp)
 
 	nd->flags = ND6_IFF_PERFORMNUD;
 
-	/* A loopback interface always has ND6_IFF_AUTO_LINKLOCAL. */
-	if (V_ip6_auto_linklocal || (ifp->if_flags & IFF_LOOPBACK))
+	/* A loopback interface always has ND6_IFF_AUTO_LINKLOCAL.
+	 * XXXHRS: Clear ND6_IFF_AUTO_LINKLOCAL on an IFT_BRIDGE interface by
+	 * default regardless of the V_ip6_auto_linklocal configuration to
+	 * give a reasonable default behavior.
+	 */
+	if ((V_ip6_auto_linklocal && ifp->if_type != IFT_BRIDGE) ||
+	    (ifp->if_flags & IFF_LOOPBACK))
 		nd->flags |= ND6_IFF_AUTO_LINKLOCAL;
-
-	/* A loopback interface does not need to accept RTADV. */
-	if (V_ip6_accept_rtadv && !(ifp->if_flags & IFF_LOOPBACK))
-		nd->flags |= ND6_IFF_ACCEPT_RTADV;
+	/*
+	 * A loopback interface does not need to accept RTADV.
+	 * XXXHRS: Clear ND6_IFF_ACCEPT_RTADV on an IFT_BRIDGE interface by
+	 * default regardless of the V_ip6_accept_rtadv configuration to
+	 * prevent the interface from accepting RA messages arrived
+	 * on one of the member interfaces with ND6_IFF_ACCEPT_RTADV.
+	 */
+	if (V_ip6_accept_rtadv &&
+	    !(ifp->if_flags & IFF_LOOPBACK) &&
+	    (ifp->if_type != IFT_BRIDGE))
+			nd->flags |= ND6_IFF_ACCEPT_RTADV;
 	if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK))
 		nd->flags |= ND6_IFF_NO_RADR;
 
@@ -1360,16 +1372,6 @@ nd6_ioctl(u_long cmd, caddr_t data, stru
 		struct ifaddr *ifa;
 		struct in6_ifaddr *ia;
 
-		/*
-		 * Try to clear ifdisabled flag when enabling
-		 * accept_rtadv or auto_linklocal.
-		 */
-		if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
-		    !(ND.flags & ND6_IFF_IFDISABLED) &&
-		    (ND.flags & (ND6_IFF_ACCEPT_RTADV |
-		    ND6_IFF_AUTO_LINKLOCAL)))
-			ND.flags &= ~ND6_IFF_IFDISABLED;
-
 		if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
 		    !(ND.flags & ND6_IFF_IFDISABLED)) {
 			/* ifdisabled 1->0 transision */

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:55:29 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 80A93940;
 Fri, 12 Jul 2013 01:55:29 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 72D0511B1;
 Fri, 12 Jul 2013 01:55:29 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1tTNh006708;
 Fri, 12 Jul 2013 01:55:29 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1tTrp006707;
 Fri, 12 Jul 2013 01:55:29 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120155.r6C1tTrp006707@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:55:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253240 - stable/9/share/man/man4
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:55:29 -0000

Author: hrs
Date: Fri Jul 12 01:55:28 2013
New Revision: 253240
URL: http://svnweb.freebsd.org/changeset/base/253240

Log:
  MFC 253093:
  
  Make mandoc lint happy.

Modified:
  stable/9/share/man/man4/bridge.4
Directory Properties:
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/bridge.4
==============================================================================
--- stable/9/share/man/man4/bridge.4	Fri Jul 12 01:52:31 2013	(r253239)
+++ stable/9/share/man/man4/bridge.4	Fri Jul 12 01:55:28 2013	(r253240)
@@ -151,7 +151,7 @@ The following
 .Xr rc.conf 5
 variable configures an IPv6 link-local address on
 .Li bridge0
-interface: 
+interface:
 .Bd -literal -offset indent
 ifconfig_bridge0_ipv6="up"
 .Ed
@@ -186,7 +186,7 @@ and applications use both of them.
 To prevent this situation,
 .Nm
 checks whether an link-local scoped IPv6 address is configured on
-a member interface to be added and the 
+a member interface to be added and the
 .Nm
 interface.
 When the
@@ -214,7 +214,6 @@ and/or
 .Va net.inet6.ip6.auto_linklocal
 is set to
 .Li 1 .
-.Ed
 .Sh SPANNING TREE
 The
 .Nm

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:56:06 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 8155CA71;
 Fri, 12 Jul 2013 01:56:06 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 59B0011B8;
 Fri, 12 Jul 2013 01:56:06 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1u6HH006831;
 Fri, 12 Jul 2013 01:56:06 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1u6Z3006829;
 Fri, 12 Jul 2013 01:56:06 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120156.r6C1u6Z3006829@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:56:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253241 - stable/9/lib/libc/net
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:56:06 -0000

Author: hrs
Date: Fri Jul 12 01:56:05 2013
New Revision: 253241
URL: http://svnweb.freebsd.org/changeset/base/253241

Log:
  MFC 253066:
  
  Update references.

Modified:
  stable/9/lib/libc/net/getaddrinfo.3
  stable/9/lib/libc/net/getnameinfo.3
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/net/getaddrinfo.3
==============================================================================
--- stable/9/lib/libc/net/getaddrinfo.3	Fri Jul 12 01:55:28 2013	(r253240)
+++ stable/9/lib/libc/net/getaddrinfo.3	Fri Jul 12 01:56:05 2013	(r253241)
@@ -255,7 +255,7 @@ member points to a filled-in socket addr
 This implementation of
 .Fn getaddrinfo
 allows numeric IPv6 address notation with scope identifier,
-as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt.
+as documented in chapter 11 of RFC 4007.
 By appending the percent character and scope identifier to addresses,
 one can fill the
 .Li sin6_scope_id
@@ -441,9 +441,8 @@ freeaddrinfo(res0);
 .%A E. Nordmark
 .%A B. Zill
 .%T "IPv6 Scoped Address Architecture"
-.%R internet draft
-.%N draft-ietf-ipv6-scoping-arch-02.txt
-.%O work in progress material
+.%R RFC 4007
+.%D March 2005
 .Re
 .Rs
 .%A Craig Metz

Modified: stable/9/lib/libc/net/getnameinfo.3
==============================================================================
--- stable/9/lib/libc/net/getnameinfo.3	Fri Jul 12 01:55:28 2013	(r253240)
+++ stable/9/lib/libc/net/getnameinfo.3	Fri Jul 12 01:56:05 2013	(r253241)
@@ -191,10 +191,11 @@ printf("host=%s\en", hbuf);
 .%A R. Gilligan
 .%A S. Thomson
 .%A J. Bound
+.%A J. McCann
 .%A W. Stevens
 .%T Basic Socket Interface Extensions for IPv6
-.%R RFC 2553
-.%D March 1999
+.%R RFC 3493
+.%D February 2003
 .Re
 .Rs
 .%A S. Deering
@@ -203,9 +204,8 @@ printf("host=%s\en", hbuf);
 .%A E. Nordmark
 .%A B. Zill
 .%T "IPv6 Scoped Address Architecture"
-.%R internet draft
-.%N draft-ietf-ipv6-scoping-arch-02.txt
-.%O work in progress material
+.%R RFC 4007
+.%D March 2005
 .Re
 .Rs
 .%A Craig Metz
@@ -217,9 +217,9 @@ printf("host=%s\en", hbuf);
 The
 .Fn getnameinfo
 function is defined by the
-.St -p1003.1g-2000
-draft specification and documented in
-.Tn "RFC 2553" ,
+.St -p1003.1-2004
+specification and documented in
+.Tn "RFC 3493" ,
 .Dq Basic Socket Interface Extensions for IPv6 .
 .Sh CAVEATS
 .Fn getnameinfo

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 01:59:31 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 4EBD3BBF;
 Fri, 12 Jul 2013 01:59:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 411FC11CA;
 Fri, 12 Jul 2013 01:59:31 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C1xVF3007260;
 Fri, 12 Jul 2013 01:59:31 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C1xVx1007259;
 Fri, 12 Jul 2013 01:59:31 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120159.r6C1xVx1007259@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 01:59:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253242 - stable/9/usr.sbin/rtadvd
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 01:59:31 -0000

Author: hrs
Date: Fri Jul 12 01:59:30 2013
New Revision: 253242
URL: http://svnweb.freebsd.org/changeset/base/253242

Log:
  MFC 253058:
  
  - Add missing "static" keywords.
  - Add a check for ifindex to if_indextoifinfo().  It returns NULL when
    if_indextoname() fails.

Modified:
  stable/9/usr.sbin/rtadvd/rtadvd.c
Directory Properties:
  stable/9/usr.sbin/rtadvd/   (props changed)

Modified: stable/9/usr.sbin/rtadvd/rtadvd.c
==============================================================================
--- stable/9/usr.sbin/rtadvd/rtadvd.c	Fri Jul 12 01:56:05 2013	(r253241)
+++ stable/9/usr.sbin/rtadvd/rtadvd.c	Fri Jul 12 01:59:30 2013	(r253242)
@@ -95,7 +95,7 @@ struct sockaddr_in6 rcvfrom;
 static const char *pidfilename = _PATH_RTADVDPID;
 const char *conffile = _PATH_RTADVDCONF;
 static struct pidfh *pfh;
-int dflag = 0, sflag = 0;
+static int dflag, sflag;
 static int wait_shutdown;
 
 #define	PFD_RAWSOCK	0
@@ -139,7 +139,7 @@ union nd_opt {
 #define NDOPT_FLAG_RDNSS	(1 << 5)
 #define NDOPT_FLAG_DNSSL	(1 << 6)
 
-uint32_t ndopt_flags[] = {
+static uint32_t ndopt_flags[] = {
 	[ND_OPT_SOURCE_LINKADDR]	= NDOPT_FLAG_SRCLINKADDR,
 	[ND_OPT_TARGET_LINKADDR]	= NDOPT_FLAG_TGTLINKADDR,
 	[ND_OPT_PREFIX_INFORMATION]	= NDOPT_FLAG_PREFIXINFO,
@@ -1637,6 +1637,11 @@ struct ifinfo *
 if_indextoifinfo(int idx)
 {
 	struct ifinfo *ifi;
+	char *name, name0[IFNAMSIZ];
+
+	/* Check if the interface has a valid name or not. */
+	if (if_indextoname(idx, name0) == NULL)
+		return (NULL);
 
 	TAILQ_FOREACH(ifi, &ifilist, ifi_next) {
 		if (ifi->ifi_ifindex == idx)

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 02:11:42 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id A3EF9E8B;
 Fri, 12 Jul 2013 02:11:42 +0000 (UTC) (envelope-from hrs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 967541227;
 Fri, 12 Jul 2013 02:11:42 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C2BgVg012718;
 Fri, 12 Jul 2013 02:11:42 GMT (envelope-from hrs@svn.freebsd.org)
Received: (from hrs@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C2BgId012717;
 Fri, 12 Jul 2013 02:11:42 GMT (envelope-from hrs@svn.freebsd.org)
Message-Id: <201307120211.r6C2BgId012717@svn.freebsd.org>
From: Hiroki Sato 
Date: Fri, 12 Jul 2013 02:11:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253243 - stable/9/usr.sbin/ifmcstat
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 02:11:42 -0000

Author: hrs
Date: Fri Jul 12 02:11:42 2013
New Revision: 253243
URL: http://svnweb.freebsd.org/changeset/base/253243

Log:
  MFC 245015:
  
  Print the flags= part only when flags != 0.

Modified:
  stable/9/usr.sbin/ifmcstat/ifmcstat.c
Directory Properties:
  stable/9/usr.sbin/ifmcstat/   (props changed)

Modified: stable/9/usr.sbin/ifmcstat/ifmcstat.c
==============================================================================
--- stable/9/usr.sbin/ifmcstat/ifmcstat.c	Fri Jul 12 01:59:30 2013	(r253242)
+++ stable/9/usr.sbin/ifmcstat/ifmcstat.c	Fri Jul 12 02:11:42 2013	(r253243)
@@ -296,7 +296,8 @@ in_ifinfo(struct igmp_ifinfo *igi)
 		printf("igmpv?(%d)", igi->igi_version);
 		break;
 	}
-	printb(" flags", igi->igi_flags, "\020\1SILENT\2LOOPBACK");
+	if (igi->igi_flags)
+		printb(" flags", igi->igi_flags, "\020\1SILENT\2LOOPBACK");
 	if (igi->igi_version == IGMP_VERSION_3) {
 		printf(" rv %u qi %u qri %u uri %u",
 		    igi->igi_rv, igi->igi_qi, igi->igi_qri, igi->igi_uri);
@@ -751,7 +752,8 @@ in6_ifinfo(struct mld_ifinfo *mli)
 		printf("mldv?(%d)", mli->mli_version);
 		break;
 	}
-	printb(" flags", mli->mli_flags, "\020\1SILENT\2USEALLOW");
+	if (mli->mli_flags)
+		printb(" flags", mli->mli_flags, "\020\1SILENT\2USEALLOW");
 	if (mli->mli_version == MLD_VERSION_2) {
 		printf(" rv %u qi %u qri %u uri %u",
 		    mli->mli_rv, mli->mli_qi, mli->mli_qri, mli->mli_uri);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 02:26:17 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 45D7F20D;
 Fri, 12 Jul 2013 02:26:17 +0000 (UTC)
 (envelope-from sbruno@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 36B811281;
 Fri, 12 Jul 2013 02:26:17 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C2QHV4016066;
 Fri, 12 Jul 2013 02:26:17 GMT (envelope-from sbruno@svn.freebsd.org)
Received: (from sbruno@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C2QF6I016058;
 Fri, 12 Jul 2013 02:26:15 GMT (envelope-from sbruno@svn.freebsd.org)
Message-Id: <201307120226.r6C2QF6I016058@svn.freebsd.org>
From: Sean Bruno 
Date: Fri, 12 Jul 2013 02:26:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253244 - in stable/9: sys/dev/mfi usr.sbin/mfiutil
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 02:26:17 -0000

Author: sbruno
Date: Fri Jul 12 02:26:15 2013
New Revision: 253244
URL: http://svnweb.freebsd.org/changeset/base/253244

Log:
  MFC r251516
  
  Implement foreign device handling.
  
  PR:	kern/172091

Added:
  stable/9/usr.sbin/mfiutil/mfi_foreign.c
     - copied unchanged from r251516, head/usr.sbin/mfiutil/mfi_foreign.c
Modified:
  stable/9/sys/dev/mfi/mfireg.h
  stable/9/usr.sbin/mfiutil/Makefile
  stable/9/usr.sbin/mfiutil/mfi_config.c
  stable/9/usr.sbin/mfiutil/mfi_show.c
  stable/9/usr.sbin/mfiutil/mfiutil.8
  stable/9/usr.sbin/mfiutil/mfiutil.c
  stable/9/usr.sbin/mfiutil/mfiutil.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/usr.sbin/mfiutil/   (props changed)

Modified: stable/9/sys/dev/mfi/mfireg.h
==============================================================================
--- stable/9/sys/dev/mfi/mfireg.h	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/sys/dev/mfi/mfireg.h	Fri Jul 12 02:26:15 2013	(r253244)
@@ -230,7 +230,11 @@ typedef enum {
 	MFI_DCMD_CFG_CLEAR =		0x04030000,
 	MFI_DCMD_CFG_MAKE_SPARE =	0x04040000,
 	MFI_DCMD_CFG_REMOVE_SPARE =	0x04050000,
+	MFI_DCMD_CFG_FOREIGN_SCAN =     0x04060100,
+	MFI_DCMD_CFG_FOREIGN_DISPLAY =  0x04060200,
+	MFI_DCMD_CFG_FOREIGN_PREVIEW =  0x04060300,
 	MFI_DCMD_CFG_FOREIGN_IMPORT =	0x04060400,
+	MFI_DCMD_CFG_FOREIGN_CLEAR =    0x04060500,
 	MFI_DCMD_BBU_GET_STATUS =	0x05010000,
 	MFI_DCMD_BBU_GET_CAPACITY_INFO =0x05020000,
 	MFI_DCMD_BBU_GET_DESIGN_INFO =	0x05030000,

Modified: stable/9/usr.sbin/mfiutil/Makefile
==============================================================================
--- stable/9/usr.sbin/mfiutil/Makefile	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/Makefile	Fri Jul 12 02:26:15 2013	(r253244)
@@ -2,7 +2,7 @@
 PROG=	mfiutil
 
 SRCS=	mfiutil.c mfi_bbu.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c \
-	mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c
+	mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c mfi_foreign.c
 MAN8=	mfiutil.8
 
 CFLAGS+= -fno-builtin-strftime

Modified: stable/9/usr.sbin/mfiutil/mfi_config.c
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfi_config.c	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/mfi_config.c	Fri Jul 12 02:26:15 2013	(r253244)
@@ -37,19 +37,13 @@
 #include 
 #include 
 #include 
-#ifdef DEBUG
 #include 
-#endif
 #include 
 #include 
 #include 
 #include 
 #include "mfiutil.h"
 
-#ifdef DEBUG
-static void	dump_config(int fd, struct mfi_config_data *config);
-#endif
-
 static int	add_spare(int ac, char **av);
 static int	remove_spare(int ac, char **av);
 
@@ -81,9 +75,17 @@ dehumanize(const char *value)
         }
         return (iv);
 }
+
 int
 mfi_config_read(int fd, struct mfi_config_data **configp)
 {
+	return mfi_config_read_opcode(fd, MFI_DCMD_CFG_READ, configp, NULL, 0);
+}
+
+int
+mfi_config_read_opcode(int fd, uint32_t opcode, struct mfi_config_data **configp,
+	uint8_t *mbox, size_t mboxlen)
+{
 	struct mfi_config_data *config;
 	uint32_t config_size;
 	int error;
@@ -98,8 +100,8 @@ fetch:
 	config = reallocf(config, config_size);
 	if (config == NULL)
 		return (-1);
-	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_READ, config,
-	    config_size, NULL, 0, NULL) < 0) {
+	if (mfi_dcmd_command(fd, opcode, config,
+	    config_size, mbox, mboxlen, NULL) < 0) {
 		error = errno;
 		free(config);
 		errno = error;
@@ -366,6 +368,13 @@ parse_array(int fd, int raid_type, char 
 			info->drives = NULL;
 			return (EINVAL);
 		}
+
+		if (pinfo->state.ddf.v.pd_type.is_foreign) {
+			warnx("Drive %u is foreign", device_id);
+			free(info->drives);
+			info->drives = NULL;
+			return (EINVAL);
+		}
 	}
 
 	return (0);
@@ -804,7 +813,7 @@ create_volume(int ac, char **av)
 
 #ifdef DEBUG
 	if (dump)
-		dump_config(fd, config);
+		dump_config(fd, config, NULL);
 #endif
 
 	/* Send the new config to the controller. */
@@ -1093,10 +1102,9 @@ remove_spare(int ac, char **av)
 }
 MFI_COMMAND(top, remove, remove_spare);
 
-#ifdef DEBUG
 /* Display raw data about a config. */
-static void
-dump_config(int fd, struct mfi_config_data *config)
+void
+dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix)
 {
 	struct mfi_array *ar;
 	struct mfi_ld_config *ld;
@@ -1106,9 +1114,12 @@ dump_config(int fd, struct mfi_config_da
 	char *p;
 	int i, j;
 
+	if (NULL == msg_prefix)
+		msg_prefix = "Configuration (Debug)";
+
 	printf(
-	    "mfi%d Configuration (Debug): %d arrays, %d volumes, %d spares\n",
-	    mfi_unit, config->array_count, config->log_drv_count,
+	    "mfi%d %s: %d arrays, %d volumes, %d spares\n", mfi_unit,
+	    msg_prefix, config->array_count, config->log_drv_count,
 	    config->spares_count);
 	printf("  array size: %u\n", config->array_size);
 	printf("  volume size: %u\n", config->log_drv_size);
@@ -1186,6 +1197,7 @@ dump_config(int fd, struct mfi_config_da
 	}
 }
 
+#ifdef DEBUG
 static int
 debug_config(int ac, char **av)
 {
@@ -1213,7 +1225,7 @@ debug_config(int ac, char **av)
 	}
 
 	/* Dump out the configuration. */
-	dump_config(fd, config);
+	dump_config(fd, config, NULL);
 	free(config);
 	close(fd);
 
@@ -1265,7 +1277,7 @@ dump(int ac, char **av)
 		close(fd);
 		return (error);
 	}
-	dump_config(fd, config);
+	dump_config(fd, config, NULL);
 	free(config);
 	close(fd);
 

Copied: stable/9/usr.sbin/mfiutil/mfi_foreign.c (from r251516, head/usr.sbin/mfiutil/mfi_foreign.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/usr.sbin/mfiutil/mfi_foreign.c	Fri Jul 12 02:26:15 2013	(r253244, copy of r251516, head/usr.sbin/mfiutil/mfi_foreign.c)
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 2013 smh@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mfiutil.h"
+
+MFI_TABLE(top, foreign);
+
+static int
+foreign_clear(__unused int ac, __unused char **av)
+{
+	int ch, error, fd;
+
+	fd = mfi_open(mfi_unit, O_RDWR);
+	if (fd < 0) {
+		error = errno;
+		warn("mfi_open");
+		return (error);
+	}
+
+	printf(
+	    "Are you sure you wish to clear ALL foreign configurations"
+	    " on mfi%u? [y/N] ", mfi_unit);
+
+	ch = getchar();
+	if (ch != 'y' && ch != 'Y') {
+		printf("\nAborting\n");
+		close(fd);
+		return (0);
+	}
+
+	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_CLEAR, NULL, 0, NULL,
+	    0, NULL) < 0) {
+		error = errno;
+		warn("Failed to clear foreign configuration");
+		close(fd);
+		return (error);
+	}
+
+	printf("mfi%d: Foreign configuration cleared\n", mfi_unit);
+	close(fd);
+	return (0);
+}
+MFI_COMMAND(foreign, clear, foreign_clear);
+
+static int
+foreign_scan(__unused int ac, __unused char **av)
+{
+	struct mfi_foreign_scan_info info;
+	int error, fd;
+
+	fd = mfi_open(mfi_unit, O_RDONLY);
+	if (fd < 0) {
+		error = errno;
+		warn("mfi_open");
+		return (error);
+	}
+
+	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+	    sizeof(info), NULL, 0, NULL) < 0) {
+		error = errno;
+		warn("Failed to scan foreign configuration");
+		close(fd);
+		return (error);
+	}
+
+	printf("mfi%d: Found %d foreign configurations\n", mfi_unit,
+	       info.count);
+	close(fd);
+	return (0);
+}
+MFI_COMMAND(foreign, scan, foreign_scan);
+
+static int
+foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
+{
+	struct mfi_config_data *config;
+	char prefix[26];
+	int error;
+	uint8_t mbox[4];
+
+	bzero(mbox, sizeof(mbox));
+	mbox[0] = cfgidx;
+	if (mfi_config_read_opcode(fd, opcode, &config, mbox, sizeof(mbox)) < 0) {
+		error = errno;
+		warn("Failed to get foreign config %d", error);
+		close(fd);
+		return (error);
+	}
+
+	if (opcode == MFI_DCMD_CFG_FOREIGN_PREVIEW)
+		sprintf(prefix, "Foreign configuration preview %d", cfgidx);
+	else
+		sprintf(prefix, "Foreign configuration %d", cfgidx);
+	/*
+	 * MegaCli uses DCMD opcodes: 0x03100200 (which fails) followed by
+	 * 0x1a721880 which returns what looks to be drive / volume info
+	 * but we have no real information on what these are or what they do
+	 * so we're currently relying solely on the config returned above
+	 */
+	if (diagnostic)
+		dump_config(fd, config, prefix);
+	else {
+		char *ld_list;
+		int i;
+
+		ld_list = (char *)(config->array);
+
+        	printf("%s: %d arrays, %d volumes, %d spares\n", prefix, 
+		       config->array_count, config->log_drv_count,
+		       config->spares_count);
+
+
+		for (i = 0; i < config->array_count; i++)
+			 ld_list += config->array_size;
+
+		for (i = 0; i < config->log_drv_count; i++) {
+        		const char *level;
+        		char size[6], stripe[5];
+			struct mfi_ld_config *ld;
+
+			ld = (struct mfi_ld_config *)ld_list;
+
+        		format_stripe(stripe, sizeof(stripe),
+            			ld->params.stripe_size);
+			/*
+			 * foreign configs don't seem to have a secondary raid level
+			 * but, we can use span depth here as if a LD spans multiple
+			 * arrays of disks (2 raid 1 sets for example), we will have an
+			 * indication based on the spam depth. swb
+			 */ 
+        		level = mfi_raid_level(ld->params.primary_raid_level,
+            					(ld->params.span_depth - 1));
+
+        		humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512,
+            			"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+
+			printf(" ID%d ", i);
+              		printf("(%6s) %-8s |",
+				size, level);
+			printf("volume spans %d %s\n",	ld->params.span_depth,
+							(ld->params.span_depth > 1) ? "arrays" : "array");
+			for (int j = 0; j < ld->params.span_depth; j++) {
+				char *ar_list;
+				struct mfi_array *ar;
+				uint16_t device_id;
+
+				printf("      array %u @ ", ld->span[j].array_ref);
+        			humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512,
+            				"", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+				
+				printf("(%6s)\n",size);
+				ar_list = (char *)config->array + (ld->span[j].array_ref * config->array_size);
+
+				ar = (struct mfi_array *)ar_list;
+				for (int k = 0; k < ar->num_drives; k++) {
+					device_id = ar->pd[k].ref.v.device_id;
+					if (device_id == 0xffff)
+						printf("        drive MISSING\n");
+					else {
+						printf("        drive %u %s\n", device_id,
+			    				mfi_pdstate(ar->pd[k].fw_state));
+					}
+				}
+
+			}
+			ld_list += config->log_drv_size;
+		}
+	}
+
+	free(config);
+
+	return (0);
+}
+
+int
+display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd)
+{
+	struct mfi_foreign_scan_info info;
+	uint8_t i;
+	int error, fd;
+
+	if (ac > 2) {
+		warnx("foreign display: extra arguments");
+                return (EINVAL);
+	}
+
+	fd = mfi_open(mfi_unit, O_RDONLY);
+	if (fd < 0) {
+		error = errno;
+		warn("mfi_open");
+		return (error);
+	}
+
+	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+	    sizeof(info), NULL, 0, NULL) < 0) {
+		error = errno;
+		warn("Failed to scan foreign configuration");
+		close(fd);
+		return (error);
+	}
+
+	if (info.count == 0) {
+		warnx("foreign display: no foreign configs found");
+		close(fd);
+		return (EINVAL);
+	}
+
+	if (ac == 1) {
+		for (i = 0; i < info.count; i++) {
+			error = foreign_show_cfg(fd,
+				display_cmd, i, diagnostic);
+			if(error != 0) {
+				close(fd);
+				return (error);
+			}
+			if (i < info.count - 1)
+				printf("\n");
+		}
+	} else if (ac == 2) {
+		error = foreign_show_cfg(fd,
+			display_cmd, atoi(av[1]), diagnostic);
+		if (error != 0) {
+			close(fd);
+			return (error);
+		}
+	}
+	
+	close(fd);
+	return (0);
+}
+
+static int
+foreign_display(int ac, char **av)
+{
+	return(display_format(ac, av, 1/*diagnostic output*/, MFI_DCMD_CFG_FOREIGN_DISPLAY));
+}
+MFI_COMMAND(foreign, diag, foreign_display);
+
+static int
+foreign_preview(int ac, char **av)
+{
+	return(display_format(ac, av, 1/*diagnostic output*/, MFI_DCMD_CFG_FOREIGN_PREVIEW));
+}
+MFI_COMMAND(foreign, preview, foreign_preview);
+
+static int
+foreign_import(int ac, char **av)
+{
+	struct mfi_foreign_scan_info info;
+	int ch, error, fd;
+	uint8_t cfgidx;
+	uint8_t mbox[4];
+
+	if (ac > 2) {
+		warnx("foreign preview: extra arguments");
+                return (EINVAL);
+	}
+
+	fd = mfi_open(mfi_unit, O_RDWR);
+	if (fd < 0) {
+		error = errno;
+		warn("mfi_open");
+		return (error);
+	}
+
+	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+	    sizeof(info), NULL, 0, NULL) < 0) {
+		error = errno;
+		warn("Failed to scan foreign configuration");
+		close(fd);
+		return (error);
+	}
+
+	if (info.count == 0) {
+		warnx("foreign import: no foreign configs found");
+		close(fd);
+		return (EINVAL);
+	}
+
+	if (ac == 1) {
+		cfgidx = 0xff;
+		printf("Are you sure you wish to import ALL foreign "
+		       "configurations on mfi%u? [y/N] ", mfi_unit);
+	} else {
+		/*
+		 * While this is docmmented for MegaCli this failed with
+		 * exit code 0x03 on the test controller which was a Supermicro
+		 * SMC2108 with firmware 12.12.0-0095 which is a LSI 2108 based
+		 * controller.
+		 */
+		cfgidx = atoi(av[1]);
+		if (cfgidx >= info.count) {
+			warnx("Invalid foreign config %d specified max is %d",
+			      cfgidx, info.count - 1);
+			close(fd);
+			return (EINVAL);
+		}
+		printf("Are you sure you wish to import the foreign "
+		       "configuration %d on mfi%u? [y/N] ", cfgidx, mfi_unit);
+	}
+
+	ch = getchar();
+	if (ch != 'y' && ch != 'Y') {
+		printf("\nAborting\n");
+		close(fd);
+		return (0);
+	}
+
+	bzero(mbox, sizeof(mbox));
+	mbox[0] = cfgidx;
+	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_IMPORT, NULL, 0, mbox,
+	    sizeof(mbox), NULL) < 0) {
+		error = errno;
+		warn("Failed to import foreign configuration");
+		close(fd);
+		return (error);
+	}
+
+	if (ac == 1)
+		printf("mfi%d: All foreign configurations imported\n",
+		       mfi_unit);
+	else
+		printf("mfi%d: Foreign configuration %d imported\n", mfi_unit,
+		       cfgidx);
+	close(fd);
+	return (0);
+}
+MFI_COMMAND(foreign, import, foreign_import);

Modified: stable/9/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfi_show.c	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/mfi_show.c	Fri Jul 12 02:26:15 2013	(r253244)
@@ -40,9 +40,11 @@
 #include 
 #include "mfiutil.h"
 
+static const char* foreign_state = " (FOREIGN)";
+
 MFI_TABLE(top, show);
 
-static void
+void
 format_stripe(char *buf, size_t buflen, uint8_t stripe)
 {
 
@@ -291,7 +293,7 @@ show_battery(int ac, char **av __unused)
 }
 MFI_COMMAND(show, battery, show_battery);
 
-static void
+void
 print_ld(struct mfi_ld_info *info, int state_len)
 {
 	struct mfi_ld_params *params = &info->ld_config.params;
@@ -312,19 +314,24 @@ print_ld(struct mfi_ld_info *info, int s
 		    mfi_ldstate(params->state));
 }
 
-static void
+void
 print_pd(struct mfi_pd_info *info, int state_len)
 {
 	const char *s;
-	char buf[6];
+	char buf[256];
 
 	humanize_number(buf, sizeof(buf), info->raw_size * 512, "",
 	    HN_AUTOSCALE, HN_B | HN_NOSPACE |HN_DECIMAL);
 	printf("(%6s) ", buf);
+	if (info->state.ddf.v.pd_type.is_foreign) {
+		sprintf(buf, "%s%s", mfi_pdstate(info->fw_state), foreign_state);
+		s = buf;
+	} else
+		s = mfi_pdstate(info->fw_state);
 	if (state_len > 0)
-		printf("%-*s", state_len, mfi_pdstate(info->fw_state));
+		printf("%-*s", state_len, s);
 	else
-		printf("%s", mfi_pdstate(info->fw_state));
+		printf("%s",s);
 	s = mfi_pd_inq_string(info);
 	if (s != NULL)
 		printf(" %s", s);
@@ -560,6 +567,8 @@ show_drives(int ac, char **av __unused)
 			goto error;
 		}
 		len = strlen(mfi_pdstate(info.fw_state));
+		if (info.state.ddf.v.pd_type.is_foreign)
+			len += strlen(foreign_state);
 		if (len > state_len)
 			state_len = len;
 	}
@@ -787,7 +796,7 @@ show_progress(int ac, char **av __unused
 			printf("drive %s ", mfi_drive_name(NULL, device_id,
 			    MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS));
 			mfi_display_progress("Clear", &pinfo.prog_info.clear);
-			busy = 1;
+			
 		}
 	}
 
@@ -800,3 +809,10 @@ show_progress(int ac, char **av __unused
 	return (0);
 }
 MFI_COMMAND(show, progress, show_progress);
+
+static int
+show_foreign(int ac, char **av)
+{
+	return(display_format(ac, av, 0/*normal display*/, MFI_DCMD_CFG_FOREIGN_DISPLAY));
+}
+MFI_COMMAND(show, foreign, show_foreign);

Modified: stable/9/usr.sbin/mfiutil/mfiutil.8
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfiutil.8	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/mfiutil.8	Fri Jul 12 02:26:15 2013	(r253244)
@@ -63,6 +63,9 @@
 .Cm show firmware
 .Nm
 .Op Fl u Ar unit
+.Cm show foreign Op Ar volume
+.Nm
+.Op Fl u Ar unit
 .Cm show logstate
 .Nm
 .Op Fl d
@@ -140,6 +143,21 @@
 .Cm patrol Ar command Op Ar interval Op Ar start
 .Nm
 .Op Fl u Ar unit
+.Cm foreign scan
+.Nm
+.Op Fl u Ar unit
+.Cm foreign clear Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign diag Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign preview Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign import Op Ar config
+.Nm
+.Op Fl u Ar unit
 .Cm flash Ar file
 .Nm
 .Op Fl u Ar unit
@@ -321,6 +339,8 @@ The entry in the event log corresponding
 .El
 .It Cm show firmware
 Lists all of the firmware images present on the controller.
+.It Cm show foreign
+Displays detected foreign configurations on disks for importation or removal.
 .It Cm show logstate
 Display the various sequence numbers associated with the event log.
 .It Cm show patrol
@@ -567,6 +587,35 @@ Enable manual patrol reads that are only
 Start a patrol read operation.
 .It Cm stop patrol
 Stop a currently running patrol read operation.
+.It Cm foreign scan
+Scan for foreign configurations and display the number found. The
+.Ar config
+argument for the commands below takes the form of a number from 0 to the total
+configurations found.
+.It Cm foreign clear Op config
+Clear the specifed foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
+.It Cm foreign diag Op config
+Display a diagnostic display of the specifed foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
+.It Cm foreign preview Op config
+Preview the specifed foreign
+.Ar config
+after import or all if no
+.Ar config
+argument is provided.
+.It Cm foreign import Op config
+Import the specifed foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
 .It Cm flash Ar file
 Updates the flash on the controller with the firmware stored in
 .Ar file .
@@ -635,6 +684,9 @@ patrol read starting in 5 minutes:
 .Pp
 .Dl Nm Cm patrol auto 604800 300
 .Pp
+Display the second detected foreign configuration:
+.Pp
+.Dl Nm Cm show foreign 1
 .Sh SEE ALSO
 .Xr mfi 4
 .Sh HISTORY

Modified: stable/9/usr.sbin/mfiutil/mfiutil.c
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfiutil.c	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/mfiutil.c	Fri Jul 12 02:26:15 2013	(r253244)
@@ -60,6 +60,7 @@ usage(void)
 	fprintf(stderr, "    show drives               - list physical drives\n");
 	fprintf(stderr, "    show events               - display event log\n");
 	fprintf(stderr, "    show firmware             - list firmware images\n");
+	fprintf(stderr, "    show foreign              - display detected foreign volumes\n");
 	fprintf(stderr, "    show logstate             - display event log sequence numbers\n");
 	fprintf(stderr, "    show volumes              - list logical volumes\n");
 	fprintf(stderr, "    show patrol               - display patrol read status\n");
@@ -83,6 +84,11 @@ usage(void)
 	fprintf(stderr, "    patrol  [interval [start]]\n");
 	fprintf(stderr, "    start patrol              - start a patrol read\n");
 	fprintf(stderr, "    stop patrol               - stop a patrol read\n");
+	fprintf(stderr, "    foreign scan              - scan for foreign configurations\n");
+	fprintf(stderr, "    foreign clear [volume]    - clear foreign configurations (default all)\n");
+	fprintf(stderr, "    foreign diag [volume]     - diagnostic display foreign configurations (default all)\n");
+	fprintf(stderr, "    foreign preview [volume]  - preview foreign configurations (default all)\n");
+	fprintf(stderr, "    foreign import [volume]   - import foreign configurations (default all)\n");
 	fprintf(stderr, "    flash \n");
 	fprintf(stderr, "    start learn               - start a BBU relearn\n");
 	fprintf(stderr, "    bbu       - set BBU properties\n");

Modified: stable/9/usr.sbin/mfiutil/mfiutil.h
==============================================================================
--- stable/9/usr.sbin/mfiutil/mfiutil.h	Fri Jul 12 02:11:42 2013	(r253243)
+++ stable/9/usr.sbin/mfiutil/mfiutil.h	Fri Jul 12 02:26:15 2013	(r253244)
@@ -123,6 +123,16 @@ struct mfiutil_command {
 extern int mfi_unit;
 extern u_int mfi_opts;
 
+/* We currently don't know the full details of the following struct */
+struct mfi_foreign_scan_cfg {
+        char data[24];
+};
+
+struct mfi_foreign_scan_info {
+        uint32_t count; /* Number of foreign configs found */
+        struct mfi_foreign_scan_cfg cfgs[8];
+};
+
 void	mbox_store_ldref(uint8_t *mbox, union mfi_ld_ref *ref);
 void	mbox_store_pdref(uint8_t *mbox, union mfi_pd_ref *ref);
 void	mfi_display_progress(const char *label, struct mfi_progress *prog);
@@ -135,6 +145,8 @@ const char *mfi_pd_inq_string(struct mfi
 const char *mfi_volume_name(int fd, uint8_t target_id);
 int	mfi_volume_busy(int fd, uint8_t target_id);
 int	mfi_config_read(int fd, struct mfi_config_data **configp);
+int	mfi_config_read_opcode(int fd, uint32_t opcode,
+    struct mfi_config_data **configp, uint8_t *mbox, size_t mboxlen);
 int	mfi_lookup_drive(int fd, char *drive, uint16_t *device_id);
 int	mfi_lookup_volume(int fd, const char *name, uint8_t *target_id);
 int	mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize,
@@ -151,6 +163,10 @@ int	mfi_reconfig_supported(void);
 const char *mfi_status(u_int status_code);
 const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id,
     uint32_t def);
+void	format_stripe(char *buf, size_t buflen, uint8_t stripe);
+void	print_ld(struct mfi_ld_info *info, int state_len);
+void	print_pd(struct mfi_pd_info *info, int state_len);
+void	dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix);
 int	mfi_bbu_get_props(int fd, struct mfi_bbu_properties *props,
 	    uint8_t *statusp);
 int	mfi_bbu_set_props(int fd, struct mfi_bbu_properties *props,
@@ -159,4 +175,5 @@ void	mfi_autolearn_period(uint32_t, char
 void	mfi_next_learn_time(uint32_t, char *, size_t);
 void	mfi_autolearn_mode(uint8_t, char *, size_t);
 
+int	display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd);
 #endif /* !__MFIUTIL_H__ */

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 02:28:02 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 2680435B;
 Fri, 12 Jul 2013 02:28:02 +0000 (UTC)
 (envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 1846A128C;
 Fri, 12 Jul 2013 02:28:02 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C2S1u4016300;
 Fri, 12 Jul 2013 02:28:01 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C2S1b9016299;
 Fri, 12 Jul 2013 02:28:01 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201307120228.r6C2S1b9016299@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Fri, 12 Jul 2013 02:28:01 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253245 - stable/9/sys/dev/hme
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 02:28:02 -0000

Author: yongari
Date: Fri Jul 12 02:28:01 2013
New Revision: 253245
URL: http://svnweb.freebsd.org/changeset/base/253245

Log:
  MFC r253134:
    Avoid controller reinitialization which could be triggered by
    dhclient(8) or alias addresses are added.

Modified:
  stable/9/sys/dev/hme/if_hme.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/hme/if_hme.c
==============================================================================
--- stable/9/sys/dev/hme/if_hme.c	Fri Jul 12 02:26:15 2013	(r253244)
+++ stable/9/sys/dev/hme/if_hme.c	Fri Jul 12 02:28:01 2013	(r253245)
@@ -742,6 +742,10 @@ hme_init_locked(struct hme_softc *sc)
 	u_int32_t n, v;
 
 	HME_LOCK_ASSERT(sc, MA_OWNED);
+
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+		return;
+
 	/*
 	 * Initialization sequence. The numbered steps below correspond
 	 * to the sequence outlined in section 6.3.5.1 in the Ethernet
@@ -1324,6 +1328,7 @@ hme_eint(struct hme_softc *sc, u_int sta
 	/* check for fatal errors that needs reset to unfreeze DMA engine */
 	if ((status & HME_SEB_STAT_FATAL_ERRORS) != 0) {
 		HME_WHINE(sc->sc_dev, "error signaled, status=%#x\n", status);
+		sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 		hme_init_locked(sc);
 	}
 }
@@ -1370,6 +1375,7 @@ hme_watchdog(struct hme_softc *sc)
 		device_printf(sc->sc_dev, "device timeout (no link)\n");
 	++ifp->if_oerrors;
 
+	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 	hme_init_locked(sc);
 	hme_start_locked(ifp);
 	return (EJUSTRETURN);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 05:39:52 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 3EBA5E0E;
 Fri, 12 Jul 2013 05:39:52 +0000 (UTC)
 (envelope-from Andre.Albsmeier@siemens.com)
Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28])
 by mx1.freebsd.org (Postfix) with ESMTP id BA7B81AB8;
 Fri, 12 Jul 2013 05:39:51 +0000 (UTC)
Received: from mail2.siemens.de (localhost [127.0.0.1])
 by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id r6C5doOe027166;
 Fri, 12 Jul 2013 07:39:50 +0200
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130])
 by mail2.siemens.de (8.13.6/8.13.6) with ESMTP id r6C5dot2005087;
 Fri, 12 Jul 2013 07:39:50 +0200
Received: (from localhost)
 by curry.mchp.siemens.de (8.14.7/8.14.7) id r6C5dorw051492;
Date: Fri, 12 Jul 2013 07:39:50 +0200
From: Andre Albsmeier 
To: "Kenneth D. Merry" 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130712053950.GA97972@bali>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali>
 <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali>
 <20130710184915.GA28790@nargothrond.kdm.org>
 <20130710185833.GA83135@bali>
 <20130711205332.GA26100@nargothrond.kdm.org>
 <20130711220211.GA30392@nargothrond.kdm.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20130711220211.GA30392@nargothrond.kdm.org>
X-Echelon: 
X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses!
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 05:39:52 -0000

On Fri, 12-Jul-2013 at 00:02:11 +0200, Kenneth D. Merry wrote:
> On Thu, Jul 11, 2013 at 14:53:32 -0600, Kenneth D. Merry wrote:
> > On Wed, Jul 10, 2013 at 20:58:33 +0200, Andre Albsmeier wrote:
> > > On Wed, 10-Jul-2013 at 20:49:15 +0200, Kenneth D. Merry wrote:
> > > > On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> > > > > On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > > > > > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > > > > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > > > > > Author: ken
> > > > > > > > Date: Tue Jun 25 21:43:49 2013
> > > > > > > > New Revision: 252214
> > > > > > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > > > > > 
> > > > > > > Hi Ken,
> > > > > > > 
> > > > > > > > Log:
> > > > > > > >   MFC: 249658, 249701
> > > > > > > > 
> > > > > > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > > > > > 
> > > > > > > >   This allows mapping a tape drive in a changer (as reported by
> > > > > > > >   'chio status') to a sa(4) driver instance by comparing the
> > > > > > > >   serial numbers.
> > > > > > > > 
> > > > > > > >   The designators can be ASCII (which is printed out directly), binary
> > > > > > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > > > > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > > > > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > > > > > >   explanation and example UTF-8 printing code.
> > > > > > > > 
> > > > > > > >   chio.h:               Modify the changer_element_status structure to add new
> > > > > > > >                 fields and definitions from the SMC3r16 spec.
> > > > > > > > 
> > > > > > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > > > > > >                 define a new CHIOGSTATUS ioctl.
> > > > > > > > 
> > > > > > > >                 Clean up some tab/space issues.
> > > > > > > > 
> > > > > > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > > > > > >                 if it is supplied by a device.
> > > > > > > > 
> > > > > > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > > > > > >                 ELEMENT STATUS command structure.
> > > > > > > > 
> > > > > > > >                 Add a read_element_status_device_id structure
> > > > > > > >                 for the data fields in the new standard. Add new
> > > > > > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > > > > > >                 and address data from either SCSI-2 or newer devices.
> > > > > > > > 
> > > > > > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > > > > > >                 ELEMENT STATUS data.
> > > > > > > > 
> > > > > > > >                 Add new arguments to scsi_read_element_status() to
> > > > > > > >                 allow the user to request the DVCID and CURDATA bits.
> > > > > > > 
> > > > > > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > > > > > 
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > > > > > 
> > > > > > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > > > > > this workaround to make it work again until a better solution is available:
> > > > > > > 
> > > > > > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > > > > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > > > > > @@ -1245,8 +1245,8 @@
> > > > > > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > > > > > >  				 /* voltag */ want_voltags,
> > > > > > >  				 /* sea */ softc->sc_firsts[chet],
> > > > > > > -				 /* dvcid */ 1,
> > > > > > > -				 /* curdata */ 1,
> > > > > > > +				 /* dvcid */ 0,
> > > > > > > +				 /* curdata */ 0,
> > > > > > >  				 /* count */ 1,
> > > > > > >  				 /* data_ptr */ data,
> > > > > > >  				 /* dxfer_len */ 1024,
> > > > > > > @@ -1284,8 +1284,8 @@
> > > > > > >  				 /* voltag */ want_voltags,
> > > > > > >  				 /* sea */ softc->sc_firsts[chet]
> > > > > > >  				 + cesr->cesr_element_base,
> > > > > > > -				 /* dvcid */ 1,
> > > > > > > -				 /* curdata */ 1,
> > > > > > > +				 /* dvcid */ 0,
> > > > > > > +				 /* curdata */ 0,
> > > > > > >  				 /* count */ cesr->cesr_element_count,
> > > > > > >  				 /* data_ptr */ data,
> > > > > > >  				 /* dxfer_len */ size,
> > > > > > > 
> > > > > > > 	-Andre
> > > > > > 
> > > > > > Oops, sorry.
> > > > > > 
> > > > > > We need to check the SCSI version to see whether to set those bits, and
> > > > > > also fall back in case it doesn't work.
> > > > > > 
> > > > > > I am on vacation and have very spotty net access.  I can't do anything
> > > > > > about it until I get back next week.
> > > > > > 
> > > > > > Justin and Alan (CCed) can work on the fix, though.
> > > > > 
> > > > > Take your time, for me it's working right now
> > > > > with the above patch...
> > > > 
> > > > Okay, I'm back and can take a look at this.
> > > 
> > > Welcome back ;-)
> > > 
> > > > 
> > > > Can you send me:
> > > 
> > > Sure, I am happy to help.
> > > 
> > > > 
> > > > camcontrol inquiry ch0 -v
> > > 
> > > pass17:  Removable Changer SCSI-2 device 
> > > pass17: Serial Number 0021009613
> > > pass17: 3.300MB/s transfers
> > > 
> > > > camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"
> > > 
> > > 0 0 0 0 0 0 0 0 
> > 
> > Okay, that was helpful, thanks!
> > 
> > > > 
> > > > I want to see what SCSI version this changer reports.  The second command
> > > > will print out the SCSI version descriptors, if any, that the changer
> > > > reports.
> > > 
> > > In case you need more info just drop me a note.
> > > 
> > > Thanks for looking into this.
> > 
> > Can you try the attached patch, and see how it works for you?
> > 
> > It defaults to not setting those bits for changers that claim to be SCSI-2
> > or below.  And if a SCSI-3 or higher changer returns an Illegal Request
> > type error, it will retry with the bits cleared to see whether that works.
> > 
> > I also bumped the read element status timeout after some testing with a
> > Spectra T-380.
> > 
> > The patch is against head, but stable/9 shouldn't be much different.
> 
> Oops, here is the patch.

Tried "chio status" and "chio move", both work!
dmesg now added a quirk entry for ch0:

 ch0:  Removable Changer SCSI-2 device 
 ch0: 3.300MB/s transfers
 ch0: 11 slots, 1 drive, 1 picker, 1 portal
+ch0: quirks=0x2
 sa0 at ahd3 bus 0 scbus4 target 0 lun 0
 sa0:  Removable Sequential Access SCSI-3 device 
 sa0: 160.000MB/s transfers (80.000MHz DT, offset 126, 16bit)

Thanks,

	-Andre

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 05:45:10 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 15E1F357;
 Fri, 12 Jul 2013 05:45:10 +0000 (UTC)
 (envelope-from grehan@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 08BDF1AFF;
 Fri, 12 Jul 2013 05:45:10 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C5j9UP075902;
 Fri, 12 Jul 2013 05:45:09 GMT (envelope-from grehan@svn.freebsd.org)
Received: (from grehan@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6C5j9m1075901;
 Fri, 12 Jul 2013 05:45:09 GMT (envelope-from grehan@svn.freebsd.org)
Message-Id: <201307120545.r6C5j9m1075901@svn.freebsd.org>
From: Peter Grehan 
Date: Fri, 12 Jul 2013 05:45:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253250 - stable/9/sys/kern
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 05:45:10 -0000

Author: grehan
Date: Fri Jul 12 05:45:09 2013
New Revision: 253250
URL: http://svnweb.freebsd.org/changeset/base/253250

Log:
  MFC r245066
  -------------------------------------------------------------------------
  Teach the kernel to recognize that it is executing inside a bhyve virtual
  machine.
  -------------------------------------------------------------------------
  
  This will help a 9.2 guest to run more effectively as a bhyve guest.
  
  Reviewed by:	neel
  Approved by:	re

Modified:
  stable/9/sys/kern/subr_param.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/subr_param.c
==============================================================================
--- stable/9/sys/kern/subr_param.c	Fri Jul 12 04:22:46 2013	(r253249)
+++ stable/9/sys/kern/subr_param.c	Fri Jul 12 05:45:09 2013	(r253250)
@@ -163,6 +163,7 @@ static const char *const vm_bnames[] = {
 	"Plex86",			/* Plex86 */
 	"Bochs",			/* Bochs */
 	"Xen",				/* Xen */
+	"BHYVE",			/* bhyve */
 	"Seabios",			/* KVM */
 	NULL
 };

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 10:02:47 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id A80A1630;
 Fri, 12 Jul 2013 10:02:47 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 9A4E81AF8;
 Fri, 12 Jul 2013 10:02:47 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CA2lgI051352;
 Fri, 12 Jul 2013 10:02:47 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CA2lkH051351;
 Fri, 12 Jul 2013 10:02:47 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201307121002.r6CA2lkH051351@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 12 Jul 2013 10:02:47 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253257 - stable/9/sys/vm
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 10:02:47 -0000

Author: kib
Date: Fri Jul 12 10:02:47 2013
New Revision: 253257
URL: http://svnweb.freebsd.org/changeset/base/253257

Log:
  MFC r253095:
  Fix typo in comment.
  
  Approved by:	re (hrs)

Modified:
  stable/9/sys/vm/swap_pager.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/vm/swap_pager.c
==============================================================================
--- stable/9/sys/vm/swap_pager.c	Fri Jul 12 09:20:55 2013	(r253256)
+++ stable/9/sys/vm/swap_pager.c	Fri Jul 12 10:02:47 2013	(r253257)
@@ -835,7 +835,7 @@ swap_pager_freespace(vm_object_t object,
  * SWAP_PAGER_RESERVE() - reserve swap blocks in object
  *
  *	Assigns swap blocks to the specified range within the object.  The 
- *	swap blocks are not zerod.  Any previous swap assignment is destroyed.
+ *	swap blocks are not zeroed.  Any previous swap assignment is destroyed.
  *
  *	Returns 0 on success, -1 on failure.
  */

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 10:07:49 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 0A37B8D0;
 Fri, 12 Jul 2013 10:07:49 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id F0DD41B20;
 Fri, 12 Jul 2013 10:07:48 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CA7mau052186;
 Fri, 12 Jul 2013 10:07:48 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CA7mpN052185;
 Fri, 12 Jul 2013 10:07:48 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201307121007.r6CA7mpN052185@svn.freebsd.org>
From: Konstantin Belousov 
Date: Fri, 12 Jul 2013 10:07:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253259 - stable/9/sys/kern
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 10:07:49 -0000

Author: kib
Date: Fri Jul 12 10:07:48 2013
New Revision: 253259
URL: http://svnweb.freebsd.org/changeset/base/253259

Log:
  MFC r251282:
  When auto-sizing the buffer cache, limit the amount of physical memory
  used as the estimation of size, to 16GB.  This provides around 100K of
  buffer headers and corresponding KVA for buffer map at the peak.
  Sizing the cache larger is not useful, also resulting in the wasting
  and exhausting of KVA for large machines.
  
  MFC note: the commit message was adjusted to match the code change, the
  sizing cap is for 16GB, as noted by delphij.
  
  Approved by:	re (delphij)

Modified:
  stable/9/sys/kern/vfs_bio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_bio.c
==============================================================================
--- stable/9/sys/kern/vfs_bio.c	Fri Jul 12 10:07:21 2013	(r253258)
+++ stable/9/sys/kern/vfs_bio.c	Fri Jul 12 10:07:48 2013	(r253259)
@@ -562,7 +562,8 @@ kern_vfs_bio_buffer_alloc(caddr_t v, lon
 			nbuf += min((physmem_est - 4096) / factor,
 			    65536 / factor);
 		if (physmem_est > 65536)
-			nbuf += (physmem_est - 65536) * 2 / (factor * 5);
+			nbuf += min((physmem_est - 65536) * 2 / (factor * 5),
+			    32 * 1024 * 1024 / (factor * 5));
 
 		if (maxbcache && nbuf > maxbcache / BKVASIZE)
 			nbuf = maxbcache / BKVASIZE;

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 12:40:22 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 4A1DD73B;
 Fri, 12 Jul 2013 12:40:22 +0000 (UTC)
 (envelope-from tuexen@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 3C2B4125F;
 Fri, 12 Jul 2013 12:40:22 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CCeM9S096155;
 Fri, 12 Jul 2013 12:40:22 GMT (envelope-from tuexen@svn.freebsd.org)
Received: (from tuexen@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CCeMMi096154;
 Fri, 12 Jul 2013 12:40:22 GMT (envelope-from tuexen@svn.freebsd.org)
Message-Id: <201307121240.r6CCeMMi096154@svn.freebsd.org>
From: Michael Tuexen 
Date: Fri, 12 Jul 2013 12:40:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253263 - stable/9/sys/netinet
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 12:40:22 -0000

Author: tuexen
Date: Fri Jul 12 12:40:21 2013
New Revision: 253263
URL: http://svnweb.freebsd.org/changeset/base/253263

Log:
  MFC r253099:
  Use IPSECSTAT_INC() and IPSEC6STAT_INC() macros for ipsec statistics
  accounting.
  
  Approved by: re@

Modified:
  stable/9/sys/netinet/sctp_input.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/sctp_input.c
==============================================================================
--- stable/9/sys/netinet/sctp_input.c	Fri Jul 12 12:36:12 2013	(r253262)
+++ stable/9/sys/netinet/sctp_input.c	Fri Jul 12 12:40:21 2013	(r253263)
@@ -5705,7 +5705,7 @@ sctp_common_input_processing(struct mbuf
 #ifdef INET
 		case AF_INET:
 			if (ipsec4_in_reject(m, &inp->ip_inp.inp)) {
-				MODULE_GLOBAL(ipsec4stat).in_polvio++;
+				IPSECSTAT_INC(in_polvio);
 				SCTP_STAT_INCR(sctps_hdrops);
 				goto out;
 			}
@@ -5714,7 +5714,7 @@ sctp_common_input_processing(struct mbuf
 #ifdef INET6
 		case AF_INET6:
 			if (ipsec6_in_reject(m, &inp->ip_inp.inp)) {
-				MODULE_GLOBAL(ipsec6stat).in_polvio++;
+				IPSEC6STAT_INC(in_polvio);
 				SCTP_STAT_INCR(sctps_hdrops);
 				goto out;
 			}

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 14:58:09 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id E3B2D5D6;
 Fri, 12 Jul 2013 14:58:09 +0000 (UTC)
 (envelope-from tuexen@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id D5EE41AE3;
 Fri, 12 Jul 2013 14:58:09 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CEw9H5036989;
 Fri, 12 Jul 2013 14:58:09 GMT (envelope-from tuexen@svn.freebsd.org)
Received: (from tuexen@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CEw98v036988;
 Fri, 12 Jul 2013 14:58:09 GMT (envelope-from tuexen@svn.freebsd.org)
Message-Id: <201307121458.r6CEw98v036988@svn.freebsd.org>
From: Michael Tuexen 
Date: Fri, 12 Jul 2013 14:58:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253269 - stable/9/lib/libc/net
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 14:58:10 -0000

Author: tuexen
Date: Fri Jul 12 14:58:09 2013
New Revision: 253269
URL: http://svnweb.freebsd.org/changeset/base/253269

Log:
  MFC r253104:
  Fix a bug where SCTP_ENABLE_STREAM_RESET is not handled by
  sctp_opt_info().
  
  MFC r253105:
  Fix the handling of SCTP_CURRENT_ASSOC and SCTP_ALL_ASSOC in
  sctp_opt_info().
  
  Approved by: re@

Modified:
  stable/9/lib/libc/net/sctp_sys_calls.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/net/sctp_sys_calls.c
==============================================================================
--- stable/9/lib/libc/net/sctp_sys_calls.c	Fri Jul 12 14:46:40 2013	(r253268)
+++ stable/9/lib/libc/net/sctp_sys_calls.c	Fri Jul 12 14:58:09 2013	(r253269)
@@ -274,6 +274,11 @@ sctp_opt_info(int sd, sctp_assoc_t id, i
 		errno = EINVAL;
 		return (-1);
 	}
+	if ((id == SCTP_CURRENT_ASSOC) ||
+	    (id == SCTP_ALL_ASSOC)) {
+		errno = EINVAL;
+		return (-1);
+	}
 	switch (opt) {
 	case SCTP_RTOINFO:
 		((struct sctp_rtoinfo *)arg)->srto_assoc_id = id;
@@ -338,6 +343,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, i
 	case SCTP_MAX_BURST:
 		((struct sctp_assoc_value *)arg)->assoc_id = id;
 		break;
+	case SCTP_ENABLE_STREAM_RESET:
+		((struct sctp_assoc_value *)arg)->assoc_id = id;
+		break;
 	default:
 		break;
 	}

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 16:41:59 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id B346112C;
 Fri, 12 Jul 2013 16:41:59 +0000 (UTC)
 (envelope-from marius@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 951A71FB8;
 Fri, 12 Jul 2013 16:41:59 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CGfx4S071153;
 Fri, 12 Jul 2013 16:41:59 GMT (envelope-from marius@svn.freebsd.org)
Received: (from marius@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CGfw9R071149;
 Fri, 12 Jul 2013 16:41:58 GMT (envelope-from marius@svn.freebsd.org)
Message-Id: <201307121641.r6CGfw9R071149@svn.freebsd.org>
From: Marius Strobl 
Date: Fri, 12 Jul 2013 16:41:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253273 - stable/9/sys/dev/pci
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 16:41:59 -0000

Author: marius
Date: Fri Jul 12 16:41:58 2013
New Revision: 253273
URL: http://svnweb.freebsd.org/changeset/base/253273

Log:
  MFC: r253120
  
  - As it turns out, not only MSI-X is broken for devices passed through by
    VMware up to at least ESXi 5.1. Actually, using INTx in that case instead
    may still result in interrupt storms, with MSI being the only working
    option in some configurations. So introduce a PCI_QUIRK_DISABLE_MSIX quirk
    which only blacklists MSI-X but not also MSI and use it for the VMware
    PCI-PCI-bridges. Note that, currently, we still assume that if MSI doesn't
    work, MSI-X won't work either - but that's part of the internal logic and
    not guaranteed as part of the API contract. While at it, add and employ
    a pci_has_quirk() helper.
    Reported and tested by: Paul Bucher
  - Use NULL instead of 0 for pointers.
  
  Submitted by:	jhb (mostly)
  Approved by:	re (hrs), jhb

Modified:
  stable/9/sys/dev/pci/pci.c
  stable/9/sys/dev/pci/pci_pci.c
  stable/9/sys/dev/pci/pcib_private.h
  stable/9/sys/dev/pci/pcivar.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/pci/pci.c
==============================================================================
--- stable/9/sys/dev/pci/pci.c	Fri Jul 12 15:56:30 2013	(r253272)
+++ stable/9/sys/dev/pci/pci.c	Fri Jul 12 16:41:58 2013	(r253273)
@@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
 	(((cfg)->hdrtype == PCIM_HDRTYPE_NORMAL && reg == PCIR_BIOS) ||	\
 	 ((cfg)->hdrtype == PCIM_HDRTYPE_BRIDGE && reg == PCIR_BIOS_1))
 
+static int		pci_has_quirk(uint32_t devid, int quirk);
 static pci_addr_t	pci_mapbase(uint64_t mapreg);
 static const char	*pci_maptype(uint64_t mapreg);
 static int		pci_mapsize(uint64_t testval);
@@ -130,6 +131,7 @@ static void		pci_enable_msix(device_t de
 static void		pci_mask_msix(device_t dev, u_int index);
 static void		pci_unmask_msix(device_t dev, u_int index);
 static int		pci_msi_blacklisted(void);
+static int		pci_msix_blacklisted(void);
 static void		pci_resume_msi(device_t dev);
 static void		pci_resume_msix(device_t dev);
 static int		pci_remap_intr_method(device_t bus, device_t dev,
@@ -193,7 +195,7 @@ static device_method_t pci_methods[] = {
 DEFINE_CLASS_0(pci, pci_driver, pci_methods, sizeof(struct pci_softc));
 
 static devclass_t pci_devclass;
-DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, 0);
+DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, NULL);
 MODULE_VERSION(pci, 1);
 
 static char	*pci_vendordata;
@@ -203,15 +205,16 @@ struct pci_quirk {
 	uint32_t devid;	/* Vendor/device of the card */
 	int	type;
 #define	PCI_QUIRK_MAP_REG	1 /* PCI map register in weird place */
-#define	PCI_QUIRK_DISABLE_MSI	2 /* MSI/MSI-X doesn't work */
+#define	PCI_QUIRK_DISABLE_MSI	2 /* Neither MSI nor MSI-X work */
 #define	PCI_QUIRK_ENABLE_MSI_VM	3 /* Older chipset in VM where MSI works */
 #define	PCI_QUIRK_UNMAP_REG	4 /* Ignore PCI map register */
+#define	PCI_QUIRK_DISABLE_MSIX	5 /* MSI-X doesn't work */
 	int	arg1;
 	int	arg2;
 };
 
 static const struct pci_quirk pci_quirks[] = {
-	/* The Intel 82371AB and 82443MX has a map register at offset 0x90. */
+	/* The Intel 82371AB and 82443MX have a map register at offset 0x90. */
 	{ 0x71138086, PCI_QUIRK_MAP_REG,	0x90,	 0 },
 	{ 0x719b8086, PCI_QUIRK_MAP_REG,	0x90,	 0 },
 	/* As does the Serverworks OSB4 (the SMBus mapping register) */
@@ -246,8 +249,8 @@ static const struct pci_quirk pci_quirks
 	 * MSI-X allocation doesn't work properly for devices passed through
 	 * by VMware up to at least ESXi 5.1.
 	 */
-	{ 0x079015ad, PCI_QUIRK_DISABLE_MSI,	0,	0 }, /* PCI/PCI-X */
-	{ 0x07a015ad, PCI_QUIRK_DISABLE_MSI,	0,	0 }, /* PCIe */
+	{ 0x079015ad, PCI_QUIRK_DISABLE_MSIX,	0,	0 }, /* PCI/PCI-X */
+	{ 0x07a015ad, PCI_QUIRK_DISABLE_MSIX,	0,	0 }, /* PCIe */
 
 	/*
 	 * Some virtualization environments emulate an older chipset
@@ -329,7 +332,7 @@ SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi
 static int pci_honor_msi_blacklist = 1;
 TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist);
 SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD,
-    &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI");
+    &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI/MSI-X");
 
 #if defined(__i386__) || defined(__amd64__)
 static int pci_usb_takeover = 1;
@@ -342,6 +345,18 @@ SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_
 Disable this if you depend on BIOS emulation of USB devices, that is\n\
 you use USB devices (like keyboard or mouse) but do not load USB drivers");
 
+static int
+pci_has_quirk(uint32_t devid, int quirk)
+{
+	const struct pci_quirk *q;
+
+	for (q = &pci_quirks[0]; q->devid; q++) {
+		if (q->devid == devid && q->type == quirk)
+			return (1);
+	}
+	return (0);
+}
+
 /* Find a device_t by bus/slot/function in domain 0 */
 
 device_t
@@ -1358,8 +1373,8 @@ pci_alloc_msix_method(device_t dev, devi
 	if (cfg->msi.msi_alloc != 0 || cfg->msix.msix_alloc != 0)
 		return (ENXIO);
 
-	/* If MSI is blacklisted for this system, fail. */
-	if (pci_msi_blacklisted())
+	/* If MSI-X is blacklisted for this system, fail. */
+	if (pci_msix_blacklisted())
 		return (ENXIO);
 
 	/* MSI-X capability present? */
@@ -1911,38 +1926,15 @@ pci_remap_intr_method(device_t bus, devi
 int
 pci_msi_device_blacklisted(device_t dev)
 {
-	const struct pci_quirk *q;
 
 	if (!pci_honor_msi_blacklist)
 		return (0);
 
-	for (q = &pci_quirks[0]; q->devid; q++) {
-		if (q->devid == pci_get_devid(dev) &&
-		    q->type == PCI_QUIRK_DISABLE_MSI)
-			return (1);
-	}
-	return (0);
-}
-
-/*
- * Returns true if a specified chipset supports MSI when it is
- * emulated hardware in a virtual machine.
- */
-static int
-pci_msi_vm_chipset(device_t dev)
-{
-	const struct pci_quirk *q;
-
-	for (q = &pci_quirks[0]; q->devid; q++) {
-		if (q->devid == pci_get_devid(dev) &&
-		    q->type == PCI_QUIRK_ENABLE_MSI_VM)
-			return (1);
-	}
-	return (0);
+	return (pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_DISABLE_MSI));
 }
 
 /*
- * Determine if MSI is blacklisted globally on this sytem.  Currently,
+ * Determine if MSI is blacklisted globally on this system.  Currently,
  * we just check for blacklisted chipsets as represented by the
  * host-PCI bridge at device 0:0:0.  In the future, it may become
  * necessary to check other system attributes, such as the kenv values
@@ -1959,9 +1951,14 @@ pci_msi_blacklisted(void)
 	/* Blacklist all non-PCI-express and non-PCI-X chipsets. */
 	if (!(pcie_chipset || pcix_chipset)) {
 		if (vm_guest != VM_GUEST_NO) {
+			/*
+			 * Whitelist older chipsets in virtual
+			 * machines known to support MSI.
+			 */
 			dev = pci_find_bsf(0, 0, 0);
 			if (dev != NULL)
-				return (pci_msi_vm_chipset(dev) == 0);
+				return (!pci_has_quirk(pci_get_devid(dev),
+					PCI_QUIRK_ENABLE_MSI_VM));
 		}
 		return (1);
 	}
@@ -1973,6 +1970,45 @@ pci_msi_blacklisted(void)
 }
 
 /*
+ * Returns true if the specified device is blacklisted because MSI-X
+ * doesn't work.  Note that this assumes that if MSI doesn't work,
+ * MSI-X doesn't either.
+ */
+int
+pci_msix_device_blacklisted(device_t dev)
+{
+
+	if (!pci_honor_msi_blacklist)
+		return (0);
+
+	if (pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_DISABLE_MSIX))
+		return (1);
+
+	return (pci_msi_device_blacklisted(dev));
+}
+
+/*
+ * Determine if MSI-X is blacklisted globally on this system.  If MSI
+ * is blacklisted, assume that MSI-X is as well.  Check for additional
+ * chipsets where MSI works but MSI-X does not.
+ */
+static int
+pci_msix_blacklisted(void)
+{
+	device_t dev;
+
+	if (!pci_honor_msi_blacklist)
+		return (0);
+
+	dev = pci_find_bsf(0, 0, 0);
+	if (dev != NULL && pci_has_quirk(pci_get_devid(dev),
+	    PCI_QUIRK_DISABLE_MSIX))
+		return (1);
+
+	return (pci_msi_blacklisted());
+}
+
+/*
  * Attempt to allocate *count MSI messages.  The actual number allocated is
  * returned in *count.  After this function returns, each message will be
  * available to the driver as SYS_RES_IRQ resources starting at a rid 1.

Modified: stable/9/sys/dev/pci/pci_pci.c
==============================================================================
--- stable/9/sys/dev/pci/pci_pci.c	Fri Jul 12 15:56:30 2013	(r253272)
+++ stable/9/sys/dev/pci/pci_pci.c	Fri Jul 12 16:41:58 2013	(r253273)
@@ -100,7 +100,7 @@ static device_method_t pcib_methods[] = 
 static devclass_t pcib_devclass;
 
 DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc));
-DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0);
+DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL);
 
 #ifdef NEW_PCIB
 /*
@@ -624,6 +624,9 @@ pcib_attach_common(device_t dev)
     if (pci_msi_device_blacklisted(dev))
 	sc->flags |= PCIB_DISABLE_MSI;
 
+    if (pci_msix_device_blacklisted(dev))
+	sc->flags |= PCIB_DISABLE_MSIX;
+
     /*
      * Intel 815, 845 and other chipsets say they are PCI-PCI bridges,
      * but have a ProgIF of 0x80.  The 82801 family (AA, AB, BAM/CAM,
@@ -1379,7 +1382,7 @@ pcib_alloc_msix(device_t pcib, device_t 
 	struct pcib_softc *sc = device_get_softc(pcib);
 	device_t bus;
 
-	if (sc->flags & PCIB_DISABLE_MSI)
+	if (sc->flags & PCIB_DISABLE_MSIX)
 		return (ENXIO);
 	bus = device_get_parent(pcib);
 	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));

Modified: stable/9/sys/dev/pci/pcib_private.h
==============================================================================
--- stable/9/sys/dev/pci/pcib_private.h	Fri Jul 12 15:56:30 2013	(r253272)
+++ stable/9/sys/dev/pci/pcib_private.h	Fri Jul 12 16:41:58 2013	(r253273)
@@ -91,6 +91,7 @@ struct pcib_softc 
     uint32_t	flags;		/* flags */
 #define	PCIB_SUBTRACTIVE	0x1
 #define	PCIB_DISABLE_MSI	0x2
+#define	PCIB_DISABLE_MSIX	0x4
     uint16_t	command;	/* command register */
     u_int	domain;		/* domain number */
     u_int	pribus;		/* primary bus number */

Modified: stable/9/sys/dev/pci/pcivar.h
==============================================================================
--- stable/9/sys/dev/pci/pcivar.h	Fri Jul 12 15:56:30 2013	(r253272)
+++ stable/9/sys/dev/pci/pcivar.h	Fri Jul 12 16:41:58 2013	(r253273)
@@ -463,6 +463,7 @@ device_t pci_find_class(uint8_t class, u
 int	pci_pending_msix(device_t dev, u_int index);
 
 int	pci_msi_device_blacklisted(device_t dev);
+int	pci_msix_device_blacklisted(device_t dev);
 
 void	pci_ht_map_msi(device_t dev, uint64_t addr);
 

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 17:11:01 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id EA158847;
 Fri, 12 Jul 2013 17:11:01 +0000 (UTC) (envelope-from ken@kdm.org)
Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81])
 by mx1.freebsd.org (Postfix) with ESMTP id 9CA2510F5;
 Fri, 12 Jul 2013 17:11:01 +0000 (UTC)
Received: from nargothrond.kdm.org (localhost [127.0.0.1])
 by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id r6CHB0re000894;
 Fri, 12 Jul 2013 11:11:00 -0600 (MDT)
 (envelope-from ken@nargothrond.kdm.org)
Received: (from ken@localhost)
 by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id r6CHB0xF000893;
 Fri, 12 Jul 2013 11:11:00 -0600 (MDT) (envelope-from ken)
Date: Fri, 12 Jul 2013 11:11:00 -0600
From: "Kenneth D. Merry" 
To: Andre Albsmeier 
Subject: Re: svn commit: r252214 - in stable/9: bin/chio sys/cam/scsi sys/sys
Message-ID: <20130712171100.GA287@nargothrond.kdm.org>
References: <201306252143.r5PLhoM0064338@svn.freebsd.org>
 <20130702055333.GA2729@bali> <20130703052236.GA65730@nargothrond.kdm.org>
 <20130703054349.GA13656@bali> <20130710184915.GA28790@nargothrond.kdm.org>
 <20130710185833.GA83135@bali> <20130711205332.GA26100@nargothrond.kdm.org>
 <20130711220211.GA30392@nargothrond.kdm.org> <20130712053950.GA97972@bali>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20130712053950.GA97972@bali>
User-Agent: Mutt/1.4.2i
Cc: "src-committers@freebsd.org" ,
 "asomers@freebsd.org" ,
 "svn-src-stable@freebsd.org" ,
 "svn-src-all@freebsd.org" ,
 "svn-src-stable-9@freebsd.org" ,
 "gibbs@freebsd.org" 
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 17:11:02 -0000

On Fri, Jul 12, 2013 at 07:39:50 +0200, Andre Albsmeier wrote:
> On Fri, 12-Jul-2013 at 00:02:11 +0200, Kenneth D. Merry wrote:
> > On Thu, Jul 11, 2013 at 14:53:32 -0600, Kenneth D. Merry wrote:
> > > On Wed, Jul 10, 2013 at 20:58:33 +0200, Andre Albsmeier wrote:
> > > > On Wed, 10-Jul-2013 at 20:49:15 +0200, Kenneth D. Merry wrote:
> > > > > On Wed, Jul 03, 2013 at 07:43:49 +0200, Andre Albsmeier wrote:
> > > > > > On Wed, 03-Jul-2013 at 07:22:36 +0200, Kenneth D. Merry wrote:
> > > > > > > On Tue, Jul 02, 2013 at 07:53:33 +0200, Andre Albsmeier wrote:
> > > > > > > > On Tue, 25-Jun-2013 at 23:43:50 +0200, Kenneth D. Merry wrote:
> > > > > > > > > Author: ken
> > > > > > > > > Date: Tue Jun 25 21:43:49 2013
> > > > > > > > > New Revision: 252214
> > > > > > > > > URL: http://svnweb.freebsd.org/changeset/base/252214
> > > > > > > > 
> > > > > > > > Hi Ken,
> > > > > > > > 
> > > > > > > > > Log:
> > > > > > > > >   MFC: 249658, 249701
> > > > > > > > > 
> > > > > > > > >   Update chio(1) and ch(4) to support reporting element designators.
> > > > > > > > > 
> > > > > > > > >   This allows mapping a tape drive in a changer (as reported by
> > > > > > > > >   'chio status') to a sa(4) driver instance by comparing the
> > > > > > > > >   serial numbers.
> > > > > > > > > 
> > > > > > > > >   The designators can be ASCII (which is printed out directly), binary
> > > > > > > > >   (which is printed in hex format) or UTF-8, which is printed in either
> > > > > > > > >   native UTF-8 format if the terminal can support it, or in %XX notation
> > > > > > > > >   for non-ASCII characters.  Thanks to Hiroki Sato  for the
> > > > > > > > >   explanation and example UTF-8 printing code.
> > > > > > > > > 
> > > > > > > > >   chio.h:               Modify the changer_element_status structure to add new
> > > > > > > > >                 fields and definitions from the SMC3r16 spec.
> > > > > > > > > 
> > > > > > > > >                 Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
> > > > > > > > >                 define a new CHIOGSTATUS ioctl.
> > > > > > > > > 
> > > > > > > > >                 Clean up some tab/space issues.
> > > > > > > > > 
> > > > > > > > >   chio.c:       For the 'status' subcommand, print the designator field
> > > > > > > > >                 if it is supplied by a device.
> > > > > > > > > 
> > > > > > > > >   scsi_ch.h:    Add new flags for DVCID and CURDATA to the READ
> > > > > > > > >                 ELEMENT STATUS command structure.
> > > > > > > > > 
> > > > > > > > >                 Add a read_element_status_device_id structure
> > > > > > > > >                 for the data fields in the new standard. Add new
> > > > > > > > >                 unions, dt_or_obsolete and voltage_devid, to hold
> > > > > > > > >                 and address data from either SCSI-2 or newer devices.
> > > > > > > > > 
> > > > > > > > >   scsi_ch.c:    Implement support for fetching device IDs with READ
> > > > > > > > >                 ELEMENT STATUS data.
> > > > > > > > > 
> > > > > > > > >                 Add new arguments to scsi_read_element_status() to
> > > > > > > > >                 allow the user to request the DVCID and CURDATA bits.
> > > > > > > > 
> > > > > > > > This broke "chio status" when talking to my QUALSTAR TLS-8211 library:
> > > > > > > > 
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): READ ELEMENT STATUS. CDB: b8 10 fd e8 00 01 03 00 04 00 00 00
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): CAM status: SCSI Status Error
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI status: Check Condition
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): SCSI sense: ILLEGAL REQUEST asc:24,0 (Invalid field in CDB)
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Command byte 6 is invalid
> > > > > > > > Jul  2 07:08:22  server kernel: (ch0:ahd3:0:1:0): Error 22, Unretryable error
> > > > > > > > 
> > > > > > > > scsi_cmd->flags (Byte 6) must be zero for this library so I had to use
> > > > > > > > this workaround to make it work again until a better solution is available:
> > > > > > > > 
> > > > > > > > --- sys/cam/scsi/scsi_ch.c.ORI	2013-06-26 13:38:54.000000000 +0200
> > > > > > > > +++ sys/cam/scsi/scsi_ch.c	2013-07-02 07:42:24.000000000 +0200
> > > > > > > > @@ -1245,8 +1245,8 @@
> > > > > > > >  				 /* tag_action */ MSG_SIMPLE_Q_TAG,
> > > > > > > >  				 /* voltag */ want_voltags,
> > > > > > > >  				 /* sea */ softc->sc_firsts[chet],
> > > > > > > > -				 /* dvcid */ 1,
> > > > > > > > -				 /* curdata */ 1,
> > > > > > > > +				 /* dvcid */ 0,
> > > > > > > > +				 /* curdata */ 0,
> > > > > > > >  				 /* count */ 1,
> > > > > > > >  				 /* data_ptr */ data,
> > > > > > > >  				 /* dxfer_len */ 1024,
> > > > > > > > @@ -1284,8 +1284,8 @@
> > > > > > > >  				 /* voltag */ want_voltags,
> > > > > > > >  				 /* sea */ softc->sc_firsts[chet]
> > > > > > > >  				 + cesr->cesr_element_base,
> > > > > > > > -				 /* dvcid */ 1,
> > > > > > > > -				 /* curdata */ 1,
> > > > > > > > +				 /* dvcid */ 0,
> > > > > > > > +				 /* curdata */ 0,
> > > > > > > >  				 /* count */ cesr->cesr_element_count,
> > > > > > > >  				 /* data_ptr */ data,
> > > > > > > >  				 /* dxfer_len */ size,
> > > > > > > > 
> > > > > > > > 	-Andre
> > > > > > > 
> > > > > > > Oops, sorry.
> > > > > > > 
> > > > > > > We need to check the SCSI version to see whether to set those bits, and
> > > > > > > also fall back in case it doesn't work.
> > > > > > > 
> > > > > > > I am on vacation and have very spotty net access.  I can't do anything
> > > > > > > about it until I get back next week.
> > > > > > > 
> > > > > > > Justin and Alan (CCed) can work on the fix, though.
> > > > > > 
> > > > > > Take your time, for me it's working right now
> > > > > > with the above patch...
> > > > > 
> > > > > Okay, I'm back and can take a look at this.
> > > > 
> > > > Welcome back ;-)
> > > > 
> > > > > 
> > > > > Can you send me:
> > > > 
> > > > Sure, I am happy to help.
> > > > 
> > > > > 
> > > > > camcontrol inquiry ch0 -v
> > > > 
> > > > pass17:  Removable Changer SCSI-2 device 
> > > > pass17: Serial Number 0021009613
> > > > pass17: 3.300MB/s transfers
> > > > 
> > > > > camcontrol cmd ch0 -v -c "12 0 0 0 ff 0" -i 255 "s58 i2 i2 i2 i2 i2 i2 i2 i2"
> > > > 
> > > > 0 0 0 0 0 0 0 0 
> > > 
> > > Okay, that was helpful, thanks!
> > > 
> > > > > 
> > > > > I want to see what SCSI version this changer reports.  The second command
> > > > > will print out the SCSI version descriptors, if any, that the changer
> > > > > reports.
> > > > 
> > > > In case you need more info just drop me a note.
> > > > 
> > > > Thanks for looking into this.
> > > 
> > > Can you try the attached patch, and see how it works for you?
> > > 
> > > It defaults to not setting those bits for changers that claim to be SCSI-2
> > > or below.  And if a SCSI-3 or higher changer returns an Illegal Request
> > > type error, it will retry with the bits cleared to see whether that works.
> > > 
> > > I also bumped the read element status timeout after some testing with a
> > > Spectra T-380.
> > > 
> > > The patch is against head, but stable/9 shouldn't be much different.
> > 
> > Oops, here is the patch.
> 
> Tried "chio status" and "chio move", both work!
> dmesg now added a quirk entry for ch0:
> 
>  ch0:  Removable Changer SCSI-2 device 
>  ch0: 3.300MB/s transfers
>  ch0: 11 slots, 1 drive, 1 picker, 1 portal
> +ch0: quirks=0x2
>  sa0 at ahd3 bus 0 scbus4 target 0 lun 0
>  sa0:  Removable Sequential Access SCSI-3 device 
>  sa0: 160.000MB/s transfers (80.000MHz DT, offset 126, 16bit)

Great, thanks for testing it!

I just committed the fix.

I'll put in the MFC request as soon as the 3 day waiting period is done.

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 18:02:11 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 1DDAAE4E;
 Fri, 12 Jul 2013 18:02:11 +0000 (UTC)
 (envelope-from marius@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 0F084137B;
 Fri, 12 Jul 2013 18:02:11 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CI2A7l094956;
 Fri, 12 Jul 2013 18:02:10 GMT (envelope-from marius@svn.freebsd.org)
Received: (from marius@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CI2Agj094955;
 Fri, 12 Jul 2013 18:02:10 GMT (envelope-from marius@svn.freebsd.org)
Message-Id: <201307121802.r6CI2Agj094955@svn.freebsd.org>
From: Marius Strobl 
Date: Fri, 12 Jul 2013 18:02:10 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253278 - stable/9/sys/dev/pci
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 18:02:11 -0000

Author: marius
Date: Fri Jul 12 18:02:10 2013
New Revision: 253278
URL: http://svnweb.freebsd.org/changeset/base/253278

Log:
  MFC: r240981, r240990, r240992, r244695
  
  Add 32-bit ABI compat shims. Those are necessary for i386 binary-only
  tools like sysutils/hpacucli (HP P4xx RAID controller management
  suite) working on amd64 systems.
  
  PR:		139271
  Submitted by:	Kazumi MORINAGA, Eugene Grosbein
  Approved by:	re (kib)

Modified:
  stable/9/sys/dev/pci/pci_user.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/pci/pci_user.c
==============================================================================
--- stable/9/sys/dev/pci/pci_user.c	Fri Jul 12 17:37:05 2013	(r253277)
+++ stable/9/sys/dev/pci/pci_user.c	Fri Jul 12 18:02:10 2013	(r253278)
@@ -225,6 +225,51 @@ struct pci_io_old {
 	u_int32_t	pi_data;	/* data to write or result of read */
 };
 
+#ifdef COMPAT_FREEBSD32
+struct pci_conf_old32 {
+	struct pcisel_old pc_sel;	/* bus+slot+function */
+	uint8_t		pc_hdr;		/* PCI header type */
+	uint16_t	pc_subvendor;	/* card vendor ID */
+	uint16_t	pc_subdevice;	/* card device ID, assigned by
+					   card vendor */
+	uint16_t	pc_vendor;	/* chip vendor ID */
+	uint16_t	pc_device;	/* chip device ID, assigned by
+					   chip vendor */
+	uint8_t		pc_class;	/* chip PCI class */
+	uint8_t		pc_subclass;	/* chip PCI subclass */
+	uint8_t		pc_progif;	/* chip PCI programming interface */
+	uint8_t		pc_revid;	/* chip revision ID */
+	char		pd_name[PCI_MAXNAMELEN + 1]; /* device name */
+	uint32_t	pd_unit;	/* device unit number (u_long) */
+};
+
+struct pci_match_conf_old32 {
+	struct pcisel_old pc_sel;	/* bus+slot+function */
+	char		pd_name[PCI_MAXNAMELEN + 1]; /* device name */
+	uint32_t	pd_unit;	/* Unit number (u_long) */
+	uint16_t	pc_vendor;	/* PCI Vendor ID */
+	uint16_t	pc_device;	/* PCI Device ID */
+	uint8_t		pc_class;	/* PCI class */
+	pci_getconf_flags_old flags;	/* Matching expression */
+};
+
+struct pci_conf_io32 {
+	uint32_t	pat_buf_len;	/* pattern buffer length */
+	uint32_t	num_patterns;	/* number of patterns */
+	uint32_t	patterns;	/* pattern buffer
+					   (struct pci_match_conf_old32 *) */
+	uint32_t	match_buf_len;	/* match buffer length */
+	uint32_t	num_matches;	/* number of matches returned */
+	uint32_t	matches;	/* match buffer
+					   (struct pci_conf_old32 *) */
+	uint32_t	offset;		/* offset into device list */
+	uint32_t	generation;	/* device list generation */
+	pci_getconf_status status;	/* request status */
+};
+
+#define	PCIOCGETCONF_OLD32	_IOWR('p', 1, struct pci_conf_io32)
+#endif	/* COMPAT_FREEBSD32 */
+
 #define	PCIOCGETCONF_OLD	_IOWR('p', 1, struct pci_conf_io)
 #define	PCIOCREAD_OLD		_IOWR('p', 2, struct pci_io_old)
 #define	PCIOCWRITE_OLD		_IOWR('p', 3, struct pci_io_old)
@@ -295,7 +340,71 @@ pci_conf_match_old(struct pci_match_conf
 	return(1);
 }
 
-#endif
+#ifdef COMPAT_FREEBSD32
+static int
+pci_conf_match_old32(struct pci_match_conf_old32 *matches, int num_matches,
+    struct pci_conf *match_buf)
+{
+	int i;
+
+	if ((matches == NULL) || (match_buf == NULL) || (num_matches <= 0))
+		return(1);
+
+	for (i = 0; i < num_matches; i++) {
+		if (match_buf->pc_sel.pc_domain != 0)
+			continue;
+
+		/*
+		 * I'm not sure why someone would do this...but...
+		 */
+		if (matches[i].flags == PCI_GETCONF_NO_MATCH_OLD)
+			continue;
+
+		/*
+		 * Look at each of the match flags.  If it's set, do the
+		 * comparison.  If the comparison fails, we don't have a
+		 * match, go on to the next item if there is one.
+		 */
+		if (((matches[i].flags & PCI_GETCONF_MATCH_BUS_OLD) != 0) &&
+		    (match_buf->pc_sel.pc_bus != matches[i].pc_sel.pc_bus))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_DEV_OLD) != 0) &&
+		    (match_buf->pc_sel.pc_dev != matches[i].pc_sel.pc_dev))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_FUNC_OLD) != 0) &&
+		    (match_buf->pc_sel.pc_func != matches[i].pc_sel.pc_func))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_VENDOR_OLD) != 0) &&
+		    (match_buf->pc_vendor != matches[i].pc_vendor))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_DEVICE_OLD) != 0) &&
+		    (match_buf->pc_device != matches[i].pc_device))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_CLASS_OLD) != 0) &&
+		    (match_buf->pc_class != matches[i].pc_class))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_UNIT_OLD) != 0) &&
+		    ((u_int32_t)match_buf->pd_unit != matches[i].pd_unit))
+			continue;
+
+		if (((matches[i].flags & PCI_GETCONF_MATCH_NAME_OLD) != 0) &&
+		    (strncmp(matches[i].pd_name, match_buf->pd_name,
+		    sizeof(match_buf->pd_name)) != 0))
+			continue;
+
+		return (0);
+	}
+
+	return (1);
+}
+#endif	/* COMPAT_FREEBSD32 */
+#endif	/* PRE7_COMPAT */
 
 static int
 pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
@@ -304,7 +413,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 	void *confdata;
 	const char *name;
 	struct devlist *devlist_head;
-	struct pci_conf_io *cio;
+	struct pci_conf_io *cio = NULL;
 	struct pci_devinfo *dinfo;
 	struct pci_io *io;
 	struct pci_bar_io *bio;
@@ -313,13 +422,17 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 	size_t confsz, iolen, pbufsz;
 	int error, ionum, i, num_patterns;
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+	struct pci_conf_io32 *cio32 = NULL;
+	struct pci_conf_old32 conf_old32;
+	struct pci_match_conf_old32 *pattern_buf_old32 = NULL;
+#endif
 	struct pci_conf_old conf_old;
 	struct pci_io iodata;
 	struct pci_io_old *io_old;
-	struct pci_match_conf_old *pattern_buf_old;
+	struct pci_match_conf_old *pattern_buf_old = NULL;
 
 	io_old = NULL;
-	pattern_buf_old = NULL;
 
 	if (!(flag & FWRITE) && cmd != PCIOCGETBAR &&
 	    cmd != PCIOCGETCONF && cmd != PCIOCGETCONF_OLD)
@@ -331,11 +444,36 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 
 	switch(cmd) {
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+       case PCIOCGETCONF_OLD32:
+               cio32 = (struct pci_conf_io32 *)data;
+               cio = malloc(sizeof(struct pci_conf_io), M_TEMP, M_WAITOK);
+               cio->pat_buf_len = cio32->pat_buf_len;
+               cio->num_patterns = cio32->num_patterns;
+               cio->patterns = (void *)(uintptr_t)cio32->patterns;
+               cio->match_buf_len = cio32->match_buf_len;
+               cio->num_matches = cio32->num_matches;
+               cio->matches = (void *)(uintptr_t)cio32->matches;
+               cio->offset = cio32->offset;
+               cio->generation = cio32->generation;
+               cio->status = cio32->status;
+               cio32->num_matches = 0;
+               break;
+#endif
 	case PCIOCGETCONF_OLD:
-		/* FALLTHROUGH */
 #endif
 	case PCIOCGETCONF:
 		cio = (struct pci_conf_io *)data;
+	}
+
+	switch(cmd) {
+#ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+	case PCIOCGETCONF_OLD32:
+#endif
+	case PCIOCGETCONF_OLD:
+#endif
+	case PCIOCGETCONF:
 
 		pattern_buf = NULL;
 		num_patterns = 0;
@@ -353,7 +491,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 		 && (cio->generation != pci_generation)){
 			cio->status = PCI_GETCONF_LIST_CHANGED;
 			error = 0;
-			break;
+			goto getconfexit;
 		}
 
 		/*
@@ -363,7 +501,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 		if (cio->offset >= pci_numdevs) {
 			cio->status = PCI_GETCONF_LAST_DEVICE;
 			error = 0;
-			break;
+			goto getconfexit;
 		}
 
 		/* get the head of the device queue */
@@ -376,6 +514,11 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 		 * didn't specify a multiple of that size.
 		 */
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+		if (cmd == PCIOCGETCONF_OLD32)
+			confsz = sizeof(struct pci_conf_old32);
+		else
+#endif
 		if (cmd == PCIOCGETCONF_OLD)
 			confsz = sizeof(struct pci_conf_old);
 		else
@@ -410,6 +553,11 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 			 * updated their kernel but not their userland.
 			 */
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+			if (cmd == PCIOCGETCONF_OLD32)
+				pbufsz = sizeof(struct pci_match_conf_old32);
+			else
+#endif
 			if (cmd == PCIOCGETCONF_OLD)
 				pbufsz = sizeof(struct pci_match_conf_old);
 			else
@@ -419,20 +567,28 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 				/* The user made a mistake, return an error. */
 				cio->status = PCI_GETCONF_ERROR;
 				error = EINVAL;
-				break;
+				goto getconfexit;
 			}
 
 			/*
 			 * Allocate a buffer to hold the patterns.
 			 */
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+			if (cmd == PCIOCGETCONF_OLD32) {
+				pattern_buf_old32 = malloc(cio->pat_buf_len,
+				    M_TEMP, M_WAITOK);
+				error = copyin(cio->patterns,
+				    pattern_buf_old32, cio->pat_buf_len);
+			} else
+#endif /* COMPAT_FREEBSD32 */
 			if (cmd == PCIOCGETCONF_OLD) {
 				pattern_buf_old = malloc(cio->pat_buf_len,
 				    M_TEMP, M_WAITOK);
 				error = copyin(cio->patterns,
 				    pattern_buf_old, cio->pat_buf_len);
 			} else
-#endif
+#endif /* PRE7_COMPAT */
 			{
 				pattern_buf = malloc(cio->pat_buf_len, M_TEMP,
 				    M_WAITOK);
@@ -451,7 +607,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 			 */
 			cio->status = PCI_GETCONF_ERROR;
 			error = EINVAL;
-			break;
+                       goto getconfexit;
 		}
 
 		/*
@@ -483,7 +639,14 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 			}
 
 #ifdef PRE7_COMPAT
-			if ((cmd == PCIOCGETCONF_OLD &&
+			if (
+#ifdef COMPAT_FREEBSD32
+			    (cmd == PCIOCGETCONF_OLD32 &&
+			    (pattern_buf_old32 == NULL ||
+			    pci_conf_match_old32(pattern_buf_old32,
+			    num_patterns, &dinfo->conf) == 0)) ||
+#endif
+			    (cmd == PCIOCGETCONF_OLD &&
 			    (pattern_buf_old == NULL ||
 			    pci_conf_match_old(pattern_buf_old, num_patterns,
 			    &dinfo->conf) == 0)) ||
@@ -508,6 +671,40 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 					break;
 
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+				if (cmd == PCIOCGETCONF_OLD32) {
+					conf_old32.pc_sel.pc_bus =
+					    dinfo->conf.pc_sel.pc_bus;
+					conf_old32.pc_sel.pc_dev =
+					    dinfo->conf.pc_sel.pc_dev;
+					conf_old32.pc_sel.pc_func =
+					    dinfo->conf.pc_sel.pc_func;
+					conf_old32.pc_hdr = dinfo->conf.pc_hdr;
+					conf_old32.pc_subvendor =
+					    dinfo->conf.pc_subvendor;
+					conf_old32.pc_subdevice =
+					    dinfo->conf.pc_subdevice;
+					conf_old32.pc_vendor =
+					    dinfo->conf.pc_vendor;
+					conf_old32.pc_device =
+					    dinfo->conf.pc_device;
+					conf_old32.pc_class =
+					    dinfo->conf.pc_class;
+					conf_old32.pc_subclass =
+					    dinfo->conf.pc_subclass;
+					conf_old32.pc_progif =
+					    dinfo->conf.pc_progif;
+					conf_old32.pc_revid =
+					    dinfo->conf.pc_revid;
+					strncpy(conf_old32.pd_name,
+					    dinfo->conf.pd_name,
+					    sizeof(conf_old32.pd_name));
+					conf_old32.pd_name[PCI_MAXNAMELEN] = 0;
+					conf_old32.pd_unit =
+					    (uint32_t)dinfo->conf.pd_unit;
+					confdata = &conf_old32;
+				} else
+#endif /* COMPAT_FREEBSD32 */
 				if (cmd == PCIOCGETCONF_OLD) {
 					conf_old.pc_sel.pc_bus =
 					    dinfo->conf.pc_sel.pc_bus;
@@ -540,7 +737,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 					    dinfo->conf.pd_unit;
 					confdata = &conf_old;
 				} else
-#endif
+#endif /* PRE7_COMPAT */
 					confdata = &dinfo->conf;
 				/* Only if we can copy it out do we count it. */
 				if (!(error = copyout(confdata,
@@ -574,12 +771,23 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 			cio->status = PCI_GETCONF_MORE_DEVS;
 
 getconfexit:
-		if (pattern_buf != NULL)
-			free(pattern_buf, M_TEMP);
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+		if (cmd == PCIOCGETCONF_OLD32) {
+			cio32->status = cio->status;
+			cio32->generation = cio->generation;
+			cio32->offset = cio->offset;
+			cio32->num_matches = cio->num_matches;
+			free(cio, M_TEMP);
+		}
+		if (pattern_buf_old32 != NULL)
+			free(pattern_buf_old32, M_TEMP);
+#endif
 		if (pattern_buf_old != NULL)
 			free(pattern_buf_old, M_TEMP);
 #endif
+		if (pattern_buf != NULL)
+			free(pattern_buf, M_TEMP);
 
 		break;
 

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 18:54:49 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 5EF2FBA6;
 Fri, 12 Jul 2013 18:54:49 +0000 (UTC)
 (envelope-from trociny@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 40F0718DD;
 Fri, 12 Jul 2013 18:54:49 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CIsn05010091;
 Fri, 12 Jul 2013 18:54:49 GMT (envelope-from trociny@svn.freebsd.org)
Received: (from trociny@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CIsmXx010086;
 Fri, 12 Jul 2013 18:54:48 GMT (envelope-from trociny@svn.freebsd.org)
Message-Id: <201307121854.r6CIsmXx010086@svn.freebsd.org>
From: Mikolaj Golub 
Date: Fri, 12 Jul 2013 18:54:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253281 - in stable/9/sys: netinet netinet6
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 18:54:49 -0000

Author: trociny
Date: Fri Jul 12 18:54:47 2013
New Revision: 253281
URL: http://svnweb.freebsd.org/changeset/base/253281

Log:
  MFC r252710:
  
  In r227207, to fix the issue with possible NULL inp_socket pointer
  dereferencing, when checking for SO_REUSEPORT option (and SO_REUSEADDR
  for multicast), INP_REUSEPORT flag was introduced to cache the socket
  option.  It was decided then that one flag would be enough to cache
  both SO_REUSEPORT and SO_REUSEADDR: when processing SO_REUSEADDR
  setsockopt(2), it was checked if it was called for a multicast address
  and INP_REUSEPORT was set accordingly.
  
  Unfortunately that approach does not work when setsockopt(2) is called
  before binding to a multicast address: the multicast check fails and
  INP_REUSEPORT is not set.
  
  Fix this by adding INP_REUSEADDR flag to unconditionally cache
  SO_REUSEADDR.
  
  PR:		179901
  Submitted by:	Michael Gmelin freebsd grem.de (initial version)
  Reviewed by:	rwatson
  Approved by:	re (kib)

Modified:
  stable/9/sys/netinet/in_pcb.c
  stable/9/sys/netinet/in_pcb.h
  stable/9/sys/netinet/ip_output.c
  stable/9/sys/netinet6/in6_pcb.c
  stable/9/sys/netinet6/ip6_output.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/in_pcb.c
==============================================================================
--- stable/9/sys/netinet/in_pcb.c	Fri Jul 12 18:52:33 2013	(r253280)
+++ stable/9/sys/netinet/in_pcb.c	Fri Jul 12 18:54:47 2013	(r253281)
@@ -466,6 +466,23 @@ in_pcb_lport(struct inpcb *inp, struct i
 
 	return (0);
 }
+
+/*
+ * Return cached socket options.
+ */
+short
+inp_so_options(const struct inpcb *inp)
+{
+   short so_options;
+
+   so_options = 0;
+
+   if ((inp->inp_flags2 & INP_REUSEPORT) != 0)
+	   so_options |= SO_REUSEPORT;
+   if ((inp->inp_flags2 & INP_REUSEADDR) != 0)
+	   so_options |= SO_REUSEADDR;
+   return (so_options);
+}
 #endif /* INET || INET6 */
 
 #ifdef INET
@@ -594,8 +611,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
 				if (tw == NULL ||
 				    (reuseport & tw->tw_so_options) == 0)
 					return (EADDRINUSE);
-			} else if (t && (reuseport == 0 ||
-			    (t->inp_flags2 & INP_REUSEPORT) == 0)) {
+			} else if (t && (reuseport & inp_so_options(t)) == 0) {
 #ifdef INET6
 				if (ntohl(sin->sin_addr.s_addr) !=
 				    INADDR_ANY ||

Modified: stable/9/sys/netinet/in_pcb.h
==============================================================================
--- stable/9/sys/netinet/in_pcb.h	Fri Jul 12 18:52:33 2013	(r253280)
+++ stable/9/sys/netinet/in_pcb.h	Fri Jul 12 18:54:47 2013	(r253281)
@@ -442,6 +442,7 @@ struct tcpcb *
 	inp_inpcbtotcpcb(struct inpcb *inp);
 void 	inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
 		uint32_t *faddr, uint16_t *fp);
+short	inp_so_options(const struct inpcb *inp);
 
 #endif /* _KERNEL */
 
@@ -543,6 +544,7 @@ void 	inp_4tuple_get(struct inpcb *inp, 
 #define	INP_PCBGROUPWILD	0x00000004 /* in pcbgroup wildcard list */
 #define	INP_REUSEPORT		0x00000008 /* SO_REUSEPORT option is set */
 #define	INP_FREED		0x00000010 /* inp itself is not valid */
+#define	INP_REUSEADDR		0x00000020 /* SO_REUSEADDR option is set */
 
 /*
  * Flags passed to in_pcblookup*() functions.

Modified: stable/9/sys/netinet/ip_output.c
==============================================================================
--- stable/9/sys/netinet/ip_output.c	Fri Jul 12 18:52:33 2013	(r253280)
+++ stable/9/sys/netinet/ip_output.c	Fri Jul 12 18:54:47 2013	(r253281)
@@ -899,13 +899,10 @@ ip_ctloutput(struct socket *so, struct s
 			switch (sopt->sopt_name) {
 			case SO_REUSEADDR:
 				INP_WLOCK(inp);
-				if (IN_MULTICAST(ntohl(inp->inp_laddr.s_addr))) {
-					if ((so->so_options &
-					    (SO_REUSEADDR | SO_REUSEPORT)) != 0)
-						inp->inp_flags2 |= INP_REUSEPORT;
-					else
-						inp->inp_flags2 &= ~INP_REUSEPORT;
-				}
+				if ((so->so_options & SO_REUSEADDR) != 0)
+					inp->inp_flags2 |= INP_REUSEADDR;
+				else
+					inp->inp_flags2 &= ~INP_REUSEADDR;
 				INP_WUNLOCK(inp);
 				error = 0;
 				break;

Modified: stable/9/sys/netinet6/in6_pcb.c
==============================================================================
--- stable/9/sys/netinet6/in6_pcb.c	Fri Jul 12 18:52:33 2013	(r253280)
+++ stable/9/sys/netinet6/in6_pcb.c	Fri Jul 12 18:54:47 2013	(r253281)
@@ -245,8 +245,7 @@ in6_pcbbind(register struct inpcb *inp, 
 				if (tw == NULL ||
 				    (reuseport & tw->tw_so_options) == 0)
 					return (EADDRINUSE);
-			} else if (t && (reuseport == 0 ||
-			    (t->inp_flags2 & INP_REUSEPORT) == 0)) {
+			} else if (t && (reuseport & inp_so_options(t)) == 0) {
 				return (EADDRINUSE);
 			}
 #ifdef INET
@@ -267,8 +266,8 @@ in6_pcbbind(register struct inpcb *inp, 
 					     INP_IPV6PROTO) ==
 					     (t->inp_vflag & INP_IPV6PROTO))))
 						return (EADDRINUSE);
-				} else if (t && (reuseport == 0 ||
-				    (t->inp_flags2 & INP_REUSEPORT) == 0) &&
+				} else if (t &&
+				    (reuseport & inp_so_options(t)) == 0 &&
 				    (ntohl(t->inp_laddr.s_addr) != INADDR_ANY ||
 				    (t->inp_vflag & INP_IPV6PROTO) != 0))
 					return (EADDRINUSE);

Modified: stable/9/sys/netinet6/ip6_output.c
==============================================================================
--- stable/9/sys/netinet6/ip6_output.c	Fri Jul 12 18:52:33 2013	(r253280)
+++ stable/9/sys/netinet6/ip6_output.c	Fri Jul 12 18:54:47 2013	(r253281)
@@ -1491,13 +1491,10 @@ ip6_ctloutput(struct socket *so, struct 
 			switch (sopt->sopt_name) {
 			case SO_REUSEADDR:
 				INP_WLOCK(in6p);
-				if (IN_MULTICAST(ntohl(in6p->inp_laddr.s_addr))) {
-					if ((so->so_options &
-					    (SO_REUSEADDR | SO_REUSEPORT)) != 0)
-						in6p->inp_flags2 |= INP_REUSEPORT;
-					else
-						in6p->inp_flags2 &= ~INP_REUSEPORT;
-				}
+				if ((so->so_options & SO_REUSEADDR) != 0)
+					in6p->inp_flags2 |= INP_REUSEADDR;
+				else
+					in6p->inp_flags2 &= ~INP_REUSEADDR;
 				INP_WUNLOCK(in6p);
 				error = 0;
 				break;

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 20:06:53 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 78BEFB84;
 Fri, 12 Jul 2013 20:06:53 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 6AB181CA5;
 Fri, 12 Jul 2013 20:06:53 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CK6rRD030841;
 Fri, 12 Jul 2013 20:06:53 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CK6rY7030839;
 Fri, 12 Jul 2013 20:06:53 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201307122006.r6CK6rY7030839@svn.freebsd.org>
From: Dimitry Andric 
Date: Fri, 12 Jul 2013 20:06:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253283 - stable/9/lib/clang
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 20:06:53 -0000

Author: dim
Date: Fri Jul 12 20:06:52 2013
New Revision: 253283
URL: http://svnweb.freebsd.org/changeset/base/253283

Log:
  Update clang's target triple for FreeBSD 9.2-PRERELEASE.
  
  Approved by:	re (delphij)

Modified:
  stable/9/lib/clang/clang.build.mk

Modified: stable/9/lib/clang/clang.build.mk
==============================================================================
--- stable/9/lib/clang/clang.build.mk	Fri Jul 12 19:08:33 2013	(r253282)
+++ stable/9/lib/clang/clang.build.mk	Fri Jul 12 20:06:52 2013	(r253283)
@@ -27,8 +27,8 @@ TARGET_ABI=	gnueabi
 TARGET_ABI=	unknown
 .endif
 
-TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd9.1
-BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/}-unknown-freebsd9.1
+TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd9.2
+BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/}-unknown-freebsd9.2
 CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
 		-DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" \
 		-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:01:19 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 62A95C45;
 Fri, 12 Jul 2013 22:01:19 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 436411199;
 Fri, 12 Jul 2013 22:01:19 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM1Jve064822;
 Fri, 12 Jul 2013 22:01:19 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM1IcV064819;
 Fri, 12 Jul 2013 22:01:18 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122201.r6CM1IcV064819@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:01:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253289 - stable/9/share/man/man4
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:01:19 -0000

Author: jimharris
Date: Fri Jul 12 22:01:18 2013
New Revision: 253289
URL: http://svnweb.freebsd.org/changeset/base/253289

Log:
  MFC r241431:
  
  Add man pages for nvme(4) and nvd(4).
  
  Approved by:	re (kib)

Added:
  stable/9/share/man/man4/nvd.4
     - copied unchanged from r241431, head/share/man/man4/nvd.4
  stable/9/share/man/man4/nvme.4
     - copied unchanged from r241431, head/share/man/man4/nvme.4
Modified:
  stable/9/share/man/man4/Makefile
Directory Properties:
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/Makefile
==============================================================================
--- stable/9/share/man/man4/Makefile	Fri Jul 12 21:36:29 2013	(r253288)
+++ stable/9/share/man/man4/Makefile	Fri Jul 12 22:01:18 2013	(r253289)
@@ -329,7 +329,9 @@ MAN=	aac.4 \
 	nmdm.4 \
 	nsp.4 \
 	null.4 \
+	${_nvd.4} \
 	${_nve.4} \
+	${_nvme.4} \
 	${_nvram.4} \
 	${_nvram2env.4} \
 	${_nxge.4} \
@@ -742,7 +744,9 @@ _linux.4=	linux.4
 _ndis.4=	ndis.4
 _nfe.4=		nfe.4
 _nfsmb.4=	nfsmb.4
+_nvd.4=		nvd.4
 _nve.4=		nve.4
+_nvme.4=	nvme.4
 _nvram.4=	nvram.4
 _nxge.4=	nxge.4
 _virtio.4=	virtio.4

Copied: stable/9/share/man/man4/nvd.4 (from r241431, head/share/man/man4/nvd.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/share/man/man4/nvd.4	Fri Jul 12 22:01:18 2013	(r253289, copy of r241431, head/share/man/man4/nvd.4)
@@ -0,0 +1,91 @@
+.\"
+.\" Copyright (c) 2012 Intel Corporation
+.\" 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,
+.\"    without modification.
+.\" 2. Redistributions in binary form must reproduce at minimum a disclaimer
+.\"    substantially similar to the "NO WARRANTY" disclaimer below
+.\"    ("Disclaimer") and any redistribution must be conditioned upon
+.\"    including a substantially similar Disclaimer requirement for further
+.\"    binary redistribution.
+.\"
+.\" NO WARRANTY
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+.\" HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+.\"
+.\" nvd driver man page.
+.\"
+.\" Author: Jim Harris 
+.\"
+.\" $FreeBSD$
+.\"
+.Dd October 10, 2012
+.Dt NVD 4
+.Os
+.Sh NAME
+.Nm nvd
+.Nd NVM Express disk driver
+.Sh SYNOPSIS
+To compile this driver into your kernel,
+place the following lines in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device nvme"
+.Cd "device nvd"
+.Ed
+.Pp
+Or, to load the driver as a module at boot, place the following lines in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+nvme_load="YES"
+nvd_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver exposes NVM Express (NVMe) namespaces as disks to the kernel disk
+storage API.
+It depends on the
+.Xr nvme 4
+driver for notification of existing NVMe namespaces and submission of NVM
+I/O commands.
+.Sh SEE ALSO
+.Xr nvme 4 ,
+.Xr nvmecontrol 8 , 
+.Xr disk 9 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was developed by Intel and originally written by
+.An Jim Harris Aq jimharris@FreeBSD.org ,
+with contributions from Joe Golio at EMC.
+.Pp
+This man page was written by
+.An Jim Harris Aq jimharris@FreeBSD.org .
+.Sh BUGS
+The
+.Nm
+driver is considered experimental.
+Development and testing have been primarily focused on amd64.
+The following areas of development and testing are in progress:
+.Bl -bullet
+.It
+testing on i386
+.It 
+command timeout error handling
+.El
+

Copied: stable/9/share/man/man4/nvme.4 (from r241431, head/share/man/man4/nvme.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/share/man/man4/nvme.4	Fri Jul 12 22:01:18 2013	(r253289, copy of r241431, head/share/man/man4/nvme.4)
@@ -0,0 +1,175 @@
+.\"
+.\" Copyright (c) 2012 Intel Corporation
+.\" 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,
+.\"    without modification.
+.\" 2. Redistributions in binary form must reproduce at minimum a disclaimer
+.\"    substantially similar to the "NO WARRANTY" disclaimer below
+.\"    ("Disclaimer") and any redistribution must be conditioned upon
+.\"    including a substantially similar Disclaimer requirement for further
+.\"    binary redistribution.
+.\"
+.\" NO WARRANTY
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+.\" HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+.\"
+.\" nvme driver man page.
+.\"
+.\" Author: Jim Harris 
+.\"
+.\" $FreeBSD$
+.\"
+.Dd October 10, 2012
+.Dt NVME 4
+.Os
+.Sh NAME
+.Nm nvme
+.Nd NVM Express core driver
+.Sh SYNOPSIS
+To compile this driver into your kernel,
+place the following line in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device nvme"
+.Ed
+.Pp
+Or, to load the driver as a module at boot, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+nvme_load="YES"
+.Ed
+.Pp
+Most users will also want to enable
+.Xr nvd 4
+to surface NVM Express namespaces as disk devices.
+Note that in NVM Express terms, a namespace is roughly equivalent to a
+SCSI LUN.
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for NVM Express (NVMe) controllers, such as:
+.Bl -bullet
+.It
+Hardware initialization
+.It
+Per-CPU IO queue pairs
+.It
+API for registering NVMe namespace consumers such as
+.Xr nvd 4
+.It
+API for submitting NVM commands to namespaces
+.It
+Ioctls for controller and namespace configuration and management
+.Nm
+creates controller devices in the format /dev/nvmeX and namespace devices in
+the format /dev/nvmeXnsY.
+Note that the NVM Express specification starts numbering namespaces at 1,
+not 0, and this driver follows that convention.
+.El
+.Sh CONFIGURATION
+By default,
+.Nm
+will create an I/O queue pair for each CPU, provided enough MSI-X vectors
+can be allocated.
+To force a single I/O queue pair shared by all CPUs, set the following
+tunable value in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+hw.nvme.per_cpu_io_queues=0
+.Ed
+.Pp
+To force legacy interrupts for all
+.Nm
+driver instances, set the following tunable value in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+hw.nvme.force_intx=1
+.Ed
+.Pp
+Note that use of INTx implies disabling of per-CPU I/O queue pairs.
+.Sh SYSCTL VARIABLES
+The following controller-level sysctls are currently implemented:
+.Bl -tag -width indent
+.It Va dev.nvme.0.int_coal_time
+(R/W) Interrupt coalescing timer period in microseconds.  Set to 0 to disable.
+.It Va dev.nvme.0.int_coal_threshold
+(R/W) Interrupt coalescing threshold in number of command completions.
+Set to 0 to disable.
+.El
+.Pp
+The following queue pair-level sysctls are currently implemented.
+Admin queue sysctls take the format of dev.nvme.0.adminq and I/O queue sysctls
+take the format of dev.nvme.0.ioq0.
+.Bl -tag -width indent
+.It Va dev.nvme.0.ioq0.num_entries
+(R) Number of entries in this queue pair's command and completion queue.
+.It Va dev.nvme.0.ioq0.num_tr
+(R) Number of nvme_tracker structures currently allocated for this queue pair.
+.It Va dev.nvme.0.ioq0.num_prp_list
+(R) Number of nvme_prp_list structures currently allocated for this queue pair.
+.It Va dev.nvme.0.ioq0.sq_head
+(R) Current location of the submission queue head pointer as observed by
+the driver.
+The head pointer is incremented by the controller as it takes commands off
+of the submission queue.
+.It Va dev.nvme.0.ioq0.sq_tail
+(R) Current location of the submission queue tail pointer as observed by
+the driver.
+The driver increments the tail pointer after writing a command
+into the submission queue to signal that a new command is ready to be
+processed.
+.It Va dev.nvme.0.ioq0.cq_head
+(R) Current location of the completion queue head pointer as observed by
+the driver.
+The driver increments the head pointer after finishing
+with a completion entry that was posted by the controller.
+.It Va dev.nvme.0.ioq0.num_cmds
+(R) Number of commands that have been submitted on this queue pair.
+.It Va dev.nvme.0.ioq0.dump_debug
+(W) Writing 1 to this sysctl will dump the full contents of the submission
+and completion queues to the console.
+.El
+.Sh SEE ALSO
+.Xr nvd 4 ,
+.Xr pci 4 ,
+.Xr nvmecontrol 8 ,
+.Xr disk 9 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was developed by Intel and originally written by
+.An Jim Harris Aq jimharris@FreeBSD.org , 
+with contributions from Joe Golio at EMC.
+.Pp
+This man page was written by
+.An Jim Harris Aq jimharris@FreeBSD.org .
+.Sh BUGS
+The
+.Nm
+driver is considered experimental.
+Development and testing have been primarily focused on amd64.
+The following areas of development and testing are in progress:
+.Bl -bullet
+.It
+testing on i386
+.It
+asynchronous error reporting
+.It
+command timeout error handling
+.It
+controller-level resets
+.El

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:02:35 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id E037AEAB;
 Fri, 12 Jul 2013 22:02:35 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id D142E11A2;
 Fri, 12 Jul 2013 22:02:35 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM2Z3R065115;
 Fri, 12 Jul 2013 22:02:35 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM2ZOD065113;
 Fri, 12 Jul 2013 22:02:35 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122202.r6CM2ZOD065113@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:02:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253291 - stable/9/share/man/man4
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:02:36 -0000

Author: jimharris
Date: Fri Jul 12 22:02:35 2013
New Revision: 253291
URL: http://svnweb.freebsd.org/changeset/base/253291

Log:
  MFC r241479:
  
  Remove whitespace.
  
  Approved by:	re (kib)

Modified:
  stable/9/share/man/man4/nvd.4
  stable/9/share/man/man4/nvme.4
Directory Properties:
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/nvd.4
==============================================================================
--- stable/9/share/man/man4/nvd.4	Fri Jul 12 22:02:11 2013	(r253290)
+++ stable/9/share/man/man4/nvd.4	Fri Jul 12 22:02:35 2013	(r253291)
@@ -64,7 +64,7 @@ driver for notification of existing NVMe
 I/O commands.
 .Sh SEE ALSO
 .Xr nvme 4 ,
-.Xr nvmecontrol 8 , 
+.Xr nvmecontrol 8 ,
 .Xr disk 9 .
 .Sh AUTHORS
 .An -nosplit
@@ -85,7 +85,6 @@ The following areas of development and t
 .Bl -bullet
 .It
 testing on i386
-.It 
+.It
 command timeout error handling
 .El
-

Modified: stable/9/share/man/man4/nvme.4
==============================================================================
--- stable/9/share/man/man4/nvme.4	Fri Jul 12 22:02:11 2013	(r253290)
+++ stable/9/share/man/man4/nvme.4	Fri Jul 12 22:02:35 2013	(r253291)
@@ -152,7 +152,7 @@ and completion queues to the console.
 The
 .Nm
 driver was developed by Intel and originally written by
-.An Jim Harris Aq jimharris@FreeBSD.org , 
+.An Jim Harris Aq jimharris@FreeBSD.org ,
 with contributions from Joe Golio at EMC.
 .Pp
 This man page was written by

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:03:43 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 592CC1C9;
 Fri, 12 Jul 2013 22:03:41 +0000 (UTC)
 (envelope-from remko@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id B14A411BE;
 Fri, 12 Jul 2013 22:03:41 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM3f3V065384;
 Fri, 12 Jul 2013 22:03:41 GMT (envelope-from remko@svn.freebsd.org)
Received: (from remko@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM3fUk065381;
 Fri, 12 Jul 2013 22:03:41 GMT (envelope-from remko@svn.freebsd.org)
Message-Id: <201307122203.r6CM3fUk065381@svn.freebsd.org>
From: Remko Lodder 
Date: Fri, 12 Jul 2013 22:03:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253292 - in stable/9/sys/dev/usb: . serial
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:03:43 -0000

Author: remko
Date: Fri Jul 12 22:03:41 2013
New Revision: 253292
URL: http://svnweb.freebsd.org/changeset/base/253292

Log:
  MFC r252294 and r252295:
  
  Add support for the NTT Docomo L-02C Card
  
  PR:		180017
  Submitted by:	Masaharu FUJITA
  Glanced at by:	imp
  Approved by:	re (delphij)

Modified:
  stable/9/sys/dev/usb/serial/u3g.c
  stable/9/sys/dev/usb/usbdevs

Modified: stable/9/sys/dev/usb/serial/u3g.c
==============================================================================
--- stable/9/sys/dev/usb/serial/u3g.c	Fri Jul 12 22:02:35 2013	(r253291)
+++ stable/9/sys/dev/usb/serial/u3g.c	Fri Jul 12 22:03:41 2013	(r253292)
@@ -391,6 +391,7 @@ static const STRUCT_USB_HOST_ID u3g_devs
 	U3G_DEV(QISDA, H20_2, 0),
 	U3G_DEV(QISDA, H21_1, 0),
 	U3G_DEV(QISDA, H21_2, 0),
+	U3G_DEV(QUALCOMM, NTT_L02C_MODEM, U3GINIT_SCSIEJECT),
 	U3G_DEV(QUALCOMM2, AC8700, 0),
 	U3G_DEV(QUALCOMM2, MF330, 0),
 	U3G_DEV(QUALCOMM2, SIM5218, 0),

Modified: stable/9/sys/dev/usb/usbdevs
==============================================================================
--- stable/9/sys/dev/usb/usbdevs	Fri Jul 12 22:02:35 2013	(r253291)
+++ stable/9/sys/dev/usb/usbdevs	Fri Jul 12 22:03:41 2013	(r253292)
@@ -3363,6 +3363,8 @@ product QISDA H20_2		0x4519	3G modem
 
 /* Qualcomm products */
 product QUALCOMM CDMA_MSM	0x6000	CDMA Technologies MSM phone
+product QUALCOMM NTT_L02C_MODEM	0x618f	NTT DOCOMO L-02C
+product QUALCOMM NTT_L02C_STORAGE	0x61dd	NTT DOCOMO L-02C
 product QUALCOMM2 MF330		0x6613	MF330
 product QUALCOMM2 RWT_FCT	0x3100	RWT FCT-CDMA 2000 1xRTT modem
 product QUALCOMM2 CDMA_MSM	0x3196	CDMA Technologies MSM modem

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:03:47 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 620C0268;
 Fri, 12 Jul 2013 22:03:47 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 3B8B011C0;
 Fri, 12 Jul 2013 22:03:47 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM3lk0065435;
 Fri, 12 Jul 2013 22:03:47 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM3kBY065433;
 Fri, 12 Jul 2013 22:03:46 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122203.r6CM3kBY065433@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:03:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253293 - stable/9/share/man/man4
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:03:47 -0000

Author: jimharris
Date: Fri Jul 12 22:03:46 2013
New Revision: 253293
URL: http://svnweb.freebsd.org/changeset/base/253293

Log:
  MFC r253111:
  
  Update nvme(4) and nvd(4) to reflect recent work and upcoming inclusion
  in 9.2 release.
  
  Approved by:	re (kib)

Modified:
  stable/9/share/man/man4/nvd.4
  stable/9/share/man/man4/nvme.4
Directory Properties:
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/nvd.4
==============================================================================
--- stable/9/share/man/man4/nvd.4	Fri Jul 12 22:03:41 2013	(r253292)
+++ stable/9/share/man/man4/nvd.4	Fri Jul 12 22:03:46 2013	(r253293)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright (c) 2012 Intel Corporation
+.\" Copyright (c) 2012-2013 Intel Corporation
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,11 @@ I/O commands.
 .Xr nvme 4 ,
 .Xr nvmecontrol 8 ,
 .Xr disk 9 .
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 9.2.
 .Sh AUTHORS
 .An -nosplit
 The
@@ -76,15 +81,3 @@ with contributions from Joe Golio at EMC
 .Pp
 This man page was written by
 .An Jim Harris Aq jimharris@FreeBSD.org .
-.Sh BUGS
-The
-.Nm
-driver is considered experimental.
-Development and testing have been primarily focused on amd64.
-The following areas of development and testing are in progress:
-.Bl -bullet
-.It
-testing on i386
-.It
-command timeout error handling
-.El

Modified: stable/9/share/man/man4/nvme.4
==============================================================================
--- stable/9/share/man/man4/nvme.4	Fri Jul 12 22:03:41 2013	(r253292)
+++ stable/9/share/man/man4/nvme.4	Fri Jul 12 22:03:46 2013	(r253293)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright (c) 2012 Intel Corporation
+.\" Copyright (c) 2012-2013 Intel Corporation
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -147,6 +147,11 @@ and completion queues to the console.
 .Xr pci 4 ,
 .Xr nvmecontrol 8 ,
 .Xr disk 9 .
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 9.2.
 .Sh AUTHORS
 .An -nosplit
 The
@@ -157,19 +162,3 @@ with contributions from Joe Golio at EMC
 .Pp
 This man page was written by
 .An Jim Harris Aq jimharris@FreeBSD.org .
-.Sh BUGS
-The
-.Nm
-driver is considered experimental.
-Development and testing have been primarily focused on amd64.
-The following areas of development and testing are in progress:
-.Bl -bullet
-.It
-testing on i386
-.It
-asynchronous error reporting
-.It
-command timeout error handling
-.It
-controller-level resets
-.El

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:05:17 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 99205504;
 Fri, 12 Jul 2013 22:05:17 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 8B16811CE;
 Fri, 12 Jul 2013 22:05:17 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM5HJ9065758;
 Fri, 12 Jul 2013 22:05:17 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM5Hlo065756;
 Fri, 12 Jul 2013 22:05:17 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122205.r6CM5Hlo065756@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:05:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253294 - stable/9/sys/dev/nvme
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:05:17 -0000

Author: jimharris
Date: Fri Jul 12 22:05:17 2013
New Revision: 253294
URL: http://svnweb.freebsd.org/changeset/base/253294

Log:
  MFC r253107:
  
    Add pci_enable_busmaster() and pci_disable_busmaster() calls in
    nvme_attach() and nvme_detach() respectively.
  
  Approved by:	re (kib)

Modified:
  stable/9/sys/dev/nvme/nvme.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/nvme/nvme.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme.c	Fri Jul 12 22:03:46 2013	(r253293)
+++ stable/9/sys/dev/nvme/nvme.c	Fri Jul 12 22:05:17 2013	(r253294)
@@ -255,6 +255,8 @@ nvme_attach(device_t dev)
 
 	nvme_sysctl_initialize_ctrlr(ctrlr);
 
+	pci_enable_busmaster(dev);
+
 	ctrlr->config_hook.ich_func = nvme_ctrlr_start_config_hook;
 	ctrlr->config_hook.ich_arg = ctrlr;
 
@@ -269,6 +271,7 @@ nvme_detach (device_t dev)
 	struct nvme_controller	*ctrlr = DEVICE2SOFTC(dev);
 
 	nvme_ctrlr_destruct(ctrlr, dev);
+	pci_disable_busmaster(dev);
 	return (0);
 }
 

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:06:18 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 501B463B;
 Fri, 12 Jul 2013 22:06:18 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 41B5D11D7;
 Fri, 12 Jul 2013 22:06:18 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM6INb065960;
 Fri, 12 Jul 2013 22:06:18 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM6IJU065959;
 Fri, 12 Jul 2013 22:06:18 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122206.r6CM6IJU065959@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:06:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253295 - stable/9/sys/dev/nvme
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:06:18 -0000

Author: jimharris
Date: Fri Jul 12 22:06:17 2013
New Revision: 253295
URL: http://svnweb.freebsd.org/changeset/base/253295

Log:
  MFC r253108:
  
    Do not retry failed async event requests.
  
  Approved by:	re (kib)

Modified:
  stable/9/sys/dev/nvme/nvme_ctrlr.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ctrlr.c	Fri Jul 12 22:05:17 2013	(r253294)
+++ stable/9/sys/dev/nvme/nvme_ctrlr.c	Fri Jul 12 22:06:17 2013	(r253295)
@@ -649,12 +649,12 @@ nvme_ctrlr_async_event_cb(void *arg, con
 {
 	struct nvme_async_event_request	*aer = arg;
 
-	if (cpl->status.sc == NVME_SC_ABORTED_SQ_DELETION) {
+	if (nvme_completion_is_error(cpl)) {
 		/*
-		 *  This is simulated when controller is being shut down, to
-		 *  effectively abort outstanding asynchronous event requests
-		 *  and make sure all memory is freed.  Do not repost the
-		 *  request in this case.
+		 *  Do not retry failed async event requests.  This avoids
+		 *  infinite loops where a new async event request is submitted
+		 *  to replace the one just failed, only to fail again and
+		 *  perpetuate the loop.
 		 */
 		return;
 	}

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:07:35 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id A8D2A77D;
 Fri, 12 Jul 2013 22:07:35 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 8A64411E2;
 Fri, 12 Jul 2013 22:07:35 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM7Zn9066203;
 Fri, 12 Jul 2013 22:07:35 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM7XIC066192;
 Fri, 12 Jul 2013 22:07:33 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122207.r6CM7XIC066192@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:07:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253296 - in stable/9/sys/dev: nvd nvme
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:07:35 -0000

Author: jimharris
Date: Fri Jul 12 22:07:33 2013
New Revision: 253296
URL: http://svnweb.freebsd.org/changeset/base/253296

Log:
  MFC r253112:
  
    Update copyright dates.
  
  Approved by:	re (kib)

Modified:
  stable/9/sys/dev/nvd/nvd.c
  stable/9/sys/dev/nvme/nvme.c
  stable/9/sys/dev/nvme/nvme.h
  stable/9/sys/dev/nvme/nvme_ctrlr.c
  stable/9/sys/dev/nvme/nvme_ctrlr_cmd.c
  stable/9/sys/dev/nvme/nvme_ns.c
  stable/9/sys/dev/nvme/nvme_private.h
  stable/9/sys/dev/nvme/nvme_qpair.c
  stable/9/sys/dev/nvme/nvme_sysctl.c
  stable/9/sys/dev/nvme/nvme_test.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/nvd/nvd.c
==============================================================================
--- stable/9/sys/dev/nvd/nvd.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvd/nvd.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme.h
==============================================================================
--- stable/9/sys/dev/nvme/nvme.h	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme.h	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ctrlr.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_ctrlr.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_ctrlr_cmd.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ctrlr_cmd.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_ctrlr_cmd.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_ns.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_ns.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_ns.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_private.h
==============================================================================
--- stable/9/sys/dev/nvme/nvme_private.h	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_private.h	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_qpair.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_qpair.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_qpair.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_sysctl.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_sysctl.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_sysctl.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/dev/nvme/nvme_test.c
==============================================================================
--- stable/9/sys/dev/nvme/nvme_test.c	Fri Jul 12 22:06:17 2013	(r253295)
+++ stable/9/sys/dev/nvme/nvme_test.c	Fri Jul 12 22:07:33 2013	(r253296)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 2012 Intel Corporation
+ * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:08:24 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id B21FF8AC;
 Fri, 12 Jul 2013 22:08:24 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id A3C0E11E6;
 Fri, 12 Jul 2013 22:08:24 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CM8OZw066386;
 Fri, 12 Jul 2013 22:08:24 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CM8OiJ066385;
 Fri, 12 Jul 2013 22:08:24 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122208.r6CM8OiJ066385@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:08:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253297 - stable/9/sys/dev/nvme
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:08:24 -0000

Author: jimharris
Date: Fri Jul 12 22:08:24 2013
New Revision: 253297
URL: http://svnweb.freebsd.org/changeset/base/253297

Log:
  MFC r253113:
  
    Add comment explaining why CACHE_LINE_SIZE is defined in nvme_private.h
    if not already defined elsewhere.
  
  Approved by:	re (kib)

Modified:
  stable/9/sys/dev/nvme/nvme_private.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/nvme/nvme_private.h
==============================================================================
--- stable/9/sys/dev/nvme/nvme_private.h	Fri Jul 12 22:07:33 2013	(r253296)
+++ stable/9/sys/dev/nvme/nvme_private.h	Fri Jul 12 22:08:24 2013	(r253297)
@@ -109,6 +109,10 @@ MALLOC_DECLARE(M_NVME);
 /* Maximum log page size to fetch for AERs. */
 #define NVME_MAX_AER_LOG_SIZE		(4096)
 
+/*
+ * Define CACHE_LINE_SIZE here for older FreeBSD versions that do not define
+ *  it.
+ */
 #ifndef CACHE_LINE_SIZE
 #define CACHE_LINE_SIZE		(64)
 #endif

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:12:50 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 66079A55;
 Fri, 12 Jul 2013 22:12:50 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 47F791210;
 Fri, 12 Jul 2013 22:12:50 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMCoIn068776;
 Fri, 12 Jul 2013 22:12:50 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CMCnUc068768;
 Fri, 12 Jul 2013 22:12:49 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122212.r6CMCnUc068768@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:12:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253298 - stable/9/sbin/nvmecontrol
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:12:50 -0000

Author: jimharris
Date: Fri Jul 12 22:12:48 2013
New Revision: 253298
URL: http://svnweb.freebsd.org/changeset/base/253298

Log:
  MFC r253109, r253279:
  
  r253109:
    Incorporate feedback from bde@ based on r252672 changes:
  
    * Use 0/1 instead of sysexits.  Man pages are confusing on this topic,
      but 0/1 is sufficient for nvmecontrol.
    * Use err function family where possible instead of fprintf/exit.
    * Fix some typing errors.
    * Clean up some error message inconsistencies.
  
  r253279:
    %d should be used for printing int32_t instead of %zd.
  
    clang does not complain about this - only gcc.
  
  Incorporated r253279 prior to MFC timeout because it is required for gcc
  builds.
  
  Approved by:	re (kib)

Modified:
  stable/9/sbin/nvmecontrol/devlist.c
  stable/9/sbin/nvmecontrol/firmware.c
  stable/9/sbin/nvmecontrol/identify.c
  stable/9/sbin/nvmecontrol/logpage.c
  stable/9/sbin/nvmecontrol/nvmecontrol.c
  stable/9/sbin/nvmecontrol/perftest.c
  stable/9/sbin/nvmecontrol/reset.c
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/devlist.c
==============================================================================
--- stable/9/sbin/nvmecontrol/devlist.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/devlist.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -29,13 +29,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -45,7 +44,7 @@ devlist_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, DEVLIST_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 static inline uint32_t
@@ -62,9 +61,7 @@ devlist(int argc, char *argv[])
 	struct nvme_namespace_data	nsdata;
 	char				name[64];
 	uint32_t			i;
-	int				ch, ctrlr, exit_code, fd, found;
-
-	exit_code = EX_OK;
+	int				ch, ctrlr, fd, found, ret;
 
 	while ((ch = getopt(argc, argv, "")) != -1) {
 		switch ((char)ch) {
@@ -80,14 +77,14 @@ devlist(int argc, char *argv[])
 		ctrlr++;
 		sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr);
 
-		exit_code = open_dev(name, &fd, 0, 0);
+		ret = open_dev(name, &fd, 0, 0);
 
-		if (exit_code == EX_NOINPUT)
-			break;
-		else if (exit_code == EX_NOPERM) {
-			printf("Could not open /dev/%s, errno = %d (%s)\n",
-			    name, errno, strerror(errno));
-			continue;
+		if (ret != 0) {
+			if (fd < 0) {
+				warnx("could not open /dev/%s\n", name);
+				continue;
+			} else
+				break;
 		}
 
 		found++;
@@ -111,5 +108,5 @@ devlist(int argc, char *argv[])
 	if (found == 0)
 		printf("No NVMe controllers found.\n");
 
-	exit(EX_OK);
+	exit(1);
 }

Modified: stable/9/sbin/nvmecontrol/firmware.c
==============================================================================
--- stable/9/sbin/nvmecontrol/firmware.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/firmware.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -36,14 +36,14 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -64,60 +64,58 @@ slot_has_valid_firmware(int fd, int slot
 }
 
 static void
-read_image_file(char *path, void **buf, ssize_t *size)
+read_image_file(char *path, void **buf, int32_t *size)
 {
 	struct stat	sb;
+	int32_t		filesize;
 	int		fd;
 
 	*size = 0;
 	*buf = NULL;
 
-	if ((fd = open(path, O_RDONLY)) < 0) {
-		fprintf(stderr, "Unable to open '%s'.\n", path);
-		exit(EX_IOERR);
-	}
-	if (fstat(fd, &sb) < 0) {
-		fprintf(stderr, "Unable to stat '%s'.\n", path);
-		close(fd);
-		exit(EX_IOERR);
-	}
-	if ((*buf = malloc(sb.st_size)) == NULL) {
-		fprintf(stderr, "Unable to malloc %jd bytes.\n",
-		    sb.st_size);
-		close(fd);
-		exit(EX_IOERR);
-	}
-	if ((*size = read(fd, *buf, sb.st_size)) < 0) {
-		fprintf(stderr, "Error reading '%s', errno=%d (%s)\n",
-		    path, errno, strerror(errno));
-		close(fd);
-		exit(EX_IOERR);
-	}
-	if (*size != sb.st_size) {
-		fprintf(stderr, "Error reading '%s', "
-		    "read %zd bytes, requested %jd bytes\n",
-		    path, *size, sb.st_size);
-		close(fd);
-		exit(EX_IOERR);
-	}
+	if ((fd = open(path, O_RDONLY)) < 0)
+		err(1, "unable to open '%s'", path);
+	if (fstat(fd, &sb) < 0)
+		err(1, "unable to stat '%s'", path);
+
+	/*
+	 * The NVMe spec does not explicitly state a maximum firmware image
+	 *  size, although one can be inferred from the dword size limitation
+	 *  for the size and offset fields in the Firmware Image Download
+	 *  command.
+	 *
+	 * Technically, the max is UINT32_MAX * sizeof(uint32_t), since the
+	 *  size and offsets are specified in terms of dwords (not bytes), but
+	 *  realistically INT32_MAX is sufficient here and simplifies matters
+	 *  a bit.
+	 */
+	if (sb.st_size > INT32_MAX)
+		errx(1, "size of file '%s' is too large (%jd bytes)",
+		    path, (intmax_t)sb.st_size);
+	filesize = (int32_t)sb.st_size;
+	if ((*buf = malloc(filesize)) == NULL)
+		errx(1, "unable to malloc %d bytes", filesize);
+	if ((*size = read(fd, *buf, filesize)) < 0)
+		err(1, "error reading '%s'", path);
+	/* XXX assuming no short reads */
+	if (*size != filesize)
+		errx(1,
+		    "error reading '%s' (read %d bytes, requested %d bytes)",
+		    path, *size, filesize);
 }
 
 static void
-update_firmware(int fd, uint8_t *payload, uint32_t payload_size)
+update_firmware(int fd, uint8_t *payload, int32_t payload_size)
 {
 	struct nvme_pt_command	pt;
-	size_t			size;
+	int32_t			off, resid, size;
 	void			*chunk;
-	uint32_t		off, resid;
-	int			exit_code = EX_OK;
 
 	off = 0;
 	resid = payload_size;
 
-	if ((chunk = malloc((size_t)NVME_MAX_XFER_SIZE)) == NULL) {
-		printf("Unable to malloc %d bytes.\n", NVME_MAX_XFER_SIZE);
-		exit(EX_IOERR);
-	}
+	if ((chunk = malloc(NVME_MAX_XFER_SIZE)) == NULL)
+		errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE);
 
 	while (resid > 0) {
 		size = (resid >= NVME_MAX_XFER_SIZE) ?
@@ -132,26 +130,15 @@ update_firmware(int fd, uint8_t *payload
 		pt.len = size;
 		pt.is_read = 0;
 
-		if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
-			printf("Firmware image download request failed. "
-			    "errno=%d (%s)\n",
-			    errno, strerror(errno));
-			exit_code = EX_IOERR;
-			break;
-		}
+		if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
+			err(1, "firmware download request failed");
 
-		if (nvme_completion_is_error(&pt.cpl)) {
-			printf("Passthrough command returned error.\n");
-			exit_code = EX_IOERR;
-			break;
-		}
+		if (nvme_completion_is_error(&pt.cpl))
+			errx(1, "firmware download request returned error");
 
 		resid -= size;
 		off += size;
 	}
-	
-	if (exit_code != EX_OK)
-		exit(exit_code);
 }
 
 static void
@@ -164,16 +151,11 @@ activate_firmware(int fd, int slot, int 
 	pt.cmd.cdw10 = (activate_action << 3) | slot;
 	pt.is_read = 0;
 
-	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
-		printf("Firmware activate request failed. errno=%d (%s)\n",
-		    errno, strerror(errno));
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
+		err(1, "firmware activate request failed");
 
-	if (nvme_completion_is_error(&pt.cpl)) {
-		printf("Passthrough command returned error.\n");
-		exit(EX_IOERR);
-	}
+	if (nvme_completion_is_error(&pt.cpl))
+		errx(1, "firmware activate request returned error");
 }
 
 static void
@@ -181,7 +163,7 @@ firmware_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, FIRMWARE_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 void
@@ -192,7 +174,7 @@ firmware(int argc, char *argv[])
 	char				ch, *p, *image = NULL;
 	char				*controller = NULL, prompt[64];
 	void				*buf = NULL;
-	ssize_t				size;
+	int32_t				size = 0;
 	struct nvme_controller_data	cdata;
 
 	a_flag = s_flag = f_flag = false;
@@ -252,34 +234,24 @@ firmware(int argc, char *argv[])
 	open_dev(controller, &fd, 1, 1);
 	read_controller_data(fd, &cdata);
 
-	if (cdata.oacs.firmware == 0) {
-		fprintf(stderr, 
-		    "Controller does not support firmware "
-		    "activate/download.\n");
-		exit(EX_IOERR);
-	}
-
-	if (f_flag && slot == 1 && cdata.frmw.slot1_ro) {
-		fprintf(stderr, "Slot %d is marked as read only.\n", slot);
-		exit(EX_IOERR);
-	}
-
-	if (slot > cdata.frmw.num_slots) {
-		fprintf(stderr,
-		    "Slot %d was specified but controller only "
-		    "supports %d firmware slots.\n",
+	if (cdata.oacs.firmware == 0)
+		errx(1,
+		    "controller does not support firmware activate/download");
+
+	if (f_flag && slot == 1 && cdata.frmw.slot1_ro)
+		errx(1, "slot %d is marked as read only", slot);
+
+	if (slot > cdata.frmw.num_slots)
+		errx(1,
+		    "slot %d specified but controller only supports %d slots",
 		    slot, cdata.frmw.num_slots);
-		exit(EX_IOERR);
-	}
 
-	if (!slot_has_valid_firmware(fd, slot)) {
-		fprintf(stderr,
-		    "Slot %d does not contain valid firmware.\n"
-		    "Try 'nvmecontrol logpage -p 3 %s' to get a list "
-		    "of available firmware images.\n",
+	if (!slot_has_valid_firmware(fd, slot))
+		errx(1,
+		    "slot %d does not contain valid firmware,\n"
+		    "try 'nvmecontrol logpage -p 3 %s' to get a list "
+		    "of available images\n",
 		    slot, controller);
-		exit(EX_IOERR);
-	}
 
 	if (f_flag && a_flag)
 		printf("You are about to download and activate "
@@ -305,7 +277,7 @@ firmware(int argc, char *argv[])
 		if (strncasecmp(prompt, "yes", 3) == 0)
 			break;
 		if (strncasecmp(prompt, "no", 2) == 0)
-			exit(EX_OK);
+			exit(1);
 		printf("Please answer \"yes\" or \"no\". ");
 	}
 
@@ -331,5 +303,5 @@ firmware(int argc, char *argv[])
 	}
 
 	close(fd);
-	exit(EX_OK);
+	exit(0);
 }

Modified: stable/9/sbin/nvmecontrol/identify.c
==============================================================================
--- stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -30,13 +30,13 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -139,7 +139,7 @@ identify_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, IDENTIFY_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 static void
@@ -177,16 +177,16 @@ identify_ctrlr(int argc, char *argv[])
 			hexlength = offsetof(struct nvme_controller_data,
 			    reserved5);
 		print_hex(&cdata, hexlength);
-		exit(EX_OK);
+		exit(0);
 	}
 
 	if (verboseflag == 1) {
-		printf("-v not currently supported without -x.\n");
+		fprintf(stderr, "-v not currently supported without -x\n");
 		identify_usage();
 	}
 
 	print_controller(&cdata);
-	exit(EX_OK);
+	exit(0);
 }
 
 static void
@@ -231,10 +231,8 @@ identify_ns(int argc, char *argv[])
 	nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
 	if (nsloc != NULL)
 		nsid = strtol(nsloc + 2, NULL, 10);
-	if (nsloc == NULL || (nsid == 0 && errno != 0)) {
-		printf("Invalid namespace ID %s.\n", argv[optind]);
-		exit(EX_IOERR);
-	}
+	if (nsloc == NULL || (nsid == 0 && errno != 0))
+		errx(1, "invalid namespace ID '%s'", argv[optind]);
 
 	/*
 	 * We send IDENTIFY commands to the controller, not the namespace,
@@ -253,16 +251,16 @@ identify_ns(int argc, char *argv[])
 			hexlength = offsetof(struct nvme_namespace_data,
 			    reserved6);
 		print_hex(&nsdata, hexlength);
-		exit(EX_OK);
+		exit(0);
 	}
 
 	if (verboseflag == 1) {
-		printf("-v not currently supported without -x.\n");
+		fprintf(stderr, "-v not currently supported without -x\n");
 		identify_usage();
 	}
 
 	print_namespace(&nsdata);
-	exit(EX_OK);
+	exit(0);
 }
 
 void

Modified: stable/9/sbin/nvmecontrol/logpage.c
==============================================================================
--- stable/9/sbin/nvmecontrol/logpage.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/logpage.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,7 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -52,14 +52,13 @@ __FBSDID("$FreeBSD$");
 typedef void (*print_fn_t)(void *buf, uint32_t size);
 
 static void *
-get_log_buffer(size_t size)
+get_log_buffer(uint32_t size)
 {
 	void	*buf;
 
-	if ((buf = malloc(size)) == NULL) {
-		fprintf(stderr, "Unable to malloc %zd bytes\n", size);
-		exit(EX_IOERR);
-	}
+	if ((buf = malloc(size)) == NULL)
+		errx(1, "unable to malloc %u bytes", size);
+
 	memset(buf, 0, size);
 	return (buf);
 }
@@ -79,16 +78,11 @@ read_logpage(int fd, uint8_t log_page, i
 	pt.len = payload_size;
 	pt.is_read = 1;
 
-	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
-		printf("Get log page request failed. errno=%d (%s)\n",
-		    errno, strerror(errno));
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
+		err(1, "get log page request failed");
 
-	if (nvme_completion_is_error(&pt.cpl)) {
-		printf("Passthrough command returned error.\n");
-		exit(EX_IOERR);
-	}
+	if (nvme_completion_is_error(&pt.cpl))
+		errx(1, "get log page request returned error");
 }
 
 static void
@@ -242,7 +236,7 @@ logpage_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, LOGPAGE_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 void
@@ -254,7 +248,7 @@ logpage(int argc, char *argv[])
 	int				allow_ns = false;
 	char				ch, *p, *nsloc = NULL;
 	char				*cname = NULL;
-	size_t				size;
+	uint32_t			size;
 	void				*buf;
 	struct logpage_function		*f;
 	struct nvme_controller_data	cdata;
@@ -313,28 +307,20 @@ logpage(int argc, char *argv[])
 	/* If a namespace id was specified, validate it's use */
 	if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) {
 		if (!allow_ns) {
-			if (log_page != NVME_LOG_HEALTH_INFORMATION) {
-				fprintf(stderr,
-				    "Namespace ID not valid for log page %d.\n",
+			if (log_page != NVME_LOG_HEALTH_INFORMATION)
+				errx(1,
+				    "log page %d valid only at controller level",
 				    log_page);
-			} else if (cdata.lpa.ns_smart == 0) {
-				fprintf(stderr,
-				    "Controller does not support per "
-				    "namespace SMART/Health information.\n");
-			}
-			close(fd);
-			exit(EX_IOERR);
+			else if (cdata.lpa.ns_smart == 0)
+				errx(1,
+				    "controller does not support per "
+				    "namespace smart/health information");
 		}
 		nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
 		if (nsloc != NULL)
 			nsid = strtol(nsloc + 2, NULL, 10);
-		if (nsloc == NULL || (nsid == 0 && errno != 0)) {
-			fprintf(stderr,
-			    "Invalid namespace ID %s.\n",
-			    argv[optind]);
-			close(fd);
-			exit(EX_IOERR);
-		}
+		if (nsloc == NULL || (nsid == 0 && errno != 0))
+			errx(1, "invalid namespace id '%s'", argv[optind]);
 
 		/*
 		 * User is asking for per namespace log page information
@@ -384,5 +370,5 @@ logpage(int argc, char *argv[])
 	print_fn(buf, size);
 
 	close(fd);
-	exit(EX_OK);
+	exit(0);
 }

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.c
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -32,14 +32,13 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -71,7 +70,7 @@ usage(void)
 		fprintf(stderr, "%s", f->usage);
 		f++;
 	}
-	exit(EX_USAGE);
+	exit(1);
 }
 
 static void
@@ -134,16 +133,11 @@ read_controller_data(int fd, struct nvme
 	pt.len = sizeof(*cdata);
 	pt.is_read = 1;
 
-	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
-		printf("Identify request failed. errno=%d (%s)\n",
-		    errno, strerror(errno));
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
+		err(1, "identify request failed");
 
-	if (nvme_completion_is_error(&pt.cpl)) {
-		printf("Passthrough command returned error.\n");
-		exit(EX_IOERR);
-	}
+	if (nvme_completion_is_error(&pt.cpl))
+		errx(1, "identify request returned error");
 }
 
 void
@@ -158,16 +152,11 @@ read_namespace_data(int fd, int nsid, st
 	pt.len = sizeof(*nsdata);
 	pt.is_read = 1;
 
-	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
-		printf("Identify request failed. errno=%d (%s)\n",
-		    errno, strerror(errno));
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
+		err(1, "identify request failed");
 
-	if (nvme_completion_is_error(&pt.cpl)) {
-		printf("Passthrough command returned error.\n");
-		exit(EX_IOERR);
-	}
+	if (nvme_completion_is_error(&pt.cpl))
+		errx(1, "identify request returned error");
 }
 
 int
@@ -178,38 +167,35 @@ open_dev(const char *str, int *fd, int s
 
 	if (!strnstr(str, NVME_CTRLR_PREFIX, strlen(NVME_CTRLR_PREFIX))) {
 		if (show_error)
-			fprintf(stderr,
-			    "Controller/namespace IDs must begin with '%s'.\n",
+			warnx("controller/namespace ids must begin with '%s'",
 			    NVME_CTRLR_PREFIX);
 		if (exit_on_error)
-			exit(EX_USAGE);
+			exit(1);
 		else
-			return (EX_USAGE);
+			return (1);
 	}
 
 	snprintf(full_path, sizeof(full_path), "/dev/%s", str);
 	if (stat(full_path, &devstat) != 0) {
 		if (show_error)
-			fprintf(stderr, "Could not stat %s. errno=%d (%s)\n",
-			    full_path, errno, strerror(errno));
+			warn("could not stat %s", full_path);
 		if (exit_on_error)
-			exit(EX_NOINPUT);
+			exit(1);
 		else
-			return (EX_NOINPUT);
+			return (1);
 	}
 
 	*fd = open(full_path, O_RDWR);
 	if (*fd < 0) {
 		if (show_error)
-			fprintf(stderr, "Could not open %s. errno=%d (%s)\n",
-			    full_path, errno, strerror(errno));
+			warn("could not open %s", full_path);
 		if (exit_on_error)
-			exit(EX_NOPERM);
+			exit(1);
 		else
-			return (EX_NOPERM);
+			return (1);
 	}
 
-	return (EX_OK);
+	return (0);
 }
 
 int

Modified: stable/9/sbin/nvmecontrol/perftest.c
==============================================================================
--- stable/9/sbin/nvmecontrol/perftest.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/perftest.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -31,14 +31,13 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -72,7 +71,7 @@ perftest_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, PERFTEST_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 void
@@ -168,14 +167,10 @@ perftest(int argc, char *argv[])
 		perftest_usage();
 
 	open_dev(argv[optind], &fd, 1, 1);
-	if (ioctl(fd, ioctl_cmd, &io_test) < 0) {
-		fprintf(stderr, "NVME_IO_TEST failed. errno=%d (%s)\n", errno,
-		    strerror(errno));
-		close(fd);
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, ioctl_cmd, &io_test) < 0)
+		err(1, "ioctl NVME_IO_TEST failed");
 
 	close(fd);
 	print_perftest(&io_test, perthread);
-	exit(EX_OK);
+	exit(0);
 }

Modified: stable/9/sbin/nvmecontrol/reset.c
==============================================================================
--- stable/9/sbin/nvmecontrol/reset.c	Fri Jul 12 22:08:24 2013	(r253297)
+++ stable/9/sbin/nvmecontrol/reset.c	Fri Jul 12 22:12:48 2013	(r253298)
@@ -30,12 +30,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "nvmecontrol.h"
@@ -45,7 +44,7 @@ reset_usage(void)
 {
 	fprintf(stderr, "usage:\n");
 	fprintf(stderr, RESET_USAGE);
-	exit(EX_USAGE);
+	exit(1);
 }
 
 void
@@ -65,11 +64,8 @@ reset(int argc, char *argv[])
 		reset_usage();
 
 	open_dev(argv[optind], &fd, 1, 1);
-	if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) {
-		printf("Reset request to %s failed. errno=%d (%s)\n",
-		    argv[optind], errno, strerror(errno));
-		exit(EX_IOERR);
-	}
+	if (ioctl(fd, NVME_RESET_CONTROLLER) < 0)
+		err(1, "reset request to %s failed", argv[optind]);
 
-	exit(EX_OK);
+	exit(0);
 }

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:13:46 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id CE3D6B9E;
 Fri, 12 Jul 2013 22:13:46 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id BFF7D121D;
 Fri, 12 Jul 2013 22:13:46 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMDkf9068968;
 Fri, 12 Jul 2013 22:13:46 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CMDknq068967;
 Fri, 12 Jul 2013 22:13:46 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122213.r6CMDknq068967@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:13:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253299 - stable/9/sbin/nvmecontrol
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:13:46 -0000

Author: jimharris
Date: Fri Jul 12 22:13:46 2013
New Revision: 253299
URL: http://svnweb.freebsd.org/changeset/base/253299

Log:
  MFC r253110:
  
    Try to read firmware image before prompting the user to confirm
    firmware download.  This correctly prints an error and exits for
    an incorrect firmware image name before prompting the user to
    confirm the download.
  
  Approved by:	re (kib)

Modified:
  stable/9/sbin/nvmecontrol/firmware.c
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/firmware.c
==============================================================================
--- stable/9/sbin/nvmecontrol/firmware.c	Fri Jul 12 22:12:48 2013	(r253298)
+++ stable/9/sbin/nvmecontrol/firmware.c	Fri Jul 12 22:13:46 2013	(r253299)
@@ -253,6 +253,9 @@ firmware(int argc, char *argv[])
 		    "of available images\n",
 		    slot, controller);
 
+	if (f_flag)
+		read_image_file(image, &buf, &size);
+
 	if (f_flag && a_flag)
 		printf("You are about to download and activate "
 		       "firmware image (%s) to controller %s.\n"
@@ -282,7 +285,6 @@ firmware(int argc, char *argv[])
 	}
 
 	if (f_flag) {
-		read_image_file(image, &buf, &size);
 		update_firmware(fd, buf, size);
 		if (a_flag)
 			activate_firmware(fd, slot,

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:14:58 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 66B3DDC0;
 Fri, 12 Jul 2013 22:14:58 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 57F0B122A;
 Fri, 12 Jul 2013 22:14:58 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMEwTb069166;
 Fri, 12 Jul 2013 22:14:58 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CMEvQQ069162;
 Fri, 12 Jul 2013 22:14:57 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122214.r6CMEvQQ069162@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:14:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253300 - stable/9/sbin/nvmecontrol
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:14:58 -0000

Author: jimharris
Date: Fri Jul 12 22:14:57 2013
New Revision: 253300
URL: http://svnweb.freebsd.org/changeset/base/253300

Log:
  MFC r253114:
  
    Send per-namespace logpage commands to the controller devnode, so they
    are processed as admin commands, not I/O commands.
  
    As part of this change, pull out the code for parsing a namespace node
    string into a separate function, since it is used for both identify and
    logpage commands.
  
  Approved by:	re (kib)

Modified:
  stable/9/sbin/nvmecontrol/identify.c
  stable/9/sbin/nvmecontrol/logpage.c
  stable/9/sbin/nvmecontrol/nvmecontrol.c
  stable/9/sbin/nvmecontrol/nvmecontrol.h
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/identify.c
==============================================================================
--- stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:13:46 2013	(r253299)
+++ stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:14:57 2013	(r253300)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -194,7 +193,6 @@ identify_ns(int argc, char *argv[])
 {
 	struct nvme_namespace_data	nsdata;
 	char				path[64];
-	char				*nsloc;
 	int				ch, fd, hexflag = 0, hexlength, nsid;
 	int				verboseflag = 0;
 
@@ -224,22 +222,12 @@ identify_ns(int argc, char *argv[])
 	close(fd);
 
 	/*
-	 * Pull the namespace id from the string. +2 skips past the "ns" part
-	 *  of the string.  Don't search past 10 characters into the string,
-	 *  otherwise we know it is malformed.
-	 */
-	nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
-	if (nsloc != NULL)
-		nsid = strtol(nsloc + 2, NULL, 10);
-	if (nsloc == NULL || (nsid == 0 && errno != 0))
-		errx(1, "invalid namespace ID '%s'", argv[optind]);
-
-	/*
 	 * We send IDENTIFY commands to the controller, not the namespace,
-	 *  since it is an admin cmd.  So the path should only include the
-	 *  nvmeX part of the nvmeXnsY string.
+	 *  since it is an admin cmd.  The namespace ID will be specified in
+	 *  the IDENTIFY command itself.  So parse the namespace's device node
+	 *  string to get the controller substring and namespace ID.
 	 */
-	snprintf(path, nsloc - argv[optind] + 1, "%s", argv[optind]);
+	parse_ns_str(argv[optind], path, &nsid);
 	open_dev(path, &fd, 1, 1);
 	read_namespace_data(fd, nsid, &nsdata);
 	close(fd);

Modified: stable/9/sbin/nvmecontrol/logpage.c
==============================================================================
--- stable/9/sbin/nvmecontrol/logpage.c	Fri Jul 12 22:13:46 2013	(r253299)
+++ stable/9/sbin/nvmecontrol/logpage.c	Fri Jul 12 22:14:57 2013	(r253300)
@@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -242,12 +241,11 @@ logpage_usage(void)
 void
 logpage(int argc, char *argv[])
 {
-	int				fd, nsid, len;
+	int				fd, nsid;
 	int				log_page = 0, pageflag = false;
-	int				hexflag = false;
-	int				allow_ns = false;
-	char				ch, *p, *nsloc = NULL;
-	char				*cname = NULL;
+	int				hexflag = false, ns_specified;
+	char				ch, *p;
+	char				cname[64];
 	uint32_t			size;
 	void				*buf;
 	struct logpage_function		*f;
@@ -290,46 +288,31 @@ logpage(int argc, char *argv[])
 	if (optind >= argc)
 		logpage_usage();
 
+	if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) {
+		ns_specified = true;
+		parse_ns_str(argv[optind], cname, &nsid);
+		open_dev(cname, &fd, 1, 1);
+	} else {
+		ns_specified = false;
+		nsid = NVME_GLOBAL_NAMESPACE_TAG;
+		open_dev(argv[optind], &fd, 1, 1);
+	}
+
 	/*
 	 * The log page attribtues indicate whether or not the controller
 	 * supports the SMART/Health information log page on a per
 	 * namespace basis.
 	 */
-	cname = malloc(strlen(NVME_CTRLR_PREFIX) + 2);
-	len = strlen(NVME_CTRLR_PREFIX) + 1;
-	cname = strncpy(cname, argv[optind], len);
-	open_dev(cname, &fd, 1, 1);
-	read_controller_data(fd, &cdata);
-
-	if (log_page == NVME_LOG_HEALTH_INFORMATION && cdata.lpa.ns_smart != 0)
-		allow_ns = true;
-
-	/* If a namespace id was specified, validate it's use */
-	if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) {
-		if (!allow_ns) {
-			if (log_page != NVME_LOG_HEALTH_INFORMATION)
-				errx(1,
-				    "log page %d valid only at controller level",
-				    log_page);
-			else if (cdata.lpa.ns_smart == 0)
-				errx(1,
-				    "controller does not support per "
-				    "namespace smart/health information");
-		}
-		nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
-		if (nsloc != NULL)
-			nsid = strtol(nsloc + 2, NULL, 10);
-		if (nsloc == NULL || (nsid == 0 && errno != 0))
-			errx(1, "invalid namespace id '%s'", argv[optind]);
-
-		/*
-		 * User is asking for per namespace log page information
-		 * so close the controller and open up the namespace.
-		 */
-		close(fd);
-		open_dev(argv[optind], &fd, 1, 1);
-	} else
-		nsid = NVME_GLOBAL_NAMESPACE_TAG;
+	if (ns_specified) {
+		if (log_page != NVME_LOG_HEALTH_INFORMATION)
+			errx(1, "log page %d valid only at controller level",
+			    log_page);
+		read_controller_data(fd, &cdata);
+		if (cdata.lpa.ns_smart == 0)
+			errx(1,
+			    "controller does not support per namespace "
+			    "smart/health information");
+	}
 
 	print_fn = print_hex;
 	if (!hexflag) {

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.c
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.c	Fri Jul 12 22:13:46 2013	(r253299)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.c	Fri Jul 12 22:14:57 2013	(r253300)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -198,6 +199,29 @@ open_dev(const char *str, int *fd, int s
 	return (0);
 }
 
+void
+parse_ns_str(const char *ns_str, char *ctrlr_str, int *nsid)
+{
+	char	*nsloc;
+
+	/*
+	 * Pull the namespace id from the string. +2 skips past the "ns" part
+	 *  of the string.  Don't search past 10 characters into the string,
+	 *  otherwise we know it is malformed.
+	 */
+	nsloc = strnstr(ns_str, NVME_NS_PREFIX, 10);
+	if (nsloc != NULL)
+		*nsid = strtol(nsloc + 2, NULL, 10);
+	if (nsloc == NULL || (*nsid == 0 && errno != 0))
+		errx(1, "invalid namespace ID '%s'", ns_str);
+
+	/*
+	 * The controller string will include only the nvmX part of the
+	 *  nvmeXnsY string.
+	 */
+	snprintf(ctrlr_str, nsloc - ns_str + 1, "%s", ns_str);
+}
+
 int
 main(int argc, char *argv[])
 {

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.h
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.h	Fri Jul 12 22:13:46 2013	(r253299)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.h	Fri Jul 12 22:14:57 2013	(r253300)
@@ -63,6 +63,7 @@ void logpage(int argc, char *argv[]);
 void firmware(int argc, char *argv[]);
 
 int open_dev(const char *str, int *fd, int show_error, int exit_on_error);
+void parse_ns_str(const char *ns_str, char *ctrlr_str, int *nsid);
 void read_controller_data(int fd, struct nvme_controller_data *cdata);
 void read_namespace_data(int fd, int nsid, struct nvme_namespace_data *nsdata);
 void print_hex(void *data, uint32_t length);

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:15:50 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 948E8F15;
 Fri, 12 Jul 2013 22:15:50 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 8618B1238;
 Fri, 12 Jul 2013 22:15:50 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMFoaZ069364;
 Fri, 12 Jul 2013 22:15:50 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CMFoYM069363;
 Fri, 12 Jul 2013 22:15:50 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122215.r6CMFoYM069363@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:15:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253301 - stable/9/sbin/nvmecontrol
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:15:50 -0000

Author: jimharris
Date: Fri Jul 12 22:15:50 2013
New Revision: 253301
URL: http://svnweb.freebsd.org/changeset/base/253301

Log:
  MFC r253115:
  
    Condense the output for displaying LBA formats.
  
  Approved by:	re (kib)

Modified:
  stable/9/sbin/nvmecontrol/identify.c
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/identify.c
==============================================================================
--- stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:14:57 2013	(r253300)
+++ stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:15:50 2013	(r253301)
@@ -124,13 +124,11 @@ print_namespace(struct nvme_namespace_da
 	printf("Thin Provisioning:           %s\n",
 		nsdata->nsfeat.thin_prov ? "Supported" : "Not Supported");
 	printf("Number of LBA Formats:       %d\n", nsdata->nlbaf+1);
-	printf("Current LBA Format:          LBA Format #%d\n",
+	printf("Current LBA Format:          LBA Format #%02d\n",
 		nsdata->flbas.format);
-	for (i = 0; i <= nsdata->nlbaf; i++) {
-		printf("LBA Format #%d:\n", i);
-		printf("  LBA Data Size:             %d\n",
-			1 << nsdata->lbaf[i].lbads);
-	}
+	for (i = 0; i <= nsdata->nlbaf; i++)
+		printf("LBA Format #%02d: Data Size: %5d  Metadata Size: %5d\n",
+		    i, 1 << nsdata->lbaf[i].lbads, nsdata->lbaf[i].ms);
 }
 
 static void

From owner-svn-src-stable-9@FreeBSD.ORG  Fri Jul 12 22:16:43 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id CF63AD9;
 Fri, 12 Jul 2013 22:16:43 +0000 (UTC)
 (envelope-from jimharris@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id C0FD0123D;
 Fri, 12 Jul 2013 22:16:43 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CMGhLx069526;
 Fri, 12 Jul 2013 22:16:43 GMT
 (envelope-from jimharris@svn.freebsd.org)
Received: (from jimharris@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6CMGhtU069522;
 Fri, 12 Jul 2013 22:16:43 GMT
 (envelope-from jimharris@svn.freebsd.org)
Message-Id: <201307122216.r6CMGhtU069522@svn.freebsd.org>
From: Jim Harris 
Date: Fri, 12 Jul 2013 22:16:43 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253302 - stable/9/sbin/nvmecontrol
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 12 Jul 2013 22:16:43 -0000

Author: jimharris
Date: Fri Jul 12 22:16:43 2013
New Revision: 253302
URL: http://svnweb.freebsd.org/changeset/base/253302

Log:
  MFC r253116:
  
    Ensure controller or namespace node name is specified before trying to
    access it.
  
    While here, also fix the identify usage message to show the -v and -x
    parameters.
  
  Approved by:	re (kib)

Modified:
  stable/9/sbin/nvmecontrol/identify.c
  stable/9/sbin/nvmecontrol/nvmecontrol.h
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)

Modified: stable/9/sbin/nvmecontrol/identify.c
==============================================================================
--- stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:15:50 2013	(r253301)
+++ stable/9/sbin/nvmecontrol/identify.c	Fri Jul 12 22:16:43 2013	(r253302)
@@ -259,6 +259,10 @@ identify(int argc, char *argv[])
 
 	while (getopt(argc, argv, "vx") != -1) ;
 
+	/* Check that a controller or namespace was specified. */
+	if (optind >= argc)
+		identify_usage();
+
 	target = argv[optind];
 
 	optreset = 1;

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.h
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.h	Fri Jul 12 22:15:50 2013	(r253301)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.h	Fri Jul 12 22:16:43 2013	(r253302)
@@ -38,7 +38,7 @@
 "       nvmecontrol devlist\n"
 
 #define IDENTIFY_USAGE							       \
-"       nvmecontrol identify \n"
+"       nvmecontrol identify [-x [-v]] \n"
 
 #define PERFTEST_USAGE							       \
 "       nvmecontrol perftest <-n num_threads> <-o read|write>\n"	       \

From owner-svn-src-stable-9@FreeBSD.ORG  Sat Jul 13 10:47:18 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id A1E8C78D;
 Sat, 13 Jul 2013 10:47:18 +0000 (UTC) (envelope-from des@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 938BA1A3F;
 Sat, 13 Jul 2013 10:47:18 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DAlIJV088946;
 Sat, 13 Jul 2013 10:47:18 GMT (envelope-from des@svn.freebsd.org)
Received: (from des@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6DAlIfi088944;
 Sat, 13 Jul 2013 10:47:18 GMT (envelope-from des@svn.freebsd.org)
Message-Id: <201307131047.r6DAlIfi088944@svn.freebsd.org>
From: Dag-Erling Smørgrav 
Date: Sat, 13 Jul 2013 10:47:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253320 - in stable/9: tools/build/mk usr.sbin/authpf
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 13 Jul 2013 10:47:18 -0000

Author: des
Date: Sat Jul 13 10:47:17 2013
New Revision: 253320
URL: http://svnweb.freebsd.org/changeset/base/253320

Log:
  MFH (r253138,r253258): install authpf-noip
  
  Approved by:	re (delphij)

Modified:
  stable/9/tools/build/mk/OptionalObsoleteFiles.inc
  stable/9/usr.sbin/authpf/Makefile
Directory Properties:
  stable/9/tools/build/   (props changed)
  stable/9/usr.sbin/authpf/   (props changed)

Modified: stable/9/tools/build/mk/OptionalObsoleteFiles.inc
==============================================================================
--- stable/9/tools/build/mk/OptionalObsoleteFiles.inc	Sat Jul 13 10:10:45 2013	(r253319)
+++ stable/9/tools/build/mk/OptionalObsoleteFiles.inc	Sat Jul 13 10:47:17 2013	(r253320)
@@ -134,7 +134,9 @@ OLD_FILES+=usr/share/man/man8/auditd.8.g
 
 .if ${MK_AUTHPF} == no
 OLD_FILES+=usr/sbin/authpf
+OLD_FILES+=usr/sbin/authpf-noip
 OLD_FILES+=usr/share/man/man8/authpf.8.gz
+OLD_FILES+=usr/share/man/man8/authpf-noip.8.gz
 .endif
 
 .if ${MK_BIND} == no

Modified: stable/9/usr.sbin/authpf/Makefile
==============================================================================
--- stable/9/usr.sbin/authpf/Makefile	Sat Jul 13 10:10:45 2013	(r253319)
+++ stable/9/usr.sbin/authpf/Makefile	Sat Jul 13 10:47:17 2013	(r253320)
@@ -21,4 +21,7 @@ DPADD+= ${LIBM} ${LIBMD} ${LIBUTIL}
 
 WARNS?=	3
 
+LINKS=	${BINDIR}/authpf ${BINDIR}/authpf-noip
+MLINKS=	authpf.8 authpf-noip.8
+
 .include 

From owner-svn-src-stable-9@FreeBSD.ORG  Sat Jul 13 18:09:43 2013
Return-Path: 
Delivered-To: svn-src-stable-9@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id B21985F9;
 Sat, 13 Jul 2013 18:09:43 +0000 (UTC)
 (envelope-from mckusick@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 by mx1.freebsd.org (Postfix) with ESMTP id 944781B67;
 Sat, 13 Jul 2013 18:09:43 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DI9h92099887;
 Sat, 13 Jul 2013 18:09:43 GMT
 (envelope-from mckusick@svn.freebsd.org)
Received: (from mckusick@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6DI9hsk099878;
 Sat, 13 Jul 2013 18:09:43 GMT
 (envelope-from mckusick@svn.freebsd.org)
Message-Id: <201307131809.r6DI9hsk099878@svn.freebsd.org>
From: Kirk McKusick 
Date: Sat, 13 Jul 2013 18:09:43 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r253324 - stable/9/sys/ufs/ffs
X-SVN-Group: stable-9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-9@freebsd.org
X-Mailman-Version: 2.1.14
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, 13 Jul 2013 18:09:43 -0000

Author: mckusick
Date: Sat Jul 13 18:09:42 2013
New Revision: 253324
URL: http://svnweb.freebsd.org/changeset/base/253324

Log:
  MFC of 252527:
  
  Make better use of metadata area by avoiding using it for data blocks
  that no should no longer immediately follow their indirect blocks.
  
  Reviewed by: Bruce Evans
  Approved by: re (marius@)

Modified:
  stable/9/sys/ufs/ffs/ffs_alloc.c
  stable/9/sys/ufs/ffs/ffs_balloc.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- stable/9/sys/ufs/ffs/ffs_alloc.c	Sat Jul 13 15:34:37 2013	(r253323)
+++ stable/9/sys/ufs/ffs/ffs_alloc.c	Sat Jul 13 18:09:42 2013	(r253324)
@@ -1709,7 +1709,7 @@ ffs_alloccgblk(ip, bp, bpref, size)
 	cgp = (struct cg *)bp->b_data;
 	blksfree = cg_blksfree(cgp);
 	if (bpref == 0) {
-		bpref = cgp->cg_rotor;
+		bpref = cgbase(fs, cgp->cg_cgx) + cgp->cg_rotor + fs->fs_frag;
 	} else if ((cgbpref = dtog(fs, bpref)) != cgp->cg_cgx) {
 		/* map bpref to correct zone in this cg */
 		if (bpref < cgdata(fs, cgbpref))

Modified: stable/9/sys/ufs/ffs/ffs_balloc.c
==============================================================================
--- stable/9/sys/ufs/ffs/ffs_balloc.c	Sat Jul 13 15:34:37 2013	(r253323)
+++ stable/9/sys/ufs/ffs/ffs_balloc.c	Sat Jul 13 18:09:42 2013	(r253324)
@@ -299,6 +299,10 @@ retry:
 			continue;
 		}
 		UFS_LOCK(ump);
+		/*
+		 * If parent indirect has just been allocated, try to cluster
+		 * immediately following it.
+		 */
 		if (pref == 0)
 			pref = ffs_blkpref_ufs1(ip, lbn, i - num - 1,
 			    (ufs1_daddr_t *)0);
@@ -368,7 +372,14 @@ retry:
 	 */
 	if (nb == 0) {
 		UFS_LOCK(ump);
-		if (pref == 0)
+		/*
+		 * If allocating metadata at the front of the cylinder
+		 * group and parent indirect block has just been allocated,
+		 * then cluster next to it if it is the first indirect in
+		 * the file. Otherwise it has been allocated in the metadata
+		 * area, so we want to find our own place out in the data area.
+		 */
+		if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
 			pref = ffs_blkpref_ufs1(ip, lbn, indirs[i].in_off,
 			    &bap[0]);
 		error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
@@ -850,6 +861,10 @@ retry:
 			continue;
 		}
 		UFS_LOCK(ump);
+		/*
+		 * If parent indirect has just been allocated, try to cluster
+		 * immediately following it.
+		 */
 		if (pref == 0)
 			pref = ffs_blkpref_ufs2(ip, lbn, i - num - 1,
 			    (ufs2_daddr_t *)0);
@@ -920,7 +935,14 @@ retry:
 	 */
 	if (nb == 0) {
 		UFS_LOCK(ump);
-		if (pref == 0)
+		/*
+		 * If allocating metadata at the front of the cylinder
+		 * group and parent indirect block has just been allocated,
+		 * then cluster next to it if it is the first indirect in
+		 * the file. Otherwise it has been allocated in the metadata
+		 * area, so we want to find our own place out in the data area.
+		 */
+		if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
 			pref = ffs_blkpref_ufs2(ip, lbn, indirs[i].in_off,
 			    &bap[0]);
 		error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,