From owner-svn-src-stable-10@freebsd.org Sun Oct 8 20:55:50 2017 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 2E0A2E3FDD8; Sun, 8 Oct 2017 20:55:50 +0000 (UTC) (envelope-from mm@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 89FC668B01; Sun, 8 Oct 2017 20:55:49 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v98Ktm3G079223; Sun, 8 Oct 2017 20:55:48 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v98Ktj9O079189; Sun, 8 Oct 2017 20:55:45 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201710082055.v98Ktj9O079189@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Sun, 8 Oct 2017 20:55:45 +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: r324418 - in stable/10: contrib/libarchive/cat/test contrib/libarchive/cpio contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarch... X-SVN-Group: stable-10 X-SVN-Commit-Author: mm X-SVN-Commit-Paths: in stable/10: contrib/libarchive/cat/test contrib/libarchive/cpio contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchiv... X-SVN-Commit-Revision: 324418 X-SVN-Commit-Repository: base 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, 08 Oct 2017 20:55:50 -0000 Author: mm Date: Sun Oct 8 20:55:45 2017 New Revision: 324418 URL: https://svnweb.freebsd.org/changeset/base/324418 Log: MFH r324148: Sync libarchive with vendor. Relevant vendor changes: PR #905: Support for Zstandard read and write filters PR #922: Avoid overflow when reading corrupt cpio archive Issue #935: heap-based buffer overflow in xml_data (CVE-2017-14166) OSS-Fuzz 2936: Place a limit on the mtree line length OSS-Fuzz 2394: Ensure that the ZIP AES extension header is large enough OSS-Fuzz 573: Read off-by-one error in RAR archives (CVE-2017-14502) Security: CVE-2017-14166, CVE-2017-14502 Added: stable/10/contrib/libarchive/cat/test/test_empty.zst.uu - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu stable/10/contrib/libarchive/cat/test/test_empty_zstd.c - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c stable/10/contrib/libarchive/cat/test/test_expand.zst.uu - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu stable/10/contrib/libarchive/cat/test/test_expand_zstd.c - copied unchanged from r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c stable/10/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu stable/10/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c stable/10/contrib/libarchive/cpio/test/test_option_zstd.c - copied unchanged from r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c - copied unchanged from r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c - copied unchanged from r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c stable/10/contrib/libarchive/libarchive/test/test_compat_zstd.c - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_compat_zstd.c stable/10/contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu stable/10/contrib/libarchive/libarchive/test/test_write_filter_zstd.c - copied unchanged from r324148, head/contrib/libarchive/libarchive/test/test_write_filter_zstd.c stable/10/contrib/libarchive/tar/test/test_extract.tar.zst.uu - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_extract.tar.zst.uu stable/10/contrib/libarchive/tar/test/test_extract_tar_zstd.c - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_extract_tar_zstd.c stable/10/contrib/libarchive/tar/test/test_option_zstd.c - copied unchanged from r324148, head/contrib/libarchive/tar/test/test_option_zstd.c Modified: stable/10/contrib/libarchive/cpio/bsdcpio.1 stable/10/contrib/libarchive/cpio/cmdline.c stable/10/contrib/libarchive/cpio/cpio.c stable/10/contrib/libarchive/cpio/cpio.h stable/10/contrib/libarchive/libarchive/archive.h stable/10/contrib/libarchive/libarchive/archive_cmdline.c stable/10/contrib/libarchive/libarchive/archive_platform.h stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c stable/10/contrib/libarchive/libarchive/archive_read_filter.3 stable/10/contrib/libarchive/libarchive/archive_read_support_filter_all.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c stable/10/contrib/libarchive/libarchive/archive_string.c stable/10/contrib/libarchive/libarchive/archive_version_details.c stable/10/contrib/libarchive/libarchive/archive_write.3 stable/10/contrib/libarchive/libarchive/archive_write_add_filter.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c stable/10/contrib/libarchive/libarchive/archive_write_filter.3 stable/10/contrib/libarchive/libarchive/archive_write_set_format_pax.c stable/10/contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c stable/10/contrib/libarchive/libarchive/test/test_fuzz.c stable/10/contrib/libarchive/tar/bsdtar.1 stable/10/contrib/libarchive/tar/bsdtar.c stable/10/contrib/libarchive/tar/bsdtar.h stable/10/contrib/libarchive/tar/cmdline.c stable/10/contrib/libarchive/tar/creation_set.c stable/10/contrib/libarchive/tar/test/test_option_acls.c stable/10/contrib/libarchive/test_utils/test_common.h stable/10/contrib/libarchive/test_utils/test_main.c stable/10/lib/libarchive/Makefile stable/10/lib/libarchive/tests/Makefile stable/10/usr.bin/bsdcat/tests/Makefile stable/10/usr.bin/cpio/tests/Makefile stable/10/usr.bin/tar/tests/Makefile Directory Properties: stable/10/ (props changed) Copied: stable/10/contrib/libarchive/cat/test/test_empty.zst.uu (from r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cat/test/test_empty.zst.uu Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cat/test/test_empty.zst.uu) @@ -0,0 +1,4 @@ +begin 644 test_empty.zst +-*+4O_010`0``F>G840`` +` +end Copied: stable/10/contrib/libarchive/cat/test/test_empty_zstd.c (from r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cat/test/test_empty_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cat/test/test_empty_zstd.c) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * 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(S) ``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(S) 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 "test.h" + +DEFINE_TEST(test_empty_zstd) +{ + const char *reffile = "test_empty.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, f); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } +} Copied: stable/10/contrib/libarchive/cat/test/test_expand.zst.uu (from r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cat/test/test_expand.zst.uu Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cat/test/test_expand.zst.uu) @@ -0,0 +1,4 @@ +begin 644 test_expand.zst +J*+4O_010Z0``8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N>G-T+@J;23#F +` +end Copied: stable/10/contrib/libarchive/cat/test/test_expand_zstd.c (from r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cat/test/test_expand_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cat/test/test_expand_zstd.c) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * 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(S) ``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(S) 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 "test.h" + +DEFINE_TEST(test_expand_zstd) +{ + const char *reffile = "test_expand.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, f); + assertTextFileContents("contents of test_expand.zst.\n", "test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } +} Modified: stable/10/contrib/libarchive/cpio/bsdcpio.1 ============================================================================== --- stable/10/contrib/libarchive/cpio/bsdcpio.1 Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/cpio/bsdcpio.1 Sun Oct 8 20:55:45 2017 (r324418) @@ -187,6 +187,11 @@ In input mode, this option is ignored. Compress the archive with lz4-compatible compression before writing it. In input mode, this option is ignored; lz4 compression is recognized automatically on input. +.It Fl Fl zstd +(o mode only) +Compress the archive with zstd-compatible compression before writing it. +In input mode, this option is ignored; zstd compression is recognized +automatically on input. .It Fl Fl lzma (o mode only) Compress the file with lzma-compatible compression before writing it. Modified: stable/10/contrib/libarchive/cpio/cmdline.c ============================================================================== --- stable/10/contrib/libarchive/cpio/cmdline.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/cpio/cmdline.c Sun Oct 8 20:55:45 2017 (r324418) @@ -92,6 +92,7 @@ static const struct option { { "verbose", 0, 'v' }, { "version", 0, OPTION_VERSION }, { "xz", 0, 'J' }, + { "zstd", 0, OPTION_ZSTD }, { NULL, 0, 0 } }; Modified: stable/10/contrib/libarchive/cpio/cpio.c ============================================================================== --- stable/10/contrib/libarchive/cpio/cpio.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/cpio/cpio.c Sun Oct 8 20:55:45 2017 (r324418) @@ -269,6 +269,7 @@ main(int argc, char *argv[]) case OPTION_LZ4: case OPTION_LZMA: /* GNU tar, others */ case OPTION_LZOP: /* GNU tar, others */ + case OPTION_ZSTD: cpio->compress = opt; break; case 'm': /* POSIX 1997 */ @@ -545,6 +546,9 @@ mode_out(struct cpio *cpio) break; case OPTION_LZOP: r = archive_write_add_filter_lzop(cpio->archive); + break; + case OPTION_ZSTD: + r = archive_write_add_filter_zstd(cpio->archive); break; case 'j': case 'y': r = archive_write_add_filter_bzip2(cpio->archive); Modified: stable/10/contrib/libarchive/cpio/cpio.h ============================================================================== --- stable/10/contrib/libarchive/cpio/cpio.h Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/cpio/cpio.h Sun Oct 8 20:55:45 2017 (r324418) @@ -111,7 +111,8 @@ enum { OPTION_PRESERVE_OWNER, OPTION_QUIET, OPTION_UUENCODE, - OPTION_VERSION + OPTION_VERSION, + OPTION_ZSTD, }; int cpio_getopt(struct cpio *cpio); Copied: stable/10/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu (from r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cpio/test/test_extract.cpio.zst.uu) @@ -0,0 +1,6 @@ +begin 644 test_extract.cpio.zst +M*+4O_01090,`,@41%X")&@#'G6T\K16_MR)#=DK)5:.1,2J0HY2"!(1!`!7R +M$(UB`2"*D41;J2UF&)<0!Y7X'TU<%W.\W^R]GO-WW^OO^QX0`%P<]30-!#U` +?!KD!`#XP,_`U4`HT3+RF:#!7Y\V@R)5"7P"^;WEUK@`` +` +end Copied: stable/10/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c (from r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cpio/test/test_extract_cpio_zstd.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * 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(S) ``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(S) 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 "test.h" +__FBSDID("$FreeBSD$"); + +DEFINE_TEST(test_extract_cpio_zstd) +{ + const char *reffile = "test_extract.cpio.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertTextFileContents("1 block\n", "test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } +} Copied: stable/10/contrib/libarchive/cpio/test/test_option_zstd.c (from r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cpio/test/test_option_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/cpio/test/test_option_zstd.c) @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * 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(S) ``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(S) 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 "test.h" +__FBSDID("$FreeBSD$"); + +DEFINE_TEST(test_option_zstd) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with zstd compression. */ + r = systemf("echo f | %s -o --zstd >archive.out 2>archive.err", + testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (strstr(p, "Unsupported compression") != NULL) { + skipping("This version of bsdcpio was compiled " + "without zstd support"); + goto done; + } + /* POSIX permits different handling of the spawnp + * system call used to launch the subsidiary + * program: */ + /* Some systems fail immediately to spawn the new process. */ + if (strstr(p, "Can't launch") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* Some systems successfully spawn the new process, + * but fail to exec a program within that process. + * This results in failure at the first attempt to + * write. */ + if (strstr(p, "Can't write") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* On some systems the error won't be detected until closing + time, by a 127 exit error returned by waitpid. */ + if (strstr(p, "Error closing") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + return; + } + failure("--zstd option is broken: %s", p); + assertEqualInt(r, 0); + goto done; + } + free(p); + /* Check that the archive file has an zstd signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x28\xb5\x2f\xfd", 4); + +done: + free(p); +} Modified: stable/10/contrib/libarchive/libarchive/archive.h ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive.h Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive.h Sun Oct 8 20:55:45 2017 (r324418) @@ -177,6 +177,7 @@ __LA_DECL const char * archive_zlib_version(void); __LA_DECL const char * archive_liblzma_version(void); __LA_DECL const char * archive_bzlib_version(void); __LA_DECL const char * archive_liblz4_version(void); +__LA_DECL const char * archive_libzstd_version(void); /* Declare our basic types. */ struct archive; @@ -276,6 +277,7 @@ typedef const char *archive_passphrase_callback(struct #define ARCHIVE_FILTER_LZOP 11 #define ARCHIVE_FILTER_GRZIP 12 #define ARCHIVE_FILTER_LZ4 13 +#define ARCHIVE_FILTER_ZSTD 14 #if ARCHIVE_VERSION_NUMBER < 4000000 #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE @@ -433,6 +435,7 @@ __LA_DECL int archive_read_support_filter_program_sign __LA_DECL int archive_read_support_filter_rpm(struct archive *); __LA_DECL int archive_read_support_filter_uu(struct archive *); __LA_DECL int archive_read_support_filter_xz(struct archive *); +__LA_DECL int archive_read_support_filter_zstd(struct archive *); __LA_DECL int archive_read_support_format_7zip(struct archive *); __LA_DECL int archive_read_support_format_all(struct archive *); @@ -778,6 +781,7 @@ __LA_DECL int archive_write_add_filter_program(struct const char *cmd); __LA_DECL int archive_write_add_filter_uuencode(struct archive *); __LA_DECL int archive_write_add_filter_xz(struct archive *); +__LA_DECL int archive_write_add_filter_zstd(struct archive *); /* A convenience function to set the format based on the code or name. */ Modified: stable/10/contrib/libarchive/libarchive/archive_cmdline.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_cmdline.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_cmdline.c Sun Oct 8 20:55:45 2017 (r324418) @@ -100,10 +100,10 @@ get_argument(struct archive_string *as, const char *p) /* * Set up command line arguments. - * Returns ARChIVE_OK if everything okey. - * Returns ARChIVE_FAILED if there is a lack of the `"' terminator or an + * Returns ARCHIVE_OK if everything okey. + * Returns ARCHIVE_FAILED if there is a lack of the `"' terminator or an * empty command line. - * Returns ARChIVE_FATAL if no memory. + * Returns ARCHIVE_FATAL if no memory. */ int __archive_cmdline_parse(struct archive_cmdline *data, const char *cmd) Modified: stable/10/contrib/libarchive/libarchive/archive_platform.h ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_platform.h Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_platform.h Sun Oct 8 20:55:45 2017 (r324418) @@ -52,6 +52,17 @@ #error Oops: No config.h and no pre-built configuration in archive_platform.h. #endif +/* On macOS check for some symbols based on the deployment target version. */ +#if defined(__APPLE__) +# undef HAVE_FUTIMENS +# undef HAVE_UTIMENSAT +# include +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +# define HAVE_FUTIMENS 1 +# define HAVE_UTIMENSAT 1 +# endif +#endif + /* It should be possible to get rid of this by extending the feature-test * macros to cover Windows API functions, probably along with non-trivial * refactoring of code to find structures that sit more cleanly on top of Modified: stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c Sun Oct 8 20:55:45 2017 (r324418) @@ -89,6 +89,10 @@ archive_read_append_filter(struct archive *_a, int cod strcpy(str, "lz4"); r1 = archive_read_support_filter_lz4(_a); break; + case ARCHIVE_FILTER_ZSTD: + strcpy(str, "zstd"); + r1 = archive_read_support_filter_zstd(_a); + break; case ARCHIVE_FILTER_LZIP: strcpy(str, "lzip"); r1 = archive_read_support_filter_lzip(_a); Modified: stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Sun Oct 8 20:55:45 2017 (r324418) @@ -127,7 +127,7 @@ archive_read_disk_entry_setup_acls(struct archive_read /* * Enter working directory and return working pathname of archive_entry. * If a pointer to an integer is provided and its value is below zero - * open a file descriptor on this pahtname. + * open a file descriptor on this pathname. */ const char * archive_read_disk_entry_setup_path(struct archive_read_disk *a, Modified: stable/10/contrib/libarchive/libarchive/archive_read_filter.3 ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_filter.3 Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_filter.3 Sun Oct 8 20:55:45 2017 (r324418) @@ -38,6 +38,7 @@ .Nm archive_read_support_filter_rpm , .Nm archive_read_support_filter_uu , .Nm archive_read_support_filter_xz , +.Nm archive_read_support_filter_zstd , .Nm archive_read_support_filter_program , .Nm archive_read_support_filter_program_signature .Nd functions for reading streaming archives @@ -73,6 +74,8 @@ Streaming Archive Library (libarchive, -larchive) .Ft int .Fn archive_read_support_filter_xz "struct archive *" .Ft int +.Fn archive_read_support_filter_zstd "struct archive *" +.Ft int .Fo archive_read_support_filter_program .Fa "struct archive *" .Fa "const char *cmd" @@ -99,7 +102,8 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_read_support_filter_none , .Fn archive_read_support_filter_rpm , .Fn archive_read_support_filter_uu , -.Fn archive_read_support_filter_xz +.Fn archive_read_support_filter_xz , +.Fn archive_read_support_filter_zstd , .Xc Enables auto-detection code and decompression support for the specified compression. Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_filter_all.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_filter_all.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_filter_all.c Sun Oct 8 20:55:45 2017 (r324418) @@ -71,6 +71,8 @@ archive_read_support_filter_all(struct archive *a) archive_read_support_filter_grzip(a); /* Lz4 falls back to "lz4 -d" command-line program. */ archive_read_support_filter_lz4(a); + /* Zstd falls back to "zstd -d" command-line program. */ + archive_read_support_filter_zstd(a); /* Note: We always return ARCHIVE_OK here, even if some of the * above return ARCHIVE_WARN. The intent here is to enable Copied: stable/10/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c (from r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/libarchive/archive_read_support_filter_zstd.c) @@ -0,0 +1,292 @@ +/*- + * Copyright (c) 2009-2011 Sean Purcell + * 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(S) ``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(S) 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 "archive_platform.h" + +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_ERRNO_H +#include +#endif + +#ifdef HAVE_ERRNO_H +#include +#endif +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#if HAVE_ZSTD_H +#include +#endif + +#include "archive.h" +#include "archive_endian.h" +#include "archive_private.h" +#include "archive_read_private.h" + +#if HAVE_ZSTD_H && HAVE_LIBZSTD + +struct private_data { + ZSTD_DStream *dstream; + unsigned char *out_block; + size_t out_block_size; + int64_t total_out; + char in_frame; /* True = in the middle of a zstd frame. */ + char eof; /* True = found end of compressed data. */ +}; + +/* Zstd Filter. */ +static ssize_t zstd_filter_read(struct archive_read_filter *, const void**); +static int zstd_filter_close(struct archive_read_filter *); +#endif + +/* + * Note that we can detect zstd compressed files even if we can't decompress + * them. (In fact, we like detecting them because we can give better error + * messages.) So the bid framework here gets compiled even if no zstd library + * is available. + */ +static int zstd_bidder_bid(struct archive_read_filter_bidder *, + struct archive_read_filter *); +static int zstd_bidder_init(struct archive_read_filter *); + +int +archive_read_support_filter_zstd(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + struct archive_read_filter_bidder *bidder; + + archive_check_magic(_a, ARCHIVE_READ_MAGIC, + ARCHIVE_STATE_NEW, "archive_read_support_filter_zstd"); + + if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK) + return (ARCHIVE_FATAL); + + bidder->data = NULL; + bidder->name = "zstd"; + bidder->bid = zstd_bidder_bid; + bidder->init = zstd_bidder_init; + bidder->options = NULL; + bidder->free = NULL; +#if HAVE_ZSTD_H && HAVE_LIBZSTD + return (ARCHIVE_OK); +#else + archive_set_error(_a, ARCHIVE_ERRNO_MISC, + "Using external zstd program for zstd decompression"); + return (ARCHIVE_WARN); +#endif +} + +/* + * Test whether we can handle this data. + */ +static int +zstd_bidder_bid(struct archive_read_filter_bidder *self, + struct archive_read_filter *filter) +{ + const unsigned char *buffer; + ssize_t avail; + unsigned prefix; + + /* Zstd frame magic values */ + const unsigned zstd_magic = 0xFD2FB528U; + + (void) self; /* UNUSED */ + + buffer = __archive_read_filter_ahead(filter, 4, &avail); + if (buffer == NULL) + return (0); + + prefix = archive_le32dec(buffer); + if (prefix == zstd_magic) + return (32); + + return (0); +} + +#if !(HAVE_ZSTD_H && HAVE_LIBZSTD) + +/* + * If we don't have the library on this system, we can't do the + * decompression directly. We can, however, try to run "zstd -d" + * in case that's available. + */ +static int +zstd_bidder_init(struct archive_read_filter *self) +{ + int r; + + r = __archive_read_program(self, "zstd -d -qq"); + /* Note: We set the format here even if __archive_read_program() + * above fails. We do, after all, know what the format is + * even if we weren't able to read it. */ + self->code = ARCHIVE_FILTER_ZSTD; + self->name = "zstd"; + return (r); +} + +#else + +/* + * Initialize the filter object + */ +static int +zstd_bidder_init(struct archive_read_filter *self) +{ + struct private_data *state; + const size_t out_block_size = ZSTD_DStreamOutSize(); + void *out_block; + ZSTD_DStream *dstream; + + self->code = ARCHIVE_FILTER_ZSTD; + self->name = "zstd"; + + state = (struct private_data *)calloc(sizeof(*state), 1); + out_block = (unsigned char *)malloc(out_block_size); + dstream = ZSTD_createDStream(); + + if (state == NULL || out_block == NULL || dstream == NULL) { + free(out_block); + free(state); + ZSTD_freeDStream(dstream); /* supports free on NULL */ + archive_set_error(&self->archive->archive, ENOMEM, + "Can't allocate data for zstd decompression"); + return (ARCHIVE_FATAL); + } + + self->data = state; + + state->out_block_size = out_block_size; + state->out_block = out_block; + state->dstream = dstream; + self->read = zstd_filter_read; + self->skip = NULL; /* not supported */ + self->close = zstd_filter_close; + + state->eof = 0; + state->in_frame = 0; + + return (ARCHIVE_OK); +} + +static ssize_t +zstd_filter_read(struct archive_read_filter *self, const void **p) +{ + struct private_data *state; + size_t decompressed; + ssize_t avail_in; + ZSTD_outBuffer out; + ZSTD_inBuffer in; + + state = (struct private_data *)self->data; + + out = (ZSTD_outBuffer) { state->out_block, state->out_block_size, 0 }; + + /* Try to fill the output buffer. */ + while (out.pos < out.size && !state->eof) { + if (!state->in_frame) { + const size_t ret = ZSTD_initDStream(state->dstream); + if (ZSTD_isError(ret)) { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Error initializing zstd decompressor: %s", + ZSTD_getErrorName(ret)); + return (ARCHIVE_FATAL); + } + } + in.src = __archive_read_filter_ahead(self->upstream, 1, + &avail_in); + if (avail_in < 0) { + return avail_in; + } + if (in.src == NULL && avail_in == 0) { + if (!state->in_frame) { + /* end of stream */ + state->eof = 1; + break; + } else { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Truncated zstd input"); + return (ARCHIVE_FATAL); + } + } + in.size = avail_in; + in.pos = 0; + + { + const size_t ret = + ZSTD_decompressStream(state->dstream, &out, &in); + + if (ZSTD_isError(ret)) { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Zstd decompression failed: %s", + ZSTD_getErrorName(ret)); + return (ARCHIVE_FATAL); + } + + /* Decompressor made some progress */ + __archive_read_filter_consume(self->upstream, in.pos); + + /* ret guaranteed to be > 0 if frame isn't done yet */ + state->in_frame = (ret != 0); + } + } + + decompressed = out.pos; + state->total_out += decompressed; + if (decompressed == 0) + *p = NULL; + else + *p = state->out_block; + return (decompressed); +} + +/* + * Clean up the decompressor. + */ +static int +zstd_filter_close(struct archive_read_filter *self) +{ + struct private_data *state; + + state = (struct private_data *)self->data; + + ZSTD_freeDStream(state->dstream); + free(state->out_block); + free(state); + + return (ARCHIVE_OK); +} + +#endif /* HAVE_ZLIB_H && HAVE_LIBZSTD */ Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c Sun Oct 8 20:55:45 2017 (r324418) @@ -633,6 +633,13 @@ header_newc(struct archive_read *a, struct cpio *cpio, /* Pad name to 2 more than a multiple of 4. */ *name_pad = (2 - *namelength) & 3; + /* Make sure that the padded name length fits into size_t. */ + if (*name_pad > SIZE_MAX - *namelength) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "cpio archive has invalid namelength"); + return (ARCHIVE_FATAL); + } + /* * Note: entry_bytes_remaining is at least 64 bits and * therefore guaranteed to be big enough for a 33-bit file Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Sun Oct 8 20:55:45 2017 (r324418) @@ -77,6 +77,8 @@ __FBSDID("$FreeBSD$"); #define MTREE_HASHTABLE_SIZE 1024 +#define MAX_LINE_LEN (1024 * 1024) + struct mtree_option { struct mtree_option *next; char *value; @@ -333,6 +335,14 @@ next_line(struct archive_read *a, ssize_t diff = *ravail - *avail; size_t nbytes_req = (*ravail+1023) & ~1023U; ssize_t tested; + + /* + * Place an arbitrary limit on the line length. + * mtree is almost free-form input and without line length limits, + * it can consume a lot of memory. + */ + if (len >= MAX_LINE_LEN) + return (-1); /* Increase reading bytes if it is not enough to at least * new two lines. */ Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c Sun Oct 8 20:55:45 2017 (r324418) @@ -1496,7 +1496,11 @@ read_header(struct archive_read *a, struct archive_ent return (ARCHIVE_FATAL); } filename[filename_size++] = '\0'; - filename[filename_size++] = '\0'; + /* + * Do not increment filename_size here as the computations below + * add the space for the terminating NUL explicitly. + */ + filename[filename_size] = '\0'; /* Decoded unicode form is UTF-16BE, so we have to update a string * conversion object for it. */ Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c Sun Oct 8 20:55:45 2017 (r324418) @@ -2243,7 +2243,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct ta else tar->sparse_list = p; tar->sparse_last = p; - if (remaining < 0 || offset < 0) { + if (remaining < 0 || offset < 0 || offset > INT64_MAX - remaining) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Malformed sparse map data"); return (ARCHIVE_FATAL); } Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c Sun Oct 8 20:55:45 2017 (r324418) @@ -1040,6 +1040,9 @@ atol10(const char *p, size_t char_cnt) uint64_t l; int digit; + if (char_cnt == 0) + return (0); + l = 0; digit = *p - '0'; while (digit >= 0 && digit < 10 && char_cnt-- > 0) { @@ -1054,7 +1057,10 @@ atol8(const char *p, size_t char_cnt) { int64_t l; int digit; - + + if (char_cnt == 0) + return (0); + l = 0; while (char_cnt-- > 0) { if (*p >= '0' && *p <= '7') @@ -2623,6 +2629,14 @@ strappend_base64(struct xar *xar, archive_strncat(as, (const char *)buff, len); } +static int +is_string(const char *known, const char *data, size_t len) +{ + if (strlen(known) != len) + return -1; + return memcmp(data, known, len); +} + static void xml_data(void *userData, const char *s, int len) { @@ -2674,26 +2688,26 @@ xml_data(void *userData, const char *s, int len) archive_strncpy(&(xar->file->symlink), s, len); break; case FILE_TYPE: - if (strncmp("file", s, len) == 0 || - strncmp("hardlink", s, len) == 0) + if (is_string("file", s, len) == 0 || + is_string("hardlink", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFREG; - if (strncmp("directory", s, len) == 0) + if (is_string("directory", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFDIR; - if (strncmp("symlink", s, len) == 0) + if (is_string("symlink", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFLNK; - if (strncmp("character special", s, len) == 0) + if (is_string("character special", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFCHR; - if (strncmp("block special", s, len) == 0) + if (is_string("block special", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFBLK; - if (strncmp("socket", s, len) == 0) + if (is_string("socket", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFSOCK; - if (strncmp("fifo", s, len) == 0) + if (is_string("fifo", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFIFO; xar->file->has |= HAS_TYPE; Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c Sun Oct 8 20:55:45 2017 (r324418) @@ -723,6 +723,11 @@ process_extra(struct archive_read *a, const char *p, s } case 0x9901: /* WinZip AES extra data field. */ + if (datasize < 6) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Incomplete AES field"); + return ARCHIVE_FAILED; + } if (p[offset + 2] == 'A' && p[offset + 3] == 'E') { /* Vendor version. */ zip_entry->aes_extra.vendor = Modified: stable/10/contrib/libarchive/libarchive/archive_string.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_string.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_string.c Sun Oct 8 20:55:45 2017 (r324418) @@ -214,7 +214,8 @@ archive_wstring_append(struct archive_wstring *as, con { if (archive_wstring_ensure(as, as->length + s + 1) == NULL) return (NULL); - wmemmove(as->s + as->length, p, s); + if (s) + wmemmove(as->s + as->length, p, s); as->length += s; as->s[as->length] = 0; return (as); Modified: stable/10/contrib/libarchive/libarchive/archive_version_details.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_version_details.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_version_details.c Sun Oct 8 20:55:45 2017 (r324418) @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_LZ4_H #include #endif +#ifdef HAVE_ZSTD_H +#include +#endif #include "archive.h" #include "archive_private.h" @@ -59,6 +62,7 @@ archive_version_details(void) const char *liblzma = archive_liblzma_version(); const char *bzlib = archive_bzlib_version(); const char *liblz4 = archive_liblz4_version(); + const char *libzstd = archive_libzstd_version(); if (!init) { archive_string_init(&str); @@ -84,6 +88,10 @@ archive_version_details(void) archive_strcat(&str, " liblz4/"); archive_strcat(&str, liblz4); } + if (libzstd) { + archive_strcat(&str, " libzstd/"); + archive_strcat(&str, libzstd); + } } return str.s; } @@ -127,6 +135,16 @@ archive_liblz4_version(void) return NUMBER(LZ4_VERSION_MAJOR) "." NUMBER(LZ4_VERSION_MINOR) "." NUMBER(LZ4_VERSION_RELEASE); #undef NUMBER #undef str +#else + return NULL; +#endif +} + +const char * +archive_libzstd_version(void) +{ +#if HAVE_ZSTD_H && HAVE_LIBZSTD + return ZSTD_VERSION_STRING; #else return NULL; #endif Modified: stable/10/contrib/libarchive/libarchive/archive_write.3 ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_write.3 Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_write.3 Sun Oct 8 20:55:45 2017 (r324418) @@ -71,7 +71,7 @@ support. .\" .Ss Set options See -.Xr archive_read_set_options 3 . +.Xr archive_write_set_options 3 . .\" .Ss Open archive See Modified: stable/10/contrib/libarchive/libarchive/archive_write_add_filter.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_write_add_filter.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_write_add_filter.c Sun Oct 8 20:55:45 2017 (r324418) @@ -53,6 +53,7 @@ struct { int code; int (*setter)(struct archive *); } { ARCHIVE_FILTER_LZOP, archive_write_add_filter_lzip }, { ARCHIVE_FILTER_UU, archive_write_add_filter_uuencode }, { ARCHIVE_FILTER_XZ, archive_write_add_filter_xz }, + { ARCHIVE_FILTER_ZSTD, archive_write_add_filter_zstd }, { -1, NULL } }; Modified: stable/10/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c Sun Oct 8 20:54:53 2017 (r324417) +++ stable/10/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c Sun Oct 8 20:55:45 2017 (r324418) @@ -57,6 +57,7 @@ struct { const char *name; int (*setter)(struct archiv { "lzop", archive_write_add_filter_lzop }, { "uuencode", archive_write_add_filter_uuencode }, { "xz", archive_write_add_filter_xz }, + { "zstd", archive_write_add_filter_zstd }, { NULL, NULL } }; Copied: stable/10/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c (from r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c Sun Oct 8 20:55:45 2017 (r324418, copy of r324148, head/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c) @@ -0,0 +1,335 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * 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(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Tue Oct 10 02:22:37 2017 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 0F988E44239; Tue, 10 Oct 2017 02:22:37 +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 DD241659D4; Tue, 10 Oct 2017 02:22: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 v9A2MZuJ015446; Tue, 10 Oct 2017 02:22:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A2MY6U015429; Tue, 10 Oct 2017 02:22:34 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100222.v9A2MY6U015429@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 02:22: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: r324461 - in stable/10/sys/dev/hyperv: include netvsc pcib storvsc utilities vmbus vmbus/amd64 X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: in stable/10/sys/dev/hyperv: include netvsc pcib storvsc utilities vmbus vmbus/amd64 X-SVN-Commit-Revision: 324461 X-SVN-Commit-Repository: base 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, 10 Oct 2017 02:22:37 -0000 Author: sephe Date: Tue Oct 10 02:22:34 2017 New Revision: 324461 URL: https://svnweb.freebsd.org/changeset/base/324461 Log: MFC 322488 hyperv: Update copyright for the files changed in 2017 Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11982 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hn_nvs.c stable/10/sys/dev/hyperv/netvsc/hn_nvs.h stable/10/sys/dev/hyperv/netvsc/hn_rndis.c stable/10/sys/dev/hyperv/netvsc/hn_rndis.h stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/pcib/vmbus_pcib.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/vmbus.c 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 Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/netvsc/hn_nvs.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_nvs.h Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2010-2012 Citrix Inc. - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * All rights reserved. * Modified: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/pcib/vmbus_pcib.c ============================================================================== --- stable/10/sys/dev/hyperv/pcib/vmbus_pcib.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/pcib/vmbus_pcib.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012 Microsoft Corp. + * Copyright (c) 2009-2012,2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014,2016 Microsoft Corp. + * Copyright (c) 2014,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014,2016 Microsoft Corp. + * Copyright (c) 2014,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_et.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Tue Oct 10 01:31:44 2017 (r324460) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Tue Oct 10 02:22:34 2017 (r324461) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015,2016 Microsoft Corp. + * Copyright (c) 2015,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-stable-10@freebsd.org Tue Oct 10 02:35:06 2017 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 33E0DE4498A; Tue, 10 Oct 2017 02:35:06 +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 0E0A366021; Tue, 10 Oct 2017 02:35:05 +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 v9A2Z54K019798; Tue, 10 Oct 2017 02:35:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A2Z5xK019795; Tue, 10 Oct 2017 02:35:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100235.v9A2Z5xK019795@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 02:35: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: r324462 - in stable/10/sys: net sys X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: in stable/10/sys: net sys X-SVN-Commit-Revision: 324462 X-SVN-Commit-Repository: base 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, 10 Oct 2017 02:35:06 -0000 Author: sephe Date: Tue Oct 10 02:35:04 2017 New Revision: 324462 URL: https://svnweb.freebsd.org/changeset/base/324462 Log: MFC 323170 if: Add ioctls to get RSS key and hash type/function. It will be needed by hn(4) to configure its RSS key and hash type/function in the transparent VF mode in order to match VF's RSS settings. The description of the transparent VF mode and the RSS hash value issue are here: https://svnweb.freebsd.org/base?view=revision&revision=322299 https://svnweb.freebsd.org/base?view=revision&revision=322485 These are generic enough to promise two independent IOCs instead of abusing SIOCGDRVSPEC. Setting RSS key and hash type/function is a different story, which probably requires more discussion. Comment about UDP_{IPV4,IPV6,IPV6_EX} were only in the patch in the review request; these hash types are standardized now. Reviewed by: gallatin Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12174 Modified: stable/10/sys/net/if.c stable/10/sys/net/if.h stable/10/sys/sys/sockio.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/if.c ============================================================================== --- stable/10/sys/net/if.c Tue Oct 10 02:22:34 2017 (r324461) +++ stable/10/sys/net/if.c Tue Oct 10 02:35:04 2017 (r324462) @@ -2632,6 +2632,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, case SIOCGIFMEDIA: case SIOCGIFXMEDIA: case SIOCGIFGENERIC: + case SIOCGIFRSSKEY: + case SIOCGIFRSSHASH: if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); error = (*ifp->if_ioctl)(ifp, cmd, data); Modified: stable/10/sys/net/if.h ============================================================================== --- stable/10/sys/net/if.h Tue Oct 10 02:22:34 2017 (r324461) +++ stable/10/sys/net/if.h Tue Oct 10 02:35:04 2017 (r324462) @@ -534,6 +534,42 @@ struct ifi2creq { uint8_t data[8]; /* read buffer */ }; +/* + * RSS hash. + */ + +#define RSS_FUNC_NONE 0 /* RSS disabled */ +#define RSS_FUNC_PRIVATE 1 /* non-standard */ +#define RSS_FUNC_TOEPLITZ 2 + +#define RSS_TYPE_IPV4 0x00000001 +#define RSS_TYPE_TCP_IPV4 0x00000002 +#define RSS_TYPE_IPV6 0x00000004 +#define RSS_TYPE_IPV6_EX 0x00000008 +#define RSS_TYPE_TCP_IPV6 0x00000010 +#define RSS_TYPE_TCP_IPV6_EX 0x00000020 +#define RSS_TYPE_UDP_IPV4 0x00000040 +#define RSS_TYPE_UDP_IPV6 0x00000080 +#define RSS_TYPE_UDP_IPV6_EX 0x00000100 + +#define RSS_KEYLEN 128 + +struct ifrsskey { + char ifrk_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + uint8_t ifrk_func; /* RSS_FUNC_ */ + uint8_t ifrk_spare0; + uint16_t ifrk_keylen; + uint8_t ifrk_key[RSS_KEYLEN]; +}; + +struct ifrsshash { + char ifrh_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + uint8_t ifrh_func; /* RSS_FUNC_ */ + uint8_t ifrh_spare0; + uint16_t ifrh_spare1; + uint32_t ifrh_types; /* RSS_TYPE_ */ +}; + #endif /* __BSD_VISIBLE */ #ifdef _KERNEL Modified: stable/10/sys/sys/sockio.h ============================================================================== --- stable/10/sys/sys/sockio.h Tue Oct 10 02:22:34 2017 (r324461) +++ stable/10/sys/sys/sockio.h Tue Oct 10 02:35:04 2017 (r324462) @@ -134,4 +134,8 @@ #define SIOCGIFGMEMB _IOWR('i', 138, struct ifgroupreq) /* get members */ #define SIOCGIFXMEDIA _IOWR('i', 139, struct ifmediareq) /* get net xmedia */ +#define SIOCGIFRSSKEY _IOWR('i', 150, struct ifrsskey)/* get RSS key */ +#define SIOCGIFRSSHASH _IOWR('i', 151, struct ifrsshash)/* get the current RSS + type/func settings */ + #endif /* !_SYS_SOCKIO_H_ */ From owner-svn-src-stable-10@freebsd.org Tue Oct 10 02:57:31 2017 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 58A8DE45582; Tue, 10 Oct 2017 02:57:31 +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 2E4A666CD2; Tue, 10 Oct 2017 02:57:31 +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 v9A2vUaT028307; Tue, 10 Oct 2017 02:57:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A2vUOu028306; Tue, 10 Oct 2017 02:57:30 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100257.v9A2vUOu028306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 02:57:30 +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: r324463 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324463 X-SVN-Commit-Repository: base 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, 10 Oct 2017 02:57:31 -0000 Author: sephe Date: Tue Oct 10 02:57:30 2017 New Revision: 324463 URL: https://svnweb.freebsd.org/changeset/base/324463 Log: MFC 323175 hyperv/hn: Implement SIOCGIFRSS{KEY,HASH}. The conditional compiling in the review request is removed, since these IOCTLs will be available in stable/10 and stable/11. Reviewed by: gallatin Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12175 Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c 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 Tue Oct 10 02:35:04 2017 (r324462) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 02:57:30 2017 (r324463) @@ -3303,6 +3303,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr = (struct ifreq *)data, ifr_vf; struct ifnet *vf_ifp; int mask, error = 0; + struct ifrsskey *ifrk; + struct ifrsshash *ifrh; switch (cmd) { case SIOCSIFMTU: @@ -3558,6 +3560,56 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } HN_UNLOCK(sc); error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); + break; + + case SIOCGIFRSSHASH: + ifrh = (struct ifrsshash *)data; + HN_LOCK(sc); + if (sc->hn_rx_ring_inuse == 1) { + HN_UNLOCK(sc); + ifrh->ifrh_func = RSS_FUNC_NONE; + ifrh->ifrh_types = 0; + break; + } + + if (sc->hn_rss_hash & NDIS_HASH_FUNCTION_TOEPLITZ) + ifrh->ifrh_func = RSS_FUNC_TOEPLITZ; + else + ifrh->ifrh_func = RSS_FUNC_PRIVATE; + + ifrh->ifrh_types = 0; + if (sc->hn_rss_hash & NDIS_HASH_IPV4) + ifrh->ifrh_types |= RSS_TYPE_IPV4; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV4) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV4; + if (sc->hn_rss_hash & NDIS_HASH_IPV6) + ifrh->ifrh_types |= RSS_TYPE_IPV6; + if (sc->hn_rss_hash & NDIS_HASH_IPV6_EX) + ifrh->ifrh_types |= RSS_TYPE_IPV6_EX; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6_EX) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6_EX; + HN_UNLOCK(sc); + break; + + case SIOCGIFRSSKEY: + ifrk = (struct ifrsskey *)data; + HN_LOCK(sc); + if (sc->hn_rx_ring_inuse == 1) { + HN_UNLOCK(sc); + ifrk->ifrk_func = RSS_FUNC_NONE; + ifrk->ifrk_keylen = 0; + break; + } + if (sc->hn_rss_hash & NDIS_HASH_FUNCTION_TOEPLITZ) + ifrk->ifrk_func = RSS_FUNC_TOEPLITZ; + else + ifrk->ifrk_func = RSS_FUNC_PRIVATE; + ifrk->ifrk_keylen = NDIS_HASH_KEYSIZE_TOEPLITZ; + memcpy(ifrk->ifrk_key, sc->hn_rss.rss_key, + NDIS_HASH_KEYSIZE_TOEPLITZ); + HN_UNLOCK(sc); break; default: From owner-svn-src-stable-10@freebsd.org Tue Oct 10 03:02:56 2017 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 2CAA4E458C2; Tue, 10 Oct 2017 03:02:56 +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 EEE46673E0; Tue, 10 Oct 2017 03:02:55 +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 v9A32tGk033133; Tue, 10 Oct 2017 03:02:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A32tI7033132; Tue, 10 Oct 2017 03:02:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100302.v9A32tI7033132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 03:02: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: r324464 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324464 X-SVN-Commit-Repository: base 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, 10 Oct 2017 03:02:56 -0000 Author: sephe Date: Tue Oct 10 03:02:54 2017 New Revision: 324464 URL: https://svnweb.freebsd.org/changeset/base/324464 Log: MFC 323176 hyperv/hn: Log RSS capabilities mask. This helps to detect when UDP hash types can be supported. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12177 Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.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 Tue Oct 10 02:57:30 2017 (r324463) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 03:02:54 2017 (r324464) @@ -498,6 +498,8 @@ hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_c caps.ndis_caps); return (EOPNOTSUPP); } + if (bootverbose) + if_printf(sc->hn_ifp, "RSS caps %#x\n", caps.ndis_caps); /* Commit! */ sc->hn_rss_ind_size = indsz; From owner-svn-src-stable-10@freebsd.org Tue Oct 10 03:21:19 2017 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 06D78E46107; Tue, 10 Oct 2017 03:21:19 +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 C647767D24; Tue, 10 Oct 2017 03:21:18 +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 v9A3LIjT038383; Tue, 10 Oct 2017 03:21:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A3LHpZ038379; Tue, 10 Oct 2017 03:21:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100321.v9A3LHpZ038379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 03:21:17 +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: r324465 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324465 X-SVN-Commit-Repository: base 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, 10 Oct 2017 03:21:19 -0000 Author: sephe Date: Tue Oct 10 03:21:17 2017 New Revision: 324465 URL: https://svnweb.freebsd.org/changeset/base/324465 Log: MFC 323727,324316 323727 hyperv/hn: Apply VF's RSS setting Since in Azure SYN and SYN|ACK go through the synthetic parts while the rest of the same TCP flow goes through the VF, apply VF's RSS settings to synthetic parts to have a consistent hash value/type for the same TCP flow. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12333 324316 hyperv/hn: Fix options RSS building Reported by: np Sponsored by: Microsoft 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 stable/10/sys/dev/hyperv/netvsc/ndis.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 Tue Oct 10 03:02:54 2017 (r324464) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 03:21:17 2017 (r324465) @@ -503,7 +503,7 @@ hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_c /* Commit! */ sc->hn_rss_ind_size = indsz; - sc->hn_rss_hash = hash_func | hash_types; + sc->hn_rss_hcap = hash_func | hash_types; *rxr_cnt0 = rxr_cnt; return (0); } Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:02:54 2017 (r324464) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:21:17 2017 (r324465) @@ -279,6 +279,8 @@ static void hn_xpnt_vf_init_taskfunc(void *, int); static void hn_xpnt_vf_init(struct hn_softc *); static void hn_xpnt_vf_setenable(struct hn_softc *); static void hn_xpnt_vf_setdisable(struct hn_softc *, bool); +static void hn_vf_rss_fixup(struct hn_softc *, bool); +static void hn_vf_rss_restore(struct hn_softc *); static int hn_rndis_rxinfo(const void *, int, struct hn_rxinfo *); @@ -320,6 +322,8 @@ static int hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS); 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_rss_hcap_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_mbuf_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); @@ -377,8 +381,11 @@ static int hn_set_rxfilter(struct hn_softc *, uint32 static int hn_rxfilter_config(struct hn_softc *); static int hn_rss_reconfig(struct hn_softc *); static void hn_rss_ind_fixup(struct hn_softc *); +static void hn_rss_mbuf_hash(struct hn_softc *, uint32_t); static int hn_rxpkt(struct hn_rx_ring *, const void *, int, const struct hn_rxinfo *); +static uint32_t hn_rss_type_fromndis(uint32_t); +static uint32_t hn_rss_type_tondis(uint32_t); static int hn_tx_ring_create(struct hn_softc *, int); static void hn_tx_ring_destroy(struct hn_tx_ring *); @@ -1121,11 +1128,13 @@ hn_rxvf_change(struct hn_softc *sc, struct ifnet *ifp, hn_rxvf_set(sc, rxvf ? ifp : NULL); if (rxvf) { + hn_vf_rss_fixup(sc, true); hn_suspend_mgmt(sc); sc->hn_link_flags &= ~(HN_LINK_FLAG_LINKUP | HN_LINK_FLAG_NETCHG); if_link_state_change(hn_ifp, LINK_STATE_DOWN); } else { + hn_vf_rss_restore(sc); hn_resume_mgmt(sc); } @@ -1322,7 +1331,249 @@ hn_mtu_change_fixup(struct hn_softc *sc) #endif } +static uint32_t +hn_rss_type_fromndis(uint32_t rss_hash) +{ + uint32_t types = 0; + + if (rss_hash & NDIS_HASH_IPV4) + types |= RSS_TYPE_IPV4; + if (rss_hash & NDIS_HASH_TCP_IPV4) + types |= RSS_TYPE_TCP_IPV4; + if (rss_hash & NDIS_HASH_IPV6) + types |= RSS_TYPE_IPV6; + if (rss_hash & NDIS_HASH_IPV6_EX) + types |= RSS_TYPE_IPV6_EX; + if (rss_hash & NDIS_HASH_TCP_IPV6) + types |= RSS_TYPE_TCP_IPV6; + if (rss_hash & NDIS_HASH_TCP_IPV6_EX) + types |= RSS_TYPE_TCP_IPV6_EX; + return (types); +} + +static uint32_t +hn_rss_type_tondis(uint32_t types) +{ + uint32_t rss_hash = 0; + + KASSERT((types & + (RSS_TYPE_UDP_IPV4 | RSS_TYPE_UDP_IPV6 | RSS_TYPE_UDP_IPV6_EX)) == 0, + ("UDP4, UDP6 and UDP6EX are not supported")); + + if (types & RSS_TYPE_IPV4) + rss_hash |= NDIS_HASH_IPV4; + if (types & RSS_TYPE_TCP_IPV4) + rss_hash |= NDIS_HASH_TCP_IPV4; + if (types & RSS_TYPE_IPV6) + rss_hash |= NDIS_HASH_IPV6; + if (types & RSS_TYPE_IPV6_EX) + rss_hash |= NDIS_HASH_IPV6_EX; + if (types & RSS_TYPE_TCP_IPV6) + rss_hash |= NDIS_HASH_TCP_IPV6; + if (types & RSS_TYPE_TCP_IPV6_EX) + rss_hash |= NDIS_HASH_TCP_IPV6_EX; + return (rss_hash); +} + static void +hn_rss_mbuf_hash(struct hn_softc *sc, uint32_t mbuf_hash) +{ + int i; + + HN_LOCK_ASSERT(sc); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_mbuf_hash = mbuf_hash; +} + +static void +hn_vf_rss_fixup(struct hn_softc *sc, bool reconf) +{ + struct ifnet *ifp, *vf_ifp; + struct ifrsshash ifrh; + struct ifrsskey ifrk; + int error; + uint32_t my_types, diff_types, mbuf_types = 0; + + HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("%s: synthetic parts are not attached", sc->hn_ifp->if_xname)); + + if (sc->hn_rx_ring_inuse == 1) { + /* No RSS on synthetic parts; done. */ + return; + } + if ((sc->hn_rss_hcap & NDIS_HASH_FUNCTION_TOEPLITZ) == 0) { + /* Synthetic parts do not support Toeplitz; done. */ + return; + } + + ifp = sc->hn_ifp; + vf_ifp = sc->hn_vf_ifp; + + /* + * Extract VF's RSS key. Only 40 bytes key for Toeplitz is + * supported. + */ + memset(&ifrk, 0, sizeof(ifrk)); + strlcpy(ifrk.ifrk_name, vf_ifp->if_xname, sizeof(ifrk.ifrk_name)); + error = vf_ifp->if_ioctl(vf_ifp, SIOCGIFRSSKEY, (caddr_t)&ifrk); + if (error) { + if_printf(ifp, "%s SIOCGRSSKEY failed: %d\n", + vf_ifp->if_xname, error); + goto done; + } + if (ifrk.ifrk_func != RSS_FUNC_TOEPLITZ) { + if_printf(ifp, "%s RSS function %u is not Toeplitz\n", + vf_ifp->if_xname, ifrk.ifrk_func); + goto done; + } + if (ifrk.ifrk_keylen != NDIS_HASH_KEYSIZE_TOEPLITZ) { + if_printf(ifp, "%s invalid RSS Toeplitz key length %d\n", + vf_ifp->if_xname, ifrk.ifrk_keylen); + goto done; + } + + /* + * Extract VF's RSS hash. Only Toeplitz is supported. + */ + memset(&ifrh, 0, sizeof(ifrh)); + strlcpy(ifrh.ifrh_name, vf_ifp->if_xname, sizeof(ifrh.ifrh_name)); + error = vf_ifp->if_ioctl(vf_ifp, SIOCGIFRSSHASH, (caddr_t)&ifrh); + if (error) { + if_printf(ifp, "%s SIOCGRSSHASH failed: %d\n", + vf_ifp->if_xname, error); + goto done; + } + if (ifrh.ifrh_func != RSS_FUNC_TOEPLITZ) { + if_printf(ifp, "%s RSS function %u is not Toeplitz\n", + vf_ifp->if_xname, ifrh.ifrh_func); + goto done; + } + + my_types = hn_rss_type_fromndis(sc->hn_rss_hcap); + if ((ifrh.ifrh_types & my_types) == 0) { + /* This disables RSS; ignore it then */ + if_printf(ifp, "%s intersection of RSS types failed. " + "VF %#x, mine %#x\n", vf_ifp->if_xname, + ifrh.ifrh_types, my_types); + goto done; + } + + diff_types = my_types ^ ifrh.ifrh_types; + my_types &= ifrh.ifrh_types; + mbuf_types = my_types; + + /* + * Detect RSS hash value/type confliction. + * + * NOTE: + * We don't disable the hash type, but stop delivery the hash + * value/type through mbufs on RX path. + */ + if ((my_types & RSS_TYPE_IPV4) && + (diff_types & ifrh.ifrh_types & + (RSS_TYPE_TCP_IPV4 | RSS_TYPE_UDP_IPV4))) { + /* Conflict; disable IPV4 hash type/value delivery. */ + if_printf(ifp, "disable IPV4 mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_IPV4; + } + if ((my_types & RSS_TYPE_IPV6) && + (diff_types & ifrh.ifrh_types & + (RSS_TYPE_TCP_IPV6 | RSS_TYPE_UDP_IPV6 | + RSS_TYPE_TCP_IPV6_EX | RSS_TYPE_UDP_IPV6_EX | + RSS_TYPE_IPV6_EX))) { + /* Conflict; disable IPV6 hash type/value delivery. */ + if_printf(ifp, "disable IPV6 mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_IPV6; + } + if ((my_types & RSS_TYPE_IPV6_EX) && + (diff_types & ifrh.ifrh_types & + (RSS_TYPE_TCP_IPV6 | RSS_TYPE_UDP_IPV6 | + RSS_TYPE_TCP_IPV6_EX | RSS_TYPE_UDP_IPV6_EX | + RSS_TYPE_IPV6))) { + /* Conflict; disable IPV6_EX hash type/value delivery. */ + if_printf(ifp, "disable IPV6_EX mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_IPV6_EX; + } + if ((my_types & RSS_TYPE_TCP_IPV6) && + (diff_types & ifrh.ifrh_types & RSS_TYPE_TCP_IPV6_EX)) { + /* Conflict; disable TCP_IPV6 hash type/value delivery. */ + if_printf(ifp, "disable TCP_IPV6 mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_TCP_IPV6; + } + if ((my_types & RSS_TYPE_TCP_IPV6_EX) && + (diff_types & ifrh.ifrh_types & RSS_TYPE_TCP_IPV6)) { + /* Conflict; disable TCP_IPV6_EX hash type/value delivery. */ + if_printf(ifp, "disable TCP_IPV6_EX mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_TCP_IPV6_EX; + } + if ((my_types & RSS_TYPE_UDP_IPV6) && + (diff_types & ifrh.ifrh_types & RSS_TYPE_UDP_IPV6_EX)) { + /* Conflict; disable UDP_IPV6 hash type/value delivery. */ + if_printf(ifp, "disable UDP_IPV6 mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_UDP_IPV6; + } + if ((my_types & RSS_TYPE_UDP_IPV6_EX) && + (diff_types & ifrh.ifrh_types & RSS_TYPE_UDP_IPV6)) { + /* Conflict; disable UDP_IPV6_EX hash type/value delivery. */ + if_printf(ifp, "disable UDP_IPV6_EX mbuf hash delivery\n"); + mbuf_types &= ~RSS_TYPE_UDP_IPV6_EX; + } + + /* + * Indirect table does not matter. + */ + + sc->hn_rss_hash = (sc->hn_rss_hcap & NDIS_HASH_FUNCTION_MASK) | + hn_rss_type_tondis(my_types); + memcpy(sc->hn_rss.rss_key, ifrk.ifrk_key, sizeof(sc->hn_rss.rss_key)); + sc->hn_flags |= HN_FLAG_HAS_RSSKEY; + + if (reconf) { + error = hn_rss_reconfig(sc); + if (error) { + /* XXX roll-back? */ + if_printf(ifp, "hn_rss_reconfig failed: %d\n", error); + /* XXX keep going. */ + } + } +done: + /* Hash deliverability for mbufs. */ + hn_rss_mbuf_hash(sc, hn_rss_type_tondis(mbuf_types)); +} + +static void +hn_vf_rss_restore(struct hn_softc *sc) +{ + + HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("%s: synthetic parts are not attached", sc->hn_ifp->if_xname)); + + if (sc->hn_rx_ring_inuse == 1) + goto done; + + /* + * Restore hash types. Key does _not_ matter. + */ + if (sc->hn_rss_hash != sc->hn_rss_hcap) { + int error; + + sc->hn_rss_hash = sc->hn_rss_hcap; + error = hn_rss_reconfig(sc); + if (error) { + if_printf(sc->hn_ifp, "hn_rss_reconfig failed: %d\n", + error); + /* XXX keep going. */ + } + } +done: + /* Hash deliverability for mbufs. */ + hn_rss_mbuf_hash(sc, NDIS_HASH_ALL); +} + +static void hn_xpnt_vf_setready(struct hn_softc *sc) { struct ifnet *ifp, *vf_ifp; @@ -1488,6 +1739,13 @@ hn_xpnt_vf_init(struct hn_softc *sc) */ hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_VF); + /* + * NOTE: + * Fixup RSS related bits _after_ the VF is brought up, since + * many VFs generate RSS key during it's initialization. + */ + hn_vf_rss_fixup(sc, true); + /* Mark transparent mode VF as enabled. */ hn_xpnt_vf_setenable(sc); } @@ -1646,7 +1904,8 @@ hn_ifnet_detevent(void *xsc, struct ifnet *ifp) ifp->if_input = sc->hn_vf_input; sc->hn_vf_input = NULL; - if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) && + (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED)) hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_SYNTH); if (sc->hn_vf_rdytick == 0) { @@ -1668,11 +1927,18 @@ hn_ifnet_detevent(void *xsc, struct ifnet *ifp) sc->hn_ifp->if_hw_tsomaxsegsize = sc->hn_saved_tsosegsz; } - /* - * Resume link status management, which was suspended - * by hn_ifnet_attevent(). - */ - hn_resume_mgmt(sc); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { + /* + * Restore RSS settings. + */ + hn_vf_rss_restore(sc); + + /* + * Resume link status management, which was suspended + * by hn_ifnet_attevent(). + */ + hn_resume_mgmt(sc); + } } /* Mark transparent mode VF as disabled. */ @@ -1918,6 +2184,12 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_hash", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_rss_hash_sysctl, "A", "RSS hash"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_hashcap", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rss_hcap_sysctl, "A", "RSS hash capabilities"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "mbuf_hash", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rss_mbuf_sysctl, "A", "RSS hash for mbufs"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rss_ind_size", CTLFLAG_RD, &sc->hn_rss_ind_size, 0, "RSS indirect entry count"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", @@ -3015,14 +3287,21 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int { struct ifnet *ifp, *hn_ifp = rxr->hn_ifp; struct mbuf *m_new; - int size, do_lro = 0, do_csum = 1; - int hash_type = M_HASHTYPE_OPAQUE; + int size, do_lro = 0, do_csum = 1, is_vf = 0; + int hash_type = M_HASHTYPE_NONE; - /* - * If the non-transparent mode VF is active, inject this packet - * into the VF. - */ - ifp = rxr->hn_rxvf_ifp ? rxr->hn_rxvf_ifp : hn_ifp; + ifp = hn_ifp; + if (rxr->hn_rxvf_ifp != NULL) { + /* + * Non-transparent mode VF; pretend this packet is from + * the VF. + */ + ifp = rxr->hn_rxvf_ifp; + is_vf = 1; + } else if (rxr->hn_rx_flags & HN_RX_FLAG_XPNT_VF) { + /* Transparent mode VF. */ + is_vf = 1; + } if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { /* @@ -3175,16 +3454,6 @@ skip: * If VF is activated (tranparent/non-transparent mode does not * matter here). * - * - Don't setup mbuf hash, if 'options RSS' is set. - * - * In Azure, when VF is activated, TCP SYN and SYN|ACK go - * through hn(4) while the rest of segments and ACKs belonging - * to the same TCP 4-tuple go through the VF. So don't setup - * mbuf hash, if a VF is activated and 'options RSS' is not - * enabled. hn(4) and the VF may use neither the same RSS - * hash key nor the same RSS hash function, so the hash value - * for packets belonging to the same flow could be different! - * * - Disable LRO * * hn(4) will only receive broadcast packets, multicast packets, @@ -3195,19 +3464,23 @@ skip: * all, since the LRO flush will use hn(4) as the receiving * interface; i.e. hn_ifp->if_input(hn_ifp, m). */ - if (hn_ifp != ifp || (rxr->hn_rx_flags & HN_RX_FLAG_XPNT_VF)) { - do_lro = 0; /* disable LRO. */ -#ifndef RSS - goto skip_hash; /* skip mbuf hash setup */ -#endif - } + if (is_vf) + do_lro = 0; + /* + * If VF is activated (tranparent/non-transparent mode does not + * matter here), do _not_ mess with unsupported hash types or + * functions. + */ if (info->hash_info != HN_NDIS_HASH_INFO_INVALID) { rxr->hn_rss_pkts++; m_new->m_pkthdr.flowid = info->hash_value; + if (!is_vf) + hash_type = M_HASHTYPE_OPAQUE; if ((info->hash_info & NDIS_HASH_FUNCTION_MASK) == NDIS_HASH_FUNCTION_TOEPLITZ) { - uint32_t type = (info->hash_info & NDIS_HASH_TYPE_MASK); + uint32_t type = (info->hash_info & NDIS_HASH_TYPE_MASK & + rxr->hn_mbuf_hash); /* * NOTE: @@ -3244,14 +3517,11 @@ skip: break; } } - } else { + } else if (!is_vf) { m_new->m_pkthdr.flowid = rxr->hn_rx_idx; } M_HASHTYPE_SET(m_new, hash_type); -#ifndef RSS -skip_hash: -#endif if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if (hn_ifp != ifp) { const struct ether_header *eh; @@ -3576,20 +3846,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifrh->ifrh_func = RSS_FUNC_TOEPLITZ; else ifrh->ifrh_func = RSS_FUNC_PRIVATE; - - ifrh->ifrh_types = 0; - if (sc->hn_rss_hash & NDIS_HASH_IPV4) - ifrh->ifrh_types |= RSS_TYPE_IPV4; - if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV4) - ifrh->ifrh_types |= RSS_TYPE_TCP_IPV4; - if (sc->hn_rss_hash & NDIS_HASH_IPV6) - ifrh->ifrh_types |= RSS_TYPE_IPV6; - if (sc->hn_rss_hash & NDIS_HASH_IPV6_EX) - ifrh->ifrh_types |= RSS_TYPE_IPV6_EX; - if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6) - ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6; - if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6_EX) - ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6_EX; + ifrh->ifrh_types = hn_rss_type_fromndis(sc->hn_rss_hash); HN_UNLOCK(sc); break; @@ -4139,6 +4396,16 @@ hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) if (error || req->newptr == NULL) goto back; + if ((sc->hn_flags & HN_FLAG_RXVF) || + (hn_xpnt_vf && sc->hn_vf_ifp != NULL)) { + /* + * RSS key is synchronized w/ VF's, don't allow users + * to change it. + */ + error = EBUSY; + goto back; + } + error = SYSCTL_IN(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); if (error) goto back; @@ -4203,6 +4470,34 @@ hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS) } static int +hn_rss_hcap_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char hash_str[128]; + uint32_t hash; + + HN_LOCK(sc); + hash = sc->hn_rss_hcap; + HN_UNLOCK(sc); + snprintf(hash_str, sizeof(hash_str), "%b", hash, NDIS_HASH_BITS); + return sysctl_handle_string(oidp, hash_str, sizeof(hash_str), req); +} + +static int +hn_rss_mbuf_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char hash_str[128]; + uint32_t hash; + + HN_LOCK(sc); + hash = sc->hn_rx_ring[0].hn_mbuf_hash; + HN_UNLOCK(sc); + snprintf(hash_str, sizeof(hash_str), "%b", hash, NDIS_HASH_BITS); + return sysctl_handle_string(oidp, hash_str, sizeof(hash_str), req); +} + +static int hn_vf_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -4502,6 +4797,7 @@ hn_create_rx_data(struct hn_softc *sc, int ring_cnt) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_UDP; if (hn_trust_hostip) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; + rxr->hn_mbuf_hash = NDIS_HASH_ALL; rxr->hn_ifp = sc->hn_ifp; if (i < sc->hn_tx_ring_cnt) rxr->hn_txr = &sc->hn_tx_ring[i]; @@ -5952,6 +6248,7 @@ hn_synth_attach(struct hn_softc *sc, int mtu) /* Clear RSS stuffs. */ sc->hn_rss_ind_size = 0; sc->hn_rss_hash = 0; + sc->hn_rss_hcap = 0; /* * Attach the primary channel _before_ attaching NVS and RNDIS. @@ -6058,6 +6355,12 @@ hn_synth_attach(struct hn_softc *sc, int mtu) hn_rss_ind_fixup(sc); } + sc->hn_rss_hash = sc->hn_rss_hcap; + if ((sc->hn_flags & HN_FLAG_RXVF) || + (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED)) { + /* NOTE: Don't reconfigure RSS; will do immediately. */ + hn_vf_rss_fixup(sc, false); + } error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); if (error) goto failed; Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 03:02:54 2017 (r324464) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 03:21:17 2017 (r324465) @@ -64,6 +64,7 @@ struct hn_rx_ring { void *hn_pktbuf; int hn_pktbuf_len; int hn_rx_flags; /* HN_RX_FLAG_ */ + uint32_t hn_mbuf_hash; /* NDIS_HASH_ */ uint8_t *hn_rxbuf; /* shadow sc->hn_rxbuf */ int hn_rx_idx; @@ -239,7 +240,8 @@ struct hn_softc { uint32_t hn_rndis_agg_align; int hn_rss_ind_size; - uint32_t hn_rss_hash; /* NDIS_HASH_ */ + uint32_t hn_rss_hash; /* setting, NDIS_HASH_ */ + uint32_t hn_rss_hcap; /* caps, NDIS_HASH_ */ struct ndis_rssprm_toeplitz hn_rss; eventhandler_tag hn_ifaddr_evthand; Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Tue Oct 10 03:02:54 2017 (r324464) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Tue Oct 10 03:21:17 2017 (r324465) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,13 @@ #define NDIS_HASH_IPV6_EX 0x00000800 #define NDIS_HASH_TCP_IPV6 0x00001000 #define NDIS_HASH_TCP_IPV6_EX 0x00002000 + +#define NDIS_HASH_ALL (NDIS_HASH_IPV4 | \ + NDIS_HASH_TCP_IPV4 | \ + NDIS_HASH_IPV6 | \ + NDIS_HASH_IPV6_EX | \ + NDIS_HASH_TCP_IPV6 | \ + NDIS_HASH_TCP_IPV6_EX) /* Hash description for use with printf(9) %b identifier. */ #define NDIS_HASH_BITS \ From owner-svn-src-stable-10@freebsd.org Tue Oct 10 03:29:38 2017 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 2571EE46670; Tue, 10 Oct 2017 03:29: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 F2D3968503; Tue, 10 Oct 2017 03:29: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 v9A3TbRp041783; Tue, 10 Oct 2017 03:29:37 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A3Ta8U041777; Tue, 10 Oct 2017 03:29:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100329.v9A3Ta8U041777@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 03:29: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: r324466 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324466 X-SVN-Commit-Repository: base 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, 10 Oct 2017 03:29:38 -0000 Author: sephe Date: Tue Oct 10 03:29:36 2017 New Revision: 324466 URL: https://svnweb.freebsd.org/changeset/base/324466 Log: MFC 323728,323729 323728 hyperv/hn: Fix MTU setting - Add size of an ethernet header to the value configured to NVS. This does not seem to have any effects if MTU is 1500, but fix hypervisor side's setting if MTU > 1500. - Override the MTU setting according to the view from the hypervisor side. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12352 323729 hyperv/hn: Incease max supported MTU Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12365 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/hn_rndis.h 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 Tue Oct 10 03:21:17 2017 (r324465) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 03:29:36 2017 (r324466) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -503,7 +504,7 @@ hn_nvs_conf_ndis(struct hn_softc *sc, int mtu) memset(&conf, 0, sizeof(conf)); conf.nvs_type = HN_NVS_TYPE_NDIS_CONF; - conf.nvs_mtu = mtu; + conf.nvs_mtu = mtu + ETHER_HDR_LEN; conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; if (sc->hn_nvs_ver >= HN_NVS_VERSION_5) conf.nvs_caps |= HN_NVS_NDIS_CONF_SRIOV; Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 03:21:17 2017 (r324465) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 03:29:36 2017 (r324466) @@ -189,6 +189,24 @@ hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t return (0); } +int +hn_rndis_get_mtu(struct hn_softc *sc, uint32_t *mtu) +{ + size_t size; + int error; + + size = sizeof(*mtu); + error = hn_rndis_query(sc, OID_GEN_MAXIMUM_FRAME_SIZE, NULL, 0, + mtu, &size); + if (error) + return (error); + if (size != sizeof(uint32_t)) { + if_printf(sc->hn_ifp, "invalid mtu len %zu\n", size); + return (EINVAL); + } + return (0); +} + static const void * hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, struct hn_nvs_sendctx *sndc, size_t *comp_len) Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 03:21:17 2017 (r324465) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 03:29:36 2017 (r324466) @@ -41,6 +41,7 @@ int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t * /* link_status: NDIS_MEDIA_STATE_ */ int hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status); +int hn_rndis_get_mtu(struct hn_softc *sc, uint32_t *mtu); /* filter: NDIS_PACKET_TYPE_. */ int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter); void hn_rndis_rx_ctrl(struct hn_softc *sc, const void *data, Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:21:17 2017 (r324465) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:29:36 2017 (r324466) @@ -1990,6 +1990,7 @@ hn_attach(device_t dev) uint8_t eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; + uint32_t mtu; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -2142,6 +2143,12 @@ hn_attach(device_t dev) if (error) goto failed; + error = hn_rndis_get_mtu(sc, &mtu); + if (error) + mtu = ETHERMTU; + else if (bootverbose) + device_printf(dev, "RNDIS mtu %u\n", mtu); + #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { /* @@ -2326,6 +2333,10 @@ hn_attach(device_t dev) if_printf(ifp, "TSO segcnt %u segsz %u\n", ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); } + if (mtu < ETHERMTU) { + if_printf(ifp, "fixup mtu %lu -> %u\n", ifp->if_mtu, mtu); + ifp->if_mtu = mtu; + } /* Inform the upper layer about the long frame support. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); @@ -3575,6 +3586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) int mask, error = 0; struct ifrsskey *ifrk; struct ifrsshash *ifrh; + uint32_t mtu; switch (cmd) { case SIOCSIFMTU: @@ -3638,11 +3650,23 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + error = hn_rndis_get_mtu(sc, &mtu); + if (error) + mtu = ifr->ifr_mtu; + else if (bootverbose) + if_printf(ifp, "RNDIS mtu %u\n", mtu); + /* * Commit the requested MTU, after the synthetic parts * have been successfully attached. */ - ifp->if_mtu = ifr->ifr_mtu; + if (mtu >= ifr->ifr_mtu) { + mtu = ifr->ifr_mtu; + } else { + if_printf(ifp, "fixup mtu %d -> %u\n", + ifr->ifr_mtu, mtu); + } + ifp->if_mtu = mtu; /* * Synthetic parts' reattach may change the chimney Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 03:21:17 2017 (r324465) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 03:29:36 2017 (r324466) @@ -36,8 +36,7 @@ #define HN_RXBUF_SIZE (16 * 1024 * 1024) #define HN_RXBUF_SIZE_COMPAT (15 * 1024 * 1024) -/* Claimed to be 12232B */ -#define HN_MTU_MAX (9 * 1024) +#define HN_MTU_MAX (65535 - ETHER_ADDR_LEN) #define HN_TXBR_SIZE (128 * PAGE_SIZE) #define HN_RXBR_SIZE (128 * PAGE_SIZE) From owner-svn-src-stable-10@freebsd.org Tue Oct 10 03:35:25 2017 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 651C9E46ABE; Tue, 10 Oct 2017 03:35: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 420A768A5B; Tue, 10 Oct 2017 03:35: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 v9A3ZOjG045759; Tue, 10 Oct 2017 03:35:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A3ZOBK045757; Tue, 10 Oct 2017 03:35:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100335.v9A3ZOBK045757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 03:35: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: r324467 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324467 X-SVN-Commit-Repository: base 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, 10 Oct 2017 03:35:25 -0000 Author: sephe Date: Tue Oct 10 03:35:24 2017 New Revision: 324467 URL: https://svnweb.freebsd.org/changeset/base/324467 Log: MFC 324048 hyperv/hn: Set tcp header offset for CSUM/LSO offloading. No observable effect; better safe than sorry. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12417 Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/ndis.h 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 Tue Oct 10 03:29:36 2017 (r324466) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:35:24 2017 (r324467) @@ -716,6 +716,7 @@ hn_tso_fixup(struct mbuf *m_head) ehlen = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; else ehlen = ETHER_HDR_LEN; + m_head->m_pkthdr.l2hlen = ehlen; #ifdef INET if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { @@ -725,6 +726,7 @@ hn_tso_fixup(struct mbuf *m_head) PULLUP_HDR(m_head, ehlen + sizeof(*ip)); ip = mtodo(m_head, ehlen); iphlen = ip->ip_hl << 2; + m_head->m_pkthdr.l3hlen = iphlen; PULLUP_HDR(m_head, ehlen + iphlen + sizeof(*th)); th = mtodo(m_head, ehlen + iphlen); @@ -748,6 +750,7 @@ hn_tso_fixup(struct mbuf *m_head) m_freem(m_head); return (NULL); } + m_head->m_pkthdr.l3hlen = sizeof(*ip6); PULLUP_HDR(m_head, ehlen + sizeof(*ip6) + sizeof(*th)); th = mtodo(m_head, ehlen + sizeof(*ip6)); @@ -757,41 +760,34 @@ hn_tso_fixup(struct mbuf *m_head) } #endif return (m_head); - } /* * NOTE: If this function failed, the m_head would be freed. */ static __inline struct mbuf * -hn_check_tcpsyn(struct mbuf *m_head, int *tcpsyn) +hn_set_hlen(struct mbuf *m_head) { const struct ether_vlan_header *evl; - const struct tcphdr *th; int ehlen; - *tcpsyn = 0; - PULLUP_HDR(m_head, sizeof(*evl)); evl = mtod(m_head, const struct ether_vlan_header *); if (evl->evl_encap_proto == ntohs(ETHERTYPE_VLAN)) ehlen = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; else ehlen = ETHER_HDR_LEN; + m_head->m_pkthdr.l2hlen = ehlen; #ifdef INET - if (m_head->m_pkthdr.csum_flags & CSUM_IP_TCP) { + if (m_head->m_pkthdr.csum_flags & (CSUM_IP_TCP | CSUM_IP_UDP)) { const struct ip *ip; int iphlen; PULLUP_HDR(m_head, ehlen + sizeof(*ip)); ip = mtodo(m_head, ehlen); iphlen = ip->ip_hl << 2; - - PULLUP_HDR(m_head, ehlen + iphlen + sizeof(*th)); - th = mtodo(m_head, ehlen + iphlen); - if (th->th_flags & TH_SYN) - *tcpsyn = 1; + m_head->m_pkthdr.l3hlen = iphlen; } #endif #if defined(INET6) && defined(INET) @@ -803,18 +799,36 @@ hn_check_tcpsyn(struct mbuf *m_head, int *tcpsyn) PULLUP_HDR(m_head, ehlen + sizeof(*ip6)); ip6 = mtodo(m_head, ehlen); - if (ip6->ip6_nxt != IPPROTO_TCP) - return (m_head); - - PULLUP_HDR(m_head, ehlen + sizeof(*ip6) + sizeof(*th)); - th = mtodo(m_head, ehlen + sizeof(*ip6)); - if (th->th_flags & TH_SYN) - *tcpsyn = 1; + if (ip6->ip6_nxt != IPPROTO_TCP) { + m_freem(m_head); + return (NULL); + } + m_head->m_pkthdr.l3hlen = sizeof(*ip6); } #endif return (m_head); } +/* + * NOTE: If this function failed, the m_head would be freed. + */ +static __inline struct mbuf * +hn_check_tcpsyn(struct mbuf *m_head, int *tcpsyn) +{ + const struct tcphdr *th; + int ehlen, iphlen; + + *tcpsyn = 0; + ehlen = m_head->m_pkthdr.l2hlen; + iphlen = m_head->m_pkthdr.l3hlen; + + PULLUP_HDR(m_head, ehlen + iphlen + sizeof(*th)); + th = mtodo(m_head, ehlen + iphlen); + if (th->th_flags & TH_SYN) + *tcpsyn = 1; + return (m_head); +} + #undef PULLUP_HDR #endif /* INET6 || INET */ @@ -2999,7 +3013,8 @@ hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, st NDIS_LSO2_INFO_SIZE, NDIS_PKTINFO_TYPE_LSO); #ifdef INET if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { - *pi_data = NDIS_LSO2_INFO_MAKEIPV4(0, + *pi_data = NDIS_LSO2_INFO_MAKEIPV4( + m_head->m_pkthdr.l2hlen + m_head->m_pkthdr.l3hlen, m_head->m_pkthdr.tso_segsz); } #endif @@ -3008,7 +3023,8 @@ hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, st #endif #ifdef INET6 { - *pi_data = NDIS_LSO2_INFO_MAKEIPV6(0, + *pi_data = NDIS_LSO2_INFO_MAKEIPV6( + m_head->m_pkthdr.l2hlen + m_head->m_pkthdr.l3hlen, m_head->m_pkthdr.tso_segsz); } #endif @@ -3025,11 +3041,15 @@ hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, st *pi_data |= NDIS_TXCSUM_INFO_IPCS; } - if (m_head->m_pkthdr.csum_flags & (CSUM_IP_TCP | CSUM_IP6_TCP)) - *pi_data |= NDIS_TXCSUM_INFO_TCPCS; - else if (m_head->m_pkthdr.csum_flags & - (CSUM_IP_UDP | CSUM_IP6_UDP)) - *pi_data |= NDIS_TXCSUM_INFO_UDPCS; + if (m_head->m_pkthdr.csum_flags & + (CSUM_IP_TCP | CSUM_IP6_TCP)) { + *pi_data |= NDIS_TXCSUM_INFO_MKTCPCS( + m_head->m_pkthdr.l2hlen + m_head->m_pkthdr.l3hlen); + } else if (m_head->m_pkthdr.csum_flags & + (CSUM_IP_UDP | CSUM_IP6_UDP)) { + *pi_data |= NDIS_TXCSUM_INFO_MKUDPCS( + m_head->m_pkthdr.l2hlen + m_head->m_pkthdr.l3hlen); + } } pkt_hlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; @@ -5550,6 +5570,13 @@ hn_start_locked(struct hn_tx_ring *txr, int len) if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } + } else if (m_head->m_pkthdr.csum_flags & + (CSUM_IP_UDP | CSUM_IP_TCP | CSUM_IP6_UDP | CSUM_IP6_TCP)) { + m_head = hn_set_hlen(m_head); + if (__predict_false(m_head == NULL)) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + continue; + } } #endif @@ -5830,11 +5857,18 @@ hn_transmit(struct ifnet *ifp, struct mbuf *m) #if defined(INET6) || defined(INET) /* - * Perform TSO packet header fixup now, since the TSO - * packet header should be cache-hot. + * Perform TSO packet header fixup or get l2/l3 header length now, + * since packet headers should be cache-hot. */ if (m->m_pkthdr.csum_flags & CSUM_TSO) { m = hn_tso_fixup(m); + if (__predict_false(m == NULL)) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + return EIO; + } + } else if (m->m_pkthdr.csum_flags & + (CSUM_IP_UDP | CSUM_IP_TCP | CSUM_IP6_UDP | CSUM_IP6_TCP)) { + m = hn_set_hlen(m); if (__predict_false(m == NULL)) { if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return EIO; Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Tue Oct 10 03:29:36 2017 (r324466) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Tue Oct 10 03:35:24 2017 (r324467) @@ -402,4 +402,13 @@ struct ndis_offload { #define NDIS_TXCSUM_INFO_IPCS 0x00000010 #define NDIS_TXCSUM_INFO_THOFF 0x03ff0000 +#define NDIS_TXCSUM_INFO_MKL4CS(thoff, flag) \ + ((((uint32_t)(thoff)) << 16) | (flag)) + +#define NDIS_TXCSUM_INFO_MKTCPCS(thoff) \ + NDIS_TXCSUM_INFO_MKL4CS((thoff), NDIS_TXCSUM_INFO_TCPCS) + +#define NDIS_TXCSUM_INFO_MKUDPCS(thoff) \ + NDIS_TXCSUM_INFO_MKL4CS((thoff), NDIS_TXCSUM_INFO_UDPCS) + #endif /* !_NET_NDIS_H_ */ From owner-svn-src-stable-10@freebsd.org Tue Oct 10 03:40:39 2017 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 B0320E46E48; Tue, 10 Oct 2017 03:40: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 8B84D69343; Tue, 10 Oct 2017 03:40: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 v9A3ecXB046019; Tue, 10 Oct 2017 03:40:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9A3ecYX046018; Tue, 10 Oct 2017 03:40:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710100340.v9A3ecYX046018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 10 Oct 2017 03:40: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: r324468 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324468 X-SVN-Commit-Repository: base 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, 10 Oct 2017 03:40:39 -0000 Author: sephe Date: Tue Oct 10 03:40:38 2017 New Revision: 324468 URL: https://svnweb.freebsd.org/changeset/base/324468 Log: MFC 324049,324077 324049 hyperv/hn: Fix UDP checksum offload issue in Azure. UDP checksum offload does not work in Azure if following conditions are met: - sizeof(IP hdr + UDP hdr + payload) > 1420. - IP_DF is not set in IP hdr Use software checksum for UDP datagrams falling into this category. Add two tunables to disable UDP/IPv4 and UDP/IPv6 checksum offload, in case something unexpected happened. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12429 324077 hyperv/hn: Unbreak i386 building. Reported by: cy Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c 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 Tue Oct 10 03:35:24 2017 (r324467) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 03:40:38 2017 (r324468) @@ -60,7 +60,9 @@ __FBSDID("$FreeBSD$"); #include "opt_hn.h" #include +#include #include +#include #include #include #include @@ -76,7 +78,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -451,6 +452,35 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostip, CTLFLAG_RDT "Trust ip packet verification on host side, " "when csum info is missing (global setting)"); +/* + * Offload UDP/IPv4 checksum. + */ +static int hn_enable_udp4cs = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, enable_udp4cs, CTLFLAG_RDTUN, + &hn_enable_udp4cs, 0, "Offload UDP/IPv4 checksum"); + +/* + * Offload UDP/IPv6 checksum. + */ +static int hn_enable_udp6cs = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, enable_udp6cs, CTLFLAG_RDTUN, + &hn_enable_udp6cs, 0, "Offload UDP/IPv6 checksum"); + +/* Stats. */ +static counter_u64_t hn_udpcs_fixup; +SYSCTL_COUNTER_U64(_hw_hn, OID_AUTO, udpcs_fixup, CTLFLAG_RW, + &hn_udpcs_fixup, "# of UDP checksum fixup"); + +/* + * See hn_set_hlen(). + * + * This value is for Azure. For Hyper-V, set this above + * 65536 to disable UDP datagram checksum fixup. + */ +static int hn_udpcs_fixup_mtu = 1420; +SYSCTL_INT(_hw_hn, OID_AUTO, udpcs_fixup_mtu, CTLFLAG_RWTUN, + &hn_udpcs_fixup_mtu, 0, "UDP checksum fixup MTU threshold"); + /* Limit TSO burst size */ static int hn_tso_maxlen = IP_MAXPACKET; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, @@ -788,6 +818,27 @@ hn_set_hlen(struct mbuf *m_head) ip = mtodo(m_head, ehlen); iphlen = ip->ip_hl << 2; m_head->m_pkthdr.l3hlen = iphlen; + + /* + * UDP checksum offload does not work in Azure, if the + * following conditions meet: + * - sizeof(IP hdr + UDP hdr + payload) > 1420. + * - IP_DF is not set in the IP hdr. + * + * Fallback to software checksum for these UDP datagrams. + */ + if ((m_head->m_pkthdr.csum_flags & CSUM_IP_UDP) && + m_head->m_pkthdr.len > hn_udpcs_fixup_mtu + ehlen && + (ntohs(ip->ip_off) & IP_DF) == 0) { + uint16_t off = ehlen + iphlen; + + counter_u64_add(hn_udpcs_fixup, 1); + PULLUP_HDR(m_head, off + sizeof(struct udphdr)); + *(uint16_t *)(m_head->m_data + off + + m_head->m_pkthdr.csum_data) = in_cksum_skip( + m_head, m_head->m_pkthdr.len, off); + m_head->m_pkthdr.csum_flags &= ~CSUM_IP_UDP; + } } #endif #if defined(INET6) && defined(INET) @@ -5463,11 +5514,11 @@ hn_fixup_tx_data(struct hn_softc *sc) csum_assist |= CSUM_IP; if (sc->hn_caps & HN_CAP_TCP4CS) csum_assist |= CSUM_IP_TCP; - if (sc->hn_caps & HN_CAP_UDP4CS) + if ((sc->hn_caps & HN_CAP_UDP4CS) && hn_enable_udp4cs) csum_assist |= CSUM_IP_UDP; if (sc->hn_caps & HN_CAP_TCP6CS) csum_assist |= CSUM_IP6_TCP; - if (sc->hn_caps & HN_CAP_UDP6CS) + if ((sc->hn_caps & HN_CAP_UDP6CS) && hn_enable_udp6cs) csum_assist |= CSUM_IP6_UDP; for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_csum_assist = csum_assist; @@ -7289,6 +7340,8 @@ hn_sysinit(void *arg __unused) { int i; + hn_udpcs_fixup = counter_u64_alloc(M_WAITOK); + #ifdef HN_IFSTART_SUPPORT /* * Don't use ifnet.if_start if transparent VF mode is requested; @@ -7368,5 +7421,7 @@ hn_sysuninit(void *arg __unused) if (hn_vfmap != NULL) free(hn_vfmap, M_DEVBUF); rm_destroy(&hn_vfmap_lock); + + counter_u64_free(hn_udpcs_fixup); } SYSUNINIT(hn_sysuninit, SI_SUB_DRIVERS, SI_ORDER_SECOND, hn_sysuninit, NULL); From owner-svn-src-stable-10@freebsd.org Tue Oct 10 21:04:41 2017 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 EDD0FE3CF54; Tue, 10 Oct 2017 21:04: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 B18616CB5D; Tue, 10 Oct 2017 21:04:41 +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 v9AL4eYU085911; Tue, 10 Oct 2017 21:04:40 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9AL4eSM085909; Tue, 10 Oct 2017 21:04:40 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201710102104.v9AL4eSM085909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 10 Oct 2017 21:04: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: r324505 - in stable/10/lib/libc: gen tests/gen X-SVN-Group: stable-10 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in stable/10/lib/libc: gen tests/gen X-SVN-Commit-Revision: 324505 X-SVN-Commit-Repository: base 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, 10 Oct 2017 21:04:42 -0000 Author: pfg Date: Tue Oct 10 21:04:40 2017 New Revision: 324505 URL: https://svnweb.freebsd.org/changeset/base/324505 Log: MFC r322368, r322371: fnmatch(3): improve POSIX conformance. In a recent interpretation[1], "\\" shall return a non-zero value (indicating either no match or an error). The fix involves a change over r254091 and now the behavior matches the Sun/IBM/HP closed source implementations and also likely musl libc. Submitted by: Joerg Schilling [1] http://austingroupbugs.net/view.php?id=806 Modified: stable/10/lib/libc/gen/fnmatch.c stable/10/lib/libc/tests/gen/fnmatch_testcases.h Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/fnmatch.c ============================================================================== --- stable/10/lib/libc/gen/fnmatch.c Tue Oct 10 20:45:45 2017 (r324504) +++ stable/10/lib/libc/gen/fnmatch.c Tue Oct 10 21:04:40 2017 (r324505) @@ -188,7 +188,8 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, if (!(flags & FNM_NOESCAPE)) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) + if (pclen == 0 || pclen == (size_t)-1 || + pclen == (size_t)-2) return (FNM_NOMATCH); pattern += pclen; } Modified: stable/10/lib/libc/tests/gen/fnmatch_testcases.h ============================================================================== --- stable/10/lib/libc/tests/gen/fnmatch_testcases.h Tue Oct 10 20:45:45 2017 (r324504) +++ stable/10/lib/libc/tests/gen/fnmatch_testcases.h Tue Oct 10 21:04:40 2017 (r324505) @@ -131,7 +131,7 @@ struct testcase { { "\\(", "\\(", 0, FNM_NOMATCH }, { "\\a", "\\a", 0, FNM_NOMATCH }, { "\\", "\\", 0, FNM_NOMATCH }, - { "\\", "", 0, 0 }, + { "\\", "", 0, FNM_NOMATCH }, { "\\*", "\\*", FNM_NOESCAPE, 0 }, { "\\?", "\\?", FNM_NOESCAPE, 0 }, { "\\", "\\", FNM_NOESCAPE, 0 }, From owner-svn-src-stable-10@freebsd.org Wed Oct 11 05:02:37 2017 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 BA86EE466F4; Wed, 11 Oct 2017 05:02:37 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 872DF7DA3D; Wed, 11 Oct 2017 05:02:37 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9B52ak3084349; Wed, 11 Oct 2017 05:02:36 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9B52ahl084348; Wed, 11 Oct 2017 05:02:36 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201710110502.v9B52ahl084348@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 11 Oct 2017 05:02: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: r324513 - in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet X-SVN-Group: stable-10 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 324513 X-SVN-Commit-Repository: base 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, 11 Oct 2017 05:02:37 -0000 Author: cy Date: Wed Oct 11 05:02:36 2017 New Revision: 324513 URL: https://svnweb.freebsd.org/changeset/base/324513 Log: MFC r323945 and 323962 Fix misspellings, typos and /* border misalignments. Modified: stable/10/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/10/sys/contrib/ipfilter/netinet/ip_nat.c Wed Oct 11 03:50:44 2017 (r324512) +++ stable/10/sys/contrib/ipfilter/netinet/ip_nat.c Wed Oct 11 05:02:36 2017 (r324513) @@ -6098,8 +6098,8 @@ ipf_nat_icmpquerytype(icmptype) { case ICMP_ECHOREPLY: case ICMP_ECHO: - /* route aedvertisement/solliciation is currently unsupported: */ - /* it would require rewriting the ICMP data section */ + /* route advertisement/solicitation is currently unsupported: */ + /* it would require rewriting the ICMP data section */ case ICMP_TSTAMP: case ICMP_TSTAMPREPLY: case ICMP_IREQ: From owner-svn-src-stable-10@freebsd.org Wed Oct 11 05:07:38 2017 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 B93E2E46865; Wed, 11 Oct 2017 05:07:38 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8747D7DDCF; Wed, 11 Oct 2017 05:07:38 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9B57blt084614; Wed, 11 Oct 2017 05:07:37 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9B57b06084613; Wed, 11 Oct 2017 05:07:37 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201710110507.v9B57b06084613@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 11 Oct 2017 05:07: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: r324515 - in stable: 10/lib/libc/net 11/lib/libc/net X-SVN-Group: stable-10 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/lib/libc/net 11/lib/libc/net X-SVN-Commit-Revision: 324515 X-SVN-Commit-Repository: base 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, 11 Oct 2017 05:07:38 -0000 Author: cy Date: Wed Oct 11 05:07:37 2017 New Revision: 324515 URL: https://svnweb.freebsd.org/changeset/base/324515 Log: MFC r324249, 324260, and 324277 Clarify the wording describing the stayopen flag and style fixes. Modified: stable/10/lib/libc/net/gethostbyname.3 Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/libc/net/gethostbyname.3 Directory Properties: stable/11/ (props changed) Modified: stable/10/lib/libc/net/gethostbyname.3 ============================================================================== --- stable/10/lib/libc/net/gethostbyname.3 Wed Oct 11 05:04:46 2017 (r324514) +++ stable/10/lib/libc/net/gethostbyname.3 Wed Oct 11 05:07:37 2017 (r324515) @@ -28,7 +28,7 @@ .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 .\" $FreeBSD$ .\" -.Dd May 12, 2006 +.Dd October 4, 2017 .Dt GETHOSTBYNAME 3 .Os .Sh NAME @@ -189,19 +189,20 @@ function may be used to request the use of a connected .Tn TCP socket for queries. +Queries will by default use +.Tn UDP +datagrams. If the .Fa stayopen -flag is non-zero, -this sets the option to send all queries to the name server using +flag is non-zero, a .Tn TCP -and to retain the connection after each call to +connection to the name server will be used. +It will remain open after calls to .Fn gethostbyname , .Fn gethostbyname2 or -.Fn gethostbyaddr . -Otherwise, queries are performed using -.Tn UDP -datagrams. +.Fn gethostbyaddr +have completed. .Pp The .Fn endhostent From owner-svn-src-stable-10@freebsd.org Wed Oct 11 06:28:48 2017 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 00BDAE47F40; Wed, 11 Oct 2017 06:28:48 +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 C1DED80594; Wed, 11 Oct 2017 06:28:47 +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 v9B6SkJv018020; Wed, 11 Oct 2017 06:28:46 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9B6SkLN018019; Wed, 11 Oct 2017 06:28:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710110628.v9B6SkLN018019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 11 Oct 2017 06:28:46 +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: r324520 - stable/10/sys/netinet X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/netinet X-SVN-Commit-Revision: 324520 X-SVN-Commit-Repository: base 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, 11 Oct 2017 06:28:48 -0000 Author: sephe Date: Wed Oct 11 06:28:46 2017 New Revision: 324520 URL: https://svnweb.freebsd.org/changeset/base/324520 Log: MFC 324050 tcp: Don't "negotiate" MSS. _NO_ OSes actually "negotiate" MSS. RFC 879: "... This Maximum Segment Size (MSS) announcement (often mistakenly called a negotiation) ..." This negotiation behaviour was introduced 11 years ago by r159955 without any explaination about why FreeBSD had to "negotiate" MSS: In syncache_respond() do not reply with a MSS that is larger than what the peer announced to us but make it at least tcp_minmss in size. Sponsored by: TCP/IP Optimization Fundraise 2005 The tcp_minmss behaviour is still kept. Syncookie fix was prodded by tuexen, who also helped to test this patch w/ packetdrill. Reviewed by: tuexen, karels, bz (previous version) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12430 Modified: stable/10/sys/netinet/tcp_syncache.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_syncache.c ============================================================================== --- stable/10/sys/netinet/tcp_syncache.c Wed Oct 11 06:08:01 2017 (r324519) +++ stable/10/sys/netinet/tcp_syncache.c Wed Oct 11 06:28:46 2017 (r324520) @@ -1551,9 +1551,7 @@ syncache_respond(struct syncache *sc, const struct mbu tlen = hlen + sizeof(struct tcphdr); /* Determine MSS we advertize to other end of connection. */ - mssopt = tcp_mssopt(&sc->sc_inc); - if (sc->sc_peer_mss) - mssopt = max( min(sc->sc_peer_mss, mssopt), V_tcp_minmss); + mssopt = max(tcp_mssopt(&sc->sc_inc), V_tcp_minmss); /* XXX: Assume that the entire packet will fit in a header mbuf. */ KASSERT(max_linkhdr + tlen + TCP_MAXOLEN <= MHLEN, @@ -1896,7 +1894,7 @@ syncookie_mac(struct in_conninfo *inc, tcp_seq irs, ui static tcp_seq syncookie_generate(struct syncache_head *sch, struct syncache *sc) { - u_int i, mss, secbit, wscale; + u_int i, secbit, wscale; uint32_t iss, hash; uint8_t *secbits; union syncookie cookie; @@ -1906,9 +1904,8 @@ syncookie_generate(struct syncache_head *sch, struct s cookie.cookie = 0; /* Map our computed MSS into the 3-bit index. */ - mss = min(tcp_mssopt(&sc->sc_inc), max(sc->sc_peer_mss, V_tcp_minmss)); for (i = sizeof(tcp_sc_msstab) / sizeof(*tcp_sc_msstab) - 1; - tcp_sc_msstab[i] > mss && i > 0; + tcp_sc_msstab[i] > sc->sc_peer_mss && i > 0; i--) ; cookie.flags.mss_idx = i; From owner-svn-src-stable-10@freebsd.org Wed Oct 11 10:04:19 2017 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 6B057E270E2; Wed, 11 Oct 2017 10:04:19 +0000 (UTC) (envelope-from hselasky@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 42F3E2669; Wed, 11 Oct 2017 10:04:19 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BA4I6P007772; Wed, 11 Oct 2017 10:04:18 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BA4Ifr007768; Wed, 11 Oct 2017 10:04:18 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710111004.v9BA4Ifr007768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 11 Oct 2017 10:04:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r324523 - stable/10/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 324523 X-SVN-Commit-Repository: base 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, 11 Oct 2017 10:04:19 -0000 Author: hselasky Date: Wed Oct 11 10:04:17 2017 New Revision: 324523 URL: https://svnweb.freebsd.org/changeset/base/324523 Log: MFC r324202: Make sure the doorbell lock is valid for the i386 version of the mlx5en(4) driver. Tested by: gallatin @ Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mlx5/mlx5_en/en.h ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/en.h Wed Oct 11 10:00:58 2017 (r324522) +++ stable/10/sys/dev/mlx5/mlx5_en/en.h Wed Oct 11 10:04:17 2017 (r324523) @@ -810,12 +810,12 @@ mlx5e_tx_notify_hw(struct mlx5e_sq *sq, u32 *wqe, int } static inline void -mlx5e_cq_arm(struct mlx5e_cq *cq) +mlx5e_cq_arm(struct mlx5e_cq *cq, spinlock_t *dblock) { struct mlx5_core_cq *mcq; mcq = &cq->mcq; - mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc); + mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, dblock, cq->wq.cc); } extern const struct ethtool_ops mlx5e_ethtool_ops; Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Oct 11 10:00:58 2017 (r324522) +++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Oct 11 10:04:17 2017 (r324523) @@ -1415,7 +1415,7 @@ mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_p if (err) return (err); - mlx5e_cq_arm(cq); + mlx5e_cq_arm(cq, MLX5_GET_DOORBELL_LOCK(&cq->priv->doorbell_lock)); return (0); } Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Wed Oct 11 10:00:58 2017 (r324522) +++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Wed Oct 11 10:04:17 2017 (r324523) @@ -445,7 +445,7 @@ mlx5e_rx_cq_comp(struct mlx5_core_cq *mcq) mlx5e_post_rx_wqes(rq); } mlx5e_post_rx_wqes(rq); - mlx5e_cq_arm(&rq->cq); + mlx5e_cq_arm(&rq->cq, MLX5_GET_DOORBELL_LOCK(&rq->channel->priv->doorbell_lock)); #ifdef HAVE_TURBO_LRO tcp_tlro_flush(&rq->lro, 1); #endif Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Wed Oct 11 10:00:58 2017 (r324522) +++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Wed Oct 11 10:04:17 2017 (r324523) @@ -574,7 +574,7 @@ mlx5e_tx_cq_comp(struct mlx5_core_cq *mcq) mtx_lock(&sq->comp_lock); mlx5e_poll_tx_cq(sq, MLX5E_BUDGET_MAX); - mlx5e_cq_arm(&sq->cq); + mlx5e_cq_arm(&sq->cq, MLX5_GET_DOORBELL_LOCK(&sq->priv->doorbell_lock)); mtx_unlock(&sq->comp_lock); } From owner-svn-src-stable-10@freebsd.org Wed Oct 11 10:20:54 2017 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 73BC9E277B2; Wed, 11 Oct 2017 10:20:54 +0000 (UTC) (envelope-from hselasky@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 3FE112EFE; Wed, 11 Oct 2017 10:20:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BAKr26013057; Wed, 11 Oct 2017 10:20:53 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BAKr8v013056; Wed, 11 Oct 2017 10:20:53 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710111020.v9BAKr8v013056@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 11 Oct 2017 10:20: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: r324525 - stable/10/sys/ofed/include/linux X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/ofed/include/linux X-SVN-Commit-Revision: 324525 X-SVN-Commit-Repository: base 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, 11 Oct 2017 10:20:54 -0000 Author: hselasky Date: Wed Oct 11 10:20:53 2017 New Revision: 324525 URL: https://svnweb.freebsd.org/changeset/base/324525 Log: MFC r315405, r323351 and r323364: Add helper function similar to ip_dev_find() to the LinuxKPI to lookup a network device by its IPv6 address in the given VNET. Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/include/linux/inetdevice.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/include/linux/inetdevice.h ============================================================================== --- stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:12:22 2017 (r324524) +++ stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:20:53 2017 (r324525) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,6 +25,7 @@ * 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. + * */ #ifndef _LINUX_INETDEVICE_H_ @@ -51,6 +52,40 @@ ip_dev_find(struct net *net, uint32_t addr) if_ref(ifp); ifa_free(ifa); } + return (ifp); +} + +static inline struct net_device * +ip6_dev_find(struct vnet *vnet, struct in6_addr addr) +{ + struct sockaddr_in6 sin6; + struct ifaddr *ifa = NULL; + struct ifnet *ifp = NULL; + int x; + + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_addr = addr; + sin6.sin6_len = sizeof(sin6); + sin6.sin6_family = AF_INET6; + CURVNET_SET_QUIET(vnet); + if (IN6_IS_SCOPE_LINKLOCAL(&addr) || + IN6_IS_ADDR_MC_INTFACELOCAL(&addr)) { + /* XXX need to search all scope ID's */ + for (x = 0; x <= V_if_index && x < 65536; x++) { + sin6.sin6_addr.s6_addr16[1] = htons(x); + ifa = ifa_ifwithaddr((struct sockaddr *)&sin6); + if (ifa != NULL) + break; + } + } else { + ifa = ifa_ifwithaddr((struct sockaddr *)&sin6); + } + if (ifa != NULL) { + ifp = ifa->ifa_ifp; + if_ref(ifp); + ifa_free(ifa); + } + CURVNET_RESTORE(); return (ifp); } From owner-svn-src-stable-10@freebsd.org Wed Oct 11 10:57:01 2017 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 8A6AAE284E2; Wed, 11 Oct 2017 10:57:01 +0000 (UTC) (envelope-from hselasky@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 5205263634; Wed, 11 Oct 2017 10:57:01 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BAv0RR028669; Wed, 11 Oct 2017 10:57:00 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BAv0uB028665; Wed, 11 Oct 2017 10:57:00 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710111057.v9BAv0uB028665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 11 Oct 2017 10:57: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: r324527 - in stable/10/sys/ofed: drivers/infiniband/core include/linux X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/10/sys/ofed: drivers/infiniband/core include/linux X-SVN-Commit-Revision: 324527 X-SVN-Commit-Repository: base 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, 11 Oct 2017 10:57:01 -0000 Author: hselasky Date: Wed Oct 11 10:56:59 2017 New Revision: 324527 URL: https://svnweb.freebsd.org/changeset/base/324527 Log: MFC r315404: Add basic support for VIMAGE to the LinuxKPI and ibcore. Support is implemented by mapping Linux's "struct net" into FreeBSD's "struct vnet". Currently only vnet0 is supported by ibcore. Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/drivers/infiniband/core/addr.c stable/10/sys/ofed/include/linux/inetdevice.h stable/10/sys/ofed/include/linux/linux_compat.c stable/10/sys/ofed/include/linux/netdevice.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/drivers/infiniband/core/addr.c ============================================================================== --- stable/10/sys/ofed/drivers/infiniband/core/addr.c Wed Oct 11 10:36:40 2017 (r324526) +++ stable/10/sys/ofed/drivers/infiniband/core/addr.c Wed Oct 11 10:56:59 2017 (r324527) @@ -172,7 +172,9 @@ int rdma_translate_ip(struct sockaddr *addr, struct rd sin6 = (struct sockaddr_in6 *)addr; port = sin6->sin6_port; sin6->sin6_port = 0; + CURVNET_SET_QUIET(&init_net); ifa = ifa_ifwithaddr(addr); + CURVNET_RESTORE(); sin6->sin6_port = port; if (ifa == NULL) { ret = -ENODEV; @@ -339,7 +341,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, #else #include -static int addr_resolve(struct sockaddr *src_in, +static int addr_resolve_sub(struct sockaddr *src_in, struct sockaddr *dst_in, struct rdma_dev_addr *addr) { @@ -487,6 +489,18 @@ mcast: return -error; } +static int addr_resolve(struct sockaddr *src_in, + struct sockaddr *dst_in, + struct rdma_dev_addr *addr) +{ + int error; + + CURVNET_SET_QUIET(&init_net); + error = addr_resolve_sub(src_in, dst_in, addr); + CURVNET_RESTORE(); + + return (error); +} #endif static void process_req(struct work_struct *work) Modified: stable/10/sys/ofed/include/linux/inetdevice.h ============================================================================== --- stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:36:40 2017 (r324526) +++ stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:56:59 2017 (r324527) @@ -34,23 +34,25 @@ #include static inline struct net_device * -ip_dev_find(struct net *net, uint32_t addr) +ip_dev_find(struct vnet *vnet, uint32_t addr) { struct sockaddr_in sin; struct ifaddr *ifa; struct ifnet *ifp; - ifp = NULL; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = addr; - sin.sin_port = 0; sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; + CURVNET_SET_QUIET(vnet); ifa = ifa_ifwithaddr((struct sockaddr *)&sin); + CURVNET_RESTORE(); if (ifa) { ifp = ifa->ifa_ifp; if_ref(ifp); ifa_free(ifa); + } else { + ifp = NULL; } return (ifp); } Modified: stable/10/sys/ofed/include/linux/linux_compat.c ============================================================================== --- stable/10/sys/ofed/include/linux/linux_compat.c Wed Oct 11 10:36:40 2017 (r324526) +++ stable/10/sys/ofed/include/linux/linux_compat.c Wed Oct 11 10:56:59 2017 (r324527) @@ -80,7 +80,6 @@ struct device linux_rootdev; struct class miscclass; struct list_head pci_drivers; struct list_head pci_devices; -struct net init_net; spinlock_t pci_lock; unsigned long linux_timer_hz_mask; Modified: stable/10/sys/ofed/include/linux/netdevice.h ============================================================================== --- stable/10/sys/ofed/include/linux/netdevice.h Wed Oct 11 10:36:40 2017 (r324526) +++ stable/10/sys/ofed/include/linux/netdevice.h Wed Oct 11 10:56:59 2017 (r324527) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,24 +38,40 @@ #include #include +#include #include #include #include #include #include -struct net { -}; +#ifdef VIMAGE +#define init_net *vnet0 +#else +#define init_net *((struct vnet *)0) +#endif -extern struct net init_net; - #define MAX_ADDR_LEN 20 #define net_device ifnet -#define dev_get_by_index(n, idx) ifnet_byindex_ref((idx)) -#define dev_hold(d) if_ref((d)) -#define dev_put(d) if_rele((d)) +static inline struct ifnet * +dev_get_by_index(struct vnet *vnet, int if_index) +{ + struct ifnet *retval; + + CURVNET_SET(vnet); + retval = ifnet_byindex_ref(if_index); + CURVNET_RESTORE(); + + return (retval); +} + +#define dev_hold(d) if_ref(d) +#define dev_put(d) if_rele(d) +#define dev_net(d) ((d)->if_vnet) + +#define net_eq(a,b) ((a) == (b)) #define netif_running(dev) !!((dev)->if_drv_flags & IFF_DRV_RUNNING) #define netif_oper_up(dev) !!((dev)->if_flags & IFF_UP) From owner-svn-src-stable-10@freebsd.org Wed Oct 11 23:21:25 2017 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 D1400E3A0F9; Wed, 11 Oct 2017 23:21:25 +0000 (UTC) (envelope-from rmacklem@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 9FE1981AD9; Wed, 11 Oct 2017 23:21:25 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BNLORd043875; Wed, 11 Oct 2017 23:21:24 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BNLORw043874; Wed, 11 Oct 2017 23:21:24 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201710112321.v9BNLORw043874@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 11 Oct 2017 23:21: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: r324543 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/10/sys/fs/nfsclient X-SVN-Commit-Revision: 324543 X-SVN-Commit-Repository: base 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, 11 Oct 2017 23:21:25 -0000 Author: rmacklem Date: Wed Oct 11 23:21:24 2017 New Revision: 324543 URL: https://svnweb.freebsd.org/changeset/base/324543 Log: MFC: r323689 Fix bogus FREAD with NFSV4OPEN_ACCESSREAD. No functional change. The code in nfscl_doflayoutio() bogusly used FREAD instead of NFSV4OPEN_ACCESSREAD. Since both happen to be defined as "1", this worked and the patch doesn't result in a functional change. Found by inspection during development of Flex File Layout support. Modified: stable/10/sys/fs/nfsclient/nfs_clrpcops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clrpcops.c Wed Oct 11 21:53:53 2017 (r324542) +++ stable/10/sys/fs/nfsclient/nfs_clrpcops.c Wed Oct 11 23:21:24 2017 (r324543) @@ -5766,7 +5766,7 @@ nfscl_doflayoutio(vnode_t vp, struct uio *uiop, int *i np->n_flag &= ~NDSCOMMIT; mtx_unlock(&np->n_mtx); } - } else if (rwflag == FREAD) + } else if (rwflag == NFSV4OPEN_ACCESSREAD) error = nfsrpc_readds(vp, uiop, stateidp, eofp, *dspp, io_off, xfer, fhp, cred, p); else { From owner-svn-src-stable-10@freebsd.org Wed Oct 11 23:33:51 2017 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 D56C0E3A4A3; Wed, 11 Oct 2017 23:33:51 +0000 (UTC) (envelope-from rmacklem@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 A352A8211E; Wed, 11 Oct 2017 23:33:51 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BNXovZ048858; Wed, 11 Oct 2017 23:33:50 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BNXoZI048857; Wed, 11 Oct 2017 23:33:50 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201710112333.v9BNXoZI048857@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 11 Oct 2017 23:33:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r324544 - stable/10/sys/fs/nfsserver X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/10/sys/fs/nfsserver X-SVN-Commit-Revision: 324544 X-SVN-Commit-Repository: base 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, 11 Oct 2017 23:33:52 -0000 Author: rmacklem Date: Wed Oct 11 23:33:50 2017 New Revision: 324544 URL: https://svnweb.freebsd.org/changeset/base/324544 Log: MFC: r323978 Change a panic to an error return. There was a panic() in the NFS server's write operation that didn't need to be a panic() and could just be an error return. This patch makes that change. Found by code inspection during development of the pNFS service. Modified: stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Wed Oct 11 23:21:24 2017 (r324543) +++ stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Wed Oct 11 23:33:50 2017 (r324544) @@ -910,7 +910,7 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int i nd->nd_md, nd->nd_dpos, nd->nd_cred, p); error = nfsm_advance(nd, NFSM_RNDUP(retlen), -1); if (error) - panic("nfsrv_write mbuf"); + goto nfsmout; } if (nd->nd_flag & ND_NFSV4) aftat_ret = 0; From owner-svn-src-stable-10@freebsd.org Wed Oct 11 23:42:31 2017 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 2ABF7E3A66D; Wed, 11 Oct 2017 23:42:31 +0000 (UTC) (envelope-from rmacklem@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 E61B6824FF; Wed, 11 Oct 2017 23:42:30 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9BNgUlT052894; Wed, 11 Oct 2017 23:42:30 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BNgUjn052893; Wed, 11 Oct 2017 23:42:30 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201710112342.v9BNgUjn052893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 11 Oct 2017 23:42:30 +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: r324545 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/10/sys/fs/nfsclient X-SVN-Commit-Revision: 324545 X-SVN-Commit-Repository: base 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, 11 Oct 2017 23:42:31 -0000 Author: rmacklem Date: Wed Oct 11 23:42:29 2017 New Revision: 324545 URL: https://svnweb.freebsd.org/changeset/base/324545 Log: MFC: r324074 Fix a memory leak that occurred in the pNFS client. When a "pnfs" NFSv4.1 mount was unmounted, it didn't free up the layouts and deviceinfo structures. This leak only affects "pnfs" mounts and only when the mount is umounted. Found while testing the pNFS Flexible File layout client code. Modified: stable/10/sys/fs/nfsclient/nfs_clstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clstate.c Wed Oct 11 23:33:50 2017 (r324544) +++ stable/10/sys/fs/nfsclient/nfs_clstate.c Wed Oct 11 23:42:29 2017 (r324545) @@ -1627,6 +1627,14 @@ nfscl_cleanclient(struct nfsclclient *clp) { struct nfsclowner *owp, *nowp; struct nfsclopen *op, *nop; + struct nfscllayout *lyp, *nlyp; + struct nfscldevinfo *dip, *ndip; + + TAILQ_FOREACH_SAFE(lyp, &clp->nfsc_layout, nfsly_list, nlyp) + nfscl_freelayout(lyp); + + LIST_FOREACH_SAFE(dip, &clp->nfsc_devinfo, nfsdi_list, ndip) + nfscl_freedevinfo(dip); /* Now, all the OpenOwners, etc. */ LIST_FOREACH_SAFE(owp, &clp->nfsc_owner, nfsow_list, nowp) { From owner-svn-src-stable-10@freebsd.org Fri Oct 13 02:01:05 2017 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 1D349E3A431; Fri, 13 Oct 2017 02:01:05 +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 DFC4C6F9B7; Fri, 13 Oct 2017 02:01:04 +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 v9D214Fb017094; Fri, 13 Oct 2017 02:01:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D2141B017093; Fri, 13 Oct 2017 02:01:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710130201.v9D2141B017093@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 13 Oct 2017 02:01: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: r324572 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/vmbus X-SVN-Commit-Revision: 324572 X-SVN-Commit-Repository: base 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, 13 Oct 2017 02:01:05 -0000 Author: sephe Date: Fri Oct 13 02:01:03 2017 New Revision: 324572 URL: https://svnweb.freebsd.org/changeset/base/324572 Log: MFC 324487 hyperv/vmbus: Add tunable to pin/unpin event tasks. Event tasks are pinned to their respective CPU by default, in the same fashion as they were. Unpin the event tasks by setting hw.vmbus.pin_evttask to 0, if certain CPUs serve special purpose. Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.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 Oct 12 21:58:51 2017 (r324571) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 13 02:01:03 2017 (r324572) @@ -129,6 +129,13 @@ static struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr); +SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Hyper-V vmbus"); + +static int vmbus_pin_evttask = 1; +SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN, + &vmbus_pin_evttask, 0, "Pin event tasks to their respective CPU"); + static const uint32_t vmbus_version[] = { VMBUS_VERSION_WIN8_1, VMBUS_VERSION_WIN8, @@ -978,13 +985,15 @@ vmbus_intr_setup(struct vmbus_softc *sc) taskqueue_start_threads(VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET, "hvevent%d", cpu); - CPU_SETOF(cpu, &cpu_mask); - TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task, - &cpu_mask); - taskqueue_enqueue(VMBUS_PCPU_GET(sc, event_tq, cpu), - &cpuset_task); - taskqueue_drain(VMBUS_PCPU_GET(sc, event_tq, cpu), - &cpuset_task); + if (vmbus_pin_evttask) { + CPU_SETOF(cpu, &cpu_mask); + TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task, + &cpu_mask); + taskqueue_enqueue(VMBUS_PCPU_GET(sc, event_tq, cpu), + &cpuset_task); + taskqueue_drain(VMBUS_PCPU_GET(sc, event_tq, cpu), + &cpuset_task); + } /* * Setup tasks and taskqueues to handle messages. From owner-svn-src-stable-10@freebsd.org Fri Oct 13 02:16:37 2017 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 2DAB6E3A7FC; Fri, 13 Oct 2017 02:16:37 +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 EDF5A70068; Fri, 13 Oct 2017 02:16: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 v9D2Gajr024443; Fri, 13 Oct 2017 02:16:36 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D2GaKd024441; Fri, 13 Oct 2017 02:16:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710130216.v9D2GaKd024441@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 13 Oct 2017 02:16: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: r324573 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: in stable/10/sys/dev/hyperv: include vmbus X-SVN-Commit-Revision: 324573 X-SVN-Commit-Repository: base 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, 13 Oct 2017 02:16:37 -0000 Author: sephe Date: Fri Oct 13 02:16:35 2017 New Revision: 324573 URL: https://svnweb.freebsd.org/changeset/base/324573 Log: MFC 324488 hyperv/vmbus: Expose Hyper-V major version. Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hyperv.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 Oct 13 02:01:03 2017 (r324572) +++ stable/10/sys/dev/hyperv/include/hyperv.h Fri Oct 13 02:16:35 2017 (r324573) @@ -90,6 +90,7 @@ int hyperv_guid2str(const struct hyperv_guid *, char */ extern hyperv_tc64_t hyperv_tc64; extern u_int hyperv_features; /* CPUID_HV_MSR_ */ +extern u_int hyperv_ver_major; #endif /* _KERNEL */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 13 02:01:03 2017 (r324572) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 13 02:16:35 2017 (r324573) @@ -77,6 +77,8 @@ static u_int hyperv_get_timecount(struct timecounter static bool hyperv_identify(void); static void hypercall_memfree(void); +u_int hyperv_ver_major; + u_int hyperv_features; u_int hyperv_recommends; @@ -169,8 +171,9 @@ hyperv_identify(void) hyperv_features3 = regs[3]; do_cpuid(CPUID_LEAF_HV_IDENTITY, regs); + hyperv_ver_major = regs[1] >> 16; printf("Hyper-V Version: %d.%d.%d [SP%d]\n", - regs[1] >> 16, regs[1] & 0xffff, regs[0], regs[2]); + hyperv_ver_major, regs[1] & 0xffff, regs[0], regs[2]); printf(" Features=0x%b\n", hyperv_features, "\020" From owner-svn-src-stable-10@freebsd.org Fri Oct 13 02:26:41 2017 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 ACC87E3AB69; Fri, 13 Oct 2017 02:26:41 +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 679F7704DA; Fri, 13 Oct 2017 02:26:41 +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 v9D2QejK028441; Fri, 13 Oct 2017 02:26:40 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D2QeEH028436; Fri, 13 Oct 2017 02:26:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710130226.v9D2QeEH028436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 13 Oct 2017 02:26: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: r324574 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324574 X-SVN-Commit-Repository: base 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, 13 Oct 2017 02:26:41 -0000 Author: sephe Date: Fri Oct 13 02:26:39 2017 New Revision: 324574 URL: https://svnweb.freebsd.org/changeset/base/324574 Log: MFC 324489,324516 324489 hyperv/hn: Workaround erroneous hash type observed on WS2016. Background: - UDP 4-tuple hash type is unconditionally enabled in Hyper-V on WS2016, which is _not_ affected by NDIS_OBJTYPE_RSS_PARAMS. - Non-fragment UDP/IPv4 datagrams' hash type is delivered to VM as TCP_IPV4. Currently this erroneous behavior only applies to WS2016/Windows10. Force l3/l4 protocol check, if the RXed packet's hash type is TCP_IPV4, and the Hyper-V is running on WS2016/Windows10. If the RXed packet is UDP datagram, adjust mbuf hash type to UDP_IPV4. Sponsored by: Microsoft 324516 hyperv/hn: Workaround erroneous hash type observed on WS2016 for VF. The background was described in r324489. Sponsored by: Microsoft 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 stable/10/sys/dev/hyperv/netvsc/ndis.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 Fri Oct 13 02:16:35 2017 (r324573) +++ stable/10/sys/dev/hyperv/netvsc/hn_nvs.c Fri Oct 13 02:26:39 2017 (r324574) @@ -601,6 +601,11 @@ hn_nvs_attach(struct hn_softc *sc, int mtu) { int error; + if (hyperv_ver_major >= 10) { + /* UDP 4-tuple hash is enforced. */ + sc->hn_caps |= HN_CAP_UDPHASH; + } + /* * Initialize NVS. */ Modified: stable/10/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Fri Oct 13 02:16:35 2017 (r324573) +++ stable/10/sys/dev/hyperv/netvsc/hn_rndis.c Fri Oct 13 02:26:39 2017 (r324574) @@ -522,6 +522,10 @@ hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_c /* Commit! */ sc->hn_rss_ind_size = indsz; sc->hn_rss_hcap = hash_func | hash_types; + if (sc->hn_caps & HN_CAP_UDPHASH) { + /* UDP 4-tuple hash is unconditionally enabled. */ + sc->hn_rss_hcap |= NDIS_HASH_UDP_IPV4_X; + } *rxr_cnt0 = rxr_cnt; return (0); } @@ -761,8 +765,10 @@ hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags) ("NDIS 6.20+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); /* XXX only one can be specified through, popcnt? */ - KASSERT((sc->hn_rss_hash & NDIS_HASH_FUNCTION_MASK), ("no hash func")); - KASSERT((sc->hn_rss_hash & NDIS_HASH_TYPE_MASK), ("no hash types")); + KASSERT((sc->hn_rss_hash & NDIS_HASH_FUNCTION_MASK), + ("no hash func %08x", sc->hn_rss_hash)); + KASSERT((sc->hn_rss_hash & NDIS_HASH_STD), + ("no standard hash types %08x", sc->hn_rss_hash)); KASSERT(sc->hn_rss_ind_size > 0, ("no indirect table size")); if (bootverbose) { @@ -781,7 +787,8 @@ hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags) prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; prm->ndis_hdr.ndis_size = rss_size; prm->ndis_flags = flags; - prm->ndis_hash = sc->hn_rss_hash; + prm->ndis_hash = sc->hn_rss_hash & + (NDIS_HASH_FUNCTION_MASK | NDIS_HASH_STD); prm->ndis_indsize = sizeof(rss->rss_ind[0]) * sc->hn_rss_ind_size; prm->ndis_indoffset = __offsetof(struct ndis_rssprm_toeplitz, rss_ind[0]); Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Oct 13 02:16:35 2017 (r324573) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Oct 13 02:26:39 2017 (r324574) @@ -119,6 +119,11 @@ __FBSDID("$FreeBSD$"); #define HN_IFSTART_SUPPORT +/* NOTE: M_HASHTYPE_RSS_UDP_IPV4 is not available on stable/10. */ +#ifndef M_HASHTYPE_RSS_UDP_IPV4 +#define M_HASHTYPE_RSS_UDP_IPV4 M_HASHTYPE_OPAQUE +#endif + #define HN_RING_CNT_DEF_MAX 8 #define HN_VFMAP_SIZE_DEF 8 @@ -378,6 +383,7 @@ static void hn_link_status(struct hn_softc *); static int hn_create_rx_data(struct hn_softc *, int); static void hn_destroy_rx_data(struct hn_softc *); static int hn_check_iplen(const struct mbuf *, int); +static void hn_rxpkt_proto(const struct mbuf *, int *, int *); static int hn_set_rxfilter(struct hn_softc *, uint32_t); static int hn_rxfilter_config(struct hn_softc *); static int hn_rss_reconfig(struct hn_softc *); @@ -392,6 +398,7 @@ static int hn_tx_ring_create(struct hn_softc *, int) static void hn_tx_ring_destroy(struct hn_tx_ring *); static int hn_create_tx_data(struct hn_softc *, int); static void hn_fixup_tx_data(struct hn_softc *); +static void hn_fixup_rx_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 *, @@ -1413,6 +1420,8 @@ hn_rss_type_fromndis(uint32_t rss_hash) types |= RSS_TYPE_TCP_IPV6; if (rss_hash & NDIS_HASH_TCP_IPV6_EX) types |= RSS_TYPE_TCP_IPV6_EX; + if (rss_hash & NDIS_HASH_UDP_IPV4_X) + types |= RSS_TYPE_UDP_IPV4; return (types); } @@ -1421,9 +1430,8 @@ hn_rss_type_tondis(uint32_t types) { uint32_t rss_hash = 0; - KASSERT((types & - (RSS_TYPE_UDP_IPV4 | RSS_TYPE_UDP_IPV6 | RSS_TYPE_UDP_IPV6_EX)) == 0, - ("UDP4, UDP6 and UDP6EX are not supported")); + KASSERT((types & (RSS_TYPE_UDP_IPV6 | RSS_TYPE_UDP_IPV6_EX)) == 0, + ("UDP6 and UDP6EX are not supported")); if (types & RSS_TYPE_IPV4) rss_hash |= NDIS_HASH_IPV4; @@ -1437,6 +1445,8 @@ hn_rss_type_tondis(uint32_t types) rss_hash |= NDIS_HASH_TCP_IPV6; if (types & RSS_TYPE_TCP_IPV6_EX) rss_hash |= NDIS_HASH_TCP_IPV6_EX; + if (types & RSS_TYPE_UDP_IPV4) + rss_hash |= NDIS_HASH_UDP_IPV4_X; return (rss_hash); } @@ -1535,6 +1545,13 @@ hn_vf_rss_fixup(struct hn_softc *sc, bool reconf) * NOTE: * We don't disable the hash type, but stop delivery the hash * value/type through mbufs on RX path. + * + * XXX If HN_CAP_UDPHASH is set in hn_caps, then UDP 4-tuple + * hash is delivered with type of TCP_IPV4. This means if + * UDP_IPV4 is enabled, then TCP_IPV4 should be forced, at + * least to hn_mbuf_hash. However, given that _all_ of the + * NICs implement TCP_IPV4, this will _not_ impose any issues + * here. */ if ((my_types & RSS_TYPE_IPV4) && (diff_types & ifrh.ifrh_types & @@ -2225,9 +2242,10 @@ hn_attach(device_t dev) #endif /* - * Fixup TX stuffs after synthetic parts are attached. + * Fixup TX/RX stuffs after synthetic parts are attached. */ hn_fixup_tx_data(sc); + hn_fixup_rx_data(sc); ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); @@ -3371,6 +3389,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int struct mbuf *m_new; int size, do_lro = 0, do_csum = 1, is_vf = 0; int hash_type = M_HASHTYPE_NONE; + int l3proto = ETHERTYPE_MAX, l4proto = IPPROTO_DONE; ifp = hn_ifp; if (rxr->hn_rxvf_ifp != NULL) { @@ -3470,31 +3489,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) do_lro = 1; } else { - const struct ether_header *eh; - uint16_t etype; - int hoff; - - hoff = sizeof(*eh); - /* Checked at the beginning of this function. */ - KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); - - eh = mtod(m_new, struct ether_header *); - etype = ntohs(eh->ether_type); - if (etype == ETHERTYPE_VLAN) { - const struct ether_vlan_header *evl; - - hoff = sizeof(*evl); - if (m_new->m_len < hoff) - goto skip; - evl = mtod(m_new, struct ether_vlan_header *); - etype = ntohs(evl->evl_proto); - } - - if (etype == ETHERTYPE_IP) { - int pr; - - pr = hn_check_iplen(m_new, hoff); - if (pr == IPPROTO_TCP) { + hn_rxpkt_proto(m_new, &l3proto, &l4proto); + if (l3proto == ETHERTYPE_IP) { + if (l4proto == IPPROTO_TCP) { if (do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_TCP)) { @@ -3505,7 +3502,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int m_new->m_pkthdr.csum_data = 0xffff; } do_lro = 1; - } else if (pr == IPPROTO_UDP) { + } else if (l4proto == IPPROTO_UDP) { if (do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_UDP)) { @@ -3515,7 +3512,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; } - } else if (pr != IPPROTO_DONE && do_csum && + } else if (l4proto != IPPROTO_DONE && do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_IP)) { rxr->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= @@ -3523,7 +3520,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int } } } -skip: + if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) { m_new->m_pkthdr.ether_vtag = EVL_MAKETAG( NDIS_VLAN_INFO_ID(info->vlan_info), @@ -3578,6 +3575,37 @@ skip: case NDIS_HASH_TCP_IPV4: hash_type = M_HASHTYPE_RSS_TCP_IPV4; + if (rxr->hn_rx_flags & HN_RX_FLAG_UDP_HASH) { + int def_htype = M_HASHTYPE_OPAQUE; + + if (is_vf) + def_htype = M_HASHTYPE_NONE; + + /* + * UDP 4-tuple hash is delivered as + * TCP 4-tuple hash. + */ + if (l3proto == ETHERTYPE_MAX) { + hn_rxpkt_proto(m_new, + &l3proto, &l4proto); + } + if (l3proto == ETHERTYPE_IP) { + if (l4proto == IPPROTO_UDP && + (rxr->hn_mbuf_hash & + NDIS_HASH_UDP_IPV4_X)) { + hash_type = + M_HASHTYPE_RSS_UDP_IPV4; + do_lro = 0; + } else if (l4proto != + IPPROTO_TCP) { + hash_type = def_htype; + do_lro = 0; + } + } else { + hash_type = def_htype; + do_lro = 0; + } + } break; case NDIS_HASH_IPV6: @@ -4823,6 +4851,36 @@ hn_check_iplen(const struct mbuf *m, int hoff) return ip->ip_p; } +static void +hn_rxpkt_proto(const struct mbuf *m_new, int *l3proto, int *l4proto) +{ + const struct ether_header *eh; + uint16_t etype; + int hoff; + + hoff = sizeof(*eh); + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); + + eh = mtod(m_new, const struct ether_header *); + etype = ntohs(eh->ether_type); + if (etype == ETHERTYPE_VLAN) { + const struct ether_vlan_header *evl; + + hoff = sizeof(*evl); + if (m_new->m_len < hoff) + return; + evl = mtod(m_new, const struct ether_vlan_header *); + etype = ntohs(evl->evl_proto); + } + *l3proto = etype; + + if (etype == ETHERTYPE_IP) + *l4proto = hn_check_iplen(m_new, hoff); + else + *l4proto = IPPROTO_DONE; +} + static int hn_create_rx_data(struct hn_softc *sc, int ring_cnt) { @@ -5531,6 +5589,18 @@ hn_fixup_tx_data(struct hn_softc *sc) if_printf(sc->hn_ifp, "support HASHVAL pktinfo\n"); for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_tx_flags |= HN_TX_FLAG_HASHVAL; + } +} + +static void +hn_fixup_rx_data(struct hn_softc *sc) +{ + + if (sc->hn_caps & HN_CAP_UDPHASH) { + int i; + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags |= HN_RX_FLAG_UDP_HASH; } } Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 13 02:16:35 2017 (r324573) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 13 02:26:39 2017 (r324574) @@ -97,6 +97,7 @@ struct hn_rx_ring { #define HN_RX_FLAG_ATTACHED 0x0001 #define HN_RX_FLAG_BR_REF 0x0002 #define HN_RX_FLAG_XPNT_VF 0x0004 +#define HN_RX_FLAG_UDP_HASH 0x0008 struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING @@ -305,11 +306,12 @@ do { \ #define HN_CAP_TSO4 0x0080 #define HN_CAP_TSO6 0x0100 #define HN_CAP_HASHVAL 0x0200 +#define HN_CAP_UDPHASH 0x0400 /* Capability description for use with printf(9) %b identifier. */ #define HN_CAP_BITS \ "\020\1VLAN\2MTU\3IPCS\4TCP4CS\5TCP6CS" \ - "\6UDP4CS\7UDP6CS\10TSO4\11TSO6\12HASHVAL" + "\6UDP4CS\7UDP6CS\10TSO4\11TSO6\12HASHVAL\13UDPHASH" #define HN_LINK_FLAG_LINKUP 0x0001 #define HN_LINK_FLAG_NETCHG 0x0002 Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Fri Oct 13 02:16:35 2017 (r324573) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Fri Oct 13 02:26:39 2017 (r324574) @@ -56,17 +56,26 @@ #define NDIS_HASH_IPV6_EX 0x00000800 #define NDIS_HASH_TCP_IPV6 0x00001000 #define NDIS_HASH_TCP_IPV6_EX 0x00002000 +#define NDIS_HASH_UDP_IPV4_X 0x00004000 /* XXX non-standard */ #define NDIS_HASH_ALL (NDIS_HASH_IPV4 | \ NDIS_HASH_TCP_IPV4 | \ NDIS_HASH_IPV6 | \ NDIS_HASH_IPV6_EX | \ NDIS_HASH_TCP_IPV6 | \ + NDIS_HASH_TCP_IPV6_EX |\ + NDIS_HASH_UDP_IPV4_X) + +#define NDIS_HASH_STD (NDIS_HASH_IPV4 | \ + NDIS_HASH_TCP_IPV4 | \ + NDIS_HASH_IPV6 | \ + NDIS_HASH_IPV6_EX | \ + NDIS_HASH_TCP_IPV6 | \ NDIS_HASH_TCP_IPV6_EX) /* Hash description for use with printf(9) %b identifier. */ #define NDIS_HASH_BITS \ - "\20\1TOEPLITZ\11IP4\12TCP4\13IP6\14IP6EX\15TCP6\16TCP6EX" + "\20\1TOEPLITZ\11IP4\12TCP4\13IP6\14IP6EX\15TCP6\16TCP6EX\17UDP4_X" #define NDIS_HASH_KEYSIZE_TOEPLITZ 40 #define NDIS_HASH_INDCNT 128 From owner-svn-src-stable-10@freebsd.org Fri Oct 13 02:29:44 2017 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 74520E3AC85; Fri, 13 Oct 2017 02:29:44 +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 430267065F; Fri, 13 Oct 2017 02:29:44 +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 v9D2Thhi028603; Fri, 13 Oct 2017 02:29:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D2Thhq028602; Fri, 13 Oct 2017 02:29:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201710130229.v9D2Thhq028602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 13 Oct 2017 02:29: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: r324575 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 324575 X-SVN-Commit-Repository: base 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, 13 Oct 2017 02:29:44 -0000 Author: sephe Date: Fri Oct 13 02:29:43 2017 New Revision: 324575 URL: https://svnweb.freebsd.org/changeset/base/324575 Log: MFC 324517 hyperv/hn: Enable transparent VF by default. Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c 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 Fri Oct 13 02:26:39 2017 (r324574) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Fri Oct 13 02:29:43 2017 (r324575) @@ -582,7 +582,7 @@ SYSCTL_PROC(_hw_hn, OID_AUTO, vfmap, CTLFLAG_RD | CTLT 0, 0, hn_vfmap_sysctl, "A", "VF mapping"); /* Transparent VF */ -static int hn_xpnt_vf = 0; +static int hn_xpnt_vf = 1; SYSCTL_INT(_hw_hn, OID_AUTO, vf_transparent, CTLFLAG_RDTUN, &hn_xpnt_vf, 0, "Transparent VF mod"); From owner-svn-src-stable-10@freebsd.org Fri Oct 13 09:05:21 2017 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 3DA64E41F8B; Fri, 13 Oct 2017 09:05:21 +0000 (UTC) (envelope-from avg@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 0A2787EF30; Fri, 13 Oct 2017 09:05:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9D95Kx7096670; Fri, 13 Oct 2017 09:05:20 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D95KUs096669; Fri, 13 Oct 2017 09:05:20 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710130905.v9D95KUs096669@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 13 Oct 2017 09:05:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r324582 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Commit-Revision: 324582 X-SVN-Commit-Repository: base 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, 13 Oct 2017 09:05:21 -0000 Author: avg Date: Fri Oct 13 09:05:20 2017 New Revision: 324582 URL: https://svnweb.freebsd.org/changeset/base/324582 Log: MFC r323524: MFV r316932: 6280 libzfs: unshare_one() could fail with EZFS_SHARENFSFAILED Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Fri Oct 13 07:50:44 2017 (r324581) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Fri Oct 13 09:05:20 2017 (r324582) @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov @@ -872,7 +873,7 @@ unshare_one(libzfs_handle_t *hdl, const char *name, co /* make sure libshare initialized */ if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { free(mntpt); /* don't need the copy anymore */ - return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, + return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, _sa_errorstr(err))); } From owner-svn-src-stable-10@freebsd.org Fri Oct 13 09:07:59 2017 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 962A5E421BF; Fri, 13 Oct 2017 09:07:59 +0000 (UTC) (envelope-from avg@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 62E4E7F4DC; Fri, 13 Oct 2017 09:07:59 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9D97wpk097243; Fri, 13 Oct 2017 09:07:58 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D97wkh097242; Fri, 13 Oct 2017 09:07:58 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710130907.v9D97wkh097242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 13 Oct 2017 09:07: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: r324585 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Commit-Revision: 324585 X-SVN-Commit-Repository: base 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, 13 Oct 2017 09:07:59 -0000 Author: avg Date: Fri Oct 13 09:07:58 2017 New Revision: 324585 URL: https://svnweb.freebsd.org/changeset/base/324585 Log: MFC r323525: MFV r323523: 8331 zfs_unshare returns wrong error code for smb unshare failure Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Fri Oct 13 09:06:57 2017 (r324584) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Fri Oct 13 09:07:58 2017 (r324585) @@ -24,6 +24,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov + * Copyright 2017 RackTop Systems. */ /* @@ -88,7 +89,7 @@ zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, c zfs_share_proto_t); /* - * The share protocols table must be in the same order as the zfs_share_prot_t + * The share protocols table must be in the same order as the zfs_share_proto_t * enum in libzfs_impl.h */ typedef struct { @@ -873,7 +874,7 @@ unshare_one(libzfs_handle_t *hdl, const char *name, co /* make sure libshare initialized */ if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { free(mntpt); /* don't need the copy anymore */ - return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, + return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, _sa_errorstr(err))); } @@ -884,12 +885,13 @@ unshare_one(libzfs_handle_t *hdl, const char *name, co if (share != NULL) { err = zfs_sa_disable_share(share, proto_table[proto].p_name); if (err != SA_OK) { - return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, + return (zfs_error_fmt(hdl, + proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, _sa_errorstr(err))); } } else { - return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, + return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"), name)); } From owner-svn-src-stable-10@freebsd.org Fri Oct 13 09:11:25 2017 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 C26A8E42341; Fri, 13 Oct 2017 09:11:25 +0000 (UTC) (envelope-from avg@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 8F4B57F857; Fri, 13 Oct 2017 09:11:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9D9BOEB099863; Fri, 13 Oct 2017 09:11:24 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D9BOmr099862; Fri, 13 Oct 2017 09:11:24 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710130911.v9D9BOmr099862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 13 Oct 2017 09:11: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: r324587 - stable/10/cddl/contrib/opensolaris/lib/libzpool/common X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/10/cddl/contrib/opensolaris/lib/libzpool/common X-SVN-Commit-Revision: 324587 X-SVN-Commit-Repository: base 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, 13 Oct 2017 09:11:25 -0000 Author: avg Date: Fri Oct 13 09:11:24 2017 New Revision: 324587 URL: https://svnweb.freebsd.org/changeset/base/324587 Log: MFC r323528: MFV r323527: 5815 libzpool's panic function doesn't set global panicstr Modified: stable/10/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Fri Oct 13 09:10:37 2017 (r324586) +++ stable/10/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Fri Oct 13 09:11:24 2017 (r324587) @@ -727,11 +727,9 @@ static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n" void vpanic(const char *fmt, va_list adx) { - (void) fprintf(stderr, "error: "); - (void) vfprintf(stderr, fmt, adx); - (void) fprintf(stderr, "\n"); - - abort(); /* think of it as a "user-level crash dump" */ + char buf[512]; + (void) vsnprintf(buf, 512, fmt, adx); + assfail(buf, NULL, 0); } void From owner-svn-src-stable-10@freebsd.org Fri Oct 13 09:14:06 2017 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 7750EE425C8; Fri, 13 Oct 2017 09:14:06 +0000 (UTC) (envelope-from avg@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 44B8E7FCEF; Fri, 13 Oct 2017 09:14:06 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9D9E5jh001746; Fri, 13 Oct 2017 09:14:05 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9D9E5YZ001744; Fri, 13 Oct 2017 09:14:05 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201710130914.v9D9E5YZ001744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 13 Oct 2017 09:14: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: r324589 - stable/10/sys/geom/mirror X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/10/sys/geom/mirror X-SVN-Commit-Revision: 324589 X-SVN-Commit-Repository: base 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, 13 Oct 2017 09:14:06 -0000 Author: avg Date: Fri Oct 13 09:14:05 2017 New Revision: 324589 URL: https://svnweb.freebsd.org/changeset/base/324589 Log: MFC r323612: gmirror: treat ENXIO as disk disconnect, not media error Modified: stable/10/sys/geom/mirror/g_mirror.c stable/10/sys/geom/mirror/g_mirror.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/10/sys/geom/mirror/g_mirror.c Fri Oct 13 09:13:08 2017 (r324588) +++ stable/10/sys/geom/mirror/g_mirror.c Fri Oct 13 09:14:05 2017 (r324589) @@ -975,7 +975,13 @@ g_mirror_regular_request(struct bio *bp) if (g_mirror_disconnect_on_failure && g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE) > 1) { - sc->sc_bump_id |= G_MIRROR_BUMP_GENID; + if (bp->bio_error == ENXIO && + bp->bio_cmd == BIO_READ) + sc->sc_bump_id |= G_MIRROR_BUMP_SYNCID; + else if (bp->bio_error == ENXIO) + sc->sc_bump_id |= G_MIRROR_BUMP_SYNCID_NOW; + else + sc->sc_bump_id |= G_MIRROR_BUMP_GENID; g_mirror_event_send(disk, G_MIRROR_DISK_STATE_DISCONNECTED, G_MIRROR_EVENT_DONTWAIT); @@ -2479,6 +2485,10 @@ g_mirror_update_device(struct g_mirror_softc *sc, bool if ((sc->sc_bump_id & G_MIRROR_BUMP_GENID) != 0) { sc->sc_bump_id &= ~G_MIRROR_BUMP_GENID; g_mirror_bump_genid(sc); + } + if ((sc->sc_bump_id & G_MIRROR_BUMP_SYNCID_NOW) != 0) { + sc->sc_bump_id &= ~G_MIRROR_BUMP_SYNCID_NOW; + g_mirror_bump_syncid(sc); } break; default: Modified: stable/10/sys/geom/mirror/g_mirror.h ============================================================================== --- stable/10/sys/geom/mirror/g_mirror.h Fri Oct 13 09:13:08 2017 (r324588) +++ stable/10/sys/geom/mirror/g_mirror.h Fri Oct 13 09:14:05 2017 (r324589) @@ -166,9 +166,11 @@ struct g_mirror_event { #define G_MIRROR_DEVICE_STATE_RUNNING 1 /* Bump syncid on first write. */ -#define G_MIRROR_BUMP_SYNCID 0x1 +#define G_MIRROR_BUMP_SYNCID 0x1 /* Bump genid immediately. */ -#define G_MIRROR_BUMP_GENID 0x2 +#define G_MIRROR_BUMP_GENID 0x2 +/* Bump syncid immediately. */ +#define G_MIRROR_BUMP_SYNCID_NOW 0x4 struct g_mirror_softc { u_int sc_state; /* Device state. */ uint32_t sc_slice; /* Slice size. */ From owner-svn-src-stable-10@freebsd.org Fri Oct 13 17:11:10 2017 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 120DEE2783B; Fri, 13 Oct 2017 17:11:10 +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 CD35B6D770; Fri, 13 Oct 2017 17:11:09 +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 v9DHB9hr003582; Fri, 13 Oct 2017 17:11:09 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9DHB9rt003581; Fri, 13 Oct 2017 17:11:09 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201710131711.v9DHB9rt003581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 13 Oct 2017 17:11: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: r324602 - in stable: 10/sys/vm 11/sys/vm X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/vm 11/sys/vm X-SVN-Commit-Revision: 324602 X-SVN-Commit-Repository: base 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, 13 Oct 2017 17:11:10 -0000 Author: jhb Date: Fri Oct 13 17:11:08 2017 New Revision: 324602 URL: https://svnweb.freebsd.org/changeset/base/324602 Log: MFC 324072: Add UMA_ALIGNOF(). This is a wrapper around _Alignof() that sets the alignment for a zone to the alignment required by a given type. This allows the compiler to determine the proper alignment rather than having the programmer try to guess. Modified: stable/10/sys/vm/uma.h Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/vm/uma.h Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/vm/uma.h ============================================================================== --- stable/10/sys/vm/uma.h Fri Oct 13 16:31:50 2017 (r324601) +++ stable/10/sys/vm/uma.h Fri Oct 13 17:11:08 2017 (r324602) @@ -296,6 +296,7 @@ uma_zone_t uma_zcache_create(char *name, int size, uma #define UMA_ALIGN_SHORT (sizeof(short) - 1) /* "" short */ #define UMA_ALIGN_CHAR (sizeof(char) - 1) /* "" char */ #define UMA_ALIGN_CACHE (0 - 1) /* Cache line size align */ +#define UMA_ALIGNOF(type) (_Alignof(type) - 1) /* Alignment fit for 'type' */ /* * Destroys an empty uma zone. If the zone is not empty uma complains loudly. From owner-svn-src-stable-10@freebsd.org Fri Oct 13 21:58:45 2017 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 78A5DE2E1B6; Fri, 13 Oct 2017 21:58:45 +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 45EC3766DA; Fri, 13 Oct 2017 21:58:45 +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 v9DLwidn026667; Fri, 13 Oct 2017 21:58:44 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9DLwiVH026666; Fri, 13 Oct 2017 21:58:44 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201710132158.v9DLwiVH026666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 13 Oct 2017 21:58:44 +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: r324611 - in stable: 10/sys/kern 11/sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/kern 11/sys/kern X-SVN-Commit-Revision: 324611 X-SVN-Commit-Repository: base 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, 13 Oct 2017 21:58:45 -0000 Author: jhb Date: Fri Oct 13 21:58:44 2017 New Revision: 324611 URL: https://svnweb.freebsd.org/changeset/base/324611 Log: MFC 324073: Use UMA_ALIGNOF() for name cache UMA zones. This fixes kernel crashes due to misaligned accesses to the 64-bit time_t embedded in struct namecache_ts in MIPS n32 kernels. Modified: stable/10/sys/kern/vfs_cache.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/vfs_cache.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/kern/vfs_cache.c ============================================================================== --- stable/10/sys/kern/vfs_cache.c Fri Oct 13 21:54:34 2017 (r324610) +++ stable/10/sys/kern/vfs_cache.c Fri Oct 13 21:58:44 2017 (r324611) @@ -907,16 +907,20 @@ nchinit(void *dummy __unused) cache_zone_small = uma_zcreate("S VFS Cache", sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1, - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache), + UMA_ZONE_ZINIT); cache_zone_small_ts = uma_zcreate("STS VFS Cache", sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1, - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache_ts), + UMA_ZONE_ZINIT); cache_zone_large = uma_zcreate("L VFS Cache", sizeof(struct namecache) + NAME_MAX + 1, - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache), + UMA_ZONE_ZINIT); cache_zone_large_ts = uma_zcreate("LTS VFS Cache", sizeof(struct namecache_ts) + NAME_MAX + 1, - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT); + NULL, NULL, NULL, NULL, UMA_ALIGNOF(struct namecache_ts), + UMA_ZONE_ZINIT); nchashtbl = hashinit(desiredvnodes * 2, M_VFSCACHE, &nchash); } From owner-svn-src-stable-10@freebsd.org Fri Oct 13 22:40:58 2017 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 48C8FE2F04B; Fri, 13 Oct 2017 22:40:58 +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 168CB779CE; Fri, 13 Oct 2017 22:40:58 +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 v9DMevQb045892; Fri, 13 Oct 2017 22:40:57 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9DMev9g045891; Fri, 13 Oct 2017 22:40:57 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201710132240.v9DMev9g045891@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 13 Oct 2017 22:40:57 +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: r324612 - in stable: 10/sys/ufs/ffs 11/sys/ufs/ffs X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/ufs/ffs 11/sys/ufs/ffs X-SVN-Commit-Revision: 324612 X-SVN-Commit-Repository: base 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, 13 Oct 2017 22:40:58 -0000 Author: jhb Date: Fri Oct 13 22:40:57 2017 New Revision: 324612 URL: https://svnweb.freebsd.org/changeset/base/324612 Log: MFC 324039: Don't defer wakeup()s for completed journal workitems. Normally wakeups() are performed for completed softupdates work items in workitem_free() before the underlying memory is free()'d. complete_jseg() was clearing the "wakeup needed" flag in work items to defer the wakeup until the end of each loop iteration. However, this resulted in the item being free'd before it's address was used with wakeup(). As a result, another part of the kernel could allocate this memory from malloc() and use it as a wait channel for a different "event" with a different lock. This triggered an assertion failure when the lock passed to sleepq_add() did not match the existing lock associated with the sleep queue. Fix this by removing the code to defer the wakeup in complete_jseg() allowing the wakeup to occur slightly earlier in workitem_free() before free() is called. Modified: stable/10/sys/ufs/ffs/ffs_softdep.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/ufs/ffs/ffs_softdep.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/10/sys/ufs/ffs/ffs_softdep.c Fri Oct 13 21:58:44 2017 (r324611) +++ stable/10/sys/ufs/ffs/ffs_softdep.c Fri Oct 13 22:40:57 2017 (r324612) @@ -3594,15 +3594,13 @@ complete_jseg(jseg) { struct worklist *wk; struct jmvref *jmvref; - int waiting; #ifdef INVARIANTS int i = 0; #endif while ((wk = LIST_FIRST(&jseg->js_entries)) != NULL) { WORKLIST_REMOVE(wk); - waiting = wk->wk_state & IOWAITING; - wk->wk_state &= ~(INPROGRESS | IOWAITING); + wk->wk_state &= ~INPROGRESS; wk->wk_state |= COMPLETE; KASSERT(i++ < jseg->js_cnt, ("handle_written_jseg: overflow %d >= %d", @@ -3643,8 +3641,6 @@ complete_jseg(jseg) TYPENAME(wk->wk_type)); /* NOTREACHED */ } - if (waiting) - wakeup(wk); } /* Release the self reference so the structure may be freed. */ rele_jseg(jseg); From owner-svn-src-stable-10@freebsd.org Sat Oct 14 16:49:40 2017 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 51B93E4AD52; Sat, 14 Oct 2017 16:49:40 +0000 (UTC) (envelope-from brooks@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 1E52A7505C; Sat, 14 Oct 2017 16:49:40 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9EGndYL001683; Sat, 14 Oct 2017 16:49:39 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9EGnd5R001682; Sat, 14 Oct 2017 16:49:39 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201710141649.v9EGnd5R001682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Sat, 14 Oct 2017 16:49: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: r324617 - stable/10/lib/libc/gen X-SVN-Group: stable-10 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/10/lib/libc/gen X-SVN-Commit-Revision: 324617 X-SVN-Commit-Repository: base 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, 14 Oct 2017 16:49:40 -0000 Author: brooks Date: Sat Oct 14 16:49:39 2017 New Revision: 324617 URL: https://svnweb.freebsd.org/changeset/base/324617 Log: MFC r324243: Remove an unneeded and incorrect memset(). On Variant I TLS architectures (aarch64, arm, mips, powerpc, and riscv) the __libc_allocate_tls function allocates thread local storage memory with calloc(). It then copies initialization data over the portions with non-zero initial values. Before this change it would then pointlessly zero the already zeroed remainder of the storage. Unfortunately the calculation was wrong and it would zero TLS_TCB_SIZE (2*sizeof(void *)) additional bytes. In practice, this overflow only matters if the TLS segment is sized such that calloc() allocates less than TLS_TCB_SIZE extra memory. Even then, the likely result will be zeroing part of the next bucket. This coupled with the impact being confined to Tier II platforms means there will be no security advisory for this issue. Reviewed by: kib, dfr Discussed with: security-officer (delphij) Found by: CHERI Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12547 Modified: stable/10/lib/libc/gen/tls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/tls.c ============================================================================== --- stable/10/lib/libc/gen/tls.c Sat Oct 14 16:23:25 2017 (r324616) +++ stable/10/lib/libc/gen/tls.c Sat Oct 14 16:49:39 2017 (r324617) @@ -161,9 +161,6 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size if (tls_init_size > 0) memcpy((void*)dtv[2], tls_init, tls_init_size); - if (tls_static_space > tls_init_size) - memset((void*)(dtv[2] + tls_init_size), 0, - tls_static_space - tls_init_size); } return(tcb);