svn commit: r347423 - head/sys/dev/random

2019-05-09 Thread Mark Johnston
Author: markj
Date: Fri May 10 04:28:17 2019
New Revision: 347423
URL: https://svnweb.freebsd.org/changeset/base/347423

Log:
  Avoid returning a NULL pointer from the Intel hw PRNG ifunc resolver.
  
  DTrace expects kernel function symbols of a non-zero size to have an
  implementation, which is a reasonable invariant to preserve.
  
  Reported and tested by:   ler
  Reviewed by:  cem, kib
  Approved by:  so (delphij)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D20218

Modified:
  head/sys/dev/random/ivy.c

Modified: head/sys/dev/random/ivy.c
==
--- head/sys/dev/random/ivy.c   Fri May 10 02:30:16 2019(r347422)
+++ head/sys/dev/random/ivy.c   Fri May 10 04:28:17 2019(r347423)
@@ -97,6 +97,13 @@ x86_rdseed_store(u_long *buf)
return (retry);
 }
 
+static int
+x86_unimpl_store(u_long *buf __unused)
+{
+
+   panic("%s called", __func__);
+}
+
 DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf), static)
 {
has_rdrand = (cpu_feature2 & CPUID2_RDRAND);
@@ -107,7 +114,7 @@ DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf)
else if (has_rdrand)
return (x86_rdrand_store);
else
-   return (NULL);
+   return (x86_unimpl_store);
 }
 
 /* It is required that buf length is a multiple of sizeof(u_long). */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347422 - head/sys/dev/dcons

2019-05-09 Thread Ian Lepore
Author: ian
Date: Fri May 10 02:30:16 2019
New Revision: 347422
URL: https://svnweb.freebsd.org/changeset/base/347422

Log:
  Allow dcons(4) to be unloaded when loaded as a module.
  
  When the module is unloaded, the tty devices are destroyed.  That requires
  implementing the tsw_free callback to avoid a panic.  This driver requires
  no particular cleanup to be done from the callback, but the module itself
  must remain in memory until the deferred tsw_free callbacks are invoked.
  These changes implement that by incrementing a reference count variable in
  the detach routine, and decrementing it in the tsw_free callback.  The
  MOD_UNLOAD event handler doesn't return until the count drops to zero.
  
  PR: 237758

Modified:
  head/sys/dev/dcons/dcons_os.c

Modified: head/sys/dev/dcons/dcons_os.c
==
--- head/sys/dev/dcons/dcons_os.c   Fri May 10 01:22:11 2019
(r347421)
+++ head/sys/dev/dcons/dcons_os.c   Fri May 10 02:30:16 2019
(r347422)
@@ -52,6 +52,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -135,12 +136,16 @@ extern struct gdb_dbgport *gdb_cur;
 #endif
 
 static tsw_outwakeup_t dcons_outwakeup;
+static tsw_free_t  dcons_free;
 
 static struct ttydevsw dcons_ttydevsw = {
.tsw_flags  = TF_NOPREFIX,
.tsw_outwakeup  = dcons_outwakeup,
+   .tsw_free   = dcons_free,
 };
 
+static int dcons_close_refs;
+
 #if (defined(GDB) || defined(DDB))
 static int
 dcons_check_break(struct dcons_softc *dc, int c)
@@ -198,6 +203,14 @@ dcons_os_putc(struct dcons_softc *dc, int c)
 }
 
 static void
+dcons_free(void *xsc __unused)
+{
+
+   /* Our deferred free has arrived, now we're waiting for one fewer. */
+   atomic_subtract_rel_int(&dcons_close_refs, 1);
+}
+
+static void
 dcons_outwakeup(struct tty *tp)
 {
struct dcons_softc *dc;
@@ -396,6 +409,8 @@ dcons_detach(int port)
dc = &sc[port];
tp = dc->tty;
 
+   /* tty_rel_gone() schedules a deferred free callback, count it. */
+   atomic_add_int(&dcons_close_refs, 1);
tty_lock(tp);
tty_rel_gone(tp);
 
@@ -430,6 +445,9 @@ dcons_modevent(module_t mode, int type, void *data)
contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
}
 
+   /* Wait for tty deferred free callbacks to complete. */
+   while (atomic_load_acq_int(&dcons_close_refs) > 0)
+pause_sbt("dcunld", mstosbt(50), mstosbt(10), 0);
break;
case MOD_SHUTDOWN:
 #if 0  /* Keep connection after halt */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347418 - head/sys/net

2019-05-09 Thread Eric Joyner
Author: erj
Date: Fri May 10 00:41:42 2019
New Revision: 347418
URL: https://svnweb.freebsd.org/changeset/base/347418

Log:
  iflib: use default ntxd and nrxd when user value is not power of 2
  
  From Jake:
  A user may set a sysctl to override the default number of Tx or Rx
  descriptors. However, certain calculations in the iflib core expect the
  number of descriptors to be a power of 2.
  
  Update _iflib_assert to verify that all of the shared context parameters
  for the number of descriptors are powers of 2.
  
  Modify iflib_reset_qvalues to check that the provided isc_nrxd value is
  a power of 2. If it's not, print a warning message and then use the
  default value.
  
  An alternative might be to try rounding the number down instead.
  However, this creates problems in case the rounded down value is below
  the minimum value that the driver would support.
  
  Submitted by: Jacob Keller 
  Reviewed by:  marius@
  MFC after:1 week
  Sponsored by: Intel Corporation
  Differential Revision:https://reviews.freebsd.org/D19880

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cFri May 10 00:03:32 2019(r347417)
+++ head/sys/net/iflib.cFri May 10 00:41:42 2019(r347418)
@@ -4387,9 +4387,6 @@ iflib_reset_qvalues(if_ctx_t ctx)
 
scctx->isc_txrx_budget_bytes_max = IFLIB_MAX_TX_BYTES;
scctx->isc_tx_qdepth = IFLIB_DEFAULT_TX_QDEPTH;
-   /*
-* XXX sanity check that ntxd & nrxd are a power of 2
-*/
if (ctx->ifc_sysctl_ntxqs != 0)
scctx->isc_ntxqsets = ctx->ifc_sysctl_ntxqs;
if (ctx->ifc_sysctl_nrxqs != 0)
@@ -4420,6 +4417,11 @@ iflib_reset_qvalues(if_ctx_t ctx)
  i, scctx->isc_nrxd[i], 
sctx->isc_nrxd_max[i]);
scctx->isc_nrxd[i] = sctx->isc_nrxd_max[i];
}
+   if (!powerof2(scctx->isc_nrxd[i])) {
+   device_printf(dev, "nrxd%d: %d is not a power of 2 - 
using default value of %d\n",
+ i, scctx->isc_nrxd[i], 
sctx->isc_nrxd_default[i]);
+   scctx->isc_nrxd[i] = sctx->isc_nrxd_default[i];
+   }
}
 
for (i = 0; i < sctx->isc_ntxqs; i++) {
@@ -4433,6 +4435,11 @@ iflib_reset_qvalues(if_ctx_t ctx)
  i, scctx->isc_ntxd[i], 
sctx->isc_ntxd_max[i]);
scctx->isc_ntxd[i] = sctx->isc_ntxd_max[i];
}
+   if (!powerof2(scctx->isc_ntxd[i])) {
+   device_printf(dev, "ntxd%d: %d is not a power of 2 - 
using default value of %d\n",
+ i, scctx->isc_ntxd[i], 
sctx->isc_ntxd_default[i]);
+   scctx->isc_ntxd[i] = sctx->isc_ntxd_default[i];
+   }
}
 }
 
@@ -4543,7 +4550,7 @@ iflib_device_register(device_t dev, void *sc, if_share
if_softc_ctx_t scctx;
kobjop_desc_t kobj_desc;
kobj_method_t *kobj_method;
-   int err, i, msix, rid;
+   int err, msix, rid;
uint16_t main_rxq, main_txq;
 
ctx = malloc(sizeof(* ctx), M_IFLIB, M_WAITOK|M_ZERO);
@@ -4598,23 +4605,6 @@ iflib_device_register(device_t dev, void *sc, if_share
/* XXX change for per-queue sizes */
device_printf(dev, "Using %d TX descriptors and %d RX descriptors\n",
scctx->isc_ntxd[main_txq], scctx->isc_nrxd[main_rxq]);
-   for (i = 0; i < sctx->isc_nrxqs; i++) {
-   if (!powerof2(scctx->isc_nrxd[i])) {
-   /* round down instead? */
-   device_printf(dev,
-   "# RX descriptors must be a power of 2\n");
-   err = EINVAL;
-   goto fail_iflib_detach;
-   }
-   }
-   for (i = 0; i < sctx->isc_ntxqs; i++) {
-   if (!powerof2(scctx->isc_ntxd[i])) {
-   device_printf(dev,
-   "# TX descriptors must be a power of 2");
-   err = EINVAL;
-   goto fail_iflib_detach;
-   }
-   }
 
if (scctx->isc_tx_nsegments > scctx->isc_ntxd[main_txq] /
MAX_SINGLE_PACKET_FRACTION)
@@ -4790,7 +4780,6 @@ fail_intr_free:
 fail_queues:
iflib_tx_structures_free(ctx);
iflib_rx_structures_free(ctx);
-fail_iflib_detach:
IFDI_DETACH(ctx);
 fail_unlock:
CTX_UNLOCK(ctx);
@@ -4833,9 +4822,6 @@ iflib_pseudo_register(device_t dev, if_shared_ctx_t sc
scctx = &ctx->ifc_softc_ctx;
ifp = ctx->ifc_ifp;
 
-   /*
-* XXX sanity check that ntxd & nrxd are a power of 2
-*/
iflib_reset_qvalues(ctx);
CTX_LOCK(ctx);
if ((err = IFDI_ATTACH_PRE(ctx)) != 0) {
@@ -4899,23 +4885,6 @@ iflib_pseudo_register(device_t d

svn commit: r347417 - in head: . tests/sys/opencrypto

2019-05-09 Thread Enji Cooper
Author: ngie
Date: Fri May 10 00:03:32 2019
New Revision: 347417
URL: https://svnweb.freebsd.org/changeset/base/347417

Log:
  Refactor tests/sys/opencrypto/runtests
  
  * Convert from plain to TAP for slightly improved introspection when skipping
the tests due to requirements not being met.
  * Test for the net/py-dpkt (origin) package being required when running the
tests, instead of relying on a copy of the dpkt.py module from 2014. This
enables the tests to work with py3. Subsequently, remove
`tests/sys/opencrypto/dpkt.py(c)?` via `make delete-old`.
  * Parameterize out `python2` as `$PYTHON`.
  
  PR:   237403
  MFC after:1 week

Deleted:
  head/tests/sys/opencrypto/dpkt.py
Modified:
  head/ObsoleteFiles.inc
  head/tests/sys/opencrypto/Makefile
  head/tests/sys/opencrypto/runtests.sh

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu May  9 23:57:02 2019(r347416)
+++ head/ObsoleteFiles.inc  Fri May 10 00:03:32 2019(r347417)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20190509: tests/sys/opencrypto requires the net/py-dpkt package.
+OLD_FILES+=usr/tests/sys/opencrypto/dpkt.py
+OLD_FILES+=usr/tests/sys/opencrypto/dpkt.pyc
 # 20190304: new libc++ import which bumps version from 7.0.1 to 8.0.0.
 OLD_FILES+=usr/include/c++/v1/experimental/dynarray
 # 20190304: new clang import which bumps version from 7.0.1 to 8.0.0.

Modified: head/tests/sys/opencrypto/Makefile
==
--- head/tests/sys/opencrypto/Makefile  Thu May  9 23:57:02 2019
(r347416)
+++ head/tests/sys/opencrypto/Makefile  Fri May 10 00:03:32 2019
(r347417)
@@ -12,12 +12,12 @@ CFLAGS.poly1305_test.c  += -I${SRCTOP}/sys/opencrypto
 
 ATF_TESTS_C+=  blake2_test poly1305_test
 
-PLAIN_TESTS_SH=runtests
+TAP_TESTS_SH+= runtests
 
 TEST_METADATA.runtests+= required_programs="python2"
 TEST_METADATA.runtests+= required_user="root"
 
-PYMODULES= cryptodev.py cryptodevh.py cryptotest.py dpkt.py
+PYMODULES= cryptodev.py cryptodevh.py cryptotest.py
 
 ${PACKAGE}FILES+=  ${PYMODULES}
 

Modified: head/tests/sys/opencrypto/runtests.sh
==
--- head/tests/sys/opencrypto/runtests.sh   Thu May  9 23:57:02 2019
(r347416)
+++ head/tests/sys/opencrypto/runtests.sh   Fri May 10 00:03:32 2019
(r347417)
@@ -29,13 +29,18 @@
 # $FreeBSD$
 #
 
-set -ex
+: ${PYTHON=python2}
 
 if [ ! -d /usr/local/share/nist-kat ]; then
-   echo 'Skipping, nist-kat package not installed for test vectors.'
+   echo "1..0 # SKIP: nist-kat package not installed for test vectors"
exit 0
 fi
 
+if ! $PYTHON -c "from dpkt import dpkt"; then
+   echo "1..0 # SKIP: py-dpkt package not installed"
+   exit 0
+fi
+
 loaded_modules=
 cleanup_tests()
 {
@@ -43,6 +48,10 @@ cleanup_tests()
 
set +e
 
+   if [ -n "$oldcdas" ]; then
+   sysctl "$oldcdas" 2>/dev/null
+   fi
+
# Unload modules in reverse order
for loaded_module in $(echo $loaded_modules | tr ' ' '\n' | sort -r); do
kldunload $loaded_module
@@ -52,15 +61,28 @@ trap cleanup_tests EXIT INT TERM
 
 for required_module in nexus/aesni cryptodev; do
if ! kldstat -q -m $required_module; then
-   kldload ${required_module#nexus/}
+   module_to_load=${required_module#nexus/}
+   if ! kldload ${module_to_load}; then
+   echo "1..0 # SKIP: could not load ${module_to_load}"
+   exit 0
+   fi
loaded_modules="$loaded_modules $required_module"
fi
 done
 
-# Run software crypto test
-oldcdas=$(sysctl -e kern.cryptodevallowsoft)
-sysctl kern.cryptodevallowsoft=1
+cdas_sysctl=kern.cryptodevallowsoft
+if ! oldcdas=$(sysctl -e $cdas_sysctl); then
+   echo "1..0 # SKIP: could not resolve sysctl: $cdas_sysctl"
+   exit 0
+fi
+if ! sysctl $cdas_sysctl=1; then
+   echo "1..0 # SKIP: could not enable /dev/crypto access via $cdas_sysctl 
sysctl."
+   exit 0
+fi
 
-python2 $(dirname $0)/cryptotest.py
-
-sysctl "$oldcdas"
+echo "1..1"
+if "$PYTHON" $(dirname $0)/cryptotest.py; then
+   echo "ok 1"
+else
+   echo "not ok 1"
+fi
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347415 - in head/sys/contrib/dev/acpica: . compiler components/events include

2019-05-09 Thread Jung-uk Kim
Author: jkim
Date: Thu May  9 23:03:10 2019
New Revision: 347415
URL: https://svnweb.freebsd.org/changeset/base/347415

Log:
  MFV:  r347413
  
  Import ACPICA 20190509.

Modified:
  head/sys/contrib/dev/acpica/changes.txt
  head/sys/contrib/dev/acpica/compiler/aslcodegen.c
  head/sys/contrib/dev/acpica/compiler/aslcompile.c
  head/sys/contrib/dev/acpica/compiler/aslcompiler.h
  head/sys/contrib/dev/acpica/compiler/aslerror.c
  head/sys/contrib/dev/acpica/compiler/aslfiles.c
  head/sys/contrib/dev/acpica/compiler/aslload.c
  head/sys/contrib/dev/acpica/compiler/aslmain.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.h
  head/sys/contrib/dev/acpica/compiler/asloperands.c
  head/sys/contrib/dev/acpica/compiler/aslstartup.c
  head/sys/contrib/dev/acpica/compiler/aslutils.c
  head/sys/contrib/dev/acpica/compiler/aslwalks.c
  head/sys/contrib/dev/acpica/compiler/aslxref.c
  head/sys/contrib/dev/acpica/components/events/evgpe.c
  head/sys/contrib/dev/acpica/include/acpixf.h
Directory Properties:
  head/sys/contrib/dev/acpica/   (props changed)

Modified: head/sys/contrib/dev/acpica/changes.txt
==
--- head/sys/contrib/dev/acpica/changes.txt Thu May  9 22:49:58 2019
(r347414)
+++ head/sys/contrib/dev/acpica/changes.txt Thu May  9 23:03:10 2019
(r347415)
@@ -1,4 +1,91 @@
 
+09 May 2019. Summary of changes for version 20190509:
+
+
+1) ACPICA kernel-resident subsystem:
+
+Revert commit  6c43e1a ("ACPICA: Clear status of GPEs before enabling 
+them") that causes problems with Thunderbolt controllers to occur if a 
+dock device is connected at init time (the xhci_hcd and thunderbolt 
+modules crash which prevents peripherals connected through them from 
+working). Commit 6c43e1a effectively causes commit ecc1165b8b74 ("ACPICA: 
+Dispatch active GPEs at init time") to get undone, so the problem 
+addressed by commit ecc1165b8b74 appears again as a result of it.
+
+
+2) iASL Compiler/Disassembler and ACPICA tools:
+
+Reverted iASL: Additional forward reference detection. This change 
+reverts forward reference detection for field declarations. The feature 
+unintentionally emitted AML bytecode with incorrect package lengths for 
+some ASL code related to Fields and OperationRegions. This malformed AML 
+can cause systems to crash
+during boot. The malformed AML bytecode is emitted in iASL version 
+20190329 and 20190405.
+
+iASL: improve forward reference detection. This change improves forward 
+reference detection for named objects inside of scopes. If a parse object 
+has the OP_NOT_FOUND_DURING_LOAD set, it means that Op is a reference to 
+a named object that is declared later in the AML bytecode. This is 
+allowed if the reference is inside of a method and the declaration is 
+outside of a method like so:
+
+DefinitionBlock(...)
+{
+Method (TEST)
+{
+Return (NUM0)
+}
+Name (NUM0,0)
+}
+
+However, if the declaration and reference are both in the same method or 
+outside any methods, this is a forward reference and should be marked as 
+an error because it would result in runtime errors.
+
+DefinitionBlock(...)
+{
+Name (BUFF, Buffer (NUM0) {}) // Forward reference
+Name (NUM0, 0x0)
+
+Method (TEST)
+{
+Local0 = NUM1
+Name (NUM1, 0x1) // Forward reference
+return (Local0)
+}
+}
+
+iASL: Implemented additional buffer overflow analysis for BufferField 
+declarations. Check if a buffer index argument to a create buffer field 
+operation is beyond the end of the target buffer.
+
+This affects these AML operators:
+ 
+   AML_CREATE_FIELD_OP
+   AML_CREATE_BIT_FIELD_OP
+   AML_CREATE_BYTE_FIELD_OP
+   AML_CREATE_WORD_FIELD_OP
+   AML_CREATE_DWORD_FIELD_OP
+   AML_CREATE_QWORD_FIELD_OP
+
+ There are three conditions that must be satisfied in order to allow this 
+validation at compile time:
+ 
+   1) The length of the target buffer must be an integer constant
+   2) The index specified in the create* must be an integer constant
+   3) For CreateField, the bit length argument must be non-zero.
+
+Example:
+Name (BUF1, Buffer() {1,2})
+CreateField (BUF1, 7, 9, CF03)  // 3: ERR
+
+dsdt.asl 14: CreateField (BUF1, 7, 9, CF03)  // 3: ERR
+Error6165 -   ^ Buffer index beyond end of 
+target buffer
+
+
+
 05 April 2019. Summary of changes for version 20190405:
 
 

Modified: head/sys/contrib/dev/acpica/compiler/aslcodegen.c
==
--- head/sys/contrib/dev/acpica/compiler/aslcodegen.c   Thu May  9 22:49:58 
2019(r347414)
+++ head/sys/contrib/dev/acpica/compiler/aslcodegen.c   Thu May  9 23:03:10 
2019(r347415)
@@ -690,7 +690,8 @@ CgUpdateHeader (
 {
 if (FlReadFile 

svn commit: r347410 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/i386/conf sys/powerpc/conf sys/riscv/conf sys/sparc64/conf

2019-05-09 Thread Andrew Gallatin
Author: gallatin
Date: Thu May  9 22:38:15 2019
New Revision: 347410
URL: https://svnweb.freebsd.org/changeset/base/347410

Log:
  Remove IPSEC from GENERIC due to performance issues
  
  Having IPSEC compiled into the kernel imposes a non-trivial
  performance penalty on multi-threaded workloads due to IPSEC
  refcounting. In my benchmarks of multi-threaded UDP
  transmit (connected sockets), I've seen a roughly 20% performance
  penalty when the IPSEC option is included in the kernel (16.8Mpps
  vs 13.8Mpps with 32 senders on a 14 core / 28 HTT Xeon
  2697v3)). This is largely due to key_addref() incrementing and
  decrementing an atomic reference count on the default
  policy. This cause all CPUs to stall on the same cacheline, as it
  bounces between different CPUs.
  
  Given that relatively few users use ipsec, and that it can be
  loaded as a module, it seems reasonable to ask those users to
  load the ipsec module so as to avoid imposing this penalty on the
  GENERIC kernel. Its my hope that this will make FreeBSD look
  better in "out of the box" benchmark comparisons with other
  operating systems.
  
  Many thanks to ae for fixing auto-loading of ipsec.ko when
  ifconfig tries to configure ipsec, and to cy for volunteering
  to ensure the the racoon ports will load the ipsec.ko module
  
  Reviewed by:  cem, cy, delphij, gnn, jhb, jpaetzel
  Differential Revision:https://reviews.freebsd.org/D20163

Modified:
  head/UPDATING
  head/sys/amd64/conf/GENERIC
  head/sys/arm/conf/std.armv6
  head/sys/arm/conf/std.armv7
  head/sys/arm64/conf/GENERIC
  head/sys/i386/conf/GENERIC
  head/sys/powerpc/conf/GENERIC
  head/sys/powerpc/conf/GENERIC64
  head/sys/riscv/conf/GENERIC
  head/sys/sparc64/conf/GENERIC

Modified: head/UPDATING
==
--- head/UPDATING   Thu May  9 22:31:47 2019(r347409)
+++ head/UPDATING   Thu May  9 22:38:15 2019(r347410)
@@ -32,6 +32,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
 20190507:
+   The IPSEC option has been removed from GENERIC.  Users requiring
+   ipsec(4) must now load the ipsec(4) kernel module.
+
+20190507:
The tap(4) driver has been folded into tun(4), and the module has been
renamed to tuntap.  You should update any kld_load="if_tap" or
kld_load="if_tun" entries in /etc/rc.conf, if_tap_load="YES" or

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Thu May  9 22:31:47 2019(r347409)
+++ head/sys/amd64/conf/GENERIC Thu May  9 22:38:15 2019(r347410)
@@ -30,7 +30,6 @@ options   PREEMPTION  # Enable kernel thread 
preemption
 optionsVIMAGE  # Subsystem virtualization, e.g. VNET
 optionsINET# InterNETworking
 optionsINET6   # IPv6 communications protocols
-optionsIPSEC   # IP (v4/v6) security
 optionsIPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5
 optionsTCP_OFFLOAD # TCP offload
 optionsTCP_BLACKBOX# Enhanced TCP event logging

Modified: head/sys/arm/conf/std.armv6
==
--- head/sys/arm/conf/std.armv6 Thu May  9 22:31:47 2019(r347409)
+++ head/sys/arm/conf/std.armv6 Thu May  9 22:38:15 2019(r347410)
@@ -11,7 +11,7 @@ options   INET# InterNETworking
 optionsINET6   # IPv6 communications protocols
 optionsTCP_HHOOK   # hhook(9) framework for TCP
 device crypto  # core crypto support
-optionsIPSEC   # IP (v4/v6) security
+optionsIPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5
 optionsSCTP# Stream Control Transmission Protocol
 optionsFFS # Berkeley Fast Filesystem
 optionsSOFTUPDATES # Enable FFS soft updates support

Modified: head/sys/arm/conf/std.armv7
==
--- head/sys/arm/conf/std.armv7 Thu May  9 22:31:47 2019(r347409)
+++ head/sys/arm/conf/std.armv7 Thu May  9 22:38:15 2019(r347410)
@@ -11,7 +11,7 @@ options   INET# InterNETworking
 optionsINET6   # IPv6 communications protocols
 optionsTCP_HHOOK   # hhook(9) framework for TCP
 device crypto  # core crypto support
-optionsIPSEC   # IP (v4/v6) security
+optionsIPSEC_SUPPORT   # Allow kldload of ipsec and tcpmd5
 optionsSCTP# Stream Control Transmission Protocol
 optionsFFS  

svn commit: r347408 - in head/lib/libsecureboot: . openpgp tests

2019-05-09 Thread Simon J. Gerraty
Author: sjg
Date: Thu May  9 22:25:12 2019
New Revision: 347408
URL: https://svnweb.freebsd.org/changeset/base/347408

Log:
  libsecureboot: make it easier to customize trust anchors
  
  Avoid making hash self-tests depend on X.509 certs.
  Include OpenPGP keys in trust store count.
  
  Reviewed by:  stevek
  MFC after:1 week
  Sponsored by: Juniper Networks
  Differential Revision:https://reviews.freebsd.org/D20208

Modified:
  head/lib/libsecureboot/Makefile.inc
  head/lib/libsecureboot/libsecureboot-priv.h
  head/lib/libsecureboot/local.trust.mk
  head/lib/libsecureboot/openpgp/Makefile.inc
  head/lib/libsecureboot/openpgp/opgp_key.c
  head/lib/libsecureboot/tests/Makefile
  head/lib/libsecureboot/vets.c

Modified: head/lib/libsecureboot/Makefile.inc
==
--- head/lib/libsecureboot/Makefile.inc Thu May  9 21:00:15 2019
(r347407)
+++ head/lib/libsecureboot/Makefile.inc Thu May  9 22:25:12 2019
(r347408)
@@ -98,10 +98,20 @@ CFLAGS+= ${VE_HASH_LIST:@H@-DVE_$H_SUPPORT@} \
 
 .if ${VE_SELF_TESTS} != "no"
 # The input used for hash KATs
+# we use a string by default so it is independent of any other test
+VE_HASH_KAT_STRLEN?= strlen
+.if ${VE_HASH_KAT_STRLEN} == "strlen"
+VE_HASH_KAT_STR?= self-tests-are-good
+VE_HASH_KAT_STR_INPUT= echo -n
+XCFLAGS.vets+= -DVE_HASH_KAT_STR=\"${VE_HASH_KAT_STR}\"
+.else
 VE_HASH_KAT_STR?= vc_PEM
-
+VE_HASH_KAT_STR_INPUT= cat
+VE_HASH_KAT_STRLEN= sizeof
 XCFLAGS.vets+= -DVE_HASH_KAT_STR=${VE_HASH_KAT_STR}
 .endif
+XCFLAGS.vets+= -DVE_HASH_KAT_STRLEN=${VE_HASH_KAT_STRLEN}
+.endif
 
 # this should be updated occassionally this is 2019-01-01Z
 SOURCE_DATE_EPOCH?= 1546329600
@@ -121,17 +131,20 @@ BUILD_UTC?= ${${STAT:Ustat} -f %m ${BUILD_UTC_FILE}:L:
 # If we are doing self-tests, we define another arrary vc_PEM
 # containing certificates that we can verify for each trust anchor.
 # This is typically a subordinate CA cert.
-# Finally we generate a hash of vc_PEM using each supported hash method
+# Finally we generate a hash of VE_HASH_KAT_STR
+# using each supported hash method
 # to use as a Known Answer Test (needed for FIPS 140-2)
 #
+TA_PEM_LIST ?= ${.ALLSRC:N*crl*:Mt*.pem}
+VC_PEM_LIST ?= ${.ALLSRC:N*crl*:Mv*.pem}
 vets.o vets.po vets.pico: ta.h
-ta.h: ${.ALLTARGETS:M[tv]*pem:O:u}
+ta.h:
@( echo '/* Autogenerated - DO NOT EDIT!!! */'; echo; \
-   cat ${.ALLSRC:N*crl*:Mt*.pem} /dev/null | \
+   cat ${TA_PEM_LIST:O:u} /dev/null | \
file2c -sx 'static const char ta_PEM[] = {' '};'; \
-   echo "${.newline}${VE_HASH_LIST:@H@static char vh_$H[] = \"`cat 
${.ALLSRC:N*crl*:Mv*.pem} | ${$H:U${H:tl}}`\";${.newline}@}"; ) > ${.TARGET}
+   echo "${.newline}${VE_HASH_LIST:O:u:@H@static char vh_$H[] = 
\"`${VE_HASH_KAT_STR_INPUT} ${VE_HASH_KAT_STR} | 
${$H:U${H:tl}}`\";${.newline}@}"; ) > ${.TARGET}
 .if ${VE_SELF_TESTS} != "no"
-   ( cat ${.ALLSRC:N*crl*:Mv*.pem} /dev/null | \
+   ( cat ${VC_PEM_LIST:O:u} /dev/null | \
file2c -sx 'static const char vc_PEM[] = {' '};'; echo ) >> ${.TARGET}
 .endif
echo '#define BUILD_UTC ${BUILD_UTC}' >> ${.TARGET} 
${.OODATE:MNOMETA_CMP}
@@ -141,7 +154,7 @@ vesigned.o vesigned.po vesigned.pico: vse.h
 vse.h:
@( echo '/* Autogenerated - DO NOT EDIT!!! */'; echo; \
echo "static const char *signature_exts[] = {"; \
-   echo '${VE_SIGNATURE_EXT_LIST:@e@"$e",${.newline}@}'; \
+   echo '${VE_SIGNATURE_EXT_LIST:O:u:@e@"$e",${.newline}@}'; \
echo 'NULL };' ) > ${.TARGET}
 
 

Modified: head/lib/libsecureboot/libsecureboot-priv.h
==
--- head/lib/libsecureboot/libsecureboot-priv.h Thu May  9 21:00:15 2019
(r347407)
+++ head/lib/libsecureboot/libsecureboot-priv.h Thu May  9 22:25:12 2019
(r347408)
@@ -55,6 +55,7 @@ int verify_rsa_digest(br_rsa_public_key *pkey,
 int is_verified(struct stat *stp);
 void add_verify_status(struct stat *stp, int status);
 
+int openpgp_trust_init(void);
 int openpgp_self_tests(void);
 
 int efi_secure_boot_enabled(void);

Modified: head/lib/libsecureboot/local.trust.mk
==
--- head/lib/libsecureboot/local.trust.mk   Thu May  9 21:00:15 2019
(r347407)
+++ head/lib/libsecureboot/local.trust.mk   Thu May  9 22:25:12 2019
(r347408)
@@ -51,7 +51,7 @@ SIGN_OPENPGP= ${PYTHON} ${SIGNER:H}/openpgp-sign.py -a
 ta_openpgp.asc:
${SIGN_OPENPGP} -C ${.TARGET}
 
-ta.h: ta_openpgp.asc
+ta_asc.h: ta_openpgp.asc
 
 .if ${VE_SELF_TESTS} != "no"
 # for self test
@@ -59,7 +59,7 @@ vc_openpgp.asc: ta_openpgp.asc
${SIGN_OPENPGP} ${.ALLSRC:M*.asc}
mv ta_openpgp.asc.asc ${.TARGET}
 
-ta.h: vc_openpgp.asc
+ta_asc.h: vc_openpgp.asc
 .endif
 .endif
 
@@ -72,17 +72,20 @@ ecerts.pem:
 .if ${VE_SIGNATURE_LIST:tu:MECDSA} != ""
 # the last cert in th

svn commit: r347407 - head/sys/netinet

2019-05-09 Thread Michael Tuexen
Author: tuexen
Date: Thu May  9 21:00:15 2019
New Revision: 347407
URL: https://svnweb.freebsd.org/changeset/base/347407

Log:
  Don't use C++ style comments.
  
  These where introduced in r347382.
  Reported by:  ngie@

Modified:
  head/sys/netinet/tcp_input.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cThu May  9 20:30:35 2019
(r347406)
+++ head/sys/netinet/tcp_input.cThu May  9 21:00:15 2019
(r347407)
@@ -3045,15 +3045,21 @@ dodata: 
/* XXX */
if (tp->t_flags & TF_SACK_PERMIT) {
if (((tlen == 0) && (save_tlen > 0) &&
(SEQ_LT(save_start, save_rnxt {
-   // DSACK actually handled in the fastpath above
+   /*
+* DSACK actually handled in the fastpath
+* above.
+*/
tcp_update_sack_list(tp, save_start, save_start 
+ save_tlen);
} else
if ((tlen > 0) && SEQ_GT(tp->rcv_nxt, save_rnxt)) {
-   // cleaning sackblks by using zero length update
+   /*
+* Cleaning sackblks by using zero length
+* update.
+*/
tcp_update_sack_list(tp, save_start, 
save_start);
} else
if ((tlen > 0) && (tlen >= save_tlen)) {
-   // update of sackblks
+   /* Update of sackblks. */
tcp_update_sack_list(tp, save_start, save_start 
+ save_tlen);
} else
if (tlen > 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 1:43 PM Andrey V. Elsukov  wrote:
>
> On 09.05.2019 21:36, Kyle Evans wrote:
> > Any chance the mechanism I introduced for ifconfig mapping ifname <->
> > kld in r347241 would solve the same set of problems this would?
> > (unsure if there are any non-ifconfig(8) problems in consideration) If
> > we have more consumers of it than just vmnet (from a stable/ point of
> > view) then I'd be more than happy to MFC that separately from the rest
> > of the commit.
> >
>
> Hi,
>
> there is two IPsec related interfaces that have problem with automatic
> loading - if_enc and if_ipsec. So, if you add both to the mapping list,
> this will be useful. CAM enc driver has conflicting name and prevents to
> automatic loading of if_enc(4). It is probably always build in the
> kernel, but renaming it into "ses" may break some third-party device
> drivers.
>

I think you want something like [0] to add both of these to the map
and stop ifconfig(8) from bailing on loading if_enc because 'enc' is
loaded. This is safe at least for the set of modules currently mapped.

Thanks,

Kyle Evans

[0] https://people.freebsd.org/~kevans/ipsec.diff
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347405 - head/usr.sbin/nfsd

2019-05-09 Thread Mateusz Piotrowski
Author: 0mp (ports committer)
Date: Thu May  9 19:03:52 2019
New Revision: 347405
URL: https://svnweb.freebsd.org/changeset/base/347405

Log:
  nfsd.8: Fix mandoc -Tlint and igor warnings
  
  - Remove Tn macros
  - Refernce sysctl(8) instead of sysctl(1)
  - Start new sentences on new lines
  - Capitalize NFS where needed
  - Use Fx for FreeBSD
  - Remove a list block (Bl) that was added to the manual page
by accident in r335174
  
  Reviewed by:  bcr
  Approved by:  doc (bcr)
  Differential Revision:https://reviews.freebsd.org/D20215

Modified:
  head/usr.sbin/nfsd/nfsd.8

Modified: head/usr.sbin/nfsd/nfsd.8
==
--- head/usr.sbin/nfsd/nfsd.8   Thu May  9 18:54:29 2019(r347404)
+++ head/usr.sbin/nfsd/nfsd.8   Thu May  9 19:03:52 2019(r347405)
@@ -34,8 +34,7 @@
 .Sh NAME
 .Nm nfsd
 .Nd remote
-.Tn NFS
-server
+NFS server
 .Sh SYNOPSIS
 .Nm
 .Op Fl ardute
@@ -49,23 +48,18 @@ server
 .Sh DESCRIPTION
 The
 .Nm
-utility runs on a server machine to service
-.Tn NFS
-requests from client machines.
+utility runs on a server machine to service NFS requests from client machines.
 At least one
 .Nm
 must be running for a machine to operate as a server.
 .Pp
-Unless otherwise specified, eight servers per CPU for
-.Tn UDP
-transport are started.
+Unless otherwise specified, eight servers per CPU for UDP transport are
+started.
 .Pp
 The following options are available:
 .Bl -tag -width Ds
 .It Fl r
-Register the
-.Tn NFS
-service with
+Register the NFS service with
 .Xr rpcbind 8
 without creating any servers.
 This option can be used along with the
@@ -74,16 +68,15 @@ or
 .Fl t
 options to re-register NFS if the rpcbind server is restarted.
 .It Fl d
-Unregister the
-.Tn NFS
-service with
+Unregister the NFS service with
 .Xr rpcbind 8
 without creating any servers.
 .It Fl V Ar virtual_hostname
 Specifies a hostname to be used as a principal name, instead of
 the default hostname.
 .It Fl n Ar threads
-Specifies how many servers to create.  This option is equivalent to specifying
+Specifies how many servers to create.
+This option is equivalent to specifying
 .Fl Fl maxthreads
 and
 .Fl Fl minthreads
@@ -114,13 +107,14 @@ Enables pNFS support in the server and specifies the i
 daemon needs to start it.
 This option can only be used on one server and specifies that this server
 will be the MetaData Server (MDS) for the pNFS service.
-This can only be done if there is at least one FreeBSD system configured
+This can only be done if there is at least one
+.Fx
+system configured
 as a Data Server (DS) for it to use.
 .Pp
 The
 .Ar pnfs_setup
 string is a set of fields separated by ',' characters:
-.Bl -tag -width Ds
 Each of these fields specifies one DS.
 It consists of a server hostname, followed by a ':'
 and the directory path where the DS's data storage file system is mounted on
@@ -159,7 +153,6 @@ data files for
 .Dq /export1
 and nfsv4-data1 will be used to store data files for
 .Dq /export2 .
-.El
 .sp
 When using IPv6 addresses for DSs
 be wary of using link local addresses.
@@ -201,28 +194,20 @@ If mirroring is enabled, the server must use the Flexi
 layout.
 If mirroring is not enabled, the server will use the File layout
 by default, but this default can be changed to the Flexible File layout if the
-.Xr sysctl 1
+.Xr sysctl 8
 vfs.nfsd.default_flexfile
 is set non-zero.
 .It Fl t
-Serve
-.Tn TCP NFS
-clients.
+Serve TCP NFS clients.
 .It Fl u
-Serve
-.Tn UDP NFS
-clients.
+Serve UDP NFS clients.
 .It Fl e
 Ignored; included for backward compatibility.
 .El
 .Pp
 For example,
 .Dq Li "nfsd -u -t -n 6"
-serves
-.Tn UDP
-and
-.Tn TCP
-transports using six daemons.
+serves UDP and TCP transports using six daemons.
 .Pp
 A server should run enough daemons to handle
 the maximum level of concurrency from its clients,
@@ -231,8 +216,7 @@ typically four to six.
 The
 .Nm
 utility listens for service requests at the port indicated in the
-.Tn NFS
-server specification; see
+NFS server specification; see
 .%T "Network File System Protocol Specification" ,
 RFC1094,
 .%T "NFS: Network File System Version 3 Protocol Specification" ,
@@ -245,15 +229,10 @@ RFC5661.
 If
 .Nm
 detects that
-.Tn NFS
-is not loaded in the running kernel, it will attempt
-to load a loadable kernel module containing
-.Tn NFS
-support using
+NFS is not loaded in the running kernel, it will attempt
+to load a loadable kernel module containing NFS support using
 .Xr kldload 2 .
-If this fails, or no
-.Tn NFS
-KLD is available,
+If this fails, or no NFS KLD is available,
 .Nm
 will exit with an error.
 .Pp
@@ -271,7 +250,7 @@ that the NFS sockets can only be accessed by the insid
 The
 .Nm ipfw
 utility
-would then be used to block nfs-related packets that come in on the outside
+would then be used to block NFS-related packets that come in on the outside
 interface.
 .Pp
 If the server has stopped servicing clients and has generated a console mes

svn commit: r347404 - head/sys/net

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 18:54:29 2019
New Revision: 347404
URL: https://svnweb.freebsd.org/changeset/base/347404

Log:
  tuntap: Don't down tap interfaces if LINK0 is set

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cThu May  9 18:23:09 2019(r347403)
+++ head/sys/net/if_tuntap.cThu May  9 18:54:29 2019(r347404)
@@ -947,7 +947,8 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
}
 
/* For vmnet, we won't do most of the address/route bits */
-   if ((tp->tun_flags & TUN_VMNET) != 0)
+   if ((tp->tun_flags & TUN_VMNET) != 0 ||
+   (l2tun && (ifp->if_flags & IFF_LINK0) != 0))
goto out;
 
if (ifp->if_flags & IFF_UP) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Andrey V. Elsukov
On 09.05.2019 21:36, Kyle Evans wrote:
> Any chance the mechanism I introduced for ifconfig mapping ifname <->
> kld in r347241 would solve the same set of problems this would?
> (unsure if there are any non-ifconfig(8) problems in consideration) If
> we have more consumers of it than just vmnet (from a stable/ point of
> view) then I'd be more than happy to MFC that separately from the rest
> of the commit.
> 

Hi,

there is two IPsec related interfaces that have problem with automatic
loading - if_enc and if_ipsec. So, if you add both to the mapping list,
this will be useful. CAM enc driver has conflicting name and prevents to
automatic loading of if_enc(4). It is probably always build in the
kernel, but renaming it into "ses" may break some third-party device
drivers.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 1:06 PM Andrey V. Elsukov  wrote:
>
> Author: ae
> Date: Thu May  9 18:06:11 2019
> New Revision: 347402
> URL: https://svnweb.freebsd.org/changeset/base/347402
>
> Log:
>   Add if_ipsec.ko symlink to ipsec.ko kernel module.
>
>   This add ability to automatically load ipsec kernel module, when
>   if_ipsec(4) virtual interface is created using ifconfig(8).
>
>   Reviewed by:  gallatin
>   MFC after:1 week
>   Differential Revision:https://reviews.freebsd.org/D20169
>

Hi,

Any chance the mechanism I introduced for ifconfig mapping ifname <->
kld in r347241 would solve the same set of problems this would?
(unsure if there are any non-ifconfig(8) problems in consideration) If
we have more consumers of it than just vmnet (from a stable/ point of
view) then I'd be more than happy to MFC that separately from the rest
of the commit.

Thanks,

Kyle Evans
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347392 - head/sbin/ifconfig

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 12:27 PM Enji Cooper (yaneurabeya)
 wrote:
>
>
> > On May 9, 2019, at 05:58, Kyle Evans  wrote:
> >
> > Author: kevans
> > Date: Thu May  9 12:58:33 2019
> > New Revision: 347392
> > URL: https://svnweb.freebsd.org/changeset/base/347392
> >
> > Log:
> >  ifconfig(8): Partial revert of r347241
> >
> >  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
> >  can autoload the correct module on use. It also inadvertently made bogus
> >  some previously valid uses of sizeof().
> >
> >  Revert back to ifkind on the stack for simplicity sake. This reduces the
> >  diff from the previous version of ifmaybeload for easiser auditing.
>
> Hi Kyle,
> Thank you for this revert. This change fixed the FreeBSD test suite 
> runs, which are once again green after this change. A number of tests which 
> use ifconfig were failing because they couldn’t configure interfaces: 
> https://ci.freebsd.org/job/FreeBSD-head-amd64-test/11134/testReport/ .
> Cheers!
> -Enji

Hi,

Sorry- I failed in the commit message. =(

Reported by: ci (via lwhsu)

lwhsu clued me in this morning. =)

Thanks!

Kyle Evans
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Andrey V. Elsukov
Author: ae
Date: Thu May  9 18:06:11 2019
New Revision: 347402
URL: https://svnweb.freebsd.org/changeset/base/347402

Log:
  Add if_ipsec.ko symlink to ipsec.ko kernel module.
  
  This add ability to automatically load ipsec kernel module, when
  if_ipsec(4) virtual interface is created using ifconfig(8).
  
  Reviewed by:  gallatin
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20169

Modified:
  head/sys/modules/ipsec/Makefile

Modified: head/sys/modules/ipsec/Makefile
==
--- head/sys/modules/ipsec/Makefile Thu May  9 17:57:04 2019
(r347401)
+++ head/sys/modules/ipsec/Makefile Thu May  9 18:06:11 2019
(r347402)
@@ -7,6 +7,7 @@ SRCS=   if_ipsec.c ipsec.c ipsec_input.c ipsec_mbuf.c ip
ipsec_output.c xform_ah.c xform_esp.c xform_ipcomp.c \
opt_inet.h opt_inet6.h opt_ipsec.h opt_sctp.h 
 SRCS.INET= udpencap.c
+SYMLINKS=  ${KMOD}.ko ${KMODDIR}/if_${KMOD}.ko
 
 opt_ipsec.h:
@echo "#define IPSEC_SUPPORT 1" > ${.TARGET}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r347392 - head/sbin/ifconfig

2019-05-09 Thread Enji Cooper (yaneurabeya)

> On May 9, 2019, at 05:58, Kyle Evans  wrote:
> 
> Author: kevans
> Date: Thu May  9 12:58:33 2019
> New Revision: 347392
> URL: https://svnweb.freebsd.org/changeset/base/347392
> 
> Log:
>  ifconfig(8): Partial revert of r347241
> 
>  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
>  can autoload the correct module on use. It also inadvertently made bogus
>  some previously valid uses of sizeof().
> 
>  Revert back to ifkind on the stack for simplicity sake. This reduces the
>  diff from the previous version of ifmaybeload for easiser auditing.

Hi Kyle,
Thank you for this revert. This change fixed the FreeBSD test suite 
runs, which are once again green after this change. A number of tests which use 
ifconfig were failing because they couldn’t configure interfaces: 
https://ci.freebsd.org/job/FreeBSD-head-amd64-test/11134/testReport/ . 
Cheers!
-Enji
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347394 - head/sys/net

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 14:06:24 2019
New Revision: 347394
URL: https://svnweb.freebsd.org/changeset/base/347394

Log:
  tuntap: Properly detach tap ifp

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cThu May  9 13:12:43 2019(r347393)
+++ head/sys/net/if_tuntap.cThu May  9 14:06:24 2019(r347394)
@@ -529,7 +529,6 @@ out:
 static void
 tun_destroy(struct tuntap_softc *tp)
 {
-   struct cdev *dev;
 
TUN_LOCK(tp);
tp->tun_flags |= TUN_DYING;
@@ -543,15 +542,18 @@ tun_destroy(struct tuntap_softc *tp)
TUN2IFP(tp)->if_softc = NULL;
sx_xunlock(&tun_ioctl_sx);
 
-   dev = tp->tun_dev;
-   bpfdetach(TUN2IFP(tp));
-   if_detach(TUN2IFP(tp));
-   free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
-   if_free(TUN2IFP(tp));
-   destroy_dev(dev);
+   destroy_dev(tp->tun_dev);
seldrain(&tp->tun_rsel);
knlist_clear(&tp->tun_rsel.si_note, 0);
knlist_destroy(&tp->tun_rsel.si_note);
+   if ((tp->tun_flags & TUN_L2) != 0) {
+   ether_ifdetach(TUN2IFP(tp));
+   } else {
+   bpfdetach(TUN2IFP(tp));
+   if_detach(TUN2IFP(tp));
+   }
+   free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
+   if_free(TUN2IFP(tp));
mtx_destroy(&tp->tun_mtx);
cv_destroy(&tp->tun_cv);
free(tp, M_TUN);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347393 - in head/stand: common i386/libi386

2019-05-09 Thread Toomas Soome
Author: tsoome
Date: Thu May  9 13:12:43 2019
New Revision: 347393
URL: https://svnweb.freebsd.org/changeset/base/347393

Log:
  loader: use DPRINTF in biosdisk.c and define safe DPRINTF
  
  r345066 did miss biosdisk.c.
  
  Also define DPRINTF as ((void)0) for case we do not want debug printouts.
  
  MFC after:1 week

Modified:
  head/stand/common/disk.c
  head/stand/common/interp_forth.c
  head/stand/common/part.c
  head/stand/i386/libi386/biosdisk.c

Modified: head/stand/common/disk.c
==
--- head/stand/common/disk.cThu May  9 12:58:33 2019(r347392)
+++ head/stand/common/disk.cThu May  9 13:12:43 2019(r347393)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
 #ifdef DISK_DEBUG
 # define DPRINTF(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args)
 #else
-# define DPRINTF(fmt, args...)
+# define DPRINTF(fmt, args...) ((void)0)
 #endif
 
 struct open_disk {

Modified: head/stand/common/interp_forth.c
==
--- head/stand/common/interp_forth.cThu May  9 12:58:33 2019
(r347392)
+++ head/stand/common/interp_forth.cThu May  9 13:12:43 2019
(r347393)
@@ -41,7 +41,7 @@ INTERP_DEFINE("4th");
 #ifdef BFORTH_DEBUG
 #defineDPRINTF(fmt, args...)   printf("%s: " fmt "\n" , __func__ , ## 
args)
 #else
-#defineDPRINTF(fmt, args...)
+#defineDPRINTF(fmt, args...)   ((void)0)
 #endif
 
 /*

Modified: head/stand/common/part.c
==
--- head/stand/common/part.cThu May  9 12:58:33 2019(r347392)
+++ head/stand/common/part.cThu May  9 13:12:43 2019(r347393)
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
 #ifdef PART_DEBUG
 #defineDPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
 #else
-#defineDPRINTF(fmt, args...)
+#defineDPRINTF(fmt, args...)   ((void)0)
 #endif
 
 #ifdef LOADER_GPT_SUPPORT

Modified: head/stand/i386/libi386/biosdisk.c
==
--- head/stand/i386/libi386/biosdisk.c  Thu May  9 12:58:33 2019
(r347392)
+++ head/stand/i386/libi386/biosdisk.c  Thu May  9 13:12:43 2019
(r347393)
@@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$");
 #defineCDMAJOR 15
 
 #ifdef DISK_DEBUG
-#defineDEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## 
args)
+#defineDPRINTF(fmt, args...)   printf("%s: " fmt "\n", __func__, ## 
args)
 #else
-#defineDEBUG(fmt, args...)
+#defineDPRINTF(fmt, args...)   ((void)0)
 #endif
 
 struct specification_packet {
@@ -218,12 +218,12 @@ bd_bios2unit(int biosdev)
bdinfo_t *bd;
int i, unit;
 
-   DEBUG("looking for bios device 0x%x", biosdev);
+   DPRINTF("looking for bios device 0x%x", biosdev);
for (i = 0; bdi[i] != NULL; i++) {
unit = 0;
STAILQ_FOREACH(bd, bdi[i], bd_link) {
if (bd->bd_unit == biosdev) {
-   DEBUG("bd unit %d is BIOS device 0x%x", unit,
+   DPRINTF("bd unit %d is BIOS device 0x%x", unit,
bd->bd_unit);
return (unit);
}
@@ -620,7 +620,7 @@ bd_int13probe(bdinfo_t *bd)
if (bd->bd_sectors == 0)
bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
 
-   DEBUG("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl,
+   DPRINTF("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl,
bd->bd_hds, bd->bd_sec);
 
return (true);
@@ -919,7 +919,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
return (EIO);
}
 
-   DEBUG("open_disk %p", dev);
+   DPRINTF("open_disk %p", dev);
 
offset = dblk * BIOSDISK_SECSIZE;
dblk = offset / bd->bd_sectorsize;
@@ -932,7 +932,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
 * while translating block count to bytes.
 */
if (size > INT_MAX) {
-   DEBUG("too large I/O: %zu bytes", size);
+   DPRINTF("too large I/O: %zu bytes", size);
return (EIO);
}
 
@@ -972,7 +972,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
if (dblk + blks >= d_offset + disk_blocks) {
blks = d_offset + disk_blocks - dblk;
size = blks * bd->bd_sectorsize;
-   DEBUG("short I/O %d", blks);
+   DPRINTF("short I/O %d", blks);
}
 
bio_size = min(BIO_BUFFER_SIZE, size);
@@ -997,7 +997,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
 
switch (rw & F_MASK) {
case F_READ:
-   DEBUG("read %d from %lld to %p", x, dblk, buf);
+ 

svn commit: r347392 - head/sbin/ifconfig

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 12:58:33 2019
New Revision: 347392
URL: https://svnweb.freebsd.org/changeset/base/347392

Log:
  ifconfig(8): Partial revert of r347241
  
  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
  can autoload the correct module on use. It also inadvertently made bogus
  some previously valid uses of sizeof().
  
  Revert back to ifkind on the stack for simplicity sake. This reduces the
  diff from the previous version of ifmaybeload for easiser auditing.

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Thu May  9 12:14:52 2019
(r347391)
+++ head/sbin/ifconfig/ifconfig.c   Thu May  9 12:58:33 2019
(r347392)
@@ -1433,7 +1433,7 @@ ifmaybeload(const char *name)
 #define MOD_PREFIX_LEN 3   /* "if_" */
struct module_stat mstat;
int i, fileid, modid;
-   char ifname[IFNAMSIZ], *ifkind, *dp;
+   char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
struct module_map_entry *mme;
 
@@ -1450,21 +1450,17 @@ ifmaybeload(const char *name)
}
 
/* Either derive it from the map or guess otherwise */
-   ifkind = NULL;
+   *ifkind = '\0';
for (i = 0; i < nitems(module_map); ++i) {
mme = &module_map[i];
if (strcmp(mme->ifname, ifname) == 0) {
-   ifkind = strdup(mme->kldname);
-   if (ifkind == NULL)
-   err(EXIT_FAILURE, "ifmaybeload");
+   strlcpy(ifkind, mme->kldname, sizeof(ifkind));
break;
}
}
 
/* We didn't have an alias for it... we'll guess. */
-   if (ifkind == NULL) {
-   ifkind = malloc(IFNAMSIZ + MOD_PREFIX_LEN);
-
+   if (*ifkind == '\0') {
/* turn interface and unit into module name */
strlcpy(ifkind, "if_", sizeof(ifkind));
strlcat(ifkind, ifname, sizeof(ifkind));
@@ -1487,7 +1483,7 @@ ifmaybeload(const char *name)
/* already loaded? */
if (strcmp(ifname, cp) == 0 ||
strcmp(ifkind, cp) == 0)
-   goto out;
+   return;
}
}
 
@@ -1496,8 +1492,6 @@ ifmaybeload(const char *name)
 * infer the names of all drivers (eg mlx4en(4)).
 */
(void) kldload(ifkind);
-out:
-   free(ifkind);
 }
 
 static struct cmd basic_cmds[] = {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347391 - in head/stand: efi/libefi i386/libi386

2019-05-09 Thread Toomas Soome
Author: tsoome
Date: Thu May  9 12:14:52 2019
New Revision: 347391
URL: https://svnweb.freebsd.org/changeset/base/347391

Log:
  loader: no-TERM_EMU is broken now
  
  If TERM_EMU is not defined, we do not have curx variable. Use conout mode
  for efi and expose get_pos() for i386.

Modified:
  head/stand/efi/libefi/efi_console.c
  head/stand/i386/libi386/vidconsole.c

Modified: head/stand/efi/libefi/efi_console.c
==
--- head/stand/efi/libefi/efi_console.c Thu May  9 11:34:46 2019
(r347390)
+++ head/stand/efi/libefi/efi_console.c Thu May  9 12:14:52 2019
(r347391)
@@ -138,7 +138,7 @@ efi_cons_rawputchar(int c)
if (c == '\t') {
int n;
 
-   n = 8 - ((curx + 8) % 8);
+   n = 8 - ((conout->Mode->CursorColumn + 8) % 8);
for (i = 0; i < n; i++)
efi_cons_rawputchar(' ');
} else {

Modified: head/stand/i386/libi386/vidconsole.c
==
--- head/stand/i386/libi386/vidconsole.cThu May  9 11:34:46 2019
(r347390)
+++ head/stand/i386/libi386/vidconsole.cThu May  9 12:14:52 2019
(r347391)
@@ -49,6 +49,8 @@ static intvidc_ischar(void);
 
 static int vidc_started;
 
+void   get_pos(int *x, int *y);
+
 #ifdef TERM_EMU
 #define MAXARGS8
 #define DEFAULT_FGCOLOR7
@@ -57,7 +59,6 @@ static intvidc_started;
 void   end_term(void);
 void   bail_out(int c);
 void   vidc_term_emu(int c);
-void   get_pos(int *x, int *y);
 void   curs_move(int *_x, int *_y, int x, int y);
 void   write_char(int c, int fg, int bg);
 void   scroll_up(int rows, int fg, int bg);
@@ -138,7 +139,12 @@ vidc_rawputchar(int c)
 
 if (c == '\t') {
int n;
+#ifndef TERM_EMU
+   int curx, cury;
 
+   get_pos(&curx, %cury);
+#endif
+
n = 8 - ((curx + 8) % 8);
for (i = 0; i < n; i++)
vidc_rawputchar(' ');
@@ -190,8 +196,6 @@ vidc_rawputchar(int c)
 }
 }
 
-#ifdef TERM_EMU
-
 /* Get cursor position on the screen. Result is in edx. Sets
  * curx and cury appropriately.
  */
@@ -207,6 +211,8 @@ get_pos(int *x, int *y)
 *x = v86.edx & 0x00ff;
 *y = (v86.edx & 0xff00) >> 8;
 }
+
+#ifdef TERM_EMU
 
 /* Move cursor to x rows and y cols (0-based). */
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347390 - head/sys/net

2019-05-09 Thread Marius Strobl
Author: marius
Date: Thu May  9 11:34:46 2019
New Revision: 347390
URL: https://svnweb.freebsd.org/changeset/base/347390

Log:
  - Merge r338254 from cxgbe(4):
Use fcmpset instead of cmpset when appropriate.
  - Revert r277226 of cxgbe(4), obsolete since r334320.

Modified:
  head/sys/net/mp_ring.c

Modified: head/sys/net/mp_ring.c
==
--- head/sys/net/mp_ring.c  Thu May  9 11:04:10 2019(r347389)
+++ head/sys/net/mp_ring.c  Thu May  9 11:34:46 2019(r347390)
@@ -36,12 +36,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
-#if defined(__i386__)
-#define atomic_cmpset_acq_64 atomic_cmpset_64
-#define atomic_cmpset_rel_64 atomic_cmpset_64
-#endif
-
 #include 
 
 union ring_state {
@@ -195,11 +189,12 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st
n = r->drain(r, cidx, pidx);
if (n == 0) {
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = STALLED;
-   } while (atomic_cmpset_64(&r->state, os.state,
+   } while (atomic_fcmpset_64(&r->state, &os.state,
ns.state) == 0);
critical_exit();
if (prev != STALLED)
@@ -222,11 +217,13 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st
if (cidx != pidx && pending < 64 && total < budget)
continue;
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = state_to_flags(ns, total >= budget);
-   } while (atomic_cmpset_acq_64(&r->state, os.state, ns.state) == 
0);
+   } while (atomic_fcmpset_acq_64(&r->state, &os.state,
+   ns.state) == 0);
critical_exit();
 
if (ns.flags == ABDICATED)
@@ -379,10 +376,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
if (abdicate) {
if (os.flags == IDLE)
ns.flags = ABDICATED;
-   }
-   else {
+   } else
ns.flags = BUSY;
-   }
r->state = ns.state;
counter_u64_add(r->enqueues, n);
 
@@ -398,7 +393,6 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
mtx_unlock(&r->lock);
return (0);
 }
-
 #else
 int
 ifmp_ring_enqueue(struct ifmp_ring *r, void **items, int n, int budget, int 
abdicate)
@@ -414,8 +408,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
 * Reserve room for the new items.  Our reservation, if successful, is
 * from 'pidx_start' to 'pidx_stop'.
 */
+   os.state = r->state;
for (;;) {
-   os.state = r->state;
if (n >= space_available(r, os)) {
counter_u64_add(r->drops, n);
MPASS(os.flags != IDLE);
@@ -426,7 +420,7 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
ns.state = os.state;
ns.pidx_head = increment_idx(r, os.pidx_head, n);
critical_enter();
-   if (atomic_cmpset_64(&r->state, os.state, ns.state))
+   if (atomic_fcmpset_64(&r->state, &os.state, ns.state))
break;
critical_exit();
cpu_spinwait();
@@ -456,17 +450,16 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
 * Update the ring's pidx_tail.  The release style atomic guarantees
 * that the items are visible to any thread that sees the updated pidx.
 */
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.pidx_tail = pidx_stop;
if (abdicate) {
if (os.flags == IDLE)
ns.flags = ABDICATED;
-   }
-   else {
+   } else
ns.flags = BUSY;
-   }
-   } while (atomic_cmpset_rel_64(&r->state, os.state, ns.state) == 0);
+   } while (atomic_fcmpset_rel_64(&r->state, &os.state, ns.state) == 0);
critical_exit();
counter_u64_add(r->enqueues, n);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347389 - head/stand/common

2019-05-09 Thread Toomas Soome
Author: tsoome
Date: Thu May  9 11:04:10 2019
New Revision: 347389
URL: https://svnweb.freebsd.org/changeset/base/347389

Log:
  loader: ptable_print() needs two tabs sometimes
  
  Since the partition/slice names do vary in length, check the length
  of the fixed part of the line against 3 * 8, if the lenth is less than
  3 tab stops, print out extra tab.
  
  use snprintf() instead of sprintf.

Modified:
  head/stand/common/disk.c

Modified: head/stand/common/disk.c
==
--- head/stand/common/disk.cThu May  9 10:37:57 2019(r347388)
+++ head/stand/common/disk.cThu May  9 11:04:10 2019(r347389)
@@ -75,7 +75,7 @@ display_size(uint64_t size, u_int sectorsize)
size /= 1024;
unit = 'M';
}
-   sprintf(buf, "%4ld%cB", (long)size, unit);
+   snprintf(buf, sizeof(buf), "%4ld%cB", (long)size, unit);
return (buf);
 }
 
@@ -118,11 +118,24 @@ ptable_print(void *arg, const char *pname, const struc
od = (struct open_disk *)pa->dev->dd.d_opendata;
sectsize = od->sectorsize;
partsize = part->end - part->start + 1;
-   sprintf(line, "  %s%s: %s\t%s\n", pa->prefix, pname,
-   parttype2str(part->type),
-   pa->verbose ? display_size(partsize, sectsize) : "");
+   snprintf(line, sizeof(line), "  %s%s: %s", pa->prefix, pname,
+   parttype2str(part->type));
if (pager_output(line))
-   return 1;
+   return (1);
+
+   if (pa->verbose) {
+   /* Emit extra tab when the line is shorter than 3 tab stops */
+   if (strlen(line) < 24)
+   (void) pager_output("\t");
+
+   snprintf(line, sizeof(line), "\t%s",
+   display_size(partsize, sectsize));
+   if (pager_output(line))
+   return (1);
+   }
+   if (pager_output("\n"))
+   return (1);
+
res = 0;
if (part->type == PART_FREEBSD) {
/* Open slice with BSD label */
@@ -133,7 +146,8 @@ ptable_print(void *arg, const char *pname, const struc
if (disk_open(&dev, partsize, sectsize) == 0) {
table = ptable_open(&dev, partsize, sectsize, ptblread);
if (table != NULL) {
-   sprintf(line, "  %s%s", pa->prefix, pname);
+   snprintf(line, sizeof(line), "  %s%s",
+   pa->prefix, pname);
bsd.dev = pa->dev;
bsd.prefix = line;
bsd.verbose = pa->verbose;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347388 - in head/stand: efi/libefi i386/libi386

2019-05-09 Thread Toomas Soome
Author: tsoome
Date: Thu May  9 10:37:57 2019
New Revision: 347388
URL: https://svnweb.freebsd.org/changeset/base/347388

Log:
  loader: implement proper 8 char tab stops
  
  The current console code is printing out 8 spaces for tab, calculate
  the amount of spaces based on tab stops.

Modified:
  head/stand/efi/libefi/efi_console.c
  head/stand/i386/libi386/vidconsole.c

Modified: head/stand/efi/libefi/efi_console.c
==
--- head/stand/efi/libefi/efi_console.c Thu May  9 10:23:42 2019
(r347387)
+++ head/stand/efi/libefi/efi_console.c Thu May  9 10:37:57 2019
(r347388)
@@ -135,11 +135,13 @@ efi_cons_rawputchar(int c)
UINTN x, y;
conout->QueryMode(conout, conout->Mode->Mode, &x, &y);
 
-   if (c == '\t')
-   /* XXX lame tab expansion */
-   for (i = 0; i < 8; i++)
+   if (c == '\t') {
+   int n;
+
+   n = 8 - ((curx + 8) % 8);
+   for (i = 0; i < n; i++)
efi_cons_rawputchar(' ');
-   else {
+   } else {
 #ifndefTERM_EMU
if (c == '\n')
efi_cons_efiputchar('\r');

Modified: head/stand/i386/libi386/vidconsole.c
==
--- head/stand/i386/libi386/vidconsole.cThu May  9 10:23:42 2019
(r347387)
+++ head/stand/i386/libi386/vidconsole.cThu May  9 10:37:57 2019
(r347388)
@@ -136,11 +136,13 @@ vidc_rawputchar(int c)
 {
 inti;
 
-if (c == '\t')
-   /* lame tab expansion */
-   for (i = 0; i < 8; i++)
+if (c == '\t') {
+   int n;
+
+   n = 8 - ((curx + 8) % 8);
+   for (i = 0; i < n; i++)
vidc_rawputchar(' ');
-else {
+} else {
 #ifndef TERM_EMU
 vidc_biosputchar(c);
 #else
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347387 - head/sys/compat/linuxkpi/common/src

2019-05-09 Thread Hans Petter Selasky
Author: hselasky
Date: Thu May  9 10:23:42 2019
New Revision: 347387
URL: https://svnweb.freebsd.org/changeset/base/347387

Log:
  Fix memory leak of PCI BUS structure in the LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_pci.c

Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c
==
--- head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May  9 09:49:07 
2019(r347386)
+++ head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May  9 10:23:42 
2019(r347387)
@@ -251,12 +251,10 @@ linux_pci_attach(device_t dev)
if (error)
goto out_dma_init;
 
-   if (pdev->bus == NULL) {
-   pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO);
-   pbus->self = pdev;
-   pbus->number = pci_get_bus(dev);
-   pdev->bus = pbus;
-   }
+   pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO);
+   pbus->self = pdev;
+   pbus->number = pci_get_bus(dev);
+   pdev->bus = pbus;
 
spin_lock(&pci_lock);
list_add(&pdev->links, &pci_devices);
@@ -268,6 +266,7 @@ linux_pci_attach(device_t dev)
return (0);
 
 out_probe:
+   free(pdev->bus, M_DEVBUF);
linux_pdev_dma_uninit(pdev);
 out_dma_init:
spin_lock(&pci_lock);
@@ -286,6 +285,8 @@ linux_pci_detach(device_t dev)
pdev = device_get_softc(dev);
 
pdev->pdrv->remove(pdev);
+
+   free(pdev->bus, M_DEVBUF);
linux_pdev_dma_uninit(pdev);
 
spin_lock(&pci_lock);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347385 - head/sys/compat/linuxkpi/common/src

2019-05-09 Thread Hans Petter Selasky
Author: hselasky
Date: Thu May  9 09:45:19 2019
New Revision: 347385
URL: https://svnweb.freebsd.org/changeset/base/347385

Log:
  Fix regression issue after r346645 in the LinuxKPI.
  Make sure LinuxKPI PCI devices get a default BUSDMA tag.
  
  Found by: Thomas Laus 
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_pci.c

Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c
==
--- head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May  9 08:35:50 
2019(r347384)
+++ head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May  9 09:45:19 
2019(r347385)
@@ -89,6 +89,7 @@ static int
 linux_pdev_dma_init(struct pci_dev *pdev)
 {
struct linux_dma_priv *priv;
+   int error;
 
priv = malloc(sizeof(*priv), M_DEVBUF, M_WAITOK | M_ZERO);
pdev->dev.dma_priv = priv;
@@ -97,7 +98,14 @@ linux_pdev_dma_init(struct pci_dev *pdev)
 
pctrie_init(&priv->ptree);
 
-   return (0);
+   /* create a default DMA tag */
+   error = linux_dma_tag_init(&pdev->dev, DMA_BIT_MASK(64));
+   if (error) {
+   mtx_destroy(&priv->lock);
+   free(priv, M_DEVBUF);
+   pdev->dev.dma_priv = NULL;
+   }
+   return (error);
 }
 
 static int
@@ -241,7 +249,7 @@ linux_pci_attach(device_t dev)
pdev->irq = pdev->dev.irq;
error = linux_pdev_dma_init(pdev);
if (error)
-   goto out;
+   goto out_dma_init;
 
if (pdev->bus == NULL) {
pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -255,15 +263,18 @@ linux_pci_attach(device_t dev)
spin_unlock(&pci_lock);
 
error = pdrv->probe(pdev, id);
-out:
-   if (error) {
-   spin_lock(&pci_lock);
-   list_del(&pdev->links);
-   spin_unlock(&pci_lock);
-   put_device(&pdev->dev);
-   error = -error;
-   }
-   return (error);
+   if (error)
+   goto out_probe;
+   return (0);
+
+out_probe:
+   linux_pdev_dma_uninit(pdev);
+out_dma_init:
+   spin_lock(&pci_lock);
+   list_del(&pdev->links);
+   spin_unlock(&pci_lock);
+   put_device(&pdev->dev);
+   return (-error);
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347383 - head/sys/netinet6

2019-05-09 Thread Andrey V. Elsukov
Author: ae
Date: Thu May  9 07:57:33 2019
New Revision: 347383
URL: https://svnweb.freebsd.org/changeset/base/347383

Log:
  In mld_v2_cancel_link_timers() check number of references and disconnect
  inm before releasing the last reference. This fixes possible panics and
  assertion.
  
  PR:   237329
  Reviewed by:  mmacy
  MFC after:2 weeks

Modified:
  head/sys/netinet6/mld6.c

Modified: head/sys/netinet6/mld6.c
==
--- head/sys/netinet6/mld6.cThu May  9 07:34:15 2019(r347382)
+++ head/sys/netinet6/mld6.cThu May  9 07:57:33 2019(r347383)
@@ -1708,6 +1708,8 @@ mld_v2_cancel_link_timers(struct mld_ifsoftc *mli)
 * version, we need to release the final
 * reference held for issuing the INCLUDE {}.
 */
+   if (inm->in6m_refcount == 1)
+   in6m_disconnect_locked(&inmh, inm);
in6m_rele_locked(&inmh, inm);
/* FALLTHROUGH */
case MLD_G_QUERY_PENDING_MEMBER:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347382 - head/sys/netinet

2019-05-09 Thread Michael Tuexen
Author: tuexen
Date: Thu May  9 07:34:15 2019
New Revision: 347382
URL: https://svnweb.freebsd.org/changeset/base/347382

Log:
  Receiver side DSACK implemenation.
  
  This adds initial support for RFC 2883.
  
  Submitted by: Richard Scheffenegger
  Reviewed by:  rrs@
  Differential Revision:https://reviews.freebsd.org/D19334

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_sack.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cThu May  9 07:11:08 2019
(r347381)
+++ head/sys/netinet/tcp_input.cThu May  9 07:34:15 2019
(r347382)
@@ -2258,6 +2258,17 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru
TCPSTAT_INC(tcps_rcvpartduppack);
TCPSTAT_ADD(tcps_rcvpartdupbyte, todrop);
}
+   /*
+* DSACK - add SACK block for dropped range
+*/
+   if (tp->t_flags & TF_SACK_PERMIT) {
+   tcp_update_sack_list(tp, th->th_seq, th->th_seq+tlen);
+   /*
+* ACK now, as the next in-sequence segment
+* will clear the DSACK block again
+*/
+   tp->t_flags |= TF_ACKNOW;
+   }
drop_hdrlen += todrop;  /* drop from the top afterwards */
th->th_seq += todrop;
tlen -= todrop;
@@ -2986,6 +2997,8 @@ dodata:   
/* XXX */
if ((tlen || (thflags & TH_FIN) || tfo_syn) &&
TCPS_HAVERCVDFIN(tp->t_state) == 0) {
tcp_seq save_start = th->th_seq;
+   tcp_seq save_rnxt  = tp->rcv_nxt;
+   int save_tlen  = tlen;
m_adj(m, drop_hdrlen);  /* delayed header drop */
/*
 * Insert segment which includes th into TCP reassembly queue
@@ -3025,11 +3038,28 @@ dodata: 
/* XXX */
 * m_adj() doesn't actually frees any mbufs
 * when trimming from the head.
 */
-   thflags = tcp_reass(tp, th, &save_start, &tlen, m);
+   tcp_seq temp = save_start;
+   thflags = tcp_reass(tp, th, &temp, &tlen, m);
tp->t_flags |= TF_ACKNOW;
}
-   if (tlen > 0 && (tp->t_flags & TF_SACK_PERMIT))
-   tcp_update_sack_list(tp, save_start, save_start + tlen);
+   if (tp->t_flags & TF_SACK_PERMIT) {
+   if (((tlen == 0) && (save_tlen > 0) &&
+   (SEQ_LT(save_start, save_rnxt {
+   // DSACK actually handled in the fastpath above
+   tcp_update_sack_list(tp, save_start, save_start 
+ save_tlen);
+   } else
+   if ((tlen > 0) && SEQ_GT(tp->rcv_nxt, save_rnxt)) {
+   // cleaning sackblks by using zero length update
+   tcp_update_sack_list(tp, save_start, 
save_start);
+   } else
+   if ((tlen > 0) && (tlen >= save_tlen)) {
+   // update of sackblks
+   tcp_update_sack_list(tp, save_start, save_start 
+ save_tlen);
+   } else
+   if (tlen > 0) {
+   tcp_update_sack_list(tp, save_start, 
save_start+tlen);
+   }
+   }
 #if 0
/*
 * Note the amount of data that peer has sent into

Modified: head/sys/netinet/tcp_sack.c
==
--- head/sys/netinet/tcp_sack.c Thu May  9 07:11:08 2019(r347381)
+++ head/sys/netinet/tcp_sack.c Thu May  9 07:34:15 2019(r347382)
@@ -168,7 +168,7 @@ tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_sta
INP_WLOCK_ASSERT(tp->t_inpcb);
 
/* Check arguments. */
-   KASSERT(SEQ_LT(rcv_start, rcv_end), ("rcv_start < rcv_end"));
+   KASSERT(SEQ_LEQ(rcv_start, rcv_end), ("rcv_start <= rcv_end"));
 
/* SACK block for the received segment. */
head_blk.start = rcv_start;
@@ -193,12 +193,54 @@ tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_sta
 * Merge this SACK block into head_blk.  This SACK
 * block itself will be discarded.
 */
-   if (SEQ_GT(head_blk.start, start))
+   /*
+* |-|
+*   |---|  merge
+*
+* |-|
+ 

svn commit: r347381 - head/sys/netinet/cc

2019-05-09 Thread Michael Tuexen
Author: tuexen
Date: Thu May  9 07:11:08 2019
New Revision: 347381
URL: https://svnweb.freebsd.org/changeset/base/347381

Log:
  Prevent cwnd to collapse down to 1 MSS after exiting recovery.
  
  This is descrined in RFC 6582, which updates RFC 3782.
  
  Submitted by: Richard Scheffenegger
  Reviewed by:  lstewart@
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D17614

Modified:
  head/sys/netinet/cc/cc_cubic.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/cc/cc_newreno.c

Modified: head/sys/netinet/cc/cc_cubic.c
==
--- head/sys/netinet/cc/cc_cubic.c  Thu May  9 04:16:31 2019
(r347380)
+++ head/sys/netinet/cc/cc_cubic.c  Thu May  9 07:11:08 2019
(r347381)
@@ -324,7 +324,12 @@ cubic_post_recovery(struct cc_var *ccv)
pipe = CCV(ccv, snd_max) - ccv->curack;
 
if (pipe < CCV(ccv, snd_ssthresh))
-   CCV(ccv, snd_cwnd) = pipe + CCV(ccv, t_maxseg);
+   /*
+* Ensure that cwnd does not collapse to 1 MSS under
+* adverse conditions. Implements RFC6582
+*/
+   CCV(ccv, snd_cwnd) = max(pipe, CCV(ccv, t_maxseg)) +
+   CCV(ccv, t_maxseg);
else
/* Update cwnd based on beta and adjusted max_cwnd. */
CCV(ccv, snd_cwnd) = max(1, ((CUBIC_BETA *

Modified: head/sys/netinet/cc/cc_htcp.c
==
--- head/sys/netinet/cc/cc_htcp.c   Thu May  9 04:16:31 2019
(r347380)
+++ head/sys/netinet/cc/cc_htcp.c   Thu May  9 07:11:08 2019
(r347381)
@@ -366,7 +366,12 @@ htcp_post_recovery(struct cc_var *ccv)
pipe = CCV(ccv, snd_max) - ccv->curack;

if (pipe < CCV(ccv, snd_ssthresh))
-   CCV(ccv, snd_cwnd) = pipe + CCV(ccv, t_maxseg);
+   /*
+* Ensure that cwnd down not collape to 1 MSS under
+* adverse conditions. Implements RFC6582
+*/
+   CCV(ccv, snd_cwnd) = max(pipe, CCV(ccv, t_maxseg)) +
+   CCV(ccv, t_maxseg);
else
CCV(ccv, snd_cwnd) = max(1, ((htcp_data->beta *
htcp_data->prev_cwnd / CCV(ccv, t_maxseg))

Modified: head/sys/netinet/cc/cc_newreno.c
==
--- head/sys/netinet/cc/cc_newreno.cThu May  9 04:16:31 2019
(r347380)
+++ head/sys/netinet/cc/cc_newreno.cThu May  9 07:11:08 2019
(r347381)
@@ -295,7 +295,12 @@ newreno_post_recovery(struct cc_var *ccv)
pipe = CCV(ccv, snd_max) - ccv->curack;
 
if (pipe < CCV(ccv, snd_ssthresh))
-   CCV(ccv, snd_cwnd) = pipe + CCV(ccv, t_maxseg);
+   /*
+* Ensure that cwnd does not collapse to 1 MSS under
+* adverse conditons. Implements RFC6582
+*/
+   CCV(ccv, snd_cwnd) = max(pipe, CCV(ccv, t_maxseg)) +
+   CCV(ccv, t_maxseg);
else
CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"