From owner-svn-src-stable-10@freebsd.org Sun Dec 25 22:32:17 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 55931C91992; Sun, 25 Dec 2016 22:32:17 +0000 (UTC) (envelope-from jilles@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 240C612D5; Sun, 25 Dec 2016 22:32:17 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBPMWGH4049821; Sun, 25 Dec 2016 22:32:16 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBPMWG0H049600; Sun, 25 Dec 2016 22:32:16 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201612252232.uBPMWG0H049600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 25 Dec 2016 22:32:16 +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: r310558 - stable/10/tests/sys/kern 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.23 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, 25 Dec 2016 22:32:17 -0000 Author: jilles Date: Sun Dec 25 22:32:16 2016 New Revision: 310558 URL: https://svnweb.freebsd.org/changeset/base/310558 Log: MFC r309836: Add some tests for reaper functionality (in procctl()). Added: stable/10/tests/sys/kern/reaper.c - copied unchanged from r309836, head/tests/sys/kern/reaper.c Modified: stable/10/tests/sys/kern/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/tests/sys/kern/Makefile ============================================================================== --- stable/10/tests/sys/kern/Makefile Sun Dec 25 21:41:40 2016 (r310557) +++ stable/10/tests/sys/kern/Makefile Sun Dec 25 22:32:16 2016 (r310558) @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= ptrace_test +ATF_TESTS_C+= reaper ATF_TESTS_C+= unix_seqpacket_test ATF_TESTS_C+= unix_passfd_test TEST_METADATA.unix_seqpacket_test+= timeout="15" Copied: stable/10/tests/sys/kern/reaper.c (from r309836, head/tests/sys/kern/reaper.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/tests/sys/kern/reaper.c Sun Dec 25 22:32:16 2016 (r310558, copy of r309836, head/tests/sys/kern/reaper.c) @@ -0,0 +1,494 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include + +ATF_TC_WITHOUT_HEAD(reaper_wait_child_first); +ATF_TC_BODY(reaper_wait_child_first, tc) +{ + pid_t parent, child, grandchild, pid; + int status, r; + int pip[2]; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[1]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) { + if (read(pip[0], &(uint8_t){ 0 }, 1) != 0) + _exit(102); + if (getppid() != parent) + _exit(103); + _exit(2); + } else + _exit(3); + } + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(3, r); + + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0 && pid != child); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(2, r); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_wait_grandchild_first); +ATF_TC_BODY(reaper_wait_grandchild_first, tc) +{ + pid_t parent, child, grandchild, pid; + int status, r; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) + _exit(2); + else { + if (waitid(P_PID, grandchild, NULL, + WNOWAIT | WEXITED) != 0) + _exit(102); + _exit(3); + } + } + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(3, r); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0 && pid != child); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(2, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_status); +ATF_TC_BODY(reaper_status, tc) +{ + struct procctl_reaper_status st; + ssize_t sr; + pid_t parent, child, pid; + int r, status; + int pip[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(0, st.rs_flags & REAPER_STATUS_OWNED); + ATF_CHECK(st.rs_children > 0); + ATF_CHECK(st.rs_descendants > 0); + ATF_CHECK(st.rs_descendants >= st.rs_children); + ATF_CHECK(st.rs_reaper != parent); + ATF_CHECK(st.rs_reaper > 0); + + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(0, st.rs_children); + ATF_CHECK_EQ(0, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(-1, st.rs_pid); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[0]) != 0) + _exit(100); + if (procctl(P_PID, parent, PROC_REAP_STATUS, &st) != 0) + _exit(101); + if (write(pip[1], &st, sizeof(st)) != (ssize_t)sizeof(st)) + _exit(102); + if (procctl(P_PID, getpid(), PROC_REAP_STATUS, &st) != 0) + _exit(103); + if (write(pip[1], &st, sizeof(st)) != (ssize_t)sizeof(st)) + _exit(104); + _exit(0); + } + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + sr = read(pip[0], &st, sizeof(st)); + ATF_REQUIRE_EQ((ssize_t)sizeof(st), sr); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(1, st.rs_children); + ATF_CHECK_EQ(1, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(child, st.rs_pid); + sr = read(pip[0], &st, sizeof(st)); + ATF_REQUIRE_EQ((ssize_t)sizeof(st), sr); + ATF_CHECK_EQ(0, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(1, st.rs_children); + ATF_CHECK_EQ(1, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(child, st.rs_pid); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK_EQ(0, status); + + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(0, st.rs_children); + ATF_CHECK_EQ(0, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(-1, st.rs_pid); +} + +ATF_TC_WITHOUT_HEAD(reaper_getpids); +ATF_TC_BODY(reaper_getpids, tc) +{ + struct procctl_reaper_pidinfo info[10]; + ssize_t sr; + pid_t parent, child, grandchild, pid; + int r, status, childidx; + int pipa[2], pipb[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(0, info[0].pi_flags & REAPER_PIDINFO_VALID); + + r = pipe(pipa); + ATF_REQUIRE_EQ(0, r); + r = pipe(pipb); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pipa[1]) != 0) + _exit(100); + if (close(pipb[0]) != 0) + _exit(100); + if (read(pipa[0], &(uint8_t){ 0 }, 1) != 1) + _exit(101); + grandchild = fork(); + if (grandchild == -1) + _exit(102); + if (grandchild == 0) { + if (write(pipb[1], &(uint8_t){ 0 }, 1) != 1) + _exit(103); + if (read(pipa[0], &(uint8_t){ 0 }, 1) != 1) + _exit(104); + _exit(0); + } + for (;;) + pause(); + } + r = close(pipa[0]); + ATF_REQUIRE_EQ(0, r); + r = close(pipb[1]); + ATF_REQUIRE_EQ(0, r); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID | REAPER_PIDINFO_CHILD, + info[0].pi_flags & (REAPER_PIDINFO_VALID | REAPER_PIDINFO_CHILD)); + ATF_CHECK_EQ(child, info[0].pi_pid); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + + sr = write(pipa[1], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + sr = read(pipb[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[2].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(child, info[1].pi_subtree); + childidx = info[1].pi_pid == child ? 1 : 0; + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[childidx].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(0, info[childidx ^ 1].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK(info[childidx].pi_pid == child); + grandchild = info[childidx ^ 1].pi_pid; + ATF_CHECK(grandchild > 0); + ATF_CHECK(grandchild != child); + ATF_CHECK(grandchild != parent); + + r = kill(child, SIGTERM); + ATF_REQUIRE_EQ(0, r); + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[0].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(grandchild, info[0].pi_pid); + + sr = write(pipa[1], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[0].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(grandchild, info[0].pi_pid); + + pid = waitpid(grandchild, &status, 0); + ATF_REQUIRE_EQ(grandchild, pid); + ATF_CHECK_EQ(0, status); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(0, info[0].pi_flags & REAPER_PIDINFO_VALID); + + r = close(pipa[1]); + ATF_REQUIRE_EQ(0, r); + r = close(pipb[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_badsig); +ATF_TC_BODY(reaper_kill_badsig, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = -1; + params.rk_flags = 0; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == EINVAL); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_sigzero); +ATF_TC_BODY(reaper_kill_sigzero, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = 0; + params.rk_flags = 0; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == EINVAL); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_empty); +ATF_TC_BODY(reaper_kill_empty, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = SIGTERM; + params.rk_flags = 0; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == ESRCH); + ATF_CHECK_EQ(0, params.rk_killed); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_normal); +ATF_TC_BODY(reaper_kill_normal, tc) +{ + struct procctl_reaper_kill params; + ssize_t sr; + pid_t parent, child, grandchild, pid; + int r, status; + int pip[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[0]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + if (grandchild == 0) { + if (write(pip[1], &(uint8_t){ 0 }, 1) != 1) + _exit(102); + for (;;) + pause(); + } + for (;;) + pause(); + } + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + sr = read(pip[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + params.rk_sig = SIGTERM; + params.rk_flags = 0; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(2, params.rk_killed); + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0); + ATF_CHECK(pid != parent); + ATF_CHECK(pid != child); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, reaper_wait_child_first); + ATF_TP_ADD_TC(tp, reaper_wait_grandchild_first); + ATF_TP_ADD_TC(tp, reaper_status); + ATF_TP_ADD_TC(tp, reaper_getpids); + ATF_TP_ADD_TC(tp, reaper_kill_badsig); + ATF_TP_ADD_TC(tp, reaper_kill_sigzero); + ATF_TP_ADD_TC(tp, reaper_kill_empty); + ATF_TP_ADD_TC(tp, reaper_kill_normal); + return (atf_no_error()); +} From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:04:11 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 93616C8446E; Mon, 26 Dec 2016 06:04:11 +0000 (UTC) (envelope-from ngie@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 62631F65; Mon, 26 Dec 2016 06:04:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ64Aw1033507; Mon, 26 Dec 2016 06:04:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ64Aae033506; Mon, 26 Dec 2016 06:04:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260604.uBQ64Aae033506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:04: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: r310562 - stable/10/usr.sbin/bsnmpd/tools/bsnmptools 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.23 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, 26 Dec 2016 06:04:11 -0000 Author: ngie Date: Mon Dec 26 06:04:10 2016 New Revision: 310562 URL: https://svnweb.freebsd.org/changeset/base/310562 Log: MFstable/11 r310561: MFC r310203: Clean up parse_ip(..) - Clean up trailing whitespace - Fix variable alignment Modified: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Mon Dec 26 06:02:45 2016 (r310561) +++ stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Mon Dec 26 06:04:10 2016 (r310562) @@ -603,9 +603,9 @@ parse_oid_string(struct snmp_toolinfo *s static int32_t parse_ip(struct snmp_value * value, char * val) { - uint32_t v; - int32_t i; char *endptr, *str; + int32_t i; + uint32_t v; str = val; for (i = 0; i < 4; i++) { @@ -617,8 +617,8 @@ parse_ip(struct snmp_value * value, char str = endptr + 1; value->v.ipaddress[i] = (uint8_t) v; } - value->syntax = SNMP_SYNTAX_IPADDRESS; + return (0); } From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:06:56 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 58CF5C8457D; Mon, 26 Dec 2016 06:06:56 +0000 (UTC) (envelope-from ngie@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 0DF991287; Mon, 26 Dec 2016 06:06:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ66tE9033719; Mon, 26 Dec 2016 06:06:55 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ66tqB033718; Mon, 26 Dec 2016 06:06:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260606.uBQ66tqB033718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:06:55 +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: r310564 - stable/10/usr.sbin/bsnmpd/modules/snmp_bridge 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.23 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, 26 Dec 2016 06:06:56 -0000 Author: ngie Date: Mon Dec 26 06:06:55 2016 New Revision: 310564 URL: https://svnweb.freebsd.org/changeset/base/310564 Log: MFstable/11 r310563: MFC r310196: Fix some minor typos with begemotBridgeTpLearnedEntryDiscards and begemotBridgeTpMaxAddresses Bump LAST-UPDATED for the MIB, per the change Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Mon Dec 26 06:05:47 2016 (r310563) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt Mon Dec 26 06:06:55 2016 (r310564) @@ -41,7 +41,7 @@ IMPORTS FROM BEGEMOT-MIB; begemotBridge MODULE-IDENTITY - LAST-UPDATED "200708060000Z" + LAST-UPDATED "201612170000Z" ORGANIZATION "Sofia University St. Kliment Ohridski" CONTACT-INFO " Shteryana Shopova @@ -56,6 +56,9 @@ begemotBridge MODULE-IDENTITY E-Mail: syrinx@FreeBSD.org" DESCRIPTION "The Begemot MIB for managing bridge interfaces." + REVISION "201612170000Z" + DESCRIPTION + "Address some minor typos and grammar mistakes." REVISION "200708060000Z" DESCRIPTION "Third revision adds begemotBridgeBasePortPrivate @@ -856,7 +859,7 @@ begemotBridgeTpLearnedEntryDiscards OBJE DESCRIPTION "The total number of Forwarding Database entries that would have been learnt, but have been discarded due to Forwarding - Address Table having reached it's maximum entries limit." + Address Table having reached its maximum entries limit." ::= { begemotBridgeTpEntry 1 } begemotBridgeTpAgingTime OBJECT-TYPE @@ -874,7 +877,7 @@ begemotBridgeTpMaxAddresses OBJECT-TYPE MAX-ACCESS read-write STATUS current DESCRIPTION - "The maximum number of entires that this bridge can + "The maximum number of entries that this bridge can learn in it's Forwarding Address Table and use for making forwarding decisions." ::= { begemotBridgeTpEntry 3 } From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:09:10 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 67774C84698; Mon, 26 Dec 2016 06:09:10 +0000 (UTC) (envelope-from ngie@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 267C915D5; Mon, 26 Dec 2016 06:09:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ699oN033921; Mon, 26 Dec 2016 06:09:09 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ699rf033920; Mon, 26 Dec 2016 06:09:09 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260609.uBQ699rf033920@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:09:09 +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: r310566 - stable/10/contrib/bsnmp/lib 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.23 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, 26 Dec 2016 06:09:10 -0000 Author: ngie Date: Mon Dec 26 06:09:09 2016 New Revision: 310566 URL: https://svnweb.freebsd.org/changeset/base/310566 Log: MFstable/11 r310565: MFC r310202: Clean up trailing and leading whitespace Fix variable type alignment in snmp_dialog(..) Modified: stable/10/contrib/bsnmp/lib/snmpclient.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpclient.c Mon Dec 26 06:08:20 2016 (r310565) +++ stable/10/contrib/bsnmp/lib/snmpclient.c Mon Dec 26 06:09:09 2016 (r310566) @@ -8,7 +8,7 @@ * * Author: Harti Brandt * Kendy Kutzner - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -17,7 +17,7 @@ * 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 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 @@ -1236,23 +1236,23 @@ snmp_send_packet(struct snmp_pdu * pdu) return (-1); } - pdu->request_id = snmp_next_reqid(&snmp_client); + pdu->request_id = snmp_next_reqid(&snmp_client); - b.asn_ptr = buf; - b.asn_len = snmp_client.txbuflen; - if (snmp_pdu_encode(pdu, &b)) { + b.asn_ptr = buf; + b.asn_len = snmp_client.txbuflen; + if (snmp_pdu_encode(pdu, &b)) { seterr(&snmp_client, "%s", strerror(errno)); free(buf); return (-1); } - if (snmp_client.dump_pdus) - snmp_pdu_dump(pdu); + if (snmp_client.dump_pdus) + snmp_pdu_dump(pdu); - if ((ret = send(snmp_client.fd, buf, b.asn_ptr - buf, 0)) == -1) { + if ((ret = send(snmp_client.fd, buf, b.asn_ptr - buf, 0)) == -1) { seterr(&snmp_client, "%s", strerror(errno)); free(buf); - return (-1); + return (-1); } free(buf); @@ -1269,7 +1269,7 @@ snmp_timeout(void * listentry_ptr) #if 0 warnx("snmp request %i timed out, attempt (%i/%i)", - listentry->reqid, listentry->retrycount, snmp_client.retries); + listentry->reqid, listentry->retrycount, snmp_client.retries); #endif listentry->retrycount++; @@ -1314,7 +1314,7 @@ snmp_pdu_send(struct snmp_pdu *pdu, snmp listentry->callback = func; listentry->arg = arg; listentry->retrycount=1; - listentry->timeout_id = + listentry->timeout_id = snmp_client.timeout_start(&snmp_client.timeout, snmp_timeout, listentry); @@ -1463,7 +1463,7 @@ snmp_receive_packet(struct snmp_pdu *pdu return (+1); } -static int +static int snmp_deliver_packet(struct snmp_pdu * resp) { struct sent_pdu *listentry; @@ -1548,7 +1548,7 @@ ok_getnext(const struct snmp_pdu * req, &resp->bindings[i].var)) { if (i != 0) warnx("SNMP GETNEXT: inconsistent table " - "response"); + "response"); return (0); } if (resp->version != SNMP_V1 && @@ -1654,7 +1654,7 @@ ok_set(const struct snmp_pdu * req, cons /* * Simple checks for response PDUs against request PDUs. Return values: 1=ok, - * 0=nosuchname or similar, -1=failure, -2=no response at all + * 0=nosuchname or similar, -1=failure, -2=no response at all */ int snmp_pdu_check(const struct snmp_pdu *req, @@ -1681,12 +1681,12 @@ snmp_pdu_check(const struct snmp_pdu *re int snmp_dialog(struct snmp_v1_pdu *req, struct snmp_v1_pdu *resp) { - u_int i; - int32_t reqid; - int ret; - struct timeval tv = snmp_client.timeout; + struct timeval tv = snmp_client.timeout; struct timeval end; struct snmp_pdu pdu; + u_int i; + int32_t reqid; + int ret; /* * Make a copy of the request and replace the syntaxes by NULL @@ -1698,11 +1698,11 @@ snmp_dialog(struct snmp_v1_pdu *req, str for (i = 0; i < pdu.nbindings; i++) pdu.bindings[i].syntax = SNMP_SYNTAX_NULL; } - - for (i = 0; i <= snmp_client.retries; i++) { + + for (i = 0; i <= snmp_client.retries; i++) { (void)gettimeofday(&end, NULL); timeradd(&end, &snmp_client.timeout, &end); - if ((reqid = snmp_send_packet(&pdu)) == -1) + if ((reqid = snmp_send_packet(&pdu)) == -1) return (-1); for (;;) { (void)gettimeofday(&tv, NULL); @@ -1717,16 +1717,16 @@ snmp_dialog(struct snmp_v1_pdu *req, str if (reqid == resp->request_id) return (0); /* not for us */ - (void)snmp_deliver_packet(resp); + (void)snmp_deliver_packet(resp); } if (ret < 0 && errno == EPIPE) /* stream closed */ return (-1); } - } + } errno = ETIMEDOUT; seterr(&snmp_client, "retry count exceeded"); - return (-1); + return (-1); } int From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:11: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 E7A51C84795; Mon, 26 Dec 2016 06:11:44 +0000 (UTC) (envelope-from ngie@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 B706D19B0; Mon, 26 Dec 2016 06:11:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ6BhXI034833; Mon, 26 Dec 2016 06:11:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ6Bhs6034832; Mon, 26 Dec 2016 06:11:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260611.uBQ6Bhs6034832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:11:43 +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: r310568 - stable/10/etc 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.23 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, 26 Dec 2016 06:11:45 -0000 Author: ngie Date: Mon Dec 26 06:11:43 2016 New Revision: 310568 URL: https://svnweb.freebsd.org/changeset/base/310568 Log: MFstable/11 r310567: MFC r310457: Clean up trailing whitespace No functional change Modified: stable/10/etc/snmpd.config Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/snmpd.config ============================================================================== --- stable/10/etc/snmpd.config Mon Dec 26 06:10:21 2016 (r310567) +++ stable/10/etc/snmpd.config Mon Dec 26 06:11:43 2016 (r310568) @@ -127,7 +127,7 @@ snmpEnableAuthenTraps = 2 # The following block creates a user with name "bsnmp" and sets privacy # and encryption options to SHA256 message digests and AES encryption # for this user. -# +# # usmUserStatus.$(engine).$(user1) = 5 # usmUserAuthProtocol.$(engine).$(user1) = $(HMACSHAAuthProtocol) # usmUserAuthKeyChange.$(engine).$(user1) = $(user1passwd) @@ -170,7 +170,7 @@ snmpEnableAuthenTraps = 2 # vacmSecurityToGroupStatus.$(securityModelUSM).$(read) = 4 # vacmGroupName.$(securityModelUSM).$(read) = $(write) -# +# # The OID of the .iso.org.dod.internet subtree # # internetoid := 1.3.6.1 @@ -193,7 +193,7 @@ snmpEnableAuthenTraps = 2 # vacmAccessReadViewName.$(read)."".$(securityModelSNMPv1).$(noAuthNoPriv) = "internet" # -# Read-write access for SNMPv2 users +# Read-write access for SNMPv2 users # # vacmAccessStatus.$(write)."".$(securityModelSNMPv2c).$(noAuthNoPriv) = 4 # vacmAccessReadViewName.$(write)."".$(securityModelSNMPv2c).$(noAuthNoPriv) = "internet" From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:25:43 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 D5DBFC84CEF; Mon, 26 Dec 2016 06:25:43 +0000 (UTC) (envelope-from ngie@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 6CCCF1F5; Mon, 26 Dec 2016 06:25:43 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ6Pgpl041783; Mon, 26 Dec 2016 06:25:42 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ6Pd3l041756; Mon, 26 Dec 2016 06:25:39 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260625.uBQ6Pd3l041756@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:25:39 +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: r310570 - in stable/10/contrib/libarchive: cpio/test libarchive/test tar/test 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.23 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, 26 Dec 2016 06:25:43 -0000 Author: ngie Date: Mon Dec 26 06:25:39 2016 New Revision: 310570 URL: https://svnweb.freebsd.org/changeset/base/310570 Log: MFstable/11 r310569: MFC r309869: Merge changes from vendor to address several Coverity issues with contrib/libarchive's tests Obtained from: libarchive (ebe29c, fd0ea2, f9e3de) Modified: stable/10/contrib/libarchive/cpio/test/test_option_J_upper.c stable/10/contrib/libarchive/cpio/test/test_option_Z_upper.c stable/10/contrib/libarchive/cpio/test/test_option_u.c stable/10/contrib/libarchive/cpio/test/test_option_y.c stable/10/contrib/libarchive/libarchive/test/read_open_memory.c stable/10/contrib/libarchive/libarchive/test/test_fuzz.c stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c stable/10/contrib/libarchive/tar/test/main.c stable/10/contrib/libarchive/tar/test/test_leading_slash.c stable/10/contrib/libarchive/tar/test/test_option_a.c stable/10/contrib/libarchive/tar/test/test_option_b.c stable/10/contrib/libarchive/tar/test/test_option_b64encode.c stable/10/contrib/libarchive/tar/test/test_option_gid_gname.c stable/10/contrib/libarchive/tar/test/test_option_grzip.c stable/10/contrib/libarchive/tar/test/test_option_j.c stable/10/contrib/libarchive/tar/test/test_option_lrzip.c stable/10/contrib/libarchive/tar/test/test_option_lz4.c stable/10/contrib/libarchive/tar/test/test_option_lzma.c stable/10/contrib/libarchive/tar/test/test_option_lzop.c stable/10/contrib/libarchive/tar/test/test_option_r.c stable/10/contrib/libarchive/tar/test/test_option_uid_uname.c stable/10/contrib/libarchive/tar/test/test_option_uuencode.c stable/10/contrib/libarchive/tar/test/test_option_xz.c stable/10/contrib/libarchive/tar/test/test_option_z.c stable/10/contrib/libarchive/tar/test/test_stdio.c stable/10/contrib/libarchive/tar/test/test_version.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libarchive/cpio/test/test_option_J_upper.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_option_J_upper.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/cpio/test/test_option_J_upper.c Mon Dec 26 06:25:39 2016 (r310570) @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_J_upper) } failure("-J option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an xz signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\3757zXZ", 5); +done: + free(p); } Modified: stable/10/contrib/libarchive/cpio/test/test_option_Z_upper.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_option_Z_upper.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/cpio/test/test_option_Z_upper.c Mon Dec 26 06:25:39 2016 (r310570) @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_Z_upper) } failure("-Z option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has a compress signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x1f\x9d", 2); +done: + free(p); } Modified: stable/10/contrib/libarchive/cpio/test/test_option_u.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_option_u.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/cpio/test/test_option_u.c Mon Dec 26 06:25:39 2016 (r310570) @@ -49,6 +49,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Recreate the file with a single "b" */ assertMakeFile("f", 0644, "b"); @@ -68,6 +69,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Copy the file to the "copy" dir with -u (force) */ r = systemf("echo f| %s -pud copy >copy.out 2>copy.err", @@ -78,4 +80,5 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "b", 1); + free(p); } Modified: stable/10/contrib/libarchive/cpio/test/test_option_y.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_option_y.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/cpio/test/test_option_y.c Mon Dec 26 06:25:39 2016 (r310570) @@ -46,11 +46,14 @@ DEFINE_TEST(test_option_y) } failure("-y option is broken"); assertEqualInt(r, 0); - return; + goto done; } assertTextFileContents("1 block\n", "archive.err"); /* Check that the archive file has a bzip2 signature. */ + free(p); p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "BZh9", 4); +done: + free(p); } Modified: stable/10/contrib/libarchive/libarchive/test/read_open_memory.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/read_open_memory.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/libarchive/test/read_open_memory.c Mon Dec 26 06:25:39 2016 (r310570) @@ -86,21 +86,7 @@ static int read_open_memory_internal(struct archive *a, const void *buff, size_t size, size_t read_size, int level) { - struct read_memory_data *mine; - - mine = (struct read_memory_data *)malloc(sizeof(*mine)); - if (mine == NULL) { - archive_set_error(a, ENOMEM, "No memory"); - return (ARCHIVE_FATAL); - } - memset(mine, 0, sizeof(*mine)); - mine->start = mine->p = (const unsigned char *)buff; - mine->end = mine->start + size; - mine->read_size = read_size; - mine->copy_buff_offset = 32; - mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; - mine->copy_buff = malloc(mine->copy_buff_size); - memset(mine->copy_buff, 0xA5, mine->copy_buff_size); + struct read_memory_data *mine = NULL; switch (level) { case 3: @@ -109,6 +95,20 @@ read_open_memory_internal(struct archive archive_read_set_open_callback(a, memory_read_open); archive_read_set_skip_callback(a, memory_read_skip); case 1: + mine = malloc(sizeof(*mine)); + if (mine == NULL) { + archive_set_error(a, ENOMEM, "No memory"); + return (ARCHIVE_FATAL); + } + memset(mine, 0, sizeof(*mine)); + mine->start = mine->p = (const unsigned char *)buff; + mine->end = mine->start + size; + mine->read_size = read_size; + mine->copy_buff_offset = 32; + mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; + mine->copy_buff = malloc(mine->copy_buff_size); + memset(mine->copy_buff, 0xA5, mine->copy_buff_size); + archive_read_set_read_callback(a, memory_read); archive_read_set_close_callback(a, memory_read_close); archive_read_set_callback_data(a, mine); @@ -213,7 +213,8 @@ memory_read_close(struct archive *a, voi { struct read_memory_data *mine = (struct read_memory_data *)client_data; (void)a; /* UNUSED */ - free(mine->copy_buff); + if (mine != NULL) + free(mine->copy_buff); free(mine); return (ARCHIVE_OK); } Modified: stable/10/contrib/libarchive/libarchive/test/test_fuzz.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_fuzz.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/libarchive/test/test_fuzz.c Mon Dec 26 06:25:39 2016 (r310570) @@ -104,16 +104,19 @@ test_fuzz(const struct files *filesets) } if (!assert(size < buffsize)) { free(rawimage); + rawimage = NULL; continue; } } else { for (i = 0; filesets[n].names[i] != NULL; ++i) { tmp = slurpfile(&size, filesets[n].names[i]); - char *newraw = (char *)realloc(rawimage, oldsize + size); + char *newraw = realloc(rawimage, oldsize + size); if (!assert(newraw != NULL)) { free(rawimage); + rawimage = NULL; + free(tmp); continue; } rawimage = newraw; @@ -123,14 +126,21 @@ test_fuzz(const struct files *filesets) free(tmp); } } - if (size == 0) + if (size == 0) { + free(rawimage); + rawimage = NULL; continue; + } image = malloc(size); assert(image != NULL); if (image == NULL) { free(rawimage); + rawimage = NULL; return; } + + assert(rawimage != NULL); + srand((unsigned)time(NULL)); for (i = 0; i < 1000; ++i) { @@ -162,6 +172,7 @@ test_fuzz(const struct files *filesets) Sleep(100); #endif } + assert(f != NULL); assertEqualInt((size_t)size, fwrite(image, 1, (size_t)size, f)); fclose(f); @@ -195,7 +206,7 @@ test_fuzz(const struct files *filesets) archive_read_close(a); } archive_read_free(a); -} + } free(image); free(rawimage); } Modified: stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c Mon Dec 26 06:25:39 2016 (r310570) @@ -1327,6 +1327,7 @@ test_callbacks(void) if (assert((m = archive_match_new()) != NULL)) { archive_entry_free(ae); archive_read_free(a); + archive_match_free(m); return; } Modified: stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Mon Dec 26 06:25:39 2016 (r310570) @@ -219,8 +219,8 @@ DEFINE_TEST(test_read_append_filter_wron /* bunzip2 will write to stderr, redirect it to a file */ fflush(stderr); fgetpos(stderr, &pos); - fd = dup(fileno(stderr)); - fp = freopen("stderr1", "w", stderr); + assert((fd = dup(fileno(stderr))) != -1); + fp = freopen("stderr1", "w", stderr); #endif assert((a = archive_read_new()) != NULL); @@ -238,10 +238,10 @@ DEFINE_TEST(test_read_append_filter_wron if (fp != NULL) { fflush(stderr); dup2(fd, fileno(stderr)); - close(fd); clearerr(stderr); - fsetpos(stderr, &pos); + (void)fsetpos(stderr, &pos); } + close(fd); assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); #endif } Modified: stable/10/contrib/libarchive/tar/test/main.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/main.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/main.c Mon Dec 26 06:25:39 2016 (r310570) @@ -1060,7 +1060,7 @@ assertion_file_contains_lines_any_order( char **expected = NULL; char *p, **actual = NULL; char c; - int expected_failure = 0, actual_failure = 0; + int expected_failure = 0, actual_failure = 0, retval = 0; assertion_count(file, line); @@ -1081,8 +1081,7 @@ assertion_file_contains_lines_any_order( if (expected == NULL) { failure_start(pathname, line, "Can't allocate memory"); failure_finish(NULL); - free(expected); - return (0); + goto done; } for (i = 0; lines[i] != NULL; ++i) { expected[i] = strdup(lines[i]); @@ -1103,8 +1102,7 @@ assertion_file_contains_lines_any_order( if (actual == NULL) { failure_start(pathname, line, "Can't allocate memory"); failure_finish(NULL); - free(expected); - return (0); + goto done; } for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) { @@ -1141,27 +1139,27 @@ assertion_file_contains_lines_any_order( ++actual_failure; } if (expected_failure == 0 && actual_failure == 0) { - free(buff); - free(expected); - free(actual); - return (1); + retval = 1; + goto done; } failure_start(file, line, "File doesn't match: %s", pathname); for (i = 0; i < expected_count; ++i) { - if (expected[i] != NULL) { + if (expected[i] != NULL) logprintf(" Expected but not present: %s\n", expected[i]); - free(expected[i]); - } } for (j = 0; j < actual_count; ++j) { if (actual[j] != NULL) logprintf(" Present but not expected: %s\n", actual[j]); } failure_finish(NULL); +done: + free(actual); free(buff); + for (i = 0; i < expected_count; ++i) + free(expected[i]); free(expected); - free(actual); - return (0); + + return (retval); } /* Verify that a text file does not contains the specified strings */ @@ -1590,7 +1588,7 @@ is_symlink(const char *file, int line, * really not much point in bothering with this. */ return (0); #else - char buff[300]; + char buff[301]; struct stat st; ssize_t linklen; int r; @@ -1607,7 +1605,7 @@ is_symlink(const char *file, int line, return (0); if (contents == NULL) return (1); - linklen = readlink(pathname, buff, sizeof(buff)); + linklen = readlink(pathname, buff, sizeof(buff) - 1); if (linklen < 0) { failure_start(file, line, "Can't read symlink %s", pathname); failure_finish(NULL); @@ -2324,7 +2322,7 @@ extract_reference_file(const char *name) for (;;) { if (fgets(buff, sizeof(buff), in) == NULL) { /* TODO: This is a failure. */ - return; + goto done; } if (memcmp(buff, "begin ", 6) == 0) break; @@ -2365,6 +2363,7 @@ extract_reference_file(const char *name) } } fclose(out); +done: fclose(in); } @@ -2958,8 +2957,8 @@ main(int argc, char **argv) strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp), "%Y-%m-%dT%H.%M.%S", localtime(&now)); - sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname, - tmpdir_timestamp, i); + snprintf(tmpdir, sizeof(tmpdir), "%s/%s.%s-%03d", tmp, + progname, tmpdir_timestamp, i); if (assertMakeDir(tmpdir,0755)) break; if (i >= 999) { Modified: stable/10/contrib/libarchive/tar/test/test_leading_slash.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_leading_slash.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_leading_slash.c Mon Dec 26 06:25:39 2016 (r310570) @@ -44,6 +44,7 @@ DEFINE_TEST(test_leading_slash) if (assertFileExists("test.err")) { errfile = slurpfile(&errfile_size, "test.err"); assert(strstr(errfile, expected_errmsg) != NULL); + free(errfile); } } Modified: stable/10/contrib/libarchive/tar/test/test_option_a.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_a.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_a.c Mon Dec 26 06:25:39 2016 (r310570) @@ -43,6 +43,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test2: archive it with .taZ suffix. */ assertEqualInt(0, @@ -53,6 +54,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test3: archive it with .tar.Z.uu suffix. */ assertEqualInt(0, @@ -63,6 +65,7 @@ DEFINE_TEST(test_option_a) assert(s > 12); failure("The archive should be uuencoded"); assertEqualMem(p, "begin 644 -\n", 12); + free(p); /* Test4: archive it with .zip suffix. */ assertEqualInt(0, @@ -73,6 +76,7 @@ DEFINE_TEST(test_option_a) assert(s > 4); failure("The archive should be zipped"); assertEqualMem(p, "\x50\x4b\x03\x04", 4); + free(p); /* Test5: archive it with .tar.Z suffix and --uuencode option. */ assertEqualInt(0, @@ -84,6 +88,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed, ignoring --uuencode option"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test6: archive it with .xxx suffix(unknown suffix) and * --uuencode option. */ @@ -96,6 +101,7 @@ DEFINE_TEST(test_option_a) assert(s > 12); failure("The archive should be uuencoded"); assertEqualMem(p, "begin 644 -\n", 12); + free(p); /* Test7: archive it with .tar.Z suffix using a long-name option. */ assertEqualInt(0, @@ -107,4 +113,5 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_b.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_b.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_b.c Mon Dec 26 06:25:39 2016 (r310570) @@ -78,4 +78,6 @@ DEFINE_TEST(test_option_b) * Note: It's not possible to verify at this level that blocks * are getting written with the */ + + free(testprog_ustar); } Modified: stable/10/contrib/libarchive/tar/test/test_option_b64encode.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_b64encode.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_b64encode.c Mon Dec 26 06:25:39 2016 (r310570) @@ -42,6 +42,7 @@ DEFINE_TEST(test_option_b64encode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin-base64 644", 16); + free(p); /* Archive it with uuencode only. */ assertEqualInt(0, @@ -51,4 +52,5 @@ DEFINE_TEST(test_option_b64encode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin-base64 644", 16); + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_gid_gname.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_gid_gname.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_gid_gname.c Mon Dec 26 06:25:39 2016 (r310570) @@ -53,6 +53,7 @@ DEFINE_TEST(test_option_gid_gname) /* Should force gid and gname fields in ustar header. */ assertEqualMem(data + 116, "000021 \0", 8); assertEqualMem(data + 297, "foofoofoo\0", 10); + free(data); /* Again with just --gname */ failure("Error invoking %s c", testprog); @@ -65,6 +66,8 @@ DEFINE_TEST(test_option_gid_gname) /* Gid should be unchanged from original reference. */ assertEqualMem(data + 116, reference + 116, 8); assertEqualMem(data + 297, "foofoofoo\0", 10); + free(data); + free(reference); /* Again with --gid and force gname to empty. */ failure("Error invoking %s c", testprog); @@ -77,6 +80,7 @@ DEFINE_TEST(test_option_gid_gname) assertEqualMem(data + 116, "000021 \0", 8); /* Gname field in ustar header should be empty. */ assertEqualMem(data + 297, "\0", 1); + free(data); /* TODO: It would be nice to verify that --gid= by itself * will look up the associated gname and use that, but Modified: stable/10/contrib/libarchive/tar/test/test_option_grzip.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_grzip.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_grzip.c Mon Dec 26 06:25:39 2016 (r310570) @@ -45,8 +45,11 @@ DEFINE_TEST(test_option_grzip) testprog)); p = slurpfile(&s, "archive.err"); p[s] = '\0'; + free(p); + /* Check that the archive file has an grzip signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12); + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_j.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_j.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_j.c Mon Dec 26 06:25:39 2016 (r310570) @@ -42,15 +42,18 @@ DEFINE_TEST(test_option_j) if (r != 0) { if (!canBzip2()) { skipping("bzip2 is not supported on this platform"); - return; + goto done; } failure("-j option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); assertEmptyFile("archive.err"); /* Check that the archive file has a bzip2 signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "BZh9", 4); +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_lrzip.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_lrzip.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_lrzip.c Mon Dec 26 06:25:39 2016 (r310570) @@ -45,8 +45,10 @@ DEFINE_TEST(test_option_lrzip) testprog)); p = slurpfile(&s, "archive.err"); p[s] = '\0'; + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "LRZI\x00", 5); + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_lz4.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_lz4.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_lz4.c Mon Dec 26 06:25:39 2016 (r310570) @@ -43,7 +43,7 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Unsupported compression") != NULL) { skipping("This version of bsdtar was compiled " "without lz4 support"); - return; + goto done; } /* POSIX permits different handling of the spawnp * system call used to launch the subsidiary @@ -52,7 +52,7 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Can't launch") != NULL && !canLz4()) { skipping("This version of bsdtar uses an external lz4 program " "but no such program is available on this system."); - return; + goto done; } /* Some systems successfully spawn the new process, * but fail to exec a program within that process. @@ -61,14 +61,18 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Can't write") != NULL && !canLz4()) { skipping("This version of bsdtar uses an external lz4 program " "but no such program is available on this system."); - return; + goto done; } failure("--lz4 option is broken: %s", p); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lz4 signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x04\x22\x4d\x18", 4); + +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_lzma.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_lzma.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_lzma.c Mon Dec 26 06:25:39 2016 (r310570) @@ -48,10 +48,13 @@ DEFINE_TEST(test_option_lzma) } failure("--lzma option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x5d\00\00", 3); +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_lzop.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_lzop.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_lzop.c Mon Dec 26 06:25:39 2016 (r310570) @@ -42,14 +42,17 @@ DEFINE_TEST(test_option_lzop) if (r != 0) { if (!canLzop()) { skipping("lzop is not supported on this platform"); - return; + goto done; } failure("--lzop option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9); +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_r.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_r.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_r.c Mon Dec 26 06:25:39 2016 (r310570) @@ -36,6 +36,10 @@ DEFINE_TEST(test_option_r) size_t s, buff_size_rounded; int r, i; + buff = NULL; + p0 = NULL; + p1 = NULL; + /* Create an archive with one file. */ assertMakeFile("f1", 0644, "abc"); r = systemf("%s cf archive.tar --format=ustar f1 >step1.out 2>step1.err", testprog); @@ -47,11 +51,9 @@ DEFINE_TEST(test_option_r) /* Do some basic validation of the constructed archive. */ p0 = slurpfile(&s, "archive.tar"); if (!assert(p0 != NULL)) - return; - if (!assert(s >= 2048)) { - free(p0); - return; - } + goto done; + if (!assert(s >= 2048)) + goto done; assertEqualMem(p0 + 0, "f1", 3); assertEqualMem(p0 + 512, "abc", 3); assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8); @@ -60,10 +62,8 @@ DEFINE_TEST(test_option_r) /* Edit that file with a lot more data and update the archive with a new copy. */ buff = malloc(buff_size); assert(buff != NULL); - if (buff == NULL) { - free(p0); - return; - } + if (buff == NULL) + goto done; for (i = 0; i < (int)buff_size; ++i) buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26]; @@ -77,10 +77,8 @@ DEFINE_TEST(test_option_r) /* The constructed archive should just have the new entry appended. */ p1 = slurpfile(&s, "archive.tar"); - if (!assert(p1 != NULL)) { - free(p0); - return; - } + if (!assert(p1 != NULL)) + goto done; buff_size_rounded = ((buff_size + 511) / 512) * 512; assert(s >= 2560 + buff_size_rounded); /* Verify first entry is unchanged. */ @@ -105,10 +103,8 @@ DEFINE_TEST(test_option_r) /* Validate the constructed archive. */ p1 = slurpfile(&s, "archive.tar"); - if (!assert(p1 != NULL)) { - free(p0); - return; - } + if (!assert(p1 != NULL)) + goto done; assert(s >= 3584 + buff_size_rounded); /* Verify first two entries are unchanged. */ assertEqualMem(p0, p1, 1536 + buff_size_rounded); @@ -118,7 +114,6 @@ DEFINE_TEST(test_option_r) /* Verify end-of-archive marker. */ assertEqualMem(p1 + 2560 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8); assertEqualMem(p1 + 3072 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8); - free(p0); free(p1); /* Unpack everything */ @@ -132,4 +127,7 @@ DEFINE_TEST(test_option_r) /* Verify that the second copy of f1 overwrote the first. */ assertFileContents(buff, (int)strlen(buff), "f1"); +done: + free(buff); + free(p0); } Modified: stable/10/contrib/libarchive/tar/test/test_option_uid_uname.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_uid_uname.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_uid_uname.c Mon Dec 26 06:25:39 2016 (r310570) @@ -53,6 +53,7 @@ DEFINE_TEST(test_option_uid_uname) /* Should force uid and uname fields in ustar header. */ assertEqualMem(data + 108, "000021 \0", 8); assertEqualMem(data + 265, "foofoofoo\0", 10); + free(data); /* Again with just --uid */ failure("Error invoking %s c", testprog); @@ -65,6 +66,7 @@ DEFINE_TEST(test_option_uid_uname) assertEqualMem(data + 108, "000021 \0", 8); /* Uname field in ustar header should be empty. */ assertEqualMem(data + 265, "\0", 1); + free(data); /* Again with just --uname */ failure("Error invoking %s c", testprog); @@ -77,4 +79,7 @@ DEFINE_TEST(test_option_uid_uname) /* Uid should be unchanged from original reference. */ assertEqualMem(data + 108, reference + 108, 8); assertEqualMem(data + 265, "foofoofoo\0", 10); + free(data); + + free(reference); } Modified: stable/10/contrib/libarchive/tar/test/test_option_uuencode.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_uuencode.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_uuencode.c Mon Dec 26 06:25:39 2016 (r310570) @@ -42,6 +42,7 @@ DEFINE_TEST(test_option_uuencode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin 644", 9); + free(p); /* Archive it with uuencode only. */ assertEqualInt(0, @@ -51,4 +52,5 @@ DEFINE_TEST(test_option_uuencode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin 644", 9); + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_xz.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_xz.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_xz.c Mon Dec 26 06:25:39 2016 (r310570) @@ -44,14 +44,17 @@ DEFINE_TEST(test_option_xz) if (strstr(p, "Unsupported compression") != NULL) { skipping("This version of bsdtar was compiled " "without xz support"); - return; + goto done; } failure("--xz option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an xz signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6); +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_option_z.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_z.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_option_z.c Mon Dec 26 06:25:39 2016 (r310570) @@ -42,14 +42,17 @@ DEFINE_TEST(test_option_z) if (r != 0) { if (!canGzip()) { skipping("gzip is not supported on this platform"); - return; + goto done; } failure("-z option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has a gzip signature. */ p = slurpfile(&s, "archive.out"); assert(s > 4); assertEqualMem(p, "\x1f\x8b\x08\x00", 4); +done: + free(p); } Modified: stable/10/contrib/libarchive/tar/test/test_stdio.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_stdio.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_stdio.c Mon Dec 26 06:25:39 2016 (r310570) @@ -116,6 +116,7 @@ DEFINE_TEST(test_stdio) assertEqualInt((int)s, 3); assertEqualMem(p, "abc", 3); /* TODO: Verify xvf.err */ + free(p); /* 'xvf -' should generate list on stderr, empty stdout. */ r = systemf("%s xvf - < archive >xvf-.out 2>xvf-.err", testprog); Modified: stable/10/contrib/libarchive/tar/test/test_version.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_version.c Mon Dec 26 06:16:27 2016 (r310569) +++ stable/10/contrib/libarchive/tar/test/test_version.c Mon Dec 26 06:25:39 2016 (r310570) @@ -53,7 +53,7 @@ DEFINE_TEST(test_version) assert(s > 6); failure("Version must start with 'bsdtar': ``%s''", p); if (!assertEqualMem(q, "bsdtar ", 7)) - return; + goto done; q += 7; s -= 7; /* Version number is a series of digits and periods. */ while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) { @@ -98,5 +98,6 @@ DEFINE_TEST(test_version) failure("Version output must end with \\n or \\r\\n"); if (*q == '\r') { ++q; --s; } assertEqualMem(q, "\n", 1); +done: free(p); } From owner-svn-src-stable-10@freebsd.org Mon Dec 26 06:33: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 9E915C91164; Mon, 26 Dec 2016 06:33:44 +0000 (UTC) (envelope-from ngie@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 6D954B7F; Mon, 26 Dec 2016 06:33:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQ6XhQr045720; Mon, 26 Dec 2016 06:33:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQ6XhIk045719; Mon, 26 Dec 2016 06:33:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612260633.uBQ6XhIk045719@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 26 Dec 2016 06:33:43 +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: r310572 - stable/10/contrib/bsnmp/snmpd 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.23 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, 26 Dec 2016 06:33:44 -0000 Author: ngie Date: Mon Dec 26 06:33:43 2016 New Revision: 310572 URL: https://svnweb.freebsd.org/changeset/base/310572 Log: MFstable/11 r310571: MFC r310459: Sort #includes per style(9) No functional change Modified: stable/10/contrib/bsnmp/snmpd/action.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/action.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/action.c Mon Dec 26 06:32:42 2016 (r310571) +++ stable/10/contrib/bsnmp/snmpd/action.c Mon Dec 26 06:33:43 2016 (r310572) @@ -38,12 +38,12 @@ #include #include #include +#include +#include +#include #include #include -#include #include -#include -#include #include #include "snmpmod.h" From owner-svn-src-stable-10@freebsd.org Mon Dec 26 10:13:54 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 6901CC906CB; Mon, 26 Dec 2016 10:13:54 +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 2D773CAB; Mon, 26 Dec 2016 10:13:54 +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 uBQADrqM035437; Mon, 26 Dec 2016 10:13:53 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQADrGG035436; Mon, 26 Dec 2016 10:13:53 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612261013.uBQADrGG035436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Dec 2016 10:13:53 +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: r310584 - stable/10/sys/kern 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.23 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, 26 Dec 2016 10:13:54 -0000 Author: kib Date: Mon Dec 26 10:13:53 2016 New Revision: 310584 URL: https://svnweb.freebsd.org/changeset/base/310584 Log: MFC r310302: Do not clear KN_INFLUX when not owning influx state. PR: 214923 Modified: stable/10/sys/kern/kern_event.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_event.c ============================================================================== --- stable/10/sys/kern/kern_event.c Mon Dec 26 10:03:33 2016 (r310583) +++ stable/10/sys/kern/kern_event.c Mon Dec 26 10:13:53 2016 (r310584) @@ -1935,6 +1935,7 @@ knote(struct knlist *list, long hint, in struct kqueue *kq; struct knote *kn, *tkn; int error; + bool own_influx; if (list == NULL) return; @@ -1965,11 +1966,14 @@ knote(struct knlist *list, long hint, in */ KQ_UNLOCK(kq); } else if ((lockflags & KNF_NOKQLOCK) != 0) { - kn->kn_status |= KN_INFLUX; + own_influx = (kn->kn_status & KN_INFLUX) == 0; + if (own_influx) + kn->kn_status |= KN_INFLUX; KQ_UNLOCK(kq); error = kn->kn_fop->f_event(kn, hint); KQ_LOCK(kq); - kn->kn_status &= ~KN_INFLUX; + if (own_influx) + kn->kn_status &= ~KN_INFLUX; if (error) KNOTE_ACTIVATE(kn, 1); KQ_UNLOCK_FLUX(kq); From owner-svn-src-stable-10@freebsd.org Mon Dec 26 10:16: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 A9696C907C3; Mon, 26 Dec 2016 10:16: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 78A20E9E; Mon, 26 Dec 2016 10:16: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 uBQAG5KJ035581; Mon, 26 Dec 2016 10:16:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQAG563035580; Mon, 26 Dec 2016 10:16:05 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612261016.uBQAG563035580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Dec 2016 10:16: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: r310585 - stable/10/sys/kern 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.23 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, 26 Dec 2016 10:16:06 -0000 Author: kib Date: Mon Dec 26 10:16:05 2016 New Revision: 310585 URL: https://svnweb.freebsd.org/changeset/base/310585 Log: MFC r309886: When a zombie gets reparented due to the parent exit, send SIGCHLD to the reaper. Modified: stable/10/sys/kern/kern_exit.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exit.c ============================================================================== --- stable/10/sys/kern/kern_exit.c Mon Dec 26 10:13:53 2016 (r310584) +++ stable/10/sys/kern/kern_exit.c Mon Dec 26 10:16:05 2016 (r310585) @@ -499,6 +499,11 @@ exit1(struct thread *td, int rv) if (!(q->p_flag & P_TRACED)) { proc_reparent(q, q->p_reaper); + if (q->p_state == PRS_ZOMBIE) { + PROC_LOCK(q->p_reaper); + pksignal(q->p_reaper, SIGCHLD, q->p_ksi); + PROC_UNLOCK(q->p_reaper); + } } else { /* * Traced processes are killed since their existence From owner-svn-src-stable-10@freebsd.org Mon Dec 26 16:43: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 54A9BC91E13; Mon, 26 Dec 2016 16:43:41 +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 F2E5A1F74; Mon, 26 Dec 2016 16:43:40 +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 uBQGheRN099807; Mon, 26 Dec 2016 16:43:40 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQGhexl099806; Mon, 26 Dec 2016 16:43:40 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201612261643.uBQGhexl099806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 26 Dec 2016 16:43: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: r310606 - stable/10/bin/pax 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.23 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, 26 Dec 2016 16:43:41 -0000 Author: pfg Date: Mon Dec 26 16:43:39 2016 New Revision: 310606 URL: https://svnweb.freebsd.org/changeset/base/310606 Log: MFC r310367: pax(1): Fix a bug with archives smaller than 512 bytes. The problem here is that the archive is too short (< 512 bytes). The buffer routines, try to read at least 512 bytes, even when we try to determine what format file we have, which is wrong. Obtained from: NetBSD (CVS rev 1.26) Modified: stable/10/bin/pax/buf_subs.c Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/pax/buf_subs.c ============================================================================== --- stable/10/bin/pax/buf_subs.c Mon Dec 26 16:42:38 2016 (r310605) +++ stable/10/bin/pax/buf_subs.c Mon Dec 26 16:43:39 2016 (r310606) @@ -852,10 +852,13 @@ buf_fill(void) /* * errors require resync, EOF goes to next archive + * but in case we have not determined yet the format, + * this means that we have a very short file, so we + * are done again. */ if (cnt < 0) break; - if (ar_next() < 0) { + if (frmt == NULL || ar_next() < 0) { fini = 1; return(0); } From owner-svn-src-stable-10@freebsd.org Mon Dec 26 17:26: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 AD2A6C92C50; Mon, 26 Dec 2016 17:26:26 +0000 (UTC) (envelope-from jilles@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 6DBA11612; Mon, 26 Dec 2016 17:26:26 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQHQPVr017603; Mon, 26 Dec 2016 17:26:25 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQHQPbp017602; Mon, 26 Dec 2016 17:26:25 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201612261726.uBQHQPbp017602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Mon, 26 Dec 2016 17:26: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: r310610 - stable/10/tests/sys/kern 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.23 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, 26 Dec 2016 17:26:26 -0000 Author: jilles Date: Mon Dec 26 17:26:25 2016 New Revision: 310610 URL: https://svnweb.freebsd.org/changeset/base/310610 Log: MFC r309957: Add tests for reaper receiving SIGCHLD (r309886). PR: 213928 Modified: stable/10/tests/sys/kern/reaper.c Directory Properties: stable/10/ (props changed) Modified: stable/10/tests/sys/kern/reaper.c ============================================================================== --- stable/10/tests/sys/kern/reaper.c Mon Dec 26 17:23:09 2016 (r310609) +++ stable/10/tests/sys/kern/reaper.c Mon Dec 26 17:26:25 2016 (r310610) @@ -35,6 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +static void +dummy_sighandler(int sig __unused, siginfo_t *info __unused, void *ctx __unused) +{ +} + ATF_TC_WITHOUT_HEAD(reaper_wait_child_first); ATF_TC_BODY(reaper_wait_child_first, tc) { @@ -129,6 +134,161 @@ ATF_TC_BODY(reaper_wait_grandchild_first ATF_CHECK_EQ(2, r); } +ATF_TC(reaper_sigchld_child_first); +ATF_TC_HEAD(reaper_sigchld_child_first, tc) +{ + atf_tc_set_md_var(tc, "timeout", "2"); +} +ATF_TC_BODY(reaper_sigchld_child_first, tc) +{ + struct sigaction act; + sigset_t mask; + siginfo_t info; + pid_t parent, child, grandchild, pid; + int r; + int pip[2]; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + act.sa_sigaction = dummy_sighandler; + act.sa_flags = SA_SIGINFO | SA_RESTART; + r = sigemptyset(&act.sa_mask); + ATF_REQUIRE_EQ(0, r); + r = sigaction(SIGCHLD, &act, NULL); + ATF_REQUIRE_EQ(0, r); + + r = sigemptyset(&mask); + ATF_REQUIRE_EQ(0, r); + r = sigaddset(&mask, SIGCHLD); + ATF_REQUIRE_EQ(0, r); + r = sigprocmask(SIG_BLOCK, &mask, NULL); + ATF_REQUIRE_EQ(0, r); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[1]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) { + if (read(pip[0], &(uint8_t){ 0 }, 1) != 0) + _exit(102); + if (getppid() != parent) + _exit(103); + _exit(2); + } else + _exit(3); + } + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(3, info.si_status); + ATF_CHECK_EQ(child, info.si_pid); + + pid = waitpid(child, NULL, 0); + ATF_REQUIRE_EQ(child, pid); + + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(2, info.si_status); + grandchild = info.si_pid; + ATF_REQUIRE(grandchild > 0); + ATF_REQUIRE(grandchild != parent); + ATF_REQUIRE(grandchild != child); + + pid = waitpid(-1, NULL, 0); + ATF_REQUIRE_EQ(grandchild, pid); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC(reaper_sigchld_grandchild_first); +ATF_TC_HEAD(reaper_sigchld_grandchild_first, tc) +{ + atf_tc_set_md_var(tc, "timeout", "2"); +} +ATF_TC_BODY(reaper_sigchld_grandchild_first, tc) +{ + struct sigaction act; + sigset_t mask; + siginfo_t info; + pid_t parent, child, grandchild, pid; + int r; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + act.sa_sigaction = dummy_sighandler; + act.sa_flags = SA_SIGINFO | SA_RESTART; + r = sigemptyset(&act.sa_mask); + ATF_REQUIRE_EQ(0, r); + r = sigaction(SIGCHLD, &act, NULL); + ATF_REQUIRE_EQ(0, r); + + r = sigemptyset(&mask); + ATF_REQUIRE_EQ(0, r); + r = sigaddset(&mask, SIGCHLD); + ATF_REQUIRE_EQ(0, r); + r = sigprocmask(SIG_BLOCK, &mask, NULL); + ATF_REQUIRE_EQ(0, r); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) + _exit(2); + else { + if (waitid(P_PID, grandchild, NULL, + WNOWAIT | WEXITED) != 0) + _exit(102); + _exit(3); + } + } + + pid = waitpid(child, NULL, 0); + ATF_REQUIRE_EQ(child, pid); + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(2, info.si_status); + grandchild = info.si_pid; + ATF_REQUIRE(grandchild > 0); + ATF_REQUIRE(grandchild != parent); + ATF_REQUIRE(grandchild != child); + + pid = waitpid(-1, NULL, 0); + ATF_REQUIRE_EQ(grandchild, pid); +} + ATF_TC_WITHOUT_HEAD(reaper_status); ATF_TC_BODY(reaper_status, tc) { @@ -484,6 +644,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, reaper_wait_child_first); ATF_TP_ADD_TC(tp, reaper_wait_grandchild_first); + ATF_TP_ADD_TC(tp, reaper_sigchld_child_first); + ATF_TP_ADD_TC(tp, reaper_sigchld_grandchild_first); ATF_TP_ADD_TC(tp, reaper_status); ATF_TP_ADD_TC(tp, reaper_getpids); ATF_TP_ADD_TC(tp, reaper_kill_badsig); From owner-svn-src-stable-10@freebsd.org Tue Dec 27 20:06:27 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 80ADCC93844; Tue, 27 Dec 2016 20:06:27 +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 490E51852; Tue, 27 Dec 2016 20:06:27 +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 uBRK6QN5071254; Tue, 27 Dec 2016 20:06:26 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBRK6QKw071251; Tue, 27 Dec 2016 20:06:26 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612272006.uBRK6QKw071251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 27 Dec 2016 20:06:26 +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: r310637 - in stable: 10/share/man/man4 11/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.23 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: Tue, 27 Dec 2016 20:06:27 -0000 Author: jhb Date: Tue Dec 27 20:06:26 2016 New Revision: 310637 URL: https://svnweb.freebsd.org/changeset/base/310637 Log: MFC 309581,309582,310424: Document T6 support. 309581: Document support for Terminator 6 adapters in cxgbe(4) and cxgbev(4). 309582: Bump Dd for addition of T6. 310424: Replace passive voice with active voice and other tweaks. - Drop uses of 'will'. - Replace 'to use' with active voice. - Tidy language around interrupt types and clarify that INTx doesn't work on VFs. - Drop leading articles from sysctl/tunable descriptions. - Tweak the wording of several sysctl/tunable descriptions. Modified: stable/10/share/man/man4/Makefile stable/10/share/man/man4/cxgbe.4 stable/10/share/man/man4/cxgbev.4 Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/share/man/man4/Makefile stable/11/share/man/man4/cxgbe.4 stable/11/share/man/man4/cxgbev.4 Directory Properties: stable/11/ (props changed) Modified: stable/10/share/man/man4/Makefile ============================================================================== --- stable/10/share/man/man4/Makefile Tue Dec 27 19:08:08 2016 (r310636) +++ stable/10/share/man/man4/Makefile Tue Dec 27 20:06:26 2016 (r310637) @@ -584,11 +584,21 @@ MLINKS+=crypto.4 cryptodev.4 MLINKS+=cue.4 if_cue.4 MLINKS+=cxgb.4 if_cxgb.4 MLINKS+=cxgbe.4 if_cxgbe.4 \ + cxgbe.4 vcxgbe.4 \ + cxgbe.4 if_vcxgbe.4 \ cxgbe.4 cxl.4 \ - cxgbe.4 if_cxl.4 + cxgbe.4 if_cxl.4 \ + cxgbe.4 vcxl.4 \ + cxgbe.4 if_vcxl.4 \ + cxgbe.4 cc.4 \ + cxgbe.4 if_cc.4 \ + cxgbe.4 vcc.4 \ + cxgbe.4 if_vcc.4 MLINKS+=cxgbev.4 if_cxgbev.4 \ cxgbev.4 cxlv.4 \ - cxgbev.4 if_cxlv.4 + cxgbev.4 if_cxlv.4 \ + cxgbev.4 ccv.4 \ + cxgbev.4 if_ccv.4 MLINKS+=dc.4 if_dc.4 MLINKS+=de.4 if_de.4 MLINKS+=disc.4 if_disc.4 Modified: stable/10/share/man/man4/cxgbe.4 ============================================================================== --- stable/10/share/man/man4/cxgbe.4 Tue Dec 27 19:08:08 2016 (r310636) +++ stable/10/share/man/man4/cxgbe.4 Tue Dec 27 20:06:26 2016 (r310637) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2011-2014, Chelsio Inc +.\" Copyright (c) 2011-2016, Chelsio Inc .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -31,12 +31,12 @@ .\" .\" $FreeBSD$ .\" -.Dd December 2, 2015 +.Dd December 22, 2016 .Dt CXGBE 4 .Os .Sh NAME .Nm cxgbe -.Nd "Chelsio T4 and T5 based 40Gb, 10Gb, and 1Gb Ethernet adapter driver" +.Nd "Chelsio T4-, T5-, and T6-based 100Gb, 40Gb, 25Gb, 10Gb, and 1Gb Ethernet adapter driver" .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -51,13 +51,14 @@ module at boot time, place the following .Bd -literal -offset indent t4fw_cfg_load="YES" t5fw_cfg_load="YES" +t6fw_cfg_load="YES" if_cxgbe_load="YES" .Ed .Sh DESCRIPTION The .Nm driver provides support for PCI Express Ethernet adapters based on -the Chelsio Terminator 4 and Terminator 5 ASICs (T4 and T5). +the Chelsio Terminator 4, Terminator 5, and Terminator 6 ASICs (T4, T5, and T6). The driver supports Jumbo Frames, Transmit/Receive checksum offload, TCP segmentation offload (TSO), Large Receive Offload (LRO), VLAN tag insertion/extraction, VLAN checksum offload, VLAN TSO, and @@ -66,18 +67,47 @@ For further hardware information and que requirements, see .Pa http://www.chelsio.com/ . .Pp -Note that ports of T5 cards are named cxl and attach to a t5nex parent device -(in contrast to ports named cxgbe that attach to a t4nex parent for a T4 card). -Loader tunables with the hw.cxgbe prefix apply to both T4 and T5 cards. -The sysctl MIBs are at dev.t5nex and dev.cxl for T5 cards and at dev.t4nex and -dev.cxgbe for T4 cards. +The +.Nm +driver uses different names for devices based on the associated ASIC: +.Bl -column -offset indent "ASIC" "Port Name" "Parent Device" +.It Sy ASIC Ta Sy Port Name Ta Sy Parent Device Ta Sy Virtual Interface +.It T4 Ta cxgbe Ta t4nex Ta vcxgbe +.It T5 Ta cxl Ta t5nex Ta vcxl +.It T6 Ta cc Ta t6nex Ta vcc +.El .Pp +Loader tunables with the hw.cxgbe prefix apply to all cards. +The driver provides sysctl MIBs for both ports and parent devices using +the names above. +For example, a T5 adapter provides port MIBs under dev.cxl and +adapter-wide MIBs under dev.t5nex. +References to sysctl MIBs in the remainder of this page use +dev. for port MIBs and dev. for adapter-wide MIBs. +.Pp For more information on configuring this device, see .Xr ifconfig 8 . .Sh HARDWARE The .Nm +driver supports 100Gb and 25Gb Ethernet adapters based on the T6 ASIC: +.Pp +.Bl -bullet -compact +.It +Chelsio T6225-CR +.It +Chelsio T6225-SO-CR +.It +Chelsio T62100-LP-CR +.It +Chelsio T62100-SO-CR +.It +Chelsio T62100-CR +.El +.Pp +The +.Nm driver supports 40Gb, 10Gb and 1Gb Ethernet adapters based on the T5 ASIC: .Pp .Bl -bullet -compact @@ -140,92 +170,89 @@ prompt before booting the kernel or stor .Xr loader.conf 5 . .Bl -tag -width indent .It Va hw.cxgbe.ntxq10g -The number of tx queues to use for a 10Gb or 40Gb port. +Number of tx queues used for a 10Gb or higher-speed port. The default is 16 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq10g -The number of rx queues to use for a 10Gb or 40Gb port. +Number of rx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.ntxq1g -The number of tx queues to use for a 1Gb port. +Number of tx queues used for a 1Gb port. The default is 4 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq1g -The number of rx queues to use for a 1Gb port. +Number of rx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldtxq10g -The number of TOE tx queues to use for a 10Gb or 40Gb port. +Number of TOE tx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldrxq10g -The number of TOE rx queues to use for a 10Gb or 40Gb port. +Number of TOE rx queues used for a 10Gb or higher-speed port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldtxq1g -The number of TOE tx queues to use for a 1Gb port. +Number of TOE tx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nofldrxq1g -The number of TOE rx queues to use for a 1Gb port. +Number of TOE rx queues used for a 1Gb port. The default is 1. .It Va hw.cxgbe.num_vis -The number of virtual interfaces (VIs) created for each port. +Number of virtual interfaces (VIs) created for each port. Each virtual interface creates a separate network interface. The first virtual interface on each port is required and represents the primary network interface on the port. -Additional virtual interfaces on a port are named vcxgbe (T4) or -vcxl (T5) and only use a single rx and tx queue. +Additional virtual interfaces on a port are named using the Virtual Interface +name from the table above. Additional virtual interfaces use a single pair of queues for rx and tx as well an additional pair of queues for TOE rx and tx. The default is 1. .It Va hw.cxgbe.holdoff_timer_idx_10G .It Va hw.cxgbe.holdoff_timer_idx_1G -The timer index value to use to delay interrupts. +Timer index value used to delay interrupts. The holdoff timer list has the values 1, 5, 10, 50, 100, and 200 by default (all values are in microseconds) and the index selects a value from this list. The default value is 1 which means the timer value is 5us. Different interfaces can be assigned different values at any time via the -dev.cxgbe.X.holdoff_tmr_idx or dev.cxl.X.holdoff_tmr_idx sysctl. +dev..X.holdoff_tmr_idx sysctl. .It Va hw.cxgbe.holdoff_pktc_idx_10G .It Va hw.cxgbe.holdoff_pktc_idx_1G -The packet-count index value to use to delay interrupts. -The packet-count list has the values 1, 8, 16, and 32 by default +Packet-count index value used to delay interrupts. +The packet-count list has the values 1, 8, 16, and 32 by default, and the index selects a value from this list. The default value is -1 which means packet counting is disabled and interrupts are generated based solely on the holdoff timer value. Different interfaces can be assigned different values via the -dev.cxgbe.X.holdoff_pktc_idx or dev.cxl.X.holdoff_pktc_idx sysctl. +dev..X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_txq -The size, in number of entries, of the descriptor ring used for a tx -queue. +Number of entries in a transmit queue's descriptor ring. A buf_ring of the same size is also allocated for additional software queuing. See .Xr ifnet 9 . The default value is 1024. Different interfaces can be assigned different values via the -dev.cxgbe.X.qsize_txq sysctl or dev.cxl.X.qsize_txq sysctl. +dev..X.qsize_txq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_rxq -The size, in number of entries, of the descriptor ring used for an -rx queue. +Number of entries in a receive queue's descriptor ring. The default value is 1024. Different interfaces can be assigned different values via the -dev.cxgbe.X.qsize_rxq or dev.cxl.X.qsize_rxq sysctl. +dev..X.qsize_rxq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.interrupt_types -The interrupt types that the driver is allowed to use. -Bit 0 represents INTx (line interrupts), bit 1 MSI, bit 2 MSI-X. +Permitted interrupt types. +Bit 0 represents INTx (line interrupts), bit 1 MSI, and bit 2 MSI-X. The default is 7 (all allowed). -The driver will select the best possible type out of the allowed types by -itself. +The driver selects the best possible type out of the allowed types. .It Va hw.cxgbe.fw_install 0 prohibits the driver from installing a firmware on the card. 1 allows the driver to install a new firmware if internal driver @@ -236,7 +263,7 @@ long as it is compatible with the driver the one already on the card. The default is 1. .It Va hw.cxgbe.fl_pktshift -The number of bytes of padding inserted before the beginning of an Ethernet +Number of padding bytes inserted before the beginning of an Ethernet frame in the receive buffer. The default value of 2 ensures that the Ethernet payload (usually the IP header) is at a 4 byte aligned address. @@ -262,7 +289,7 @@ reaches a high threshold, 0 prohibits th The default is 3 (both rx_pause and tx_pause = 1). This tunable establishes the default PAUSE settings for all ports. Settings can be displayed and controlled on a per-port basis via the -dev.cxgbe.X.pause_settings (dev.cxl.X.pause_settings for T5 cards) sysctl. +dev..X.pause_settings sysctl. .It Va hw.cxgbe.buffer_packing Allow the hardware to deliver multiple frames in the same receive buffer opportunistically. @@ -278,8 +305,8 @@ Sizes of rx clusters. Each of these mus (usually 2048, 4096, 9216, and 16384) and largest_rx_cluster must be greater than or equal to safest_rx_cluster. The defaults are 16384 and 4096 respectively. -The driver will never attempt to allocate a receive buffer larger than -largest_rx_cluster and will fall back to allocating buffers of +The driver never attempts to allocate a receive buffer larger than +largest_rx_cluster and falls back to allocating buffers of safest_rx_cluster size if an allocation larger than safest_rx_cluster fails. Note that largest_rx_cluster merely establishes a ceiling -- the driver is allowed to allocate buffers of smaller sizes. @@ -289,8 +316,8 @@ A configuration file contains a recipe f hardware resources on the card. This tunable is for specialized applications only and should not be used in normal operation. -The configuration profile currently in use is available in the dev.t4nex.X.cf -and dev.t4nex.X.cfcsum (dev.t5nex for T5 cards) sysctls. +The configuration profile currently in use is available in the dev..X.cf +and dev..X.cfcsum sysctls. .It Va hw.cxgbe.linkcaps_allowed .It Va hw.cxgbe.niccaps_allowed .It Va hw.cxgbe.toecaps_allowed @@ -304,7 +331,7 @@ capability. This tunable is for specialized applications only and should not be used in normal operation. The capabilities for which hardware resources have been reserved are listed in -dev.t4nex.X.*caps or dev.t5nex.X.*caps sysctls. +dev..X.*caps sysctls. .El .Sh SUPPORT For general information and support, @@ -331,6 +358,10 @@ Support for T5 cards first appeared in .Fx 9.2 and .Fx 10.0 . +Support for T6 cards first appeared in +.Fx 11.1 +and +.Fx 12.0 . .Sh AUTHORS .An -nosplit The Modified: stable/10/share/man/man4/cxgbev.4 ============================================================================== --- stable/10/share/man/man4/cxgbev.4 Tue Dec 27 19:08:08 2016 (r310636) +++ stable/10/share/man/man4/cxgbev.4 Tue Dec 27 20:06:26 2016 (r310637) @@ -31,12 +31,12 @@ .\" .\" $FreeBSD$ .\" -.Dd August 22, 2016 +.Dd December 22, 2016 .Dt CXGBEV 4 .Os .Sh NAME .Nm cxgbev -.Nd "Chelsio T4 and T5 based 40Gb, 10Gb, and 1Gb Ethernet VF driver" +.Nd "Chelsio T4-, T5-, and T6-based 100Gb, 40Gb, 25Gb, 10Gb, and 1Gb Ethernet VF driver" .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -56,7 +56,8 @@ if_cxgbev_load="YES" The .Nm driver provides support for Virtual Functions on PCI Express Ethernet adapters -based on the Chelsio Terminator 4 and Terminator 5 ASICs (T4 and T5). +based on the Chelsio Terminator 4, Terminator 5, and Terminator 6 ASICs +(T4, T5, and T6). The driver supports Jumbo Frames, Transmit/Receive checksum offload, TCP segmentation offload (TSO), Large Receive Offload (LRO), VLAN tag insertion/extraction, VLAN checksum offload, VLAN TSO, and @@ -65,18 +66,49 @@ For further hardware information and que requirements, see .Pa http://www.chelsio.com/ . .Pp -Note that ports of T5 VFs are named cxlv and attach to a t5vf parent device -(in contrast to ports named cxgbev that attach to a t4vf parent for a T4 VF). -Loader tunables with the hw.cxgbe prefix apply to both T4 and T5 VFs. -The Physical Function driver for T4 and T5 adapters shares these tunables. -The sysctl MIBs are at dev.t5vf and dev.cxlv for T5 cards and at dev.t4vf and -dev.cxgbev for T4 cards. +The +.Nm +driver uses different names for devices based on the associated ASIC: +.Bl -column -offset indent "ASIC" "Port Name" +.It Sy ASIC Ta Sy Port Name Ta Sy Parent Device +.It T4 Ta cxgbev Ta t4vf +.It T5 Ta cxlv Ta t5vf +.It T6 Ta ccv Ta t6vf +.El +.Pp +Loader tunables with the hw.cxgbe prefix apply to VFs from all cards. +The Physical Function driver for Chelsio Terminator adapters shares these +tunables. +The driver provides sysctl MIBs for both ports and parent devices using +the names above. +For example, a T5 VF provides port MIBs under dev.cxlv and +parent device MIBs under dev.t5vf. +References to sysctl MIBs in the remainder of this page use +dev. for port MIBs and dev. for parent device MIBs. .Pp For more information on configuring this device, see .Xr ifconfig 8 . .Sh HARDWARE The .Nm +driver supports Virtual Functions on 100Gb and 25Gb Ethernet adapters +based on the T6 ASIC: +.Pp +.Bl -bullet -compact +.It +Chelsio T6225-CR +.It +Chelsio T6225-SO-CR +.It +Chelsio T62100-LP-CR +.It +Chelsio T62100-SO-CR +.It +Chelsio T62100-CR +.El +.Pp +The +.Nm driver supports Virtual Functions on 40Gb, 10Gb and 1Gb Ethernet adapters based on the T5 ASIC: .Pp @@ -141,69 +173,68 @@ prompt before booting the kernel or stor .Xr loader.conf 5 . .Bl -tag -width indent .It Va hw.cxgbe.ntxq10g -The number of tx queues to use for a 10Gb or 40Gb port. +Number of tx queues used for a 10Gb or higher-speed port. The default is 16 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq10g -The number of rx queues to use for a 10Gb or 40Gb port. +Number of rx queues used for a 10Gb or higher-speed port. The default is 8 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.ntxq1g -The number of tx queues to use for a 1Gb port. +Number of tx queues used for a 1Gb port. The default is 4 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.nrxq1g -The number of rx queues to use for a 1Gb port. +Number of rx queues used for a 1Gb port. The default is 2 or the number of CPU cores in the system, whichever is less. .It Va hw.cxgbe.holdoff_timer_idx_10G .It Va hw.cxgbe.holdoff_timer_idx_1G -The timer index value to use to delay interrupts. +Timer index value used to delay interrupts. The holdoff timer list has the values 1, 5, 10, 50, 100, and 200 by default (all values are in microseconds) and the index selects a value from this list. The default value is 1 which means the timer value is 5us. Different interfaces can be assigned different values at any time via the -dev.cxgbev.X.holdoff_tmr_idx or dev.cxlv.X.holdoff_tmr_idx sysctl. +dev..X.holdoff_tmr_idx sysctl. .It Va hw.cxgbe.holdoff_pktc_idx_10G .It Va hw.cxgbe.holdoff_pktc_idx_1G -The packet-count index value to use to delay interrupts. -The packet-count list has the values 1, 8, 16, and 32 by default +Packet-count index value used to delay interrupts. +The packet-count list has the values 1, 8, 16, and 32 by default, and the index selects a value from this list. The default value is -1 which means packet counting is disabled and interrupts are generated based solely on the holdoff timer value. Different interfaces can be assigned different values via the -dev.cxgbev.X.holdoff_pktc_idx or dev.cxlv.X.holdoff_pktc_idx sysctl. +dev..X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_txq -The size, in number of entries, of the descriptor ring used for a tx -queue. +Number of entries in a transmit queue's descriptor ring. A buf_ring of the same size is also allocated for additional software queuing. See .Xr ifnet 9 . The default value is 1024. Different interfaces can be assigned different values via the -dev.cxgbev.X.qsize_txq sysctl or dev.cxlv.X.qsize_txq sysctl. +dev..X.qsize_txq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.qsize_rxq -The size, in number of entries, of the descriptor ring used for an -rx queue. +Number of entries in a receive queue's descriptor ring. The default value is 1024. Different interfaces can be assigned different values via the -dev.cxgbev.X.qsize_rxq or dev.cxlv.X.qsize_rxq sysctl. +dev..X.qsize_rxq sysctl. This sysctl works only when the interface has never been marked up (as done by ifconfig up). .It Va hw.cxgbe.interrupt_types -The interrupt types that the driver is allowed to use. -Bit 0 represents INTx (line interrupts), bit 1 MSI, bit 2 MSI-X. +Permitted interrupt types. +Bit 0 represents INTx (line interrupts), bit 1 MSI, and bit 2 MSI-X. The default is 7 (all allowed). -The driver will select the best possible type out of the allowed types by -itself. +The driver selects the best possible type out of the allowed types. +Note that Virtual Functions do not support INTx interrupts and fail +to attach if neither MSI nor MSI-X are enabled. .It Va hw.cxgbe.fl_pktshift -The number of bytes of padding inserted before the beginning of an Ethernet +Number of padding bytes inserted before the beginning of an Ethernet frame in the receive buffer. The default value of 2 ensures that the Ethernet payload (usually the IP header) is at a 4 byte aligned address. @@ -230,8 +261,8 @@ Each of these must be set to one of the (usually 2048, 4096, 9216, and 16384) and largest_rx_cluster must be greater than or equal to safest_rx_cluster. The defaults are 16384 and 4096 respectively. -The driver will never attempt to allocate a receive buffer larger than -largest_rx_cluster and will fall back to allocating buffers of +The driver never attempts to allocate a receive buffer larger than +largest_rx_cluster and falls back to allocating buffers of safest_rx_cluster size if an allocation larger than safest_rx_cluster fails. Note that largest_rx_cluster merely establishes a ceiling -- the driver is allowed to allocate buffers of smaller sizes. @@ -239,8 +270,8 @@ allowed to allocate buffers of smaller s .Pp Certain settings and resources for Virtual Functions are dictated by the parent Physical Function driver. -For example, the Physical Function driver limits the number of queues a -Virtual Function is permitted to use. +For example, the Physical Function driver limits the number of queues +available to a Virtual Function. Some of these limits can be adjusted in the firmware configuration file used with the Physical Function driver. .Pp @@ -258,7 +289,7 @@ to 1 .Pc . .Pp The VF driver currently depends on the PF driver. -As a result, loading the VF driver will also load the PF driver as a +As a result, loading the VF driver also loads the PF driver as a dependency. .Sh SUPPORT For general information and support, @@ -279,6 +310,8 @@ email all the specific information relat The .Nm device driver first appeared in +.Fx 11.1 +and .Fx 12.0 . .Sh AUTHORS .An -nosplit From owner-svn-src-stable-10@freebsd.org Tue Dec 27 20:22:45 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 A0E9DC93DFF; Tue, 27 Dec 2016 20:22:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7DDC414C2; Tue, 27 Dec 2016 20:22:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 771EB10AA64; Tue, 27 Dec 2016 15:22:44 -0500 (EST) From: John Baldwin To: Andriy Gapon Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: Re: svn commit: r308371 - in stable/10: share/man/man4 sys/conf sys/dev/jedec_ts sys/modules/i2c sys/modules/i2c/jedec_ts Date: Tue, 27 Dec 2016 11:51:50 -0800 Message-ID: <1756673.351QfCkGNL@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: <9c234848-2d27-b417-b78d-18bde988bc07@FreeBSD.org> References: <201611061356.uA6DuYcO079294@repo.freebsd.org> <2547422.gn4y6NaJ31@ralph.baldwin.cx> <9c234848-2d27-b417-b78d-18bde988bc07@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 27 Dec 2016 15:22:44 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 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: Tue, 27 Dec 2016 20:22:45 -0000 On Saturday, December 24, 2016 03:35:37 PM Andriy Gapon wrote: > On 19/12/2016 18:55, John Baldwin wrote: > > Yes. Well, it fixes linking of kernels at least. Now make tinderbox > > on 10 fails for the following kernels: > > > > _.ia64.GENERIC: Maxmem is not available on ia64. It is spelled > > paddr_max instead. The firewire code is trying to use Maxmem. > > _.ia64.LINT: Same. > > _.arm.LINT: Many link errors and warnings, though lack of 'kbd_*' symbols > > seems to be the only actual errors. > > > > I suspect you recently MFC'd changes to fwohci.c that are using Maxmem. > > However, I'm not sure it is worth fixing fwohci on ia64. > > The ia64 problem should be fixed now. > I added Maxmem as we discussed. Thanks! -- John Baldwin From owner-svn-src-stable-10@freebsd.org Wed Dec 28 06:15:40 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 BB0EAC92F72; Wed, 28 Dec 2016 06:15:40 +0000 (UTC) (envelope-from ngie@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 89CFA1228; Wed, 28 Dec 2016 06:15:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBS6FdCw031736; Wed, 28 Dec 2016 06:15:39 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBS6FdTk031735; Wed, 28 Dec 2016 06:15:39 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612280615.uBS6FdTk031735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 28 Dec 2016 06:15:39 +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: r310671 - stable/10/contrib/bsnmp/snmp_target 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.23 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, 28 Dec 2016 06:15:40 -0000 Author: ngie Date: Wed Dec 28 06:15:39 2016 New Revision: 310671 URL: https://svnweb.freebsd.org/changeset/base/310671 Log: MFstable/11 r310670: MFC r310503: style(9): delete stray trailing whitespace after break statement Modified: stable/10/contrib/bsnmp/snmp_target/target_snmp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmp_target/target_snmp.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_target/target_snmp.c Wed Dec 28 06:14:50 2016 (r310670) +++ stable/10/contrib/bsnmp/snmp_target/target_snmp.c Wed Dec 28 06:15:39 2016 (r310671) @@ -299,7 +299,7 @@ op_snmp_target_addrs(struct snmp_context return (target_delete_address(addrs)); break; default: - break; + break; } return (SNMP_ERR_NOERROR); From owner-svn-src-stable-10@freebsd.org Wed Dec 28 06:16:56 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 D8D1EC94082; Wed, 28 Dec 2016 06:16:56 +0000 (UTC) (envelope-from ngie@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 A803B1579; Wed, 28 Dec 2016 06:16:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBS6Gtch031902; Wed, 28 Dec 2016 06:16:55 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBS6Gt5o031901; Wed, 28 Dec 2016 06:16:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612280616.uBS6Gt5o031901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 28 Dec 2016 06:16:55 +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: r310673 - stable/10/contrib/bsnmp/lib 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.23 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, 28 Dec 2016 06:16:57 -0000 Author: ngie Date: Wed Dec 28 06:16:55 2016 New Revision: 310673 URL: https://svnweb.freebsd.org/changeset/base/310673 Log: MFstable/11 r310672: MFC r310499: Sort #includes No functional change Modified: stable/10/contrib/bsnmp/lib/snmp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/lib/snmp.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmp.c Wed Dec 28 06:16:19 2016 (r310672) +++ stable/10/contrib/bsnmp/lib/snmp.c Wed Dec 28 06:16:55 2016 (r310673) @@ -38,19 +38,19 @@ */ #include #include +#include +#include +#include #include #include #include #include +#include #ifdef HAVE_STDINT_H #include #elif defined(HAVE_INTTYPES_H) #include #endif -#include -#include -#include -#include #include "asn1.h" #include "snmp.h" From owner-svn-src-stable-10@freebsd.org Thu Dec 29 00:24: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 690E9C94449; Thu, 29 Dec 2016 00:24:59 +0000 (UTC) (envelope-from ngie@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 37E131F53; Thu, 29 Dec 2016 00:24:59 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT0OwFn086052; Thu, 29 Dec 2016 00:24:58 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT0Owmk086051; Thu, 29 Dec 2016 00:24:58 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612290024.uBT0Owmk086051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 29 Dec 2016 00:24: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: r310731 - stable/10/contrib/bsnmp/snmpd 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.23 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, 29 Dec 2016 00:24:59 -0000 Author: ngie Date: Thu Dec 29 00:24:58 2016 New Revision: 310731 URL: https://svnweb.freebsd.org/changeset/base/310731 Log: MFstable/11 r310730: MFC r310592: style(9): fix trailing whitespace Modified: stable/10/contrib/bsnmp/snmpd/trap.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/trap.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/trap.c Thu Dec 29 00:24:16 2016 (r310730) +++ stable/10/contrib/bsnmp/snmpd/trap.c Thu Dec 29 00:24:58 2016 (r310731) @@ -214,7 +214,7 @@ trapsink_unmodify(struct trapsink *t, st t->version = tdep->rb_version; if (tdep->set & TDEP_COMM) strcpy(t->comm, tdep->rb_comm); - + return (SNMP_ERR_NOERROR); } @@ -546,7 +546,7 @@ snmp_send_trap(const struct asn_oid *tra TAILQ_FOREACH(t, &trapsink_list, link) { if (t->status != TRAPSINK_ACTIVE) continue; - + if (t->version == TRAPSINK_V1) snmp_create_v1_trap(&pdu, t->comm, trap_oid); else From owner-svn-src-stable-10@freebsd.org Thu Dec 29 00:26:28 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 6B305C94541; Thu, 29 Dec 2016 00:26:28 +0000 (UTC) (envelope-from ngie@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 38DC8124D; Thu, 29 Dec 2016 00:26:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT0QRdt086231; Thu, 29 Dec 2016 00:26:27 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT0QRCk086229; Thu, 29 Dec 2016 00:26:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612290026.uBT0QRCk086229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 29 Dec 2016 00:26:27 +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: r310733 - stable/10/contrib/bsnmp/snmpd 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.23 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, 29 Dec 2016 00:26:28 -0000 Author: ngie Date: Thu Dec 29 00:26:27 2016 New Revision: 310733 URL: https://svnweb.freebsd.org/changeset/base/310733 Log: MFstable/11 r310732: MFC r310574: Fix style(9) - Sort #includes - Delete trailing whitespace No functional change Modified: stable/10/contrib/bsnmp/snmpd/trans_lsock.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/trans_lsock.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/trans_lsock.c Thu Dec 29 00:25:38 2016 (r310732) +++ stable/10/contrib/bsnmp/snmpd/trans_lsock.c Thu Dec 29 00:26:27 2016 (r310733) @@ -32,15 +32,15 @@ */ #include #include -#include #include +#include +#include +#include #include #include -#include -#include #include -#include +#include #include #include "snmpmod.h" @@ -417,7 +417,7 @@ lsock_send(struct tport *tp, const u_cha return (-1); } } - + return (sendto(peer->input.fd, buf, len, 0, addr, addrlen)); } From owner-svn-src-stable-10@freebsd.org Thu Dec 29 05:32:36 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 C408FC9510E; Thu, 29 Dec 2016 05:32:36 +0000 (UTC) (envelope-from sephe@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 607A71043; Thu, 29 Dec 2016 05:32:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT5WZXv016428; Thu, 29 Dec 2016 05:32:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT5WYtG016418; Thu, 29 Dec 2016 05:32:34 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290532.uBT5WYtG016418@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 05:32: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: r310735 - in stable/10: contrib/hyperv/tools etc/devd etc/mtree include share/man/man4 sys/conf sys/dev/hyperv/utilities sys/modules/hyperv/utilities usr.sbin/hyperv usr.sbin/hyperv/too... 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.23 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, 29 Dec 2016 05:32:36 -0000 Author: sephe Date: Thu Dec 29 05:32:34 2016 New Revision: 310735 URL: https://svnweb.freebsd.org/changeset/base/310735 Log: MFC 308664,308742,308743 308664 hyperv/vss: Add driver and tools for VSS VSS stands for "Volume Shadow Copy Service". Unlike virtual machine snapshot, it only takes snapshot for the virtual disks, so both filesystem and applications have to aware of it, and cooperate the whole VSS process. This driver exposes two device files to the userland: /dev/hv_fsvss_dev Normally userland programs should _not_ mess with this device file. It is currently used by the hv_vss_daemon(8), which freezes and thaws the filesystem. NOTE: currently only UFS is supported, if the system mounts _any_ other filesystems, the hv_vss_daemon(8) will veto the VSS process. If hv_vss_daemon(8) was disabled, then this device file must be opened, and proper ioctls must be issued to keep the VSS working. /dev/hv_appvss_dev Userland application can opened this device file to receive the VSS freeze notification, hold the VSS for a while (mainly to flush application data to filesystem), release the VSS process, and receive the VSS thaw notification i.e. applications can run again. The VSS will still work, even if this device file is not opened. However, only filesystem consistency is promised, if this device file is not opened or is not operated properly. hv_vss_daemon(8) is started by devd(8) by default. It can be disabled by editting /etc/devd/hyperv.conf. Submitted by: Hongjiang Zhang Reviewed by: kib, mckusick Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8224 308742 hyperv/vss: Nuke unused variables. Submitted by: markj Reported by: markj Sponsored by: Microsoft 308743 hyperv/vss: Install the userland daemon to /usr/sbin instead of / Submitted by: markj Reported by: markj Sponsored by: Microsoft Added: stable/10/contrib/hyperv/tools/hv_vss_daemon.8 - copied unchanged from r308664, head/contrib/hyperv/tools/hv_vss_daemon.8 stable/10/contrib/hyperv/tools/hv_vss_daemon.c - copied, changed from r308664, head/contrib/hyperv/tools/hv_vss_daemon.c stable/10/share/man/man4/hv_vss.4 - copied unchanged from r308664, head/share/man/man4/hv_vss.4 stable/10/sys/dev/hyperv/utilities/hv_snapshot.c - copied unchanged from r308664, head/sys/dev/hyperv/utilities/hv_snapshot.c stable/10/sys/dev/hyperv/utilities/hv_snapshot.h - copied unchanged from r308664, head/sys/dev/hyperv/utilities/hv_snapshot.h stable/10/usr.sbin/hyperv/tools/Makefile.inc - copied unchanged from r308743, head/usr.sbin/hyperv/tools/Makefile.inc stable/10/usr.sbin/hyperv/tools/kvp/ - copied from r308664, head/usr.sbin/hyperv/tools/kvp/ stable/10/usr.sbin/hyperv/tools/vss/ - copied from r308664, head/usr.sbin/hyperv/tools/vss/ Deleted: stable/10/usr.sbin/hyperv/tools/Makefile Modified: stable/10/etc/devd/hyperv.conf stable/10/etc/mtree/BSD.include.dist stable/10/include/Makefile stable/10/share/man/man4/Makefile stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/modules/hyperv/utilities/Makefile stable/10/usr.sbin/hyperv/Makefile Directory Properties: stable/10/ (props changed) Copied: stable/10/contrib/hyperv/tools/hv_vss_daemon.8 (from r308664, head/contrib/hyperv/tools/hv_vss_daemon.8) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/hyperv/tools/hv_vss_daemon.8 Thu Dec 29 05:32:34 2016 (r310735, copy of r308664, head/contrib/hyperv/tools/hv_vss_daemon.8) @@ -0,0 +1,88 @@ +.\" Copyright (c) 2016 Microsoft Corp. +.\" 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 October 12, 2016 +.Dt HV_VSS_DAEMON 8 +.Os +.Sh NAME +.Nm hv_vss_daemon +.Nd Hyper-V Volume Shadow Copy Service Daemon +.Sh SYNOPSIS +.Nm +.Op Fl dn +.Sh DESCRIPTION +The +.Nm +daemon provides the ability to freeze and thaw the file system for +.Fx +guest partitions running on Hyper-V. +.Pp +Hyper-V allows administrators to backup or restore the +.Fx +guest partition. +Administrators can +use Windows Powershell scripts to backup or restore the +.Fx +VM. +.Pp +The +.Nm +accepts file system freeze and thaw requests from the +.Xr hv_utils 4 +driver and performs the actual file-system operation. +.Pp +The file system freeze and thaw functionality is +useful when the Hyper-V host wants to do live backup of +.Fx +guest. Hyper-V host sends file system freezing request to +.Nm +which conducts the real operation. After successfully freezing file +system, Hyper-V host takes a snapshot of the VM. In the future, +Hyper-V host can restore the +.Fx +VM through that snapshot. +.Pp +The options are as follows: +.Bl -tag -width indent +.It Fl d +Run as regular process instead of a daemon for debugging purpose. +.It Fl n +Generate debugging output. +.El +.Sh SEE ALSO +.Xr hv_vmbus 4 , +.Xr hv_utils 4 , +.Xr hv_netvsc 4 , +.Xr hv_storvsc 4 , +.Xr hv_kvp 4 +.Sh HISTORY +The daemon was introduced in October 2016 and developed by Microsoft Corp. +.Sh AUTHORS +.An -nosplit +.Fx +support for +.Nm +was first added by +.An Microsoft BSD Integration Services Team Aq Mt bsdic@microsoft.com . Copied and modified: stable/10/contrib/hyperv/tools/hv_vss_daemon.c (from r308664, head/contrib/hyperv/tools/hv_vss_daemon.c) ============================================================================== --- head/contrib/hyperv/tools/hv_vss_daemon.c Tue Nov 15 02:36:12 2016 (r308664, copy source) +++ stable/10/contrib/hyperv/tools/hv_vss_daemon.c Thu Dec 29 05:32:34 2016 (r310735) @@ -158,10 +158,9 @@ main(int argc, char* argv[]) struct pollfd hv_vss_poll_fd[1]; uint32_t op; - int ch, r, len, error; + int ch, r, error; int hv_vss_dev_fd; - int freeze_thaw = UNDEF_FREEZE_THAW; while ((ch = getopt(argc, argv, "dnh")) != -1) { switch (ch) { case 'n': Modified: stable/10/etc/devd/hyperv.conf ============================================================================== --- stable/10/etc/devd/hyperv.conf Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/etc/devd/hyperv.conf Thu Dec 29 05:32:34 2016 (r310735) @@ -17,3 +17,19 @@ notify 10 { match "cdev" "hv_kvp_dev"; action "pkill -x hv_kvp_daemon"; }; + +notify 11 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "hv_fsvss_dev"; + action "/usr/sbin/hv_vss_daemon"; +}; + +notify 11 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "DESTROY"; + match "cdev" "hv_fsvss_dev"; + action "pkill -x hv_vss_daemon"; +}; Modified: stable/10/etc/mtree/BSD.include.dist ============================================================================== --- stable/10/etc/mtree/BSD.include.dist Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/etc/mtree/BSD.include.dist Thu Dec 29 05:32:34 2016 (r310735) @@ -118,6 +118,8 @@ .. hwpmc .. + hyperv + .. ic .. ieee488 Modified: stable/10/include/Makefile ============================================================================== --- stable/10/include/Makefile Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/include/Makefile Thu Dec 29 05:32:34 2016 (r310735) @@ -44,7 +44,7 @@ LDIRS= bsm cam geom net net80211 netatal LSUBDIRS= cam/ata cam/scsi \ dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \ - dev/hwpmc \ + dev/hwpmc dev/hyperv \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \ dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/utopia dev/vkbd dev/wi \ @@ -161,7 +161,7 @@ copies: done .endif .endfor -.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} +.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/hyperv:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ ${DESTDIR}${INCLUDEDIR}/$i @@ -184,6 +184,9 @@ copies: ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \ ${DESTDIR}${INCLUDEDIR}/dev/nand .endif + cd ${.CURDIR}/../sys/dev/hyperv/utilities; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 hv_snapshot.h \ + ${DESTDIR}${INCLUDEDIR}/dev/hyperv cd ${.CURDIR}/../sys/dev/pci; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \ ${DESTDIR}${INCLUDEDIR}/dev/pci @@ -256,7 +259,7 @@ symlinks: ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ done .endfor -.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} +.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/hyperv:Ndev/nand:Ndev/pci} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ @@ -284,6 +287,11 @@ symlinks: ${DESTDIR}${INCLUDEDIR}/dev/nand; \ done .endif + cd ${.CURDIR}/../sys/dev/hyperv/utilities; \ + for h in hv_snapshot.h; do \ + ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/utilities/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/hyperv; \ + done cd ${.CURDIR}/../sys/dev/pci; \ for h in pcireg.h; do \ ln -fs ../../../../sys/dev/pci/$$h \ Modified: stable/10/share/man/man4/Makefile ============================================================================== --- stable/10/share/man/man4/Makefile Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/share/man/man4/Makefile Thu Dec 29 05:32:34 2016 (r310735) @@ -180,6 +180,7 @@ MAN= aac.4 \ ${_hv_storvsc.4} \ ${_hv_utils.4} \ ${_hv_vmbus.4} \ + hv_vss.4 \ hwpmc.4 \ ichsmb.4 \ ${_ichwd.4} \ Copied: stable/10/share/man/man4/hv_vss.4 (from r308664, head/share/man/man4/hv_vss.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/share/man/man4/hv_vss.4 Thu Dec 29 05:32:34 2016 (r310735, copy of r308664, head/share/man/man4/hv_vss.4) @@ -0,0 +1,366 @@ +.\" Copyright (c) 2016 Microsoft Corp. +.\" 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 October 12, 2016 +.Dt HV_VSS 4 +.Os +.Sh NAME +.Nm hv_vss +.Nd Hyper-V Volume Shadow Copy Service API +.Sh SYNOPSIS +.In dev/hyperv/hv_snapshot.h +.Bd -literal +#define VSS_SUCCESS 0x00000000 +#define VSS_FAIL 0x00000001 + +enum hv_vss_op_t { + HV_VSS_NONE = 0, + HV_VSS_CHECK, + HV_VSS_FREEZE, + HV_VSS_THAW, + HV_VSS_COUNT +}; + +struct hv_vss_opt_msg { + uint32_t opt; /* operation */ + uint32_t status; /* 0 for success, 1 for error */ + uint64_t msgid; /* an ID used to identify the transaction */ + uint8_t reserved[48]; /* reserved values are all zeroes */ +}; +.Ed +.Sh DESCRIPTION +The freeze or thaw functionality of application is important to guarantee +the application consistent backup. On windows platform, VSS is defined to do +live backup. But for VM guest running on Hyper-V, the corresponding VSS is +not defined yet. For example, a running database server instance, it knows when the +applications' freeze/thaw should start or finish. But it is not aware of +the freeze/thaw notification from Hyper-V host. The +.Nm +is designed to notify application freeze/thaw request. +Thus, it plays a role of broker to forward the freeze/thaw command from Hyper-V host +to userland application if it registered VSS service on +.Fx +VM, and sends the result back to Hyper-V host. +.Pp +Generally, +.Xr hv_vss_daemon 8 +takes the responsiblity to freeze/thaw UFS file system, +and it is automatically launched after system boots. When Hyper-V host wants to +take a snapshot of the +.Fx +VM, it will first send VSS capability check to +.Fx +VM. The +.Nm +received the request and forward the request to userland application if it is +registered. Only after +.Nm +received the VSS_SUCCESS response from application, the +.Xr hv_vss_daemon 8 +will be informed to check whether file system freeze/thaw is supported. Any error +occurs during this period, +.Nm +will inform Hyper-V host that VSS is not supported. In addition, there is a default +timeout limit before sending response to Hyper-V host. +If the total response time from application and +.Xr hv_vss_daemon 8 +exceeds this value, timeout +will occurs and VSS unsupported is responsed to Hyper-V host. +.Pp +After Hyper-V host confirmed the +.Fx +VM supports VSS, it will send freeze request to VM, and +.Nm +will first forward it to application. After application finished freezing, it should +inform +.Nm +and file system level freezing will be triggered by +.Xr hv_vss_daemon 8 . After all freezing +on both application and +.Xr hv_vss_daemon 8 +were finished, the +.Nm +will inform Hyper-V host that freezing is done. Of course, there is a timeout limit as +same as VSS capability is set to make sure freezing on +.Fx +VM is not hang. If there is any error occurs or timeout happened, the freezing is failed +on Hyper-V side. +.Pp +Hyper-V host will send thaw request after taking the snapshot, typically, this period is +very short in order not to block the running application. +.Nm +firstly thaw the file system by notifying +.Xr hv_vss_daemon 8 , +then notifies user registered +application. There is also a timeout check before sending response to Hyper-V host. +.Pp +All the default timeout limit used in VSS capability check, freeze or thaw is the same. +It is 15 seconds currently. +.Sh NOTES +.Nm +only support UFS currently. If any of file system partition is non UFS, the VSS capability +check will fail. If application does not register VSS, +.Nm +only support backup for file system level consistent. The device should be closed before it +was opened again. If you want to simultaneously open "/dev/hv_appvss_dev" two or more times, +an error (-1) will be returned, and errno was set. +.Pp +If +.Xr hv_vss_daemon 8 +was killed after system boots, the VSS functionality will not work. +.Sh EXAMPLES +The following is a complete example which does nothing except for waiting 2 seconds when +receiving those notifications from +.Nm +.Bd -literal +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define UNDEF_FREEZE_THAW (0) +#define FREEZE (1) +#define THAW (2) +#define CHECK (3) + +#define VSS_LOG(priority, format, args...) do { \\ + if (is_debugging == 1) { \\ + if (is_daemon == 1) \\ + syslog(priority, format, ## args); \\ + else \\ + printf(format, ## args); \\ + } else { \\ + if (priority < LOG_DEBUG) { \\ + if (is_daemon == 1) \\ + syslog(priority, format, ## args); \\ + else \\ + printf(format, ## args); \\ + } \\ + } \\ + } while(0) + +#define CHECK_TIMEOUT 1 +#define CHECK_FAIL 2 +#define FREEZE_TIMEOUT 1 +#define FREEZE_FAIL 2 +#define THAW_TIMEOUT 1 +#define THAW_FAIL 2 + +static int is_daemon = 1; +static int is_debugging = 0; +static int simu_opt_waiting = 2; // seconds + +#define GENERIC_OPT(TIMEOUT, FAIL) \\ + do { \\ + sleep(simu_opt_waiting); \\ + if (opt == CHECK_TIMEOUT) { \\ + sleep(simu_opt_waiting * 10); \\ + VSS_LOG(LOG_INFO, "%s timeout simulation\\n", \\ + __func__); \\ + return (0); \\ + } else if (opt == CHECK_FAIL) { \\ + VSS_LOG(LOG_INFO, "%s failure simulation\\n", \\ + __func__); \\ + return (CHECK_FAIL); \\ + } else { \\ + VSS_LOG(LOG_INFO, "%s success simulation\\n", \\ + __func__); \\ + return (0); \\ + } \\ + } while (0) + +static int +check(int opt) +{ + GENERIC_OPT(CHECK_TIMEOUT, CHECK_FAIL); +} + +static int +freeze(int opt) +{ + GENERIC_OPT(FREEZE_TIMEOUT, FREEZE_FAIL); +} + +static int +thaw(int opt) +{ + GENERIC_OPT(THAW_TIMEOUT, THAW_FAIL); +} + +static void usage(const char* cmd) { + fprintf(stderr, + "%s -f <0|1|2>: simulate app freeze." + " 0: successful, 1: freeze timeout, 2: freeze failed\\n" + " -c <0|1|2>: simulate vss feature check" + " -t <0|1|2>: simulate app thaw." + " 0: successful, 1: freeze timeout, 2: freeze failed\\n" + " -d : enable debug mode\\n" + " -n : run this tool under non-daemon mode\\n", cmd); +} + +int +main(int argc, char* argv[]) { + int ch, freezesimuop = 0, thawsimuop = 0, checksimuop = 0, fd, r, error; + uint32_t op; + struct pollfd app_vss_fd[1]; + struct hv_vss_opt_msg userdata; + + while ((ch = getopt(argc, argv, "f:c:t:dnh")) != -1) { + switch (ch) { + case 'f': + /* Run as regular process for debugging purpose. */ + freezesimuop = (int)strtol(optarg, NULL, 10); + break; + case 't': + thawsimuop = (int)strtol(optarg, NULL, 10); + break; + case 'c': + checksimuop = (int)strtol(optarg, NULL, 10); + break; + case 'd': + is_debugging = 1; + break; + case 'n': + is_daemon = 0; + break; + case 'h': + default: + usage(argv[0]); + exit(0); + } + } + + openlog("APPVSS", 0, LOG_USER); + /* Become daemon first. */ + if (is_daemon == 1) + daemon(1, 0); + else + VSS_LOG(LOG_DEBUG, "Run as regular process.\\n"); + + VSS_LOG(LOG_INFO, "HV_VSS starting; pid is: %d\\n", getpid()); + + fd = open(VSS_DEV(APP_VSS_DEV_NAME), O_RDWR); + if (fd < 0) { + VSS_LOG(LOG_ERR, "Fail to open %s, error: %d %s\\n", + VSS_DEV(APP_VSS_DEV_NAME), errno, strerror(errno)); + exit(EXIT_FAILURE); + } + app_vss_fd[0].fd = fd; + app_vss_fd[0].events = POLLIN | POLLRDNORM; + + while (1) { + r = poll(app_vss_fd, 1, INFTIM); + + VSS_LOG(LOG_DEBUG, "poll returned r = %d, revent = 0x%x\\n", + r, app_vss_fd[0].revents); + + if (r == 0 || (r < 0 && errno == EAGAIN) || + (r < 0 && errno == EINTR)) { + /* Nothing to read */ + continue; + } + + if (r < 0) { + /* + * For poll return failure other than EAGAIN, + * we want to exit. + */ + VSS_LOG(LOG_ERR, "Poll failed.\\n"); + perror("poll"); + exit(EIO); + } + + /* Read from character device */ + error = ioctl(fd, IOCHVVSSREAD, &userdata); + if (error < 0) { + VSS_LOG(LOG_ERR, "Read failed.\\n"); + perror("pread"); + exit(EIO); + } + + if (userdata.status != 0) { + VSS_LOG(LOG_ERR, "data read error\\n"); + continue; + } + + op = userdata.opt; + + switch (op) { + case HV_VSS_CHECK: + error = check(checksimuop); + break; + case HV_VSS_FREEZE: + error = freeze(freezesimuop); + break; + case HV_VSS_THAW: + error = thaw(thawsimuop); + break; + default: + VSS_LOG(LOG_ERR, "Illegal operation: %d\\n", op); + error = VSS_FAIL; + } + if (error) + userdata.status = VSS_FAIL; + else + userdata.status = VSS_SUCCESS; + error = ioctl(fd, IOCHVVSSWRITE, &userdata); + if (error != 0) { + VSS_LOG(LOG_ERR, "Fail to write to device\\n"); + exit(EXIT_FAILURE); + } else { + VSS_LOG(LOG_INFO, "Send response %d for %s to kernel\\n", + userdata.status, op == HV_VSS_FREEZE ? "Freeze" : + (op == HV_VSS_THAW ? "Thaw" : "Check")); + } + } + return 0; +} +.Sh SEE ALSO +.Xr hv_vss_daemon 8 , +.Xr hv_utils 4 +.Sh HISTORY +The daemon was introduced in October 2016 and developed by Microsoft Corp. +.Sh AUTHORS +.An -nosplit +.Fx +support for +.Nm +was first added by +.An Microsoft BSD Integration Services Team Aq Mt bsdic@microsoft.com . Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/sys/conf/files.amd64 Thu Dec 29 05:32:34 2016 (r310735) @@ -268,6 +268,7 @@ dev/hyperv/netvsc/if_hn.c optional hy dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv +dev/hyperv/utilities/hv_snapshot.c optional hyperv dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Thu Dec 29 01:11:57 2016 (r310734) +++ stable/10/sys/conf/files.i386 Thu Dec 29 05:32:34 2016 (r310735) @@ -245,6 +245,7 @@ dev/hyperv/netvsc/if_hn.c optional hy dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv +dev/hyperv/utilities/hv_snapshot.c optional hyperv dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv Copied: stable/10/sys/dev/hyperv/utilities/hv_snapshot.c (from r308664, head/sys/dev/hyperv/utilities/hv_snapshot.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/utilities/hv_snapshot.c Thu Dec 29 05:32:34 2016 (r310735, copy of r308664, head/sys/dev/hyperv/utilities/hv_snapshot.c) @@ -0,0 +1,1061 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * 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 unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "hv_util.h" +#include "hv_snapshot.h" +#include "vmbus_if.h" + +#define VSS_MAJOR 5 +#define VSS_MINOR 0 +#define VSS_MSGVER VMBUS_IC_VERSION(VSS_MAJOR, VSS_MINOR) + +#define VSS_FWVER_MAJOR 3 +#define VSS_FWVER VMBUS_IC_VERSION(VSS_FWVER_MAJOR, 0) + +#define TIMEOUT_LIMIT (15) // seconds +enum hv_vss_op { + VSS_OP_CREATE = 0, + VSS_OP_DELETE, + VSS_OP_HOT_BACKUP, + VSS_OP_GET_DM_INFO, + VSS_OP_BU_COMPLETE, + /* + * Following operations are only supported with IC version >= 5.0 + */ + VSS_OP_FREEZE, /* Freeze the file systems in the VM */ + VSS_OP_THAW, /* Unfreeze the file systems */ + VSS_OP_AUTO_RECOVER, + VSS_OP_COUNT /* Number of operations, must be last */ +}; + +/* + * Header for all VSS messages. + */ +struct hv_vss_hdr { + struct vmbus_icmsg_hdr ic_hdr; + uint8_t operation; + uint8_t reserved[7]; +} __packed; + + +/* + * Flag values for the hv_vss_check_feature. Here supports only + * one value. + */ +#define VSS_HBU_NO_AUTO_RECOVERY 0x00000005 + +struct hv_vss_check_feature { + uint32_t flags; +} __packed; + +struct hv_vss_check_dm_info { + uint32_t flags; +} __packed; + +struct hv_vss_msg { + union { + struct hv_vss_hdr vss_hdr; + } hdr; + union { + struct hv_vss_check_feature vss_cf; + struct hv_vss_check_dm_info dm_info; + } body; +} __packed; + +struct hv_vss_req { + struct hv_vss_opt_msg opt_msg; /* used to communicate with daemon */ + struct hv_vss_msg msg; /* used to communicate with host */ +} __packed; + +/* hv_vss debug control */ +static int hv_vss_log = 0; + +#define hv_vss_log_error(...) do { \ + if (hv_vss_log > 0) \ + log(LOG_ERR, "hv_vss: " __VA_ARGS__); \ +} while (0) + +#define hv_vss_log_info(...) do { \ + if (hv_vss_log > 1) \ + log(LOG_INFO, "hv_vss: " __VA_ARGS__); \ +} while (0) + +static const struct vmbus_ic_desc vmbus_vss_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x29, 0x2e, 0xfa, 0x35, 0x23, 0xea, 0x36, 0x42, + 0x96, 0xae, 0x3a, 0x6e, 0xba, 0xcb, 0xa4, 0x40} }, + .ic_desc = "Hyper-V VSS" + }, + VMBUS_IC_DESC_END +}; + +static const char * vss_opt_name[] = {"None", "VSSCheck", "Freeze", "Thaw"}; + +/* character device prototypes */ +static d_open_t hv_vss_dev_open; +static d_close_t hv_vss_dev_close; +static d_poll_t hv_vss_dev_daemon_poll; +static d_ioctl_t hv_vss_dev_daemon_ioctl; + +static d_open_t hv_appvss_dev_open; +static d_close_t hv_appvss_dev_close; +static d_poll_t hv_appvss_dev_poll; +static d_ioctl_t hv_appvss_dev_ioctl; + +/* hv_vss character device structure */ +static struct cdevsw hv_vss_cdevsw = +{ + .d_version = D_VERSION, + .d_open = hv_vss_dev_open, + .d_close = hv_vss_dev_close, + .d_poll = hv_vss_dev_daemon_poll, + .d_ioctl = hv_vss_dev_daemon_ioctl, + .d_name = FS_VSS_DEV_NAME, +}; + +static struct cdevsw hv_appvss_cdevsw = +{ + .d_version = D_VERSION, + .d_open = hv_appvss_dev_open, + .d_close = hv_appvss_dev_close, + .d_poll = hv_appvss_dev_poll, + .d_ioctl = hv_appvss_dev_ioctl, + .d_name = APP_VSS_DEV_NAME, +}; + +struct hv_vss_sc; +/* + * Global state to track cdev + */ +struct hv_vss_dev_sc { + /* + * msg was transferred from host to notify queue, and + * ack queue. Finally, it was recyled to free list. + */ + STAILQ_HEAD(, hv_vss_req_internal) to_notify_queue; + STAILQ_HEAD(, hv_vss_req_internal) to_ack_queue; + struct hv_vss_sc *sc; + struct proc *proc_task; + struct selinfo hv_vss_selinfo; +}; +/* + * Global state to track and synchronize the transaction requests from the host. + * The VSS allows user to register their function to do freeze/thaw for application. + * VSS kernel will notify both vss daemon and user application if it is registered. + * The implementation state transition is illustrated by: + * https://clovertrail.github.io/assets/vssdot.png + */ +typedef struct hv_vss_sc { + struct hv_util_sc util_sc; + device_t dev; + + struct task task; + + /* + * mutex is used to protect access of list/queue, + * callout in request is also used this mutex. + */ + struct mtx pending_mutex; + /* + * req_free_list contains all free items + */ + LIST_HEAD(, hv_vss_req_internal) req_free_list; + + /* Indicates if daemon registered with driver */ + boolean_t register_done; + + boolean_t app_register_done; + + /* cdev for file system freeze/thaw */ + struct cdev *hv_vss_dev; + /* cdev for application freeze/thaw */ + struct cdev *hv_appvss_dev; + + /* sc for app */ + struct hv_vss_dev_sc app_sc; + /* sc for deamon */ + struct hv_vss_dev_sc daemon_sc; +} hv_vss_sc; + +typedef struct hv_vss_req_internal { + LIST_ENTRY(hv_vss_req_internal) link; + STAILQ_ENTRY(hv_vss_req_internal) slink; + struct hv_vss_req vss_req; + + /* Rcv buffer for communicating with the host*/ + uint8_t *rcv_buf; + /* Length of host message */ + uint32_t host_msg_len; + /* Host message id */ + uint64_t host_msg_id; + + hv_vss_sc *sc; + + struct callout callout; +} hv_vss_req_internal; + +#define SEARCH_REMOVE_REQ_LOCKED(reqp, queue, link, tmp, id) \ + do { \ + STAILQ_FOREACH_SAFE(reqp, queue, link, tmp) { \ + if (reqp->vss_req.opt_msg.msgid == id) { \ + STAILQ_REMOVE(queue, \ + reqp, hv_vss_req_internal, link); \ + break; \ + } \ + } \ + } while (0) + +static bool +hv_vss_is_daemon_killed_after_launch(hv_vss_sc *sc) +{ + return (!sc->register_done && sc->daemon_sc.proc_task); +} + +/* + * Callback routine that gets called whenever there is a message from host + */ +static void +hv_vss_callback(struct vmbus_channel *chan __unused, void *context) +{ + hv_vss_sc *sc = (hv_vss_sc*)context; + if (hv_vss_is_daemon_killed_after_launch(sc)) + hv_vss_log_info("%s: daemon was killed!\n", __func__); + if (sc->register_done || sc->daemon_sc.proc_task) { + hv_vss_log_info("%s: Queuing work item\n", __func__); + if (hv_vss_is_daemon_killed_after_launch(sc)) + hv_vss_log_info("%s: daemon was killed!\n", __func__); + taskqueue_enqueue(taskqueue_thread, &sc->task); + } else { + hv_vss_log_info("%s: daemon has never been registered\n", __func__); + } + hv_vss_log_info("%s: received msg from host\n", __func__); +} +/* + * Send the response back to the host. + */ +static void +hv_vss_respond_host(uint8_t *rcv_buf, struct vmbus_channel *ch, + uint32_t recvlen, uint64_t requestid, uint32_t error) +{ + struct vmbus_icmsg_hdr *hv_icmsg_hdrp; + + hv_icmsg_hdrp = (struct vmbus_icmsg_hdr *)rcv_buf; + + hv_icmsg_hdrp->ic_status = error; + hv_icmsg_hdrp->ic_flags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; + + error = vmbus_chan_send(ch, VMBUS_CHANPKT_TYPE_INBAND, 0, + rcv_buf, recvlen, requestid); + if (error) + hv_vss_log_info("%s: hv_vss_respond_host: sendpacket error:%d\n", + __func__, error); +} + +static void +hv_vss_notify_host_result_locked(struct hv_vss_req_internal *reqp, uint32_t status) +{ + struct hv_vss_msg* msg = (struct hv_vss_msg *)reqp->rcv_buf; + hv_vss_sc *sc = reqp->sc; + if (reqp->vss_req.opt_msg.opt == HV_VSS_CHECK) { + msg->body.vss_cf.flags = VSS_HBU_NO_AUTO_RECOVERY; + } + hv_vss_log_info("%s, %s response %s to host\n", __func__, + vss_opt_name[reqp->vss_req.opt_msg.opt], + status == HV_S_OK ? "Success" : "Fail"); + hv_vss_respond_host(reqp->rcv_buf, vmbus_get_channel(reqp->sc->dev), + reqp->host_msg_len, reqp->host_msg_id, status); + /* recycle the request */ + LIST_INSERT_HEAD(&sc->req_free_list, reqp, link); +} + +static void +hv_vss_notify_host_result(struct hv_vss_req_internal *reqp, uint32_t status) +{ + mtx_lock(&reqp->sc->pending_mutex); + hv_vss_notify_host_result_locked(reqp, status); + mtx_unlock(&reqp->sc->pending_mutex); +} + +static void +hv_vss_cp_vssreq_to_user(struct hv_vss_req_internal *reqp, + struct hv_vss_opt_msg *userdata) +{ + struct hv_vss_req *hv_vss_dev_buf; + hv_vss_dev_buf = &reqp->vss_req; + hv_vss_dev_buf->opt_msg.opt = HV_VSS_NONE; + switch (reqp->vss_req.msg.hdr.vss_hdr.operation) { + case VSS_OP_FREEZE: + hv_vss_dev_buf->opt_msg.opt = HV_VSS_FREEZE; + break; + case VSS_OP_THAW: + hv_vss_dev_buf->opt_msg.opt = HV_VSS_THAW; + break; + case VSS_OP_HOT_BACKUP: + hv_vss_dev_buf->opt_msg.opt = HV_VSS_CHECK; + break; + } + *userdata = hv_vss_dev_buf->opt_msg; + hv_vss_log_info("%s, read data from user for " + "%s (%ju) \n", __func__, vss_opt_name[userdata->opt], + (uintmax_t)userdata->msgid); +} + +/** + * Remove the request id from app notifiy or ack queue, + * and recyle the request by inserting it to free list. + * + * When app was notified but not yet sending ack, the request + * should locate in either notify queue or ack queue. + */ +static struct hv_vss_req_internal* +hv_vss_drain_req_queue_locked(hv_vss_sc *sc, uint64_t req_id) +{ + struct hv_vss_req_internal *reqp, *tmp; + SEARCH_REMOVE_REQ_LOCKED(reqp, &sc->daemon_sc.to_notify_queue, + slink, tmp, req_id); + if (reqp == NULL) + SEARCH_REMOVE_REQ_LOCKED(reqp, &sc->daemon_sc.to_ack_queue, + slink, tmp, req_id); + if (reqp == NULL) + SEARCH_REMOVE_REQ_LOCKED(reqp, &sc->app_sc.to_notify_queue, + slink, tmp, req_id); + if (reqp == NULL) + SEARCH_REMOVE_REQ_LOCKED(reqp, &sc->app_sc.to_ack_queue, slink, + tmp, req_id); + return (reqp); +} +/** + * Actions for daemon who has been notified. + */ +static void +hv_vss_notified(struct hv_vss_dev_sc *dev_sc, struct hv_vss_opt_msg *userdata) +{ + struct hv_vss_req_internal *reqp; + mtx_lock(&dev_sc->sc->pending_mutex); + if (!STAILQ_EMPTY(&dev_sc->to_notify_queue)) { + reqp = STAILQ_FIRST(&dev_sc->to_notify_queue); + hv_vss_cp_vssreq_to_user(reqp, userdata); + STAILQ_REMOVE_HEAD(&dev_sc->to_notify_queue, slink); + /* insert the msg to queue for write */ + STAILQ_INSERT_TAIL(&dev_sc->to_ack_queue, reqp, slink); + userdata->status = VSS_SUCCESS; + } else { + /* Timeout occur, thus request was removed from queue. */ + hv_vss_log_info("%s: notify queue is empty!\n", __func__); + userdata->status = VSS_FAIL; + } + mtx_unlock(&dev_sc->sc->pending_mutex); +} + +static void +hv_vss_notify(struct hv_vss_dev_sc *dev_sc, struct hv_vss_req_internal *reqp) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:06:07 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 5A2C7C9586B; Thu, 29 Dec 2016 06:06:07 +0000 (UTC) (envelope-from sephe@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 17D021BA0; Thu, 29 Dec 2016 06:06:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6667D029135; Thu, 29 Dec 2016 06:06:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT666hx029131; Thu, 29 Dec 2016 06:06:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290606.uBT666hx029131@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:06:06 +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: r310736 - stable/10/sys/dev/hyperv/netvsc 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.23 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, 29 Dec 2016 06:06:07 -0000 Author: sephe Date: Thu Dec 29 06:06:05 2016 New Revision: 310736 URL: https://svnweb.freebsd.org/changeset/base/310736 Log: MFC 308905 hyperv/hn: Implement RNDIS multi-packet message support. Currently, it is only applied to packet sent through chimney sending buffers. Not enabled by default yet. This one gives 20%~30% performance boost for non-TSO usage in both bit/packet rate tests and nginx performance test. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8560 Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 05:32:34 2016 (r310735) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 06:06:05 2016 (r310736) @@ -839,11 +839,15 @@ hn_rndis_init(struct hn_softc *sc) error = EIO; goto done; } + sc->hn_rndis_agg_size = comp->rm_pktmaxsz; + sc->hn_rndis_agg_pkts = comp->rm_pktmaxcnt; + sc->hn_rndis_agg_align = 1U << comp->rm_align; + if (bootverbose) { if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u, " "align %u\n", comp->rm_ver_major, comp->rm_ver_minor, - comp->rm_pktmaxsz, comp->rm_pktmaxcnt, - 1U << comp->rm_align); + sc->hn_rndis_agg_size, sc->hn_rndis_agg_pkts, + sc->hn_rndis_agg_align); } error = 0; done: Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 05:32:34 2016 (r310735) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:06:05 2016 (r310736) @@ -162,10 +162,22 @@ __FBSDID("$FreeBSD$"); #define HN_CSUM_IP6_HWASSIST(sc) \ ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) +#define HN_PKTSIZE_MIN(align) \ + roundup2(ETHER_MIN_LEN + ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN + \ + HN_RNDIS_PKT_LEN, (align)) +#define HN_PKTSIZE(m, align) \ + roundup2((m)->m_pkthdr.len + HN_RNDIS_PKT_LEN, (align)) + struct hn_txdesc { #ifndef HN_USE_TXDESC_BUFRING SLIST_ENTRY(hn_txdesc) link; #endif + STAILQ_ENTRY(hn_txdesc) agg_link; + + /* Aggregated txdescs, in sending order. */ + STAILQ_HEAD(, hn_txdesc) agg_list; + + /* The oldest packet, if transmission aggregation happens. */ struct mbuf *m; struct hn_tx_ring *txr; int refs; @@ -183,6 +195,7 @@ struct hn_txdesc { #define HN_TXD_FLAG_ONLIST 0x0001 #define HN_TXD_FLAG_DMAMAP 0x0002 +#define HN_TXD_FLAG_ONAGG 0x0004 struct hn_rxinfo { uint32_t vlan_info; @@ -262,6 +275,10 @@ static int hn_rxfilter_sysctl(SYSCTL_H static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_size_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *); static void hn_init_locked(struct hn_softc *); @@ -309,7 +326,7 @@ static int hn_create_tx_data(struct hn static void hn_fixup_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); -static int hn_encap(struct hn_tx_ring *, +static int hn_encap(struct ifnet *, struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_txpkt(struct ifnet *, struct hn_tx_ring *, struct hn_txdesc *); @@ -318,6 +335,10 @@ static void hn_set_tso_maxsize(struct static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_resume_tx(struct hn_softc *, int); +static void hn_set_txagg(struct hn_softc *); +static void *hn_try_txagg(struct ifnet *, + struct hn_tx_ring *, struct hn_txdesc *, + int); static int hn_get_txswq_depth(const struct hn_tx_ring *); static void hn_txpkt_done(struct hn_nvs_sendctx *, struct hn_softc *, struct vmbus_channel *, @@ -433,6 +454,16 @@ SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_ &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); #endif +/* Packet transmission aggregation size limit */ +static int hn_tx_agg_size = -1; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_size, CTLFLAG_RDTUN, + &hn_tx_agg_size, 0, "Packet transmission aggregation size limit"); + +/* Packet transmission aggregation count limit */ +static int hn_tx_agg_pkts = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_pkts, CTLFLAG_RDTUN, + &hn_tx_agg_pkts, 0, "Packet transmission aggregation packet limit"); + static u_int hn_cpu_index; /* next CPU for channel */ static struct taskqueue *hn_tx_taskq; /* shared TX taskqueue */ @@ -661,6 +692,84 @@ hn_set_rxfilter(struct hn_softc *sc) return (error); } +static void +hn_set_txagg(struct hn_softc *sc) +{ + uint32_t size, pkts; + int i; + + /* + * Setup aggregation size. + */ + if (sc->hn_agg_size < 0) + size = UINT32_MAX; + else + size = sc->hn_agg_size; + + if (sc->hn_rndis_agg_size < size) + size = sc->hn_rndis_agg_size; + + if (size <= 2 * HN_PKTSIZE_MIN(sc->hn_rndis_agg_align)) { + /* Disable */ + size = 0; + pkts = 0; + goto done; + } + + /* NOTE: Type of the per TX ring setting is 'int'. */ + if (size > INT_MAX) + size = INT_MAX; + + /* NOTE: We only aggregate packets using chimney sending buffers. */ + if (size > (uint32_t)sc->hn_chim_szmax) + size = sc->hn_chim_szmax; + + /* + * Setup aggregation packet count. + */ + if (sc->hn_agg_pkts < 0) + pkts = UINT32_MAX; + else + pkts = sc->hn_agg_pkts; + + if (sc->hn_rndis_agg_pkts < pkts) + pkts = sc->hn_rndis_agg_pkts; + + if (pkts <= 1) { + /* Disable */ + size = 0; + pkts = 0; + goto done; + } + + /* NOTE: Type of the per TX ring setting is 'short'. */ + if (pkts > SHRT_MAX) + pkts = SHRT_MAX; + +done: + /* NOTE: Type of the per TX ring setting is 'short'. */ + if (sc->hn_rndis_agg_align > SHRT_MAX) { + /* Disable */ + size = 0; + pkts = 0; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "TX agg size %u, pkts %u, align %u\n", + size, pkts, sc->hn_rndis_agg_align); + } + + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_agg_szmax = size; + txr->hn_agg_pktmax = pkts; + txr->hn_agg_align = sc->hn_rndis_agg_align; + mtx_unlock(&txr->hn_tx_lock); + } +} + static int hn_get_txswq_depth(const struct hn_tx_ring *txr) { @@ -801,6 +910,12 @@ hn_attach(device_t dev) HN_LOCK_INIT(sc); /* + * Initialize these tunables once. + */ + sc->hn_agg_size = hn_tx_agg_size; + sc->hn_agg_pkts = hn_tx_agg_pkts; + + /* * Setup taskqueue for transmission. */ if (hn_tx_taskq == NULL) { @@ -956,6 +1071,24 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_ind", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_ind_sysctl, "IU", "RSS indirect table"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_size", + CTLFLAG_RD, &sc->hn_rndis_agg_size, 0, + "RNDIS offered packet transmission aggregation size limit"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_pkts", + CTLFLAG_RD, &sc->hn_rndis_agg_pkts, 0, + "RNDIS offered packet transmission aggregation count limit"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rndis_agg_align", + CTLFLAG_RD, &sc->hn_rndis_agg_align, 0, + "RNDIS packet transmission aggregation alignment"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_size", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_size_sysctl, "I", + "Packet transmission aggregation size, 0 -- disable, -1 -- auto"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_pkts", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_pkts_sysctl, "I", + "Packet transmission aggregation packets, " + "0 -- disable, -1 -- auto"); /* * Setup the ifmedia, which has been initialized earlier. @@ -1211,16 +1344,45 @@ hn_txdesc_put(struct hn_tx_ring *txr, st KASSERT((txd->flags & HN_TXD_FLAG_ONLIST) == 0, ("put an onlist txd %#x", txd->flags)); + KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("put an onagg txd %#x", txd->flags)); KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs)); if (atomic_fetchadd_int(&txd->refs, -1) != 1) return 0; + if (!STAILQ_EMPTY(&txd->agg_list)) { + struct hn_txdesc *tmp_txd; + + while ((tmp_txd = STAILQ_FIRST(&txd->agg_list)) != NULL) { + int freed; + + KASSERT(STAILQ_EMPTY(&tmp_txd->agg_list), + ("resursive aggregation on aggregated txdesc")); + KASSERT((tmp_txd->flags & HN_TXD_FLAG_ONAGG), + ("not aggregated txdesc")); + KASSERT((tmp_txd->flags & HN_TXD_FLAG_DMAMAP) == 0, + ("aggregated txdesc uses dmamap")); + KASSERT(tmp_txd->chim_index == HN_NVS_CHIM_IDX_INVALID, + ("aggregated txdesc consumes " + "chimney sending buffer")); + KASSERT(tmp_txd->chim_size == 0, + ("aggregated txdesc has non-zero " + "chimney sending size")); + + STAILQ_REMOVE_HEAD(&txd->agg_list, agg_link); + tmp_txd->flags &= ~HN_TXD_FLAG_ONAGG; + freed = hn_txdesc_put(txr, tmp_txd); + KASSERT(freed, ("failed to free aggregated txdesc")); + } + } + if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("chim txd uses dmamap")); hn_chim_free(txr->hn_sc, txd->chim_index); txd->chim_index = HN_NVS_CHIM_IDX_INVALID; + txd->chim_size = 0; } else if (txd->flags & HN_TXD_FLAG_DMAMAP) { bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap, BUS_DMASYNC_POSTWRITE); @@ -1275,8 +1437,11 @@ hn_txdesc_get(struct hn_tx_ring *txr) atomic_subtract_int(&txr->hn_txdesc_avail, 1); #endif KASSERT(txd->m == NULL && txd->refs == 0 && + STAILQ_EMPTY(&txd->agg_list) && txd->chim_index == HN_NVS_CHIM_IDX_INVALID && + txd->chim_size == 0 && (txd->flags & HN_TXD_FLAG_ONLIST) && + (txd->flags & HN_TXD_FLAG_ONAGG) == 0 && (txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("invalid txd")); txd->flags &= ~HN_TXD_FLAG_ONLIST; txd->refs = 1; @@ -1293,6 +1458,22 @@ hn_txdesc_hold(struct hn_txdesc *txd) atomic_add_int(&txd->refs, 1); } +static __inline void +hn_txdesc_agg(struct hn_txdesc *agg_txd, struct hn_txdesc *txd) +{ + + KASSERT((agg_txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("recursive aggregation on aggregating txdesc")); + + KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, + ("already aggregated")); + KASSERT(STAILQ_EMPTY(&txd->agg_list), + ("recursive aggregation on to-be-aggregated txdesc")); + + txd->flags |= HN_TXD_FLAG_ONAGG; + STAILQ_INSERT_TAIL(&agg_txd->agg_list, txd, agg_link); +} + static bool hn_tx_ring_pending(struct hn_tx_ring *txr) { @@ -1410,12 +1591,123 @@ hn_rndis_pktinfo_append(struct rndis_pac return (pi->rm_data); } +static __inline int +hn_flush_txagg(struct ifnet *ifp, struct hn_tx_ring *txr) +{ + struct hn_txdesc *txd; + struct mbuf *m; + int error, pkts; + + txd = txr->hn_agg_txd; + KASSERT(txd != NULL, ("no aggregate txdesc")); + + /* + * Since hn_txpkt() will reset this temporary stat, save + * it now, so that oerrors can be updated properly, if + * hn_txpkt() ever fails. + */ + pkts = txr->hn_stat_pkts; + + /* + * Since txd's mbuf will _not_ be freed upon hn_txpkt() + * failure, save it for later freeing, if hn_txpkt() ever + * fails. + */ + m = txd->m; + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m is not. */ + m_freem(m); + + txr->hn_flush_failed++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, pkts); + } + + /* Reset all aggregation states. */ + txr->hn_agg_txd = NULL; + txr->hn_agg_szleft = 0; + txr->hn_agg_pktleft = 0; + txr->hn_agg_prevpkt = NULL; + + return (error); +} + +static void * +hn_try_txagg(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, + int pktsize) +{ + void *chim; + + if (txr->hn_agg_txd != NULL) { + if (txr->hn_agg_pktleft >= 1 && txr->hn_agg_szleft > pktsize) { + struct hn_txdesc *agg_txd = txr->hn_agg_txd; + struct rndis_packet_msg *pkt = txr->hn_agg_prevpkt; + int olen; + + /* + * Update the previous RNDIS packet's total length, + * it can be increased due to the mandatory alignment + * padding for this RNDIS packet. And update the + * aggregating txdesc's chimney sending buffer size + * accordingly. + * + * XXX + * Zero-out the padding, as required by the RNDIS spec. + */ + olen = pkt->rm_len; + pkt->rm_len = roundup2(olen, txr->hn_agg_align); + agg_txd->chim_size += pkt->rm_len - olen; + + /* Link this txdesc to the parent. */ + hn_txdesc_agg(agg_txd, txd); + + chim = (uint8_t *)pkt + pkt->rm_len; + /* Save the current packet for later fixup. */ + txr->hn_agg_prevpkt = chim; + + txr->hn_agg_pktleft--; + txr->hn_agg_szleft -= pktsize; + if (txr->hn_agg_szleft <= + HN_PKTSIZE_MIN(txr->hn_agg_align)) { + /* + * Probably can't aggregate more packets, + * flush this aggregating txdesc proactively. + */ + txr->hn_agg_pktleft = 0; + } + /* Done! */ + return (chim); + } + hn_flush_txagg(ifp, txr); + } + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); + + txr->hn_tx_chimney_tried++; + txd->chim_index = hn_chim_alloc(txr->hn_sc); + if (txd->chim_index == HN_NVS_CHIM_IDX_INVALID) + return (NULL); + txr->hn_tx_chimney++; + + chim = txr->hn_sc->hn_chim + + (txd->chim_index * txr->hn_sc->hn_chim_szmax); + + if (txr->hn_agg_pktmax > 1 && + txr->hn_agg_szmax > pktsize + HN_PKTSIZE_MIN(txr->hn_agg_align)) { + txr->hn_agg_txd = txd; + txr->hn_agg_pktleft = txr->hn_agg_pktmax - 1; + txr->hn_agg_szleft = txr->hn_agg_szmax - pktsize; + txr->hn_agg_prevpkt = chim; + } + return (chim); +} + /* * NOTE: * If this function fails, then both txd and m_head0 will be freed. */ static int -hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) +hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, + struct mbuf **m_head0) { bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; @@ -1423,33 +1715,30 @@ hn_encap(struct hn_tx_ring *txr, struct struct rndis_packet_msg *pkt; uint32_t *pi_data; void *chim = NULL; - int pktlen; + int pkt_hlen, pkt_size; pkt = txd->rndis_pkt; - if (m_head->m_pkthdr.len + HN_RNDIS_PKT_LEN < txr->hn_chim_size) { - /* - * This packet is small enough to fit into a chimney sending - * buffer. Try allocating one chimney sending buffer now. - */ - txr->hn_tx_chimney_tried++; - txd->chim_index = hn_chim_alloc(txr->hn_sc); - if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { - chim = txr->hn_sc->hn_chim + - (txd->chim_index * txr->hn_sc->hn_chim_szmax); - /* - * Directly fill the chimney sending buffer w/ the - * RNDIS packet message. - */ + pkt_size = HN_PKTSIZE(m_head, txr->hn_agg_align); + if (pkt_size < txr->hn_chim_size) { + chim = hn_try_txagg(ifp, txr, txd, pkt_size); + if (chim != NULL) pkt = chim; - } + } else { + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); } pkt->rm_type = REMOTE_NDIS_PACKET_MSG; pkt->rm_len = sizeof(*pkt) + m_head->m_pkthdr.len; pkt->rm_dataoffset = sizeof(*pkt); pkt->rm_datalen = m_head->m_pkthdr.len; + pkt->rm_oobdataoffset = 0; + pkt->rm_oobdatalen = 0; + pkt->rm_oobdataelements = 0; pkt->rm_pktinfooffset = sizeof(*pkt); pkt->rm_pktinfolen = 0; + pkt->rm_vchandle = 0; + pkt->rm_reserved = 0; if (txr->hn_tx_flags & HN_TX_FLAG_HASHVAL) { /* @@ -1510,7 +1799,7 @@ hn_encap(struct hn_tx_ring *txr, struct *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } - pktlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; + pkt_hlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; /* Convert RNDIS packet message offsets */ pkt->rm_dataoffset = hn_rndis_pktmsg_offset(pkt->rm_dataoffset); pkt->rm_pktinfooffset = hn_rndis_pktmsg_offset(pkt->rm_pktinfooffset); @@ -1519,25 +1808,36 @@ hn_encap(struct hn_tx_ring *txr, struct * Fast path: Chimney sending. */ if (chim != NULL) { - KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID, - ("chimney buffer is not used")); - KASSERT(pkt == chim, ("RNDIS pkt not in chimney buffer")); + struct hn_txdesc *tgt_txd = txd; + + if (txr->hn_agg_txd != NULL) { + tgt_txd = txr->hn_agg_txd; +#ifdef INVARIANTS + *m_head0 = NULL; +#endif + } + + KASSERT(pkt == chim, + ("RNDIS pkt not in chimney sending buffer")); + KASSERT(tgt_txd->chim_index != HN_NVS_CHIM_IDX_INVALID, + ("chimney sending buffer is not used")); + tgt_txd->chim_size += pkt->rm_len; m_copydata(m_head, 0, m_head->m_pkthdr.len, - ((uint8_t *)chim) + pktlen); + ((uint8_t *)chim) + pkt_hlen); - txd->chim_size = pkt->rm_len; txr->hn_gpa_cnt = 0; - txr->hn_tx_chimney++; txr->hn_sendpkt = hn_txpkt_chim; goto done; } + + KASSERT(txr->hn_agg_txd == NULL, ("aggregating sglist txdesc")); KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, ("chimney buffer is used")); KASSERT(pkt == txd->rndis_pkt, ("RNDIS pkt not in txdesc")); error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs); - if (error) { + if (__predict_false(error)) { int freed; /* @@ -1551,7 +1851,7 @@ hn_encap(struct hn_tx_ring *txr, struct ("fail to free txd upon txdma error")); txr->hn_txdma_failed++; - if_inc_counter(txr->hn_sc->hn_ifp, IFCOUNTER_OERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return error; } *m_head0 = m_head; @@ -1562,7 +1862,7 @@ hn_encap(struct hn_tx_ring *txr, struct /* send packet with page buffer */ txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr); txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK; - txr->hn_gpa[0].gpa_len = pktlen; + txr->hn_gpa[0].gpa_len = pkt_hlen; /* * Fill the page buffers with mbuf info after the page @@ -1585,6 +1885,12 @@ done: /* Set the completion routine */ hn_nvs_sendctx_init(&txd->send_ctx, hn_txpkt_done, txd); + /* Update temporary stats for later use. */ + txr->hn_stat_pkts++; + txr->hn_stat_size += m_head->m_pkthdr.len; + if (m_head->m_flags & M_MCAST) + txr->hn_stat_mcasts++; + return 0; } @@ -1600,23 +1906,34 @@ hn_txpkt(struct ifnet *ifp, struct hn_tx again: /* - * Make sure that txd is not freed before ETHER_BPF_MTAP. + * Make sure that this txd and any aggregated txds are not freed + * before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); error = txr->hn_sendpkt(txr, txd); if (!error) { - ETHER_BPF_MTAP(ifp, txd->m); - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if (bpf_peers_present(ifp->if_bpf)) { + const struct hn_txdesc *tmp_txd; + + ETHER_BPF_MTAP(ifp, txd->m); + STAILQ_FOREACH(tmp_txd, &txd->agg_list, agg_link) + ETHER_BPF_MTAP(ifp, tmp_txd->m); + } + + if_inc_counter(ifp, IFCOUNTER_OPACKETS, txr->hn_stat_pkts); #ifdef HN_IFSTART_SUPPORT if (!hn_use_if_start) #endif { if_inc_counter(ifp, IFCOUNTER_OBYTES, - txd->m->m_pkthdr.len); - if (txd->m->m_flags & M_MCAST) - if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); + txr->hn_stat_size); + if (txr->hn_stat_mcasts != 0) { + if_inc_counter(ifp, IFCOUNTER_OMCASTS, + txr->hn_stat_mcasts); + } } - txr->hn_pkts++; + txr->hn_pkts += txr->hn_stat_pkts; + txr->hn_sends++; } hn_txdesc_put(txr, txd); @@ -1656,7 +1973,13 @@ again: txr->hn_send_failed++; } - return error; + + /* Reset temporary stats, after this sending is done. */ + txr->hn_stat_size = 0; + txr->hn_stat_pkts = 0; + txr->hn_stat_mcasts = 0; + + return (error); } /* @@ -2438,6 +2761,64 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG } static int +hn_txagg_size_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error, size; + + size = sc->hn_agg_size; + error = sysctl_handle_int(oidp, &size, 0, req); + if (error || req->newptr == NULL) + return (error); + + HN_LOCK(sc); + sc->hn_agg_size = size; + hn_set_txagg(sc); + HN_UNLOCK(sc); + + return (0); +} + +static int +hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error, pkts; + + pkts = sc->hn_agg_pkts; + error = sysctl_handle_int(oidp, &pkts, 0, req); + if (error || req->newptr == NULL) + return (error); + + HN_LOCK(sc); + sc->hn_agg_pkts = pkts; + hn_set_txagg(sc); + HN_UNLOCK(sc); + + return (0); +} + +static int +hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int pkts; + + pkts = sc->hn_tx_ring[0].hn_agg_pktmax; + return (sysctl_handle_int(oidp, &pkts, 0, req)); +} + +static int +hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int align; + + align = sc->hn_tx_ring[0].hn_agg_align; + return (sysctl_handle_int(oidp, &align, 0, req)); +} + +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -2980,6 +3361,7 @@ hn_tx_ring_create(struct hn_softc *sc, i txd->txr = txr; txd->chim_index = HN_NVS_CHIM_IDX_INVALID; + STAILQ_INIT(&txd->agg_list); /* * Allocate and load RNDIS packet message. @@ -3063,6 +3445,8 @@ hn_tx_ring_create(struct hn_softc *sc, i SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "packets", CTLFLAG_RW, &txr->hn_pkts, "# of packets transmitted"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "sends", + CTLFLAG_RW, &txr->hn_sends, "# of sends"); } } @@ -3177,6 +3561,11 @@ hn_create_tx_data(struct hn_softc *sc, i CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_tx_ring, hn_txdma_failed), hn_tx_stat_ulong_sysctl, "LU", "# of TX DMA failure"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_flush_failed", + CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, + __offsetof(struct hn_tx_ring, hn_flush_failed), + hn_tx_stat_ulong_sysctl, "LU", + "# of packet transmission aggregation flush failure"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tx_collapsed", CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_tx_ring, hn_tx_collapsed), @@ -3213,6 +3602,17 @@ hn_create_tx_data(struct hn_softc *sc, i CTLFLAG_RD, &sc->hn_tx_ring_cnt, 0, "# created TX rings"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_inuse", CTLFLAG_RD, &sc->hn_tx_ring_inuse, 0, "# used TX rings"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "agg_szmax", + CTLFLAG_RD, &sc->hn_tx_ring[0].hn_agg_szmax, 0, + "Applied packet transmission aggregation size"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_pktmax", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_pktmax_sysctl, "I", + "Applied packet transmission aggregation packets"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "agg_align", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_txagg_align_sysctl, "I", + "Applied packet transmission aggregation alignment"); return 0; } @@ -3332,18 +3732,20 @@ hn_start_locked(struct hn_tx_ring *txr, { struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; + int sched = 0; KASSERT(hn_use_if_start, ("hn_start_locked is called, when if_start is disabled")); KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); mtx_assert(&txr->hn_tx_lock, MA_OWNED); + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); if (__predict_false(txr->hn_suspended)) - return 0; + return (0); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) - return 0; + return (0); while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { struct hn_txdesc *txd; @@ -3361,7 +3763,8 @@ hn_start_locked(struct hn_tx_ring *txr, * following up packets) to tx taskqueue. */ IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - return 1; + sched = 1; + break; } #if defined(INET6) || defined(INET) @@ -3382,21 +3785,50 @@ hn_start_locked(struct hn_tx_ring *txr, break; } - error = hn_encap(txr, txd, &m_head); + error = hn_encap(ifp, txr, txd, &m_head); if (error) { /* Both txd and m_head are freed */ + KASSERT(txr->hn_agg_txd == NULL, + ("encap failed w/ pending aggregating txdesc")); continue; } - error = hn_txpkt(ifp, txr, txd); - if (__predict_false(error)) { - /* txd is freed, but m_head is not */ - IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - break; + if (txr->hn_agg_pktleft == 0) { + if (txr->hn_agg_txd != NULL) { + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + error = hn_flush_txagg(ifp, txr); + if (__predict_false(error)) { + atomic_set_int(&ifp->if_drv_flags, + IFF_DRV_OACTIVE); + break; + } + } else { + KASSERT(m_head != NULL, ("mbuf was freed")); + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); + atomic_set_int(&ifp->if_drv_flags, + IFF_DRV_OACTIVE); + break; + } + } + } +#ifdef INVARIANTS + else { + KASSERT(txr->hn_agg_txd != NULL, + ("no aggregating txdesc")); + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); } +#endif } - return 0; + + /* Flush pending aggerated transmission. */ + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); + return (sched); } static void @@ -3473,18 +3905,20 @@ hn_xmit(struct hn_tx_ring *txr, int len) struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; struct mbuf *m_head; + int sched = 0; mtx_assert(&txr->hn_tx_lock, MA_OWNED); #ifdef HN_IFSTART_SUPPORT KASSERT(hn_use_if_start == 0, ("hn_xmit is called, when if_start is enabled")); #endif + KASSERT(txr->hn_agg_txd == NULL, ("lingering aggregating txdesc")); if (__predict_false(txr->hn_suspended)) - return 0; + return (0); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || txr->hn_oactive) - return 0; + return (0); while ((m_head = drbr_peek(ifp, txr->hn_mbuf_br)) != NULL) { struct hn_txdesc *txd; @@ -3497,7 +3931,8 @@ hn_xmit(struct hn_tx_ring *txr, int len) * following up packets) to tx taskqueue. */ drbr_putback(ifp, txr->hn_mbuf_br, m_head); - return 1; + sched = 1; + break; } txd = hn_txdesc_get(txr); @@ -3508,25 +3943,53 @@ hn_xmit(struct hn_tx_ring *txr, int len) break; } - error = hn_encap(txr, txd, &m_head); + error = hn_encap(ifp, txr, txd, &m_head); if (error) { /* Both txd and m_head are freed; discard */ + KASSERT(txr->hn_agg_txd == NULL, + ("encap failed w/ pending aggregating txdesc")); drbr_advance(ifp, txr->hn_mbuf_br); continue; } - error = hn_txpkt(ifp, txr, txd); - if (__predict_false(error)) { - /* txd is freed, but m_head is not */ - drbr_putback(ifp, txr->hn_mbuf_br, m_head); - txr->hn_oactive = 1; - break; + if (txr->hn_agg_pktleft == 0) { + if (txr->hn_agg_txd != NULL) { + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + error = hn_flush_txagg(ifp, txr); + if (__predict_false(error)) { + txr->hn_oactive = 1; + break; + } + } else { + KASSERT(m_head != NULL, ("mbuf was freed")); + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + drbr_putback(ifp, txr->hn_mbuf_br, + m_head); + txr->hn_oactive = 1; + break; + } + } } +#ifdef INVARIANTS + else { + KASSERT(txr->hn_agg_txd != NULL, + ("no aggregating txdesc")); + KASSERT(m_head == NULL, + ("pending mbuf for aggregating txdesc")); + } +#endif /* Sent */ drbr_advance(ifp, txr->hn_mbuf_br); } - return 0; + + /* Flush pending aggerated transmission. */ + if (txr->hn_agg_txd != NULL) + hn_flush_txagg(ifp, txr); + return (sched); } static int @@ -4004,6 +4467,11 @@ back: if (error) return (error); + /* + * Fixup transmission aggregation setup. + */ + hn_set_txagg(sc); + sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; return (0); } Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 05:32:34 2016 (r310735) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 06:06:05 2016 (r310736) @@ -125,6 +125,22 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + /* Applied packet transmission aggregation limits. */ + int hn_agg_szmax; + short hn_agg_pktmax; + short hn_agg_align; + + /* Packet transmission aggregation states. */ + struct hn_txdesc *hn_agg_txd; + int hn_agg_szleft; + short hn_agg_pktleft; + struct rndis_packet_msg *hn_agg_prevpkt; + + /* Temporary stats for each sends. */ + int hn_stat_size; + short hn_stat_pkts; + short hn_stat_mcasts; + int (*hn_sendpkt)(struct hn_tx_ring *, struct hn_txdesc *); int hn_suspended; int hn_gpa_cnt; @@ -137,6 +153,8 @@ struct hn_tx_ring { u_long hn_tx_chimney_tried; u_long hn_tx_chimney; u_long hn_pkts; + u_long hn_sends; + u_long hn_flush_failed; /* Rarely used stuffs */ struct hn_txdesc *hn_txdesc; @@ -181,6 +199,10 @@ struct hn_softc { uint32_t hn_nvs_ver; uint32_t hn_rx_filter; + /* Packet transmission aggregation user settings. */ + int hn_agg_size; + int hn_agg_pkts; + struct taskqueue *hn_mgmt_taskq; struct taskqueue *hn_mgmt_taskq0; struct task hn_link_task; @@ -201,6 +223,9 @@ struct hn_softc { uint32_t hn_ndis_ver; int hn_ndis_tso_szmax; int hn_ndis_tso_sgmin; + uint32_t hn_rndis_agg_size; + uint32_t hn_rndis_agg_pkts; + uint32_t hn_rndis_agg_align; int hn_rss_ind_size; uint32_t hn_rss_hash; /* NDIS_HASH_ */ From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:10:39 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 A18A0C95985; Thu, 29 Dec 2016 06:10:39 +0000 (UTC) (envelope-from sephe@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 4D5671D59; Thu, 29 Dec 2016 06:10:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6AcGD029385; Thu, 29 Dec 2016 06:10:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6AcC5029383; Thu, 29 Dec 2016 06:10:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290610.uBT6AcC5029383@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:10:38 +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: r310737 - in stable/10/sys/dev/hyperv: include vmbus 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.23 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, 29 Dec 2016 06:10:39 -0000 Author: sephe Date: Thu Dec 29 06:10:38 2016 New Revision: 310737 URL: https://svnweb.freebsd.org/changeset/base/310737 Log: MFC 308906 hyperv/vmbus: Support transction result busy-wait. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8488 Modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 06:06:05 2016 (r310736) +++ stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 06:10:38 2016 (r310737) @@ -52,6 +52,8 @@ void vmbus_xact_activate(struct vmbus_ void vmbus_xact_deactivate(struct vmbus_xact *xact); const void *vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len); +const void *vmbus_xact_busywait(struct vmbus_xact *xact, + size_t *resp_len); void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen); void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 06:06:05 2016 (r310736) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 06:10:38 2016 (r310737) @@ -69,6 +69,8 @@ static struct vmbus_xact *vmbus_xact_all static void vmbus_xact_free(struct vmbus_xact *); static struct vmbus_xact *vmbus_xact_get1(struct vmbus_xact_ctx *, uint32_t); +const void *vmbus_xact_wait1(struct vmbus_xact *, size_t *, + bool); static struct vmbus_xact * vmbus_xact_alloc(struct vmbus_xact_ctx *ctx, bus_dma_tag_t parent_dtag) @@ -249,7 +251,8 @@ vmbus_xact_deactivate(struct vmbus_xact } const void * -vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) +vmbus_xact_wait1(struct vmbus_xact *xact, size_t *resp_len, + bool can_sleep) { struct vmbus_xact_ctx *ctx = xact->x_ctx; const void *resp; @@ -258,8 +261,14 @@ vmbus_xact_wait(struct vmbus_xact *xact, KASSERT(ctx->xc_active == xact, ("xact mismatch")); while (xact->x_resp == NULL) { - mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0, - "wxact", 0); + if (can_sleep) { + mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0, + "wxact", 0); + } else { + mtx_unlock(&ctx->xc_active_lock); + DELAY(1000); + mtx_lock(&ctx->xc_active_lock); + } } ctx->xc_active = NULL; @@ -271,6 +280,20 @@ vmbus_xact_wait(struct vmbus_xact *xact, return (resp); } +const void * +vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len) +{ + + return (vmbus_xact_wait1(xact, resp_len, true /* can sleep */)); +} + +const void * +vmbus_xact_busywait(struct vmbus_xact *xact, size_t *resp_len) +{ + + return (vmbus_xact_wait1(xact, resp_len, false /* can't sleep */)); +} + static void vmbus_xact_save_resp(struct vmbus_xact *xact, const void *data, size_t dlen) { From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:13:01 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 DFB53C95BE1; Thu, 29 Dec 2016 06:13:01 +0000 (UTC) (envelope-from sephe@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 99E07111E; Thu, 29 Dec 2016 06:13:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6D0QH033031; Thu, 29 Dec 2016 06:13:00 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6D0SK033027; Thu, 29 Dec 2016 06:13:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290613.uBT6D0SK033027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:13:00 +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: r310738 - stable/10/sys/dev/hyperv/netvsc 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.23 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, 29 Dec 2016 06:13:02 -0000 Author: sephe Date: Thu Dec 29 06:13:00 2016 New Revision: 310738 URL: https://svnweb.freebsd.org/changeset/base/310738 Log: MFC 308907 hyperv/hn: Fix WITNESS warnings And re-enable SIOCADDMULTI/SIOCDELMULTI, after WITNESS warning is fixed. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8489 Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c stable/10/sys/dev/hyperv/netvsc/hn_rndis.c stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 06:10:38 2016 (r310737) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 06:13:00 2016 (r310738) @@ -109,7 +109,10 @@ hn_nvs_xact_execute(struct hn_softc *sc, vmbus_xact_deactivate(xact); return (NULL); } - hdr = vmbus_xact_wait(xact, &resplen); + if (HN_CAN_SLEEP(sc)) + hdr = vmbus_xact_wait(xact, &resplen); + else + hdr = vmbus_xact_busywait(xact, &resplen); /* * Check this NVS response message. Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 06:10:38 2016 (r310737) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 06:13:00 2016 (r310738) @@ -233,7 +233,10 @@ hn_rndis_xact_exec1(struct hn_softc *sc, if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); return (NULL); } - return (vmbus_xact_wait(xact, comp_len)); + if (HN_CAN_SLEEP(sc)) + return (vmbus_xact_wait(xact, comp_len)); + else + return (vmbus_xact_busywait(xact, comp_len)); } static const void * Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:10:38 2016 (r310737) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:13:00 2016 (r310738) @@ -152,7 +152,11 @@ __FBSDID("$FreeBSD$"); sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) #define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) #define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) -#define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) +#define HN_LOCK(sc) \ +do { \ + while (sx_try_xlock(&(sc)->hn_lock) == 0) \ + DELAY(1000); \ +} while (0) #define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) #define HN_CSUM_IP_MASK (CSUM_IP | CSUM_IP_TCP | CSUM_IP_UDP) @@ -670,18 +674,10 @@ hn_set_rxfilter(struct hn_softc *sc) filter = NDIS_PACKET_TYPE_DIRECTED; if (ifp->if_flags & IFF_BROADCAST) filter |= NDIS_PACKET_TYPE_BROADCAST; -#ifdef notyet - /* - * See the comment in SIOCADDMULTI/SIOCDELMULTI. - */ /* TODO: support multicast list */ if ((ifp->if_flags & IFF_ALLMULTI) || !TAILQ_EMPTY(&ifp->if_multiaddrs)) filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; -#else - /* Always enable ALLMULTI */ - filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; -#endif } if (sc->hn_rx_filter != filter) { @@ -2364,10 +2360,18 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Caller meight hold mutex, e.g. + * bpf; use busy-wait for the RNDIS + * reply. + */ + HN_NO_SLEEPING(sc); hn_set_rxfilter(sc); - else + HN_SLEEPING_OK(sc); + } else { hn_init_locked(sc); + } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) hn_stop(sc); @@ -2428,27 +2432,23 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, case SIOCADDMULTI: case SIOCDELMULTI: -#ifdef notyet - /* - * XXX - * Multicast uses mutex, while RNDIS RX filter setting - * sleeps. We workaround this by always enabling - * ALLMULTI. ALLMULTI would actually always be on, even - * if we supported the SIOCADDMULTI/SIOCDELMULTI, since - * we don't support multicast address list configuration - * for this driver. - */ HN_LOCK(sc); if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { HN_UNLOCK(sc); break; } - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Multicast uses mutex; use busy-wait for + * the RNDIS reply. + */ + HN_NO_SLEEPING(sc); hn_set_rxfilter(sc); + HN_SLEEPING_OK(sc); + } HN_UNLOCK(sc); -#endif break; case SIOCSIFMEDIA: Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 06:10:38 2016 (r310737) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 06:13:00 2016 (r310738) @@ -237,6 +237,20 @@ struct hn_softc { #define HN_FLAG_HAS_RSSKEY 0x0004 #define HN_FLAG_HAS_RSSIND 0x0008 #define HN_FLAG_SYNTH_ATTACHED 0x0010 +#define HN_FLAG_NO_SLEEPING 0x0020 + +#define HN_NO_SLEEPING(sc) \ +do { \ + (sc)->hn_flags |= HN_FLAG_NO_SLEEPING; \ +} while (0) + +#define HN_SLEEPING_OK(sc) \ +do { \ + (sc)->hn_flags &= ~HN_FLAG_NO_SLEEPING; \ +} while (0) + +#define HN_CAN_SLEEP(sc) \ + (((sc)->hn_flags & HN_FLAG_NO_SLEEPING) == 0) #define HN_CAP_VLAN 0x0001 #define HN_CAP_MTU 0x0002 From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:34:20 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 8749AC9512E; Thu, 29 Dec 2016 06:34:20 +0000 (UTC) (envelope-from sephe@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 47D6019BE; Thu, 29 Dec 2016 06:34:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6YJfv041516; Thu, 29 Dec 2016 06:34:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6YJ0l041513; Thu, 29 Dec 2016 06:34:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290634.uBT6YJ0l041513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:34:19 +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: r310739 - stable/10/sys/dev/hyperv/netvsc 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.23 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, 29 Dec 2016 06:34:20 -0000 Author: sephe Date: Thu Dec 29 06:34:19 2016 New Revision: 310739 URL: https://svnweb.freebsd.org/changeset/base/310739 Log: MFC 308908,308909 308908 hyperv/hn: Allow enabling IPv6 TX checksum offloading and IPv6 TSO. They are still disabled by default. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8490 308909 hyperv/hn: Don't abuse hn_{tx,rx}_ring_inuse. Just in case, the # of TX/RX rings is changed upon synthetic parts re-attach. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8520 Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c stable/10/sys/dev/hyperv/netvsc/if_hn.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 06:13:00 2016 (r310738) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 06:34:19 2016 (r310739) @@ -603,7 +603,6 @@ hn_rndis_conf_offload(struct hn_softc *s if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == HN_NDIS_LSOV2_CAP_IP6) { -#ifdef notyet caps |= HN_CAP_TSO6; params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; @@ -611,7 +610,6 @@ hn_rndis_conf_offload(struct hn_softc *s tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; -#endif } sc->hn_ndis_tso_szmax = 0; sc->hn_ndis_tso_sgmin = 0; Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:13:00 2016 (r310738) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:34:19 2016 (r310739) @@ -507,7 +507,7 @@ hn_set_lro_lenlim(struct hn_softc *sc, i { int i; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; } #endif @@ -1149,6 +1149,13 @@ hn_attach(device_t dev) /* Enable all available capabilities by default. */ ifp->if_capenable = ifp->if_capabilities; + /* + * Disable IPv6 TSO and TXCSUM by default, they still can + * be enabled through SIOCSIFCAP. + */ + ifp->if_capenable &= ~(IFCAP_TXCSUM_IPV6 | IFCAP_TSO6); + ifp->if_hwassist &= ~(HN_CSUM_IP6_MASK | CSUM_IP6_TSO); + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; @@ -2573,7 +2580,7 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS */ --ackcnt; HN_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt; HN_UNLOCK(sc); return 0; @@ -2597,7 +2604,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG return error; HN_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; if (on) @@ -2665,7 +2672,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG uint64_t stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; stat += *((uint64_t *)((uint8_t *)rxr + ofs)); } @@ -2675,7 +2682,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; *((uint64_t *)((uint8_t *)rxr + ofs)) = 0; } @@ -2719,7 +2726,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A u_long stat; stat = 0; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; stat += *((u_long *)((uint8_t *)txr + ofs)); } @@ -2729,7 +2736,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; *((u_long *)((uint8_t *)txr + ofs)) = 0; } @@ -2751,7 +2758,7 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG return error; HN_LOCK(sc); - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { txr = &sc->hn_tx_ring[i]; *((int *)((uint8_t *)txr + ofs)) = conf; } @@ -3622,7 +3629,7 @@ hn_set_chim_size(struct hn_softc *sc, in { int i; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_chim_size = chim_size; } @@ -3672,12 +3679,10 @@ hn_fixup_tx_data(struct hn_softc *sc) csum_assist |= CSUM_IP_TCP; if (sc->hn_caps & HN_CAP_UDP4CS) csum_assist |= CSUM_IP_UDP; -#ifdef notyet if (sc->hn_caps & HN_CAP_TCP6CS) csum_assist |= CSUM_IP6_TCP; if (sc->hn_caps & HN_CAP_UDP6CS) csum_assist |= CSUM_IP6_UDP; -#endif for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_csum_assist = csum_assist; From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:45:38 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 25C12C95497; Thu, 29 Dec 2016 06:45:38 +0000 (UTC) (envelope-from sephe@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 E21181F13; Thu, 29 Dec 2016 06:45:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6jb4B045686; Thu, 29 Dec 2016 06:45:37 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6jaen045681; Thu, 29 Dec 2016 06:45:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290645.uBT6jaen045681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:45:36 +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: r310740 - in stable/10/sys/dev/hyperv: include vmbus 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.23 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, 29 Dec 2016 06:45:38 -0000 Author: sephe Date: Thu Dec 29 06:45:36 2016 New Revision: 310740 URL: https://svnweb.freebsd.org/changeset/base/310740 Log: MFC 309030,309039,309080,309081,309083 309030 hyperv/vmbus: Set a mark on the revoked channel. This will be used to fix device detach DEVMETHOD for revoked primary channel. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8522 309039 hyperv/vmbus: Merge free/active locks. These functions are only used by management stuffs, so there are no needs to introduce extra complexity. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8524 309080 hyperv/vmbus: Implement orphan support for transaction API It will be used to fix the primary channel revocation support. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8525 309081 hyperv/vmbus: Fix the primary channel revoking on vmbus side. Drivers can now use vmbus_chan_{is_revoked,set_orphan,unset_orphan}() and vmbus_xact_ctx_orphan() to fix their attach/detach DEVMETHODs for revoked primary channels. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8545 309083 hyperv/vmbus: Fix the multi-channel revoking on vmbus side. - Reference count the sub-channel when channel offer message is processed, so that immediate rescind message on the same channel will not race sub-channel open on driver side. - Drop the above reference when sub-channel is closed, this closely mimics the hypervisor's reaction when primary channel is closed on the VM side. No drivers use sub-channel after primary channel is closed. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8546 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/include/vmbus_xact.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Thu Dec 29 06:34:19 2016 (r310739) +++ stable/10/sys/dev/hyperv/include/vmbus.h Thu Dec 29 06:45:36 2016 (r310740) @@ -117,6 +117,7 @@ struct vmbus_chan_br { }; struct vmbus_channel; +struct vmbus_xact_ctx; struct hyperv_guid; struct task; struct taskqueue; @@ -139,6 +140,9 @@ void vmbus_chan_close(struct vmbus_chan void vmbus_chan_intr_drain(struct vmbus_channel *chan); void vmbus_chan_run_task(struct vmbus_channel *chan, struct task *task); +void vmbus_chan_set_orphan(struct vmbus_channel *chan, + struct vmbus_xact_ctx *); +void vmbus_chan_unset_orphan(struct vmbus_channel *chan); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); @@ -173,6 +177,7 @@ int vmbus_chan_send_prplist(struct vmbu uint32_t vmbus_chan_id(const struct vmbus_channel *chan); uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); bool vmbus_chan_is_primary(const struct vmbus_channel *chan); +bool vmbus_chan_is_revoked(const struct vmbus_channel *chan); const struct hyperv_guid * vmbus_chan_guid_inst(const struct vmbus_channel *chan); int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, Modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 06:34:19 2016 (r310739) +++ stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 06:45:36 2016 (r310740) @@ -40,6 +40,8 @@ struct vmbus_xact_ctx *vmbus_xact_ctx_cr size_t req_size, size_t resp_size, size_t priv_size); void vmbus_xact_ctx_destroy(struct vmbus_xact_ctx *ctx); +bool vmbus_xact_ctx_orphan(struct vmbus_xact_ctx *ctx); + struct vmbus_xact *vmbus_xact_get(struct vmbus_xact_ctx *ctx, size_t req_len); void vmbus_xact_put(struct vmbus_xact *xact); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 06:34:19 2016 (r310739) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 06:45:36 2016 (r310740) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -64,6 +65,7 @@ static void vmbus_chan_cpu_default(str static int vmbus_chan_release(struct vmbus_channel *); static void vmbus_chan_set_chmap(struct vmbus_channel *); static void vmbus_chan_clear_chmap(struct vmbus_channel *); +static void vmbus_chan_detach(struct vmbus_channel *); static void vmbus_chan_ins_prilist(struct vmbus_softc *, struct vmbus_channel *); @@ -627,6 +629,32 @@ vmbus_chan_gpadl_disconnect(struct vmbus } static void +vmbus_chan_detach(struct vmbus_channel *chan) +{ + int refs; + + KASSERT(chan->ch_refs > 0, ("chan%u: invalid refcnt %d", + chan->ch_id, chan->ch_refs)); + refs = atomic_fetchadd_int(&chan->ch_refs, -1); +#ifdef INVARIANTS + if (VMBUS_CHAN_ISPRIMARY(chan)) { + KASSERT(refs == 1, ("chan%u: invalid refcnt %d for prichan", + chan->ch_id, refs + 1)); + } +#endif + if (refs == 1) { + /* + * Detach the target channel. + */ + if (bootverbose) { + vmbus_chan_printf(chan, "chan%u detached\n", + chan->ch_id); + } + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); + } +} + +static void vmbus_chan_clrchmap_task(void *xchan, int pending __unused) { struct vmbus_channel *chan = xchan; @@ -751,8 +779,15 @@ vmbus_chan_close(struct vmbus_channel *c int i; subchan = vmbus_subchan_get(chan, subchan_cnt); - for (i = 0; i < subchan_cnt; ++i) + for (i = 0; i < subchan_cnt; ++i) { vmbus_chan_close_internal(subchan[i]); + /* + * This sub-channel is referenced, when it is + * linked to the primary channel; drop that + * reference now. + */ + vmbus_chan_detach(subchan[i]); + } vmbus_subchan_rel(subchan, subchan_cnt); } @@ -1113,8 +1148,10 @@ vmbus_chan_alloc(struct vmbus_softc *sc) return NULL; } + chan->ch_refs = 1; chan->ch_vmbus = sc; mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + sx_init(&chan->ch_orphan_lock, "vmbus chorphan"); TAILQ_INIT(&chan->ch_subchans); vmbus_rxbr_init(&chan->ch_rxbr); vmbus_txbr_init(&chan->ch_txbr); @@ -1133,8 +1170,14 @@ vmbus_chan_free(struct vmbus_channel *ch VMBUS_CHAN_ST_ONPRIL | VMBUS_CHAN_ST_ONSUBL | VMBUS_CHAN_ST_ONLIST)) == 0, ("free busy channel")); + KASSERT(chan->ch_orphan_xact == NULL, + ("still has orphan xact installed")); + KASSERT(chan->ch_refs == 0, ("chan%u: invalid refcnt %d", + chan->ch_id, chan->ch_refs)); + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); + sx_destroy(&chan->ch_orphan_lock); vmbus_rxbr_deinit(&chan->ch_rxbr); vmbus_txbr_deinit(&chan->ch_txbr); free(chan, M_DEVBUF); @@ -1207,6 +1250,14 @@ vmbus_chan_add(struct vmbus_channel *new ("new channel is not sub-channel")); KASSERT(prichan != NULL, ("no primary channel")); + /* + * Reference count this sub-channel; it will be dereferenced + * when this sub-channel is closed. + */ + KASSERT(newchan->ch_refs == 1, ("chan%u: invalid refcnt %d", + newchan->ch_id, newchan->ch_refs)); + atomic_add_int(&newchan->ch_refs, 1); + newchan->ch_prichan = prichan; newchan->ch_dev = prichan->ch_dev; @@ -1220,7 +1271,7 @@ vmbus_chan_add(struct vmbus_channel *new wakeup(prichan); done: /* - * Hook this channel up for later rescind. + * Hook this channel up for later revocation. */ mtx_lock(&sc->vmbus_chan_lock); vmbus_chan_ins_list(sc, newchan); @@ -1353,6 +1404,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_ if (error) { device_printf(sc->vmbus_dev, "add chan%u failed: %d\n", chan->ch_id, error); + atomic_subtract_int(&chan->ch_refs, 1); vmbus_chan_free(chan); return; } @@ -1368,7 +1420,7 @@ vmbus_chan_msgproc_chrescind(struct vmbu note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data; if (note->chm_chanid > VMBUS_CHAN_MAX) { - device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n", + device_printf(sc->vmbus_dev, "invalid revoked chan%u\n", note->chm_chanid); return; } @@ -1403,11 +1455,24 @@ vmbus_chan_msgproc_chrescind(struct vmbu mtx_unlock(&sc->vmbus_prichan_lock); } - if (bootverbose) - vmbus_chan_printf(chan, "chan%u rescinded\n", note->chm_chanid); + /* + * NOTE: + * The following processing order is critical: + * Set the REVOKED state flag before orphaning the installed xact. + */ + + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_REVOKED_SHIFT)) + panic("channel has already been revoked"); - /* Detach the target channel. */ - taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); + sx_xlock(&chan->ch_orphan_lock); + if (chan->ch_orphan_xact != NULL) + vmbus_xact_ctx_orphan(chan->ch_orphan_xact); + sx_xunlock(&chan->ch_orphan_lock); + + if (bootverbose) + vmbus_chan_printf(chan, "chan%u revoked\n", note->chm_chanid); + vmbus_chan_detach(chan); } static int @@ -1695,3 +1760,30 @@ vmbus_chan_mgmt_tq(const struct vmbus_ch return (chan->ch_mgmt_tq); } + +bool +vmbus_chan_is_revoked(const struct vmbus_channel *chan) +{ + + if (chan->ch_stflags & VMBUS_CHAN_ST_REVOKED) + return (true); + return (false); +} + +void +vmbus_chan_set_orphan(struct vmbus_channel *chan, struct vmbus_xact_ctx *xact) +{ + + sx_xlock(&chan->ch_orphan_lock); + chan->ch_orphan_xact = xact; + sx_xunlock(&chan->ch_orphan_lock); +} + +void +vmbus_chan_unset_orphan(struct vmbus_channel *chan) +{ + + sx_xlock(&chan->ch_orphan_lock); + chan->ch_orphan_xact = NULL; + sx_xunlock(&chan->ch_orphan_lock); +} Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Thu Dec 29 06:34:19 2016 (r310739) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Thu Dec 29 06:45:36 2016 (r310740) @@ -33,8 +33,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -138,6 +139,11 @@ struct vmbus_channel { struct hyperv_guid ch_guid_type; struct hyperv_guid ch_guid_inst; + struct sx ch_orphan_lock; + struct vmbus_xact_ctx *ch_orphan_xact; + + int ch_refs; + struct sysctl_ctx_list ch_sysctl_ctx; } __aligned(CACHE_LINE_SIZE); @@ -159,10 +165,12 @@ struct vmbus_channel { #define VMBUS_CHAN_ST_ONPRIL_SHIFT 1 #define VMBUS_CHAN_ST_ONSUBL_SHIFT 2 #define VMBUS_CHAN_ST_ONLIST_SHIFT 3 +#define VMBUS_CHAN_ST_REVOKED_SHIFT 4 /* sticky */ #define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) #define VMBUS_CHAN_ST_ONPRIL (1 << VMBUS_CHAN_ST_ONPRIL_SHIFT) #define VMBUS_CHAN_ST_ONSUBL (1 << VMBUS_CHAN_ST_ONSUBL_SHIFT) #define VMBUS_CHAN_ST_ONLIST (1 << VMBUS_CHAN_ST_ONLIST_SHIFT) +#define VMBUS_CHAN_ST_REVOKED (1 << VMBUS_CHAN_ST_REVOKED_SHIFT) struct vmbus_softc; struct vmbus_message; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 06:34:19 2016 (r310739) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 06:45:36 2016 (r310740) @@ -50,16 +50,18 @@ struct vmbus_xact { }; struct vmbus_xact_ctx { - uint32_t xc_flags; size_t xc_req_size; size_t xc_resp_size; size_t xc_priv_size; + struct mtx xc_lock; + /* + * Protected by xc_lock. + */ + uint32_t xc_flags; /* VMBUS_XACT_CTXF_ */ struct vmbus_xact *xc_free; - struct mtx xc_free_lock; - struct vmbus_xact *xc_active; - struct mtx xc_active_lock; + struct vmbus_xact *xc_orphan; }; #define VMBUS_XACT_CTXF_DESTROY 0x0001 @@ -71,6 +73,9 @@ static struct vmbus_xact *vmbus_xact_get uint32_t); const void *vmbus_xact_wait1(struct vmbus_xact *, size_t *, bool); +static void vmbus_xact_save_resp(struct vmbus_xact *, + const void *, size_t); +static void vmbus_xact_ctx_free(struct vmbus_xact_ctx *); static struct vmbus_xact * vmbus_xact_alloc(struct vmbus_xact_ctx *ctx, bus_dma_tag_t parent_dtag) @@ -110,10 +115,10 @@ vmbus_xact_get1(struct vmbus_xact_ctx *c { struct vmbus_xact *xact; - mtx_lock(&ctx->xc_free_lock); + mtx_lock(&ctx->xc_lock); while ((ctx->xc_flags & dtor_flag) == 0 && ctx->xc_free == NULL) - mtx_sleep(&ctx->xc_free, &ctx->xc_free_lock, 0, "gxact", 0); + mtx_sleep(&ctx->xc_free, &ctx->xc_lock, 0, "gxact", 0); if (ctx->xc_flags & dtor_flag) { /* Being destroyed */ xact = NULL; @@ -124,7 +129,7 @@ vmbus_xact_get1(struct vmbus_xact_ctx *c ctx->xc_free = NULL; } - mtx_unlock(&ctx->xc_free_lock); + mtx_unlock(&ctx->xc_lock); return (xact); } @@ -135,6 +140,9 @@ vmbus_xact_ctx_create(bus_dma_tag_t dtag { struct vmbus_xact_ctx *ctx; + KASSERT(req_size > 0, ("request size is 0")); + KASSERT(resp_size > 0, ("response size is 0")); + ctx = malloc(sizeof(*ctx), M_DEVBUF, M_WAITOK | M_ZERO); ctx->xc_req_size = req_size; ctx->xc_resp_size = resp_size; @@ -146,32 +154,51 @@ vmbus_xact_ctx_create(bus_dma_tag_t dtag return (NULL); } - mtx_init(&ctx->xc_free_lock, "vmbus xact free", NULL, MTX_DEF); - mtx_init(&ctx->xc_active_lock, "vmbus xact active", NULL, MTX_DEF); + mtx_init(&ctx->xc_lock, "vmbus xact", NULL, MTX_DEF); return (ctx); } -void -vmbus_xact_ctx_destroy(struct vmbus_xact_ctx *ctx) +bool +vmbus_xact_ctx_orphan(struct vmbus_xact_ctx *ctx) { - struct vmbus_xact *xact; - - mtx_lock(&ctx->xc_free_lock); + mtx_lock(&ctx->xc_lock); + if (ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) { + mtx_unlock(&ctx->xc_lock); + return (false); + } ctx->xc_flags |= VMBUS_XACT_CTXF_DESTROY; - mtx_unlock(&ctx->xc_free_lock); + mtx_unlock(&ctx->xc_lock); + wakeup(&ctx->xc_free); + wakeup(&ctx->xc_active); - xact = vmbus_xact_get1(ctx, 0); - if (xact == NULL) + ctx->xc_orphan = vmbus_xact_get1(ctx, 0); + if (ctx->xc_orphan == NULL) panic("can't get xact"); + return (true); +} + +static void +vmbus_xact_ctx_free(struct vmbus_xact_ctx *ctx) +{ + KASSERT(ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY, + ("xact ctx was not orphaned")); + KASSERT(ctx->xc_orphan != NULL, ("no orphaned xact")); - vmbus_xact_free(xact); - mtx_destroy(&ctx->xc_free_lock); - mtx_destroy(&ctx->xc_active_lock); + vmbus_xact_free(ctx->xc_orphan); + mtx_destroy(&ctx->xc_lock); free(ctx, M_DEVBUF); } +void +vmbus_xact_ctx_destroy(struct vmbus_xact_ctx *ctx) +{ + + vmbus_xact_ctx_orphan(ctx); + vmbus_xact_ctx_free(ctx); +} + struct vmbus_xact * vmbus_xact_get(struct vmbus_xact_ctx *ctx, size_t req_len) { @@ -196,10 +223,10 @@ vmbus_xact_put(struct vmbus_xact *xact) KASSERT(ctx->xc_active == NULL, ("pending active xact")); xact->x_resp = NULL; - mtx_lock(&ctx->xc_free_lock); + mtx_lock(&ctx->xc_lock); KASSERT(ctx->xc_free == NULL, ("has free xact")); ctx->xc_free = xact; - mtx_unlock(&ctx->xc_free_lock); + mtx_unlock(&ctx->xc_lock); wakeup(&ctx->xc_free); } @@ -233,10 +260,10 @@ vmbus_xact_activate(struct vmbus_xact *x KASSERT(xact->x_resp == NULL, ("xact has pending response")); - mtx_lock(&ctx->xc_active_lock); + mtx_lock(&ctx->xc_lock); KASSERT(ctx->xc_active == NULL, ("pending active xact")); ctx->xc_active = xact; - mtx_unlock(&ctx->xc_active_lock); + mtx_unlock(&ctx->xc_lock); } void @@ -244,10 +271,10 @@ vmbus_xact_deactivate(struct vmbus_xact { struct vmbus_xact_ctx *ctx = xact->x_ctx; - mtx_lock(&ctx->xc_active_lock); + mtx_lock(&ctx->xc_lock); KASSERT(ctx->xc_active == xact, ("xact mismatch")); ctx->xc_active = NULL; - mtx_unlock(&ctx->xc_active_lock); + mtx_unlock(&ctx->xc_lock); } const void * @@ -257,25 +284,40 @@ vmbus_xact_wait1(struct vmbus_xact *xact struct vmbus_xact_ctx *ctx = xact->x_ctx; const void *resp; - mtx_lock(&ctx->xc_active_lock); + mtx_lock(&ctx->xc_lock); KASSERT(ctx->xc_active == xact, ("xact mismatch")); - while (xact->x_resp == NULL) { + while (xact->x_resp == NULL && + (ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) == 0) { if (can_sleep) { - mtx_sleep(&ctx->xc_active, &ctx->xc_active_lock, 0, + mtx_sleep(&ctx->xc_active, &ctx->xc_lock, 0, "wxact", 0); } else { - mtx_unlock(&ctx->xc_active_lock); + mtx_unlock(&ctx->xc_lock); DELAY(1000); - mtx_lock(&ctx->xc_active_lock); + mtx_lock(&ctx->xc_lock); } } + KASSERT(ctx->xc_active == xact, ("xact trashed")); + + if ((ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) && xact->x_resp == NULL) { + uint8_t b = 0; + + /* + * Orphaned and no response was received yet; fake up + * an one byte response. + */ + printf("vmbus: xact ctx was orphaned w/ pending xact\n"); + vmbus_xact_save_resp(ctx->xc_active, &b, sizeof(b)); + } + KASSERT(xact->x_resp != NULL, ("no response")); + ctx->xc_active = NULL; resp = xact->x_resp; *resp_len = xact->x_resp_len; - mtx_unlock(&ctx->xc_active_lock); + mtx_unlock(&ctx->xc_lock); return (resp); } @@ -300,7 +342,7 @@ vmbus_xact_save_resp(struct vmbus_xact * struct vmbus_xact_ctx *ctx = xact->x_ctx; size_t cplen = dlen; - mtx_assert(&ctx->xc_active_lock, MA_OWNED); + mtx_assert(&ctx->xc_lock, MA_OWNED); if (cplen > ctx->xc_resp_size) { printf("vmbus: xact response truncated %zu -> %zu\n", @@ -318,19 +360,47 @@ void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen) { struct vmbus_xact_ctx *ctx = xact->x_ctx; + int do_wakeup = 0; - mtx_lock(&ctx->xc_active_lock); - vmbus_xact_save_resp(xact, data, dlen); - mtx_unlock(&ctx->xc_active_lock); - wakeup(&ctx->xc_active); + mtx_lock(&ctx->xc_lock); + /* + * NOTE: + * xc_active could be NULL, if the ctx has been orphaned. + */ + if (ctx->xc_active != NULL) { + vmbus_xact_save_resp(xact, data, dlen); + do_wakeup = 1; + } else { + KASSERT(ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY, + ("no active xact pending")); + printf("vmbus: drop xact response\n"); + } + mtx_unlock(&ctx->xc_lock); + + if (do_wakeup) + wakeup(&ctx->xc_active); } void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, const void *data, size_t dlen) { - mtx_lock(&ctx->xc_active_lock); - KASSERT(ctx->xc_active != NULL, ("no pending xact")); - vmbus_xact_save_resp(ctx->xc_active, data, dlen); - mtx_unlock(&ctx->xc_active_lock); - wakeup(&ctx->xc_active); + int do_wakeup = 0; + + mtx_lock(&ctx->xc_lock); + /* + * NOTE: + * xc_active could be NULL, if the ctx has been orphaned. + */ + if (ctx->xc_active != NULL) { + vmbus_xact_save_resp(ctx->xc_active, data, dlen); + do_wakeup = 1; + } else { + KASSERT(ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY, + ("no active xact pending")); + printf("vmbus: drop xact response\n"); + } + mtx_unlock(&ctx->xc_lock); + + if (do_wakeup) + wakeup(&ctx->xc_active); } From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:48: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 14F10C955EE; Thu, 29 Dec 2016 06:48:12 +0000 (UTC) (envelope-from sephe@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 E0229135D; Thu, 29 Dec 2016 06:48:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6mBgM046006; Thu, 29 Dec 2016 06:48:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6mAPU046004; Thu, 29 Dec 2016 06:48:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290648.uBT6mAPU046004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:48: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: r310743 - stable/10/sys/dev/hyperv/netvsc 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.23 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, 29 Dec 2016 06:48:12 -0000 Author: sephe Date: Thu Dec 29 06:48:10 2016 New Revision: 310743 URL: https://svnweb.freebsd.org/changeset/base/310743 Log: MFC 309085 hyperv/hn: Fix primary channel revocation Since hypervisor will not drain the TX bufring, once the channels are revoked: - Setup vmbus orphan handler properly. - Make sure that suspension will not wait the TX bufring draining forever. - GC the pending TX descs on detach path, before freeing the busdma stuffs. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8559 Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c stable/10/sys/dev/hyperv/netvsc/if_hn.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 06:47:53 2016 (r310742) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 06:48:10 2016 (r310743) @@ -336,8 +336,13 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc /* * Wait for the hypervisor to receive this NVS request. + * + * NOTE: + * The TX bufring will not be drained by the hypervisor, + * if the primary channel is revoked. */ - while (!vmbus_chan_tx_empty(sc->hn_prichan)) + while (!vmbus_chan_tx_empty(sc->hn_prichan) && + !vmbus_chan_is_revoked(sc->hn_prichan)) pause("waittx", 1); /* * Linger long enough for NVS to disconnect RXBUF. @@ -387,8 +392,13 @@ hn_nvs_disconn_chim(struct hn_softc *sc) /* * Wait for the hypervisor to receive this NVS request. + * + * NOTE: + * The TX bufring will not be drained by the hypervisor, + * if the primary channel is revoked. */ - while (!vmbus_chan_tx_empty(sc->hn_prichan)) + while (!vmbus_chan_tx_empty(sc->hn_prichan) && + !vmbus_chan_is_revoked(sc->hn_prichan)) pause("waittx", 1); /* * Linger long enough for NVS to disconnect chimney Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:47:53 2016 (r310742) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 06:48:10 2016 (r310743) @@ -306,7 +306,8 @@ static void hn_resume(struct hn_softc static void hn_resume_data(struct hn_softc *); static void hn_resume_mgmt(struct hn_softc *); static void hn_suspend_mgmt_taskfunc(void *, int); -static void hn_chan_drain(struct vmbus_channel *); +static void hn_chan_drain(struct hn_softc *, + struct vmbus_channel *); static void hn_update_link_status(struct hn_softc *); static void hn_change_network(struct hn_softc *); @@ -330,6 +331,8 @@ static int hn_create_tx_data(struct hn static void hn_fixup_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); +static void hn_txdesc_gc(struct hn_tx_ring *, + struct hn_txdesc *); static int hn_encap(struct ifnet *, struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_txpkt(struct ifnet *, struct hn_tx_ring *, @@ -1011,8 +1014,25 @@ hn_attach(device_t dev) */ sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); - if (sc->hn_xact == NULL) + if (sc->hn_xact == NULL) { + error = ENXIO; + goto failed; + } + + /* + * Install orphan handler for the revocation of this device's + * primary channel. + * + * NOTE: + * The processing order is critical here: + * Install the orphan handler, _before_ testing whether this + * device's primary channel has been revoked or not. + */ + vmbus_chan_set_orphan(sc->hn_prichan, sc->hn_xact); + if (vmbus_chan_is_revoked(sc->hn_prichan)) { + error = ENXIO; goto failed; + } /* * Attach the synthetic parts, i.e. NVS and RNDIS. @@ -1192,6 +1212,14 @@ hn_detach(device_t dev) struct hn_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->hn_ifp; + if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { + /* + * In case that the vmbus missed the orphan handler + * installation. + */ + vmbus_xact_ctx_orphan(sc->hn_xact); + } + if (device_is_attached(dev)) { HN_LOCK(sc); if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { @@ -1217,8 +1245,14 @@ hn_detach(device_t dev) taskqueue_free(sc->hn_tx_taskq); taskqueue_free(sc->hn_mgmt_taskq0); - if (sc->hn_xact != NULL) + if (sc->hn_xact != NULL) { + /* + * Uninstall the orphan handler _before_ the xact is + * destructed. + */ + vmbus_chan_unset_orphan(sc->hn_prichan); vmbus_xact_ctx_destroy(sc->hn_xact); + } if_free(ifp); @@ -1457,7 +1491,7 @@ hn_txdesc_hold(struct hn_txdesc *txd) { /* 0->1 transition will never work */ - KASSERT(txd->refs > 0, ("invalid refs %d", txd->refs)); + KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs)); atomic_add_int(&txd->refs, 1); } @@ -3475,24 +3509,43 @@ hn_txdesc_dmamap_destroy(struct hn_txdes } static void +hn_txdesc_gc(struct hn_tx_ring *txr, struct hn_txdesc *txd) +{ + + KASSERT(txd->refs == 0 || txd->refs == 1, + ("invalid txd refs %d", txd->refs)); + + /* Aggregated txds will be freed by their aggregating txd. */ + if (txd->refs > 0 && (txd->flags & HN_TXD_FLAG_ONAGG) == 0) { + int freed; + + freed = hn_txdesc_put(txr, txd); + KASSERT(freed, ("can't free txdesc")); + } +} + +static void hn_tx_ring_destroy(struct hn_tx_ring *txr) { - struct hn_txdesc *txd; + int i; if (txr->hn_txdesc == NULL) return; -#ifndef HN_USE_TXDESC_BUFRING - while ((txd = SLIST_FIRST(&txr->hn_txlist)) != NULL) { - SLIST_REMOVE_HEAD(&txr->hn_txlist, link); - hn_txdesc_dmamap_destroy(txd); - } -#else - mtx_lock(&txr->hn_tx_lock); - while ((txd = buf_ring_dequeue_sc(txr->hn_txdesc_br)) != NULL) - hn_txdesc_dmamap_destroy(txd); - mtx_unlock(&txr->hn_tx_lock); -#endif + /* + * NOTE: + * Because the freeing of aggregated txds will be deferred + * to the aggregating txd, two passes are used here: + * - The first pass GCes any pending txds. This GC is necessary, + * since if the channels are revoked, hypervisor will not + * deliver send-done for all pending txds. + * - The second pass frees the busdma stuffs, i.e. after all txds + * were freed. + */ + for (i = 0; i < txr->hn_txdesc_cnt; ++i) + hn_txdesc_gc(txr, &txr->hn_txdesc[i]); + for (i = 0; i < txr->hn_txdesc_cnt; ++i) + hn_txdesc_dmamap_destroy(&txr->hn_txdesc[i]); if (txr->hn_tx_data_dtag != NULL) bus_dma_tag_destroy(txr->hn_tx_data_dtag); @@ -4525,10 +4578,17 @@ hn_set_ring_inuse(struct hn_softc *sc, i } static void -hn_chan_drain(struct vmbus_channel *chan) +hn_chan_drain(struct hn_softc *sc, struct vmbus_channel *chan) { - while (!vmbus_chan_rx_empty(chan) || !vmbus_chan_tx_empty(chan)) + /* + * NOTE: + * The TX bufring will not be drained by the hypervisor, + * if the primary channel is revoked. + */ + while (!vmbus_chan_rx_empty(chan) || + (!vmbus_chan_is_revoked(sc->hn_prichan) && + !vmbus_chan_tx_empty(chan))) pause("waitch", 1); vmbus_chan_intr_drain(chan); } @@ -4537,6 +4597,7 @@ static void hn_suspend_data(struct hn_softc *sc) { struct vmbus_channel **subch = NULL; + struct hn_tx_ring *txr; int i, nsubch; HN_LOCK_ASSERT(sc); @@ -4545,19 +4606,23 @@ hn_suspend_data(struct hn_softc *sc) * Suspend TX. */ for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + txr = &sc->hn_tx_ring[i]; mtx_lock(&txr->hn_tx_lock); txr->hn_suspended = 1; mtx_unlock(&txr->hn_tx_lock); /* No one is able send more packets now. */ - /* Wait for all pending sends to finish. */ - while (hn_tx_ring_pending(txr)) + /* + * Wait for all pending sends to finish. + * + * NOTE: + * We will _not_ receive all pending send-done, if the + * primary channel is revoked. + */ + while (hn_tx_ring_pending(txr) && + !vmbus_chan_is_revoked(sc->hn_prichan)) pause("hnwtx", 1 /* 1 tick */); - - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); } /* @@ -4580,12 +4645,27 @@ hn_suspend_data(struct hn_softc *sc) if (subch != NULL) { for (i = 0; i < nsubch; ++i) - hn_chan_drain(subch[i]); + hn_chan_drain(sc, subch[i]); } - hn_chan_drain(sc->hn_prichan); + hn_chan_drain(sc, sc->hn_prichan); if (subch != NULL) vmbus_subchan_rel(subch, nsubch); + + /* + * Drain any pending TX tasks. + * + * NOTE: + * The above hn_chan_drain() can dispatch TX tasks, so the TX + * tasks will have to be drained _after_ the above hn_chan_drain() + * calls. + */ + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + txr = &sc->hn_tx_ring[i]; + + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); + } } static void From owner-svn-src-stable-10@freebsd.org Thu Dec 29 06:59:25 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 6B781C95D33; Thu, 29 Dec 2016 06:59:25 +0000 (UTC) (envelope-from sephe@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 3407F1394; Thu, 29 Dec 2016 06:59:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT6xOfY050551; Thu, 29 Dec 2016 06:59:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6xOgh050549; Thu, 29 Dec 2016 06:59:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290659.uBT6xOgh050549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 06:59:24 +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: r310751 - in stable/10/sys/dev/hyperv: include vmbus 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.23 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, 29 Dec 2016 06:59:25 -0000 Author: sephe Date: Thu Dec 29 06:59:24 2016 New Revision: 310751 URL: https://svnweb.freebsd.org/changeset/base/310751 Log: MFC 309128,309129,309131-309136,309138-309140,309224,309225 309128 hyperv/vmbus: Commit the GPADL id only after the connection succeeds. Minor style change. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8563 309129 hyperv/vmbus: Minor style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8564 309131 hyperv/vmbus: Fix sysctl tree leakage, if channel open fails. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8565 309132 hyperv/vmbus: Don't close unopened channels. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8566 309133 hyperv/vmbus: GPADL disconnect error on a revoked channel is benign. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8567 309134 hyperv/vmbus: No stranded bufring GPADL is allowed. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8568 309135 hyperv/vmbus: Return EISCONN if the bufring GPADL can't be disconnected. So that the callers of vmbus_chan_open_br() could handle the passed in bufring memory properly. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8569 309136 hyperv/vmbus: Don't free the bufring if its GPADL can't be disconnected. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8570 309138 hyperv/vmbus: Always try disconnect/free bufring memory upon channel close While I'm here, minor wording and style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8598 309139 hyperv/vmbus: Propagate close error. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8599 309140 hyperv/vmbus: Add a simplified version of channel close. So that the caller can know the channel close error and react accordingly. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8600 309224 hyperv/vmbus: Zero out GPADL if error happens. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8601 309225 hyperv/vmbus: Add supportive transaction wait function. This function supports channel revocation properly. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8611 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Thu Dec 29 06:58:51 2016 (r310750) +++ stable/10/sys/dev/hyperv/include/vmbus.h Thu Dec 29 06:59:24 2016 (r310751) @@ -117,6 +117,7 @@ struct vmbus_chan_br { }; struct vmbus_channel; +struct vmbus_xact; struct vmbus_xact_ctx; struct hyperv_guid; struct task; @@ -130,6 +131,36 @@ vmbus_get_channel(device_t dev) return device_get_ivars(dev); } +/* + * vmbus_chan_open_br() + * + * Return values: + * 0 Succeeded. + * EISCONN Failed, and the memory passed through 'br' is still + * connected. Callers must _not_ free the the memory + * passed through 'br', if this error happens. + * other values Failed. The memory passed through 'br' is no longer + * connected. Callers are free to do anything with the + * memory passed through 'br'. + * + * + * + * vmbus_chan_close_direct() + * + * NOTE: + * Callers of this function _must_ make sure to close all sub-channels before + * closing the primary channel. + * + * Return values: + * 0 Succeeded. + * EISCONN Failed, and the memory associated with the bufring + * is still connected. Callers must _not_ free the the + * memory associated with the bufring, if this error + * happens. + * other values Failed. The memory associated with the bufring is + * no longer connected. Callers are free to do anything + * with the memory associated with the bufring. + */ int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); @@ -137,12 +168,15 @@ int vmbus_chan_open_br(struct vmbus_cha const struct vmbus_chan_br *cbr, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); +int vmbus_chan_close_direct(struct vmbus_channel *chan); void vmbus_chan_intr_drain(struct vmbus_channel *chan); void vmbus_chan_run_task(struct vmbus_channel *chan, struct task *task); void vmbus_chan_set_orphan(struct vmbus_channel *chan, struct vmbus_xact_ctx *); void vmbus_chan_unset_orphan(struct vmbus_channel *chan); +const void *vmbus_chan_xact_wait(const struct vmbus_channel *chan, + struct vmbus_xact *xact, size_t *resp_len, bool can_sleep); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 06:58:51 2016 (r310750) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 06:59:24 2016 (r310751) @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); static void vmbus_chan_update_evtflagcnt( struct vmbus_softc *, const struct vmbus_channel *); -static void vmbus_chan_close_internal( +static int vmbus_chan_close_internal( struct vmbus_channel *); static int vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS); static void vmbus_chan_sysctl_create( @@ -66,6 +66,8 @@ static int vmbus_chan_release(struct v static void vmbus_chan_set_chmap(struct vmbus_channel *); static void vmbus_chan_clear_chmap(struct vmbus_channel *); static void vmbus_chan_detach(struct vmbus_channel *); +static bool vmbus_chan_wait_revoke( + const struct vmbus_channel *); static void vmbus_chan_ins_prilist(struct vmbus_softc *, struct vmbus_channel *); @@ -322,7 +324,21 @@ vmbus_chan_open(struct vmbus_channel *ch error = vmbus_chan_open_br(chan, &cbr, udata, udlen, cb, cbarg); if (error) { - hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + if (error == EISCONN) { + /* + * XXX + * The bufring GPADL is still connected; abandon + * this bufring, instead of having mysterious + * crash or trashed data later on. + */ + vmbus_chan_printf(chan, "chan%u bufring GPADL " + "is still connected upon channel open error; " + "leak %d bytes memory\n", chan->ch_id, + txbr_size + rxbr_size); + } else { + hyperv_dmamem_free(&chan->ch_bufring_dma, + chan->ch_bufring); + } chan->ch_bufring = NULL; } return (error); @@ -345,7 +361,7 @@ vmbus_chan_open_br(struct vmbus_channel if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { vmbus_chan_printf(chan, "invalid udata len %d for chan%u\n", udlen, chan->ch_id); - return EINVAL; + return (EINVAL); } br = cbr->cbr; @@ -390,6 +406,8 @@ vmbus_chan_open_br(struct vmbus_channel /* * Connect the bufrings, both RX and TX, to this channel. */ + KASSERT(chan->ch_bufring_gpadl == 0, + ("bufring GPADL is still connected")); error = vmbus_chan_gpadl_connect(chan, cbr->cbr_paddr, txbr_size + rxbr_size, &chan->ch_bufring_gpadl); if (error) { @@ -442,23 +460,33 @@ vmbus_chan_open_br(struct vmbus_channel vmbus_msghc_put(sc, mh); if (status == 0) { - if (bootverbose) { + if (bootverbose) vmbus_chan_printf(chan, "chan%u opened\n", chan->ch_id); - } - return 0; + return (0); } vmbus_chan_printf(chan, "failed to open chan%u\n", chan->ch_id); error = ENXIO; failed: + sysctl_ctx_free(&chan->ch_sysctl_ctx); vmbus_chan_clear_chmap(chan); - if (chan->ch_bufring_gpadl) { - vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + if (chan->ch_bufring_gpadl != 0) { + int error1; + + error1 = vmbus_chan_gpadl_disconnect(chan, + chan->ch_bufring_gpadl); + if (error1) { + /* + * Give caller a hint that the bufring GPADL is still + * connected. + */ + error = EISCONN; + } chan->ch_bufring_gpadl = 0; } atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); - return error; + return (error); } int @@ -475,6 +503,12 @@ vmbus_chan_gpadl_connect(struct vmbus_ch uint64_t page_id; /* + * Reset GPADL, so that the result would consistent, if error + * happened later on. + */ + *gpadl0 = 0; + + /* * Preliminary checks. */ @@ -500,7 +534,6 @@ vmbus_chan_gpadl_connect(struct vmbus_ch * Allocate GPADL id. */ gpadl = vmbus_gpadl_alloc(sc); - *gpadl0 = gpadl; /* * Connect this GPADL to the target channel. @@ -579,15 +612,35 @@ vmbus_chan_gpadl_connect(struct vmbus_ch vmbus_chan_printf(chan, "gpadl_conn(chan%u) failed: %u\n", chan->ch_id, status); return EIO; - } else { - if (bootverbose) { - vmbus_chan_printf(chan, - "gpadl_conn(chan%u) succeeded\n", chan->ch_id); - } + } + + /* Done; commit the GPADL id. */ + *gpadl0 = gpadl; + if (bootverbose) { + vmbus_chan_printf(chan, "gpadl_conn(chan%u) succeeded\n", + chan->ch_id); } return 0; } +static bool +vmbus_chan_wait_revoke(const struct vmbus_channel *chan) +{ +#define WAIT_COUNT 200 /* 200ms */ + + int i; + + for (i = 0; i < WAIT_COUNT; ++i) { + if (vmbus_chan_is_revoked(chan)) + return (true); + /* Not sure about the context; use busy-wait. */ + DELAY(1000); + } + return (false); + +#undef WAIT_COUNT +} + /* * Disconnect the GPA from the target channel */ @@ -604,7 +657,7 @@ vmbus_chan_gpadl_disconnect(struct vmbus vmbus_chan_printf(chan, "can not get msg hypercall for gpadl_disconn(chan%u)\n", chan->ch_id); - return EBUSY; + return (EBUSY); } req = vmbus_msghc_dataptr(mh); @@ -614,18 +667,29 @@ vmbus_chan_gpadl_disconnect(struct vmbus error = vmbus_msghc_exec(sc, mh); if (error) { + vmbus_msghc_put(sc, mh); + + if (vmbus_chan_wait_revoke(chan)) { + /* + * Error is benign; this channel is revoked, + * so this GPADL will not be touched anymore. + */ + vmbus_chan_printf(chan, + "gpadl_disconn(revoked chan%u) msg hypercall " + "exec failed: %d\n", chan->ch_id, error); + return (0); + } vmbus_chan_printf(chan, "gpadl_disconn(chan%u) msg hypercall exec failed: %d\n", chan->ch_id, error); - vmbus_msghc_put(sc, mh); - return error; + return (error); } vmbus_msghc_wait_result(sc, mh); /* Discard result; no useful information */ vmbus_msghc_put(sc, mh); - return 0; + return (0); } static void @@ -681,16 +745,34 @@ vmbus_chan_set_chmap(struct vmbus_channe chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; } -static void +static int vmbus_chan_close_internal(struct vmbus_channel *chan) { struct vmbus_softc *sc = chan->ch_vmbus; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; + uint32_t old_stflags; int error; - /* TODO: stringent check */ - atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + /* + * NOTE: + * Sub-channels are closed upon their primary channel closing, + * so they can be closed even before they are opened. + */ + for (;;) { + old_stflags = chan->ch_stflags; + if (atomic_cmpset_int(&chan->ch_stflags, old_stflags, + old_stflags & ~VMBUS_CHAN_ST_OPENED)) + break; + } + if ((old_stflags & VMBUS_CHAN_ST_OPENED) == 0) { + /* Not opened yet; done */ + if (bootverbose) { + vmbus_chan_printf(chan, "chan%u not opened\n", + chan->ch_id); + } + return (0); + } /* * Free this channel's sysctl tree attached to its device's @@ -716,7 +798,8 @@ vmbus_chan_close_internal(struct vmbus_c vmbus_chan_printf(chan, "can not get msg hypercall for chclose(chan%u)\n", chan->ch_id); - return; + error = ENXIO; + goto disconnect; } req = vmbus_msghc_dataptr(mh); @@ -730,16 +813,37 @@ vmbus_chan_close_internal(struct vmbus_c vmbus_chan_printf(chan, "chclose(chan%u) msg hypercall exec failed: %d\n", chan->ch_id, error); - return; - } else if (bootverbose) { - vmbus_chan_printf(chan, "close chan%u\n", chan->ch_id); + goto disconnect; } + if (bootverbose) + vmbus_chan_printf(chan, "chan%u closed\n", chan->ch_id); + +disconnect: /* * Disconnect the TX+RX bufrings from this channel. */ - if (chan->ch_bufring_gpadl) { - vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + if (chan->ch_bufring_gpadl != 0) { + int error1; + + error1 = vmbus_chan_gpadl_disconnect(chan, + chan->ch_bufring_gpadl); + if (error1) { + /* + * XXX + * The bufring GPADL is still connected; abandon + * this bufring, instead of having mysterious + * crash or trashed data later on. + */ + vmbus_chan_printf(chan, "chan%u bufring GPADL " + "is still connected after close\n", chan->ch_id); + chan->ch_bufring = NULL; + /* + * Give caller a hint that the bufring GPADL is + * still connected. + */ + error = EISCONN; + } chan->ch_bufring_gpadl = 0; } @@ -750,6 +854,42 @@ vmbus_chan_close_internal(struct vmbus_c hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); chan->ch_bufring = NULL; } + return (error); +} + +int +vmbus_chan_close_direct(struct vmbus_channel *chan) +{ + int error; + +#ifdef INVARIANTS + if (VMBUS_CHAN_ISPRIMARY(chan)) { + struct vmbus_channel *subchan; + + /* + * All sub-channels _must_ have been closed, or are _not_ + * opened at all. + */ + mtx_lock(&chan->ch_subchan_lock); + TAILQ_FOREACH(subchan, &chan->ch_subchans, ch_sublink) { + KASSERT( + (subchan->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0, + ("chan%u: subchan%u is still opened", + chan->ch_id, subchan->ch_subidx)); + } + mtx_unlock(&chan->ch_subchan_lock); + } +#endif + + error = vmbus_chan_close_internal(chan); + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * This sub-channel is referenced, when it is linked to + * the primary channel; drop that reference now. + */ + vmbus_chan_detach(chan); + } + return (error); } /* @@ -1787,3 +1927,37 @@ vmbus_chan_unset_orphan(struct vmbus_cha chan->ch_orphan_xact = NULL; sx_xunlock(&chan->ch_orphan_lock); } + +const void * +vmbus_chan_xact_wait(const struct vmbus_channel *chan, + struct vmbus_xact *xact, size_t *resp_len, bool can_sleep) +{ + const void *ret; + + if (can_sleep) + ret = vmbus_xact_wait(xact, resp_len); + else + ret = vmbus_xact_busywait(xact, resp_len); + if (vmbus_chan_is_revoked(chan)) { + /* + * This xact probably is interrupted, and the + * interruption can race the reply reception, + * so we have to make sure that there are nothing + * left on the RX bufring, i.e. this xact will + * not be touched, once this function returns. + * + * Since the hypervisor will not put more data + * onto the RX bufring once the channel is revoked, + * the following loop will be terminated, once all + * data are drained by the driver's channel + * callback. + */ + while (!vmbus_chan_rx_empty(chan)) { + if (can_sleep) + pause("chxact", 1); + else + DELAY(1000); + } + } + return (ret); +} From owner-svn-src-stable-10@freebsd.org Thu Dec 29 07:07:18 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 2E91AC94219; Thu, 29 Dec 2016 07:07:18 +0000 (UTC) (envelope-from sephe@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 F12B011EF; Thu, 29 Dec 2016 07:07:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT77HKw055117; Thu, 29 Dec 2016 07:07:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT77GBK055113; Thu, 29 Dec 2016 07:07:16 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290707.uBT77GBK055113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 07:07:16 +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: r310757 - stable/10/sys/dev/hyperv/netvsc 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.23 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, 29 Dec 2016 07:07:18 -0000 Author: sephe Date: Thu Dec 29 07:07:16 2016 New Revision: 310757 URL: https://svnweb.freebsd.org/changeset/base/310757 Log: MFC 309226-309231,309235 309226 hyperv/hn: Utilize vmbus_chan_xact_wait Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8612 309227 hyperv/hn: Fix detach error handling. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8613 309228 hyperv/hn: Fix multi-packet RNDIS message aggregation size setting. Just in case that no chimney sending buffer can be used. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8619 309229 hyperv/hn: Fix attach error handling Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8620 309230 hyperv/hn: Enable multi-packet RNDIS message support by default. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8621 309231 hyperv/hn: Fix vmbus_chan_subidx usage. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8629 309235 hyperv/hn: Simplify RSS indirect table fixup API Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8630 Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c stable/10/sys/dev/hyperv/netvsc/hn_rndis.c stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 07:06:49 2016 (r310756) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Thu Dec 29 07:07:16 2016 (r310757) @@ -62,8 +62,8 @@ __FBSDID("$FreeBSD$"); static int hn_nvs_conn_chim(struct hn_softc *); static int hn_nvs_conn_rxbuf(struct hn_softc *); -static int hn_nvs_disconn_chim(struct hn_softc *); -static int hn_nvs_disconn_rxbuf(struct hn_softc *); +static void hn_nvs_disconn_chim(struct hn_softc *); +static void hn_nvs_disconn_rxbuf(struct hn_softc *); static int hn_nvs_conf_ndis(struct hn_softc *, int); static int hn_nvs_init_ndis(struct hn_softc *); static int hn_nvs_doinit(struct hn_softc *, uint32_t); @@ -109,10 +109,8 @@ hn_nvs_xact_execute(struct hn_softc *sc, vmbus_xact_deactivate(xact); return (NULL); } - if (HN_CAN_SLEEP(sc)) - hdr = vmbus_xact_wait(xact, &resplen); - else - hdr = vmbus_xact_busywait(xact, &resplen); + hdr = vmbus_chan_xact_wait(sc->hn_prichan, xact, &resplen, + HN_CAN_SLEEP(sc)); /* * Check this NVS response message. @@ -275,8 +273,14 @@ hn_nvs_conn_chim(struct hn_softc *sc) goto cleanup; } if (sectsz == 0) { + /* + * Can't use chimney sending buffer; done! + */ if_printf(sc->hn_ifp, "zero chimney sending buffer " "section size\n"); + sc->hn_chim_szmax = 0; + sc->hn_chim_cnt = 0; + sc->hn_flags |= HN_FLAG_CHIM_CONNECTED; return (0); } @@ -310,7 +314,7 @@ cleanup: return (error); } -static int +static void hn_nvs_disconn_rxbuf(struct hn_softc *sc) { int error; @@ -330,7 +334,12 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc if (error) { if_printf(sc->hn_ifp, "send nvs rxbuf disconn failed: %d\n", error); - return (error); + /* + * Fine for a revoked channel, since the hypervisor + * does not drain TX bufring for a revoked channel. + */ + if (!vmbus_chan_is_revoked(sc->hn_prichan)) + sc->hn_flags |= HN_FLAG_RXBUF_REF; } sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; @@ -359,14 +368,13 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc if (error) { if_printf(sc->hn_ifp, "rxbuf gpadl disconn failed: %d\n", error); - return (error); + sc->hn_flags |= HN_FLAG_RXBUF_REF; } sc->hn_rxbuf_gpadl = 0; } - return (0); } -static int +static void hn_nvs_disconn_chim(struct hn_softc *sc) { int error; @@ -386,7 +394,12 @@ hn_nvs_disconn_chim(struct hn_softc *sc) if (error) { if_printf(sc->hn_ifp, "send nvs chim disconn failed: %d\n", error); - return (error); + /* + * Fine for a revoked channel, since the hypervisor + * does not drain TX bufring for a revoked channel. + */ + if (!vmbus_chan_is_revoked(sc->hn_prichan)) + sc->hn_flags |= HN_FLAG_CHIM_REF; } sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; @@ -416,7 +429,7 @@ hn_nvs_disconn_chim(struct hn_softc *sc) if (error) { if_printf(sc->hn_ifp, "chim gpadl disconn failed: %d\n", error); - return (error); + sc->hn_flags |= HN_FLAG_CHIM_REF; } sc->hn_chim_gpadl = 0; } @@ -424,8 +437,8 @@ hn_nvs_disconn_chim(struct hn_softc *sc) if (sc->hn_chim_bmap != NULL) { free(sc->hn_chim_bmap, M_DEVBUF); sc->hn_chim_bmap = NULL; + sc->hn_chim_bmap_cnt = 0; } - return (0); } static int @@ -614,8 +627,10 @@ hn_nvs_attach(struct hn_softc *sc, int m * Connect chimney sending buffer. */ error = hn_nvs_conn_chim(sc); - if (error) + if (error) { + hn_nvs_disconn_rxbuf(sc); return (error); + } return (0); } Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 07:06:49 2016 (r310756) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Thu Dec 29 07:07:16 2016 (r310757) @@ -233,10 +233,8 @@ hn_rndis_xact_exec1(struct hn_softc *sc, if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); return (NULL); } - if (HN_CAN_SLEEP(sc)) - return (vmbus_xact_wait(xact, comp_len)); - else - return (vmbus_xact_busywait(xact, comp_len)); + return (vmbus_chan_xact_wait(sc->hn_prichan, xact, comp_len, + HN_CAN_SLEEP(sc))); } static const void * @@ -982,7 +980,6 @@ hn_rndis_attach(struct hn_softc *sc, int /* * Configure NDIS offload settings. - * XXX no offloading, if error happened? */ hn_rndis_conf_offload(sc, mtu); return (0); Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 07:06:49 2016 (r310756) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 07:07:16 2016 (r310757) @@ -299,6 +299,7 @@ static int hn_synth_attach(struct hn_s static void hn_synth_detach(struct hn_softc *); static int hn_synth_alloc_subchans(struct hn_softc *, int *); +static bool hn_synth_attachable(const struct hn_softc *); static void hn_suspend(struct hn_softc *); static void hn_suspend_data(struct hn_softc *); static void hn_suspend_mgmt(struct hn_softc *); @@ -321,7 +322,7 @@ static void hn_destroy_rx_data(struct static int hn_check_iplen(const struct mbuf *, int); static int hn_set_rxfilter(struct hn_softc *); static int hn_rss_reconfig(struct hn_softc *); -static void hn_rss_ind_fixup(struct hn_softc *, int); +static void hn_rss_ind_fixup(struct hn_softc *); static int hn_rxpkt(struct hn_rx_ring *, const void *, int, const struct hn_rxinfo *); @@ -467,7 +468,7 @@ SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_size &hn_tx_agg_size, 0, "Packet transmission aggregation size limit"); /* Packet transmission aggregation count limit */ -static int hn_tx_agg_pkts = 0; +static int hn_tx_agg_pkts = -1; SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_pkts, CTLFLAG_RDTUN, &hn_tx_agg_pkts, 0, "Packet transmission aggregation packet limit"); @@ -708,6 +709,10 @@ hn_set_txagg(struct hn_softc *sc) if (sc->hn_rndis_agg_size < size) size = sc->hn_rndis_agg_size; + /* NOTE: We only aggregate packets using chimney sending buffers. */ + if (size > (uint32_t)sc->hn_chim_szmax) + size = sc->hn_chim_szmax; + if (size <= 2 * HN_PKTSIZE_MIN(sc->hn_rndis_agg_align)) { /* Disable */ size = 0; @@ -719,10 +724,6 @@ hn_set_txagg(struct hn_softc *sc) if (size > INT_MAX) size = INT_MAX; - /* NOTE: We only aggregate packets using chimney sending buffers. */ - if (size > (uint32_t)sc->hn_chim_szmax) - size = sc->hn_chim_szmax; - /* * Setup aggregation packet count. */ @@ -819,11 +820,12 @@ hn_rss_reconfig(struct hn_softc *sc) } static void -hn_rss_ind_fixup(struct hn_softc *sc, int nchan) +hn_rss_ind_fixup(struct hn_softc *sc) { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; - int i; + int i, nchan; + nchan = sc->hn_rx_ring_inuse; KASSERT(nchan > 1, ("invalid # of channels %d", nchan)); /* @@ -1545,7 +1547,7 @@ hn_txpkt_done(struct hn_nvs_sendctx *snd txr = txd->txr; KASSERT(txr->hn_chan == chan, ("channel mismatch, on chan%u, should be chan%u", - vmbus_chan_subidx(chan), vmbus_chan_subidx(txr->hn_chan))); + vmbus_chan_id(chan), vmbus_chan_id(txr->hn_chan))); txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); @@ -2968,7 +2970,7 @@ hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS) goto back; sc->hn_flags |= HN_FLAG_HAS_RSSIND; - hn_rss_ind_fixup(sc, sc->hn_rx_ring_inuse); + hn_rss_ind_fixup(sc); error = hn_rss_reconfig(sc); back: HN_UNLOCK(sc); @@ -3275,7 +3277,10 @@ hn_destroy_rx_data(struct hn_softc *sc) int i; if (sc->hn_rxbuf != NULL) { - hyperv_dmamem_free(&sc->hn_rxbuf_dma, sc->hn_rxbuf); + if ((sc->hn_flags & HN_FLAG_RXBUF_REF) == 0) + hyperv_dmamem_free(&sc->hn_rxbuf_dma, sc->hn_rxbuf); + else + device_printf(sc->hn_dev, "RXBUF is referenced\n"); sc->hn_rxbuf = NULL; } @@ -3287,7 +3292,12 @@ hn_destroy_rx_data(struct hn_softc *sc) if (rxr->hn_br == NULL) continue; - hyperv_dmamem_free(&rxr->hn_br_dma, rxr->hn_br); + if ((rxr->hn_rx_flags & HN_RX_FLAG_BR_REF) == 0) { + hyperv_dmamem_free(&rxr->hn_br_dma, rxr->hn_br); + } else { + device_printf(sc->hn_dev, + "%dth channel bufring is referenced", i); + } rxr->hn_br = NULL; #if defined(INET) || defined(INET6) @@ -3756,7 +3766,12 @@ hn_destroy_tx_data(struct hn_softc *sc) int i; if (sc->hn_chim != NULL) { - hyperv_dmamem_free(&sc->hn_chim_dma, sc->hn_chim); + if ((sc->hn_flags & HN_FLAG_CHIM_REF) == 0) { + hyperv_dmamem_free(&sc->hn_chim_dma, sc->hn_chim); + } else { + device_printf(sc->hn_dev, + "chimney sending buffer is referenced"); + } sc->hn_chim = NULL; } @@ -4227,11 +4242,14 @@ hn_chan_attach(struct hn_softc *sc, stru cbr.cbr_rxsz = HN_RXBR_SIZE; error = vmbus_chan_open_br(chan, &cbr, NULL, 0, hn_chan_callback, rxr); if (error) { - if_printf(sc->hn_ifp, "open chan%u failed: %d\n", - vmbus_chan_id(chan), error); - rxr->hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; - if (txr != NULL) - txr->hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + if (error == EISCONN) { + if_printf(sc->hn_ifp, "bufring is connected after " + "chan%u open failure\n", vmbus_chan_id(chan)); + rxr->hn_rx_flags |= HN_RX_FLAG_BR_REF; + } else { + if_printf(sc->hn_ifp, "open chan%u failed: %d\n", + vmbus_chan_id(chan), error); + } } return (error); } @@ -4240,7 +4258,7 @@ static void hn_chan_detach(struct hn_softc *sc, struct vmbus_channel *chan) { struct hn_rx_ring *rxr; - int idx; + int idx, error; idx = vmbus_chan_subidx(chan); @@ -4269,7 +4287,15 @@ hn_chan_detach(struct hn_softc *sc, stru * NOTE: * Channel closing does _not_ destroy the target channel. */ - vmbus_chan_close(chan); + error = vmbus_chan_close_direct(chan); + if (error == EISCONN) { + if_printf(sc->hn_ifp, "chan%u bufring is connected " + "after being closed\n", vmbus_chan_id(chan)); + rxr->hn_rx_flags |= HN_RX_FLAG_BR_REF; + } else if (error) { + if_printf(sc->hn_ifp, "chan%u close failed: %d\n", + vmbus_chan_id(chan), error); + } } static int @@ -4279,15 +4305,18 @@ hn_attach_subchans(struct hn_softc *sc) int subchan_cnt = sc->hn_rx_ring_inuse - 1; int i, error = 0; - if (subchan_cnt == 0) - return (0); + KASSERT(subchan_cnt > 0, ("no sub-channels")); /* Attach the sub-channels. */ subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); for (i = 0; i < subchan_cnt; ++i) { - error = hn_chan_attach(sc, subchans[i]); - if (error) - break; + int error1; + + error1 = hn_chan_attach(sc, subchans[i]); + if (error1) { + error = error1; + /* Move on; all channels will be detached later. */ + } } vmbus_subchan_rel(subchans, subchan_cnt); @@ -4399,16 +4428,39 @@ hn_synth_alloc_subchans(struct hn_softc return (0); } +static bool +hn_synth_attachable(const struct hn_softc *sc) +{ + int i; + + if (sc->hn_flags & HN_FLAG_ERRORS) + return (false); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + const struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + + if (rxr->hn_rx_flags & HN_RX_FLAG_BR_REF) + return (false); + } + return (true); +} + static int hn_synth_attach(struct hn_softc *sc, int mtu) { +#define ATTACHED_NVS 0x0002 +#define ATTACHED_RNDIS 0x0004 + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; int error, nsubch, nchan, i; - uint32_t old_caps; + uint32_t old_caps, attached = 0; KASSERT((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0, ("synthetic parts were attached")); + if (!hn_synth_attachable(sc)) + return (ENXIO); + /* Save capabilities for later verification. */ old_caps = sc->hn_caps; sc->hn_caps = 0; @@ -4422,21 +4474,23 @@ hn_synth_attach(struct hn_softc *sc, int */ error = hn_chan_attach(sc, sc->hn_prichan); if (error) - return (error); + goto failed; /* * Attach NVS. */ error = hn_nvs_attach(sc, mtu); if (error) - return (error); + goto failed; + attached |= ATTACHED_NVS; /* * Attach RNDIS _after_ NVS is attached. */ error = hn_rndis_attach(sc, mtu); if (error) - return (error); + goto failed; + attached |= ATTACHED_RNDIS; /* * Make sure capabilities are not changed. @@ -4444,9 +4498,8 @@ hn_synth_attach(struct hn_softc *sc, int if (device_is_attached(sc->hn_dev) && old_caps != sc->hn_caps) { if_printf(sc->hn_ifp, "caps mismatch old 0x%08x, new 0x%08x\n", old_caps, sc->hn_caps); - /* Restore old capabilities and abort. */ - sc->hn_caps = old_caps; - return ENXIO; + error = ENXIO; + goto failed; } /* @@ -4459,19 +4512,34 @@ hn_synth_attach(struct hn_softc *sc, int nsubch = sc->hn_rx_ring_cnt - 1; error = hn_synth_alloc_subchans(sc, &nsubch); if (error) - return (error); + goto failed; + /* NOTE: _Full_ synthetic parts detach is required now. */ + sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; + /* + * Set the # of TX/RX rings that could be used according to + * the # of channels that NVS offered. + */ nchan = nsubch + 1; + hn_set_ring_inuse(sc, nchan); if (nchan == 1) { /* Only the primary channel can be used; done */ goto back; } /* - * Configure RSS key and indirect table _after_ all sub-channels - * are allocated. + * Attach the sub-channels. + * + * NOTE: hn_set_ring_inuse() _must_ have been called. */ + error = hn_attach_subchans(sc); + if (error) + goto failed; + /* + * Configure RSS key and indirect table _after_ all sub-channels + * are attached. + */ if ((sc->hn_flags & HN_FLAG_HAS_RSSKEY) == 0) { /* * RSS key is not set yet; set it to the default RSS key. @@ -4499,39 +4567,38 @@ hn_synth_attach(struct hn_softc *sc, int * # of usable channels may be changed, so we have to * make sure that all entries in RSS indirect table * are valid. + * + * NOTE: hn_set_ring_inuse() _must_ have been called. */ - hn_rss_ind_fixup(sc, nchan); + hn_rss_ind_fixup(sc); } error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); - if (error) { - /* - * Failed to configure RSS key or indirect table; only - * the primary channel can be used. - */ - nchan = 1; - } -back: - /* - * Set the # of TX/RX rings that could be used according to - * the # of channels that NVS offered. - */ - hn_set_ring_inuse(sc, nchan); - - /* - * Attach the sub-channels, if any. - */ - error = hn_attach_subchans(sc); if (error) - return (error); - + goto failed; +back: /* * Fixup transmission aggregation setup. */ hn_set_txagg(sc); - - sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; return (0); + +failed: + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { + hn_synth_detach(sc); + } else { + if (attached & ATTACHED_RNDIS) + hn_rndis_detach(sc); + if (attached & ATTACHED_NVS) + hn_nvs_detach(sc); + hn_chan_detach(sc, sc->hn_prichan); + /* Restore old capabilities. */ + sc->hn_caps = old_caps; + } + return (error); + +#undef ATTACHED_RNDIS +#undef ATTACHED_NVS } /* @@ -4542,7 +4609,6 @@ back: static void hn_synth_detach(struct hn_softc *sc) { - HN_LOCK_ASSERT(sc); KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 07:06:49 2016 (r310756) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 07:07:16 2016 (r310757) @@ -91,7 +91,8 @@ struct hn_rx_ring { #define HN_TRUST_HCSUM_TCP 0x0002 #define HN_TRUST_HCSUM_UDP 0x0004 -#define HN_RX_FLAG_ATTACHED 0x1 +#define HN_RX_FLAG_ATTACHED 0x0001 +#define HN_RX_FLAG_BR_REF 0x0002 struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING @@ -162,8 +163,8 @@ struct hn_tx_ring { struct sysctl_oid *hn_tx_sysctl_tree; } __aligned(CACHE_LINE_SIZE); -#define HN_TX_FLAG_ATTACHED 0x1 -#define HN_TX_FLAG_HASHVAL 0x2 /* support HASHVAL pktinfo */ +#define HN_TX_FLAG_ATTACHED 0x0001 +#define HN_TX_FLAG_HASHVAL 0x0002 /* support HASHVAL pktinfo */ /* * Device-specific softc structure @@ -238,6 +239,10 @@ struct hn_softc { #define HN_FLAG_HAS_RSSIND 0x0008 #define HN_FLAG_SYNTH_ATTACHED 0x0010 #define HN_FLAG_NO_SLEEPING 0x0020 +#define HN_FLAG_RXBUF_REF 0x0040 +#define HN_FLAG_CHIM_REF 0x0080 + +#define HN_FLAG_ERRORS (HN_FLAG_RXBUF_REF | HN_FLAG_CHIM_REF) #define HN_NO_SLEEPING(sc) \ do { \ From owner-svn-src-stable-10@freebsd.org Thu Dec 29 07:11: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 616AEC94423; Thu, 29 Dec 2016 07:11:22 +0000 (UTC) (envelope-from sephe@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 168A0164E; Thu, 29 Dec 2016 07:11:22 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT7BL3R055404; Thu, 29 Dec 2016 07:11:21 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT7BLY8055402; Thu, 29 Dec 2016 07:11:21 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290711.uBT7BLY8055402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 07:11: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: r310759 - stable/10/sys/dev/hyperv/vmbus 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.23 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, 29 Dec 2016 07:11:22 -0000 Author: sephe Date: Thu Dec 29 07:11:20 2016 New Revision: 310759 URL: https://svnweb.freebsd.org/changeset/base/310759 Log: MFC 309236,309237 309236 hyperv/vmbus: Make sure that the allocated GPADL is not zero. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8631 309237 hyperv/vmbus: Stringent GPADL parameter assertion. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8632 Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 07:10:25 2016 (r310758) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 07:11:20 2016 (r310759) @@ -327,7 +327,13 @@ vmbus_msghc_wakeup(struct vmbus_softc *s uint32_t vmbus_gpadl_alloc(struct vmbus_softc *sc) { - return atomic_fetchadd_int(&sc->vmbus_gpadl, 1); + uint32_t gpadl; + +again: + gpadl = atomic_fetchadd_int(&sc->vmbus_gpadl, 1); + if (gpadl == 0) + goto again; + return (gpadl); } static int Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 07:10:25 2016 (r310758) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 07:11:20 2016 (r310759) @@ -502,11 +502,7 @@ vmbus_chan_gpadl_connect(struct vmbus_ch int page_count, range_len, i, cnt, error; uint64_t page_id; - /* - * Reset GPADL, so that the result would consistent, if error - * happened later on. - */ - *gpadl0 = 0; + KASSERT(*gpadl0 == 0, ("GPADL is not zero")); /* * Preliminary checks. @@ -652,6 +648,8 @@ vmbus_chan_gpadl_disconnect(struct vmbus struct vmbus_chanmsg_gpadl_disconn *req; int error; + KASSERT(gpadl != 0, ("GPADL is zero")); + mh = vmbus_msghc_get(sc, sizeof(*req)); if (mh == NULL) { vmbus_chan_printf(chan, From owner-svn-src-stable-10@freebsd.org Thu Dec 29 07:27: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 03BD1C9493C; Thu, 29 Dec 2016 07:27:15 +0000 (UTC) (envelope-from sephe@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 B89041FD7; Thu, 29 Dec 2016 07:27:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT7RDcB064041; Thu, 29 Dec 2016 07:27:13 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT7RDa8064036; Thu, 29 Dec 2016 07:27:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290727.uBT7RDa8064036@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 07:27:13 +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: r310761 - in stable/10/sys/dev/hyperv: include vmbus 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.23 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, 29 Dec 2016 07:27:15 -0000 Author: sephe Date: Thu Dec 29 07:27:13 2016 New Revision: 310761 URL: https://svnweb.freebsd.org/changeset/base/310761 Log: MFC 309240,309242,309244,309245,309319,309670 309240 hyperv/vmbus: Add result polling support for xact API. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8633 309242 hyperv/vmbus: Add result polling support for message Hypercall API. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8634 309244 hyperv/vmbus: Add exec cancel support for message Hypercall API. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8635 309245 hyperv/vmbus: Use poll/cancel APIs to wait for the CHOPEN response. Since hypervisor does not respond CHOPEN to a revoked channel. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8636 309319 hypver/vmbus: Remove extra assertion. It is asserted by vmbus_chan_gpadl_connect() now. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8660 309670 hyperv/vmbus: Use pause if possible. This makes booting on Hyper-V w/ small # of vCPUs work properly. Reported by: Hongxiong Xian , Hongjiang Zhang Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 07:20:53 2016 (r310760) +++ stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Dec 29 07:27:13 2016 (r310761) @@ -56,6 +56,8 @@ const void *vmbus_xact_wait(struct vmbu size_t *resp_len); const void *vmbus_xact_busywait(struct vmbus_xact *xact, size_t *resp_len); +const void *vmbus_xact_poll(struct vmbus_xact *xact, + size_t *resp_len); void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen); void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 07:20:53 2016 (r310760) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 07:27:13 2016 (r310761) @@ -309,6 +309,13 @@ vmbus_msghc_exec(struct vmbus_softc *sc return error; } +void +vmbus_msghc_exec_cancel(struct vmbus_softc *sc __unused, struct vmbus_msghc *mh) +{ + + vmbus_xact_deactivate(mh->mh_xact); +} + const struct vmbus_message * vmbus_msghc_wait_result(struct vmbus_softc *sc __unused, struct vmbus_msghc *mh) { @@ -317,6 +324,14 @@ vmbus_msghc_wait_result(struct vmbus_sof return (vmbus_xact_wait(mh->mh_xact, &resp_len)); } +const struct vmbus_message * +vmbus_msghc_poll_result(struct vmbus_softc *sc __unused, struct vmbus_msghc *mh) +{ + size_t resp_len; + + return (vmbus_xact_poll(mh->mh_xact, &resp_len)); +} + void vmbus_msghc_wakeup(struct vmbus_softc *sc, const struct vmbus_message *msg) { Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 07:20:53 2016 (r310760) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Dec 29 07:27:13 2016 (r310761) @@ -67,7 +67,7 @@ static void vmbus_chan_set_chmap(struc static void vmbus_chan_clear_chmap(struct vmbus_channel *); static void vmbus_chan_detach(struct vmbus_channel *); static bool vmbus_chan_wait_revoke( - const struct vmbus_channel *); + const struct vmbus_channel *, bool); static void vmbus_chan_ins_prilist(struct vmbus_softc *, struct vmbus_channel *); @@ -349,7 +349,6 @@ vmbus_chan_open_br(struct vmbus_channel const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) { struct vmbus_softc *sc = chan->ch_vmbus; - const struct vmbus_chanmsg_chopen_resp *resp; const struct vmbus_message *msg; struct vmbus_chanmsg_chopen *req; struct vmbus_msghc *mh; @@ -406,8 +405,6 @@ vmbus_chan_open_br(struct vmbus_channel /* * Connect the bufrings, both RX and TX, to this channel. */ - KASSERT(chan->ch_bufring_gpadl == 0, - ("bufring GPADL is still connected")); error = vmbus_chan_gpadl_connect(chan, cbr->cbr_paddr, txbr_size + rxbr_size, &chan->ch_bufring_gpadl); if (error) { @@ -453,9 +450,50 @@ vmbus_chan_open_br(struct vmbus_channel goto failed; } - msg = vmbus_msghc_wait_result(sc, mh); - resp = (const struct vmbus_chanmsg_chopen_resp *)msg->msg_data; - status = resp->chm_status; + for (;;) { + msg = vmbus_msghc_poll_result(sc, mh); + if (msg != NULL) + break; + if (vmbus_chan_is_revoked(chan)) { + int i; + + /* + * NOTE: + * Hypervisor does _not_ send response CHOPEN to + * a revoked channel. + */ + vmbus_chan_printf(chan, + "chan%u is revoked, when it is being opened\n", + chan->ch_id); + + /* + * XXX + * Add extra delay before cancel the hypercall + * execution; mainly to close any possible + * CHRESCIND and CHOPEN_RESP races on the + * hypervisor side. + */ +#define REVOKE_LINGER 100 + for (i = 0; i < REVOKE_LINGER; ++i) { + msg = vmbus_msghc_poll_result(sc, mh); + if (msg != NULL) + break; + pause("rchopen", 1); + } +#undef REVOKE_LINGER + if (msg == NULL) + vmbus_msghc_exec_cancel(sc, mh); + break; + } + pause("chopen", 1); + } + if (msg != NULL) { + status = ((const struct vmbus_chanmsg_chopen_resp *) + msg->msg_data)->chm_status; + } else { + /* XXX any non-0 value is ok here. */ + status = 0xff; + } vmbus_msghc_put(sc, mh); @@ -620,7 +658,7 @@ vmbus_chan_gpadl_connect(struct vmbus_ch } static bool -vmbus_chan_wait_revoke(const struct vmbus_channel *chan) +vmbus_chan_wait_revoke(const struct vmbus_channel *chan, bool can_sleep) { #define WAIT_COUNT 200 /* 200ms */ @@ -629,8 +667,10 @@ vmbus_chan_wait_revoke(const struct vmbu for (i = 0; i < WAIT_COUNT; ++i) { if (vmbus_chan_is_revoked(chan)) return (true); - /* Not sure about the context; use busy-wait. */ - DELAY(1000); + if (can_sleep) + pause("wchrev", 1); + else + DELAY(1000); } return (false); @@ -667,7 +707,7 @@ vmbus_chan_gpadl_disconnect(struct vmbus if (error) { vmbus_msghc_put(sc, mh); - if (vmbus_chan_wait_revoke(chan)) { + if (vmbus_chan_wait_revoke(chan, true)) { /* * Error is benign; this channel is revoked, * so this GPADL will not be touched anymore. Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Thu Dec 29 07:20:53 2016 (r310760) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Thu Dec 29 07:27:13 2016 (r310761) @@ -157,9 +157,14 @@ void vmbus_msghc_put(struct vmbus_softc void *vmbus_msghc_dataptr(struct vmbus_msghc *); int vmbus_msghc_exec_noresult(struct vmbus_msghc *); int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); +void vmbus_msghc_exec_cancel(struct vmbus_softc *, + struct vmbus_msghc *); const struct vmbus_message * vmbus_msghc_wait_result(struct vmbus_softc *, struct vmbus_msghc *); +const struct vmbus_message * + vmbus_msghc_poll_result(struct vmbus_softc *, + struct vmbus_msghc *); void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); void vmbus_msghc_reset(struct vmbus_msghc *, size_t); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 07:20:53 2016 (r310760) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c Thu Dec 29 07:27:13 2016 (r310761) @@ -71,8 +71,10 @@ static struct vmbus_xact *vmbus_xact_all static void vmbus_xact_free(struct vmbus_xact *); static struct vmbus_xact *vmbus_xact_get1(struct vmbus_xact_ctx *, uint32_t); -const void *vmbus_xact_wait1(struct vmbus_xact *, size_t *, +static const void *vmbus_xact_wait1(struct vmbus_xact *, size_t *, bool); +static const void *vmbus_xact_return(struct vmbus_xact *, + size_t *); static void vmbus_xact_save_resp(struct vmbus_xact *, const void *, size_t); static void vmbus_xact_ctx_free(struct vmbus_xact_ctx *); @@ -277,27 +279,13 @@ vmbus_xact_deactivate(struct vmbus_xact mtx_unlock(&ctx->xc_lock); } -const void * -vmbus_xact_wait1(struct vmbus_xact *xact, size_t *resp_len, - bool can_sleep) +static const void * +vmbus_xact_return(struct vmbus_xact *xact, size_t *resp_len) { struct vmbus_xact_ctx *ctx = xact->x_ctx; const void *resp; - mtx_lock(&ctx->xc_lock); - - KASSERT(ctx->xc_active == xact, ("xact mismatch")); - while (xact->x_resp == NULL && - (ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) == 0) { - if (can_sleep) { - mtx_sleep(&ctx->xc_active, &ctx->xc_lock, 0, - "wxact", 0); - } else { - mtx_unlock(&ctx->xc_lock); - DELAY(1000); - mtx_lock(&ctx->xc_lock); - } - } + mtx_assert(&ctx->xc_lock, MA_OWNED); KASSERT(ctx->xc_active == xact, ("xact trashed")); if ((ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) && xact->x_resp == NULL) { @@ -317,6 +305,32 @@ vmbus_xact_wait1(struct vmbus_xact *xact resp = xact->x_resp; *resp_len = xact->x_resp_len; + return (resp); +} + +static const void * +vmbus_xact_wait1(struct vmbus_xact *xact, size_t *resp_len, + bool can_sleep) +{ + struct vmbus_xact_ctx *ctx = xact->x_ctx; + const void *resp; + + mtx_lock(&ctx->xc_lock); + + KASSERT(ctx->xc_active == xact, ("xact mismatch")); + while (xact->x_resp == NULL && + (ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) == 0) { + if (can_sleep) { + mtx_sleep(&ctx->xc_active, &ctx->xc_lock, 0, + "wxact", 0); + } else { + mtx_unlock(&ctx->xc_lock); + DELAY(1000); + mtx_lock(&ctx->xc_lock); + } + } + resp = vmbus_xact_return(xact, resp_len); + mtx_unlock(&ctx->xc_lock); return (resp); @@ -336,6 +350,28 @@ vmbus_xact_busywait(struct vmbus_xact *x return (vmbus_xact_wait1(xact, resp_len, false /* can't sleep */)); } +const void * +vmbus_xact_poll(struct vmbus_xact *xact, size_t *resp_len) +{ + struct vmbus_xact_ctx *ctx = xact->x_ctx; + const void *resp; + + mtx_lock(&ctx->xc_lock); + + KASSERT(ctx->xc_active == xact, ("xact mismatch")); + if (xact->x_resp == NULL && + (ctx->xc_flags & VMBUS_XACT_CTXF_DESTROY) == 0) { + mtx_unlock(&ctx->xc_lock); + *resp_len = 0; + return (NULL); + } + resp = vmbus_xact_return(xact, resp_len); + + mtx_unlock(&ctx->xc_lock); + + return (resp); +} + static void vmbus_xact_save_resp(struct vmbus_xact *xact, const void *data, size_t dlen) { From owner-svn-src-stable-10@freebsd.org Thu Dec 29 09:02:50 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 DB127C96B38; Thu, 29 Dec 2016 09:02:50 +0000 (UTC) (envelope-from sephe@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 9D4CD17B0; Thu, 29 Dec 2016 09:02:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT92nxm004741; Thu, 29 Dec 2016 09:02:49 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT92nTM004737; Thu, 29 Dec 2016 09:02:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290902.uBT92nTM004737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 09:02:49 +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: r310768 - in stable/10/sys/dev/hyperv: netvsc vmbus 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.23 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, 29 Dec 2016 09:02:51 -0000 Author: sephe Date: Thu Dec 29 09:02:49 2016 New Revision: 310768 URL: https://svnweb.freebsd.org/changeset/base/310768 Log: MFC 309310,309311,309316,309318 309310 hyperv/hn: Nuke the unused TX taskqueue CPU binding tunable. It was an experimental tunable, and is now deemed to be road blocker for further changes. Time to retire it. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8654 309311 hyperv/hn: Allow multiple TX taskqueues. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8655 309316 hyperv/vmbus: Add DEVMETHOD to map cpu to event taskq. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8658 309318 hyperv/hn: Allow TX to share event taskqueues. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8659 Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_if.m Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 08:41:25 2016 (r310767) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Thu Dec 29 09:02:49 2016 (r310768) @@ -172,6 +172,8 @@ do { \ #define HN_PKTSIZE(m, align) \ roundup2((m)->m_pkthdr.len + HN_RNDIS_PKT_LEN, (align)) +#define HN_RING_IDX2CPU(sc, idx) (((sc)->hn_cpu + (idx)) % mp_ncpus) + struct hn_txdesc { #ifndef HN_USE_TXDESC_BUFRING SLIST_ENTRY(hn_txdesc) link; @@ -414,10 +416,18 @@ SYSCTL_INT(_hw_hn, OID_AUTO, lro_entry_c #endif #endif -/* Use shared TX taskqueue */ -static int hn_share_tx_taskq = 0; -SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_taskq, CTLFLAG_RDTUN, - &hn_share_tx_taskq, 0, "Enable shared TX taskqueue"); +static int hn_tx_taskq_cnt = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_taskq_cnt, CTLFLAG_RDTUN, + &hn_tx_taskq_cnt, 0, "# of TX taskqueues"); + +#define HN_TX_TASKQ_M_INDEP 0 +#define HN_TX_TASKQ_M_GLOBAL 1 +#define HN_TX_TASKQ_M_EVTTQ 2 + +static int hn_tx_taskq_mode = HN_TX_TASKQ_M_INDEP; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_taskq_mode, CTLFLAG_RDTUN, + &hn_tx_taskq_mode, 0, "TX taskqueue modes: " + "0 - independent, 1 - share global tx taskqs, 2 - share event taskqs"); #ifndef HN_USE_TXDESC_BUFRING static int hn_use_txdesc_bufring = 0; @@ -427,11 +437,6 @@ static int hn_use_txdesc_bufring = 1; SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD, &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors"); -/* Bind TX taskqueue to the target CPU */ -static int hn_bind_tx_taskq = -1; -SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, - &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); - #ifdef HN_IFSTART_SUPPORT /* Use ifnet.if_start instead of ifnet.if_transmit */ static int hn_use_if_start = 0; @@ -473,7 +478,7 @@ SYSCTL_INT(_hw_hn, OID_AUTO, tx_agg_pkts &hn_tx_agg_pkts, 0, "Packet transmission aggregation packet limit"); static u_int hn_cpu_index; /* next CPU for channel */ -static struct taskqueue *hn_tx_taskq; /* shared TX taskqueue */ +static struct taskqueue **hn_tx_taskque;/* shared TX taskqueues */ static const uint8_t hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { @@ -883,19 +888,6 @@ hn_probe(device_t dev) return ENXIO; } -static void -hn_cpuset_setthread_task(void *xmask, int pending __unused) -{ - cpuset_t *mask = xmask; - int error; - - error = cpuset_setthread(curthread->td_tid, mask); - if (error) { - panic("curthread=%ju: can't pin; error=%d", - (uintmax_t)curthread->td_tid, error); - } -} - static int hn_attach(device_t dev) { @@ -919,26 +911,21 @@ hn_attach(device_t dev) /* * Setup taskqueue for transmission. */ - if (hn_tx_taskq == NULL) { - sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, - taskqueue_thread_enqueue, &sc->hn_tx_taskq); - taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", - device_get_nameunit(dev)); - if (hn_bind_tx_taskq >= 0) { - int cpu = hn_bind_tx_taskq; - struct task cpuset_task; - cpuset_t cpu_set; - - if (cpu > mp_ncpus - 1) - cpu = mp_ncpus - 1; - CPU_SETOF(cpu, &cpu_set); - TASK_INIT(&cpuset_task, 0, hn_cpuset_setthread_task, - &cpu_set); - taskqueue_enqueue(sc->hn_tx_taskq, &cpuset_task); - taskqueue_drain(sc->hn_tx_taskq, &cpuset_task); + if (hn_tx_taskq_mode == HN_TX_TASKQ_M_INDEP) { + int i; + + sc->hn_tx_taskqs = + malloc(hn_tx_taskq_cnt * sizeof(struct taskqueue *), + M_DEVBUF, M_WAITOK); + for (i = 0; i < hn_tx_taskq_cnt; ++i) { + sc->hn_tx_taskqs[i] = taskqueue_create("hn_tx", + M_WAITOK, taskqueue_thread_enqueue, + &sc->hn_tx_taskqs[i]); + taskqueue_start_threads(&sc->hn_tx_taskqs[i], 1, PI_NET, + "%s tx%d", device_get_nameunit(dev), i); } - } else { - sc->hn_tx_taskq = hn_tx_taskq; + } else if (hn_tx_taskq_mode == HN_TX_TASKQ_M_GLOBAL) { + sc->hn_tx_taskqs = hn_tx_taskque; } /* @@ -1243,8 +1230,13 @@ hn_detach(device_t dev) hn_destroy_rx_data(sc); hn_destroy_tx_data(sc); - if (sc->hn_tx_taskq != hn_tx_taskq) - taskqueue_free(sc->hn_tx_taskq); + if (sc->hn_tx_taskqs != NULL && sc->hn_tx_taskqs != hn_tx_taskque) { + int i; + + for (i = 0; i < hn_tx_taskq_cnt; ++i) + taskqueue_free(sc->hn_tx_taskqs[i]); + free(sc->hn_tx_taskqs, M_DEVBUF); + } taskqueue_free(sc->hn_mgmt_taskq0); if (sc->hn_xact != NULL) { @@ -3338,7 +3330,12 @@ hn_tx_ring_create(struct hn_softc *sc, i M_WAITOK, &txr->hn_tx_lock); #endif - txr->hn_tx_taskq = sc->hn_tx_taskq; + if (hn_tx_taskq_mode == HN_TX_TASKQ_M_EVTTQ) { + txr->hn_tx_taskq = VMBUS_GET_EVENT_TASKQ( + device_get_parent(dev), dev, HN_RING_IDX2CPU(sc, id)); + } else { + txr->hn_tx_taskq = sc->hn_tx_taskqs[id % hn_tx_taskq_cnt]; + } #ifdef HN_IFSTART_SUPPORT if (hn_use_if_start) { @@ -4231,7 +4228,7 @@ hn_chan_attach(struct hn_softc *sc, stru } /* Bind this channel to a proper CPU. */ - vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); + vmbus_chan_cpu_set(chan, HN_RING_IDX2CPU(sc, idx)); /* * Open this channel @@ -5377,27 +5374,42 @@ hn_chan_callback(struct vmbus_channel *c static void hn_tx_taskq_create(void *arg __unused) { + int i; + + /* + * Fix the # of TX taskqueues. + */ + if (hn_tx_taskq_cnt <= 0) + hn_tx_taskq_cnt = 1; + else if (hn_tx_taskq_cnt > mp_ncpus) + hn_tx_taskq_cnt = mp_ncpus; + + /* + * Fix the TX taskqueue mode. + */ + switch (hn_tx_taskq_mode) { + case HN_TX_TASKQ_M_INDEP: + case HN_TX_TASKQ_M_GLOBAL: + case HN_TX_TASKQ_M_EVTTQ: + break; + default: + hn_tx_taskq_mode = HN_TX_TASKQ_M_INDEP; + break; + } if (vm_guest != VM_GUEST_HV) return; - if (!hn_share_tx_taskq) + if (hn_tx_taskq_mode != HN_TX_TASKQ_M_GLOBAL) return; - hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, - taskqueue_thread_enqueue, &hn_tx_taskq); - taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx"); - if (hn_bind_tx_taskq >= 0) { - int cpu = hn_bind_tx_taskq; - struct task cpuset_task; - cpuset_t cpu_set; - - if (cpu > mp_ncpus - 1) - cpu = mp_ncpus - 1; - CPU_SETOF(cpu, &cpu_set); - TASK_INIT(&cpuset_task, 0, hn_cpuset_setthread_task, &cpu_set); - taskqueue_enqueue(hn_tx_taskq, &cpuset_task); - taskqueue_drain(hn_tx_taskq, &cpuset_task); + hn_tx_taskque = malloc(hn_tx_taskq_cnt * sizeof(struct taskqueue *), + M_DEVBUF, M_WAITOK); + for (i = 0; i < hn_tx_taskq_cnt; ++i) { + hn_tx_taskque[i] = taskqueue_create("hn_tx", M_WAITOK, + taskqueue_thread_enqueue, &hn_tx_taskque[i]); + taskqueue_start_threads(&hn_tx_taskque[i], 1, PI_NET, + "hn tx%d", i); } } SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_SECOND, @@ -5407,8 +5419,13 @@ static void hn_tx_taskq_destroy(void *arg __unused) { - if (hn_tx_taskq != NULL) - taskqueue_free(hn_tx_taskq); + if (hn_tx_taskque != NULL) { + int i; + + for (i = 0; i < hn_tx_taskq_cnt; ++i) + taskqueue_free(hn_tx_taskque[i]); + free(hn_tx_taskque, M_DEVBUF); + } } SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_SECOND, hn_tx_taskq_destroy, NULL); Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 08:41:25 2016 (r310767) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Dec 29 09:02:49 2016 (r310768) @@ -193,7 +193,7 @@ struct hn_softc { int hn_chim_szmax; int hn_cpu; - struct taskqueue *hn_tx_taskq; + struct taskqueue **hn_tx_taskqs; struct sysctl_oid *hn_tx_sysctl_tree; struct sysctl_oid *hn_rx_sysctl_tree; struct vmbus_xact_ctx *hn_xact; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 08:41:25 2016 (r310767) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Thu Dec 29 09:02:49 2016 (r310768) @@ -99,6 +99,8 @@ static int vmbus_probe_guid_method(dev const struct hyperv_guid *); static uint32_t vmbus_get_vcpu_id_method(device_t bus, device_t dev, int cpu); +static struct taskqueue *vmbus_get_eventtq_method(device_t, device_t, + int); static int vmbus_init(struct vmbus_softc *); static int vmbus_connect(struct vmbus_softc *, uint32_t); @@ -174,6 +176,7 @@ static device_method_t vmbus_methods[] = DEVMETHOD(vmbus_get_version, vmbus_get_version_method), DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), DEVMETHOD(vmbus_get_vcpu_id, vmbus_get_vcpu_id_method), + DEVMETHOD(vmbus_get_event_taskq, vmbus_get_eventtq_method), DEVMETHOD_END }; @@ -1208,6 +1211,15 @@ vmbus_get_vcpu_id_method(device_t bus, d return (VMBUS_PCPU_GET(sc, vcpuid, cpu)); } +static struct taskqueue * +vmbus_get_eventtq_method(device_t bus, device_t dev __unused, int cpu) +{ + const struct vmbus_softc *sc = device_get_softc(bus); + + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu%d", cpu)); + return (VMBUS_PCPU_GET(sc, event_tq, cpu)); +} + #ifdef NEW_PCIB #define VTPM_BASE_ADDR 0xfed40000 #define FOUR_GB (1ULL << 32) Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_if.m ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_if.m Thu Dec 29 08:41:25 2016 (r310767) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_if.m Thu Dec 29 09:02:49 2016 (r310768) @@ -33,6 +33,7 @@ INTERFACE vmbus; HEADER { struct hyperv_guid; + struct taskqueue; }; METHOD uint32_t get_version { @@ -51,3 +52,9 @@ METHOD uint32_t get_vcpu_id { device_t dev; int cpu; }; + +METHOD struct taskqueue * get_event_taskq { + device_t bus; + device_t dev; + int cpu; +}; From owner-svn-src-stable-10@freebsd.org Thu Dec 29 09:10:38 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 B13AEC96CF0; Thu, 29 Dec 2016 09:10:38 +0000 (UTC) (envelope-from sephe@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 8BABF1AEA; Thu, 29 Dec 2016 09:10:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBT9AbTe005211; Thu, 29 Dec 2016 09:10:37 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT9AbYK005210; Thu, 29 Dec 2016 09:10:37 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612290910.uBT9AbYK005210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 29 Dec 2016 09:10:37 +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: r310769 - stable/10/sys/dev/hyperv/storvsc 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.23 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, 29 Dec 2016 09:10:38 -0000 Author: sephe Date: Thu Dec 29 09:10:37 2016 New Revision: 310769 URL: https://svnweb.freebsd.org/changeset/base/310769 Log: MFC 309320,309726,309728 309320 hyperv/storvsc: Don't use timedwait. The timeout is unnecessary. Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8656 309726 hyperv/storvsc: Fix the SCSI disk attachment issue. On pre-WS2016 Hyper-V, if the only LUNs > 7 are used, then all disks fails to attach. Mainly because those versions of Hyper-V do not set SRB_STATUS properly and deliver junky INQUERY responses. Submitted by: Hongjiang Zhang Reported by: Hongxiong Xian Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8724 309728 hyperv/storvsc: Minor style changes; no functional changes. Reported by: rpokala Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Dec 29 09:02:49 2016 (r310768) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Dec 29 09:10:37 2016 (r310769) @@ -413,13 +413,7 @@ storvsc_send_multichannel_request(struct VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); - /* wait for 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - if (ret != 0) { - printf("Storvsc_error: create multi-channel timeout, %d\n", - ret); - return; - } + sema_wait(&request->synch_sema); if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO || vstor_packet->status != 0) { @@ -486,10 +480,7 @@ hv_storvsc_channel_init(struct storvsc_s if (ret != 0) goto cleanup; - /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - if (ret != 0) - goto cleanup; + sema_wait(&request->synch_sema); if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO || vstor_packet->status != 0) { @@ -516,11 +507,7 @@ hv_storvsc_channel_init(struct storvsc_s if (ret != 0) goto cleanup; - /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - - if (ret) - goto cleanup; + sema_wait(&request->synch_sema); if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO) { ret = EINVAL; @@ -555,11 +542,7 @@ hv_storvsc_channel_init(struct storvsc_s if ( ret != 0) goto cleanup; - /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - - if (ret != 0) - goto cleanup; + sema_wait(&request->synch_sema); /* TODO: Check returned version */ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO || @@ -588,11 +571,7 @@ hv_storvsc_channel_init(struct storvsc_s goto cleanup; } - /* wait 5 seconds */ - ret = sema_timedwait(&request->synch_sema, 5 * hz); - - if (ret != 0) - goto cleanup; + sema_wait(&request->synch_sema); if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO || vstor_packet->status != 0) @@ -672,12 +651,7 @@ hv_storvsc_host_reset(struct storvsc_sof goto cleanup; } - ret = sema_timedwait(&request->synch_sema, 5 * hz); /* KYS 5 seconds */ - - if (ret) { - goto cleanup; - } - + sema_wait(&request->synch_sema); /* * At this point, all outstanding requests in the adapter @@ -2079,6 +2053,19 @@ create_storvsc_request(union ccb *ccb, s return(0); } +static uint32_t +is_scsi_valid(const struct scsi_inquiry_data *inq_data) +{ + u_int8_t type; + + type = SID_TYPE(inq_data); + if (type == T_NODEVICE) + return (0); + if (SID_QUAL(inq_data) == SID_QUAL_BAD_LU) + return (0); + return (1); +} + /** * @brief completion function before returning to CAM * @@ -2097,6 +2084,7 @@ storvsc_io_done(struct hv_storvsc_reques struct vmscsi_req *vm_srb = &reqp->vstor_packet.u.vm_srb; bus_dma_segment_t *ori_sglist = NULL; int ori_sg_count = 0; + /* destroy bounce buffer if it is used */ if (reqp->bounce_sgl_count) { ori_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr; @@ -2151,6 +2139,7 @@ storvsc_io_done(struct hv_storvsc_reques ccb->ccb_h.status &= ~CAM_STATUS_MASK; if (vm_srb->scsi_status == SCSI_STATUS_OK) { const struct scsi_generic *cmd; + cmd = (const struct scsi_generic *) ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); @@ -2190,32 +2179,47 @@ storvsc_io_done(struct hv_storvsc_reques ccb->ccb_h.status |= CAM_REQ_CMP; } - if (cmd->opcode == INQUIRY) { + if (cmd->opcode == INQUIRY && + vm_srb->srb_status == SRB_STATUS_SUCCESS) { + int resp_xfer_len, resp_buf_len, data_len; + uint8_t *resp_buf = (uint8_t *)csio->data_ptr; struct scsi_inquiry_data *inq_data = (struct scsi_inquiry_data *)csio->data_ptr; - uint8_t *resp_buf = (uint8_t *)csio->data_ptr; - int resp_xfer_len, resp_buf_len, data_len; /* Get the buffer length reported by host */ resp_xfer_len = vm_srb->transfer_len; + /* Get the available buffer length */ resp_buf_len = resp_xfer_len >= 5 ? resp_buf[4] + 5 : 0; data_len = (resp_buf_len < resp_xfer_len) ? resp_buf_len : resp_xfer_len; - if (bootverbose && data_len >= 5) { xpt_print(ccb->ccb_h.path, "storvsc inquiry " "(%d) [%x %x %x %x %x ... ]\n", data_len, resp_buf[0], resp_buf[1], resp_buf[2], resp_buf[3], resp_buf[4]); } - if (vm_srb->srb_status == SRB_STATUS_SUCCESS && - data_len >= SHORT_INQUIRY_LENGTH) { + /* + * XXX: Manually fix the wrong response returned from WS2012 + */ + if (!is_scsi_valid(inq_data) && + (vmstor_proto_version == VMSTOR_PROTOCOL_VERSION_WIN8_1 || + vmstor_proto_version == VMSTOR_PROTOCOL_VERSION_WIN8 || + vmstor_proto_version == VMSTOR_PROTOCOL_VERSION_WIN7)) { + if (data_len >= 4 && + (resp_buf[2] == 0 || resp_buf[3] == 0)) { + resp_buf[2] = 5; // verion=5 means SPC-3 + resp_buf[3] = 2; // resp fmt must be 2 + if (bootverbose) + xpt_print(ccb->ccb_h.path, + "fix version and resp fmt for 0x%x\n", + vmstor_proto_version); + } + } else if (data_len >= SHORT_INQUIRY_LENGTH) { char vendor[16]; cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor), sizeof(vendor)); - /* * XXX: Upgrade SPC2 to SPC3 if host is WIN8 or * WIN2012 R2 in order to support UNMAP feature. From owner-svn-src-stable-10@freebsd.org Fri Dec 30 01:59:20 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 76ACDC974A1; Fri, 30 Dec 2016 01:59:20 +0000 (UTC) (envelope-from sephe@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 511DB13AB; Fri, 30 Dec 2016 01:59:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBU1xJHQ021392; Fri, 30 Dec 2016 01:59:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBU1xJJn021389; Fri, 30 Dec 2016 01:59:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612300159.uBU1xJJn021389@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 30 Dec 2016 01:59:19 +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: r310799 - in stable/10/sys: conf dev/hyperv/netvsc modules/hyperv/netvsc 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.23 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: Fri, 30 Dec 2016 01:59:20 -0000 Author: sephe Date: Fri Dec 30 01:59:19 2016 New Revision: 310799 URL: https://svnweb.freebsd.org/changeset/base/310799 Log: MFC 309346,309348 309346 hyperv/hn: Add HN_DEBUG kernel option. If bufring is used for per-TX ring descs, don't update "available" counter, which is only used to help debugging. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8674 309348 hyperv/hn: Don't hold txdesc, if no BPFs are attached. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8675 Modified: stable/10/sys/conf/options stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/modules/hyperv/netvsc/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/options ============================================================================== --- stable/10/sys/conf/options Fri Dec 30 01:34:06 2016 (r310798) +++ stable/10/sys/conf/options Fri Dec 30 01:59:19 2016 (r310799) @@ -947,3 +947,6 @@ RANDOM_RWFILE opt_random.h # Intel em(4) driver EM_MULTIQUEUE opt_em.h + +# Hyper-V network driver +HN_DEBUG opt_hn.h Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Dec 30 01:34:06 2016 (r310798) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Dec 30 01:59:19 2016 (r310799) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include "opt_inet.h" +#include "opt_hn.h" #include #include @@ -1436,10 +1437,12 @@ hn_txdesc_put(struct hn_tx_ring *txr, st txr->hn_txdesc_avail++; SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); mtx_unlock_spin(&txr->hn_txlist_spin); -#else +#else /* HN_USE_TXDESC_BUFRING */ +#ifdef HN_DEBUG atomic_add_int(&txr->hn_txdesc_avail, 1); - buf_ring_enqueue(txr->hn_txdesc_br, txd); #endif + buf_ring_enqueue(txr->hn_txdesc_br, txd); +#endif /* !HN_USE_TXDESC_BUFRING */ return 1; } @@ -1465,8 +1468,10 @@ hn_txdesc_get(struct hn_tx_ring *txr) if (txd != NULL) { #ifdef HN_USE_TXDESC_BUFRING +#ifdef HN_DEBUG atomic_subtract_int(&txr->hn_txdesc_avail, 1); #endif +#endif /* HN_USE_TXDESC_BUFRING */ KASSERT(txd->m == NULL && txd->refs == 0 && STAILQ_EMPTY(&txd->agg_list) && txd->chim_index == HN_NVS_CHIM_IDX_INVALID && @@ -1933,17 +1938,20 @@ done: static int hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) { - int error, send_failed = 0; + int error, send_failed = 0, has_bpf; again: - /* - * Make sure that this txd and any aggregated txds are not freed - * before ETHER_BPF_MTAP. - */ - hn_txdesc_hold(txd); + has_bpf = bpf_peers_present(ifp->if_bpf); + if (has_bpf) { + /* + * Make sure that this txd and any aggregated txds are not + * freed before ETHER_BPF_MTAP. + */ + hn_txdesc_hold(txd); + } error = txr->hn_sendpkt(txr, txd); if (!error) { - if (bpf_peers_present(ifp->if_bpf)) { + if (has_bpf) { const struct hn_txdesc *tmp_txd; ETHER_BPF_MTAP(ifp, txd->m); @@ -1966,7 +1974,8 @@ again: txr->hn_pkts += txr->hn_stat_pkts; txr->hn_sends++; } - hn_txdesc_put(txr, txd); + if (has_bpf) + hn_txdesc_put(txr, txd); if (__predict_false(error)) { int freed; @@ -3479,9 +3488,11 @@ hn_tx_ring_create(struct hn_softc *sc, i if (txr->hn_tx_sysctl_tree != NULL) { child = SYSCTL_CHILDREN(txr->hn_tx_sysctl_tree); +#ifdef HN_DEBUG SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_avail", CTLFLAG_RD, &txr->hn_txdesc_avail, 0, "# of available TX descs"); +#endif #ifdef HN_IFSTART_SUPPORT if (!hn_use_if_start) #endif Modified: stable/10/sys/modules/hyperv/netvsc/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/netvsc/Makefile Fri Dec 30 01:34:06 2016 (r310798) +++ stable/10/sys/modules/hyperv/netvsc/Makefile Fri Dec 30 01:59:19 2016 (r310799) @@ -5,7 +5,7 @@ KMOD= hv_netvsc SRCS= hn_nvs.c hn_rndis.c if_hn.c -SRCS+= bus_if.h device_if.h opt_inet.h opt_inet6.h vmbus_if.h +SRCS+= bus_if.h device_if.h opt_inet.h opt_inet6.h vmbus_if.h opt_hn.h CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/netvsc From owner-svn-src-stable-10@freebsd.org Fri Dec 30 02:02: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 17520C975D4; Fri, 30 Dec 2016 02:02:02 +0000 (UTC) (envelope-from sephe@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 D2C991961; Fri, 30 Dec 2016 02:02:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBU2215I022325; Fri, 30 Dec 2016 02:02:01 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBU221EG022324; Fri, 30 Dec 2016 02:02:01 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612300202.uBU221EG022324@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 30 Dec 2016 02:02: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: r310800 - stable/10/sys/dev/hyperv/vmbus 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.23 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: Fri, 30 Dec 2016 02:02:02 -0000 Author: sephe Date: Fri Dec 30 02:02:00 2016 New Revision: 310800 URL: https://svnweb.freebsd.org/changeset/base/310800 Log: MFC 309704 hyperv/vmbus: Utilize vmbus_chan_run_task() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8686 Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Dec 30 01:59:19 2016 (r310799) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Dec 30 02:02:00 2016 (r310800) @@ -772,8 +772,7 @@ vmbus_chan_clear_chmap(struct vmbus_chan struct task chmap_task; TASK_INIT(&chmap_task, 0, vmbus_chan_clrchmap_task, chan); - taskqueue_enqueue(chan->ch_tq, &chmap_task); - taskqueue_drain(chan->ch_tq, &chmap_task); + vmbus_chan_run_task(chan, &chmap_task); } static void From owner-svn-src-stable-10@freebsd.org Fri Dec 30 02:13: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 D2063C979D3; Fri, 30 Dec 2016 02:13:22 +0000 (UTC) (envelope-from sephe@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 ACC291EDB; Fri, 30 Dec 2016 02:13:22 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBU2DLaJ029239; Fri, 30 Dec 2016 02:13:21 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBU2DLMl029233; Fri, 30 Dec 2016 02:13:21 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612300213.uBU2DLMl029233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 30 Dec 2016 02:13: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: r310801 - in stable/10/sys/dev/hyperv: include utilities vmbus 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.23 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: Fri, 30 Dec 2016 02:13:22 -0000 Author: sephe Date: Fri Dec 30 02:13:21 2016 New Revision: 310801 URL: https://svnweb.freebsd.org/changeset/base/310801 Log: MFC 309705 hyperv/timesync: Support "sent TC" to improve accuracy. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8723 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h stable/10/sys/dev/hyperv/vmbus/hyperv_var.h stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/include/hyperv.h Fri Dec 30 02:13:21 2016 (r310801) @@ -36,6 +36,23 @@ #include #include +#define MSR_HV_TIME_REF_COUNT 0x40000020 + +#define CPUID_HV_MSR_TIME_REFCNT 0x0002 /* MSR_HV_TIME_REF_COUNT */ +#define CPUID_HV_MSR_SYNIC 0x0004 /* MSRs for SynIC */ +#define CPUID_HV_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */ +#define CPUID_HV_MSR_APIC 0x0010 /* MSR_HV_{EOI,ICR,TPR} */ +#define CPUID_HV_MSR_HYPERCALL 0x0020 /* MSR_HV_GUEST_OS_ID + * MSR_HV_HYPERCALL */ +#define CPUID_HV_MSR_VP_INDEX 0x0040 /* MSR_HV_VP_INDEX */ +#define CPUID_HV_MSR_GUEST_IDLE 0x0400 /* MSR_HV_GUEST_IDLE */ + +#ifndef NANOSEC +#define NANOSEC 1000000000ULL +#endif +#define HYPERV_TIMER_NS_FACTOR 100ULL +#define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) + struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -44,4 +61,6 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); +extern u_int hyperv_features; /* CPUID_HV_MSR_ */ + #endif /* _HYPERV_H_ */ Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Fri Dec 30 02:13:21 2016 (r310801) @@ -46,10 +46,14 @@ __FBSDID("$FreeBSD$"); #define VMBUS_TIMESYNC_FWVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_FWVER_MAJOR, 0) -#define VMBUS_TIMESYNC_MSGVER_MAJOR 3 +#define VMBUS_TIMESYNC_MSGVER_MAJOR 4 #define VMBUS_TIMESYNC_MSGVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_MSGVER_MAJOR, 0) +#define VMBUS_TIMESYNC_DORTT(sc) \ + ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ + (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) + static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { .ic_guid = { .hv_guid = { @@ -81,12 +85,16 @@ SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sam &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); static void -vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint8_t tsflags) +vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint64_t sent_tc, + uint8_t tsflags) { struct timespec vm_ts; - uint64_t hv_ns, vm_ns; + uint64_t hv_ns, vm_ns, rtt = 0; + + if (VMBUS_TIMESYNC_DORTT(sc)) + rtt = rdmsr(MSR_HV_TIME_REF_COUNT) - sent_tc; - hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE) * VMBUS_ICMSG_TS_FACTOR; + hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE + rtt) * HYPERV_TIMER_NS_FACTOR; nanotime(&vm_ts); vm_ns = (vm_ts.tv_sec * NANOSEC) + vm_ts.tv_nsec; @@ -174,6 +182,8 @@ vmbus_timesync_cb(struct vmbus_channel * VMBUS_TIMESYNC_FWVER, VMBUS_TIMESYNC_MSGVER); if (error) return; + if (VMBUS_TIMESYNC_DORTT(sc)) + device_printf(sc->ic_dev, "RTT\n"); break; case VMBUS_ICMSG_TYPE_TIMESYNC: @@ -183,7 +193,8 @@ vmbus_timesync_cb(struct vmbus_channel * return; } msg = data; - vmbus_timesync(sc, msg->ic_hvtime, msg->ic_tsflags); + vmbus_timesync(sc, msg->ic_hvtime, msg->ic_sent_tc, + msg->ic_tsflags); break; default: Modified: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Fri Dec 30 02:13:21 2016 (r310801) @@ -114,18 +114,13 @@ struct vmbus_icmsg_timesync { struct vmbus_icmsg_hdr ic_hdr; uint64_t ic_hvtime; uint64_t ic_vmtime; - uint64_t ic_rtt; + uint64_t ic_sent_tc; uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ } __packed; #define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 #define VMBUS_ICMSG_TS_FLAG_SAMPLE 0x02 -/* XXX consolidate w/ hyperv */ #define VMBUS_ICMSG_TS_BASE 116444736000000000ULL -#define VMBUS_ICMSG_TS_FACTOR 100ULL -#ifndef NANOSEC -#define NANOSEC 1000000000ULL -#endif #endif /* !_VMBUS_ICREG_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Dec 30 02:13:21 2016 (r310801) @@ -57,8 +57,6 @@ #define MSR_HV_VP_INDEX 0x40000002 -#define MSR_HV_TIME_REF_COUNT 0x40000020 - #define MSR_HV_SCONTROL 0x40000080 #define MSR_HV_SCTRL_ENABLE 0x0001ULL #define MSR_HV_SCTRL_RSVD_MASK 0xfffffffffffffffeULL @@ -106,15 +104,7 @@ #define CPUID_LEAF_HV_IDENTITY 0x40000002 #define CPUID_LEAF_HV_FEATURES 0x40000003 -/* EAX: features */ -#define CPUID_HV_MSR_TIME_REFCNT 0x0002 /* MSR_HV_TIME_REF_COUNT */ -#define CPUID_HV_MSR_SYNIC 0x0004 /* MSRs for SynIC */ -#define CPUID_HV_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */ -#define CPUID_HV_MSR_APIC 0x0010 /* MSR_HV_{EOI,ICR,TPR} */ -#define CPUID_HV_MSR_HYPERCALL 0x0020 /* MSR_HV_GUEST_OS_ID - * MSR_HV_HYPERCALL */ -#define CPUID_HV_MSR_VP_INDEX 0x0040 /* MSR_HV_VP_INDEX */ -#define CPUID_HV_MSR_GUEST_IDLE 0x0400 /* MSR_HV_GUEST_IDLE */ +/* EAX: features include/hyperv.h CPUID_HV_MSR */ /* ECX: power management features */ #define CPUPM_HV_CSTATE_MASK 0x000f /* deepest C-state */ #define CPUPM_HV_C3_HPET 0x0010 /* C3 requires HPET */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Fri Dec 30 02:13:21 2016 (r310801) @@ -31,13 +31,6 @@ #include -#ifndef NANOSEC -#define NANOSEC 1000000000ULL -#endif -#define HYPERV_TIMER_NS_FACTOR 100ULL -#define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) - -extern u_int hyperv_features; extern u_int hyperv_recommends; uint64_t hypercall_post_message(bus_addr_t msg_paddr); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_et.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Fri Dec 30 02:02:00 2016 (r310800) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Fri Dec 30 02:13:21 2016 (r310801) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include From owner-svn-src-stable-10@freebsd.org Fri Dec 30 02:18:36 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 6E7AFC97AFD; Fri, 30 Dec 2016 02:18:36 +0000 (UTC) (envelope-from sephe@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 2F13910D8; Fri, 30 Dec 2016 02:18:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBU2IZk4029473; Fri, 30 Dec 2016 02:18:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBU2IZBO029468; Fri, 30 Dec 2016 02:18:35 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612300218.uBU2IZBO029468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 30 Dec 2016 02:18:35 +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: r310802 - in stable/10/sys/dev/hyperv: include netvsc vmbus 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.23 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: Fri, 30 Dec 2016 02:18:36 -0000 Author: sephe Date: Fri Dec 30 02:18:34 2016 New Revision: 310802 URL: https://svnweb.freebsd.org/changeset/base/310802 Log: MFC 309874,309875 309874 hyperv/vmbus: Add channel polling support. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8738 309875 hyperv/hn: Add polling support Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8739 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Fri Dec 30 02:13:21 2016 (r310801) +++ stable/10/sys/dev/hyperv/include/vmbus.h Fri Dec 30 02:18:34 2016 (r310802) @@ -50,6 +50,9 @@ #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) +#define VMBUS_CHAN_POLLHZ_MIN 100 /* 10ms interval */ +#define VMBUS_CHAN_POLLHZ_MAX 1000000 /* 1us interval */ + /* * GPA stuffs. */ @@ -221,4 +224,8 @@ bool vmbus_chan_tx_empty(const struct v struct taskqueue * vmbus_chan_mgmt_tq(const struct vmbus_channel *chan); +void vmbus_chan_poll_enable(struct vmbus_channel *chan, + u_int pollhz); +void vmbus_chan_poll_disable(struct vmbus_channel *chan); + #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Dec 30 02:13:21 2016 (r310801) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Dec 30 02:18:34 2016 (r310802) @@ -286,6 +286,7 @@ static int hn_txagg_size_sysctl(SYSCTL static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_polling_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *); static void hn_init_locked(struct hn_softc *); @@ -312,6 +313,8 @@ static void hn_resume_mgmt(struct hn_s static void hn_suspend_mgmt_taskfunc(void *, int); static void hn_chan_drain(struct hn_softc *, struct vmbus_channel *); +static void hn_polling(struct hn_softc *, u_int); +static void hn_chan_polling(struct vmbus_channel *, u_int); static void hn_update_link_status(struct hn_softc *); static void hn_change_network(struct hn_softc *); @@ -1095,6 +1098,10 @@ hn_attach(device_t dev) hn_txagg_pkts_sysctl, "I", "Packet transmission aggregation packets, " "0 -- disable, -1 -- auto"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "polling", + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_polling_sysctl, "I", + "Polling frequency: [100,1000000], 0 disable polling"); /* * Setup the ifmedia, which has been initialized earlier. @@ -2347,6 +2354,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, break; } + /* Disable polling. */ + hn_polling(sc, 0); + /* * Suspend this interface before the synthetic parts * are ripped. @@ -2392,6 +2402,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, */ hn_resume(sc); + /* + * Re-enable polling if this interface is running and + * the polling is requested. + */ + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && sc->hn_pollhz > 0) + hn_polling(sc, sc->hn_pollhz); + HN_UNLOCK(sc); break; @@ -2518,6 +2535,9 @@ hn_stop(struct hn_softc *sc) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); + /* Disable polling. */ + hn_polling(sc, 0); + /* Clear RUNNING bit _before_ hn_suspend_data() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); hn_suspend_data(sc); @@ -2555,6 +2575,10 @@ hn_init_locked(struct hn_softc *sc) /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + + /* Re-enable polling if requested. */ + if (sc->hn_pollhz > 0) + hn_polling(sc, sc->hn_pollhz); } static void @@ -2862,6 +2886,61 @@ hn_txagg_align_sysctl(SYSCTL_HANDLER_ARG return (sysctl_handle_int(oidp, &align, 0, req)); } +static void +hn_chan_polling(struct vmbus_channel *chan, u_int pollhz) +{ + if (pollhz == 0) + vmbus_chan_poll_disable(chan); + else + vmbus_chan_poll_enable(chan, pollhz); +} + +static void +hn_polling(struct hn_softc *sc, u_int pollhz) +{ + int nsubch = sc->hn_rx_ring_inuse - 1; + + HN_LOCK_ASSERT(sc); + + if (nsubch > 0) { + struct vmbus_channel **subch; + int i; + + subch = vmbus_subchan_get(sc->hn_prichan, nsubch); + for (i = 0; i < nsubch; ++i) + hn_chan_polling(subch[i], pollhz); + vmbus_subchan_rel(subch, nsubch); + } + hn_chan_polling(sc->hn_prichan, pollhz); +} + +static int +hn_polling_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int pollhz, error; + + pollhz = sc->hn_pollhz; + error = sysctl_handle_int(oidp, &pollhz, 0, req); + if (error || req->newptr == NULL) + return (error); + + if (pollhz != 0 && + (pollhz < VMBUS_CHAN_POLLHZ_MIN || pollhz > VMBUS_CHAN_POLLHZ_MAX)) + return (EINVAL); + + HN_LOCK(sc); + if (sc->hn_pollhz != pollhz) { + sc->hn_pollhz = pollhz; + if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) && + (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED)) + hn_polling(sc, sc->hn_pollhz); + } + HN_UNLOCK(sc); + + return (0); +} + static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) { Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Dec 30 02:13:21 2016 (r310801) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Dec 30 02:18:34 2016 (r310802) @@ -213,6 +213,8 @@ struct hn_softc { uint32_t hn_caps; /* HN_CAP_ */ uint32_t hn_flags; /* HN_FLAG_ */ + u_int hn_pollhz; + void *hn_rxbuf; uint32_t hn_rxbuf_gpadl; struct hyperv_dma hn_rxbuf_dma; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Dec 30 02:13:21 2016 (r310801) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Dec 30 02:18:34 2016 (r310802) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -50,6 +51,11 @@ __FBSDID("$FreeBSD$"); #include #include +struct vmbus_chan_pollarg { + struct vmbus_channel *poll_chan; + u_int poll_hz; +}; + static void vmbus_chan_update_evtflagcnt( struct vmbus_softc *, const struct vmbus_channel *); @@ -68,6 +74,10 @@ static void vmbus_chan_clear_chmap(str static void vmbus_chan_detach(struct vmbus_channel *); static bool vmbus_chan_wait_revoke( const struct vmbus_channel *, bool); +static void vmbus_chan_poll_timeout(void *); +static bool vmbus_chan_poll_cancel_intq( + struct vmbus_channel *); +static void vmbus_chan_poll_cancel(struct vmbus_channel *); static void vmbus_chan_ins_prilist(struct vmbus_softc *, struct vmbus_channel *); @@ -84,7 +94,11 @@ static void vmbus_chan_rem_sublist(str static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_poll_task(void *, int); static void vmbus_chan_clrchmap_task(void *, int); +static void vmbus_chan_pollcfg_task(void *, int); +static void vmbus_chan_polldis_task(void *, int); +static void vmbus_chan_poll_cancel_task(void *, int); static void vmbus_prichan_attach_task(void *, int); static void vmbus_subchan_attach_task(void *, int); static void vmbus_prichan_detach_task(void *, int); @@ -782,6 +796,22 @@ vmbus_chan_set_chmap(struct vmbus_channe chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; } +static void +vmbus_chan_poll_cancel_task(void *xchan, int pending __unused) +{ + + vmbus_chan_poll_cancel_intq(xchan); +} + +static void +vmbus_chan_poll_cancel(struct vmbus_channel *chan) +{ + struct task poll_cancel; + + TASK_INIT(&poll_cancel, 0, vmbus_chan_poll_cancel_task, chan); + vmbus_chan_run_task(chan, &poll_cancel); +} + static int vmbus_chan_close_internal(struct vmbus_channel *chan) { @@ -818,6 +848,11 @@ vmbus_chan_close_internal(struct vmbus_c sysctl_ctx_free(&chan->ch_sysctl_ctx); /* + * Cancel polling, if it is enabled. + */ + vmbus_chan_poll_cancel(chan); + + /* * NOTE: * Order is critical. This channel _must_ be uninstalled first, * else the channel task may be enqueued by the IDT after it has @@ -1185,6 +1220,9 @@ vmbus_chan_task(void *xchan, int pending vmbus_chan_callback_t cb = chan->ch_cb; void *cbarg = chan->ch_cbarg; + KASSERT(chan->ch_poll_intvl == 0, + ("chan%u: interrupted in polling mode", chan->ch_id)); + /* * Optimize host to guest signaling by ensuring: * 1. While reading the channel, we disable interrupts from @@ -1216,9 +1254,145 @@ vmbus_chan_task_nobatch(void *xchan, int { struct vmbus_channel *chan = xchan; + KASSERT(chan->ch_poll_intvl == 0, + ("chan%u: interrupted in polling mode", chan->ch_id)); + chan->ch_cb(chan, chan->ch_cbarg); +} + +static void +vmbus_chan_poll_timeout(void *xchan) +{ + struct vmbus_channel *chan = xchan; + + KASSERT(chan->ch_poll_intvl != 0, + ("chan%u: polling timeout in interrupt mode", chan->ch_id)); + taskqueue_enqueue(chan->ch_tq, &chan->ch_poll_task); +} + +static void +vmbus_chan_poll_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + KASSERT(chan->ch_poll_intvl != 0, + ("chan%u: polling in interrupt mode", chan->ch_id)); + callout_reset_sbt_curcpu(&chan->ch_poll_timeo, chan->ch_poll_intvl, 0, + vmbus_chan_poll_timeout, chan, chan->ch_poll_flags); chan->ch_cb(chan, chan->ch_cbarg); } +static void +vmbus_chan_pollcfg_task(void *xarg, int pending __unused) +{ + const struct vmbus_chan_pollarg *arg = xarg; + struct vmbus_channel *chan = arg->poll_chan; + sbintime_t intvl; + int poll_flags; + + /* + * Save polling interval. + */ + intvl = SBT_1S / arg->poll_hz; + if (intvl == 0) + intvl = 1; + if (intvl == chan->ch_poll_intvl) { + /* Nothing changes; done */ + return; + } + chan->ch_poll_intvl = intvl; + + /* Adjust callout flags. */ + poll_flags = C_DIRECT_EXEC; + if (arg->poll_hz <= hz) + poll_flags |= C_HARDCLOCK; + chan->ch_poll_flags = poll_flags; + + /* + * Disable interrupt from the RX bufring (TX bufring does not + * generate interrupt to VM), and disconnect this channel from + * the channel map to make sure that ISR can not enqueue this + * channel task anymore. + */ + critical_enter(); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL; + critical_exit(); + + /* + * NOTE: + * At this point, this channel task will not be enqueued by + * the ISR anymore, time to cancel the pending one. + */ + taskqueue_cancel(chan->ch_tq, &chan->ch_task, NULL); + + /* Kick start! */ + taskqueue_enqueue(chan->ch_tq, &chan->ch_poll_task); +} + +static bool +vmbus_chan_poll_cancel_intq(struct vmbus_channel *chan) +{ + + if (chan->ch_poll_intvl == 0) { + /* Not enabled. */ + return (false); + } + + /* + * Stop polling callout, so that channel polling task + * will not be enqueued anymore. + */ + callout_drain(&chan->ch_poll_timeo); + + /* + * Disable polling by resetting polling interval. + * + * NOTE: + * The polling interval resetting MUST be conducted + * after the callout is drained; mainly to keep the + * proper assertion in place. + */ + chan->ch_poll_intvl = 0; + + /* + * NOTE: + * At this point, this channel polling task will not be + * enqueued by the callout anymore, time to cancel the + * pending one. + */ + taskqueue_cancel(chan->ch_tq, &chan->ch_poll_task, NULL); + + /* Polling was enabled. */ + return (true); +} + +static void +vmbus_chan_polldis_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + if (!vmbus_chan_poll_cancel_intq(chan)) { + /* Already disabled; done. */ + return; + } + + /* + * Plug this channel back to the channel map and unmask + * the RX bufring interrupt. + */ + critical_enter(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; + __compiler_membar(); + vmbus_rxbr_intr_unmask(&chan->ch_rxbr); + critical_exit(); + + /* + * Kick start the interrupt task, just in case unmasking + * interrupt races ISR. + */ + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); +} + static __inline void vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, int flag_cnt) @@ -1333,6 +1507,9 @@ vmbus_chan_alloc(struct vmbus_softc *sc) vmbus_rxbr_init(&chan->ch_rxbr); vmbus_txbr_init(&chan->ch_txbr); + TASK_INIT(&chan->ch_poll_task, 0, vmbus_chan_poll_task, chan); + callout_init(&chan->ch_poll_timeo, 1); + return chan; } @@ -1351,6 +1528,8 @@ vmbus_chan_free(struct vmbus_channel *ch ("still has orphan xact installed")); KASSERT(chan->ch_refs == 0, ("chan%u: invalid refcnt %d", chan->ch_id, chan->ch_refs)); + KASSERT(chan->ch_poll_intvl == 0, ("chan%u: polling is activated", + chan->ch_id)); hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); @@ -1998,3 +2177,32 @@ vmbus_chan_xact_wait(const struct vmbus_ } return (ret); } + +void +vmbus_chan_poll_enable(struct vmbus_channel *chan, u_int pollhz) +{ + struct vmbus_chan_pollarg arg; + struct task poll_cfg; + + KASSERT(chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD, + ("enable polling on non-batch chan%u", chan->ch_id)); + KASSERT(pollhz >= VMBUS_CHAN_POLLHZ_MIN && + pollhz <= VMBUS_CHAN_POLLHZ_MAX, ("invalid pollhz %u", pollhz)); + + arg.poll_chan = chan; + arg.poll_hz = pollhz; + TASK_INIT(&poll_cfg, 0, vmbus_chan_pollcfg_task, &arg); + vmbus_chan_run_task(chan, &poll_cfg); +} + +void +vmbus_chan_poll_disable(struct vmbus_channel *chan) +{ + struct task poll_dis; + + KASSERT(chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD, + ("disable polling on non-batch chan%u", chan->ch_id)); + + TASK_INIT(&poll_dis, 0, vmbus_chan_polldis_task, chan); + vmbus_chan_run_task(chan, &poll_dis); +} Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Fri Dec 30 02:13:21 2016 (r310801) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Fri Dec 30 02:18:34 2016 (r310802) @@ -30,6 +30,7 @@ #define _VMBUS_CHANVAR_H_ #include +#include #include #include #include @@ -49,6 +50,7 @@ struct vmbus_channel { * target CPU. */ uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ + int ch_poll_flags; /* callout flags */ /* * RX bufring; immediately following ch_txbr. @@ -57,6 +59,9 @@ struct vmbus_channel { struct taskqueue *ch_tq; struct task ch_task; + struct task ch_poll_task; + sbintime_t ch_poll_intvl; + struct callout ch_poll_timeo; vmbus_chan_callback_t ch_cb; void *ch_cbarg; From owner-svn-src-stable-10@freebsd.org Fri Dec 30 17:24:30 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 5A4FCC97594; Fri, 30 Dec 2016 17:24:30 +0000 (UTC) (envelope-from arybchik@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 0FA971829; Fri, 30 Dec 2016 17:24:29 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUHOTlg001259; Fri, 30 Dec 2016 17:24:29 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUHOT38001256; Fri, 30 Dec 2016 17:24:29 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301724.uBUHOT38001256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 17:24:29 +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: r310830 - stable/10/sys/dev/sfxge 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.23 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: Fri, 30 Dec 2016 17:24:30 -0000 Author: arybchik Date: Fri Dec 30 17:24:28 2016 New Revision: 310830 URL: https://svnweb.freebsd.org/changeset/base/310830 Log: MFC r310627 sfxge(4): do not limit driver RSS table to RSS channels max Specification of entire RSS table in the driver allows to spread traffic more equally across CPUs/RSS channels if number of RSS channels is not power of 2. Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/sfxge.h stable/10/sys/dev/sfxge/sfxge_rx.c stable/10/sys/dev/sfxge/sfxge_tx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/sfxge.h ============================================================================== --- stable/10/sys/dev/sfxge/sfxge.h Fri Dec 30 17:12:41 2016 (r310829) +++ stable/10/sys/dev/sfxge/sfxge.h Fri Dec 30 17:24:28 2016 (r310830) @@ -302,7 +302,7 @@ struct sfxge_softc { unsigned int max_rss_channels; uma_zone_t rxq_cache; struct sfxge_rxq *rxq[SFXGE_RX_SCALE_MAX]; - unsigned int rx_indir_table[SFXGE_RX_SCALE_MAX]; + unsigned int rx_indir_table[EFX_RSS_TBL_SIZE]; struct sfxge_txq *txq[SFXGE_TXQ_NTYPES + SFXGE_RX_SCALE_MAX]; Modified: stable/10/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_rx.c Fri Dec 30 17:12:41 2016 (r310829) +++ stable/10/sys/dev/sfxge/sfxge_rx.c Fri Dec 30 17:24:28 2016 (r310830) @@ -1128,10 +1128,10 @@ sfxge_rx_start(struct sfxge_softc *sc) /* * Set up the scale table. Enable all hash types and hash insertion. */ - for (index = 0; index < SFXGE_RX_SCALE_MAX; index++) + for (index = 0; index < nitems(sc->rx_indir_table); index++) sc->rx_indir_table[index] = index % sc->rxq_count; if ((rc = efx_rx_scale_tbl_set(sc->enp, sc->rx_indir_table, - SFXGE_RX_SCALE_MAX)) != 0) + nitems(sc->rx_indir_table))) != 0) goto fail; (void)efx_rx_scale_mode_set(sc->enp, EFX_RX_HASHALG_TOEPLITZ, (1 << EFX_RX_HASH_IPV4) | (1 << EFX_RX_HASH_TCPIPV4) | Modified: stable/10/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_tx.c Fri Dec 30 17:12:41 2016 (r310829) +++ stable/10/sys/dev/sfxge/sfxge_tx.c Fri Dec 30 17:24:28 2016 (r310830) @@ -820,8 +820,9 @@ sfxge_if_transmit(struct ifnet *ifp, str /* check if flowid is set */ if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { uint32_t hash = m->m_pkthdr.flowid; + uint32_t idx = hash % nitems(sc->rx_indir_table); - index = sc->rx_indir_table[hash % SFXGE_RX_SCALE_MAX]; + index = sc->rx_indir_table[idx]; } #if SFXGE_TX_PARSE_EARLY if (m->m_pkthdr.csum_flags & CSUM_TSO) From owner-svn-src-stable-10@freebsd.org Fri Dec 30 17:35: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 0CF7DC978A1; Fri, 30 Dec 2016 17:35:05 +0000 (UTC) (envelope-from arybchik@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 D00251F33; Fri, 30 Dec 2016 17:35:04 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUHZ4PZ005606; Fri, 30 Dec 2016 17:35:04 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUHZ4bG005605; Fri, 30 Dec 2016 17:35:04 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301735.uBUHZ4bG005605@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 17:35: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: r310832 - stable/10/sys/dev/sfxge/common 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.23 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: Fri, 30 Dec 2016 17:35:05 -0000 Author: arybchik Date: Fri Dec 30 17:35:03 2016 New Revision: 310832 URL: https://svnweb.freebsd.org/changeset/base/310832 Log: MFC r310677 sfxge(4): cleanup: fix typo in siena_mac_loopback_set() instrumentation Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/siena_mac.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/siena_mac.c ============================================================================== --- stable/10/sys/dev/sfxge/common/siena_mac.c Fri Dec 30 17:26:19 2016 (r310831) +++ stable/10/sys/dev/sfxge/common/siena_mac.c Fri Dec 30 17:35:03 2016 (r310832) @@ -223,7 +223,7 @@ siena_mac_loopback_set( return (0); fail1: - EFSYS_PROBE(fail2); + EFSYS_PROBE1(fail1, efx_rc_t, rc); epp->ep_loopback_type = old_loopback_type; epp->ep_loopback_link_mode = old_loopback_link_mode; From owner-svn-src-stable-10@freebsd.org Fri Dec 30 17:42: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 C9EDFC97E97; Fri, 30 Dec 2016 17:42:06 +0000 (UTC) (envelope-from arybchik@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 98E4D1A8E; Fri, 30 Dec 2016 17:42:06 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUHg57C009792; Fri, 30 Dec 2016 17:42:05 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUHg555009791; Fri, 30 Dec 2016 17:42:05 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301742.uBUHg555009791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 17:42: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: r310835 - stable/10/sys/dev/sfxge/common 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.23 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: Fri, 30 Dec 2016 17:42:06 -0000 Author: arybchik Date: Fri Dec 30 17:42:05 2016 New Revision: 310835 URL: https://svnweb.freebsd.org/changeset/base/310835 Log: MFC r310678 sfxge(4): cleanup: remove trailing whitespace Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_types.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_types.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_types.h Fri Dec 30 17:37:06 2016 (r310834) +++ stable/10/sys/dev/sfxge/common/efx_types.h Fri Dec 30 17:42:05 2016 (r310835) @@ -1310,7 +1310,7 @@ extern int fix_lint; /* * Set or clear a numbered bit within an octword. */ - + #define EFX_SHIFT64(_bit, _base) \ (((_bit) >= (_base) && (_bit) < (_base) + 64) ? \ ((uint64_t)1 << ((_bit) - (_base))) : \ From owner-svn-src-stable-10@freebsd.org Fri Dec 30 17:47:10 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 5248AC97036; Fri, 30 Dec 2016 17:47:10 +0000 (UTC) (envelope-from arybchik@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 0F54A1EDD; Fri, 30 Dec 2016 17:47:09 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUHl9Np010245; Fri, 30 Dec 2016 17:47:09 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUHl94w010244; Fri, 30 Dec 2016 17:47:09 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301747.uBUHl94w010244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 17:47:09 +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: r310837 - stable/10/sys/dev/sfxge/common 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.23 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: Fri, 30 Dec 2016 17:47:10 -0000 Author: arybchik Date: Fri Dec 30 17:47:09 2016 New Revision: 310837 URL: https://svnweb.freebsd.org/changeset/base/310837 Log: MFC r310679 sfxge(4): cleanup: fix wrong indent Found by DPDK checkpatch.sh Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_tx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_tx.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_tx.c Fri Dec 30 17:43:47 2016 (r310836) +++ stable/10/sys/dev/sfxge/common/efx_tx.c Fri Dec 30 17:47:09 2016 (r310837) @@ -329,7 +329,7 @@ efx_tx_qcreate( if ((rc = etxop->etxo_qcreate(enp, index, label, esmp, n, id, flags, eep, etp, addedp)) != 0) - goto fail2; + goto fail2; enp->en_tx_qcount++; *etpp = etp; From owner-svn-src-stable-10@freebsd.org Fri Dec 30 17:57: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 86BFDC974B0; Fri, 30 Dec 2016 17:57:15 +0000 (UTC) (envelope-from arybchik@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 5594F16CC; Fri, 30 Dec 2016 17:57:15 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUHvEBd014306; Fri, 30 Dec 2016 17:57:14 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUHvEBn014305; Fri, 30 Dec 2016 17:57:14 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301757.uBUHvEBn014305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 17:57: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: r310839 - stable/10/sys/dev/sfxge/common 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.23 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: Fri, 30 Dec 2016 17:57:15 -0000 Author: arybchik Date: Fri Dec 30 17:57:14 2016 New Revision: 310839 URL: https://svnweb.freebsd.org/changeset/base/310839 Log: MFC r310680 sfxge(4): cleanup: use spaces around binary arithmetic operations Found by DPDK checkpatch.sh Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_lic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_lic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_lic.c Fri Dec 30 17:50:02 2016 (r310838) +++ stable/10/sys/dev/sfxge/common/efx_lic.c Fri Dec 30 17:57:14 2016 (r310839) @@ -456,7 +456,7 @@ fail1: * Value (V): L bytes - payload */ #define EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX (256) -#define EFX_LICENSE_V1V2_HEADER_LENGTH (2*sizeof(uint16_t)) +#define EFX_LICENSE_V1V2_HEADER_LENGTH (2 * sizeof(uint16_t)) __checkReturn efx_rc_t efx_lic_v1v2_find_start( @@ -1082,9 +1082,10 @@ efx_mcdi_licensing_v3_get_id( } else { /* Shift ID down to start of buffer */ memmove(bufferp, - bufferp+MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST, - *lengthp); - memset(bufferp+(*lengthp), 0, MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST); + bufferp + MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST, + *lengthp); + memset(bufferp + (*lengthp), 0, + MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST); } return (0); From owner-svn-src-stable-10@freebsd.org Fri Dec 30 18:02:13 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 5595EC97699; Fri, 30 Dec 2016 18:02:13 +0000 (UTC) (envelope-from arybchik@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 247111E23; Fri, 30 Dec 2016 18:02:13 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUI2CtN018355; Fri, 30 Dec 2016 18:02:12 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUI2CaQ018353; Fri, 30 Dec 2016 18:02:12 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612301802.uBUI2CaQ018353@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Dec 2016 18:02:12 +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: r310842 - stable/10/sys/dev/sfxge/common 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.23 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: Fri, 30 Dec 2016 18:02:13 -0000 Author: arybchik Date: Fri Dec 30 18:02:12 2016 New Revision: 310842 URL: https://svnweb.freebsd.org/changeset/base/310842 Log: MFC r310681 sfxge(4): cleanup: remove unnecessary spaces Found by DPDK checkpatch.sh Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_impl.h stable/10/sys/dev/sfxge/common/efx_lic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_impl.h Fri Dec 30 18:01:04 2016 (r310841) +++ stable/10/sys/dev/sfxge/common/efx_impl.h Fri Dec 30 18:02:12 2016 (r310842) @@ -564,7 +564,7 @@ typedef struct efx_lic_ops_s { efx_rc_t (*elo_find_start) (efx_nic_t *, caddr_t, size_t, uint32_t *); efx_rc_t (*elo_find_end)(efx_nic_t *, caddr_t, size_t, - uint32_t , uint32_t *); + uint32_t, uint32_t *); boolean_t (*elo_find_key)(efx_nic_t *, caddr_t, size_t, uint32_t, uint32_t *, uint32_t *); boolean_t (*elo_validate_key)(efx_nic_t *, Modified: stable/10/sys/dev/sfxge/common/efx_lic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_lic.c Fri Dec 30 18:01:04 2016 (r310841) +++ stable/10/sys/dev/sfxge/common/efx_lic.c Fri Dec 30 18:02:12 2016 (r310842) @@ -627,7 +627,7 @@ efx_lic_v1v2_write_key( // Ensure space for terminator remains if ((offset + length) > - (buffer_size - EFX_LICENSE_V1V2_HEADER_LENGTH) ) { + (buffer_size - EFX_LICENSE_V1V2_HEADER_LENGTH)) { rc = ENOSPC; goto fail1; } From owner-svn-src-stable-10@freebsd.org Fri Dec 30 23:59: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 BD9D1C9898F; Fri, 30 Dec 2016 23:59:44 +0000 (UTC) (envelope-from ngie@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 980DE19CE; Fri, 30 Dec 2016 23:59:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUNxhsj068104; Fri, 30 Dec 2016 23:59:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUNxhwQ068103; Fri, 30 Dec 2016 23:59:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612302359.uBUNxhwQ068103@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 30 Dec 2016 23:59:43 +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: r310876 - stable/10/etc 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.23 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: Fri, 30 Dec 2016 23:59:44 -0000 Author: ngie Date: Fri Dec 30 23:59:43 2016 New Revision: 310876 URL: https://svnweb.freebsd.org/changeset/base/310876 Log: MFstable/11 r310875: MFC r310458,r310466: r310458: Group all loadable modules in the %default section This will allow new users to uncomment the modules and have things work with less head scratching, in the event they decide to uncomment any of the section separators, e.g. %usm or %vcm, as the module loading is only effective in the %default section. r310466: Don't hardcode $(securityModelUSM) (3) in the authPriv example under the %vacm section Modified: stable/10/etc/snmpd.config Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/snmpd.config ============================================================================== --- stable/10/etc/snmpd.config Fri Dec 30 23:52:19 2016 (r310875) +++ stable/10/etc/snmpd.config Fri Dec 30 23:59:43 2016 (r310876) @@ -112,12 +112,58 @@ sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1 snmpEnableAuthenTraps = 2 +# Uncomment `begemotSnmpdModulePath.".." = ".."' entries below to enable +# modules + +# +# Bridge module +# This requires the mibII module. +# +#begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so" + +# +# Host resources module +# This requires the mibII module. +# +#begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so" + +# +# MIB-2 module +# +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" + +# +# Netgraph module +# +#begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" + +# +# pf(4) module +# +#begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" + +# +# SNMPv3 Notification Targets +# +# begemotSnmpdModulePath."target" = "/usr/lib/snmp_target.so" + # # SNMPv3 User-based security module - must be loaded for SNMPv3 USM # #begemotSnmpdModulePath."usm" = "/usr/lib/snmp_usm.so" # +# SNMPv3 View-based Access Control module +# +#begemotSnmpdModulePath."vacm" = "/usr/lib/snmp_vacm.so" + +# +# Wireless module +# This requires the mibII module. +# +#begemotSnmpdModulePath."wlan" = "/usr/lib/snmp_wlan.so" + +# # SNMPv3 USM User definition. # @@ -147,11 +193,6 @@ snmpEnableAuthenTraps = 2 # # -# SNMPv3 View-based Access Control module -# -#begemotSnmpdModulePath."vacm" = "/usr/lib/snmp_vacm.so" - -# # Definition of view-based access control entries. # #%vacm @@ -210,15 +251,10 @@ snmpEnableAuthenTraps = 2 # #Read-write-notify access to restricted for SNMPv3 USM users with authPriv # -# vacmAccessStatus.$(write)."".3.$(authPriv) = 4 -# vacmAccessReadViewName.$(write)."".3.$(authPriv) = "restricted" -# vacmAccessWriteViewName.$(write)."".3.$(authPriv) = "restricted" -# vacmAccessNotifyViewName.$(write)."".3.$(authPriv) = "restricted" - -# -# SNMPv3 Notification Targets -# -# begemotSnmpdModulePath."target" = "/usr/lib/snmp_target.so" +# vacmAccessStatus.$(write)."".$(securityModelUSM).$(authPriv) = 4 +# vacmAccessReadViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" +# vacmAccessWriteViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" +# vacmAccessNotifyViewName.$(write)."".$(securityModelUSM).$(authPriv) = "restricted" #%target # Send notifications to target tag "test" @@ -259,44 +295,11 @@ snmpEnableAuthenTraps = 2 # snmpTargetAddrParams.$(tagremote) = $(tag) # snmpTargetAddrRowStatus.$(tagremote) = 1 -# -# Load MIB-2 module -# -begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" - # Force a polling rate for the 64-bit interface counters in case # the automatic computation is wrong (which may be the case if an interface # announces the wrong bit rate via its MIB). #%mibII #begemotIfForcePoll = 2000 - -# Netgraph module -# -#begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" -# #%netgraph #begemotNgControlNodeName = "snmpd" - -# -# pf(4) module -# -#begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" - -# -# Host resources module -# This requires the mibII module. -# -#begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so" - -# -# Bridge module -# This requires the mibII module. -# -#begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so" - -# -# Wireless module -# This requires the mibII module. -# -#begemotSnmpdModulePath."wlan" = "/usr/lib/snmp_wlan.so" From owner-svn-src-stable-10@freebsd.org Sat Dec 31 00:01:23 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 0FD71C98B41; Sat, 31 Dec 2016 00:01:23 +0000 (UTC) (envelope-from ngie@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 D34071D96; Sat, 31 Dec 2016 00:01:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBV01MTX069053; Sat, 31 Dec 2016 00:01:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBV01MTx069052; Sat, 31 Dec 2016 00:01:22 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612310001.uBV01MTx069052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 00:01:22 +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: r310878 - stable/10/contrib/bsnmp/snmpd 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.23 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, 31 Dec 2016 00:01:23 -0000 Author: ngie Date: Sat Dec 31 00:01:21 2016 New Revision: 310878 URL: https://svnweb.freebsd.org/changeset/base/310878 Log: MFstable/11 r310877: MFC r310455: Clarify failure in snmp_output(..) with call to snmp_pdu_decode - Explicitly test snmp_pdu_encode against SNMP_CODE_OK instead of assuming any non-zero value is bad. - Print out the code before calling abort() to give the end-user something actionable to debug without having to recompile the binary, since the core might not have these details. Modified: stable/10/contrib/bsnmp/snmpd/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/main.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/main.c Sat Dec 31 00:00:12 2016 (r310877) +++ stable/10/contrib/bsnmp/snmpd/main.c Sat Dec 31 00:01:21 2016 (r310878) @@ -282,12 +282,13 @@ snmp_output(struct snmp_pdu *pdu, u_char const char *dest) { struct asn_buf resp_b; + enum snmp_code code; resp_b.asn_ptr = sndbuf; resp_b.asn_len = snmpd.txbuf; - if (snmp_pdu_encode(pdu, &resp_b) != 0) { - syslog(LOG_ERR, "cannot encode message"); + if ((code = snmp_pdu_encode(pdu, &resp_b)) != SNMP_CODE_OK) { + syslog(LOG_ERR, "cannot encode message (code=%d)", code); abort(); } if (debug.dump_pdus) { From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:30:58 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 2BEF6C96A76; Sat, 31 Dec 2016 10:30:58 +0000 (UTC) (envelope-from ngie@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 E13231E55; Sat, 31 Dec 2016 10:30:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAUvCd023865; Sat, 31 Dec 2016 10:30:57 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAUuCx023856; Sat, 31 Dec 2016 10:30:56 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311030.uBVAUuCx023856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:30: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: r310900 - stable/10/usr.sbin/bsnmpd/modules/snmp_hostres 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.23 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, 31 Dec 2016 10:30:58 -0000 Author: ngie Date: Sat Dec 31 10:30:56 2016 New Revision: 310900 URL: https://svnweb.freebsd.org/changeset/base/310900 Log: MFstable/11 r310899: MFC r310666,r310675: r310666: style(9) fixes - Clean up trailing whitespace - Fix variable type alignment in storage_OS_get_swap(..) r310675: Fix the build by moving the initializers for len/nswapdev down below the declarations Pointyhat to: ngie Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c Sat Dec 31 10:30:56 2016 (r310900) @@ -123,7 +123,7 @@ device_entry_create(const char *name, co if (map == NULL) { /* new object - get a new index */ if (next_device_index > INT_MAX) { - syslog(LOG_ERR, + syslog(LOG_ERR, "%s: hrDeviceTable index wrap", __func__); /* There isn't much we can do here. * If the next_swins_index is consumed Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c Sat Dec 31 10:30:56 2016 (r310900) @@ -131,7 +131,7 @@ static const struct { const struct asn_oid *oid; /* the OID to return */ } fs_type_map[] = { { "ufs", &OIDX_hrFSBerkeleyFFS_c }, - { "zfs", &OIDX_hrFSOther_c }, + { "zfs", &OIDX_hrFSOther_c }, { "cd9660", &OIDX_hrFSiso9660_c }, { "nfs", &OIDX_hrFSNFS_c }, { "ext2fs", &OIDX_hrFSLinuxExt2_c }, @@ -167,7 +167,7 @@ fs_entry_create(const char *name) /* new object - get a new index */ if (next_fs_index > INT_MAX) { /* Unrecoverable error - die clean and quicly*/ - syslog(LOG_ERR, "%s: hrFSTable index wrap", __func__); + syslog(LOG_ERR, "%s: hrFSTable index wrap", __func__); errx(EX_SOFTWARE, "hrFSTable index wrap"); } Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c Sat Dec 31 10:30:56 2016 (r310900) @@ -177,7 +177,7 @@ partition_entry_create(int32_t ds_index, if (next_partition_index > INT_MAX) { /* Unrecoverable error - die clean and quicly*/ - syslog(LOG_ERR, "%s: hrPartitionTable index wrap", + syslog(LOG_ERR, "%s: hrPartitionTable index wrap", __func__); errx(EX_SOFTWARE, "hrPartitionTable index wrap"); } Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c Sat Dec 31 10:30:56 2016 (r310900) @@ -193,7 +193,7 @@ OS_getSystemInitialLoadParameters(u_char syslog(LOG_ERR, "malloc failed"); return (SNMP_ERR_GENERR); } - if (sysctl(mib, 2, buf, &buf_len, NULL, 0)) { + if (sysctl(mib, 2, buf, &buf_len, NULL, 0)) { syslog(LOG_ERR, "sysctl({CTL_KERN,KERN_BOOTFILE}) failed: %m"); free(buf); @@ -296,7 +296,7 @@ OS_getMemorySize(uint32_t *ms) *ms = UINT32_MAX; else *ms = phys_mem_size; - return (SNMP_ERR_NOERROR); + return (SNMP_ERR_NOERROR); } /* @@ -360,7 +360,7 @@ OS_setSystemDate(const struct timeval *t if (settimeofday(timeval_to_set, NULL) == -1) { syslog(LOG_ERR, "settimeofday failed: %m"); return (SNMP_ERR_GENERR); - } + } return (SNMP_ERR_NOERROR); } @@ -378,7 +378,7 @@ op_hrSystem(struct snmp_context *ctx, st switch (curr_op) { - case SNMP_OP_GET: + case SNMP_OP_GET: switch (value->var.subs[sub - 1]) { case LEAF_hrSystemUptime: Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c Sat Dec 31 10:30:56 2016 (r310900) @@ -163,7 +163,7 @@ hostres_start(void) start_processor_tbl(hostres_module); start_network_tbl(); - HRDBG("done."); + HRDBG("done."); } /* this identifies the HOST RESOURCES mib module */ @@ -175,8 +175,8 @@ const struct snmp_module config = { NULL, NULL, hostres_start, - NULL, /* proxy a PDU */ - hostres_ctree, /* see the generated hostres_tree.h */ + NULL, /* proxy a PDU */ + hostres_ctree, /* see the generated hostres_tree.h */ hostres_CTREE_SIZE, /* see the generated hostres_tree.h */ NULL }; Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Sat Dec 31 10:30:56 2016 (r310900) @@ -153,7 +153,7 @@ storage_entry_create(const char *name) if (map == NULL) { /* new object - get a new index */ if (next_storage_index > INT_MAX) { - syslog(LOG_ERR, + syslog(LOG_ERR, "%s: hrStorageTable index wrap", __func__); errx(EX_SOFTWARE, "hrStorageTable index wrap"); } @@ -188,7 +188,7 @@ storage_entry_create(const char *name) syslog(LOG_WARNING, "%s: %m", __func__); return (NULL); } - memset(entry, 0, sizeof(*entry)); + memset(entry, 0, sizeof(*entry)); entry->index = map->hrIndex; @@ -374,10 +374,13 @@ storage_OS_get_memstat(void) static void storage_OS_get_swap(void) { - int nswapdev = 0; - size_t len = sizeof(nswapdev); struct storage_entry *entry; char swap_w_prefix[SE_DESC_MLEN]; + size_t len; + int nswapdev; + + len = sizeof(nswapdev); + nswapdev = 0; if (sysctlbyname("vm.nswapdev", &nswapdev, &len, NULL,0 ) < 0) { syslog(LOG_ERR, Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c Sat Dec 31 10:28:59 2016 (r310899) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c Sat Dec 31 10:30:56 2016 (r310900) @@ -50,7 +50,7 @@ #include "hostres_oid.h" #include "hostres_tree.h" -#define CONTENTS_FNAME "+CONTENTS" +#define CONTENTS_FNAME "+CONTENTS" enum SWInstalledType { SWI_UNKNOWN = 1, @@ -136,7 +136,7 @@ swins_entry_create(const char *name) size_t name_len; /* new object - get a new index */ if (next_swins_index > INT_MAX) { - syslog(LOG_ERR, "%s: hrSWInstalledTable index wrap", + syslog(LOG_ERR, "%s: hrSWInstalledTable index wrap", __func__ ); /* There isn't much we can do here. * If the next_swins_index is consumed @@ -292,7 +292,7 @@ swins_get_packages(void) struct stat sb; DIR *p_dir; struct dirent *ent; - struct tm k_ts; + struct tm k_ts; char *pkg_file; struct swins_entry *entry; int ret = 0; @@ -327,7 +327,7 @@ swins_get_packages(void) return (-1); } - while (errno = 0, (ent = readdir(p_dir)) != NULL) { + while (errno = 0, (ent = readdir(p_dir)) != NULL) { HRDBG(" pkg file: %s", ent->d_name); /* check that the contents file is a regular file */ @@ -371,7 +371,7 @@ swins_get_packages(void) entry->type = (int32_t)SWI_APPLICATION; entry->date_len = make_date_time(entry->date, &k_ts, 0); - } + } if (errno != 0) { syslog(LOG_ERR, "hrSWInstalledTable: readdir_r(\"%s\") failed:" From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:34:14 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 45612C96D40; Sat, 31 Dec 2016 10:34:14 +0000 (UTC) (envelope-from ngie@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 EF980139F; Sat, 31 Dec 2016 10:34:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAYDE5027739; Sat, 31 Dec 2016 10:34:13 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAY9bi027699; Sat, 31 Dec 2016 10:34:09 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311034.uBVAY9bi027699@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:34:09 +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: r310903 - in stable/10: contrib/bsnmp/gensnmpdef contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmp_ntp contrib/bsnmp/snmp_target contrib/bsnmp/snmp... 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.23 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, 31 Dec 2016 10:34:14 -0000 Author: ngie Date: Sat Dec 31 10:34:09 2016 New Revision: 310903 URL: https://svnweb.freebsd.org/changeset/base/310903 Log: MFstable/11 r310901: MFC r310648: style(9): clean up trailing whitespace Modified: stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.1 stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c stable/10/contrib/bsnmp/gensnmptree/gensnmptree.1 stable/10/contrib/bsnmp/gensnmptree/gensnmptree.c stable/10/contrib/bsnmp/lib/asn1.3 stable/10/contrib/bsnmp/lib/asn1.c stable/10/contrib/bsnmp/lib/asn1.h stable/10/contrib/bsnmp/lib/bsnmpagent.3 stable/10/contrib/bsnmp/lib/bsnmpclient.3 stable/10/contrib/bsnmp/lib/bsnmplib.3 stable/10/contrib/bsnmp/lib/snmp.c stable/10/contrib/bsnmp/lib/snmp.h stable/10/contrib/bsnmp/lib/snmpagent.c stable/10/contrib/bsnmp/lib/snmpagent.h stable/10/contrib/bsnmp/lib/snmpclient.c stable/10/contrib/bsnmp/lib/snmpclient.h stable/10/contrib/bsnmp/lib/snmpcrypto.c stable/10/contrib/bsnmp/lib/snmppriv.h stable/10/contrib/bsnmp/lib/support.c stable/10/contrib/bsnmp/lib/support.h stable/10/contrib/bsnmp/snmp_mibII/mibII.c stable/10/contrib/bsnmp/snmp_mibII/mibII.h stable/10/contrib/bsnmp/snmp_mibII/mibII_begemot.c stable/10/contrib/bsnmp/snmp_mibII/mibII_ifmib.c stable/10/contrib/bsnmp/snmp_mibII/mibII_ifstack.c stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c stable/10/contrib/bsnmp/snmp_mibII/mibII_ip.c stable/10/contrib/bsnmp/snmp_mibII/mibII_ipaddr.c stable/10/contrib/bsnmp/snmp_mibII/mibII_nettomedia.c stable/10/contrib/bsnmp/snmp_mibII/mibII_rcvaddr.c stable/10/contrib/bsnmp/snmp_mibII/mibII_route.c stable/10/contrib/bsnmp/snmp_mibII/mibII_tcp.c stable/10/contrib/bsnmp/snmp_mibII/mibII_tree.def stable/10/contrib/bsnmp/snmp_mibII/mibII_udp.c stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.h stable/10/contrib/bsnmp/snmp_ntp/NTP-MIB.txt stable/10/contrib/bsnmp/snmp_ntp/NTP-PROXY-MIB.txt stable/10/contrib/bsnmp/snmp_target/snmp_target.3 stable/10/contrib/bsnmp/snmp_usm/snmp_usm.3 stable/10/contrib/bsnmp/snmp_usm/usm_snmp.c stable/10/contrib/bsnmp/snmp_vacm/snmp_vacm.3 stable/10/contrib/bsnmp/snmp_vacm/vacm_snmp.c stable/10/contrib/bsnmp/snmpd/BEGEMOT-MIB.txt stable/10/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt stable/10/contrib/bsnmp/snmpd/FOKUS-MIB.txt stable/10/contrib/bsnmp/snmpd/action.c stable/10/contrib/bsnmp/snmpd/config.c stable/10/contrib/bsnmp/snmpd/export.c stable/10/contrib/bsnmp/snmpd/main.c stable/10/contrib/bsnmp/snmpd/snmpd.config stable/10/contrib/bsnmp/snmpd/snmpd.h stable/10/contrib/bsnmp/snmpd/snmpd.sh stable/10/contrib/bsnmp/snmpd/snmpmod.3 stable/10/contrib/bsnmp/snmpd/snmpmod.h stable/10/contrib/bsnmp/snmpd/trans_lsock.c stable/10/contrib/bsnmp/snmpd/trans_lsock.h stable/10/contrib/bsnmp/snmpd/trans_udp.c stable/10/contrib/bsnmp/snmpd/trans_udp.h stable/10/contrib/bsnmp/snmpd/trap.c stable/10/contrib/bsnmp/snmpd/tree.def stable/10/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt stable/10/usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.3 stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3 stable/10/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c stable/10/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt stable/10/usr.sbin/bsnmpd/modules/snmp_pf/Makefile stable/10/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c stable/10/usr.sbin/bsnmpd/modules/snmp_target/Makefile stable/10/usr.sbin/bsnmpd/modules/snmp_usm/Makefile stable/10/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile stable/10/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c stable/10/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h stable/10/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.1 ============================================================================== --- stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.1 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.1 Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -13,7 +13,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c ============================================================================== --- stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Dec 31 10:34:09 2016 (r310903) @@ -1,10 +1,10 @@ -/* +/* * Copyright (C) 2004-2006 * Hartmut Brandt. * All rights reserved. - * + * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 @@ -233,7 +233,7 @@ print_scalar(SmiNode *n, u_int level) printf(" op_%s", p->name); print_access(n->access); - + printf(")\n"); } @@ -422,7 +422,7 @@ static void print_enum_typedef(SmiType *t) { SmiNamedNumber *nnum; - + for (nnum = smiGetFirstNamedNumber(t); nnum != NULL; nnum = smiGetNextNamedNumber(nnum)) { printf("\t%ld %s\n" , nnum->value.value.integer32, nnum->name); @@ -434,10 +434,10 @@ print_stype(SmiNode *n) { SmiType *type; struct tdef *t = NULL; - + type = smiGetNodeType(n); assert(type != NULL); - + if (type->basetype == SMI_BASETYPE_ENUM) { if (do_typedef == 'e' && type->name != NULL) { SLIST_FOREACH(t, &tdefs, link) { @@ -450,7 +450,7 @@ print_stype(SmiNode *n) printf("typedef %sType ENUM (\n", n->name); else return; - + print_enum_typedef(type); printf(")\n\n"); @@ -476,7 +476,7 @@ static void print_typdefs(SmiNode *n) { SmiNode *p; - + p = n; n = smiGetFirstChildNode(n); while (n != NULL) { Modified: stable/10/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- stable/10/contrib/bsnmp/gensnmptree/gensnmptree.1 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/gensnmptree/gensnmptree.1 Sat Dec 31 10:34:09 2016 (r310903) @@ -7,7 +7,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- stable/10/contrib/bsnmp/gensnmptree/gensnmptree.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/gensnmptree/gensnmptree.c Sat Dec 31 10:34:09 2016 (r310903) @@ -8,7 +8,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -17,7 +17,7 @@ * 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 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 @@ -738,7 +738,7 @@ parse_type(enum tok *tok, struct type *t e->value = -(long)val; } else e->value = val; - + if (*tok != TOK_NUM) report("need value for ENUM/BITS"); if (gettoken() != TOK_STR) Modified: stable/10/contrib/bsnmp/lib/asn1.3 ============================================================================== --- stable/10/contrib/bsnmp/lib/asn1.3 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/asn1.3 Sat Dec 31 10:34:09 2016 (r310903) @@ -5,9 +5,9 @@ .\" Copyright (c) 2001-2003 .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). .\" All rights reserved. -.\" +.\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/lib/asn1.c ============================================================================== --- stable/10/contrib/bsnmp/lib/asn1.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/asn1.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 @@ -285,7 +285,7 @@ asn_put_real_integer(struct asn_buf *b, enum asn_err ret; if (ival < 0) { - /* this may fail if |INT64_MIN| > |INT64_MAX| and + /* this may fail if |INT64_MIN| > |INT64_MAX| and * the value is between * INT64_MIN <= ival < -(INT64_MAX+1) */ val = (uint64_t)-(ival + 1); neg = 1; @@ -890,7 +890,7 @@ asn_slice_oid(struct asn_oid *dest, cons memcpy(dest->subs, &src->subs[from], dest->len * sizeof(dest->subs[0])); } -/* +/* * Append from to to */ void Modified: stable/10/contrib/bsnmp/lib/asn1.h ============================================================================== --- stable/10/contrib/bsnmp/lib/asn1.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/asn1.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/lib/bsnmpagent.3 ============================================================================== --- stable/10/contrib/bsnmp/lib/bsnmpagent.3 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/bsnmpagent.3 Sat Dec 31 10:34:09 2016 (r310903) @@ -7,7 +7,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/lib/bsnmpclient.3 ============================================================================== --- stable/10/contrib/bsnmp/lib/bsnmpclient.3 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/bsnmpclient.3 Sat Dec 31 10:34:09 2016 (r310903) @@ -7,7 +7,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/lib/bsnmplib.3 ============================================================================== --- stable/10/contrib/bsnmp/lib/bsnmplib.3 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/bsnmplib.3 Sat Dec 31 10:34:09 2016 (r310903) @@ -13,7 +13,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -22,7 +22,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/lib/snmp.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmp.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmp.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. * @@ -19,7 +19,7 @@ * 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 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 @@ -682,7 +682,7 @@ snmp_pdu_snoop(const struct asn_buf *b0) struct asn_buf b = *b0; /* <0x10|0x20> */ - + if (b.asn_len == 0) return (0); if (b.asn_cptr[0] != (ASN_TYPE_SEQUENCE | ASN_TYPE_CONSTRUCTED)) { @@ -757,7 +757,7 @@ snmp_pdu_encode_header(struct asn_buf *b if (asn_put_temp_header(b, (ASN_TYPE_SEQUENCE | ASN_TYPE_CONSTRUCTED), &v3_hdr_ptr) != ASN_ERR_OK) return (SNMP_CODE_FAILED); - + if (asn_put_integer(b, pdu->identifier) != ASN_ERR_OK) return (SNMP_CODE_FAILED); Modified: stable/10/contrib/bsnmp/lib/snmp.h ============================================================================== --- stable/10/contrib/bsnmp/lib/snmp.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmp.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,14 +4,14 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Copyright (c) 2010 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by Shteryana Sotirova Shopova * under sponsorship from the FreeBSD Foundation. * - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -20,7 +20,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/lib/snmpagent.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpagent.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmpagent.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 @@ -515,7 +515,7 @@ snmp_getbulk(struct snmp_pdu *pdu, struc /* PDU is full */ goto done; - if (cnt == 0) + if (cnt == 0) result = do_getnext(&context, &pdu->bindings[i], &resp->bindings[resp->nbindings], pdu); else @@ -689,7 +689,7 @@ snmp_set(struct snmp_pdu *pdu, struct as if (snmp_pdu_encode_header(resp_b, resp)) return (SNMP_RET_IGN); - /* + /* * 1. Find all nodes, check that they are writeable and * that the syntax is ok, copy over the binding to the response. */ @@ -967,7 +967,7 @@ snmp_dep_lookup(struct snmp_context *ctx /* * Make an error response from a PDU. We do this without decoding the * variable bindings. This means we can sent the junk back to a caller - * that has sent us junk in the first place. + * that has sent us junk in the first place. */ enum snmp_ret snmp_make_errresp(const struct snmp_pdu *pdu, struct asn_buf *pdu_b, Modified: stable/10/contrib/bsnmp/lib/snmpagent.h ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpagent.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmpagent.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 10:34:09 2016 (r310903) @@ -68,7 +68,7 @@ struct snmp_client snmp_client; /* List of all outstanding requests */ -struct sent_pdu { +struct sent_pdu { int reqid; struct snmp_pdu *pdu; struct timeval time; @@ -510,7 +510,7 @@ table_check_response(struct tabwork *wor table_free(work, 1); return (-2); } - + continue; } if (!asn_is_suboid(&work->descr->table, &b->var) || @@ -754,7 +754,7 @@ snmp_oid_append(struct asn_oid *oid, con ret = 0; while (*fmt != '\0') { switch (*fmt++) { - case 'i': + case 'i': /* just an integer more */ if (oid->len + 1 > ASN_MAXOIDLEN) { warnx("%s: OID too long for integer", __func__); @@ -804,7 +804,7 @@ snmp_oid_append(struct asn_oid *oid, con break; case 'b': - /* append `size` characters */ + /* append `size` characters */ str = (const u_char *)va_arg(va, const char *); if (oid->len + size > ASN_MAXOIDLEN) { warnx("%s: OID too long for string", __func__); @@ -852,7 +852,7 @@ snmp_client_init(struct snmp_client *c) strcpy(c->read_community, "public"); strcpy(c->write_community, "private"); - + c->security_model = SNMP_SECMODEL_USM; strcpy(c->cname, ""); @@ -863,7 +863,7 @@ snmp_client_init(struct snmp_client *c) c->txbuflen = c->rxbuflen = 10000; c->fd = -1; - + c->max_reqid = INT32_MAX; c->min_reqid = 0; c->next_reqid = 0; Modified: stable/10/contrib/bsnmp/lib/snmpclient.h ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpclient.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmpclient.h Sat Dec 31 10:34:09 2016 (r310903) @@ -5,7 +5,7 @@ * * Author: Harti Brandt * Kendy Kutzner - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -14,7 +14,7 @@ * 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 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 @@ -59,7 +59,7 @@ typedef void (*snmp_send_cb_f)(struct sn typedef void (*snmp_timeout_cb_f)(void * ); /* timeout start function */ -typedef void *(*snmp_timeout_start_f)(struct timeval *timeout, +typedef void *(*snmp_timeout_start_f)(struct timeval *timeout, snmp_timeout_cb_f callback, void *); /* timeout stop function */ Modified: stable/10/contrib/bsnmp/lib/snmpcrypto.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpcrypto.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmpcrypto.c Sat Dec 31 10:34:09 2016 (r310903) @@ -322,7 +322,7 @@ snmp_calc_keychange(struct snmp_user *us for (i = 0; i < keylen / 4; i++) rvalue[i] = random(); - + memcpy(keychange, user->auth_key, keylen); memcpy(keychange + keylen, rvalue, keylen); Modified: stable/10/contrib/bsnmp/lib/snmppriv.h ============================================================================== --- stable/10/contrib/bsnmp/lib/snmppriv.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/snmppriv.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/lib/support.c ============================================================================== --- stable/10/contrib/bsnmp/lib/support.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/support.c Sat Dec 31 10:34:09 2016 (r310903) @@ -1,10 +1,10 @@ -/* +/* * Copyright (C) 2004 * Hartmut Brandt. * All rights reserved. - * + * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/lib/support.h ============================================================================== --- stable/10/contrib/bsnmp/lib/support.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/lib/support.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 @@ -1228,7 +1228,7 @@ mib_fetch_rtab(int af, int info, int arg return (NULL); } buf = newbuf; - + if (sysctl(name, 6, buf, lenp, NULL, 0) == 0) break; @@ -1329,7 +1329,7 @@ mib_arp_update(void) in_update_arp = 0; return; } - + next = buf; while (next < buf + needed) { rtm = (struct rt_msghdr *)(void *)next; @@ -1521,7 +1521,7 @@ mib_unmodify_ifa(struct mibifa *ifa) } /* - * Modify an IFA. + * Modify an IFA. */ int mib_modify_ifa(struct mibifa *ifa) Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII.h ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_begemot.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_begemot.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_begemot.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_ifmib.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_ifmib.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_ifmib.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_ifstack.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_ifstack.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_ifstack.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_ip.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_ip.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_ip.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_ipaddr.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_ipaddr.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_ipaddr.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_nettomedia.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_nettomedia.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_nettomedia.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_rcvaddr.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_rcvaddr.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_rcvaddr.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_route.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_route.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_route.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 @@ -257,7 +257,7 @@ mib_fetch_route(void) continue; mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs); - + mib_sroute_process(rtm, addrs[RTAX_GATEWAY], addrs[RTAX_DST], addrs[RTAX_NETMASK]); } Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_tcp.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_tcp.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_tcp.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_tree.def ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_tree.def Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_tree.def Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ # All rights reserved. # # Author: Harti Brandt -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: @@ -13,7 +13,7 @@ # 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_udp.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/mibII_udp.c Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/mibII_udp.c Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Sat Dec 31 10:34:09 2016 (r310903) @@ -7,7 +7,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 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 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 Modified: stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.h ============================================================================== --- stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.h Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.h Sat Dec 31 10:34:09 2016 (r310903) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Harti Brandt - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 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 Modified: stable/10/contrib/bsnmp/snmp_ntp/NTP-MIB.txt ============================================================================== --- stable/10/contrib/bsnmp/snmp_ntp/NTP-MIB.txt Sat Dec 31 10:34:04 2016 (r310902) +++ stable/10/contrib/bsnmp/snmp_ntp/NTP-MIB.txt Sat Dec 31 10:34:09 2016 (r310903) @@ -5,7 +5,7 @@ NTP-MIB DEFINITIONS ::= BEGIN IMPORTS - Integer32, IpAddress, MODULE-IDENTITY, OBJECT-TYPE, Unsigned32, + Integer32, IpAddress, MODULE-IDENTITY, OBJECT-TYPE, Unsigned32, enterprises FROM SNMPv2-SMI @@ -14,9 +14,9 @@ IMPORTS ntpMIB MODULE-IDENTITY LAST-UPDATED "199707251530Z" - ORGANIZATION + ORGANIZATION "University of Delaware" - CONTACT-INFO + CONTACT-INFO "Adarsh Sethi Department of Computer & Information Sciences University of Delaware @@ -30,7 +30,7 @@ ntpMIB MODULE-IDENTITY Newark, DE 19716 Tel: +1 302 831 ???? E-mail: mills@ee.udel.edu" - DESCRIPTION + DESCRIPTION "This MIB module defines a MIB which provides mechanisms to monitor and control an NTP server." ::= { udel 3 } @@ -60,18 +60,18 @@ ntpFilter OBJECT IDENTIFIER NTPTimeStamp ::= TEXTUAL-CONVENTION DISPLAY-HINT "4x.4x" STATUS current - DESCRIPTION + DESCRIPTION "" SYNTAX OCTET STRING (SIZE(8)) NTPLeapIndicator ::= TEXTUAL-CONVENTION STATUS current - DESCRIPTION + DESCRIPTION "" SYNTAX INTEGER { noWarning(0), addSecond(1), - subtractSecond(2), + subtractSecond(2), alarm(3) } -- @@ -82,7 +82,7 @@ ntpSysLeap OBJECT-TYPE SYNTAX NTPLeapIndicator MAX-ACCESS read-only STATUS current - DESCRIPTION + DESCRIPTION " two-bit code warning of an impending leap second to be inserted in the NTP timescale." ::= { ntpSystem 1 } @@ -91,7 +91,7 @@ ntpSysStratum OBJECT-TYPE SYNTAX Integer32 (0..255) MAX-ACCESS read-only *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:37:52 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 3ECB8C96F21; Sat, 31 Dec 2016 10:37:52 +0000 (UTC) (envelope-from ngie@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 0B5D418E6; Sat, 31 Dec 2016 10:37:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAbpXj028096; Sat, 31 Dec 2016 10:37:51 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAbp3T028095; Sat, 31 Dec 2016 10:37:51 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311037.uBVAbp3T028095@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:37:51 +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: r310906 - stable/10/contrib/bsnmp/snmpd 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.23 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, 31 Dec 2016 10:37:52 -0000 Author: ngie Date: Sat Dec 31 10:37:50 2016 New Revision: 310906 URL: https://svnweb.freebsd.org/changeset/base/310906 Log: MFstable/11 r310904: MFC r310662,r310663: r310662: style(9): snmp_send_packet(..): fix whitespace r310663: style(9): ip_get(..): clean up whitespace Modified: stable/10/contrib/bsnmp/snmpd/export.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmpd/export.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/export.c Sat Dec 31 10:37:39 2016 (r310905) +++ stable/10/contrib/bsnmp/snmpd/export.c Sat Dec 31 10:37:50 2016 (r310906) @@ -194,6 +194,7 @@ ip_get(struct snmp_value *value, u_char value->v.ipaddress[1] = valp[1]; value->v.ipaddress[2] = valp[2]; value->v.ipaddress[3] = valp[3]; + return (SNMP_ERR_NOERROR); } From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:38: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 8A000C97033; Sat, 31 Dec 2016 10:38:59 +0000 (UTC) (envelope-from ngie@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 592F41CA8; Sat, 31 Dec 2016 10:38:59 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAcw78028245; Sat, 31 Dec 2016 10:38:58 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAcwpT028244; Sat, 31 Dec 2016 10:38:58 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311038.uBVAcwpT028244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:38: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: r310908 - stable/10/usr.sbin/bsnmpd/modules/snmp_bridge 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.23 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, 31 Dec 2016 10:38:59 -0000 Author: ngie Date: Sat Dec 31 10:38:58 2016 New Revision: 310908 URL: https://svnweb.freebsd.org/changeset/base/310908 Log: MFstable/11 r310905: MFC r310667: style(9) fixes: clean up leading whitespace Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c Sat Dec 31 10:37:56 2016 (r310907) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c Sat Dec 31 10:38:58 2016 (r310908) @@ -1472,7 +1472,7 @@ bridge_do_pfctl(int32_t bridge_ctl, enum } else s_len = 0; - len = sizeof(i); + len = sizeof(i); strcpy(mib_name, bridge_sysctl); From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:41:01 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 3259CC9714C; Sat, 31 Dec 2016 10:41:01 +0000 (UTC) (envelope-from ngie@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 DBE0A10C6; Sat, 31 Dec 2016 10:41:00 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAf0SZ028479; Sat, 31 Dec 2016 10:41:00 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAexvF028473; Sat, 31 Dec 2016 10:40:59 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311040.uBVAexvF028473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:40:59 +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: r310910 - stable/10/contrib/bsnmp/lib 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.23 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, 31 Dec 2016 10:41:01 -0000 Author: ngie Date: Sat Dec 31 10:40:59 2016 New Revision: 310910 URL: https://svnweb.freebsd.org/changeset/base/310910 Log: MFstable/11 r310909: MFC r310500,r310660: r310500: Minor style(9) fixes - Trailing whitespace cleanup - Sort variables in snmp_dialog(..) by alignment No functional change r310660: style(9): fix whitespace in pdu_encode_secparams(..) Modified: stable/10/contrib/bsnmp/lib/snmp.c stable/10/contrib/bsnmp/lib/snmpclient.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/lib/snmp.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmp.c Sat Dec 31 10:40:02 2016 (r310909) +++ stable/10/contrib/bsnmp/lib/snmp.c Sat Dec 31 10:40:59 2016 (r310910) @@ -355,8 +355,8 @@ static enum snmp_code pdu_encode_secparams(struct asn_buf *b, struct snmp_pdu *pdu) { u_char buf[256], *sptr; - struct asn_buf tb; - size_t auth_off, moved = 0; + struct asn_buf tb; + size_t auth_off, moved = 0; auth_off = 0; memset(buf, 0, 256); Modified: stable/10/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- stable/10/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 10:40:02 2016 (r310909) +++ stable/10/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 10:40:59 2016 (r310910) @@ -1214,7 +1214,7 @@ snmp_next_reqid(struct snmp_client * c) int32_t i; i = c->next_reqid; - if (c->next_reqid >= c->max_reqid) + if (c->next_reqid >= c->max_reqid) c->next_reqid = c->min_reqid; else c->next_reqid++; @@ -1230,7 +1230,7 @@ snmp_send_packet(struct snmp_pdu * pdu) u_char *buf; struct asn_buf b; ssize_t ret; - + if ((buf = malloc(snmp_client.txbuflen)) == NULL) { seterr(&snmp_client, "%s", strerror(errno)); return (-1); @@ -1684,9 +1684,9 @@ snmp_dialog(struct snmp_v1_pdu *req, str struct timeval tv = snmp_client.timeout; struct timeval end; struct snmp_pdu pdu; - u_int i; - int32_t reqid; int ret; + int32_t reqid; + u_int i; /* * Make a copy of the request and replace the syntaxes by NULL From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:43:33 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 C95E2C97399; Sat, 31 Dec 2016 10:43:33 +0000 (UTC) (envelope-from ngie@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 986471528; Sat, 31 Dec 2016 10:43:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAhWKf032365; Sat, 31 Dec 2016 10:43:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAhWFi032364; Sat, 31 Dec 2016 10:43:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311043.uBVAhWFi032364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:43:32 +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: r310912 - stable/10/usr.sbin/bsnmpd/tools/libbsnmptools 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.23 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, 31 Dec 2016 10:43:33 -0000 Author: ngie Date: Sat Dec 31 10:43:32 2016 New Revision: 310912 URL: https://svnweb.freebsd.org/changeset/base/310912 Log: MFstable/11 r310911: MFC r310668: style(9) fixes: clean up leading whitespace Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 10:41:51 2016 (r310911) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 10:43:32 2016 (r310912) @@ -1093,6 +1093,7 @@ snmp_ip2asn_oid(char *str, struct asn_oi char *endptr, *ptr; ptr = str; + for (i = 0; i < 4; i++) { v = strtoul(ptr, &endptr, 10); if (v > 0xff) From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:45: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 3D5EAC9742D; Sat, 31 Dec 2016 10:45:02 +0000 (UTC) (envelope-from ngie@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 0C87C16A4; Sat, 31 Dec 2016 10:45:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAj1Sf032506; Sat, 31 Dec 2016 10:45:01 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAj13j032505; Sat, 31 Dec 2016 10:45:01 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311045.uBVAj13j032505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:45: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: r310913 - stable/10/usr.sbin/bsnmpd/modules/snmp_pf 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.23 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, 31 Dec 2016 10:45:02 -0000 Author: ngie Date: Sat Dec 31 10:45:01 2016 New Revision: 310913 URL: https://svnweb.freebsd.org/changeset/base/310913 Log: MFstable/11 r310902: MFC r310669: style(9): clean up whitespace Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c Sat Dec 31 10:43:32 2016 (r310912) +++ stable/10/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c Sat Dec 31 10:45:01 2016 (r310913) @@ -1640,20 +1640,20 @@ err: static int altq_is_enabled(int pfdev) { - struct pfioc_altq pa; + struct pfioc_altq pa; errno = 0; - if (ioctl(pfdev, DIOCGETALTQS, &pa)) { - if (errno == ENODEV) { + if (ioctl(pfdev, DIOCGETALTQS, &pa)) { + if (errno == ENODEV) { syslog(LOG_INFO, "No ALTQ support in kernel\n" "ALTQ related functions disabled\n"); - return (0); - } else - syslog(LOG_ERR, "DIOCGETALTQS returned an error: %s", + return (0); + } else + syslog(LOG_ERR, "DIOCGETALTQS returned an error: %s", strerror(errno)); return (-1); - } - return (1); + } + return (1); } /* From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:47: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 9E3CCC974E4; Sat, 31 Dec 2016 10:47:22 +0000 (UTC) (envelope-from ngie@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 5ED9E1837; Sat, 31 Dec 2016 10:47:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAlLNN032646; Sat, 31 Dec 2016 10:47:21 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAlL2j032644; Sat, 31 Dec 2016 10:47:21 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311047.uBVAlL2j032644@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:47: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: r310914 - in stable/10: tools/build/mk usr.sbin/bsnmpd/bsnmpd 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.23 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, 31 Dec 2016 10:47:22 -0000 Author: ngie Date: Sat Dec 31 10:47:21 2016 New Revision: 310914 URL: https://svnweb.freebsd.org/changeset/base/310914 Log: MFstable/11 r310896: MFC r310654: Install snmpmod.3 as all of the bsnmpd APIs it documents Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/10/tools/build/mk/OptionalObsoleteFiles.inc Sat Dec 31 10:45:01 2016 (r310913) +++ stable/10/tools/build/mk/OptionalObsoleteFiles.inc Sat Dec 31 10:47:21 2016 (r310914) @@ -406,22 +406,119 @@ OLD_FILES+=usr/share/man/man1/bsnmpget.1 OLD_FILES+=usr/share/man/man1/bsnmpset.1.gz OLD_FILES+=usr/share/man/man1/bsnmpwalk.1.gz OLD_FILES+=usr/share/man/man1/gensnmptree.1.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT.3.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT_LINK.3.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT_LINK_INDEX.3.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_OID.3.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_OID_LINK.3.gz +OLD_FILES+=usr/share/man/man3/FIND_OBJECT_OID_LINK_INDEX.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_INT.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_INT_LINK.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_INT_LINK_INDEX.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_OID.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_OID_LINK.3.gz +OLD_FILES+=usr/share/man/man3/INSERT_OBJECT_OID_LINK_INDEX.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_INT.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_INT_LINK.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_INT_LINK_INDEX.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_OID.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_OID_LINK.3.gz +OLD_FILES+=usr/share/man/man3/NEXT_OBJECT_OID_LINK_INDEX.3.gz OLD_FILES+=usr/share/man/man3/asn1.3.gz OLD_FILES+=usr/share/man/man3/bsnmpagent.3.gz OLD_FILES+=usr/share/man/man3/bsnmpclient.3.gz +OLD_FILES+=usr/share/man/man3/bsnmpd_get_target_stats.3.gz +OLD_FILES+=usr/share/man/man3/bsnmpd_get_usm_stats.3.gz +OLD_FILES+=usr/share/man/man3/bsnmpd_reset_usm_stats.3.gz OLD_FILES+=usr/share/man/man3/bsnmplib.3.gz +OLD_FILES+=usr/share/man/man3/buf_alloc.3.gz +OLD_FILES+=usr/share/man/man3/buf_size.3.gz +OLD_FILES+=usr/share/man/man3/comm_define.3.gz +OLD_FILES+=usr/share/man/man3/community.3.gz +OLD_FILES+=usr/share/man/man3/fd_deselect.3.gz +OLD_FILES+=usr/share/man/man3/fd_resume.3.gz +OLD_FILES+=usr/share/man/man3/fd_select.3.gz +OLD_FILES+=usr/share/man/man3/fd_suspend.3.gz +OLD_FILES+=usr/share/man/man3/get_ticks.3.gz +OLD_FILES+=usr/share/man/man3/index_append.3.gz +OLD_FILES+=usr/share/man/man3/index_append_off.3.gz +OLD_FILES+=usr/share/man/man3/index_compare.3.gz +OLD_FILES+=usr/share/man/man3/index_compare_off.3.gz +OLD_FILES+=usr/share/man/man3/index_decode.3.gz +OLD_FILES+=usr/share/man/man3/ip_commit.3.gz +OLD_FILES+=usr/share/man/man3/ip_get.3.gz +OLD_FILES+=usr/share/man/man3/ip_rollback.3.gz +OLD_FILES+=usr/share/man/man3/ip_save.3.gz +OLD_FILES+=usr/share/man/man3/or_register.3.gz +OLD_FILES+=usr/share/man/man3/or_unregister.3.gz +OLD_FILES+=usr/share/man/man3/oid_commit.3.gz +OLD_FILES+=usr/share/man/man3/oid_get.3.gz +OLD_FILES+=usr/share/man/man3/oid_rollback.3.gz +OLD_FILES+=usr/share/man/man3/oid_save.3.gz +OLD_FILES+=usr/share/man/man3/oid_usmNotInTimeWindows.3.gz +OLD_FILES+=usr/share/man/man3/oid_usmUnknownEngineIDs.3.gz +OLD_FILES+=usr/share/man/man3/oid_zeroDotZero.3.gz +OLD_FILES+=usr/share/man/man3/reqid_allocate.3.gz +OLD_FILES+=usr/share/man/man3/reqid_base.3.gz +OLD_FILES+=usr/share/man/man3/reqid_istype.3.gz +OLD_FILES+=usr/share/man/man3/reqid_next.3.gz +OLD_FILES+=usr/share/man/man3/reqid_type.3.gz OLD_FILES+=usr/share/man/man3/snmp_atm.3.gz OLD_FILES+=usr/share/man/man3/snmp_bridge.3.gz OLD_FILES+=usr/share/man/man3/snmp_hast.3.gz OLD_FILES+=usr/share/man/man3/snmp_hostres.3.gz +OLD_FILES+=usr/share/man/man3/snmp_input_finish.3.gz +OLD_FILES+=usr/share/man/man3/snmp_input_start.3.gz OLD_FILES+=usr/share/man/man3/snmp_lm75.3.gz OLD_FILES+=usr/share/man/man3/snmp_mibII.3.gz OLD_FILES+=usr/share/man/man3/snmp_netgraph.3.gz +OLD_FILES+=usr/share/man/man3/snmp_output.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_auth_access.3.gz +OLD_FILES+=usr/share/man/man3/snmp_send_port.3.gz +OLD_FILES+=usr/share/man/man3/snmp_send_trap.3.gz OLD_FILES+=usr/share/man/man3/snmp_target.3.gz OLD_FILES+=usr/share/man/man3/snmp_usm.3.gz OLD_FILES+=usr/share/man/man3/snmp_vacm.3.gz OLD_FILES+=usr/share/man/man3/snmp_wlan.3.gz +OLD_FILES+=usr/share/man/man3/snmpd_target_stat.3.gz +OLD_FILES+=usr/share/man/man3/snmpd_usmstats.3.gz OLD_FILES+=usr/share/man/man3/snmpmod.3.gz +OLD_FILES+=usr/share/man/man3/start_tick.3.gz +OLD_FILES+=usr/share/man/man3/string_commit.3.gz +OLD_FILES+=usr/share/man/man3/string_free.3.gz +OLD_FILES+=usr/share/man/man3/string_get.3.gz +OLD_FILES+=usr/share/man/man3/string_get_max.3.gz +OLD_FILES+=usr/share/man/man3/string_rollback.3.gz +OLD_FILES+=usr/share/man/man3/string_save.3.gz +OLD_FILES+=usr/share/man/man3/systemg.3.gz +OLD_FILES+=usr/share/man/man3/this_tick.3.gz +OLD_FILES+=usr/share/man/man3/timer_start.3.gz +OLD_FILES+=usr/share/man/man3/timer_start_repeat.3.gz +OLD_FILES+=usr/share/man/man3/timer_stop.3.gz +OLD_FILES+=usr/share/man/man3/target_activate_address.3.gz +OLD_FILES+=usr/share/man/man3/target_address.3.gz +OLD_FILES+=usr/share/man/man3/target_delete_address.3.gz +OLD_FILES+=usr/share/man/man3/target_delete_notify.3.gz +OLD_FILES+=usr/share/man/man3/target_delete_param.3.gz +OLD_FILES+=usr/share/man/man3/target_first_address.3.gz +OLD_FILES+=usr/share/man/man3/target_first_notify.3.gz +OLD_FILES+=usr/share/man/man3/target_first_param.3.gz +OLD_FILES+=usr/share/man/man3/target_flush_all.3.gz +OLD_FILES+=usr/share/man/man3/target_next_address.3.gz +OLD_FILES+=usr/share/man/man3/target_next_notify.3.gz +OLD_FILES+=usr/share/man/man3/target_next_param.3.gz +OLD_FILES+=usr/share/man/man3/target_new_address.3.gz +OLD_FILES+=usr/share/man/man3/target_new_notify.3.gz +OLD_FILES+=usr/share/man/man3/target_new_param.3.gz +OLD_FILES+=usr/share/man/man3/target_notify.3.gz +OLD_FILES+=usr/share/man/man3/target_param.3.gz +OLD_FILES+=usr/share/man/man3/usm_delete_user.3.gz +OLD_FILES+=usr/share/man/man3/usm_find_user.3.gz +OLD_FILES+=usr/share/man/man3/usm_first_user.3.gz +OLD_FILES+=usr/share/man/man3/usm_flush_users.3.gz +OLD_FILES+=usr/share/man/man3/usm_next_user.3.gz +OLD_FILES+=usr/share/man/man3/usm_new_user.3.gz +OLD_FILES+=usr/share/man/man3/usm_user.3.gz OLD_FILES+=usr/share/snmp/defs/atm_freebsd.def OLD_FILES+=usr/share/snmp/defs/atm_tree.def OLD_FILES+=usr/share/snmp/defs/bridge_tree.def Modified: stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile ============================================================================== --- stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Sat Dec 31 10:45:01 2016 (r310913) +++ stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Sat Dec 31 10:47:21 2016 (r310914) @@ -15,8 +15,107 @@ XSYM= snmpMIB begemotSnmpdModuleTable be begemotSnmpdTransUdp begemotSnmpdTransLsock begemotSnmpdLocalPortTable \ freeBSD freeBSDVersion CLEANFILES= oid.h tree.c tree.h + MAN= bsnmpd.1 snmpmod.3 +MLINKS+= snmpmod.3 FIND_OBJECT_INT.3 +MLINKS+= snmpmod.3 FIND_OBJECT_INT_LINK.3 +MLINKS+= snmpmod.3 FIND_OBJECT_INT_LINK_INDEX.3 +MLINKS+= snmpmod.3 FIND_OBJECT_OID.3 +MLINKS+= snmpmod.3 FIND_OBJECT_OID_LINK.3 +MLINKS+= snmpmod.3 FIND_OBJECT_OID_LINK_INDEX.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_INT.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_INT_LINK.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_INT_LINK_INDEX.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_OID.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_OID_LINK.3 +MLINKS+= snmpmod.3 INSERT_OBJECT_OID_LINK_INDEX.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_INT.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_INT_LINK.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_INT_LINK_INDEX.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_OID.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_OID_LINK.3 +MLINKS+= snmpmod.3 NEXT_OBJECT_OID_LINK_INDEX.3 +MLINKS+= snmpmod.3 bsnmpd_get_target_stats.3 +MLINKS+= snmpmod.3 bsnmpd_get_usm_stats.3 +MLINKS+= snmpmod.3 bsnmpd_reset_usm_stats.3 +MLINKS+= snmpmod.3 buf_alloc.3 +MLINKS+= snmpmod.3 buf_size.3 +MLINKS+= snmpmod.3 comm_define.3 +MLINKS+= snmpmod.3 community.3 +MLINKS+= snmpmod.3 fd_deselect.3 +MLINKS+= snmpmod.3 fd_resume.3 +MLINKS+= snmpmod.3 fd_select.3 +MLINKS+= snmpmod.3 fd_suspend.3 +MLINKS+= snmpmod.3 get_ticks.3 +MLINKS+= snmpmod.3 index_append.3 +MLINKS+= snmpmod.3 index_append_off.3 +MLINKS+= snmpmod.3 index_compare.3 +MLINKS+= snmpmod.3 index_compare_off.3 +MLINKS+= snmpmod.3 index_decode.3 +MLINKS+= snmpmod.3 ip_commit.3 +MLINKS+= snmpmod.3 ip_get.3 +MLINKS+= snmpmod.3 ip_rollback.3 +MLINKS+= snmpmod.3 ip_save.3 +MLINKS+= snmpmod.3 or_register.3 +MLINKS+= snmpmod.3 or_unregister.3 +MLINKS+= snmpmod.3 oid_commit.3 +MLINKS+= snmpmod.3 oid_get.3 +MLINKS+= snmpmod.3 oid_rollback.3 +MLINKS+= snmpmod.3 oid_save.3 +MLINKS+= snmpmod.3 oid_usmNotInTimeWindows.3 +MLINKS+= snmpmod.3 oid_usmUnknownEngineIDs.3 +MLINKS+= snmpmod.3 oid_zeroDotZero.3 +MLINKS+= snmpmod.3 reqid_allocate.3 +MLINKS+= snmpmod.3 reqid_base.3 +MLINKS+= snmpmod.3 reqid_istype.3 +MLINKS+= snmpmod.3 reqid_next.3 +MLINKS+= snmpmod.3 reqid_type.3 +MLINKS+= snmpmod.3 snmp_input_finish.3 +MLINKS+= snmpmod.3 snmp_input_start.3 +MLINKS+= snmpmod.3 snmp_output.3 +MLINKS+= snmpmod.3 snmp_pdu_auth_access.3 +MLINKS+= snmpmod.3 snmp_send_port.3 +MLINKS+= snmpmod.3 snmp_send_trap.3 +MLINKS+= snmpmod.3 snmpd_target_stat.3 +MLINKS+= snmpmod.3 snmpd_usmstats.3 +MLINKS+= snmpmod.3 start_tick.3 +MLINKS+= snmpmod.3 string_commit.3 +MLINKS+= snmpmod.3 string_free.3 +MLINKS+= snmpmod.3 string_get.3 +MLINKS+= snmpmod.3 string_get_max.3 +MLINKS+= snmpmod.3 string_rollback.3 +MLINKS+= snmpmod.3 string_save.3 +MLINKS+= snmpmod.3 systemg.3 +MLINKS+= snmpmod.3 this_tick.3 +MLINKS+= snmpmod.3 timer_start.3 +MLINKS+= snmpmod.3 timer_start_repeat.3 +MLINKS+= snmpmod.3 timer_stop.3 +MLINKS+= snmpmod.3 target_activate_address.3 +MLINKS+= snmpmod.3 target_address.3 +MLINKS+= snmpmod.3 target_delete_address.3 +MLINKS+= snmpmod.3 target_delete_notify.3 +MLINKS+= snmpmod.3 target_delete_param.3 +MLINKS+= snmpmod.3 target_first_address.3 +MLINKS+= snmpmod.3 target_first_notify.3 +MLINKS+= snmpmod.3 target_first_param.3 +MLINKS+= snmpmod.3 target_flush_all.3 +MLINKS+= snmpmod.3 target_next_address.3 +MLINKS+= snmpmod.3 target_next_notify.3 +MLINKS+= snmpmod.3 target_next_param.3 +MLINKS+= snmpmod.3 target_new_address.3 +MLINKS+= snmpmod.3 target_new_notify.3 +MLINKS+= snmpmod.3 target_new_param.3 +MLINKS+= snmpmod.3 target_notify.3 +MLINKS+= snmpmod.3 target_param.3 +MLINKS+= snmpmod.3 usm_delete_user.3 +MLINKS+= snmpmod.3 usm_find_user.3 +MLINKS+= snmpmod.3 usm_first_user.3 +MLINKS+= snmpmod.3 usm_flush_users.3 +MLINKS+= snmpmod.3 usm_next_user.3 +MLINKS+= snmpmod.3 usm_new_user.3 +MLINKS+= snmpmod.3 usm_user.3 + FILESGROUPS= BMIBS DEFS BMIBS= FOKUS-MIB.txt BEGEMOT-MIB.txt BEGEMOT-SNMPD.txt From owner-svn-src-stable-10@freebsd.org Sat Dec 31 10:48:20 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 5F5EAC97584; Sat, 31 Dec 2016 10:48:20 +0000 (UTC) (envelope-from ngie@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 32B6119B1; Sat, 31 Dec 2016 10:48:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVAmJwa032746; Sat, 31 Dec 2016 10:48:19 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVAmJPg032744; Sat, 31 Dec 2016 10:48:19 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612311048.uBVAmJPg032744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 31 Dec 2016 10:48:19 +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: r310915 - in stable/10: lib/libbsnmp/libbsnmp tools/build/mk 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.23 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, 31 Dec 2016 10:48:20 -0000 Author: ngie Date: Sat Dec 31 10:48:19 2016 New Revision: 310915 URL: https://svnweb.freebsd.org/changeset/base/310915 Log: MFstable/11 r310897: MFC r310728: Install {asn1,bsnmpagent,bsnmpclient,bsnmplib}.3 as all of the APIs they document Also, alphabetically sort MAN Modified: stable/10/lib/libbsnmp/libbsnmp/Makefile stable/10/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libbsnmp/libbsnmp/Makefile ============================================================================== --- stable/10/lib/libbsnmp/libbsnmp/Makefile Sat Dec 31 10:47:21 2016 (r310914) +++ stable/10/lib/libbsnmp/libbsnmp/Makefile Sat Dec 31 10:48:19 2016 (r310915) @@ -20,7 +20,97 @@ LDADD+= -lcrypto .endif SRCS= asn1.c snmp.c snmpagent.c snmpclient.c snmpcrypto.c support.c -INCS= asn1.h snmp.h snmpagent.h snmpclient.h -MAN= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3 +INCS= asn1.h snmp.h snmpagent.h snmpclient.h +MAN= asn1.3 bsnmpagent.3 bsnmpclient.3 bsnmplib.3 + +MLINKS+= asn1.3 asn_append_oid.3 +MLINKS+= asn1.3 asn_commit_header.3 +MLINKS+= asn1.3 asn_compare_oid.3 +MLINKS+= asn1.3 asn_get_counter64_raw.3 +MLINKS+= asn1.3 asn_get_header.3 +MLINKS+= asn1.3 asn_get_integer.3 +MLINKS+= asn1.3 asn_get_integer_raw.3 +MLINKS+= asn1.3 asn_get_ipaddress.3 +MLINKS+= asn1.3 asn_get_ipaddress_raw.3 +MLINKS+= asn1.3 asn_get_null.3 +MLINKS+= asn1.3 asn_get_null_raw.3 +MLINKS+= asn1.3 asn_get_objid.3 +MLINKS+= asn1.3 asn_get_objid_raw.3 +MLINKS+= asn1.3 asn_get_octetstring.3 +MLINKS+= asn1.3 asn_get_octetstring_raw.3 +MLINKS+= asn1.3 asn_get_sequence.3 +MLINKS+= asn1.3 asn_get_timeticks.3 +MLINKS+= asn1.3 asn_get_uint32_raw.3 +MLINKS+= asn1.3 asn_is_suboid.3 +MLINKS+= asn1.3 asn_oid2str.3 +MLINKS+= asn1.3 asn_oid2str_r.3 +MLINKS+= asn1.3 asn_put_counter64.3 +MLINKS+= asn1.3 asn_put_exception.3 +MLINKS+= asn1.3 asn_put_header.3 +MLINKS+= asn1.3 asn_put_integer.3 +MLINKS+= asn1.3 asn_put_ipaddress.3 +MLINKS+= asn1.3 asn_put_null.3 +MLINKS+= asn1.3 asn_put_objid.3 +MLINKS+= asn1.3 asn_put_octetstring.3 +MLINKS+= asn1.3 asn_put_temp_header.3 +MLINKS+= asn1.3 asn_put_timeticks.3 +MLINKS+= asn1.3 asn_put_uint32.3 +MLINKS+= asn1.3 asn_skip.3 +MLINKS+= asn1.3 asn_slice_oid.3 + +MLINKS+= bsnmpagent.3 snmp_debug.3 +MLINKS+= bsnmpagent.3 snmp_dep_commit.3 +MLINKS+= bsnmpagent.3 snmp_dep_finish.3 +MLINKS+= bsnmpagent.3 snmp_dep_lookup.3 +MLINKS+= bsnmpagent.3 snmp_dep_rollback.3 +MLINKS+= bsnmpagent.3 snmp_depop_t.3 +MLINKS+= bsnmpagent.3 snmp_get.3 +MLINKS+= bsnmpagent.3 snmp_getbulk.3 +MLINKS+= bsnmpagent.3 snmp_getnext.3 +MLINKS+= bsnmpagent.3 snmp_init_context.3 +MLINKS+= bsnmpagent.3 snmp_make_errresp.3 +MLINKS+= bsnmpagent.3 snmp_op_t.3 +MLINKS+= bsnmpagent.3 snmp_set.3 +MLINKS+= bsnmpagent.3 snmp_trace.3 +MLINKS+= bsnmpagent.3 tree.3 +MLINKS+= bsnmpagent.3 tree_size.3 + +MLINKS+= bsnmpclient.3 snmp_add_binding.3 +MLINKS+= bsnmpclient.3 snmp_client.3 +MLINKS+= bsnmpclient.3 snmp_close.3 +MLINKS+= bsnmpclient.3 snmp_dialog.3 +MLINKS+= bsnmpclient.3 snmp_discover_engine.3 +MLINKS+= bsnmpclient.3 snmp_oid_append.3 +MLINKS+= bsnmpclient.3 snmp_open.3 +MLINKS+= bsnmpclient.3 snmp_parse_server.3 +MLINKS+= bsnmpclient.3 snmp_pdu_check.3 +MLINKS+= bsnmpclient.3 snmp_pdu_create.3 +MLINKS+= bsnmpclient.3 snmp_pdu_send.3 +MLINKS+= bsnmpclient.3 snmp_receive.3 +MLINKS+= bsnmpclient.3 snmp_send_cb_f.3 +MLINKS+= bsnmpclient.3 snmp_table_cb_f.3 +MLINKS+= bsnmpclient.3 snmp_table_fetch.3 +MLINKS+= bsnmpclient.3 snmp_table_fetch_async.3 +MLINKS+= bsnmpclient.3 snmp_timeout_cb_f.3 +MLINKS+= bsnmpclient.3 snmp_timeout_start_f.3 +MLINKS+= bsnmpclient.3 snmp_timeout_stop_f.3 + +MLINKS+= bsnmplib.3 TRUTH_GET.3 +MLINKS+= bsnmplib.3 TRUTH_MK.3 +MLINKS+= bsnmplib.3 TRUTH_OK.3 +MLINKS+= bsnmplib.3 snmp_calc_keychange.3 +MLINKS+= bsnmplib.3 snmp_get_local_keys.3 +MLINKS+= bsnmplib.3 snmp_passwd_to_keys.3 +MLINKS+= bsnmplib.3 snmp_pdu_decode.3 +MLINKS+= bsnmplib.3 snmp_pdu_decode_header.3 +MLINKS+= bsnmplib.3 snmp_pdu_decode_scoped.3 +MLINKS+= bsnmplib.3 snmp_pdu_decode_secmode.3 +MLINKS+= bsnmplib.3 snmp_pdu_dump.3 +MLINKS+= bsnmplib.3 snmp_pdu_encode.3 +MLINKS+= bsnmplib.3 snmp_pdu_free.3 +MLINKS+= bsnmplib.3 snmp_pdu_init_secparams.3 +MLINKS+= bsnmplib.3 snmp_value_copy.3 +MLINKS+= bsnmplib.3 snmp_value_free.3 +MLINKS+= bsnmplib.3 snmp_value_parse.3 .include Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/10/tools/build/mk/OptionalObsoleteFiles.inc Sat Dec 31 10:47:21 2016 (r310914) +++ stable/10/tools/build/mk/OptionalObsoleteFiles.inc Sat Dec 31 10:48:19 2016 (r310915) @@ -406,6 +406,95 @@ OLD_FILES+=usr/share/man/man1/bsnmpget.1 OLD_FILES+=usr/share/man/man1/bsnmpset.1.gz OLD_FILES+=usr/share/man/man1/bsnmpwalk.1.gz OLD_FILES+=usr/share/man/man1/gensnmptree.1.gz +# lib/libbsnmp/libbsnmp +OLD_FILES+=usr/share/man/man3/TRUTH_GET.3.gz +OLD_FILES+=usr/share/man/man3/TRUTH_MK.3.gz +OLD_FILES+=usr/share/man/man3/TRUTH_OK.3.gz +OLD_FILES+=usr/share/man/man3/asn1.3.gz +OLD_FILES+=usr/share/man/man3/asn_append_oid.3.gz +OLD_FILES+=usr/share/man/man3/asn_commit_header.3.gz +OLD_FILES+=usr/share/man/man3/asn_compare_oid.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_counter64_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_header.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_integer.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_integer_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_ipaddress.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_ipaddress_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_null.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_null_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_objid.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_objid_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_octetstring.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_octetstring_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_sequence.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_timeticks.3.gz +OLD_FILES+=usr/share/man/man3/asn_get_uint32_raw.3.gz +OLD_FILES+=usr/share/man/man3/asn_is_suboid.3.gz +OLD_FILES+=usr/share/man/man3/asn_oid2str.3.gz +OLD_FILES+=usr/share/man/man3/asn_oid2str_r.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_counter64.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_exception.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_header.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_integer.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_ipaddress.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_null.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_objid.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_octetstring.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_temp_header.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_timeticks.3.gz +OLD_FILES+=usr/share/man/man3/asn_put_uint32.3.gz +OLD_FILES+=usr/share/man/man3/asn_skip.3.gz +OLD_FILES+=usr/share/man/man3/asn_slice_oid.3.gz +OLD_FILES+=usr/share/man/man3/snmp_add_binding.3.gz +OLD_FILES+=usr/share/man/man3/snmp_calc_keychange.3.gz +OLD_FILES+=usr/share/man/man3/snmp_client.3.gz +OLD_FILES+=usr/share/man/man3/snmp_close.3.gz +OLD_FILES+=usr/share/man/man3/snmp_debug.3.gz +OLD_FILES+=usr/share/man/man3/snmp_dep_commit.3.gz +OLD_FILES+=usr/share/man/man3/snmp_dep_finish.3.gz +OLD_FILES+=usr/share/man/man3/snmp_dep_lookup.3.gz +OLD_FILES+=usr/share/man/man3/snmp_dep_rollback.3.gz +OLD_FILES+=usr/share/man/man3/snmp_depop_t.3.gz +OLD_FILES+=usr/share/man/man3/snmp_dialog.3.gz +OLD_FILES+=usr/share/man/man3/snmp_discover_engine.3.gz +OLD_FILES+=usr/share/man/man3/snmp_get.3.gz +OLD_FILES+=usr/share/man/man3/snmp_get_local_keys.3.gz +OLD_FILES+=usr/share/man/man3/snmp_getbulk.3.gz +OLD_FILES+=usr/share/man/man3/snmp_getnext.3.gz +OLD_FILES+=usr/share/man/man3/snmp_init_context.3.gz +OLD_FILES+=usr/share/man/man3/snmp_make_errresp.3.gz +OLD_FILES+=usr/share/man/man3/snmp_oid_append.3.gz +OLD_FILES+=usr/share/man/man3/snmp_op_t.3.gz +OLD_FILES+=usr/share/man/man3/snmp_open.3.gz +OLD_FILES+=usr/share/man/man3/snmp_parse_server.3.gz +OLD_FILES+=usr/share/man/man3/snmp_passwd_to_keys.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_check.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_create.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_decode.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_decode_header.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_decode_scoped.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_decode_secmode.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_dump.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_encode.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_free.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_init_secparams.3.gz +OLD_FILES+=usr/share/man/man3/snmp_pdu_send.3.gz +OLD_FILES+=usr/share/man/man3/snmp_receive.3.gz +OLD_FILES+=usr/share/man/man3/snmp_send_cb_f.3.gz +OLD_FILES+=usr/share/man/man3/snmp_set.3.gz +OLD_FILES+=usr/share/man/man3/snmp_table_cb_f.3.gz +OLD_FILES+=usr/share/man/man3/snmp_table_fetch.3.gz +OLD_FILES+=usr/share/man/man3/snmp_table_fetch_async.3.gz +OLD_FILES+=usr/share/man/man3/snmp_timeout_cb_f.3.gz +OLD_FILES+=usr/share/man/man3/snmp_timeout_start_f.3.gz +OLD_FILES+=usr/share/man/man3/snmp_timeout_stop_f.3.gz +OLD_FILES+=usr/share/man/man3/snmp_trace.3.gz +OLD_FILES+=usr/share/man/man3/snmp_value_copy.3.gz +OLD_FILES+=usr/share/man/man3/snmp_value_free.3.gz +OLD_FILES+=usr/share/man/man3/snmp_value_parse.3.gz +OLD_FILES+=usr/share/man/man3/tree.3.gz +OLD_FILES+=usr/share/man/man3/tree_size.3.gz +# usr.sbin/bsnmpd/bsnmpd OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT.3.gz OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT_LINK.3.gz OLD_FILES+=usr/share/man/man3/FIND_OBJECT_INT_LINK_INDEX.3.gz From owner-svn-src-stable-10@freebsd.org Sat Dec 31 12:53:00 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 33E14C98883; Sat, 31 Dec 2016 12:53:00 +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 032461191; Sat, 31 Dec 2016 12:52:59 +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 uBVCqxXh088349; Sat, 31 Dec 2016 12:52:59 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVCqxqd088347; Sat, 31 Dec 2016 12:52:59 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201612311252.uBVCqxqd088347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 31 Dec 2016 12:52:59 +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: r310967 - in 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.23 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, 31 Dec 2016 12:53:00 -0000 Author: bapt Date: Sat Dec 31 12:52:58 2016 New Revision: 310967 URL: https://svnweb.freebsd.org/changeset/base/310967 Log: Bump copyright year. Happy New Year 2017! Modified: stable/10/COPYRIGHT stable/10/sys/sys/copyright.h Directory Properties: stable/10/ (props changed) Modified: stable/10/COPYRIGHT ============================================================================== --- stable/10/COPYRIGHT Sat Dec 31 12:52:23 2016 (r310966) +++ stable/10/COPYRIGHT Sat Dec 31 12:52:58 2016 (r310967) @@ -4,7 +4,7 @@ The compilation of software known as FreeBSD is distributed under the following terms: -Copyright (c) 1992-2016 The FreeBSD Project. All rights reserved. +Copyright (c) 1992-2017 The FreeBSD Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions Modified: stable/10/sys/sys/copyright.h ============================================================================== --- stable/10/sys/sys/copyright.h Sat Dec 31 12:52:23 2016 (r310966) +++ stable/10/sys/sys/copyright.h Sat Dec 31 12:52:58 2016 (r310967) @@ -30,7 +30,7 @@ /* FreeBSD */ #define COPYRIGHT_FreeBSD \ - "Copyright (c) 1992-2016 The FreeBSD Project.\n" + "Copyright (c) 1992-2017 The FreeBSD Project.\n" /* Foundation */ #define TRADEMARK_Foundation \ From owner-svn-src-stable-10@freebsd.org Sat Dec 31 13:23:29 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 777E6C994B1; Sat, 31 Dec 2016 13:23:29 +0000 (UTC) (envelope-from mjg@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 46A5E190F; Sat, 31 Dec 2016 13:23:29 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVDNSdA000880; Sat, 31 Dec 2016 13:23:28 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVDNSD2000879; Sat, 31 Dec 2016 13:23:28 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201612311323.uBVDNSD2000879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 31 Dec 2016 13:23:28 +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: r310975 - stable/10/sys/amd64/amd64 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.23 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, 31 Dec 2016 13:23:29 -0000 Author: mjg Date: Sat Dec 31 13:23:28 2016 New Revision: 310975 URL: https://svnweb.freebsd.org/changeset/base/310975 Log: MFC r303583: amd64: implement pagezero using rep stos The current implementation uses non-temporal writes. This turns out to be detrimental to performance if the page is used shortly after, which is the typical case with page faults. Switch to rep stos. Modified: stable/10/sys/amd64/amd64/support.S Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/support.S ============================================================================== --- stable/10/sys/amd64/amd64/support.S Sat Dec 31 13:15:52 2016 (r310974) +++ stable/10/sys/amd64/amd64/support.S Sat Dec 31 13:23:28 2016 (r310975) @@ -65,17 +65,10 @@ END(bzero) /* Address: %rdi */ ENTRY(pagezero) PUSH_FRAME_POINTER - movq $-PAGE_SIZE,%rdx - subq %rdx,%rdi + movq $PAGE_SIZE/8,%rcx xorl %eax,%eax -1: - movnti %rax,(%rdi,%rdx) - movnti %rax,8(%rdi,%rdx) - movnti %rax,16(%rdi,%rdx) - movnti %rax,24(%rdi,%rdx) - addq $32,%rdx - jne 1b - sfence + rep + stosq POP_FRAME_POINTER ret END(pagezero) From owner-svn-src-stable-10@freebsd.org Sat Dec 31 16:37: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 10DAEC99DD9; Sat, 31 Dec 2016 16:37:49 +0000 (UTC) (envelope-from mjg@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 BADCE13DE; Sat, 31 Dec 2016 16:37:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVGbljm081510; Sat, 31 Dec 2016 16:37:47 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVGblbG081502; Sat, 31 Dec 2016 16:37:47 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201612311637.uBVGblbG081502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 31 Dec 2016 16:37:47 +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: r310979 - in stable/10/sys: 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.23 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, 31 Dec 2016 16:37:49 -0000 Author: mjg Date: Sat Dec 31 16:37:47 2016 New Revision: 310979 URL: https://svnweb.freebsd.org/changeset/base/310979 Log: MFC r301157: Microoptimize locking primitives by avoiding unnecessary atomic ops. Inline version of primitives do an atomic op and if it fails they fallback to actual primitives, which immediately retry the atomic op. The obvious optimisation is to check if the lock is free and only then proceed to do an atomic op. Modified: stable/10/sys/kern/kern_lock.c stable/10/sys/kern/kern_mutex.c stable/10/sys/kern/kern_rwlock.c stable/10/sys/kern/kern_sx.c stable/10/sys/sys/mutex.h stable/10/sys/sys/rwlock.h stable/10/sys/sys/sx.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_lock.c ============================================================================== --- stable/10/sys/kern/kern_lock.c Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/kern/kern_lock.c Sat Dec 31 16:37:47 2016 (r310979) @@ -792,8 +792,10 @@ __lockmgr_args(struct lock *lk, u_int fl break; } - while (!atomic_cmpset_acq_ptr(&lk->lk_lock, LK_UNLOCKED, - tid)) { + for (;;) { + if (lk->lk_lock == LK_UNLOCKED && + atomic_cmpset_acq_ptr(&lk->lk_lock, LK_UNLOCKED, tid)) + break; #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -1129,7 +1131,11 @@ __lockmgr_args(struct lock *lk, u_int fl __func__, iwmesg, file, line); } - while (!atomic_cmpset_acq_ptr(&lk->lk_lock, LK_UNLOCKED, tid)) { + for (;;) { + if (lk->lk_lock == LK_UNLOCKED && + atomic_cmpset_acq_ptr(&lk->lk_lock, LK_UNLOCKED, tid)) + break; + #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif Modified: stable/10/sys/kern/kern_mutex.c ============================================================================== --- stable/10/sys/kern/kern_mutex.c Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/kern/kern_mutex.c Sat Dec 31 16:37:47 2016 (r310979) @@ -451,7 +451,9 @@ __mtx_lock_sleep(volatile uintptr_t *c, all_time -= lockstat_nsecs(&m->lock_object); #endif - while (!_mtx_obtain_lock(m, tid)) { + for (;;) { + if (m->mtx_lock == MTX_UNOWNED && _mtx_obtain_lock(m, tid)) + break; #ifdef KDTRACE_HOOKS spin_cnt++; #endif @@ -634,8 +636,9 @@ _mtx_lock_spin_cookie(volatile uintptr_t #ifdef KDTRACE_HOOKS spin_time -= lockstat_nsecs(&m->lock_object); #endif - while (!_mtx_obtain_lock(m, tid)) { - + for (;;) { + if (m->mtx_lock == MTX_UNOWNED && _mtx_obtain_lock(m, tid)) + break; /* Give interrupts a chance while we spin. */ spinlock_exit(); while (m->mtx_lock != MTX_UNOWNED) { @@ -714,7 +717,9 @@ retry: m->lock_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line, NULL); - while (!_mtx_obtain_lock(m, tid)) { + for (;;) { + if (m->mtx_lock == MTX_UNOWNED && _mtx_obtain_lock(m, tid)) + break; if (m->mtx_lock == tid) { m->mtx_recurse++; break; Modified: stable/10/sys/kern/kern_rwlock.c ============================================================================== --- stable/10/sys/kern/kern_rwlock.c Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/kern/kern_rwlock.c Sat Dec 31 16:37:47 2016 (r310979) @@ -768,7 +768,9 @@ __rw_wlock_hard(volatile uintptr_t *c, u all_time -= lockstat_nsecs(&rw->lock_object); state = rw->rw_lock; #endif - while (!_rw_write_lock(rw, tid)) { + for (;;) { + if (rw->rw_lock == RW_UNLOCKED && _rw_write_lock(rw, tid)) + break; #ifdef KDTRACE_HOOKS spin_cnt++; #endif Modified: stable/10/sys/kern/kern_sx.c ============================================================================== --- stable/10/sys/kern/kern_sx.c Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/kern/kern_sx.c Sat Dec 31 16:37:47 2016 (r310979) @@ -547,7 +547,10 @@ _sx_xlock_hard(struct sx *sx, uintptr_t all_time -= lockstat_nsecs(&sx->lock_object); state = sx->sx_lock; #endif - while (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) { + for (;;) { + if (sx->sx_lock == SX_LOCK_UNLOCKED && + atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) + break; #ifdef KDTRACE_HOOKS spin_cnt++; #endif Modified: stable/10/sys/sys/mutex.h ============================================================================== --- stable/10/sys/sys/mutex.h Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/sys/mutex.h Sat Dec 31 16:37:47 2016 (r310979) @@ -188,7 +188,7 @@ void thread_lock_flags_(struct thread *, #define __mtx_lock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ - if (!_mtx_obtain_lock((mp), _tid)) \ + if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid)))\ _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ else \ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \ @@ -206,7 +206,7 @@ void thread_lock_flags_(struct thread *, uintptr_t _tid = (uintptr_t)(tid); \ \ spinlock_enter(); \ - if (!_mtx_obtain_lock((mp), _tid)) { \ + if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid))) {\ if ((mp)->mtx_lock == _tid) \ (mp)->mtx_recurse++; \ else \ @@ -262,7 +262,7 @@ void thread_lock_flags_(struct thread *, #define __mtx_unlock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ - if (!_mtx_release_lock((mp), _tid)) \ + if ((mp)->mtx_lock != _tid || !_mtx_release_lock((mp), _tid)) \ _mtx_unlock_sleep((mp), (opts), (file), (line)); \ } while (0) Modified: stable/10/sys/sys/rwlock.h ============================================================================== --- stable/10/sys/sys/rwlock.h Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/sys/rwlock.h Sat Dec 31 16:37:47 2016 (r310979) @@ -96,7 +96,7 @@ #define __rw_wlock(rw, tid, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ - if (!_rw_write_lock((rw), _tid)) \ + if ((rw)->rw_lock != RW_UNLOCKED || !_rw_write_lock((rw), _tid))\ _rw_wlock_hard((rw), _tid, (file), (line)); \ else \ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE, \ @@ -109,7 +109,7 @@ \ if ((rw)->rw_recurse) \ (rw)->rw_recurse--; \ - else if (!_rw_write_unlock((rw), _tid)) \ + else if ((rw)->rw_lock != _tid || !_rw_write_unlock((rw), _tid))\ _rw_wunlock_hard((rw), _tid, (file), (line)); \ } while (0) Modified: stable/10/sys/sys/sx.h ============================================================================== --- stable/10/sys/sys/sx.h Sat Dec 31 16:02:27 2016 (r310978) +++ stable/10/sys/sys/sx.h Sat Dec 31 16:37:47 2016 (r310979) @@ -148,7 +148,8 @@ __sx_xlock(struct sx *sx, struct thread uintptr_t tid = (uintptr_t)td; int error = 0; - if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) + if (sx->sx_lock != SX_LOCK_UNLOCKED || + !atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) error = _sx_xlock_hard(sx, tid, opts, file, line); else LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE, @@ -163,7 +164,8 @@ __sx_xunlock(struct sx *sx, struct threa { uintptr_t tid = (uintptr_t)td; - if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED)) + if (sx->sx_lock != tid || + !atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED)) _sx_xunlock_hard(sx, tid, file, line); } From owner-svn-src-stable-10@freebsd.org Sat Dec 31 16:57: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 ECC1AC991C4; Sat, 31 Dec 2016 16:57:06 +0000 (UTC) (envelope-from mjg@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 BB50C1D73; Sat, 31 Dec 2016 16:57:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVGv6tO089691; Sat, 31 Dec 2016 16:57:06 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVGv5Oe089686; Sat, 31 Dec 2016 16:57:05 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201612311657.uBVGv5Oe089686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 31 Dec 2016 16:57: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: r310980 - in stable/10/sys: 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.23 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, 31 Dec 2016 16:57:07 -0000 Author: mjg Date: Sat Dec 31 16:57:05 2016 New Revision: 310980 URL: https://svnweb.freebsd.org/changeset/base/310980 Log: MFC r285706,r303562,r303563,r303584,r303643,r303652,r303655,r303707: (by markj) Don't increment the spin count until after the first attempt to acquire a rwlock read lock. Otherwise the lockstat:::rw-spin probe will fire spuriously. == rwlock: s/READER/WRITER/ in wlock lockstat annotation == sx: increment spin_cnt before cpu_spinwait in xlock The change is a no-op only done for consistency with the rest of the file. == locks: change sleep_cnt and spin_cnt types to u_int Both variables are uint64_t, but they only count spins or sleeps. All reasonable values which we can get here comfortably hit in 32-bit range. == Implement trivial backoff for locking primitives. All current spinning loops retry an atomic op the first chance they get, which leads to performance degradation under load. One classic solution to the problem consists of delaying the test to an extent. This implementation has a trivial linear increment and a random factor for each attempt. For simplicity, this first thouch implementation only modifies spinning loops where the lock owner is running. spin mutexes and thread lock were not modified. Current parameters are autotuned on boot based on mp_cpus. Autotune factors are very conservative and are subject to change later. == locks: fix up ifdef guards introduced in r303643 Both sx and rwlocks had copy-pasted ADAPTIVE_MUTEXES instead of the correct define. == locks: fix compilation for KDTRACE_HOOKS && !ADAPTIVE_* case == locks: fix sx compilation on mips after r303643 The kernel.h header is required for the SYSINIT macro, which apparently was present on amd64 by accident. Modified: stable/10/sys/kern/kern_mutex.c stable/10/sys/kern/kern_rwlock.c stable/10/sys/kern/kern_sx.c stable/10/sys/kern/subr_lock.c stable/10/sys/sys/lock.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_mutex.c ============================================================================== --- stable/10/sys/kern/kern_mutex.c Sat Dec 31 16:37:47 2016 (r310979) +++ stable/10/sys/kern/kern_mutex.c Sat Dec 31 16:57:05 2016 (r310980) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -140,6 +141,37 @@ struct lock_class lock_class_mtx_spin = #endif }; +#ifdef ADAPTIVE_MUTEXES +static SYSCTL_NODE(_debug, OID_AUTO, mtx, CTLFLAG_RD, NULL, "mtx debugging"); + +static struct lock_delay_config mtx_delay = { + .initial = 1000, + .step = 500, + .min = 100, + .max = 5000, +}; + +SYSCTL_INT(_debug_mtx, OID_AUTO, delay_initial, CTLFLAG_RW, &mtx_delay.initial, + 0, ""); +SYSCTL_INT(_debug_mtx, OID_AUTO, delay_step, CTLFLAG_RW, &mtx_delay.step, + 0, ""); +SYSCTL_INT(_debug_mtx, OID_AUTO, delay_min, CTLFLAG_RW, &mtx_delay.min, + 0, ""); +SYSCTL_INT(_debug_mtx, OID_AUTO, delay_max, CTLFLAG_RW, &mtx_delay.max, + 0, ""); + +static void +mtx_delay_sysinit(void *dummy) +{ + + mtx_delay.initial = mp_ncpus * 25; + mtx_delay.step = (mp_ncpus * 25) / 2; + mtx_delay.min = mp_ncpus * 5; + mtx_delay.max = mp_ncpus * 25 * 10; +} +LOCK_DELAY_SYSINIT(mtx_delay_sysinit); +#endif + /* * System-wide mutexes */ @@ -412,9 +444,11 @@ __mtx_lock_sleep(volatile uintptr_t *c, int contested = 0; uint64_t waittime = 0; #endif +#if defined(ADAPTIVE_MUTEXES) || defined(KDTRACE_HOOKS) + struct lock_delay_arg lda; +#endif #ifdef KDTRACE_HOOKS - uint64_t spin_cnt = 0; - uint64_t sleep_cnt = 0; + u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif @@ -422,6 +456,11 @@ __mtx_lock_sleep(volatile uintptr_t *c, if (SCHEDULER_STOPPED()) return; +#if defined(ADAPTIVE_MUTEXES) + lock_delay_arg_init(&lda, &mtx_delay); +#elif defined(KDTRACE_HOOKS) + lock_delay_arg_init(&lda, NULL); +#endif m = mtxlock2mtx(c); if (mtx_owned(m)) { @@ -455,7 +494,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, if (m->mtx_lock == MTX_UNOWNED && _mtx_obtain_lock(m, tid)) break; #ifdef KDTRACE_HOOKS - spin_cnt++; + lda.spin_cnt++; #endif #ifdef ADAPTIVE_MUTEXES /* @@ -475,12 +514,8 @@ __mtx_lock_sleep(volatile uintptr_t *c, "spinning", "lockname:\"%s\"", m->lock_object.lo_name); while (mtx_owner(m) == owner && - TD_IS_RUNNING(owner)) { - cpu_spinwait(); -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif - } + TD_IS_RUNNING(owner)) + lock_delay(&lda); KTR_STATE0(KTR_SCHED, "thread", sched_tdname((struct thread *)tid), "running"); @@ -574,7 +609,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, /* * Only record the loops spinning and not sleeping. */ - if (spin_cnt > sleep_cnt) + if (lda.spin_cnt > sleep_cnt) LOCKSTAT_RECORD1(LS_MTX_LOCK_SPIN, m, (all_time - sleep_time)); #endif } Modified: stable/10/sys/kern/kern_rwlock.c ============================================================================== --- stable/10/sys/kern/kern_rwlock.c Sat Dec 31 16:37:47 2016 (r310979) +++ stable/10/sys/kern/kern_rwlock.c Sat Dec 31 16:57:05 2016 (r310980) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -66,15 +67,6 @@ PMC_SOFT_DECLARE( , , lock, failed); */ #define rwlock2rw(c) (__containerof(c, struct rwlock, rw_lock)) -#ifdef ADAPTIVE_RWLOCKS -static int rowner_retries = 10; -static int rowner_loops = 10000; -static SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL, - "rwlock debugging"); -SYSCTL_INT(_debug_rwlock, OID_AUTO, retry, CTLFLAG_RW, &rowner_retries, 0, ""); -SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, ""); -#endif - #ifdef DDB #include @@ -101,6 +93,42 @@ struct lock_class lock_class_rw = { #endif }; +#ifdef ADAPTIVE_RWLOCKS +static int rowner_retries = 10; +static int rowner_loops = 10000; +static SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL, + "rwlock debugging"); +SYSCTL_INT(_debug_rwlock, OID_AUTO, retry, CTLFLAG_RW, &rowner_retries, 0, ""); +SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, ""); + +static struct lock_delay_config rw_delay = { + .initial = 1000, + .step = 500, + .min = 100, + .max = 5000, +}; + +SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_initial, CTLFLAG_RW, &rw_delay.initial, + 0, ""); +SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_step, CTLFLAG_RW, &rw_delay.step, + 0, ""); +SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_min, CTLFLAG_RW, &rw_delay.min, + 0, ""); +SYSCTL_INT(_debug_rwlock, OID_AUTO, delay_max, CTLFLAG_RW, &rw_delay.max, + 0, ""); + +static void +rw_delay_sysinit(void *dummy) +{ + + rw_delay.initial = mp_ncpus * 25; + rw_delay.step = (mp_ncpus * 25) / 2; + rw_delay.min = mp_ncpus * 5; + rw_delay.max = mp_ncpus * 25 * 10; +} +LOCK_DELAY_SYSINIT(rw_delay_sysinit); +#endif + /* * Return a pointer to the owning thread if the lock is write-locked or * NULL if the lock is unlocked or read-locked. @@ -355,10 +383,12 @@ __rw_rlock(volatile uintptr_t *c, const int contested = 0; #endif uintptr_t v; +#if defined(ADAPTIVE_RWLOCKS) || defined(KDTRACE_HOOKS) + struct lock_delay_arg lda; +#endif #ifdef KDTRACE_HOOKS uintptr_t state; - uint64_t spin_cnt = 0; - uint64_t sleep_cnt = 0; + u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif @@ -366,6 +396,11 @@ __rw_rlock(volatile uintptr_t *c, const if (SCHEDULER_STOPPED()) return; +#if defined(ADAPTIVE_RWLOCKS) + lock_delay_arg_init(&lda, &rw_delay); +#elif defined(KDTRACE_HOOKS) + lock_delay_arg_init(&lda, NULL); +#endif rw = rwlock2rw(c); KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), @@ -383,9 +418,6 @@ __rw_rlock(volatile uintptr_t *c, const state = rw->rw_lock; #endif for (;;) { -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif /* * Handle the easy case. If no other thread has a write * lock, then try to bump up the count of read locks. Note @@ -414,6 +446,9 @@ __rw_rlock(volatile uintptr_t *c, const } continue; } +#ifdef KDTRACE_HOOKS + lda.spin_cnt++; +#endif #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif @@ -437,12 +472,8 @@ __rw_rlock(volatile uintptr_t *c, const sched_tdname(curthread), "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); while ((struct thread*)RW_OWNER(rw->rw_lock) == - owner && TD_IS_RUNNING(owner)) { - cpu_spinwait(); -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif - } + owner && TD_IS_RUNNING(owner)) + lock_delay(&lda); KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); continue; @@ -458,6 +489,9 @@ __rw_rlock(volatile uintptr_t *c, const break; cpu_spinwait(); } +#ifdef KDTRACE_HOOKS + lda.spin_cnt += rowner_loops - i; +#endif KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); if (i != rowner_loops) @@ -549,7 +583,7 @@ __rw_rlock(volatile uintptr_t *c, const (state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state)); /* Record only the loops spinning and not sleeping. */ - if (spin_cnt > sleep_cnt) + if (lda.spin_cnt > sleep_cnt) LOCKSTAT_RECORD4(LS_RW_RLOCK_SPIN, rw, all_time - sleep_time, LOCKSTAT_READER, (state & RW_LOCK_READ) == 0, (state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state)); @@ -737,10 +771,12 @@ __rw_wlock_hard(volatile uintptr_t *c, u uint64_t waittime = 0; int contested = 0; #endif +#if defined(ADAPTIVE_RWLOCKS) || defined(KDTRACE_HOOKS) + struct lock_delay_arg lda; +#endif #ifdef KDTRACE_HOOKS uintptr_t state; - uint64_t spin_cnt = 0; - uint64_t sleep_cnt = 0; + u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif @@ -748,6 +784,11 @@ __rw_wlock_hard(volatile uintptr_t *c, u if (SCHEDULER_STOPPED()) return; +#if defined(ADAPTIVE_RWLOCKS) + lock_delay_arg_init(&lda, &rw_delay); +#elif defined(KDTRACE_HOOKS) + lock_delay_arg_init(&lda, NULL); +#endif rw = rwlock2rw(c); if (rw_wlocked(rw)) { @@ -772,7 +813,7 @@ __rw_wlock_hard(volatile uintptr_t *c, u if (rw->rw_lock == RW_UNLOCKED && _rw_write_lock(rw, tid)) break; #ifdef KDTRACE_HOOKS - spin_cnt++; + lda.spin_cnt++; #endif #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); @@ -795,12 +836,8 @@ __rw_wlock_hard(volatile uintptr_t *c, u "spinning", "lockname:\"%s\"", rw->lock_object.lo_name); while ((struct thread*)RW_OWNER(rw->rw_lock) == owner && - TD_IS_RUNNING(owner)) { - cpu_spinwait(); -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif - } + TD_IS_RUNNING(owner)) + lock_delay(&lda); KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); continue; @@ -825,7 +862,7 @@ __rw_wlock_hard(volatile uintptr_t *c, u KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); #ifdef KDTRACE_HOOKS - spin_cnt += rowner_loops - i; + lda.spin_cnt += rowner_loops - i; #endif if (i != rowner_loops) continue; @@ -915,9 +952,9 @@ __rw_wlock_hard(volatile uintptr_t *c, u (state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state)); /* Record only the loops spinning and not sleeping. */ - if (spin_cnt > sleep_cnt) + if (lda.spin_cnt > sleep_cnt) LOCKSTAT_RECORD4(LS_RW_WLOCK_SPIN, rw, all_time - sleep_time, - LOCKSTAT_READER, (state & RW_LOCK_READ) == 0, + LOCKSTAT_WRITER, (state & RW_LOCK_READ) == 0, (state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state)); #endif LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE, rw, contested, Modified: stable/10/sys/kern/kern_sx.c ============================================================================== --- stable/10/sys/kern/kern_sx.c Sat Dec 31 16:37:47 2016 (r310979) +++ stable/10/sys/kern/kern_sx.c Sat Dec 31 16:57:05 2016 (r310980) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #if defined(SMP) && !defined(NO_ADAPTIVE_SX) @@ -147,6 +149,33 @@ static u_int asx_loops = 10000; static SYSCTL_NODE(_debug, OID_AUTO, sx, CTLFLAG_RD, NULL, "sxlock debugging"); SYSCTL_UINT(_debug_sx, OID_AUTO, retries, CTLFLAG_RW, &asx_retries, 0, ""); SYSCTL_UINT(_debug_sx, OID_AUTO, loops, CTLFLAG_RW, &asx_loops, 0, ""); + +static struct lock_delay_config sx_delay = { + .initial = 1000, + .step = 500, + .min = 100, + .max = 5000, +}; + +SYSCTL_INT(_debug_sx, OID_AUTO, delay_initial, CTLFLAG_RW, &sx_delay.initial, + 0, ""); +SYSCTL_INT(_debug_sx, OID_AUTO, delay_step, CTLFLAG_RW, &sx_delay.step, + 0, ""); +SYSCTL_INT(_debug_sx, OID_AUTO, delay_min, CTLFLAG_RW, &sx_delay.min, + 0, ""); +SYSCTL_INT(_debug_sx, OID_AUTO, delay_max, CTLFLAG_RW, &sx_delay.max, + 0, ""); + +static void +sx_delay_sysinit(void *dummy) +{ + + sx_delay.initial = mp_ncpus * 25; + sx_delay.step = (mp_ncpus * 25) / 2; + sx_delay.min = mp_ncpus * 5; + sx_delay.max = mp_ncpus * 25 * 10; +} +LOCK_DELAY_SYSINIT(sx_delay_sysinit); #endif void @@ -516,10 +545,12 @@ _sx_xlock_hard(struct sx *sx, uintptr_t int contested = 0; #endif int error = 0; +#if defined(ADAPTIVE_SX) || defined(KDTRACE_HOOKS) + struct lock_delay_arg lda; +#endif #ifdef KDTRACE_HOOKS uintptr_t state; - uint64_t spin_cnt = 0; - uint64_t sleep_cnt = 0; + u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif @@ -527,6 +558,12 @@ _sx_xlock_hard(struct sx *sx, uintptr_t if (SCHEDULER_STOPPED()) return (0); +#if defined(ADAPTIVE_SX) + lock_delay_arg_init(&lda, &sx_delay); +#elif defined(KDTRACE_HOOKS) + lock_delay_arg_init(&lda, NULL); +#endif + /* If we already hold an exclusive lock, then recurse. */ if (sx_xlocked(sx)) { KASSERT((sx->lock_object.lo_flags & LO_RECURSABLE) != 0, @@ -552,7 +589,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) break; #ifdef KDTRACE_HOOKS - spin_cnt++; + lda.spin_cnt++; #endif #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); @@ -581,12 +618,8 @@ _sx_xlock_hard(struct sx *sx, uintptr_t sx->lock_object.lo_name); GIANT_SAVE(); while (SX_OWNER(sx->sx_lock) == x && - TD_IS_RUNNING(owner)) { - cpu_spinwait(); -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif - } + TD_IS_RUNNING(owner)) + lock_delay(&lda); KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); continue; @@ -608,7 +641,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t break; cpu_spinwait(); #ifdef KDTRACE_HOOKS - spin_cnt++; + lda.spin_cnt++; #endif } KTR_STATE0(KTR_SCHED, "thread", @@ -728,7 +761,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t LOCKSTAT_RECORD4(LS_SX_XLOCK_BLOCK, sx, sleep_time, LOCKSTAT_WRITER, (state & SX_LOCK_SHARED) == 0, (state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state)); - if (spin_cnt > sleep_cnt) + if (lda.spin_cnt > sleep_cnt) LOCKSTAT_RECORD4(LS_SX_XLOCK_SPIN, sx, all_time - sleep_time, LOCKSTAT_WRITER, (state & SX_LOCK_SHARED) == 0, (state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state)); @@ -821,10 +854,12 @@ _sx_slock_hard(struct sx *sx, int opts, #endif uintptr_t x; int error = 0; +#if defined(ADAPTIVE_SX) || defined(KDTRACE_HOOKS) + struct lock_delay_arg lda; +#endif #ifdef KDTRACE_HOOKS uintptr_t state; - uint64_t spin_cnt = 0; - uint64_t sleep_cnt = 0; + u_int sleep_cnt = 0; int64_t sleep_time = 0; int64_t all_time = 0; #endif @@ -832,6 +867,11 @@ _sx_slock_hard(struct sx *sx, int opts, if (SCHEDULER_STOPPED()) return (0); +#if defined(ADAPTIVE_SX) + lock_delay_arg_init(&lda, &sx_delay); +#elif defined(KDTRACE_HOOKS) + lock_delay_arg_init(&lda, NULL); +#endif #ifdef KDTRACE_HOOKS state = sx->sx_lock; all_time -= lockstat_nsecs(&sx->lock_object); @@ -843,7 +883,7 @@ _sx_slock_hard(struct sx *sx, int opts, */ for (;;) { #ifdef KDTRACE_HOOKS - spin_cnt++; + lda.spin_cnt++; #endif x = sx->sx_lock; @@ -891,12 +931,8 @@ _sx_slock_hard(struct sx *sx, int opts, "lockname:\"%s\"", sx->lock_object.lo_name); GIANT_SAVE(); while (SX_OWNER(sx->sx_lock) == x && - TD_IS_RUNNING(owner)) { -#ifdef KDTRACE_HOOKS - spin_cnt++; -#endif - cpu_spinwait(); - } + TD_IS_RUNNING(owner)) + lock_delay(&lda); KTR_STATE0(KTR_SCHED, "thread", sched_tdname(curthread), "running"); continue; @@ -992,7 +1028,7 @@ _sx_slock_hard(struct sx *sx, int opts, LOCKSTAT_RECORD4(LS_SX_SLOCK_BLOCK, sx, sleep_time, LOCKSTAT_READER, (state & SX_LOCK_SHARED) == 0, (state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state)); - if (spin_cnt > sleep_cnt) + if (lda.spin_cnt > sleep_cnt) LOCKSTAT_RECORD4(LS_SX_SLOCK_SPIN, sx, all_time - sleep_time, LOCKSTAT_READER, (state & SX_LOCK_SHARED) == 0, (state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state)); Modified: stable/10/sys/kern/subr_lock.c ============================================================================== --- stable/10/sys/kern/subr_lock.c Sat Dec 31 16:37:47 2016 (r310979) +++ stable/10/sys/kern/subr_lock.c Sat Dec 31 16:57:05 2016 (r310980) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #endif #include +#include CTASSERT(LOCK_CLASS_MAX == 15); @@ -103,6 +104,34 @@ lock_destroy(struct lock_object *lock) lock->lo_flags &= ~LO_INITIALIZED; } +void +lock_delay(struct lock_delay_arg *la) +{ + u_int i, delay, backoff, min, max; + struct lock_delay_config *lc = la->config; + + delay = la->delay; + + if (delay == 0) + delay = lc->initial; + else { + delay += lc->step; + max = lc->max; + if (delay > max) + delay = max; + } + + backoff = cpu_ticks() % delay; + min = lc->min; + if (backoff < min) + backoff = min; + for (i = 0; i < backoff; i++) + cpu_spinwait(); + + la->delay = delay; + la->spin_cnt += backoff; +} + #ifdef DDB DB_SHOW_COMMAND(lock, db_show_lock) { Modified: stable/10/sys/sys/lock.h ============================================================================== --- stable/10/sys/sys/lock.h Sat Dec 31 16:37:47 2016 (r310979) +++ stable/10/sys/sys/lock.h Sat Dec 31 16:57:05 2016 (r310980) @@ -199,9 +199,33 @@ extern struct lock_class lock_class_lock extern struct lock_class *lock_classes[]; +struct lock_delay_config { + u_int initial; + u_int step; + u_int min; + u_int max; +}; + +struct lock_delay_arg { + struct lock_delay_config *config; + u_int delay; + u_int spin_cnt; +}; + +static inline void +lock_delay_arg_init(struct lock_delay_arg *la, struct lock_delay_config *lc) { + la->config = lc; + la->delay = 0; + la->spin_cnt = 0; +} + +#define LOCK_DELAY_SYSINIT(func) \ + SYSINIT(func##_ld, SI_SUB_LOCK, SI_ORDER_ANY, func, NULL) + void lock_init(struct lock_object *, struct lock_class *, const char *, const char *, int); void lock_destroy(struct lock_object *); +void lock_delay(struct lock_delay_arg *); void spinlock_enter(void); void spinlock_exit(void); void witness_init(struct lock_object *, const char *);