From owner-svn-src-stable-10@freebsd.org Sun Jul 24 04:38:51 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95E96BA0678; Sun, 24 Jul 2016 04:38:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6DD981F56; Sun, 24 Jul 2016 04:38:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6O4coGS090418; Sun, 24 Jul 2016 04:38:50 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6O4coKF090414; Sun, 24 Jul 2016 04:38:50 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607240438.u6O4coKF090414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sun, 24 Jul 2016 04:38:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303254 - in stable: 10 10/share/man/man9 10/sys/sys 9 9/share/man/man9 9/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2016 04:38:51 -0000 Author: jhb Date: Sun Jul 24 04:38:50 2016 New Revision: 303254 URL: https://svnweb.freebsd.org/changeset/base/303254 Log: MFC 300253: Remove dangling references to rman_await_resource(). This function was removed when RF_TIMESHARE was removed a couple of years ago. Modified: stable/10/ObsoleteFiles.inc stable/10/share/man/man9/Makefile stable/10/share/man/man9/rman.9 stable/10/sys/sys/rman.h Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/ObsoleteFiles.inc (contents, props changed) stable/9/share/man/man9/Makefile stable/9/share/man/man9/rman.9 stable/9/sys/sys/rman.h Directory Properties: stable/9/ (props changed) stable/9/share/man/man9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/10/ObsoleteFiles.inc ============================================================================== --- stable/10/ObsoleteFiles.inc Sun Jul 24 01:31:41 2016 (r303253) +++ stable/10/ObsoleteFiles.inc Sun Jul 24 04:38:50 2016 (r303254) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20160723: stale MLINK removed +OLD_FILES+=usr/share/man/man9/rman_await_resource.9.gz # 20160216: Remove obsolete unbound-control-setup OLD_FILES+=usr/sbin/unbound-control-setup # 20151222: liblzma header Modified: stable/10/share/man/man9/Makefile ============================================================================== --- stable/10/share/man/man9/Makefile Sun Jul 24 01:31:41 2016 (r303253) +++ stable/10/share/man/man9/Makefile Sun Jul 24 04:38:50 2016 (r303254) @@ -1074,7 +1074,6 @@ MLINKS+=resource_int_value.9 resource_lo resource_int_value.9 resource_string_value.9 MLINKS+=rman.9 rman_activate_resource.9 \ rman.9 rman_adjust_resource.9 \ - rman.9 rman_await_resource.9 \ rman.9 rman_deactivate_resource.9 \ rman.9 rman_fini.9 \ rman.9 rman_first_free_region.9 \ Modified: stable/10/share/man/man9/rman.9 ============================================================================== --- stable/10/share/man/man9/rman.9 Sun Jul 24 01:31:41 2016 (r303253) +++ stable/10/share/man/man9/rman.9 Sun Jul 24 04:38:50 2016 (r303254) @@ -25,14 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd July 15, 2014 +.Dd May 19, 2016 .Dt RMAN 9 .Os .Sh NAME .Nm rman , .Nm rman_activate_resource , .Nm rman_adjust_resource , -.Nm rman_await_resource , .Nm rman_deactivate_resource , .Nm rman_fini , .Nm rman_init , @@ -67,8 +66,6 @@ .Ft int .Fn rman_adjust_resource "struct resource *r" "u_long start" "u_long end" .Ft int -.Fn rman_await_resource "struct resource *r" "int pri2" "int timo" -.Ft int .Fn rman_deactivate_resource "struct resource *r" .Ft int .Fn rman_fini "struct rman *rm" @@ -387,23 +384,6 @@ flag. If other consumers are waiting for this range, it will wakeup their threads. .Pp The -.Fn rman_await_resource -function performs an asynchronous wait for a resource -.Fa r -to become inactive, that is, for the -.Dv RF_ACTIVE -flag to be cleared. -It is used to enable cooperative sharing of a resource -which can only be safely used by one thread at a time. -The arguments -.Fa pri -and -.Fa timo -are passed to the -.Fn rman_await_resource -function. -.Pp -The .Fn rman_get_start , .Fn rman_get_end , .Fn rman_get_size , Modified: stable/10/sys/sys/rman.h ============================================================================== --- stable/10/sys/sys/rman.h Sun Jul 24 01:31:41 2016 (r303253) +++ stable/10/sys/sys/rman.h Sun Jul 24 04:38:50 2016 (r303254) @@ -117,7 +117,6 @@ TAILQ_HEAD(rman_head, rman); int rman_activate_resource(struct resource *r); int rman_adjust_resource(struct resource *r, u_long start, u_long end); -int rman_await_resource(struct resource *r, int pri, int timo); int rman_first_free_region(struct rman *rm, u_long *start, u_long *end); bus_space_handle_t rman_get_bushandle(struct resource *); bus_space_tag_t rman_get_bustag(struct resource *); From owner-svn-src-stable-10@freebsd.org Sun Jul 24 05:24:12 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11287BA10BD; Sun, 24 Jul 2016 05:24:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C4AC015E5; Sun, 24 Jul 2016 05:24:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6O5OAmM008947; Sun, 24 Jul 2016 05:24:10 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6O5OANG008944; Sun, 24 Jul 2016 05:24:10 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607240524.u6O5OANG008944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sun, 24 Jul 2016 05:24:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303255 - in stable: 10/share/man/man9 10/sys/dev/pci 9/share/man/man9 9/sys/dev/pci X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2016 05:24:12 -0000 Author: jhb Date: Sun Jul 24 05:24:10 2016 New Revision: 303255 URL: https://svnweb.freebsd.org/changeset/base/303255 Log: MFC 302175: Add pci_get_max_payload() to fetch the PCI-express maximum payload size. Modified: stable/10/share/man/man9/pci.9 stable/10/sys/dev/pci/pci.c stable/10/sys/dev/pci/pcivar.h Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/share/man/man9/pci.9 stable/9/sys/dev/pci/pci.c stable/9/sys/dev/pci/pcivar.h Directory Properties: stable/9/share/man/man9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/10/share/man/man9/pci.9 ============================================================================== --- stable/10/share/man/man9/pci.9 Sun Jul 24 04:38:50 2016 (r303254) +++ stable/10/share/man/man9/pci.9 Sun Jul 24 05:24:10 2016 (r303255) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 23, 2015 +.Dd June 24, 2016 .Dt PCI 9 .Os .Sh NAME @@ -43,6 +43,7 @@ .Nm pci_find_extcap , .Nm pci_find_htcap , .Nm pci_find_pcie_root_port , +.Nm pci_get_max_payload , .Nm pci_get_max_read_req , .Nm pci_get_powerstate , .Nm pci_get_vpd_ident , @@ -95,6 +96,8 @@ .Ft device_t .Fn pci_find_pcie_root_port "device_t dev" .Ft int +.Fn pci_get_max_payload "device_t dev" +.Ft int .Fn pci_get_max_read_req "device_t dev" .Ft int .Fn pci_get_powerstate "device_t dev" @@ -436,6 +439,16 @@ or .Xr bus_activate_resource 9 . .Pp The +.Fn pci_get_max_payload +function returns the current maximum TLP payload size in bytes for a +PCI-express device. +If the +.Fa dev +device is not a PCI-express device, +.Fn pci_get_max_payload +returns zero. +.Pp +The .Fn pci_get_max_read_req function returns the current maximum read request size in bytes for a PCI-express device. Modified: stable/10/sys/dev/pci/pci.c ============================================================================== --- stable/10/sys/dev/pci/pci.c Sun Jul 24 04:38:50 2016 (r303254) +++ stable/10/sys/dev/pci/pci.c Sun Jul 24 05:24:10 2016 (r303255) @@ -1881,6 +1881,22 @@ pci_ht_map_msi(device_t dev, uint64_t ad } int +pci_get_max_payload(device_t dev) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + int cap; + uint16_t val; + + cap = dinfo->cfg.pcie.pcie_location; + if (cap == 0) + return (0); + val = pci_read_config(dev, cap + PCIER_DEVICE_CTL, 2); + val &= PCIEM_CTL_MAX_PAYLOAD; + val >>= 5; + return (1 << (val + 7)); +} + +int pci_get_max_read_req(device_t dev) { struct pci_devinfo *dinfo = device_get_ivars(dev); Modified: stable/10/sys/dev/pci/pcivar.h ============================================================================== --- stable/10/sys/dev/pci/pcivar.h Sun Jul 24 04:38:50 2016 (r303254) +++ stable/10/sys/dev/pci/pcivar.h Sun Jul 24 05:24:10 2016 (r303255) @@ -534,6 +534,7 @@ int pci_msix_device_blacklisted(device_t void pci_ht_map_msi(device_t dev, uint64_t addr); device_t pci_find_pcie_root_port(device_t dev); +int pci_get_max_payload(device_t dev); int pci_get_max_read_req(device_t dev); void pci_restore_state(device_t dev); void pci_save_state(device_t dev); From owner-svn-src-stable-10@freebsd.org Sun Jul 24 08:21:22 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C323BA3C5A; Sun, 24 Jul 2016 08:21:22 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E9071FCB; Sun, 24 Jul 2016 08:21:22 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6O8LLGo070994; Sun, 24 Jul 2016 08:21:21 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6O8LLX9070991; Sun, 24 Jul 2016 08:21:21 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201607240821.u6O8LLX9070991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 24 Jul 2016 08:21:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303257 - in stable/10/usr.sbin/pw: . tests X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2016 08:21:22 -0000 Author: bapt Date: Sun Jul 24 08:21:21 2016 New Revision: 303257 URL: https://svnweb.freebsd.org/changeset/base/303257 Log: Do not try to delete the home of the user if is is not a directory for example "/dev/null" PR: 211195 Submitted by: rday Reported by: eniorm Modified: stable/10/usr.sbin/pw/rm_r.c stable/10/usr.sbin/pw/tests/pw_userdel.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/pw/rm_r.c ============================================================================== --- stable/10/usr.sbin/pw/rm_r.c Sun Jul 24 08:12:23 2016 (r303256) +++ stable/10/usr.sbin/pw/rm_r.c Sun Jul 24 08:21:21 2016 (r303257) @@ -50,6 +50,9 @@ rm_r(int rootfd, const char *path, uid_t path++; dirfd = openat(rootfd, path, O_DIRECTORY); + if (dirfd == -1) { + return; + } d = fdopendir(dirfd); while ((e = readdir(d)) != NULL) { Modified: stable/10/usr.sbin/pw/tests/pw_userdel.sh ============================================================================== --- stable/10/usr.sbin/pw/tests/pw_userdel.sh Sun Jul 24 08:12:23 2016 (r303256) +++ stable/10/usr.sbin/pw/tests/pw_userdel.sh Sun Jul 24 08:21:21 2016 (r303257) @@ -59,9 +59,18 @@ delete_numeric_name_body() { ${PW} userdel -n 4001 } +atf_test_case home_not_a_dir +home_not_a_dir_body() { + populate_root_etc_skel + touch ${HOME}/foo + atf_check ${RPW} useradd foo -d /foo + atf_check ${RPW} userdel foo -r +} + atf_init_test_cases() { atf_add_test_case rmuser_seperate_group atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown atf_add_test_case delete_files atf_add_test_case delete_numeric_name + atf_add_test_case home_not_a_dir } From owner-svn-src-stable-10@freebsd.org Sun Jul 24 16:33:49 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C014BBA3808; Sun, 24 Jul 2016 16:33:49 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8FBDC17A8; Sun, 24 Jul 2016 16:33:49 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6OGXm4R059714; Sun, 24 Jul 2016 16:33:48 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6OGXmVd059713; Sun, 24 Jul 2016 16:33:48 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607241633.u6OGXmVd059713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 24 Jul 2016 16:33:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303269 - stable/10/sys/dev/ixgbe X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2016 16:33:49 -0000 Author: sbruno Date: Sun Jul 24 16:33:48 2016 New Revision: 303269 URL: https://svnweb.freebsd.org/changeset/base/303269 Log: MFC r303032 Fixup DA cable detection routines to not set the cable type to unknown if they do not match one of two cable types. PR: 150249 Modified: stable/10/sys/dev/ixgbe/ixgbe_phy.c Modified: stable/10/sys/dev/ixgbe/ixgbe_phy.c ============================================================================== --- stable/10/sys/dev/ixgbe/ixgbe_phy.c Sun Jul 24 16:32:34 2016 (r303268) +++ stable/10/sys/dev/ixgbe/ixgbe_phy.c Sun Jul 24 16:33:48 2016 (r303269) @@ -1534,21 +1534,18 @@ s32 ixgbe_identify_sfp_module_generic(st hw->phy.type = ixgbe_phy_sfp_intel; break; default: - if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) - hw->phy.type = - ixgbe_phy_sfp_passive_unknown; - else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) - hw->phy.type = - ixgbe_phy_sfp_active_unknown; - else - hw->phy.type = ixgbe_phy_sfp_unknown; + hw->phy.type = ixgbe_phy_sfp_unknown; break; } } /* Allow any DA cable vendor */ if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE | - IXGBE_SFF_DA_ACTIVE_CABLE)) { + IXGBE_SFF_DA_ACTIVE_CABLE)) { + if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) + hw->phy.type = ixgbe_phy_sfp_passive_unknown; + else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) + hw->phy.type = ixgbe_phy_sfp_active_unknown; status = IXGBE_SUCCESS; goto out; } From owner-svn-src-stable-10@freebsd.org Mon Jul 25 00:46:02 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8AA0FBA31AA; Mon, 25 Jul 2016 00:46:02 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C8AB13B0; Mon, 25 Jul 2016 00:46:02 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6P0k1Gb041295; Mon, 25 Jul 2016 00:46:01 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6P0k1i1041294; Mon, 25 Jul 2016 00:46:01 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201607250046.u6P0k1i1041294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 25 Jul 2016 00:46:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303280 - stable/10/usr.bin/mail X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 00:46:02 -0000 Author: delphij Date: Mon Jul 25 00:46:01 2016 New Revision: 303280 URL: https://svnweb.freebsd.org/changeset/base/303280 Log: MFC r302542: Use _PATH_DEVNULL instead of hardcoding. Modified: stable/10/usr.bin/mail/collect.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mail/collect.c ============================================================================== --- stable/10/usr.bin/mail/collect.c Sun Jul 24 23:40:33 2016 (r303279) +++ stable/10/usr.bin/mail/collect.c Mon Jul 25 00:46:01 2016 (r303280) @@ -339,9 +339,9 @@ cont: int nullfd, tempfd, rc; char tempname2[PATHSIZE]; - if ((nullfd = open("/dev/null", O_RDONLY, 0)) + if ((nullfd = open(_PATH_DEVNULL, O_RDONLY, 0)) == -1) { - warn("/dev/null"); + warn(_PATH_DEVNULL); break; } From owner-svn-src-stable-10@freebsd.org Mon Jul 25 13:31:19 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 694FFBA40F9; Mon, 25 Jul 2016 13:31:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A10F1517; Mon, 25 Jul 2016 13:31:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PDVI0Q021571; Mon, 25 Jul 2016 13:31:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PDVIPV021569; Mon, 25 Jul 2016 13:31:18 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607251331.u6PDVIPV021569@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 25 Jul 2016 13:31:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303291 - in stable/10/sys: kern vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 13:31:19 -0000 Author: kib Date: Mon Jul 25 13:31:18 2016 New Revision: 303291 URL: https://svnweb.freebsd.org/changeset/base/303291 Log: MFC r302567: In vgonel(), postpone setting BO_DEAD until VOP_RECLAIM() is called, if vnode is VMIO. For VMIO vnodes, set BO_DEAD in vm_object_terminate(). MFC r302580: Fix grammar. Modified: stable/10/sys/kern/vfs_subr.c stable/10/sys/vm/vm_object.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_subr.c ============================================================================== --- stable/10/sys/kern/vfs_subr.c Mon Jul 25 13:28:59 2016 (r303290) +++ stable/10/sys/kern/vfs_subr.c Mon Jul 25 13:31:18 2016 (r303291) @@ -2934,7 +2934,13 @@ vgonel(struct vnode *vp) TAILQ_EMPTY(&vp->v_bufobj.bo_clean.bv_hd) && vp->v_bufobj.bo_clean.bv_cnt == 0, ("vp %p bufobj not invalidated", vp)); - vp->v_bufobj.bo_flag |= BO_DEAD; + + /* + * For VMIO bufobj, BO_DEAD is set in vm_object_terminate() + * after the object's page queue is flushed. + */ + if (vp->v_bufobj.bo_object == NULL) + vp->v_bufobj.bo_flag |= BO_DEAD; BO_UNLOCK(&vp->v_bufobj); /* Modified: stable/10/sys/vm/vm_object.c ============================================================================== --- stable/10/sys/vm/vm_object.c Mon Jul 25 13:28:59 2016 (r303290) +++ stable/10/sys/vm/vm_object.c Mon Jul 25 13:31:18 2016 (r303291) @@ -737,6 +737,10 @@ vm_object_terminate(vm_object_t object) vinvalbuf(vp, V_SAVE, 0, 0); + BO_LOCK(&vp->v_bufobj); + vp->v_bufobj.bo_flag |= BO_DEAD; + BO_UNLOCK(&vp->v_bufobj); + VM_OBJECT_WLOCK(object); } From owner-svn-src-stable-10@freebsd.org Mon Jul 25 14:26:35 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C3B2BA4C5F; Mon, 25 Jul 2016 14:26:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8CEC12CC; Mon, 25 Jul 2016 14:26:34 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PEQX5g042846; Mon, 25 Jul 2016 14:26:33 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PEQXKV042845; Mon, 25 Jul 2016 14:26:33 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201607251426.u6PEQXKV042845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 25 Jul 2016 14:26:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303293 - stable/10/lib/libcxxrt X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 14:26:35 -0000 Author: emaste Date: Mon Jul 25 14:26:33 2016 New Revision: 303293 URL: https://svnweb.freebsd.org/changeset/base/303293 Log: MFC r302278: libcxxrt: correct mangled "typeinfo name" symbols in Version.map r261644 (MFC of r260553) added missing C++ typinfos to libcxxrt's version script. It appears that a number of duplicate mangled symbols were added due to a cut and paste error. Switch the second instances to _ZTS*, typeinfo name for *. Found by lld, which produces an error or warning for duplicate symbols. Sponsored by: The FreeBSD Foundation Modified: stable/10/lib/libcxxrt/Version.map Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libcxxrt/Version.map ============================================================================== --- stable/10/lib/libcxxrt/Version.map Mon Jul 25 14:16:28 2016 (r303292) +++ stable/10/lib/libcxxrt/Version.map Mon Jul 25 14:26:33 2016 (r303293) @@ -209,19 +209,19 @@ CXXABI_1.3 { "typeinfo name for void*"; "typeinfo name for unsigned int*"; "typeinfo name for float*"; - # C++11 typeinfo not understood by our linker + # C++11 typeinfo name not understood by our linker # std::nullptr_t - _ZTSDn;_ZTIPDn;_ZTIPKDn; + _ZTSDn;_ZTSPDn;_ZTSPKDn; # char16_t - _ZTSDi;_ZTIPDi;_ZTIPKDi; + _ZTSDi;_ZTSPDi;_ZTSPKDi; # char32_t - _ZTSDs;_ZTIPDs;_ZTIPKDs; + _ZTSDs;_ZTSPDs;_ZTSPKDs; # IEEE 754r decimal floating point - _ZTSDd;_ZTIPDd;_ZTIPKDd; - _ZTSDe;_ZTIPDe;_ZTIPKDe; - _ZTSDf;_ZTIPDf;_ZTIPKDf; + _ZTSDd;_ZTSPDd;_ZTSPKDd; + _ZTSDe;_ZTSPDe;_ZTSPKDe; + _ZTSDf;_ZTSPDf;_ZTSPKDf; # IEEE 754r half-precision floating point - _ZTSDh;_ZTIPDh;_ZTIPKDh; + _ZTSDh;_ZTSPDh;_ZTSPKDh; "typeinfo name for __cxxabiv1::__array_type_info"; "typeinfo name for __cxxabiv1::__class_type_info"; From owner-svn-src-stable-10@freebsd.org Mon Jul 25 14:28:51 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58943BA4D12; Mon, 25 Jul 2016 14:28:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AFF214D0; Mon, 25 Jul 2016 14:28:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PESodI042981; Mon, 25 Jul 2016 14:28:50 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PESo3s042980; Mon, 25 Jul 2016 14:28:50 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201607251428.u6PESo3s042980@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 25 Jul 2016 14:28:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303294 - stable/10/sys/boot/efi/boot1 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 14:28:51 -0000 Author: emaste Date: Mon Jul 25 14:28:50 2016 New Revision: 303294 URL: https://svnweb.freebsd.org/changeset/base/303294 Log: MFC r302335: boot1.efi: fix assignment / comparison expression PR: 210706 Submitted by: David Binderman Modified: stable/10/sys/boot/efi/boot1/boot1.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/efi/boot1/boot1.c ============================================================================== --- stable/10/sys/boot/efi/boot1/boot1.c Mon Jul 25 14:26:33 2016 (r303293) +++ stable/10/sys/boot/efi/boot1/boot1.c Mon Jul 25 14:28:50 2016 (r303294) @@ -629,7 +629,7 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_T case EFI_BUFFER_TOO_SMALL: (void)bs->FreePool(handles); if ((status = bs->AllocatePool(EfiLoaderData, hsize, - (void **)&handles) != EFI_SUCCESS)) { + (void **)&handles)) != EFI_SUCCESS) { panic("Failed to allocate %zu handles (%lu)", hsize / sizeof(*handles), EFI_ERROR_CODE(status)); } From owner-svn-src-stable-10@freebsd.org Mon Jul 25 14:35:15 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 611FDBA4F12; Mon, 25 Jul 2016 14:35:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B2F919A2; Mon, 25 Jul 2016 14:35:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PEZEQx046537; Mon, 25 Jul 2016 14:35:14 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PEZE3C046535; Mon, 25 Jul 2016 14:35:14 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201607251435.u6PEZE3C046535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 25 Jul 2016 14:35:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303295 - stable/10/usr.bin/ar X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 14:35:15 -0000 Author: emaste Date: Mon Jul 25 14:35:14 2016 New Revision: 303295 URL: https://svnweb.freebsd.org/changeset/base/303295 Log: MFC r301974: ar: enable reproducible output by default when invoked as 'ar -s' ar output is already deterministic by default for ar -q and ar -r, and when invoked as ranlib. Make ar -s equivalent to ranlib and enable deterministic output by default in that case too. PR: 210330 Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.bin/ar/ar.1 stable/10/usr.bin/ar/ar.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/ar/ar.1 ============================================================================== --- stable/10/usr.bin/ar/ar.1 Mon Jul 25 14:28:50 2016 (r303294) +++ stable/10/usr.bin/ar/ar.1 Mon Jul 25 14:35:14 2016 (r303295) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 24, 2015 +.Dd July 25, 2016 .Dt AR 1 .Os .Sh NAME @@ -205,7 +205,12 @@ When used in combination with the .Fl r or .Fl q -option, insert 0's instead of the real mtime, uid and gid values +option, +with the +.Fl s +option without other options, or when invoked as +.Nm ranlib , +insert 0's instead of the real mtime, uid and gid values and 0644 instead of file mode from the members named by arguments .Ar . This ensures that checksums on the resulting archives are reproducible Modified: stable/10/usr.bin/ar/ar.c ============================================================================== --- stable/10/usr.bin/ar/ar.c Mon Jul 25 14:28:50 2016 (r303294) +++ stable/10/usr.bin/ar/ar.c Mon Jul 25 14:35:14 2016 (r303295) @@ -283,7 +283,8 @@ main(int argc, char **argv) } /* Set determinstic mode for -D, and by default without -U. */ - if (Dflag || (Uflag == 0 && (bsdar->mode == 'q' || bsdar->mode == 'r'))) + if (Dflag || (Uflag == 0 && (bsdar->mode == 'q' || bsdar->mode == 'r' || + (bsdar->mode == '\0' && bsdar->options & AR_S)))) bsdar->options |= AR_D; if (bsdar->options & AR_A) From owner-svn-src-stable-10@freebsd.org Mon Jul 25 14:36:57 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12878BA3049; Mon, 25 Jul 2016 14:36:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D905F1C94; Mon, 25 Jul 2016 14:36:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PEaugv046710; Mon, 25 Jul 2016 14:36:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PEau7O046709; Mon, 25 Jul 2016 14:36:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201607251436.u6PEau7O046709@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 25 Jul 2016 14:36:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303297 - stable/10/sys/boot/efi/boot1 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 14:36:57 -0000 Author: emaste Date: Mon Jul 25 14:36:55 2016 New Revision: 303297 URL: https://svnweb.freebsd.org/changeset/base/303297 Log: MFC r297871: boot1.efifat: provide a fallback startup.nsh In case the firmware falls through to executing startup.sh, populate it with the name of our boot loader. In normal operation this should not be necessary but may allow the system to boot if it would otherwise just remain at a shell prompt. Sponsored by: The FreeBSD Foundation Modified: stable/10/sys/boot/efi/boot1/generate-fat.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/efi/boot1/generate-fat.sh ============================================================================== --- stable/10/sys/boot/efi/boot1/generate-fat.sh Mon Jul 25 14:35:48 2016 (r303296) +++ stable/10/sys/boot/efi/boot1/generate-fat.sh Mon Jul 25 14:36:55 2016 (r303297) @@ -41,6 +41,8 @@ mkdir -p stub/efi/boot # Make a dummy file for boot1 echo 'Boot1 START' | dd of=stub/efi/boot/$FILENAME cbs=$BOOT1_SIZE count=1 conv=block +# Provide a fallback startup.nsh +echo $FILENAME > stub/efi/boot/startup.nsh umount stub mdconfig -d -u $DEVICE From owner-svn-src-stable-10@freebsd.org Mon Jul 25 14:53:05 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6C1BBA361B; Mon, 25 Jul 2016 14:53:05 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 961BF1CE6; Mon, 25 Jul 2016 14:53:05 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PEr4BP054246; Mon, 25 Jul 2016 14:53:04 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PEr4VJ054245; Mon, 25 Jul 2016 14:53:04 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201607251453.u6PEr4VJ054245@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 25 Jul 2016 14:53:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303301 - in stable: 10/usr.bin/bsdiff/bspatch 9/usr.bin/bsdiff/bspatch X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 14:53:05 -0000 Author: delphij Date: Mon Jul 25 14:53:04 2016 New Revision: 303301 URL: https://svnweb.freebsd.org/changeset/base/303301 Log: Fix bspatch heap overflow vulnerability. Obtained from: Chromium Reported by: Lu Tung-Pin Security: FreeBSD-SA-16:25.bspatch Modified: stable/10/usr.bin/bsdiff/bspatch/bspatch.c Changes in other areas also in this revision: Modified: stable/9/usr.bin/bsdiff/bspatch/bspatch.c Modified: stable/10/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- stable/10/usr.bin/bsdiff/bspatch/bspatch.c Mon Jul 25 14:52:12 2016 (r303300) +++ stable/10/usr.bin/bsdiff/bspatch/bspatch.c Mon Jul 25 14:53:04 2016 (r303301) @@ -155,6 +155,10 @@ int main(int argc,char * argv[]) }; /* Sanity-check */ + if ((ctrl[0] < 0) || (ctrl[1] < 0)) + errx(1,"Corrupt patch\n"); + + /* Sanity-check */ if(newpos+ctrl[0]>newsize) errx(1,"Corrupt patch\n"); From owner-svn-src-stable-10@freebsd.org Mon Jul 25 15:04:16 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C54E0BA39A0; Mon, 25 Jul 2016 15:04:16 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97AAF16DB; Mon, 25 Jul 2016 15:04:16 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PF4FAN058147; Mon, 25 Jul 2016 15:04:15 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PF4FFd058145; Mon, 25 Jul 2016 15:04:15 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201607251504.u6PF4FFd058145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 25 Jul 2016 15:04:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303303 - stable/10/usr.bin/mail X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 15:04:16 -0000 Author: pfg Date: Mon Jul 25 15:04:15 2016 New Revision: 303303 URL: https://svnweb.freebsd.org/changeset/base/303303 Log: MFC r302911: mail(1): Avoid closing negative file descriptors. CID: 1008105, 1008106 Modified: stable/10/usr.bin/mail/quit.c stable/10/usr.bin/mail/v7.local.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mail/quit.c ============================================================================== --- stable/10/usr.bin/mail/quit.c Mon Jul 25 15:03:14 2016 (r303302) +++ stable/10/usr.bin/mail/quit.c Mon Jul 25 15:04:15 2016 (r303303) @@ -228,7 +228,8 @@ quit(void) return; } (void)Fclose(obuf); - (void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600)); + if ((fd = open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >= 0) + (void)close(fd); if ((obuf = Fopen(mbox, "r+")) == NULL) { warn("%s", mbox); (void)Fclose(ibuf); Modified: stable/10/usr.bin/mail/v7.local.c ============================================================================== --- stable/10/usr.bin/mail/v7.local.c Mon Jul 25 15:03:14 2016 (r303302) +++ stable/10/usr.bin/mail/v7.local.c Mon Jul 25 15:04:15 2016 (r303303) @@ -68,9 +68,12 @@ findmail(char *user, char *buf, int bufl void demail(void) { + int fd; if (value("keep") != NULL || rm(mailname) < 0) - (void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600)); + if ((fd = open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >= + 0) + (void)close(fd); } /* From owner-svn-src-stable-10@freebsd.org Mon Jul 25 19:18:44 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DDF1BA0FCC; Mon, 25 Jul 2016 19:18:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C916511D0; Mon, 25 Jul 2016 19:18:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PJIhuq051979; Mon, 25 Jul 2016 19:18:43 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PJIh8h051978; Mon, 25 Jul 2016 19:18:43 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607251918.u6PJIh8h051978@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 25 Jul 2016 19:18:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303317 - in stable: 10/share/man/man3 9/share/man/man3 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 19:18:44 -0000 Author: jhb Date: Mon Jul 25 19:18:42 2016 New Revision: 303317 URL: https://svnweb.freebsd.org/changeset/base/303317 Log: MFC 302861: Fix rendering issues. - Use Ta to separate column headers. - Correct width of the 'Code' column in the last table. Modified: stable/10/share/man/man3/siginfo.3 Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/share/man/man3/siginfo.3 Directory Properties: stable/9/share/man/man3/ (props changed) Modified: stable/10/share/man/man3/siginfo.3 ============================================================================== --- stable/10/share/man/man3/siginfo.3 Mon Jul 25 19:16:49 2016 (r303316) +++ stable/10/share/man/man3/siginfo.3 Mon Jul 25 19:18:42 2016 (r303317) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 14, 2012 +.Dd July 14, 2016 .Dt SIGINFO 3 .Os .Sh NAME @@ -54,7 +54,7 @@ In either case, the system returns the i .Vt siginfo_t , which includes the following information: .Bl -column ".Vt union signal" ".Va si_overrun" -.It Sy "Type Member Description" +.It Sy Type Ta Sy Member Ta Sy Description .It Vt int Ta Va si_signo Ta signal number .It Vt int Ta Va si_errno Ta @@ -107,7 +107,7 @@ for use as values of that are signal-specific or non-signal-specific reasons why the signal was generated: .Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED" -.It Sy "Signal Code Reason" +.It Sy Signal Ta Sy Code Ta Sy Reason .It Dv SIGILL Ta Dv ILL_ILLOPC Ta illegal opcode .It Ta Dv ILL_ILLOPN Ta @@ -206,7 +206,7 @@ signal sent by .Pp In addition, the following signal-specific information is available: .Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED" -.It Sy "Signal Member Value" +.It Sy Signal Ta Sy Member Ta Sy Value .It Dv SIGILL Ta Va si_addr Ta address of faulting instruction .It Ta Va si_trapno Ta @@ -240,8 +240,8 @@ or .El .Pp Finally, the following code-specific information is available: -.Bl -column ".Dv SI_QUEUE" ".Va si_overrun" -.It Sy "Code Member Value" +.Bl -column ".Dv SI_ASYNCIO" ".Va si_overrun" +.It Sy Code Ta Sy Member Ta Sy Value .It Dv SI_USER Ta Va si_pid Ta the process ID that sent the signal .It Ta Va si_uid Ta From owner-svn-src-stable-10@freebsd.org Mon Jul 25 23:38:16 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A908DBA5207; Mon, 25 Jul 2016 23:38:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7818818CB; Mon, 25 Jul 2016 23:38:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6PNcFpo055632; Mon, 25 Jul 2016 23:38:15 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6PNcErg055622; Mon, 25 Jul 2016 23:38:14 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607252338.u6PNcErg055622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 25 Jul 2016 23:38:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303325 - in stable: 10/lib/libc/sys 10/share/man/man3 10/share/man/man4 9/lib/libc/sys 9/share/man/man3 9/share/man/man4 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 23:38:16 -0000 Author: jhb Date: Mon Jul 25 23:38:14 2016 New Revision: 303325 URL: https://svnweb.freebsd.org/changeset/base/303325 Log: MFC 302899: Add documentation for the sigevent structure. - Add a sigevent(3) manpage to give a general overview of the sigevent structure and the available notification mechanisms. - Document that AIO requests contain a nested sigevent structure that can be used to request completion notification. - Expand the sigevent details in other manuals to note details such as the extra values stored in a queued signal's information or in a posted kevent. Added: stable/10/share/man/man3/sigevent.3 - copied unchanged from r302899, head/share/man/man3/sigevent.3 Modified: stable/10/lib/libc/sys/aio_fsync.2 stable/10/lib/libc/sys/aio_mlock.2 stable/10/lib/libc/sys/aio_read.2 stable/10/lib/libc/sys/aio_write.2 stable/10/lib/libc/sys/lio_listio.2 stable/10/lib/libc/sys/mq_notify.2 stable/10/lib/libc/sys/timer_create.2 stable/10/share/man/man3/Makefile stable/10/share/man/man4/aio.4 Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Added: stable/9/share/man/man3/sigevent.3 - copied unchanged from r302899, head/share/man/man3/sigevent.3 Modified: stable/9/lib/libc/sys/aio_fsync.2 stable/9/lib/libc/sys/aio_read.2 stable/9/lib/libc/sys/aio_write.2 stable/9/lib/libc/sys/lio_listio.2 stable/9/lib/libc/sys/mq_notify.2 stable/9/lib/libc/sys/timer_create.2 stable/9/share/man/man3/Makefile stable/9/share/man/man4/aio.4 Directory Properties: stable/9/lib/libc/ (props changed) stable/9/lib/libc/sys/ (props changed) stable/9/share/man/man3/ (props changed) stable/9/share/man/man4/ (props changed) Modified: stable/10/lib/libc/sys/aio_fsync.2 ============================================================================== --- stable/10/lib/libc/sys/aio_fsync.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/aio_fsync.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 27, 2013 +.Dd July 15, 2016 .Dt AIO_FSYNC 2 .Os .Sh NAME @@ -71,6 +71,29 @@ while it is in progress. .Pp If the request could not be enqueued (generally due to invalid arguments), the call returns without having enqueued the request. +.Pp +The +.Fa iocb->aio_sigevent +structure can be used to request notification of the request's +completion as described in +.Xr aio 4 . +.Sh RESTRICTIONS +The asynchronous I/O Control Block structure pointed to by +.Fa iocb +must remain valid until the +operation has completed. +For this reason, use of auto (stack) variables +for these objects is discouraged. +.Pp +The asynchronous I/O control buffer +.Fa iocb +should be zeroed before the +.Fn aio_fsync +call to avoid passing bogus context information to the kernel. +.Pp +Modifications of the Asynchronous I/O Control Block structure or the +buffer contents after the request has been enqueued, but before the +request has completed, are not allowed. .Sh RETURN VALUES .Rv -std aio_fsync .Sh ERRORS @@ -80,6 +103,10 @@ system call will fail if: .Bl -tag -width Er .It Bq Er EAGAIN The request was not queued because of system resource limitations. +.It Bq Er EINVAL +The asynchronous notification method in +.Fa iocb->aio_sigevent.sigev_notify +is invalid or not supported. .It Bq Er ENOSYS The .Fn aio_fsync @@ -138,6 +165,7 @@ system calls. .Xr aio_waitcomplete 2 , .Xr aio_write 2 , .Xr fsync 2 , +.Xr sigevent 3 , .Xr siginfo 3 , .Xr aio 4 .Sh STANDARDS Modified: stable/10/lib/libc/sys/aio_mlock.2 ============================================================================== --- stable/10/lib/libc/sys/aio_mlock.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/aio_mlock.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 3, 2013 +.Dd July 15, 2016 .Dt AIO_MLOCK 2 .Os .Sh NAME @@ -64,6 +64,12 @@ If the request could not be enqueued (ge .Xr aio 4 limits), then the call returns without having enqueued the request. +.Pp +The +.Fa iocb->aio_sigevent +structure can be used to request notification of the request's +completion as described in +.Xr aio 4 . .Sh RESTRICTIONS The Asynchronous I/O Control Block structure pointed to by .Fa iocb @@ -92,6 +98,10 @@ system call will fail if: .Bl -tag -width Er .It Bq Er EAGAIN The request was not queued because of system resource limitations. +.It Bq Er EINVAL +The asynchronous notification method in +.Fa iocb->aio_sigevent.sigev_notify +is invalid or not supported. .It Bq Er ENOSYS The .Fn aio_mlock @@ -116,6 +126,7 @@ if the request was explicitly cancelled .Xr aio_error 2 , .Xr aio_return 2 , .Xr mlock 2 , +.Xr sigevent 3 , .Xr aio 4 .Sh PORTABILITY The Modified: stable/10/lib/libc/sys/aio_read.2 ============================================================================== --- stable/10/lib/libc/sys/aio_read.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/aio_read.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 17, 1998 +.Dd July 15, 2016 .Dt AIO_READ 2 .Os .Sh NAME @@ -79,6 +79,12 @@ If the request is successfully enqueued, .Fa iocb->aio_offset can be modified during the request as context, so this value must not be referenced after the request is enqueued. +.Pp +The +.Fa iocb->aio_sigevent +structure can be used to request notification of the request's +completion as described in +.Xr aio 4 . .Sh RESTRICTIONS The Asynchronous I/O Control Block structure pointed to by .Fa iocb @@ -115,6 +121,10 @@ system call will fail if: .Bl -tag -width Er .It Bq Er EAGAIN The request was not queued because of system resource limitations. +.It Bq Er EINVAL +The asynchronous notification method in +.Fa iocb->aio_sigevent.sigev_notify +is invalid or not supported. .It Bq Er ENOSYS The .Fn aio_read @@ -191,6 +201,7 @@ would be invalid. .Xr aio_suspend 2 , .Xr aio_waitcomplete 2 , .Xr aio_write 2 , +.Xr sigevent 3 , .Xr siginfo 3 , .Xr aio 4 .Sh STANDARDS Modified: stable/10/lib/libc/sys/aio_write.2 ============================================================================== --- stable/10/lib/libc/sys/aio_write.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/aio_write.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 2, 1999 +.Dd July 15, 2016 .Dt AIO_WRITE 2 .Os .Sh NAME @@ -85,6 +85,12 @@ If the request is successfully enqueued, .Fa iocb->aio_offset can be modified during the request as context, so this value must not be referenced after the request is enqueued. +.Pp +The +.Fa iocb->aio_sigevent +structure can be used to request notification of the request's +completion as described in +.Xr aio 4 . .Sh RESTRICTIONS The Asynchronous I/O Control Block structure pointed to by .Fa iocb @@ -119,6 +125,10 @@ system call will fail if: .Bl -tag -width Er .It Bq Er EAGAIN The request was not queued because of system resource limitations. +.It Bq Er EINVAL +The asynchronous notification method in +.Fa iocb->aio_sigevent.sigev_notify +is invalid or not supported. .It Bq Er ENOSYS The .Fn aio_write @@ -186,6 +196,7 @@ would be invalid. .Xr aio_return 2 , .Xr aio_suspend 2 , .Xr aio_waitcomplete 2 , +.Xr sigevent 3 , .Xr siginfo 3 , .Xr aio 4 .Sh STANDARDS Modified: stable/10/lib/libc/sys/lio_listio.2 ============================================================================== --- stable/10/lib/libc/sys/lio_listio.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/lio_listio.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2003 +.Dd July 15, 2016 .Dt LIO_LISTIO 2 .Os .Sh NAME @@ -83,14 +83,52 @@ If .Fa mode is .Dv LIO_NOWAIT , -the requests are processed asynchronously, and the signal specified by .Fa sig -is sent when all operations have completed. +can be used to request asynchronous notification when all operations have +completed. If .Fa sig is .Dv NULL , -the calling process is not notified of I/O completion. +no notification is sent. +.Pp +For +.Dv SIGEV_KEVENT +notifications, +the posted kevent will contain: +.Bl -column ".Va filter" +.It Sy Member Ta Sy Value +.It Va ident Ta Fa list +.It Va filter Ta Dv EVFILT_LIO +.It Va udata Ta +value stored in +.Fa sig->sigev_value +.El +.Pp +For +.Dv SIGEV_SIGNO +and +.Dv SIGEV_THREAD_ID +notifications, +the information for the queued signal will include +.Dv SI_ASYNCIO +in the +.Va si_code +field and the value stored in +.Fa sig->sigev_value +in the +.Va si_value +field. +.Pp +For +.Dv SIGEV_THREAD +notifications, +the value stored in +.Fa sig->sigev_value +is passed to the +.Fa sig->sigev_notify_function +as described in +.Xr sigevent 3 . .Pp The order in which the requests are carried out is not specified; in particular, there is no guarantee that they will be executed in @@ -136,6 +174,10 @@ or .Fa nent is greater than .Dv AIO_LISTIO_MAX . +.It Bq Er EINVAL +The asynchronous notification method in +.Fa sig->sigev_notify +is invalid or not supported. .It Bq Er EINTR A signal interrupted the system call before it could be completed. .It Bq Er EIO @@ -166,6 +208,7 @@ structure individually by calling .Xr aio_write 2 , .Xr read 2 , .Xr write 2 , +.Xr sigevent 3 , .Xr siginfo 3 , .Xr aio 4 .Sh STANDARDS Modified: stable/10/lib/libc/sys/mq_notify.2 ============================================================================== --- stable/10/lib/libc/sys/mq_notify.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/mq_notify.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2005 +.Dd July 15, 2016 .Dt MQ_NOTIFY 2 .Os .Sh NAME @@ -77,18 +77,27 @@ is .Dv SIGEV_NONE , then no signal will be posted, but the error status and the return status for the operation will be set appropriately. -If -.Fa notification->sigev_notify -is -.Dv SIGEV_SIGNAL , -then the signal specified in +For +.Dv SIGEV_SIGNO +and +.Dv SIGEV_THREAD_ID +notifications, +the signal specified in .Fa notification->sigev_signo -will be sent to the process. -The signal will be queued to the process and the value specified in +will be sent to the calling process +.Pq Dv SIGEV_SIGNO +or to the thread whose LWP ID is +.Fa notification->sigev_notify_thread_id +.Pq Dv SIGEV_THREAD_ID . +The information for the queued signal will include: +.Bl -column ".Va si_value" +.It Sy Member Ta Sy Value +.It Va si_code Ta Dv SI_MESGQ +.It Va si_value Ta +the value stored in .Fa notification->sigev_value -will be the -.Va si_value -component of the generated signal. +.It Va si_mqd Ta Fa mqdes +.El .Pp If .Fa notification @@ -123,11 +132,16 @@ The argument is not a valid message queue descriptor. .It Bq Er EBUSY Process is already registered for notification by the message queue. +.It Bq Er EINVAL +The asynchronous notification method in +.Fa notification->sigev_notify +is invalid or not supported. .El .Sh SEE ALSO .Xr mq_open 2 , .Xr mq_send 2 , .Xr mq_timedsend 2 , +.Xr sigevent 3 , .Xr siginfo 3 .Sh STANDARDS The Modified: stable/10/lib/libc/sys/timer_create.2 ============================================================================== --- stable/10/lib/libc/sys/timer_create.2 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/lib/libc/sys/timer_create.2 Mon Jul 25 23:38:14 2016 (r303325) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2009 +.Dd July 15, 2016 .Dt TIMER_CREATE 2 .Os .Sh NAME @@ -74,6 +74,36 @@ structure. This structure, allocated by the application, defines the asynchronous notification to occur when the timer expires. +.Pp +If +.Fa evp->sigev_notify +is +.Dv SIGEV_SIGNO +or +.Dv SIGEV_THREAD_ID , +the signal specified in +.Fa evp->sigev_signo +will be sent to the calling process +.Pq Dv SIGEV_SIGNO +or to the thread whose LWP ID is +.Fa evp->sigev_notify_thread_id +.Pq Dv SIGEV_THREAD_ID . +The information for the queued signal will include: +.Bl -column ".Va si_value" +.It Sy Member Ta Sy Value +.It Va si_code Ta Dv SI_TIMER +.It Va si_value Ta +the value stored in +.Fa evp->sigev_value +.It Va si_timerid Ta timer ID +.It Va si_overrun Ta timer overrun count +.It Va si_errno Ta +If timer overrun is +.Brq Dv DELAYTIMER_MAX , +an error code defined in +.In errno.h +.El +.Pp If the .Fa evp argument is @@ -88,12 +118,14 @@ member having the value .Dv SIGEV_SIGNAL , the .Va sigev_signo -having a default signal number, and the +having a default signal number +.Pq Dv SIGALRM , +and the .Va sigev_value member having the value of the timer ID. .Pp -The implementations supports a +This implementation supports a .Fa clock_id of .Dv CLOCK_REALTIME @@ -144,6 +176,8 @@ The calling process has already created this implementation. .It Bq Er EINVAL The specified clock ID is not supported. +.It Bq Er EINVAL +The specified asynchronous notification method is not supported. .It Bq Er EFAULT Any arguments point outside the allocated address space or there is a memory protection fault. @@ -152,6 +186,7 @@ memory protection fault. .Xr clock_getres 2 , .Xr timer_delete 2 , .Xr timer_getoverrun 2 , +.Xr sigevent 3 , .Xr siginfo 3 .Sh STANDARDS The Modified: stable/10/share/man/man3/Makefile ============================================================================== --- stable/10/share/man/man3/Makefile Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/share/man/man3/Makefile Mon Jul 25 23:38:14 2016 (r303325) @@ -13,6 +13,7 @@ MAN= assert.3 \ offsetof.3 \ ${PTHREAD_MAN} \ queue.3 \ + sigevent.3 \ siginfo.3 \ stdarg.3 \ sysexits.3 \ Copied: stable/10/share/man/man3/sigevent.3 (from r302899, head/share/man/man3/sigevent.3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/share/man/man3/sigevent.3 Mon Jul 25 23:38:14 2016 (r303325, copy of r302899, head/share/man/man3/sigevent.3) @@ -0,0 +1,127 @@ +.\" -*- nroff -*- +.\" +.\" Copyright (c) 2016 John H. Baldwin +.\" 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 15, 2016 +.Dt SIGEVENT 3 +.Os +.Sh NAME +.Nm sigevent +.Nd "asynchronous event notification" +.Sh SYNOPSIS +.In signal.h +.Sh DESCRIPTION +Some operations permit threads to request asychronous notification of events +via a +.Vt struct sigevent +structure. +This structure contains several fields that describe the requested notification: +.Bl -column ".Vt void (*)(union sigval)" ".Va sigev_notify_kevent_flags" +.It Sy Type Ta Sy Member Ta Sy Description +.It Vt int Ta sigev_notify Ta notification method +.It Vt int Ta sigev_signo Ta signal number +.It Vt union sigval Ta sigev_value Ta signal value +.It Vt int Ta sigev_notify_kqueue Ta +.Xr kqueue 2 +file descriptor +.It Vt unsigned short Ta sigev_notify_kevent_flags Ta kevent flags +.It Vt lwpid_t Ta sigev_notify_thread_id Ta LWP ID +.It Vt void (*)(union sigval) Ta sigev_notify_function Ta +callback function pointer +.It Vt pthread_attr_t * Ta sigev_notify_attributes Ta +callback thread attributes +.El +.Pp +The +.Va sigev_notify +field specifies the notification method used when the event triggers: +.Bl -tag -width ".Dv SIGEV_THREAD_ID" +.It Dv SIGEV_NONE +No notification is sent. +.It Dv SIGEV_SIGNAL +The signal +.Va sigev_signo +is queued as a real-time signal to the calling process. +The value stored in +.Va sigev_value +will be present in the +.Va si_value +of the +.Vt siginfo_t +structure of the queued signal. +.It Dv SIGEV_THREAD +The notification function in +.Va sigev_notify_function +is called in a separate thread context. +The thread is created with the attributes specified in +.Va *sigev_notify_attributes . +The value stored in +.Va sigev_value +is passed as the sole argument to +.Va sigev_notify_function . +If +.Va sigev_notify_attributes +is +.Dv NULL , +the thread is created with default attributes. +.It Dv SIGEV_KEVENT +A new kevent is posted to the kqueue +.Va sigev_notify_kqueue . +The +.Va udata +member of the kevent structure contains the value stored in +.Va sigev_value . +The meaning of other fields in the kevent are specific to the type of triggered +event. +.It Dv SIGEV_THREAD_ID +The signal +.Va sigev_signo +is queued to the thread whose LWP ID is +.Va sigev_notify_thread_id . +The value stored in +.Va sigev_value +will be present in the +.Va si_value +of the +.Vt siginfo_t +structure of the queued signal. +.El +.Sh NOTES +Note that programs wishing to use +.Dv SIGEV_THREAD +notifications must link against the +.Lb librt . +.Sh SEE ALSO +.Xr aio_read 2 , +.Xr mq_notify 2 , +.Xr timer_create 2 , +.Xr siginfo 3 +.Sh STANDARDS +The +.Vt struct sigevent +type conforms to +.St -p1003.1-2004 . Modified: stable/10/share/man/man4/aio.4 ============================================================================== --- stable/10/share/man/man4/aio.4 Mon Jul 25 23:37:47 2016 (r303324) +++ stable/10/share/man/man4/aio.4 Mon Jul 25 23:38:14 2016 (r303325) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 24, 2002 +.Dd July 15, 2016 .Dt AIO 4 .Os .Sh NAME @@ -45,6 +45,54 @@ The facility provides system calls for asynchronous I/O. It is available both as a kernel option for static inclusion and as a dynamic kernel module. +.Pp +Asynchronous I/O control buffers should be zeroed before initializing +individual fields. +This ensures all fields are initialized. +.Pp +All asynchronous I/O control buffers contain a +.Vt sigevent +structure in the +.Va aio_sigevent +field which can be used to request notification when an operation completes. +.Pp +For +.Dv SIGEV_KEVENT +notifications, +the posted kevent will contain: +.Bl -column ".Va filter" +.It Sy Member Ta Sy Value +.It Va ident Ta asynchronous I/O control buffer pointer +.It Va filter Ta Dv EVFILT_AIO +.It Va udata Ta +value stored in +.Va aio_sigevent.sigev_value +.El +.Pp +For +.Dv SIGEV_SIGNO +and +.Dv SIGEV_THREAD_ID +notifications, +the information for the queued signal will include +.Dv SI_ASYNCIO +in the +.Va si_code +field and the value stored in +.Va sigevent.sigev_value +in the +.Va si_value +field. +.Pp +For +.Dv SIGEV_THREAD +notifications, +the value stored in +.Va aio_sigevent.sigev_value +is passed to the +.Va aio_sigevent.sigev_notify_function +as described in +.Xr sigevent 3 . .Sh SEE ALSO .Xr aio_cancel 2 , .Xr aio_error 2 , @@ -54,6 +102,7 @@ dynamic kernel module. .Xr aio_waitcomplete 2 , .Xr aio_write 2 , .Xr lio_listio 2 , +.Xr sigevent 3 , .Xr config 8 , .Xr kldload 8 , .Xr kldunload 8 From owner-svn-src-stable-10@freebsd.org Wed Jul 27 06:31:41 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0964BA6C1D; Wed, 27 Jul 2016 06:31:41 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 709A11346; Wed, 27 Jul 2016 06:31:41 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6R6VeP8070852; Wed, 27 Jul 2016 06:31:40 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6R6Venc070851; Wed, 27 Jul 2016 06:31:40 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201607270631.u6R6Venc070851@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Wed, 27 Jul 2016 06:31:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303365 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 06:31:41 -0000 Author: jch Date: Wed Jul 27 06:31:40 2016 New Revision: 303365 URL: https://svnweb.freebsd.org/changeset/base/303365 Log: MFC r273014: A connection in TIME_WAIT state before calling close() actually did not received any RST packet. Do not set error to ECONNRESET in this case. Differential Revision: https://reviews.freebsd.org/D879 Reviewed by: rpaulo, adrian Approved by: jhb (mentor) Sponsored by: Verisign, Inc. Modified: stable/10/sys/netinet/tcp_usrreq.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/10/sys/netinet/tcp_usrreq.c Wed Jul 27 06:29:41 2016 (r303364) +++ stable/10/sys/netinet/tcp_usrreq.c Wed Jul 27 06:31:40 2016 (r303365) @@ -625,7 +625,9 @@ tcp_usr_disconnect(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_TIMEWAIT) + goto out; + if (inp->inp_flags & INP_DROPPED) { error = ECONNRESET; goto out; } From owner-svn-src-stable-10@freebsd.org Wed Jul 27 07:51:59 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B4FC3BA65F6; Wed, 27 Jul 2016 07:51:59 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 762EB12E8; Wed, 27 Jul 2016 07:51:59 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6R7pwsh001014; Wed, 27 Jul 2016 07:51:58 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6R7pwEu001011; Wed, 27 Jul 2016 07:51:58 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201607270751.u6R7pwEu001011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Wed, 27 Jul 2016 07:51:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303371 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 07:51:59 -0000 Author: jch Date: Wed Jul 27 07:51:58 2016 New Revision: 303371 URL: https://svnweb.freebsd.org/changeset/base/303371 Log: MFC r271119, r272081: r271119: In tcp_input(), don't acquire the pcbinfo global write lock for SYN packets targeting a listening socket. Permit to reduce TCP input processing starvation in context of high SYN load (e.g. short-lived TCP connections or SYN flood). Submitted by: Julien Charbon Reviewed by: adrian, hiren, jhb, Mike Bentkofsky r272081: Catch up with r271119. Modified: stable/10/sys/netinet/tcp_input.c stable/10/sys/netinet/tcp_syncache.c stable/10/sys/netinet/toecore.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_input.c ============================================================================== --- stable/10/sys/netinet/tcp_input.c Wed Jul 27 07:36:54 2016 (r303370) +++ stable/10/sys/netinet/tcp_input.c Wed Jul 27 07:51:58 2016 (r303371) @@ -751,12 +751,12 @@ tcp_input(struct mbuf *m, int off0) /* * Locate pcb for segment; if we're likely to add or remove a - * connection then first acquire pcbinfo lock. There are two cases + * connection then first acquire pcbinfo lock. There are three cases * where we might discover later we need a write lock despite the - * flags: ACKs moving a connection out of the syncache, and ACKs for - * a connection in TIMEWAIT. + * flags: ACKs moving a connection out of the syncache, ACKs for a + * connection in TIMEWAIT and SYNs not targeting a listening socket. */ - if ((thflags & (TH_SYN | TH_FIN | TH_RST)) != 0) { + if ((thflags & (TH_FIN | TH_RST)) != 0) { INP_INFO_WLOCK(&V_tcbinfo); ti_locked = TI_WLOCKED; } else @@ -983,10 +983,12 @@ relocked: * now be in TIMEWAIT. */ #ifdef INVARIANTS - if ((thflags & (TH_SYN | TH_FIN | TH_RST)) != 0) + if ((thflags & (TH_FIN | TH_RST)) != 0) INP_INFO_WLOCK_ASSERT(&V_tcbinfo); #endif - if (tp->t_state != TCPS_ESTABLISHED) { + if (!((tp->t_state == TCPS_ESTABLISHED && (thflags & TH_SYN) == 0) || + (tp->t_state == TCPS_LISTEN && (thflags & TH_SYN) && + !(tp->t_flags & TF_FASTOPEN)))) { if (ti_locked == TI_UNLOCKED) { if (INP_INFO_TRY_WLOCK(&V_tcbinfo) == 0) { in_pcbref(inp); @@ -1027,17 +1029,13 @@ relocked: /* * When the socket is accepting connections (the INPCB is in LISTEN * state) we look into the SYN cache if this is a new connection - * attempt or the completion of a previous one. Because listen - * sockets are never in TCPS_ESTABLISHED, the V_tcbinfo lock will be - * held in this case. + * attempt or the completion of a previous one. */ if (so->so_options & SO_ACCEPTCONN) { struct in_conninfo inc; KASSERT(tp->t_state == TCPS_LISTEN, ("%s: so accepting but " "tp not listening", __func__)); - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); - bzero(&inc, sizeof(inc)); #ifdef INET6 if (isipv6) { @@ -1060,6 +1058,8 @@ relocked: * socket appended to the listen queue in SYN_RECEIVED state. */ if ((thflags & (TH_RST|TH_ACK|TH_SYN)) == TH_ACK) { + + INP_INFO_WLOCK_ASSERT(&V_tcbinfo); /* * Parse the TCP options here because * syncookies need access to the reflected @@ -1348,8 +1348,12 @@ new_tfo_socket: #endif /* * Entry added to syncache and mbuf consumed. - * Everything already unlocked by syncache_add(). + * Only the listen socket is unlocked by syncache_add(). */ + if (ti_locked == TI_WLOCKED) { + INP_INFO_WUNLOCK(&V_tcbinfo); + ti_locked = TI_UNLOCKED; + } INP_INFO_UNLOCK_ASSERT(&V_tcbinfo); return; } else if (tp->t_state == TCPS_LISTEN) { Modified: stable/10/sys/netinet/tcp_syncache.c ============================================================================== --- stable/10/sys/netinet/tcp_syncache.c Wed Jul 27 07:36:54 2016 (r303370) +++ stable/10/sys/netinet/tcp_syncache.c Wed Jul 27 07:51:58 2016 (r303371) @@ -1107,7 +1107,7 @@ syncache_tfo_expand(struct syncache *sc, * Global TCP locks are held because we manipulate the PCB lists * and create a new socket. */ - INP_INFO_RLOCK_ASSERT(&V_tcbinfo); + INP_INFO_WLOCK_ASSERT(&V_tcbinfo); pending_counter = intotcpcb(sotoinpcb(*lsop))->t_tfo_pending; *lsop = syncache_socket(sc, *lsop, m); @@ -1175,7 +1175,6 @@ syncache_add(struct in_conninfo *inc, st int tfo_response_cookie_valid = 0; #endif - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); /* listen socket */ KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN, ("%s: unexpected tcp flags", __func__)); @@ -1229,21 +1228,15 @@ syncache_add(struct in_conninfo *inc, st #ifdef MAC if (mac_syncache_init(&maclabel) != 0) { INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); goto done; } else mac_syncache_create(maclabel, inp); #endif #ifdef TCP_RFC7413 - if (!tfo_cookie_valid) { - INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); - } -#else - INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); + if (!tfo_cookie_valid) #endif - + INP_WUNLOCK(inp); + /* * Remember the IP options, if any. */ @@ -1272,10 +1265,8 @@ syncache_add(struct in_conninfo *inc, st SCH_LOCK_ASSERT(sch); if (sc != NULL) { #ifdef TCP_RFC7413 - if (tfo_cookie_valid) { + if (tfo_cookie_valid) INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); - } #endif TCPSTAT_INC(tcps_sc_dupsyn); if (ipopts) { Modified: stable/10/sys/netinet/toecore.c ============================================================================== --- stable/10/sys/netinet/toecore.c Wed Jul 27 07:36:54 2016 (r303370) +++ stable/10/sys/netinet/toecore.c Wed Jul 27 07:51:58 2016 (r303371) @@ -328,7 +328,6 @@ toe_syncache_add(struct in_conninfo *inc { struct socket *lso = inp->inp_socket; - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx); From owner-svn-src-stable-10@freebsd.org Wed Jul 27 08:53:12 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 850A7BA5E36; Wed, 27 Jul 2016 08:53:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3F3991B37; Wed, 27 Jul 2016 08:53:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6R8rBW0025706; Wed, 27 Jul 2016 08:53:11 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6R8rBoZ025703; Wed, 27 Jul 2016 08:53:11 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607270853.u6R8rBoZ025703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 27 Jul 2016 08:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303376 - stable/10/sys/ufs/ufs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 08:53:12 -0000 Author: kib Date: Wed Jul 27 08:53:11 2016 New Revision: 303376 URL: https://svnweb.freebsd.org/changeset/base/303376 Log: MFC r303090: Ensure that the UFS directory vnode' vm_object is properly sized before UFS_BALLOC() is called. Modified: stable/10/sys/ufs/ufs/ufs_lookup.c stable/10/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ufs/ufs/ufs_lookup.c ============================================================================== --- stable/10/sys/ufs/ufs/ufs_lookup.c Wed Jul 27 08:47:24 2016 (r303375) +++ stable/10/sys/ufs/ufs/ufs_lookup.c Wed Jul 27 08:53:11 2016 (r303376) @@ -881,6 +881,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdir struct buf *bp; u_int dsize; struct direct *ep, *nep; + u_int64_t old_isize; int error, ret, blkoff, loc, spacefree, flags, namlen; char *dirbuf; @@ -909,16 +910,18 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdir return (error); } #endif + old_isize = dp->i_size; + vnode_pager_setsize(dvp, (u_long)dp->i_offset + DIRBLKSIZ); if ((error = UFS_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ, cr, flags, &bp)) != 0) { if (DOINGSOFTDEP(dvp) && newdirbp != NULL) bdwrite(newdirbp); + vnode_pager_setsize(dvp, (u_long)old_isize); return (error); } dp->i_size = dp->i_offset + DIRBLKSIZ; DIP_SET(dp, i_size, dp->i_size); dp->i_flag |= IN_CHANGE | IN_UPDATE; - vnode_pager_setsize(dvp, (u_long)dp->i_size); dirp->d_reclen = DIRBLKSIZ; blkoff = dp->i_offset & (VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1); Modified: stable/10/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/10/sys/ufs/ufs/ufs_vnops.c Wed Jul 27 08:47:24 2016 (r303375) +++ stable/10/sys/ufs/ufs/ufs_vnops.c Wed Jul 27 08:53:11 2016 (r303376) @@ -1914,13 +1914,13 @@ ufs_mkdir(ap) dirtemplate = *dtp; dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; + vnode_pager_setsize(tvp, DIRBLKSIZ); if ((error = UFS_BALLOC(tvp, (off_t)0, DIRBLKSIZ, cnp->cn_cred, BA_CLRBUF, &bp)) != 0) goto bad; ip->i_size = DIRBLKSIZ; DIP_SET(ip, i_size, DIRBLKSIZ); ip->i_flag |= IN_CHANGE | IN_UPDATE; - vnode_pager_setsize(tvp, (u_long)ip->i_size); bcopy((caddr_t)&dirtemplate, (caddr_t)bp->b_data, sizeof dirtemplate); if (DOINGSOFTDEP(tvp)) { /* From owner-svn-src-stable-10@freebsd.org Wed Jul 27 13:53:16 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6671BA62B4; Wed, 27 Jul 2016 13:53:16 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53B0B1710; Wed, 27 Jul 2016 13:53:16 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6RDrFho037251; Wed, 27 Jul 2016 13:53:15 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6RDrFd4037250; Wed, 27 Jul 2016 13:53:15 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201607271353.u6RDrFd4037250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Wed, 27 Jul 2016 13:53:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303389 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 13:53:16 -0000 Author: jch Date: Wed Jul 27 13:53:15 2016 New Revision: 303389 URL: https://svnweb.freebsd.org/changeset/base/303389 Log: MFC r286873: Make clear that TIME_WAIT timeout expiration is managed solely by tcp_tw_2msl_scan(). Sponsored by: Verisign, Inc. Modified: stable/10/sys/netinet/tcp_timer.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_timer.c ============================================================================== --- stable/10/sys/netinet/tcp_timer.c Wed Jul 27 11:54:24 2016 (r303388) +++ stable/10/sys/netinet/tcp_timer.c Wed Jul 27 13:53:15 2016 (r303389) @@ -292,21 +292,29 @@ tcp_timer_2msl(void *xtp) /* * 2 MSL timeout in shutdown went off. If we're closed but * still waiting for peer to close and connection has been idle - * too long, or if 2MSL time is up from TIME_WAIT, delete connection - * control block. Otherwise, check again in a bit. + * too long delete connection control block. Otherwise, check + * again in a bit. + * + * If in TIME_WAIT state just ignore as this timeout is handled in + * tcp_tw_2msl_scan(). * * If fastrecycle of FIN_WAIT_2, in FIN_WAIT_2 and receiver has closed, * there's no point in hanging onto FIN_WAIT_2 socket. Just close it. * Ignore fact that there were recent incoming segments. */ + if ((inp->inp_flags & INP_TIMEWAIT) != 0) { + INP_WUNLOCK(inp); + INP_INFO_WUNLOCK(&V_tcbinfo); + CURVNET_RESTORE(); + return; + } if (tcp_fast_finwait2_recycle && tp->t_state == TCPS_FIN_WAIT_2 && tp->t_inpcb && tp->t_inpcb->inp_socket && (tp->t_inpcb->inp_socket->so_rcv.sb_state & SBS_CANTRCVMORE)) { TCPSTAT_INC(tcps_finwait2_drops); tp = tcp_close(tp); } else { - if (tp->t_state != TCPS_TIME_WAIT && - ticks - tp->t_rcvtime <= TP_MAXIDLE(tp)) { + if (ticks - tp->t_rcvtime <= TP_MAXIDLE(tp)) { if (!callout_reset(&tp->t_timers->tt_2msl, TP_KEEPINTVL(tp), tcp_timer_2msl, tp)) { tp->t_timers->tt_flags &= ~TT_2MSL_RST; From owner-svn-src-stable-10@freebsd.org Wed Jul 27 16:27:42 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91F53BA6E77; Wed, 27 Jul 2016 16:27:42 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B0971784; Wed, 27 Jul 2016 16:27:42 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6RGRfp4096295; Wed, 27 Jul 2016 16:27:41 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6RGRfAD096294; Wed, 27 Jul 2016 16:27:41 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201607271627.u6RGRfAD096294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Wed, 27 Jul 2016 16:27:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303395 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 16:27:42 -0000 Author: julian Date: Wed Jul 27 16:27:41 2016 New Revision: 303395 URL: https://svnweb.freebsd.org/changeset/base/303395 Log: MFH: r303287 Split MAKE_SYSENT into two parts so that the initializer part can be used separately if one wants to embed the sysent into a larger structure. Modified: stable/10/sys/sys/sysent.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/sysent.h ============================================================================== --- stable/10/sys/sys/sysent.h Wed Jul 27 16:01:44 2016 (r303394) +++ stable/10/sys/sys/sysent.h Wed Jul 27 16:27:41 2016 (r303395) @@ -173,13 +173,21 @@ struct syscall_module_data { struct sysent old_sysent; /* old sysent */ }; -#define MAKE_SYSENT(syscallname) \ -static struct sysent syscallname##_sysent = { \ - (sizeof(struct syscallname ## _args ) \ +/* separate initialization vector so it can be used in a substructure */ +#define SYSENT_INIT_VALS(_syscallname) { \ + .sy_narg = (sizeof(struct _syscallname ## _args ) \ / sizeof(register_t)), \ - (sy_call_t *)& sys_##syscallname, \ - SYS_AUE_##syscallname \ -} + .sy_call = (sy_call_t *)&sys_##_syscallname, \ + .sy_auevent = SYS_AUE_##_syscallname, \ + .sy_systrace_args_func = NULL, \ + .sy_entry = 0, \ + .sy_return = 0, \ + .sy_flags = 0, \ + .sy_thrcnt = 0 \ +} + +#define MAKE_SYSENT(syscallname) \ +static struct sysent syscallname##_sysent = SYSENT_INIT_VALS(syscallname); #define MAKE_SYSENT_COMPAT(syscallname) \ static struct sysent syscallname##_sysent = { \ From owner-svn-src-stable-10@freebsd.org Wed Jul 27 17:55:41 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4222EBA67D3; Wed, 27 Jul 2016 17:55:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 07D31160A; Wed, 27 Jul 2016 17:55:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6RHteLf030590; Wed, 27 Jul 2016 17:55:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6RHtekp030589; Wed, 27 Jul 2016 17:55:40 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607271755.u6RHtekp030589@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 27 Jul 2016 17:55:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303403 - in stable: 10/usr.sbin/crashinfo 9/usr.sbin/crashinfo X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 17:55:41 -0000 Author: jhb Date: Wed Jul 27 17:55:40 2016 New Revision: 303403 URL: https://svnweb.freebsd.org/changeset/base/303403 Log: MFC 303109: Update crashinfo to work with newer gdb from ports. If gdb from ports is installed, use it instead of the base system gdb to extract variables from a kernel. Note that base gdb and ports gdb do not support the same options for invoking a single command in batch mode, so a wrapper shell function is used. In addition, prefer kgdb from ports when generating a backtrace if present. PR: 193335 Modified: stable/10/usr.sbin/crashinfo/crashinfo.sh Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/usr.sbin/crashinfo/crashinfo.sh Directory Properties: stable/9/usr.sbin/crashinfo/ (props changed) Modified: stable/10/usr.sbin/crashinfo/crashinfo.sh ============================================================================== --- stable/10/usr.sbin/crashinfo/crashinfo.sh Wed Jul 27 17:55:14 2016 (r303402) +++ stable/10/usr.sbin/crashinfo/crashinfo.sh Wed Jul 27 17:55:40 2016 (r303403) @@ -35,6 +35,22 @@ usage() exit 1 } +# Run a single gdb command against a kernel file in batch mode. +# The kernel file is specified as the first argument and the command +# is given in the remaining arguments. +gdb_command() +{ + local k + + k=$1 ; shift + + if [ -x /usr/local/bin/gdb ]; then + /usr/local/bin/gdb -batch -ex "$@" $k + else + echo -e "$@" | /usr/bin/gdb -x /dev/stdin -batch $k + fi +} + find_kernel() { local ivers k kvers @@ -55,8 +71,8 @@ find_kernel() # Look for a matching kernel version. for k in `sysctl -n kern.bootfile` $(ls -t /boot/*/kernel); do - kvers=$(echo 'printf " Version String: %s", version' | \ - gdb -x /dev/stdin -batch $k 2>/dev/null) + kvers=$(gdb_command $k 'printf " Version String: %s", version' \ + 2>/dev/null) if [ "$ivers" = "$kvers" ]; then KERNEL=$k break @@ -151,11 +167,10 @@ echo "Writing crash summary to $FILE." umask 077 # Simulate uname -ostype=$(echo -e printf '"%s", ostype' | gdb -x /dev/stdin -batch $KERNEL) -osrelease=$(echo -e printf '"%s", osrelease' | gdb -x /dev/stdin -batch $KERNEL) -version=$(echo -e printf '"%s", version' | gdb -x /dev/stdin -batch $KERNEL | \ - tr '\t\n' ' ') -machine=$(echo -e printf '"%s", machine' | gdb -x /dev/stdin -batch $KERNEL) +ostype=$(gdb_command $KERNEL 'printf "%s", ostype') +osrelease=$(gdb_command $KERNEL 'printf "%s", osrelease') +version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' ' ') +machine=$(gdb_command $KERNEL 'printf "%s", machine') exec > $FILE 2>&1 @@ -174,7 +189,11 @@ file=`mktemp /tmp/crashinfo.XXXXXX` if [ $? -eq 0 ]; then echo "bt" >> $file echo "quit" >> $file - kgdb $KERNEL $VMCORE < $file + if [ -x /usr/local/bin/kgdb ]; then + /usr/local/bin/kgdb $KERNEL $VMCORE < $file + else + kgdb $KERNEL $VMCORE < $file + fi rm -f $file echo fi From owner-svn-src-stable-10@freebsd.org Wed Jul 27 19:40:26 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFAF6BA6603; Wed, 27 Jul 2016 19:40:26 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 73AFF1247; Wed, 27 Jul 2016 19:40:26 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6RJePnD067969; Wed, 27 Jul 2016 19:40:25 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6RJePgL067968; Wed, 27 Jul 2016 19:40:25 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201607271940.u6RJePgL067968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 27 Jul 2016 19:40:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303408 - stable/10/etc/ntp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2016 19:40:26 -0000 Author: cy Date: Wed Jul 27 19:40:25 2016 New Revision: 303408 URL: https://svnweb.freebsd.org/changeset/base/303408 Log: MFC r303160. Update leap-seconds to leap-seconds.3676752000. As per https://datacenter.iers.org/web/guest/eop/-/somos/5Rgv/latest/16: UTC TIME STEP on the 1st of January 2017 A positive leap second will be introduced at the end of December 2016. The sequence of dates of the UTC second markers will be: 2016 December 31, 23h 59m 59s 2016 December 31, 23h 59m 60s 2017 January 1, 0h 0m 0s The difference between UTC and the International Atomic Time TAI is: from 2015 July 1, 0h UTC, to 2017 January 1 0h UTC : UTC-TAI = - 36s from 2017 January 1, 0h UTC, until further notice : UTC-TAI = - 37s Obtained from: ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.3676752000 See also: https://www.iers.org/SharedDocs/News/EN/BulletinC.html https://datacenter.iers.org/web/guest/eop/-/somos/5Rgv/latest/16 Relnotes: yes Modified: stable/10/etc/ntp/leap-seconds Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/ntp/leap-seconds ============================================================================== --- stable/10/etc/ntp/leap-seconds Wed Jul 27 19:39:25 2016 (r303407) +++ stable/10/etc/ntp/leap-seconds Wed Jul 27 19:40:25 2016 (r303408) @@ -130,7 +130,7 @@ # Washington, DC # jeffrey.prillaman@usno.navy.mil # -# Last Update of leap second values: 11 Jan 2016 +# Last Update of leap second values: 6 Jul 2016 # # The following line shows this last update date in NTP timestamp # format. This is the date on which the most recent change to @@ -138,7 +138,7 @@ # be identified by the unique pair of characters in the first two # columns as shown below. # -#$ 3661459200 +#$ 3676752000 # # The data in this file will be updated periodically as new leap # seconds are announced. In addition to being entered on the line @@ -170,10 +170,10 @@ # current -- the update time stamp, the data and the name of the file # will not change. # -# Updated through IERS Bulletin C 51 -# File expires on: 1 Dec 2016 +# Updated through IERS Bulletin C 52 +# File expires on: 1 Jun 2017 # -#@ 3689539200 +#@ 3705264000 # 2272060800 10 # 1 Jan 1972 2287785600 11 # 1 Jul 1972 @@ -202,6 +202,7 @@ 3439756800 34 # 1 Jan 2009 3550089600 35 # 1 Jul 2012 3644697600 36 # 1 Jul 2015 +3692217600 37 # 1 Jan 2017 # # the following special comment contains the # hash value of the data in this file computed @@ -217,5 +218,5 @@ # the hash line is also ignored in the # computation. # -#h 63b4df04 0907d94f 2dadb7a1 684f7767 2a372421 +#h 63f8fea8 587c099d abcf130a ad525eae 3e105052 # From owner-svn-src-stable-10@freebsd.org Thu Jul 28 11:51:21 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 986B4BA5F5D; Thu, 28 Jul 2016 11:51:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B8F31C6A; Thu, 28 Jul 2016 11:51:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6SBpK2i030385; Thu, 28 Jul 2016 11:51:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6SBpKFK030382; Thu, 28 Jul 2016 11:51:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607281151.u6SBpKFK030382@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 28 Jul 2016 11:51:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303433 - in stable/10/sys: dev/pty kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2016 11:51:21 -0000 Author: kib Date: Thu Jul 28 11:51:20 2016 New Revision: 303433 URL: https://svnweb.freebsd.org/changeset/base/303433 Log: MFC r303151: Provide counter_warning(9) KPI. MFC r303155: Hide counted_warning(9) under #ifdef _KERNEL braces. Modified: stable/10/sys/dev/pty/pty.c stable/10/sys/kern/subr_prf.c stable/10/sys/sys/systm.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/pty/pty.c ============================================================================== --- stable/10/sys/dev/pty/pty.c Thu Jul 28 11:43:25 2016 (r303432) +++ stable/10/sys/dev/pty/pty.c Thu Jul 28 11:51:20 2016 (r303433) @@ -52,10 +52,10 @@ __FBSDID("$FreeBSD$"); * binary emulation. */ -static unsigned int pty_warningcnt = 1; +static unsigned pty_warningcnt = 1; SYSCTL_UINT(_kern, OID_AUTO, tty_pty_warningcnt, CTLFLAG_RW, - &pty_warningcnt, 0, - "Warnings that will be triggered upon legacy PTY allocation"); + &pty_warningcnt, 0, + "Warnings that will be triggered upon legacy PTY allocation"); static int ptydev_fdopen(struct cdev *dev, int fflags, struct thread *td, struct file *fp) @@ -77,12 +77,7 @@ ptydev_fdopen(struct cdev *dev, int ffla } /* Raise a warning when a legacy PTY has been allocated. */ - if (pty_warningcnt > 0) { - pty_warningcnt--; - log(LOG_INFO, "pid %d (%s) is using legacy pty devices%s\n", - td->td_proc->p_pid, td->td_name, - pty_warningcnt ? "" : " - not logging anymore"); - } + counted_warning(&pty_warningcnt, "is using legacy pty devices"); return (0); } Modified: stable/10/sys/kern/subr_prf.c ============================================================================== --- stable/10/sys/kern/subr_prf.c Thu Jul 28 11:43:25 2016 (r303432) +++ stable/10/sys/kern/subr_prf.c Thu Jul 28 11:51:20 2016 (r303433) @@ -1185,3 +1185,24 @@ sbuf_hexdump(struct sbuf *sb, const void } } +#ifdef _KERNEL +void +counted_warning(unsigned *counter, const char *msg) +{ + struct thread *td; + unsigned c; + + for (;;) { + c = *counter; + if (c == 0) + break; + if (atomic_cmpset_int(counter, c, c - 1)) { + td = curthread; + log(LOG_INFO, "pid %d (%s) %s%s\n", + td->td_proc->p_pid, td->td_name, msg, + c > 1 ? "" : " - not logging anymore"); + break; + } + } +} +#endif Modified: stable/10/sys/sys/systm.h ============================================================================== --- stable/10/sys/sys/systm.h Thu Jul 28 11:43:25 2016 (r303432) +++ stable/10/sys/sys/systm.h Thu Jul 28 11:51:20 2016 (r303433) @@ -434,4 +434,6 @@ void intr_prof_stack_use(struct thread * extern void (*softdep_ast_cleanup)(void); +void counted_warning(unsigned *counter, const char *msg); + #endif /* !_SYS_SYSTM_H_ */ From owner-svn-src-stable-10@freebsd.org Thu Jul 28 20:08:02 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD42CBA70B1; Thu, 28 Jul 2016 20:08:02 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 791861A8B; Thu, 28 Jul 2016 20:08:02 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6SK81wY012741; Thu, 28 Jul 2016 20:08:01 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6SK81AE012736; Thu, 28 Jul 2016 20:08:01 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607282008.u6SK81AE012736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Thu, 28 Jul 2016 20:08:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303458 - stable/10/sys/netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2016 20:08:02 -0000 Author: sbruno Date: Thu Jul 28 20:08:01 2016 New Revision: 303458 URL: https://svnweb.freebsd.org/changeset/base/303458 Log: MFC r296063 r297397 r299213 296063: Lock the NDP default router list and count defrouter references. This addresses a number of race conditions that can cause crashes as a result of unsynchronized access to the list. 297397 Modify nd6_llinfo_timer() to acquire the nd6 lock before the LLE lock. When expiring a neighbour cache entry we may need to look up the associated default router, which requires the nd6 read lock. To avoid an LOR, the nd6 lock should be acquired first. 299213 Clean up callers of nd6_prelist_add(). nd6_prelist_add() sets *newp if and only if it is successful, so there's no need for code that handles the case where the return value is 0 and *newp == NULL. Fix some style bugs in nd6_prelist_add() while here. Submitted by: Jason Wolfe Modified: stable/10/sys/netinet6/in6.c stable/10/sys/netinet6/nd6.c stable/10/sys/netinet6/nd6.h stable/10/sys/netinet6/nd6_nbr.c stable/10/sys/netinet6/nd6_rtr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet6/in6.c ============================================================================== --- stable/10/sys/netinet6/in6.c Thu Jul 28 19:32:25 2016 (r303457) +++ stable/10/sys/netinet6/in6.c Thu Jul 28 20:08:01 2016 (r303458) @@ -732,14 +732,6 @@ in6_control(struct socket *so, u_long cm (*carp_detach_p)(&ia->ia_ifa); goto out; } - if (pr == NULL) { - if (carp_attached) - (*carp_detach_p)(&ia->ia_ifa); - log(LOG_ERR, "nd6_prelist_add succeeded but " - "no prefix\n"); - error = EINVAL; - goto out; - } } /* relate the address to the prefix */ Modified: stable/10/sys/netinet6/nd6.c ============================================================================== --- stable/10/sys/netinet6/nd6.c Thu Jul 28 19:32:25 2016 (r303457) +++ stable/10/sys/netinet6/nd6.c Thu Jul 28 20:08:01 2016 (r303458) @@ -114,6 +114,7 @@ VNET_DEFINE(int, nd6_debug) = 0; VNET_DEFINE(struct nd_drhead, nd_defrouter); VNET_DEFINE(struct nd_prhead, nd_prefix); +VNET_DEFINE(struct rwlock, nd6_lock); VNET_DEFINE(int, nd6_recalc_reachtm_interval) = ND6_RECALC_REACHTM_INTERVAL; #define V_nd6_recalc_reachtm_interval VNET(nd6_recalc_reachtm_interval) @@ -125,7 +126,7 @@ static int nd6_is_new_addr_neighbor(stru static void nd6_setmtu0(struct ifnet *, struct nd_ifinfo *); static void nd6_slowtimo(void *); static int regen_tmpaddr(struct in6_ifaddr *); -static struct llentry *nd6_free(struct llentry *, int); +static struct llentry *nd6_free(struct llentry **, int); static void nd6_llinfo_timer(void *); static void clear_llinfo_pqueue(struct llentry *); static int nd6_output_lle(struct ifnet *, struct ifnet *, struct mbuf *, @@ -142,6 +143,8 @@ void nd6_init(void) { + rw_init(&V_nd6_lock, "nd6"); + LIST_INIT(&V_nd_prefix); /* initialization of the default router list */ @@ -162,6 +165,7 @@ nd6_destroy() callout_drain(&V_nd6_slowtimo_ch); callout_drain(&V_nd6_timer_ch); + rw_destroy(&V_nd6_lock); } #endif @@ -466,10 +470,14 @@ nd6_llinfo_timer(void *arg) struct llentry *ln; struct in6_addr *dst; struct ifnet *ifp; - struct nd_ifinfo *ndi = NULL; + struct nd_ifinfo *ndi; KASSERT(arg != NULL, ("%s: arg NULL", __func__)); ln = (struct llentry *)arg; + ifp = ln->lle_tbl->llt_ifp; + CURVNET_SET(ifp->if_vnet); + + ND6_RLOCK(); LLE_WLOCK(ln); if (callout_pending(&ln->la_timer)) { /* @@ -489,10 +497,10 @@ nd6_llinfo_timer(void *arg) * would have been 1. */ LLE_WUNLOCK(ln); + ND6_RUNLOCK(); + CURVNET_RESTORE(); return; } - ifp = ln->lle_tbl->llt_ifp; - CURVNET_SET(ifp->if_vnet); if (ln->ln_ntick > 0) { if (ln->ln_ntick > INT_MAX) { @@ -512,8 +520,7 @@ nd6_llinfo_timer(void *arg) } if (ln->la_flags & LLE_DELETED) { - (void)nd6_free(ln, 0); - ln = NULL; + (void)nd6_free(&ln, 0); goto done; } @@ -539,9 +546,7 @@ nd6_llinfo_timer(void *arg) ln->la_hold = m0; clear_llinfo_pqueue(ln); } - EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_TIMEDOUT); - (void)nd6_free(ln, 0); - ln = NULL; + (void)nd6_free(&ln, 0); if (m != NULL) icmp6_error2(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0, ifp); @@ -558,7 +563,7 @@ nd6_llinfo_timer(void *arg) /* Garbage Collection(RFC 2461 5.3) */ if (!ND6_LLINFO_PERMANENT(ln)) { EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_EXPIRED); - (void)nd6_free(ln, 1); + (void)nd6_free(&ln, 1); ln = NULL; } break; @@ -585,9 +590,7 @@ nd6_llinfo_timer(void *arg) nd6_ns_output(ifp, dst, dst, ln, NULL); LLE_WLOCK(ln); } else { - EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_EXPIRED); - (void)nd6_free(ln, 0); - ln = NULL; + (void)nd6_free(&ln, 0); } break; default: @@ -595,8 +598,10 @@ nd6_llinfo_timer(void *arg) __func__, ln->ln_state); } done: - if (ln != NULL) + if (ln != NULL) { + ND6_RUNLOCK(); LLE_FREE_LOCKED(ln); + } CURVNET_RESTORE(); } @@ -608,6 +613,7 @@ void nd6_timer(void *arg) { CURVNET_SET((struct vnet *) arg); + struct nd_drhead drq; struct nd_defrouter *dr, *ndr; struct nd_prefix *pr, *npr; struct in6_ifaddr *ia6, *nia6; @@ -615,10 +621,18 @@ nd6_timer(void *arg) callout_reset(&V_nd6_timer_ch, V_nd6_prune * hz, nd6_timer, curvnet); + TAILQ_INIT(&drq); + /* expire default router list */ - TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) { + ND6_WLOCK(); + TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) if (dr->expire && dr->expire < time_uptime) - defrtrlist_del(dr); + defrouter_unlink(dr, &drq); + ND6_WUNLOCK(); + + while ((dr = TAILQ_FIRST(&drq)) != NULL) { + TAILQ_REMOVE(&drq, dr, dr_entry); + defrouter_del(dr); } /* @@ -813,29 +827,37 @@ regen_tmpaddr(struct in6_ifaddr *ia6) void nd6_purge(struct ifnet *ifp) { + struct nd_drhead drq; struct nd_defrouter *dr, *ndr; struct nd_prefix *pr, *npr; + TAILQ_INIT(&drq); + /* * Nuke default router list entries toward ifp. * We defer removal of default router list entries that is installed * in the routing table, in order to keep additional side effects as * small as possible. */ + ND6_WLOCK(); TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) { if (dr->installed) continue; - if (dr->ifp == ifp) - defrtrlist_del(dr); + defrouter_unlink(dr, &drq); } TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, ndr) { if (!dr->installed) continue; - if (dr->ifp == ifp) - defrtrlist_del(dr); + defrouter_unlink(dr, &drq); + } + ND6_WUNLOCK(); + + while ((dr = TAILQ_FIRST(&drq)) != NULL) { + TAILQ_REMOVE(&drq, dr, dr_entry); + defrouter_del(dr); } /* Nuke prefix list entries toward ifp */ @@ -1046,13 +1068,27 @@ nd6_is_addr_neighbor(struct sockaddr_in6 * that the change is safe. */ static struct llentry * -nd6_free(struct llentry *ln, int gc) +nd6_free(struct llentry **lnp, int gc) { - struct llentry *next; - struct nd_defrouter *dr; struct ifnet *ifp; + struct llentry *ln, *next; + struct nd_defrouter *dr; + + ln = *lnp; + *lnp = NULL; LLE_WLOCK_ASSERT(ln); + ND6_RLOCK_ASSERT(); + + ifp = ln->lle_tbl->llt_ifp; + if ((ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) != 0) + dr = defrouter_lookup_locked(&L3_ADDR_SIN6(ln)->sin6_addr, ifp); + else + dr = NULL; + ND6_RUNLOCK(); + + if ((ln->la_flags & LLE_DELETED) == 0) + EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_EXPIRED); /* * we used to have pfctlinput(PRC_HOSTDEAD) here. @@ -1062,11 +1098,7 @@ nd6_free(struct llentry *ln, int gc) /* cancel timer */ nd6_llinfo_settimer_locked(ln, -1); - ifp = ln->lle_tbl->llt_ifp; - if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { - dr = defrouter_lookup(&L3_ADDR_SIN6(ln)->sin6_addr, ifp); - if (dr != NULL && dr->expire && ln->ln_state == ND6_LLINFO_STALE && gc) { /* @@ -1091,6 +1123,7 @@ nd6_free(struct llentry *ln, int gc) next = LIST_NEXT(ln, lle_next); LLE_REMREF(ln); LLE_WUNLOCK(ln); + defrouter_rele(dr); return (next); } @@ -1173,6 +1206,8 @@ nd6_free(struct llentry *ln, int gc) IF_AFDATA_UNLOCK(ifp); + if (dr != NULL) + defrouter_rele(dr); return (next); } @@ -1251,12 +1286,13 @@ nd6_rtrequest(int req, struct rtentry *r /* * check for default route */ - if (IN6_ARE_ADDR_EQUAL(&in6addr_any, - &SIN6(rt_key(rt))->sin6_addr)) { - + if (IN6_ARE_ADDR_EQUAL(&in6addr_any, + &SIN6(rt_key(rt))->sin6_addr)) { dr = defrouter_lookup(&gateway->sin6_addr, ifp); - if (dr != NULL) + if (dr != NULL) { dr->installed = 0; + defrouter_rele(dr); + } } break; } @@ -1444,12 +1480,22 @@ nd6_ioctl(u_long cmd, caddr_t data, stru case SIOCSRTRFLUSH_IN6: { /* flush all the default routers */ - struct nd_defrouter *dr, *next; + struct nd_drhead drq; + struct nd_defrouter *dr; + + TAILQ_INIT(&drq); defrouter_reset(); - TAILQ_FOREACH_SAFE(dr, &V_nd_defrouter, dr_entry, next) { - defrtrlist_del(dr); + + ND6_WLOCK(); + while ((dr = TAILQ_FIRST(&V_nd_defrouter)) != NULL) + defrouter_unlink(dr, &drq); + ND6_WUNLOCK(); + while ((dr = TAILQ_FIRST(&drq)) != NULL) { + TAILQ_REMOVE(&drq, dr, dr_entry); + defrouter_del(dr); } + defrouter_select(); break; } @@ -2200,30 +2246,33 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) struct nd_defrouter *dr; int error; - if (req->newptr) + if (req->newptr != NULL) return (EPERM); + error = sysctl_wire_old_buffer(req, 0); + if (error != 0) + return (error); + bzero(&d, sizeof(d)); d.rtaddr.sin6_family = AF_INET6; d.rtaddr.sin6_len = sizeof(d.rtaddr); - /* - * XXX locking - */ + ND6_RLOCK(); TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { d.rtaddr.sin6_addr = dr->rtaddr; error = sa6_recoverscope(&d.rtaddr); if (error != 0) - return (error); + break; d.flags = dr->raflags; d.rtlifetime = dr->rtlifetime; d.expire = dr->expire + (time_second - time_uptime); d.if_index = dr->ifp->if_index; error = SYSCTL_OUT(req, &d, sizeof(d)); if (error != 0) - return (error); + break; } - return (0); + ND6_RUNLOCK(); + return (error); } static int Modified: stable/10/sys/netinet6/nd6.h ============================================================================== --- stable/10/sys/netinet6/nd6.h Thu Jul 28 19:32:25 2016 (r303457) +++ stable/10/sys/netinet6/nd6.h Thu Jul 28 20:08:01 2016 (r303458) @@ -243,6 +243,7 @@ struct nd_defrouter { u_long expire; struct ifnet *ifp; int installed; /* is installed into kernel routing table */ + u_int refcnt; }; struct nd_prefixctl { @@ -342,6 +343,19 @@ VNET_DECLARE(int, nd6_onlink_ns_rfc4861) #define V_nd6_debug VNET(nd6_debug) #define V_nd6_onlink_ns_rfc4861 VNET(nd6_onlink_ns_rfc4861) +/* Lock for the prefix and default router lists. */ +VNET_DECLARE(struct rwlock, nd6_lock); +#define V_nd6_lock VNET(nd6_lock) + +#define ND6_RLOCK() rw_rlock(&V_nd6_lock) +#define ND6_RUNLOCK() rw_runlock(&V_nd6_lock) +#define ND6_WLOCK() rw_wlock(&V_nd6_lock) +#define ND6_WUNLOCK() rw_wunlock(&V_nd6_lock) +#define ND6_WLOCK_ASSERT() rw_assert(&V_nd6_lock, RA_WLOCKED) +#define ND6_RLOCK_ASSERT() rw_assert(&V_nd6_lock, RA_RLOCKED) +#define ND6_LOCK_ASSERT() rw_assert(&V_nd6_lock, RA_LOCKED) +#define ND6_UNLOCK_ASSERT() rw_assert(&V_nd6_lock, RA_UNLOCKED) + #define nd6log(x) do { if (V_nd6_debug) log x; } while (/*CONSTCOND*/ 0) VNET_DECLARE(struct callout, nd6_timer_ch); @@ -447,12 +461,17 @@ void nd6_rs_input(struct mbuf *, int, in void nd6_ra_input(struct mbuf *, int, int); void defrouter_reset(void); void defrouter_select(void); -void defrtrlist_del(struct nd_defrouter *); +void defrouter_ref(struct nd_defrouter *); +void defrouter_rele(struct nd_defrouter *); +bool defrouter_remove(struct in6_addr *, struct ifnet *); +void defrouter_unlink(struct nd_defrouter *, struct nd_drhead *); +void defrouter_del(struct nd_defrouter *); void prelist_remove(struct nd_prefix *); int nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *, struct nd_prefix **); void pfxlist_onlink_check(void); struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *); +struct nd_defrouter *defrouter_lookup_locked(struct in6_addr *, struct ifnet *); struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *); void rt6_flush(struct in6_addr *, struct ifnet *); int nd6_setdefaultiface(int); Modified: stable/10/sys/netinet6/nd6_nbr.c ============================================================================== --- stable/10/sys/netinet6/nd6_nbr.c Thu Jul 28 19:32:25 2016 (r303457) +++ stable/10/sys/netinet6/nd6_nbr.c Thu Jul 28 20:08:01 2016 (r303458) @@ -895,25 +895,17 @@ nd6_na_input(struct mbuf *m, int off, in * Remove the sender from the Default Router List and * update the Destination Cache entries. */ - struct nd_defrouter *dr; - struct in6_addr *in6; - - in6 = &L3_ADDR_SIN6(ln)->sin6_addr; - - dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp); - if (dr) - defrtrlist_del(dr); - else if (ND_IFINFO(ln->lle_tbl->llt_ifp)->flags & - ND6_IFF_ACCEPT_RTADV) { + if (!defrouter_remove(&L3_ADDR_SIN6(ln)->sin6_addr, + ln->lle_tbl->llt_ifp) && + (ND_IFINFO(ln->lle_tbl->llt_ifp)->flags & + ND6_IFF_ACCEPT_RTADV) != 0) /* * Even if the neighbor is not in the default - * router list, the neighbor may be used - * as a next hop for some destinations - * (e.g. redirect case). So we must - * call rt6_flush explicitly. + * router list, the neighbor may be used as a + * next hop for some destinations (e.g. redirect + * case). So we must call rt6_flush explicitly. */ rt6_flush(&ip6->ip6_src, ifp); - } } ln->ln_router = is_router; } Modified: stable/10/sys/netinet6/nd6_rtr.c ============================================================================== --- stable/10/sys/netinet6/nd6_rtr.c Thu Jul 28 19:32:25 2016 (r303457) +++ stable/10/sys/netinet6/nd6_rtr.c Thu Jul 28 20:08:01 2016 (r303458) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -218,6 +219,8 @@ nd6_ra_input(struct mbuf *m, int off, in struct nd_defrouter *dr; char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; + dr = NULL; + /* * We only accept RAs only when the per-interface flag * ND6_IFF_ACCEPT_RTADV is on the receiving interface. @@ -367,6 +370,10 @@ nd6_ra_input(struct mbuf *m, int off, in (void)prelist_update(&pr, dr, m, mcast); } } + if (dr != NULL) { + defrouter_rele(dr); + dr = NULL; + } /* * MTU @@ -444,10 +451,6 @@ nd6_ra_input(struct mbuf *m, int off, in m_freem(m); } -/* - * default router list proccessing sub routines - */ - /* tell the change to user processes watching the routing socket. */ static void nd6_rtmsg(int cmd, struct rtentry *rt) @@ -476,6 +479,10 @@ nd6_rtmsg(int cmd, struct rtentry *rt) ifa_free(ifa); } +/* + * default router list proccessing sub routines + */ + static void defrouter_addreq(struct nd_defrouter *new) { @@ -504,16 +511,43 @@ defrouter_addreq(struct nd_defrouter *ne } struct nd_defrouter * -defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp) +defrouter_lookup_locked(struct in6_addr *addr, struct ifnet *ifp) { struct nd_defrouter *dr; - TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { - if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) + ND6_LOCK_ASSERT(); + TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) + if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) { + defrouter_ref(dr); return (dr); - } + } + return (NULL); +} + +struct nd_defrouter * +defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp) +{ + struct nd_defrouter *dr; - return (NULL); /* search failed */ + ND6_RLOCK(); + dr = defrouter_lookup_locked(addr, ifp); + ND6_RUNLOCK(); + return (dr); +} + +void +defrouter_ref(struct nd_defrouter *dr) +{ + + refcount_acquire(&dr->refcnt); +} + +void +defrouter_rele(struct nd_defrouter *dr) +{ + + if (refcount_release(&dr->refcnt)) + free(dr, M_IP6NDP); } /* @@ -548,15 +582,41 @@ defrouter_delreq(struct nd_defrouter *dr } /* - * remove all default routes from default router list + * Remove all default routes from default router list. */ void defrouter_reset(void) { - struct nd_defrouter *dr; + struct nd_defrouter *dr, **dra; + int count, i; + + count = i = 0; + /* + * We can't delete routes with the ND lock held, so make a copy of the + * current default router list and use that when deleting routes. + */ + ND6_RLOCK(); TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) - defrouter_delreq(dr); + count++; + ND6_RUNLOCK(); + + dra = malloc(count * sizeof(*dra), M_TEMP, M_WAITOK | M_ZERO); + + ND6_RLOCK(); + TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { + if (i == count) + break; + defrouter_ref(dr); + dra[i++] = dr; + } + ND6_RUNLOCK(); + + for (i = 0; i < count && dra[i] != NULL; i++) { + defrouter_delreq(dra[i]); + defrouter_rele(dra[i]); + } + free(dra, M_TEMP); /* * XXX should we also nuke any default routers in the kernel, by @@ -564,12 +624,53 @@ defrouter_reset(void) */ } +/* + * Look up a matching default router list entry and remove it. Returns true if a + * matching entry was found, false otherwise. + */ +bool +defrouter_remove(struct in6_addr *addr, struct ifnet *ifp) +{ + struct nd_defrouter *dr; + + ND6_WLOCK(); + dr = defrouter_lookup_locked(addr, ifp); + if (dr == NULL) { + ND6_WUNLOCK(); + return (false); + } + + defrouter_unlink(dr, NULL); + ND6_WUNLOCK(); + defrouter_del(dr); + defrouter_rele(dr); + return (true); +} + +/* + * Remove a router from the global list and optionally stash it in a + * caller-supplied queue. + * + * The ND lock must be held. + */ void -defrtrlist_del(struct nd_defrouter *dr) +defrouter_unlink(struct nd_defrouter *dr, struct nd_drhead *drq) +{ + + ND6_WLOCK_ASSERT(); + TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); + if (drq != NULL) + TAILQ_INSERT_TAIL(drq, dr, dr_entry); +} + +void +defrouter_del(struct nd_defrouter *dr) { struct nd_defrouter *deldr = NULL; struct nd_prefix *pr; + ND6_UNLOCK_ASSERT(); + /* * Flush all the routing table entries that use the router * as a next hop. @@ -581,7 +682,6 @@ defrtrlist_del(struct nd_defrouter *dr) deldr = dr; defrouter_delreq(dr); } - TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); /* * Also delete all the pointers to the router in each prefix lists. @@ -601,7 +701,10 @@ defrtrlist_del(struct nd_defrouter *dr) if (deldr) defrouter_select(); - free(dr, M_IP6NDP); + /* + * Release the list reference. + */ + defrouter_rele(dr); } /* @@ -628,27 +731,32 @@ defrtrlist_del(struct nd_defrouter *dr) void defrouter_select(void) { - struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; + struct nd_defrouter *dr, *selected_dr, *installed_dr; struct llentry *ln = NULL; + ND6_RLOCK(); /* * Let's handle easy case (3) first: * If default router list is empty, there's nothing to be done. */ - if (TAILQ_EMPTY(&V_nd_defrouter)) + if (TAILQ_EMPTY(&V_nd_defrouter)) { + ND6_RUNLOCK(); return; + } /* * Search for a (probably) reachable router from the list. * We just pick up the first reachable one (if any), assuming that * the ordering rule of the list described in defrtrlist_update(). */ + selected_dr = installed_dr = NULL; TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { IF_AFDATA_RLOCK(dr->ifp); if (selected_dr == NULL && (ln = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) && ND6_IS_LLINFO_PROBREACH(ln)) { selected_dr = dr; + defrouter_ref(selected_dr); } IF_AFDATA_RUNLOCK(dr->ifp); if (ln != NULL) { @@ -656,12 +764,15 @@ defrouter_select(void) ln = NULL; } - if (dr->installed && installed_dr == NULL) - installed_dr = dr; - else if (dr->installed && installed_dr) { - /* this should not happen. warn for diagnosis. */ - log(LOG_ERR, "defrouter_select: more than one router" - " is installed\n"); + if (dr->installed) { + if (installed_dr == NULL) { + installed_dr = dr; + defrouter_ref(installed_dr); + } else { + /* this should not happen. warn for diagnosis. */ + log(LOG_ERR, + "defrouter_select: more than one router is installed\n"); + } } } /* @@ -673,21 +784,25 @@ defrouter_select(void) * or when the new one has a really higher preference value. */ if (selected_dr == NULL) { - if (installed_dr == NULL || !TAILQ_NEXT(installed_dr, dr_entry)) + if (installed_dr == NULL || + TAILQ_NEXT(installed_dr, dr_entry) == NULL) selected_dr = TAILQ_FIRST(&V_nd_defrouter); else selected_dr = TAILQ_NEXT(installed_dr, dr_entry); - } else if (installed_dr) { + defrouter_ref(selected_dr); + } else if (installed_dr != NULL) { IF_AFDATA_RLOCK(installed_dr->ifp); if ((ln = nd6_lookup(&installed_dr->rtaddr, 0, installed_dr->ifp)) && ND6_IS_LLINFO_PROBREACH(ln) && rtpref(selected_dr) <= rtpref(installed_dr)) { + defrouter_rele(selected_dr); selected_dr = installed_dr; } IF_AFDATA_RUNLOCK(installed_dr->ifp); if (ln != NULL) LLE_RUNLOCK(ln); } + ND6_RUNLOCK(); /* * If the selected router is different than the installed one, @@ -695,10 +810,13 @@ defrouter_select(void) * Note that the selected router is never NULL here. */ if (installed_dr != selected_dr) { - if (installed_dr) + if (installed_dr != NULL) { defrouter_delreq(installed_dr); + defrouter_rele(installed_dr); + } defrouter_addreq(selected_dr); } + defrouter_rele(selected_dr); } /* @@ -734,13 +852,14 @@ defrtrlist_update(struct nd_defrouter *n struct nd_defrouter *dr, *n; int oldpref; - if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) { - /* entry exists */ - if (new->rtlifetime == 0) { - defrtrlist_del(dr); - return (NULL); - } + if (new->rtlifetime == 0) { + defrouter_remove(&new->rtaddr, new->ifp); + return (NULL); + } + ND6_WLOCK(); + dr = defrouter_lookup_locked(&new->rtaddr, new->ifp); + if (dr != NULL) { oldpref = rtpref(dr); /* override */ @@ -753,8 +872,10 @@ defrtrlist_update(struct nd_defrouter *n * to sort the entries. Also make sure the selected * router is still installed in the kernel. */ - if (dr->installed && rtpref(new) == oldpref) + if (dr->installed && rtpref(new) == oldpref) { + ND6_WUNLOCK(); return (dr); + } /* * The preferred router may have changed, so relocate this @@ -762,19 +883,17 @@ defrtrlist_update(struct nd_defrouter *n */ TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); n = dr; - goto insert; + } else { + n = malloc(sizeof(*n), M_IP6NDP, M_NOWAIT | M_ZERO); + if (n == NULL) { + ND6_WUNLOCK(); + return (NULL); + } + memcpy(n, new, sizeof(*n)); + /* Initialize with an extra reference for the caller. */ + refcount_init(&n->refcnt, 2); } - /* entry does not exist */ - if (new->rtlifetime == 0) - return (NULL); - - n = malloc(sizeof(*n), M_IP6NDP, M_NOWAIT | M_ZERO); - if (n == NULL) - return (NULL); - memcpy(n, new, sizeof(*n)); - -insert: /* * Insert the new router in the Default Router List; * The Default Router List should be in the descending order @@ -787,10 +906,11 @@ insert: if (rtpref(n) > rtpref(dr)) break; } - if (dr) + if (dr != NULL) TAILQ_INSERT_BEFORE(dr, n, dr_entry); else TAILQ_INSERT_TAIL(&V_nd_defrouter, n, dr_entry); + ND6_WUNLOCK(); defrouter_select(); @@ -819,6 +939,7 @@ pfxrtr_add(struct nd_prefix *pr, struct if (new == NULL) return; new->router = dr; + defrouter_ref(dr); LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry); @@ -828,7 +949,9 @@ pfxrtr_add(struct nd_prefix *pr, struct static void pfxrtr_del(struct nd_pfxrouter *pfr) { + LIST_REMOVE(pfr, pfr_entry); + defrouter_rele(pfr->router); free(pfr, M_IP6NDP); } @@ -869,11 +992,9 @@ nd6_prelist_add(struct nd_prefixctl *pr, new->ndpr_flags = pr->ndpr_flags; if ((error = in6_init_prefix_ltimes(new)) != 0) { free(new, M_IP6NDP); - return(error); + return (error); } new->ndpr_lastupdate = time_uptime; - if (newp != NULL) - *newp = new; /* initialization */ LIST_INIT(&new->ndpr_advrtrs); @@ -899,10 +1020,11 @@ nd6_prelist_add(struct nd_prefixctl *pr, } } - if (dr) + if (dr != NULL) pfxrtr_add(new, dr); - - return 0; + if (newp != NULL) + *newp = new; + return (0); } void @@ -959,7 +1081,6 @@ prelist_update(struct nd_prefixctl *new, struct ifnet *ifp = new->ndpr_ifp; struct nd_prefix *pr; int error = 0; - int newprefix = 0; int auth; struct in6_addrlifetime lt6_tmp; char ip6buf[INET6_ADDRSTRLEN]; @@ -1017,23 +1138,17 @@ prelist_update(struct nd_prefixctl *new, if (dr && pfxrtr_lookup(pr, dr) == NULL) pfxrtr_add(pr, dr); } else { - struct nd_prefix *newpr = NULL; - - newprefix = 1; - if (new->ndpr_vltime == 0) goto end; if (new->ndpr_raf_onlink == 0 && new->ndpr_raf_auto == 0) goto end; - error = nd6_prelist_add(new, dr, &newpr); - if (error != 0 || newpr == NULL) { + error = nd6_prelist_add(new, dr, &pr); + if (error != 0) { nd6log((LOG_NOTICE, "prelist_update: " - "nd6_prelist_add failed for %s/%d on %s " - "errno=%d, returnpr=%p\n", + "nd6_prelist_add failed for %s/%d on %s errno=%d\n", ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr), - new->ndpr_plen, if_name(new->ndpr_ifp), - error, newpr)); + new->ndpr_plen, if_name(new->ndpr_ifp), error)); goto end; /* we should just give up in this case. */ } @@ -1044,13 +1159,11 @@ prelist_update(struct nd_prefixctl *new, * addresses. Thus, we explicitly make sure that the prefix * itself expires now. */ - if (newpr->ndpr_raf_onlink == 0) { - newpr->ndpr_vltime = 0; - newpr->ndpr_pltime = 0; - in6_init_prefix_ltimes(newpr); + if (pr->ndpr_raf_onlink == 0) { + pr->ndpr_vltime = 0; + pr->ndpr_pltime = 0; + in6_init_prefix_ltimes(pr); } - - pr = newpr; } /* @@ -1346,6 +1459,7 @@ pfxlist_onlink_check() * that does not advertise any prefixes. */ if (pr == NULL) { + ND6_RLOCK(); TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) { struct nd_prefix *pr0; @@ -1356,6 +1470,7 @@ pfxlist_onlink_check() if (pfxrtr != NULL) break; } + ND6_RUNLOCK(); } if (pr != NULL || (!TAILQ_EMPTY(&V_nd_defrouter) && pfxrtr == NULL)) { /* From owner-svn-src-stable-10@freebsd.org Thu Jul 28 20:11:35 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B6CCBA74EA; Thu, 28 Jul 2016 20:11:35 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C0DD1170; Thu, 28 Jul 2016 20:11:35 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6SKBYP1013547; Thu, 28 Jul 2016 20:11:34 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6SKBY05013546; Thu, 28 Jul 2016 20:11:34 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201607282011.u6SKBY05013546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Thu, 28 Jul 2016 20:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303459 - stable/10/sys/netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2016 20:11:35 -0000 Author: sbruno Date: Thu Jul 28 20:11:34 2016 New Revision: 303459 URL: https://svnweb.freebsd.org/changeset/base/303459 Log: MFC r299829 Use Node Information flag names instead of hard-coding their values. Modified: stable/10/sys/netinet6/icmp6.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet6/icmp6.c ============================================================================== --- stable/10/sys/netinet6/icmp6.c Thu Jul 28 20:08:01 2016 (r303458) +++ stable/10/sys/netinet6/icmp6.c Thu Jul 28 20:11:34 2016 (r303459) @@ -679,7 +679,9 @@ icmp6_input(struct mbuf **mp, int *offp, * XXX: this combination of flags is pointless, * but should we keep this for compatibility? */ - if ((V_icmp6_nodeinfo & 5) != 5) + if ((V_icmp6_nodeinfo & (ICMP6_NODEINFO_FQDNOK | + ICMP6_NODEINFO_TMPADDROK)) != + (ICMP6_NODEINFO_FQDNOK | ICMP6_NODEINFO_TMPADDROK)) break; if (code != 0) From owner-svn-src-stable-10@freebsd.org Sat Jul 30 14:47:06 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F57BBA8B88; Sat, 30 Jul 2016 14:47:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D1E011DE; Sat, 30 Jul 2016 14:47:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6UEl5il066593; Sat, 30 Jul 2016 14:47:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6UEl5fM066588; Sat, 30 Jul 2016 14:47:05 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607301447.u6UEl5fM066588@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 30 Jul 2016 14:47:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303552 - in stable/10: share/man/man9 sys/kern sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2016 14:47:06 -0000 Author: kib Date: Sat Jul 30 14:47:04 2016 New Revision: 303552 URL: https://svnweb.freebsd.org/changeset/base/303552 Log: MFC r303211: Implement mtx_trylock_spin(9). Modified: stable/10/share/man/man9/Makefile stable/10/share/man/man9/mutex.9 stable/10/sys/kern/kern_mutex.c stable/10/sys/sys/mutex.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man9/Makefile ============================================================================== --- stable/10/share/man/man9/Makefile Sat Jul 30 10:32:28 2016 (r303551) +++ stable/10/share/man/man9/Makefile Sat Jul 30 14:47:04 2016 (r303552) @@ -994,6 +994,8 @@ MLINKS+=mutex.9 mtx_assert.9 \ mutex.9 MTX_SYSINIT.9 \ mutex.9 mtx_trylock.9 \ mutex.9 mtx_trylock_flags.9 \ + mutex.9 mtx_trylock_spin.9 \ + mutex.9 mtx_trylock_spin_flags.9 \ mutex.9 mtx_unlock.9 \ mutex.9 mtx_unlock_flags.9 \ mutex.9 mtx_unlock_spin.9 \ Modified: stable/10/share/man/man9/mutex.9 ============================================================================== --- stable/10/share/man/man9/mutex.9 Sat Jul 30 10:32:28 2016 (r303551) +++ stable/10/share/man/man9/mutex.9 Sat Jul 30 14:47:04 2016 (r303552) @@ -28,7 +28,7 @@ .\" from BSDI $Id: mutex.4,v 1.1.2.3 1998/04/27 22:53:13 ewv Exp $ .\" $FreeBSD$ .\" -.Dd November 16, 2011 +.Dd July 18, 2016 .Dt MUTEX 9 .Os .Sh NAME @@ -41,6 +41,8 @@ .Nm mtx_lock_spin_flags , .Nm mtx_trylock , .Nm mtx_trylock_flags , +.Nm mtx_trylock_spin , +.Nm mtx_trylock_spin_flags , .Nm mtx_unlock , .Nm mtx_unlock_spin , .Nm mtx_unlock_flags , @@ -73,6 +75,10 @@ .Ft int .Fn mtx_trylock_flags "struct mtx *mutex" "int flags" .Ft void +.Fn mtx_trylock_spin "struct mtx *mutex" +.Ft int +.Fn mtx_trylock_spin_flags "struct mtx *mutex" "int flags" +.Ft void .Fn mtx_unlock "struct mtx *mutex" .Ft void .Fn mtx_unlock_spin "struct mtx *mutex" @@ -245,26 +251,33 @@ argument, then the mutex can be acquired .Pp The .Fn mtx_trylock -attempts to acquire the +and +.Fn mtx_trylock_spin +functions attempt to acquire a .Dv MTX_DEF -mutex pointed to by +or +.Dv MTX_SPIN +mutex, respectively, pointed to by .Fa mutex . -If the mutex cannot be immediately acquired -.Fn mtx_trylock -will return 0, -otherwise the mutex will be acquired -and a non-zero value will be returned. +If the mutex cannot be immediately acquired, the functions will return 0, +otherwise the mutex will be acquired and a non-zero value will be returned. .Pp The .Fn mtx_trylock_flags -function has the same behavior as +and +.Fn mtx_trylock_spin_flags +functions have the same behavior as .Fn mtx_trylock -but should be used when the caller desires to pass in a +and +.Fn mtx_trylock_spin +respectively, but should be used when the caller desires to pass in a .Fa flags value. Presently, the only valid value in the .Fn mtx_trylock -case is +and +.Fn mtx_trylock_spin +cases is .Dv MTX_QUIET , and its effects are identical to those described for .Fn mtx_lock @@ -443,6 +456,13 @@ while any spin lock is held. .It Dv MTX_RECURSE Specifies that the initialized mutex is allowed to recurse. This bit must be present if the mutex is permitted to recurse. +.Pp +Note that neither +.Fn mtx_trylock +nor +.Fn mtx_trylock_spin +support recursion; +that is, attempting to acquire an already-owned mutex fails. .It Dv MTX_QUIET Do not log any mutex operations for this lock. .It Dv MTX_NOWITNESS @@ -528,3 +548,7 @@ functions appeared in .Bsx 4.1 and .Fx 5.0 . +The +.Fn mtx_trylock_spin +function was added in +.Fx 12.0 . Modified: stable/10/sys/kern/kern_mutex.c ============================================================================== --- stable/10/sys/kern/kern_mutex.c Sat Jul 30 10:32:28 2016 (r303551) +++ stable/10/sys/kern/kern_mutex.c Sat Jul 30 14:47:04 2016 (r303552) @@ -285,6 +285,34 @@ __mtx_lock_spin_flags(volatile uintptr_t WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); } +int +__mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, const char *file, + int line) +{ + struct mtx *m; + + if (SCHEDULER_STOPPED()) + return (1); + + m = mtxlock2mtx(c); + + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_trylock_spin() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, + ("mtx_trylock_spin() of sleep mutex %s @ %s:%d", + m->lock_object.lo_name, file, line)); + KASSERT((opts & MTX_RECURSE) == 0, + ("mtx_trylock_spin: unsupp. opt MTX_RECURSE on mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); + if (__mtx_trylock_spin(m, curthread, opts, file, line)) { + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 1, file, line); + WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); + return (1); + } + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 0, file, line); + return (0); +} + void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line) Modified: stable/10/sys/sys/mutex.h ============================================================================== --- stable/10/sys/sys/mutex.h Sat Jul 30 10:32:28 2016 (r303551) +++ stable/10/sys/sys/mutex.h Sat Jul 30 14:47:04 2016 (r303552) @@ -111,6 +111,8 @@ void __mtx_unlock_flags(volatile uintptr int line); void __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); +int __mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, + const char *file, int line); void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -151,6 +153,8 @@ void thread_lock_flags_(struct thread *, __mtx_unlock_flags(&(m)->mtx_lock, o, f, l) #define _mtx_lock_spin_flags(m, o, f, l) \ __mtx_lock_spin_flags(&(m)->mtx_lock, o, f, l) +#define _mtx_trylock_spin_flags(m, o, f, l) \ + __mtx_trylock_spin_flags(&(m)->mtx_lock, o, f, l) #define _mtx_unlock_spin_flags(m, o, f, l) \ __mtx_unlock_spin_flags(&(m)->mtx_lock, o, f, l) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -211,6 +215,21 @@ void thread_lock_flags_(struct thread *, LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ mp, 0, 0, (file), (line)); \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid))) {\ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ + mp, 0, 0, file, line); \ + _ret = 1; \ + } \ + _ret; \ +}) #else /* SMP */ #define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ @@ -223,6 +242,20 @@ void thread_lock_flags_(struct thread *, (mp)->mtx_lock = _tid; \ } \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if ((mp)->mtx_lock != MTX_UNOWNED) { \ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + (mp)->mtx_lock = _tid; \ + _ret = 1; \ + } \ + _ret; \ +}) #endif /* SMP */ /* Unlock a normal mutex. */ @@ -292,6 +325,10 @@ void thread_lock_flags_(struct thread *, * mtx_trylock_flags(m, opts) is used the same way as mtx_trylock() but accepts * relevant option flags `opts.' * + * mtx_trylock_spin(m) attempts to acquire MTX_SPIN mutex `m' but doesn't + * spin if it cannot. Rather, it returns 0 on failure and non-zero on + * success. It always returns failure for recursed lock attempts. + * * mtx_initialized(m) returns non-zero if the lock `m' has been initialized. * * mtx_owned(m) returns non-zero if the current thread owns the lock `m' @@ -301,6 +338,7 @@ void thread_lock_flags_(struct thread *, #define mtx_lock(m) mtx_lock_flags((m), 0) #define mtx_lock_spin(m) mtx_lock_spin_flags((m), 0) #define mtx_trylock(m) mtx_trylock_flags((m), 0) +#define mtx_trylock_spin(m) mtx_trylock_spin_flags((m), 0) #define mtx_unlock(m) mtx_unlock_flags((m), 0) #define mtx_unlock_spin(m) mtx_unlock_spin_flags((m), 0) @@ -338,6 +376,8 @@ extern struct mtx_pool *mtxpool_sleep; _mtx_unlock_flags((m), (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ _mtx_lock_spin_flags((m), (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + _mtx_trylock_spin_flags((m), (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ _mtx_unlock_spin_flags((m), (opts), (file), (line)) #else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ @@ -347,6 +387,8 @@ extern struct mtx_pool *mtxpool_sleep; __mtx_unlock((m), curthread, (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ __mtx_lock_spin((m), curthread, (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + __mtx_trylock_spin((m), curthread, (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ __mtx_unlock_spin((m)) #endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ @@ -372,6 +414,8 @@ extern struct mtx_pool *mtxpool_sleep; mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_trylock_flags(m, opts) \ mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) +#define mtx_trylock_spin_flags(m, opts) \ + mtx_trylock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_assert(m, what) \ mtx_assert_((m), (what), __FILE__, __LINE__)