svn commit: r337401 - head/release

2018-08-06 Thread Colin Percival
Author: cperciva
Date: Tue Aug  7 00:51:49 2018
New Revision: 337401
URL: https://svnweb.freebsd.org/changeset/base/337401

Log:
  Fix copy-and-paste error in previous commit.

Modified:
  head/release/Makefile.ec2

Modified: head/release/Makefile.ec2
==
--- head/release/Makefile.ec2   Tue Aug  7 00:10:58 2018(r337400)
+++ head/release/Makefile.ec2   Tue Aug  7 00:51:49 2018(r337401)
@@ -36,7 +36,7 @@ AMINAMESUFFIX!=   date +-%Y-%m-%d
 PUBLISH=   --public
 .endif
 .if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP)
-PUBLISH=   --publicsnap
+PUBLICSNAP=--publicsnap
 .endif
 .if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
 EC2SNSREL= ${REVISION}-${BRANCH}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337400 - head/usr.bin/kdump

2018-08-06 Thread John Baldwin
Author: jhb
Date: Tue Aug  7 00:10:58 2018
New Revision: 337400
URL: https://svnweb.freebsd.org/changeset/base/337400

Log:
  Remove spurious ABI tags from kdump output.
  
  The abidump routine output an ABI tag when -A was specified for records
  that were not displayed due to type or pid filtering.  To fix, split
  the code to lookup the ABI from the code to display the ABI, move the
  code to display the ABI into dumpheader(), and move dumpheader() later
  in the main loop as a simplification.  Previously dumpheader() was
  called under a condition that repeated conditions made later in the
  main loop.
  
  Reviewed by:  kib
  MFC after:1 month
  Sponsored by: DARPA / AFRL
  Differential Revision:https://reviews.freebsd.org/D16608

Modified:
  head/usr.bin/kdump/kdump.c

Modified: head/usr.bin/kdump/kdump.c
==
--- head/usr.bin/kdump/kdump.c  Mon Aug  6 23:51:08 2018(r337399)
+++ head/usr.bin/kdump/kdump.c  Tue Aug  7 00:10:58 2018(r337400)
@@ -94,10 +94,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-u_int abidump(struct ktr_header *);
 int fetchprocinfo(struct ktr_header *, u_int *);
+u_int findabi(struct ktr_header *);
 int fread_tail(void *, int, int);
-void dumpheader(struct ktr_header *);
+void dumpheader(struct ktr_header *, u_int);
 void ktrsyscall(struct ktr_syscall *, u_int);
 void ktrsysret(struct ktr_sysret *, u_int);
 void ktrnamei(char *, int);
@@ -466,10 +466,6 @@ main(int argc, char *argv[])
drop_logged = 1;
}
}
-   if (trpoints & (1< size) {
@@ -482,12 +478,13 @@ main(int argc, char *argv[])
errx(1, "data too short");
if (fetchprocinfo(_header, (u_int *)m) != 0)
continue;
-   sv_flags = abidump(_header);
if (pid && ktr_header.ktr_pid != pid &&
ktr_header.ktr_tid != pid)
continue;
if ((trpoints & (1ktr_pid) {
-   flags = pi->sv_flags;
-   break;
+   return (pi->sv_flags);
}
}
-
-   if (abiflag == 0)
-   return (flags);
-
-   switch (flags & SV_ABI_MASK) {
-   case SV_ABI_LINUX:
-   abi = "L";
-   break;
-   case SV_ABI_FREEBSD:
-   abi = "F";
-   break;
-   case SV_ABI_CLOUDABI:
-   abi = "C";
-   break;
-   default:
-   abi = "U";
-   break;
-   }
-
-   if (flags & SV_LP64)
-   arch = "64";
-   else if (flags & SV_ILP32)
-   arch = "32";
-   else
-   arch = "00";
-
-   printf("%s%s  ", abi, arch);
-
-   return (flags);
+   return (0);
 }
 
 void
-dumpheader(struct ktr_header *kth)
+dumpheader(struct ktr_header *kth, u_int sv_flags)
 {
static char unknown[64];
static struct timeval prevtime, prevtime_e;
struct timeval temp;
+   const char *abi;
+   const char *arch;
const char *type;
const char *sign;
 
@@ -670,10 +637,6 @@ dumpheader(struct ktr_header *kth)
case KTR_SYSCTL:
type = "SCTL";
break;
-   case KTR_PROCCTOR:
-   /* FALLTHROUGH */
-   case KTR_PROCDTOR:
-   return;
case KTR_CAPFAIL:
type = "CAP ";
break;
@@ -731,6 +694,31 @@ dumpheader(struct ktr_header *kth)
}
}
printf("%s  ", type);
+   if (abiflag != 0) {
+   switch (sv_flags & SV_ABI_MASK) {
+   case SV_ABI_LINUX:
+   abi = "L";
+   break;
+   case SV_ABI_FREEBSD:
+   abi = "F";
+   break;
+   case SV_ABI_CLOUDABI:
+   abi = "C";
+   break;
+   default:
+   abi = "U";
+   break;
+   }
+
+   if ((sv_flags & SV_LP64) != 0)
+   arch = "64";
+   else if ((sv_flags & SV_ILP32) != 0)
+   arch = "32";
+   else
+   arch = "00";
+
+   printf("%s%s  ", abi, arch);
+   }
 }
 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337399 - head/sys/sys

2018-08-06 Thread John Baldwin
Author: jhb
Date: Mon Aug  6 23:51:08 2018
New Revision: 337399
URL: https://svnweb.freebsd.org/changeset/base/337399

Log:
  Make the system C11 atomics headers fully compatible with external GCC.
  
  The  and  headers already included support for
  C11 atomics via intrinsincs in modern versions of GCC, but these versions
  tried to "hide" atomic variables inside a wrapper structure.  This wrapper
  is not compatible with GCC's internal  header, so that if
  GCC's  was used together with , use of C11
  atomics would fail to compile.  Fix this by not hiding atomic variables
  in a structure for modern versions of GCC.  The headers already avoid
  using a wrapper structure on clang.
  
  Note that this wrapper was only used if C11 was not enabled (e.g.
  via -std=c99), so this also fixes compile failures if a modern version
  of GCC was used with -std=c11 but with FreeBSD's  instead
  of GCC's  and this change fixes that case as well.
  
  Reported by:  Mark Millard
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D16585

Modified:
  head/sys/sys/cdefs.h
  head/sys/sys/stdatomic.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hMon Aug  6 23:21:13 2018(r337398)
+++ head/sys/sys/cdefs.hMon Aug  6 23:51:08 2018(r337399)
@@ -268,7 +268,7 @@
 #endif
 
 #if !defined(__cplusplus) && !__has_extension(c_atomic) && \
-!__has_extension(cxx_atomic)
+   !__has_extension(cxx_atomic) && !__GNUC_PREREQ__(4, 7)
 /*
  * No native support for _Atomic(). Place object in structure to prevent
  * most forms of direct non-atomic access.

Modified: head/sys/sys/stdatomic.h
==
--- head/sys/sys/stdatomic.hMon Aug  6 23:21:13 2018(r337398)
+++ head/sys/sys/stdatomic.hMon Aug  6 23:51:08 2018(r337399)
@@ -171,12 +171,9 @@ atomic_signal_fence(memory_order __order __unused)
 /* Atomics in kernelspace are always lock-free. */
 #defineatomic_is_lock_free(obj) \
((void)(obj), (_Bool)1)
-#elif defined(__CLANG_ATOMICS)
+#elif defined(__CLANG_ATOMICS) || defined(__GNUC_ATOMICS)
 #defineatomic_is_lock_free(obj) \
__atomic_is_lock_free(sizeof(*(obj)), obj)
-#elif defined(__GNUC_ATOMICS)
-#defineatomic_is_lock_free(obj) \
-   __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val)
 #else
 #defineatomic_is_lock_free(obj) \
((void)(obj), sizeof((obj)->__val) <= sizeof(void *))
@@ -260,28 +257,28 @@ typedef _Atomic(__uintmax_t)  
atomic_uintmax_t;
 #elif defined(__GNUC_ATOMICS)
 #defineatomic_compare_exchange_strong_explicit(object, expected,   
\
 desired, success, failure) \
-   __atomic_compare_exchange_n(&(object)->__val, expected, \
+   __atomic_compare_exchange_n(object, expected,   \
desired, 0, success, failure)
 #defineatomic_compare_exchange_weak_explicit(object, expected, 
\
 desired, success, failure) \
-   __atomic_compare_exchange_n(&(object)->__val, expected, \
+   __atomic_compare_exchange_n(object, expected,   \
desired, 1, success, failure)
 #defineatomic_exchange_explicit(object, desired, order)
\
-   __atomic_exchange_n(&(object)->__val, desired, order)
+   __atomic_exchange_n(object, desired, order)
 #defineatomic_fetch_add_explicit(object, operand, order)   
\
-   __atomic_fetch_add(&(object)->__val, operand, order)
+   __atomic_fetch_add(object, operand, order)
 #defineatomic_fetch_and_explicit(object, operand, order)   
\
-   __atomic_fetch_and(&(object)->__val, operand, order)
+   __atomic_fetch_and(object, operand, order)
 #defineatomic_fetch_or_explicit(object, operand, order)
\
-   __atomic_fetch_or(&(object)->__val, operand, order)
+   __atomic_fetch_or(object, operand, order)
 #defineatomic_fetch_sub_explicit(object, operand, order)   
\
-   __atomic_fetch_sub(&(object)->__val, operand, order)
+   __atomic_fetch_sub(object, operand, order)
 #defineatomic_fetch_xor_explicit(object, operand, order)   
\
-   __atomic_fetch_xor(&(object)->__val, operand, order)
+   __atomic_fetch_xor(object, operand, order)
 #defineatomic_load_explicit(object, order) 
\
-   __atomic_load_n(&(object)->__val, order)
+   __atomic_load_n(object, order)
 #defineatomic_store_explicit(object, desired, order)   
\
-   __atomic_store_n(&(object)->__val, desired, order)
+   __atomic_store_n(object, desired, order)
 #else
 #define__atomic_apply_stride(object, 

svn commit: r337398 - in head/sys/dev/cxgbe: . tom

2018-08-06 Thread Navdeep Parhar
Author: np
Date: Mon Aug  6 23:21:13 2018
New Revision: 337398
URL: https://svnweb.freebsd.org/changeset/base/337398

Log:
  cxgbe(4): Allow user-configured and driver-configured traffic classes to
  be used simultaneously.  Move sysctl_tc and sysctl_tc_params to
  t4_sched.c while here.
  
  MFC after:3 weeks
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sched.c
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_tom.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hMon Aug  6 21:54:51 2018
(r337397)
+++ head/sys/dev/cxgbe/adapter.hMon Aug  6 23:21:13 2018
(r337398)
@@ -235,13 +235,15 @@ struct tx_ch_rl_params {
 };
 
 enum {
-   TX_CLRL_REFRESH = (1 << 0), /* Need to update hardware state. */
-   TX_CLRL_ERROR   = (1 << 1), /* Error, hardware state unknown. */
+   CLRL_USER   = (1 << 0), /* allocated manually. */
+   CLRL_SYNC   = (1 << 1), /* sync hw update in progress. */
+   CLRL_ASYNC  = (1 << 2), /* async hw update requested. */
+   CLRL_ERR= (1 << 3), /* last hw setup ended in error. */
 };
 
 struct tx_cl_rl_params {
int refcount;
-   u_int flags;
+   uint8_t flags;
enum fw_sched_params_rate ratemode; /* %port REL or ABS value */
enum fw_sched_params_unit rateunit; /* kbps or pps (when ABS) */
enum fw_sched_params_mode mode; /* aggr or per-flow */
@@ -1237,7 +1239,9 @@ int t4_init_tx_sched(struct adapter *);
 int t4_free_tx_sched(struct adapter *);
 void t4_update_tx_sched(struct adapter *);
 int t4_reserve_cl_rl_kbps(struct adapter *, int, u_int, int *);
-void t4_release_cl_rl_kbps(struct adapter *, int, int);
+void t4_release_cl_rl(struct adapter *, int, int);
+int sysctl_tc(SYSCTL_HANDLER_ARGS);
+int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
 #ifdef RATELIMIT
 void t4_init_etid_table(struct adapter *);
 void t4_free_etid_table(struct adapter *);

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Aug  6 21:54:51 2018
(r337397)
+++ head/sys/dev/cxgbe/t4_main.cMon Aug  6 23:21:13 2018
(r337398)
@@ -589,7 +589,6 @@ static int sysctl_tp_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_tx_rate(SYSCTL_HANDLER_ARGS);
 static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS);
 static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS);
-static int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
 static int sysctl_cpus(SYSCTL_HANDLER_ARGS);
 #ifdef TCP_OFFLOAD
 static int sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS);
@@ -5963,6 +5962,7 @@ cxgbe_sysctls(struct port_info *pi)
struct adapter *sc = pi->adapter;
int i;
char name[16];
+   static char *tc_flags = {"\20\1USER\2SYNC\3ASYNC\4ERR"};
 
ctx = device_get_sysctl_ctx(pi->dev);
 
@@ -6015,8 +6015,9 @@ cxgbe_sysctls(struct port_info *pi)
children2 = SYSCTL_CHILDREN(SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(oid), OID_AUTO, name, CTLFLAG_RD, NULL,
"traffic class"));
-   SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "flags", CTLFLAG_RD,
-   >flags, 0, "flags");
+   SYSCTL_ADD_PROC(ctx, children2, OID_AUTO, "flags",
+   CTLTYPE_STRING | CTLFLAG_RD, tc_flags, 
(uintptr_t)>flags,
+   sysctl_bitfield_8b, "A", "flags");
SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "refcount",
CTLFLAG_RD, >refcount, 0, "references to this class");
SYSCTL_ADD_PROC(ctx, children2, OID_AUTO, "params",
@@ -8607,83 +8608,6 @@ sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS)
}
}
rc = sbuf_finish(sb);
-   sbuf_delete(sb);
-
-   return (rc);
-}
-
-static int
-sysctl_tc_params(SYSCTL_HANDLER_ARGS)
-{
-   struct adapter *sc = arg1;
-   struct tx_cl_rl_params tc;
-   struct sbuf *sb;
-   int i, rc, port_id, mbps, gbps;
-
-   rc = sysctl_wire_old_buffer(req, 0);
-   if (rc != 0)
-   return (rc);
-
-   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
-   if (sb == NULL)
-   return (ENOMEM);
-
-   port_id = arg2 >> 16;
-   MPASS(port_id < sc->params.nports);
-   MPASS(sc->port[port_id] != NULL);
-   i = arg2 & 0x;
-   MPASS(i < sc->chip_params->nsched_cls);
-
-   mtx_lock(>tc_lock);
-   tc = sc->port[port_id]->sched_params->cl_rl[i];
-   mtx_unlock(>tc_lock);
-
-   switch (tc.rateunit) {
-   case SCHED_CLASS_RATEUNIT_BITS:
-   switch (tc.ratemode) {
-   case SCHED_CLASS_RATEMODE_REL:
-   /* XXX: top speed or actual link speed? */
- 

svn commit: r337397 - head/sys/dev/cxgbe

2018-08-06 Thread Navdeep Parhar
Author: np
Date: Mon Aug  6 21:54:51 2018
New Revision: 337397
URL: https://svnweb.freebsd.org/changeset/base/337397

Log:
  cxgbe(4): Break up sysctl_bitfield into 8 bit and 16 bit variants.  Have
  them display the current value of the bitfield rather than the fixed
  value that was provided when the sysctl node was created.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Aug  6 21:09:11 2018
(r337396)
+++ head/sys/dev/cxgbe/t4_main.cMon Aug  6 21:54:51 2018
(r337397)
@@ -547,7 +547,8 @@ static void cxgbe_tick(void *);
 static void cxgbe_vlan_config(void *, struct ifnet *, uint16_t);
 static void cxgbe_sysctls(struct port_info *);
 static int sysctl_int_array(SYSCTL_HANDLER_ARGS);
-static int sysctl_bitfield(SYSCTL_HANDLER_ARGS);
+static int sysctl_bitfield_8b(SYSCTL_HANDLER_ARGS);
+static int sysctl_bitfield_16b(SYSCTL_HANDLER_ARGS);
 static int sysctl_btphy(SYSCTL_HANDLER_ARGS);
 static int sysctl_noflowq(SYSCTL_HANDLER_ARGS);
 static int sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS);
@@ -5454,8 +5455,8 @@ t4_sysctls(struct adapter *sc)
sc->params.nports, "# of ports");
 
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "doorbells",
-   CTLTYPE_STRING | CTLFLAG_RD, doorbells, sc->doorbells,
-   sysctl_bitfield, "A", "available doorbells");
+   CTLTYPE_STRING | CTLFLAG_RD, doorbells, (uintptr_t)>doorbells,
+   sysctl_bitfield_8b, "A", "available doorbells");
 
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "core_clock", CTLFLAG_RD, NULL,
sc->params.vpd.cclk, "core clock frequency (in KHz)");
@@ -5526,8 +5527,8 @@ t4_sysctls(struct adapter *sc)
 
 #define SYSCTL_CAP(name, n, text) \
SYSCTL_ADD_PROC(ctx, children, OID_AUTO, #name, \
-   CTLTYPE_STRING | CTLFLAG_RD, caps_decoder[n], sc->name, \
-   sysctl_bitfield, "A", "available " text " capabilities")
+   CTLTYPE_STRING | CTLFLAG_RD, caps_decoder[n], (uintptr_t)>name, 
\
+   sysctl_bitfield_16b, "A", "available " text " capabilities")
 
SYSCTL_CAP(nbmcaps, 0, "NBM");
SYSCTL_CAP(linkcaps, 1, "link");
@@ -6215,7 +6216,7 @@ sysctl_int_array(SYSCTL_HANDLER_ARGS)
 }
 
 static int
-sysctl_bitfield(SYSCTL_HANDLER_ARGS)
+sysctl_bitfield_8b(SYSCTL_HANDLER_ARGS)
 {
int rc;
struct sbuf *sb;
@@ -6228,7 +6229,28 @@ sysctl_bitfield(SYSCTL_HANDLER_ARGS)
if (sb == NULL)
return (ENOMEM);
 
-   sbuf_printf(sb, "%b", (int)arg2, (char *)arg1);
+   sbuf_printf(sb, "%b", *(uint8_t *)(uintptr_t)arg2, (char *)arg1);
+   rc = sbuf_finish(sb);
+   sbuf_delete(sb);
+
+   return (rc);
+}
+
+static int
+sysctl_bitfield_16b(SYSCTL_HANDLER_ARGS)
+{
+   int rc;
+   struct sbuf *sb;
+
+   rc = sysctl_wire_old_buffer(req, 0);
+   if (rc != 0)
+   return(rc);
+
+   sb = sbuf_new_for_sysctl(NULL, NULL, 128, req);
+   if (sb == NULL)
+   return (ENOMEM);
+
+   sbuf_printf(sb, "%b", *(uint16_t *)(uintptr_t)arg2, (char *)arg1);
rc = sbuf_finish(sb);
sbuf_delete(sb);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337396 - in head/sys/ufs: ffs ufs

2018-08-06 Thread Kirk McKusick
Author: mckusick
Date: Mon Aug  6 21:09:11 2018
New Revision: 337396
URL: https://svnweb.freebsd.org/changeset/base/337396

Log:
  Put in place the framework for consolodating contiguous blocks into
  a smaller number of larger TRIM requests. The hope had been to have
  the full TRIM consolodation in place for 12.0, but the algorithms
  are still under development and need further testing. With this
  framework in place it will be possible to easily add TRIM consolodation
  once the optimal strategy has been found.
  
  The only functional change with this patch is the elimination of TRIM
  requests for blocks that are freed before they have been likely to
  have been written.
  
  Reviewed by: kib
  Discussed with: Warner Losh and Chuck Silvers
  Sponsored by: Netflix

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_balloc.c
  head/sys/ufs/ffs/ffs_extern.h
  head/sys/ufs/ffs/ffs_inode.c
  head/sys/ufs/ffs/ffs_snapshot.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/softdep.h
  head/sys/ufs/ufs/ufsmount.h

Modified: head/sys/ufs/ffs/ffs_alloc.c
==
--- head/sys/ufs/ffs/ffs_alloc.cMon Aug  6 20:39:27 2018
(r337395)
+++ head/sys/ufs/ffs/ffs_alloc.cMon Aug  6 21:09:11 2018
(r337396)
@@ -110,8 +110,6 @@ static ufs2_daddr_t
 static voidffs_blkfree_cg(struct ufsmount *, struct fs *,
struct vnode *, ufs2_daddr_t, long, ino_t,
struct workhead *);
-static voidffs_blkfree_trim_completed(struct buf *);
-static voidffs_blkfree_trim_task(void *ctx, int pending __unused);
 #ifdef INVARIANTS
 static int ffs_checkblk(struct inode *, ufs2_daddr_t, long);
 #endif
@@ -395,8 +393,23 @@ retry:
if (bno > 0) {
bp->b_blkno = fsbtodb(fs, bno);
if (!DOINGSOFTDEP(vp))
+   /*
+* The usual case is that a smaller fragment that
+* was just allocated has been replaced with a bigger
+* fragment or a full-size block. If it is marked as
+* B_DELWRI, the current contents have not been written
+* to disk. It is possible that the block was written
+* earlier, but very uncommon. If the block has never
+* been written, there is no need to send a BIO_DELETE
+* for it when it is freed. The gain from avoiding the
+* TRIMs for the common case of unwritten blocks far
+* exceeds the cost of the write amplification for the
+* uncommon case of failing to send a TRIM for a block
+* that had been written.
+*/
ffs_blkfree(ump, fs, ump->um_devvp, bprev, (long)osize,
-   ip->i_number, vp->v_type, NULL);
+   ip->i_number, vp->v_type, NULL,
+   (bp->b_flags & B_DELWRI) != 0 ? NOTRIM : SINGLETON);
delta = btodb(nsize - osize);
DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + delta);
if (flags & IO_EXT)
@@ -521,7 +534,7 @@ ffs_reallocblks_ufs1(ap)
struct fs *fs;
struct inode *ip;
struct vnode *vp;
-   struct buf *sbp, *ebp;
+   struct buf *sbp, *ebp, *bp;
ufs1_daddr_t *bap, *sbap, *ebap;
struct cluster_save *buflist;
struct ufsmount *ump;
@@ -730,14 +743,29 @@ ffs_reallocblks_ufs1(ap)
printf("\n\tnew:");
 #endif
for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) {
+   bp = buflist->bs_children[i];
if (!DOINGSOFTDEP(vp))
+   /*
+* The usual case is that a set of N-contiguous blocks
+* that was just allocated has been replaced with a
+* set of N+1-contiguous blocks. If they are marked as
+* B_DELWRI, the current contents have not been written
+* to disk. It is possible that the blocks were written
+* earlier, but very uncommon. If the blocks have never
+* been written, there is no need to send a BIO_DELETE
+* for them when they are freed. The gain from avoiding
+* the TRIMs for the common case of unwritten blocks
+* far exceeds the cost of the write amplification for
+* the uncommon case of failing to send a TRIM for the
+* blocks that had been written.
+*/
ffs_blkfree(ump, fs, ump->um_devvp,
-   dbtofsb(fs, buflist->bs_children[i]->b_blkno),
- 

svn commit: r337395 - in releng: 10.4 10.4/sys/conf 11.1 11.1/sys/conf 11.2 11.2/sys/conf

2018-08-06 Thread Xin LI
Author: delphij
Date: Mon Aug  6 20:39:27 2018
New Revision: 337395
URL: https://svnweb.freebsd.org/changeset/base/337395

Log:
  Bump patch level and document them.
  
  Approved by:  so

Modified:
  releng/10.4/UPDATING
  releng/10.4/sys/conf/newvers.sh
  releng/11.1/UPDATING
  releng/11.1/sys/conf/newvers.sh
  releng/11.2/UPDATING
  releng/11.2/sys/conf/newvers.sh

Modified: releng/10.4/UPDATING
==
--- releng/10.4/UPDATINGMon Aug  6 19:21:32 2018(r337394)
+++ releng/10.4/UPDATINGMon Aug  6 20:39:27 2018(r337395)
@@ -16,6 +16,10 @@ from older versions of FreeBSD, try WITHOUT_CLANG to b
 stable/10, and then rebuild without this option. The bootstrap process from
 older version of current is a bit fragile.
 
+20180806   p10 FreeBSD-SA-18:08.tcp
+
+   Fix resource exhaustion in TCP reassembly.
+
 20180508   p9  FreeBSD-SA-18:06.debugreg
FreeBSD-EN-18:05.mem
FreeBSD-EN-18:06.tzdata

Modified: releng/10.4/sys/conf/newvers.sh
==
--- releng/10.4/sys/conf/newvers.sh Mon Aug  6 19:21:32 2018
(r337394)
+++ releng/10.4/sys/conf/newvers.sh Mon Aug  6 20:39:27 2018
(r337395)
@@ -32,7 +32,7 @@
 
 TYPE="FreeBSD"
 REVISION="10.4"
-BRANCH="RELEASE-p9"
+BRANCH="RELEASE-p10"
 if [ "X${BRANCH_OVERRIDE}" != "X" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi

Modified: releng/11.1/UPDATING
==
--- releng/11.1/UPDATINGMon Aug  6 19:21:32 2018(r337394)
+++ releng/11.1/UPDATINGMon Aug  6 20:39:27 2018(r337395)
@@ -16,6 +16,10 @@ from older versions of FreeBSD, try WITHOUT_CLANG and 
 the tip of head, and then rebuild without this option. The bootstrap process
 from older version of current across the gcc/clang cutover is a bit fragile.
 
+20180806   p12 FreeBSD-SA-18:08.tcp
+
+   Fix resource exhaustion in TCP reassembly.
+
 20180621   p11 FreeBSD-SA-18:07.lazyfpu
FreeBSD-EN-18:07.pmap
 

Modified: releng/11.1/sys/conf/newvers.sh
==
--- releng/11.1/sys/conf/newvers.sh Mon Aug  6 19:21:32 2018
(r337394)
+++ releng/11.1/sys/conf/newvers.sh Mon Aug  6 20:39:27 2018
(r337395)
@@ -44,7 +44,7 @@
 
 TYPE="FreeBSD"
 REVISION="11.1"
-BRANCH="RELEASE-p11"
+BRANCH="RELEASE-p12"
 if [ -n "${BRANCH_OVERRIDE}" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi

Modified: releng/11.2/UPDATING
==
--- releng/11.2/UPDATINGMon Aug  6 19:21:32 2018(r337394)
+++ releng/11.2/UPDATINGMon Aug  6 20:39:27 2018(r337395)
@@ -16,6 +16,10 @@ from older versions of FreeBSD, try WITHOUT_CLANG and 
 the tip of head, and then rebuild without this option. The bootstrap process
 from older version of current across the gcc/clang cutover is a bit fragile.
 
+20180806   p1  FreeBSD-SA-18:08.tcp
+
+   Fix resource exhaustion in TCP reassembly.
+
 20180627:
11.2-RELEASE.
 

Modified: releng/11.2/sys/conf/newvers.sh
==
--- releng/11.2/sys/conf/newvers.sh Mon Aug  6 19:21:32 2018
(r337394)
+++ releng/11.2/sys/conf/newvers.sh Mon Aug  6 20:39:27 2018
(r337395)
@@ -44,7 +44,7 @@
 
 TYPE="FreeBSD"
 REVISION="11.2"
-BRANCH="RELEASE"
+BRANCH="RELEASE-p1"
 if [ -n "${BRANCH_OVERRIDE}" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337394 - head/release

2018-08-06 Thread Colin Percival
Author: cperciva
Date: Mon Aug  6 19:21:32 2018
New Revision: 337394
URL: https://svnweb.freebsd.org/changeset/base/337394

Log:
  Add EC2PUBLICSNAP option to EC2 builds; this passes a (recently added)
  flag to bsdec2-image-upload instructing it to mark the snapshot of its
  root disk as public (which is independent from marking the created AMIs
  as public).
  
  Requested by: Amazon

Modified:
  head/release/Makefile.ec2

Modified: head/release/Makefile.ec2
==
--- head/release/Makefile.ec2   Mon Aug  6 19:09:55 2018(r337393)
+++ head/release/Makefile.ec2   Mon Aug  6 19:21:32 2018(r337394)
@@ -35,6 +35,9 @@ AMINAMESUFFIX!=   date +-%Y-%m-%d
 .if defined(EC2PUBLIC) && !empty(EC2PUBLIC)
 PUBLISH=   --public
 .endif
+.if defined(EC2PUBLICSNAP) && !empty(EC2PUBLICSNAP)
+PUBLISH=   --publicsnap
+.endif
 .if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
 EC2SNSREL= ${REVISION}-${BRANCH}
 EC2SNSVERS=${EC2_SVNBRANCH}@${EC2_SVNREV}
@@ -79,7 +82,7 @@ ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
@echo "--"
@false
 .endif
-   /usr/local/bin/bsdec2-image-upload ${PUBLISH} --sriov --ena \
+   /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} --sriov 
--ena \
${.OBJDIR}/ec2.raw \
"${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
"${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337393 - head/sys/dev/cxgbe/tom

2018-08-06 Thread Navdeep Parhar
Author: np
Date: Mon Aug  6 19:09:55 2018
New Revision: 337393
URL: https://svnweb.freebsd.org/changeset/base/337393

Log:
  Fix typo in cxgbe/t4_tom.

Modified:
  head/sys/dev/cxgbe/tom/t4_cpl_io.c

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Mon Aug  6 18:47:03 2018
(r337392)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Mon Aug  6 19:09:55 2018
(r337393)
@@ -198,7 +198,7 @@ send_flowc_wr(struct toepcb *toep, struct flowc_tx_par
 
 #ifdef RATELIMIT
 /*
- * Input is Bytes/second (so_max_pacing-rate), chip counts in Kilobits/second.
+ * Input is Bytes/second (so_max_pacing_rate), chip counts in Kilobits/second.
  */
 static int
 update_tx_rate_limit(struct adapter *sc, struct toepcb *toep, u_int Bps)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r337384 - in head: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
On Mon, Aug 6, 2018 at 2:16 PM Bjoern A. Zeeb <
bzeeb-li...@lists.zabbadoz.net> wrote:
>
> On 6 Aug 2018, at 17:36, Jonathan T. Looney wrote:
>
> > Author: jtl
> > Date: Mon Aug  6 17:36:57 2018
> > New Revision: 337384
> > URL: https://svnweb.freebsd.org/changeset/base/337384
> >
> > Log:
> >   Address concerns about CPU usage while doing TCP reassembly.
> …
> >
> >   Reviewed by:jhb
> >   Approved by:so
> >   Security:   FreeBSD-SA-18:08.tcp
> >   Security:   CVE-2018-6922
> >
> > Modified:
> >   head/share/man/man4/tcp.4
> >   head/sys/netinet/tcp_reass.c
> >
> Would you mind bumping .Dd as well please?

Done for head and the stable branches. I'll ask so@ about the releng
branches.

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


svn commit: r337392 - stable/10/share/man/man4

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 18:47:03 2018
New Revision: 337392
URL: https://svnweb.freebsd.org/changeset/base/337392

Log:
  MFC r337390: Bump date after r337384.

Modified:
  stable/10/share/man/man4/tcp.4
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/tcp.4
==
--- stable/10/share/man/man4/tcp.4  Mon Aug  6 18:46:09 2018
(r337391)
+++ stable/10/share/man/man4/tcp.4  Mon Aug  6 18:47:03 2018
(r337392)
@@ -38,7 +38,7 @@
 .\" From: @(#)tcp.48.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd October 13, 2014
+.Dd August 6, 2018
 .Dt TCP 4
 .Os
 .Sh NAME
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337391 - stable/11/share/man/man4

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 18:46:09 2018
New Revision: 337391
URL: https://svnweb.freebsd.org/changeset/base/337391

Log:
  MFC r337390: Bump date after r337384.

Modified:
  stable/11/share/man/man4/tcp.4
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/tcp.4
==
--- stable/11/share/man/man4/tcp.4  Mon Aug  6 18:42:37 2018
(r337390)
+++ stable/11/share/man/man4/tcp.4  Mon Aug  6 18:46:09 2018
(r337391)
@@ -34,7 +34,7 @@
 .\" From: @(#)tcp.48.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd February 6, 2017
+.Dd August 6, 2018
 .Dt TCP 4
 .Os
 .Sh NAME
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337390 - head/share/man/man4

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 18:42:37 2018
New Revision: 337390
URL: https://svnweb.freebsd.org/changeset/base/337390

Log:
  Bump date after r337384.
  
  Reported by:  bz

Modified:
  head/share/man/man4/tcp.4

Modified: head/share/man/man4/tcp.4
==
--- head/share/man/man4/tcp.4   Mon Aug  6 17:50:40 2018(r337389)
+++ head/share/man/man4/tcp.4   Mon Aug  6 18:42:37 2018(r337390)
@@ -34,7 +34,7 @@
 .\" From: @(#)tcp.48.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd May 9, 2018
+.Dd August 6, 2018
 .Dt TCP 4
 .Os
 .Sh NAME
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r337384 - in head: share/man/man4 sys/netinet

2018-08-06 Thread Bjoern A. Zeeb

On 6 Aug 2018, at 17:36, Jonathan T. Looney wrote:


Author: jtl
Date: Mon Aug  6 17:36:57 2018
New Revision: 337384
URL: https://svnweb.freebsd.org/changeset/base/337384

Log:
  Address concerns about CPU usage while doing TCP reassembly.

…


  Reviewed by:  jhb
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  head/share/man/man4/tcp.4
  head/sys/netinet/tcp_reass.c

Modified: head/share/man/man4/tcp.4
==
--- head/share/man/man4/tcp.4   Mon Aug  6 17:21:20 2018(r337383)
+++ head/share/man/man4/tcp.4   Mon Aug  6 17:36:57 2018(r337384)
@@ -445,6 +445,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments


Would you mind bumping .Dd as well please?

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


svn commit: r337389 - in releng/10.4: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:50:40 2018
New Revision: 337389
URL: https://svnweb.freebsd.org/changeset/base/337389

Log:
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  releng/10.4/share/man/man4/tcp.4
  releng/10.4/sys/netinet/tcp_reass.c

Modified: releng/10.4/share/man/man4/tcp.4
==
--- releng/10.4/share/man/man4/tcp.4Mon Aug  6 17:48:46 2018
(r337388)
+++ releng/10.4/share/man/man4/tcp.4Mon Aug  6 17:50:40 2018
(r337389)
@@ -436,6 +436,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: releng/10.4/sys/netinet/tcp_reass.c
==
--- releng/10.4/sys/netinet/tcp_reass.c Mon Aug  6 17:48:46 2018
(r337388)
+++ releng/10.4/sys/netinet/tcp_reass.c Mon Aug  6 17:50:40 2018
(r337389)
@@ -96,6 +96,11 @@ SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO, overflows,
 
 static uma_zone_t tcp_reass_zone;
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -184,6 +189,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -194,7 +203,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
tcp_reass_overflows++;
TCPSTAT_INC(tcps_rcvmemdrop);
m_freem(m);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337388 - in releng/11.1: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:48:46 2018
New Revision: 337388
URL: https://svnweb.freebsd.org/changeset/base/337388

Log:
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  releng/11.1/share/man/man4/tcp.4
  releng/11.1/sys/netinet/tcp_reass.c

Modified: releng/11.1/share/man/man4/tcp.4
==
--- releng/11.1/share/man/man4/tcp.4Mon Aug  6 17:47:47 2018
(r337387)
+++ releng/11.1/share/man/man4/tcp.4Mon Aug  6 17:48:46 2018
(r337388)
@@ -445,6 +445,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: releng/11.1/sys/netinet/tcp_reass.c
==
--- releng/11.1/sys/netinet/tcp_reass.c Mon Aug  6 17:47:47 2018
(r337387)
+++ releng/11.1/sys/netinet/tcp_reass.c Mon Aug  6 17:48:46 2018
(r337388)
@@ -89,6 +89,11 @@ SYSCTL_UMA_CUR(_net_inet_tcp_reass, OID_AUTO, cursegme
 _reass_zone,
 "Global number of TCP Segments currently in Reassembly Queue");
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -168,6 +173,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -178,7 +187,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
TCPSTAT_INC(tcps_rcvreassfull);
*tlenp = 0;
if ((s = tcp_log_addrs(>t_inpcb->inp_inc, th, NULL, NULL))) 
{
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337387 - in releng/11.2: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:47:47 2018
New Revision: 337387
URL: https://svnweb.freebsd.org/changeset/base/337387

Log:
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  releng/11.2/share/man/man4/tcp.4
  releng/11.2/sys/netinet/tcp_reass.c

Modified: releng/11.2/share/man/man4/tcp.4
==
--- releng/11.2/share/man/man4/tcp.4Mon Aug  6 17:46:28 2018
(r337386)
+++ releng/11.2/share/man/man4/tcp.4Mon Aug  6 17:47:47 2018
(r337387)
@@ -445,6 +445,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: releng/11.2/sys/netinet/tcp_reass.c
==
--- releng/11.2/sys/netinet/tcp_reass.c Mon Aug  6 17:46:28 2018
(r337386)
+++ releng/11.2/sys/netinet/tcp_reass.c Mon Aug  6 17:47:47 2018
(r337387)
@@ -89,6 +89,11 @@ SYSCTL_UMA_CUR(_net_inet_tcp_reass, OID_AUTO, cursegme
 _reass_zone,
 "Global number of TCP Segments currently in Reassembly Queue");
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -168,6 +173,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -178,7 +187,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
TCPSTAT_INC(tcps_rcvreassfull);
*tlenp = 0;
if ((s = tcp_log_addrs(>t_inpcb->inp_inc, th, NULL, NULL))) 
{
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337386 - in stable/10: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:46:28 2018
New Revision: 337386
URL: https://svnweb.freebsd.org/changeset/base/337386

Log:
  MFC r337384:
  
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Sponsored by: CVE-2018-6922

Modified:
  stable/10/share/man/man4/tcp.4
  stable/10/sys/netinet/tcp_reass.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/tcp.4
==
--- stable/10/share/man/man4/tcp.4  Mon Aug  6 17:41:53 2018
(r337385)
+++ stable/10/share/man/man4/tcp.4  Mon Aug  6 17:46:28 2018
(r337386)
@@ -436,6 +436,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: stable/10/sys/netinet/tcp_reass.c
==
--- stable/10/sys/netinet/tcp_reass.c   Mon Aug  6 17:41:53 2018
(r337385)
+++ stable/10/sys/netinet/tcp_reass.c   Mon Aug  6 17:46:28 2018
(r337386)
@@ -96,6 +96,11 @@ SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO, overflows,
 
 static uma_zone_t tcp_reass_zone;
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -184,6 +189,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -194,7 +203,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
tcp_reass_overflows++;
TCPSTAT_INC(tcps_rcvmemdrop);
m_freem(m);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337385 - in stable/11: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:41:53 2018
New Revision: 337385
URL: https://svnweb.freebsd.org/changeset/base/337385

Log:
  MFC r337384:
  
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Reviewed by:  jhb
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  stable/11/share/man/man4/tcp.4
  stable/11/sys/netinet/tcp_reass.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/tcp.4
==
--- stable/11/share/man/man4/tcp.4  Mon Aug  6 17:36:57 2018
(r337384)
+++ stable/11/share/man/man4/tcp.4  Mon Aug  6 17:41:53 2018
(r337385)
@@ -445,6 +445,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: stable/11/sys/netinet/tcp_reass.c
==
--- stable/11/sys/netinet/tcp_reass.c   Mon Aug  6 17:36:57 2018
(r337384)
+++ stable/11/sys/netinet/tcp_reass.c   Mon Aug  6 17:41:53 2018
(r337385)
@@ -89,6 +89,11 @@ SYSCTL_UMA_CUR(_net_inet_tcp_reass, OID_AUTO, cursegme
 _reass_zone,
 "Global number of TCP Segments currently in Reassembly Queue");
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -168,6 +173,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -178,7 +187,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
TCPSTAT_INC(tcps_rcvreassfull);
*tlenp = 0;
if ((s = tcp_log_addrs(>t_inpcb->inp_inc, th, NULL, NULL))) 
{
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337384 - in head: share/man/man4 sys/netinet

2018-08-06 Thread Jonathan T. Looney
Author: jtl
Date: Mon Aug  6 17:36:57 2018
New Revision: 337384
URL: https://svnweb.freebsd.org/changeset/base/337384

Log:
  Address concerns about CPU usage while doing TCP reassembly.
  
  Currently, the per-queue limit is a function of the receive buffer
  size and the MSS.  In certain cases (such as connections with large
  receive buffers), the per-queue segment limit can be quite large.
  Because we process segments as a linked list, large queues may not
  perform acceptably.
  
  The better long-term solution is to make the queue more efficient.
  But, in the short-term, we can provide a way for a system
  administrator to set the maximum queue size.
  
  We set the default queue limit to 100.  This is an effort to balance
  performance with a sane resource limit.  Depending on their
  environment, goals, etc., an administrator may choose to modify this
  limit in either direction.
  
  Reviewed by:  jhb
  Approved by:  so
  Security: FreeBSD-SA-18:08.tcp
  Security: CVE-2018-6922

Modified:
  head/share/man/man4/tcp.4
  head/sys/netinet/tcp_reass.c

Modified: head/share/man/man4/tcp.4
==
--- head/share/man/man4/tcp.4   Mon Aug  6 17:21:20 2018(r337383)
+++ head/share/man/man4/tcp.4   Mon Aug  6 17:36:57 2018(r337384)
@@ -445,6 +445,20 @@ no reseeding will occur.
 Reseeding should not be necessary, and will break
 .Dv TIME_WAIT
 recycling for a few minutes.
+.It Va reass.cursegments
+The current total number of segments present in all reassembly queues.
+.It Va reass.maxsegments
+The maximum limit on the total number of segments across all reassembly
+queues.
+The limit can be adjusted as a tunable.
+.It Va reass.maxqueuelen
+The maximum number of segments allowed in each reassembly queue.
+By default, the system chooses a limit based on each TCP connection's
+receive buffer size and maximum segment size (MSS).
+The actual limit applied to a session's reassembly queue will be the lower of
+the system-calculated automatic limit and the user-specified
+.Va reass.maxqueuelen
+limit.
 .It Va rexmit_min , rexmit_slop
 Adjust the retransmit timer calculation for
 .Tn TCP .

Modified: head/sys/netinet/tcp_reass.c
==
--- head/sys/netinet/tcp_reass.cMon Aug  6 17:21:20 2018
(r337383)
+++ head/sys/netinet/tcp_reass.cMon Aug  6 17:36:57 2018
(r337384)
@@ -91,6 +91,11 @@ SYSCTL_UMA_CUR(_net_inet_tcp_reass, OID_AUTO, cursegme
 _reass_zone,
 "Global number of TCP Segments currently in Reassembly Queue");
 
+static u_int tcp_reass_maxqueuelen = 100;
+SYSCTL_UINT(_net_inet_tcp_reass, OID_AUTO, maxqueuelen, CTLFLAG_RWTUN,
+_reass_maxqueuelen, 0,
+"Maximum number of TCP Segments per Reassembly Queue");
+
 /* Initialize TCP reassembly queue */
 static void
 tcp_reass_zone_change(void *tag)
@@ -170,6 +175,10 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * socket receive buffer determines our advertised window and grows
 * automatically when socket buffer autotuning is enabled. Use it as the
 * basis for our queue limit.
+*
+* However, allow the user to specify a ceiling for the number of
+* segments in each queue.
+*
 * Always let the missing segment through which caused this queue.
 * NB: Access to the socket buffer is left intentionally unlocked as we
 * can tolerate stale information here.
@@ -180,7 +189,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tl
 * is understood.
 */
if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
-   tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+   tp->t_segqlen >= min((so->so_rcv.sb_hiwat / tp->t_maxseg) + 1,
+   tcp_reass_maxqueuelen)) {
TCPSTAT_INC(tcps_rcvreassfull);
*tlenp = 0;
if ((s = tcp_log_addrs(>t_inpcb->inp_inc, th, NULL, NULL))) 
{
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337383 - head/release/tools

2018-08-06 Thread Emmanuel Vadot
Author: manu
Date: Mon Aug  6 17:21:20 2018
New Revision: 337383
URL: https://svnweb.freebsd.org/changeset/base/337383

Log:
  release: arm: Copy the dtb to the fat partition
  
  When booting via EFI on arm we have no way to know the dtb file to load
  and we always use the one provided from the bootloader.
  This works in most case but :
  
   U-Boot have some really old DTB for some boards, the sync from Linux isn't 
done automatically for all boards
   Some boards (like TI BeagleBone series) use one u-boot for all the model and 
it doesn't embed the DTBs
   Some boards (like IMX6 based ones), don't embed the DTB
  
  We want u-boot to load and patch the DTB with the mac address or the display
  node enabled or not.
  
  Reviewed by:  gjb, imp
  Differential Revision:https://reviews.freebsd.org/D16596

Modified:
  head/release/tools/arm.subr

Modified: head/release/tools/arm.subr
==
--- head/release/tools/arm.subr Mon Aug  6 16:22:01 2018(r337382)
+++ head/release/tools/arm.subr Mon Aug  6 17:21:20 2018(r337383)
@@ -201,6 +201,8 @@ arm_install_boot() {
chroot ${CHROOTDIR} cp -p ${BOOTFILES}/efi/loader/loader.efi \
${FATMOUNT}/EFI/BOOT/$(efi_boot_name ${EMBEDDED_TARGET})
 
+   chroot ${CHROOTDIR} cp -R ${UFSMOUNT}/boot/dtb ${FATMOUNT}
+
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
umount_loop ${CHROOTDIR}/${FATMOUNT}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337382 - in head: etc/mtree sbin/dhclient sbin/init/rc.d

2018-08-06 Thread Mark Johnston
Author: markj
Date: Mon Aug  6 16:22:01 2018
New Revision: 337382
URL: https://svnweb.freebsd.org/changeset/base/337382

Log:
  dhclient: Don't chroot if we are in capability mode.
  
  The main dhclient process is Capsicumized but also chroots to
  restrict filesystem access.  With r322369, pidfile(3) maintains a
  directory descriptor for the pidfile, which can cause the chroot
  to fail in certain cases.  To minimize the problem, only chroot
  if we fail to enter capability mode, and store dhclient pidfiles
  in a subdirectory of /var/run, thus restricting access via
  pidfile(3)'s directory descriptor.
  
  PR:   223327
  Reviewed by:  cem, oshogbo
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D16584

Modified:
  head/etc/mtree/BSD.var.dist
  head/sbin/dhclient/dhclient.8
  head/sbin/dhclient/dhclient.c
  head/sbin/init/rc.d/dhclient

Modified: head/etc/mtree/BSD.var.dist
==
--- head/etc/mtree/BSD.var.dist Mon Aug  6 15:55:58 2018(r337381)
+++ head/etc/mtree/BSD.var.dist Mon Aug  6 16:22:01 2018(r337382)
@@ -74,6 +74,8 @@
 preserve
 ..
 run
+dhclient
+..
 ppp gname=network mode=0770
 ..
 wpa_supplicant

Modified: head/sbin/dhclient/dhclient.8
==
--- head/sbin/dhclient/dhclient.8   Mon Aug  6 15:55:58 2018
(r337381)
+++ head/sbin/dhclient/dhclient.8   Mon Aug  6 16:22:01 2018
(r337382)
@@ -38,7 +38,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 13, 2011
+.Dd August 4, 2018
 .Dt DHCLIENT 8
 .Os
 .Sh NAME
@@ -87,7 +87,7 @@ for the leases file.
 .It Fl p Ar file
 Specify an alternate location for the PID file.
 The default is
-.Pa /var/run/dhclient. Ns Ar interface Ns Pa .pid .
+.Pa /var/run/dhclient/dhclient. Ns Ar interface Ns Pa .pid .
 .It Fl q
 Forces
 .Nm
@@ -194,3 +194,16 @@ and
 .Pp
 The current implementation was reworked by
 .An Henning Brauer Aq Mt henn...@openbsd.org .
+.Sh BUGS
+The
+.Nm
+utility uses
+.Xr capsicum 4
+to sandbox the main process.
+If the requisite kernel support is not available, the main process will
+attempt to run in a
+.Xr chroot 2
+sandbox instead.
+This will fail if the process is jailed or the
+.Va kern.chroot_allow_open_directories
+sysctl is set to 0.

Modified: head/sbin/dhclient/dhclient.c
==
--- head/sbin/dhclient/dhclient.c   Mon Aug  6 15:55:58 2018
(r337381)
+++ head/sbin/dhclient/dhclient.c   Mon Aug  6 16:22:01 2018
(r337382)
@@ -371,6 +371,7 @@ init_casper(void)
 int
 main(int argc, char *argv[])
 {
+   u_intcapmode;
int  ch, fd, quiet = 0, i = 0;
int  pipe_fd[2];
int  immediate_daemon = 0;
@@ -419,7 +420,7 @@ main(int argc, char *argv[])
 
if (path_dhclient_pidfile == NULL) {
asprintf(_dhclient_pidfile,
-   "%sdhclient.%s.pid", _PATH_VARRUN, *argv);
+   "%s/dhclient/dhclient.%s.pid", _PATH_VARRUN, *argv);
if (path_dhclient_pidfile == NULL)
error("asprintf");
}
@@ -528,11 +529,6 @@ main(int argc, char *argv[])
if (cap_rights_limit(routefd, ) < 0 && errno != ENOSYS)
error("can't limit route socket: %m");
 
-   if (chroot(_PATH_VAREMPTY) == -1)
-   error("chroot");
-   if (chdir("/") == -1)
-   error("chdir(\"/\")");
-
if (setgroups(1, >pw_gid) ||
setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
seteuid(pw->pw_uid) || setuid(pw->pw_uid))
@@ -545,6 +541,19 @@ main(int argc, char *argv[])
if (caph_enter_casper() < 0)
error("can't enter capability mode: %m");
 
+   /*
+* If we are not in capability mode (i.e., because Capsicum or
+* libcasper is disabled), try to restrict filesystem access.  This
+* will fail if kern.chroot_allow_open_directories is 0 or the process
+* is jailed.
+*/
+   if (cap_getmode() < 0 || capmode == 0) {
+   if (chroot(_PATH_VAREMPTY) == -1)
+   error("chroot");
+   if (chdir("/") == -1)
+   error("chdir(\"/\")");
+   }
+
if (immediate_daemon)
go_daemon();
 
@@ -2449,13 +2458,8 @@ go_daemon(void)
 
cap_rights_init();
 
-   if (pidfile != NULL) {
+   if (pidfile != NULL)
pidfile_write(pidfile);
-   if (cap_rights_limit(pidfile_fileno(pidfile), ) < 0 &&
-   errno != ENOSYS) {
-   error("can't limit pidfile descriptor: %m");
-   }
-   }
 
if (nullfd != -1) {

Re: svn commit: r337379 - head/sys/arm/conf

2018-08-06 Thread Andrew Turner



> On 6 Aug 2018, at 15:40, Andrew Turner  wrote:
> 
> Author: andrew
> Date: Mon Aug  6 14:40:45 2018
> New Revision: 337379
> URL: https://svnweb.freebsd.org/changeset/base/337379
> 
> Log:
>  Default to armv5te in LINT on arm. This should fix building LINT there.

Reported by: jhb

Andrew

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


svn commit: r337381 - head/contrib/netbsd-tests/lib/libpthread

2018-08-06 Thread Ruslan Bukin
Author: br
Date: Mon Aug  6 15:55:58 2018
New Revision: 337381
URL: https://svnweb.freebsd.org/changeset/base/337381

Log:
  Increase timeout for timedmutex_test:mutex2, timedmutex_test:mutex3
  tests.
  
  Default value is 300. It takes ~310s to complete each of these tests
  in QEMU/RISC-V.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/contrib/netbsd-tests/lib/libpthread/t_mutex.c

Modified: head/contrib/netbsd-tests/lib/libpthread/t_mutex.c
==
--- head/contrib/netbsd-tests/lib/libpthread/t_mutex.c  Mon Aug  6 15:21:46 
2018(r337380)
+++ head/contrib/netbsd-tests/lib/libpthread/t_mutex.c  Mon Aug  6 15:55:58 
2018(r337381)
@@ -153,6 +153,12 @@ ATF_TC_HEAD(mutex2, tc)
atf_tc_set_md_var(tc, "timeout", "40");
 #endif
 #endif
+
+#ifdef __FreeBSD__
+#if defined(__riscv)
+   atf_tc_set_md_var(tc, "timeout", "600");
+#endif
+#endif
 }
 ATF_TC_BODY(mutex2, tc)
 {
@@ -228,6 +234,12 @@ ATF_TC_HEAD(mutex3, tc)
 #ifdef __NetBSD__
 #if defined(__powerpc__)
atf_tc_set_md_var(tc, "timeout", "40");
+#endif
+#endif
+
+#ifdef __FreeBSD__
+#if defined(__riscv)
+   atf_tc_set_md_var(tc, "timeout", "600");
 #endif
 #endif
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337379 - head/sys/arm/conf

2018-08-06 Thread Andrew Turner
Author: andrew
Date: Mon Aug  6 14:40:45 2018
New Revision: 337379
URL: https://svnweb.freebsd.org/changeset/base/337379

Log:
  Default to armv5te in LINT on arm. This should fix building LINT there.

Modified:
  head/sys/arm/conf/NOTES

Modified: head/sys/arm/conf/NOTES
==
--- head/sys/arm/conf/NOTES Mon Aug  6 11:45:28 2018(r337378)
+++ head/sys/arm/conf/NOTES Mon Aug  6 14:40:45 2018(r337379)
@@ -12,6 +12,7 @@ files "../mv/orion/files.ts7800"
 
 optionsPHYSADDR=0x
 
+makeoptionsCONF_CFLAGS+="-march=armv5te"
 makeoptionsLDFLAGS="-zmuldefs"
 makeoptionsKERNPHYSADDR=0x
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337378 - head/share/man/man8

2018-08-06 Thread Mateusz Piotrowski
Author: 0mp (ports committer)
Date: Mon Aug  6 11:45:28 2018
New Revision: 337378
URL: https://svnweb.freebsd.org/changeset/base/337378

Log:
  Fix "mandoc -Tlint" warnings.
  
  Reviewed by:  bcr
  Approved by:  mat (mentor)
  Differential Revision:https://reviews.freebsd.org/D15580

Modified:
  head/share/man/man8/rc.subr.8

Modified: head/share/man/man8/rc.subr.8
==
--- head/share/man/man8/rc.subr.8   Mon Aug  6 11:38:55 2018
(r337377)
+++ head/share/man/man8/rc.subr.8   Mon Aug  6 11:45:28 2018
(r337378)
@@ -419,7 +419,7 @@ and errors about usage of services that are not enable
 .Xr rc.conf 5 .
 This prefix also sets
 .Va rc_quiet Ns = Ns Li YES .
-.Em Please, note:
+.Em Please, note\&:
 .Va rc_quiet
 is not intended to completely mask all debug and warning messages,
 but only certain small classes of them.
@@ -506,7 +506,7 @@ This is done after invoking the commands from
 so that the missing modules are not loaded in vain
 if the preliminary commands indicate a error condition.
 A word in the list can have an optional
-.Dq Li : Ns Ar modname
+.Dq Li \&: Ns Ar modname
 or
 .Dq Li ~ Ns Ar pattern
 suffix.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337377 - head/sbin/mount

2018-08-06 Thread Mateusz Piotrowski
Author: 0mp (ports committer)
Date: Mon Aug  6 11:38:55 2018
New Revision: 337377
URL: https://svnweb.freebsd.org/changeset/base/337377

Log:
  Fix synopsis of the -t option.
  
  While here:
  
   - Remove deprecated ".Tn" macros.
   - Improve formatting and fix typos in the description of
 the -t option.
  
  Reviewed by:  bcr
  Approved by:  mat (mentor)
  Differential Revision:https://reviews.freebsd.org/D16541

Modified:
  head/sbin/mount/mount.8

Modified: head/sbin/mount/mount.8
==
--- head/sbin/mount/mount.8 Mon Aug  6 10:48:20 2018(r337376)
+++ head/sbin/mount/mount.8 Mon Aug  6 11:38:55 2018(r337377)
@@ -39,14 +39,14 @@
 .Op Fl adflpruvw
 .Op Fl F Ar fstab
 .Op Fl o Ar options
-.Op Fl t Cm ufs | Ar external_type
+.Op Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
 .Nm
 .Op Fl dfpruvw
 .Ar special | node
 .Nm
 .Op Fl dfpruvw
 .Op Fl o Ar options
-.Op Fl t Cm ufs | Ar external_type
+.Op Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
 .Ar special node
 .Sh DESCRIPTION
 The
@@ -139,9 +139,7 @@ This flag is mutually exclusive with
 .Cm nfsv4acls
 flag.
 .It Cm async
-All
-.Tn I/O
-to the file system should be done asynchronously.
+All I/O to the file system should be done asynchronously.
 This is a
 .Em dangerous
 flag to set, since it does not guarantee that the file system structure
@@ -345,9 +343,7 @@ See
 .Xr chmod 2
 for more information.
 .It Cm sync
-All
-.Tn I/O
-to the file system should be done synchronously.
+All I/O to the file system should be done synchronously.
 .It Cm update
 The same as
 .Fl u ;
@@ -415,7 +411,7 @@ The same as the
 argument to the
 .Fl o
 option.
-.It Fl t Cm ufs | Ar external_type
+.It Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
 The argument following the
 .Fl t
 is used to indicate the file system type.
@@ -429,7 +425,7 @@ to indicate that the actions should only be taken on
 file systems of the specified type.
 More than one type may be specified in a comma separated list.
 The list of file system types can be prefixed with
-.Dq Li no
+.Cm no
 to specify the file system types for which action should
 .Em not
 be taken.
@@ -440,10 +436,7 @@ command:
 mount -a -t nonfs,nullfs
 .Ed
 .Pp
-mounts all file systems except those of type
-.Tn NFS
-and
-.Tn NULLFS .
+mounts all file systems except those of type NFS and NULLFS.
 .Pp
 The default behavior of
 .Nm
@@ -464,16 +457,18 @@ However, for the following file system types:
 .Cm smbfs ,
 .Cm udf ,
 and
-.Cm unionfs .
+.Cm unionfs
 .Nm
 will not call
 .Xr nmount 2
 directly and will instead attempt to execute a program in
-.Pa /sbin/mount_ Ns Sy XXX
+.Pa /sbin/mount_ Ns Ar type
 where
-.Sy XXX
+.Ar type
 is replaced by the file system type name.
-For example, nfs file systems are mounted by the program
+For example,
+.Cm nfs
+file systems are mounted by the program
 .Pa /sbin/mount_nfs .
 .Pp
 Most file systems will be dynamically loaded by the kernel
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337376 - in head/sys/compat/linuxkpi/common: include/linux src

2018-08-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  6 10:48:20 2018
New Revision: 337376
URL: https://svnweb.freebsd.org/changeset/base/337376

Log:
  Implement current_work() function in the LinuxKPI.
  
  Tested by:Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/include/linux/workqueue.h
  head/sys/compat/linuxkpi/common/src/linux_work.c

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Mon Aug  6 
09:22:07 2018(r337375)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Mon Aug  6 
10:48:20 2018(r337376)
@@ -60,6 +60,7 @@
 
 #defineTASK_COMM_LEN   (MAXCOMLEN + 1)
 
+struct work_struct;
 struct task_struct {
struct thread *task_thread;
struct mm_struct *mm;
@@ -78,6 +79,7 @@ struct task_struct {
TAILQ_ENTRY(task_struct) rcu_entry;
int rcu_recurse;
int bsd_interrupt_value;
+   struct work_struct *work;   /* current work struct, if set */
 };
 
 #definecurrent ({ \

Modified: head/sys/compat/linuxkpi/common/include/linux/workqueue.h
==
--- head/sys/compat/linuxkpi/common/include/linux/workqueue.h   Mon Aug  6 
09:22:07 2018(r337375)
+++ head/sys/compat/linuxkpi/common/include/linux/workqueue.h   Mon Aug  6 
10:48:20 2018(r337376)
@@ -209,6 +209,9 @@ do {
\
 #definedestroy_workqueue(wq) \
linux_destroy_workqueue(wq)
 
+#definecurrent_work() \
+   linux_current_work()
+
 /* prototypes */
 
 extern struct workqueue_struct *system_wq;
@@ -232,5 +235,6 @@ extern bool linux_flush_work(struct work_struct *);
 extern bool linux_flush_delayed_work(struct delayed_work *);
 extern bool linux_work_pending(struct work_struct *);
 extern bool linux_work_busy(struct work_struct *);
+extern struct work_struct *linux_current_work(void);
 
 #endif /* _LINUX_WORKQUEUE_H_ */

Modified: head/sys/compat/linuxkpi/common/src/linux_work.c
==
--- head/sys/compat/linuxkpi/common/src/linux_work.cMon Aug  6 09:22:07 
2018(r337375)
+++ head/sys/compat/linuxkpi/common/src/linux_work.cMon Aug  6 10:48:20 
2018(r337376)
@@ -220,8 +220,9 @@ linux_work_fn(void *context, int pending)
struct work_struct *work;
struct workqueue_struct *wq;
struct work_exec exec;
+   struct task_struct *task;
 
-   linux_set_current(curthread);
+   task = current;
 
/* setup local variables */
work = context;
@@ -240,9 +241,15 @@ linux_work_fn(void *context, int pending)
case WORK_ST_CANCEL:
WQ_EXEC_UNLOCK(wq);
 
+   /* set current work structure */
+   task->work = work;
+
/* call work function */
work->func(work);
 
+   /* set current work structure */
+   task->work = NULL;
+
WQ_EXEC_LOCK(wq);
/* check if unblocked */
if (exec.target != work) {
@@ -577,6 +584,12 @@ linux_init_delayed_work(struct delayed_work *dwork, wo
mtx_init(>timer.mtx, spin_lock_name("lkpi-dwork"), NULL,
MTX_DEF | MTX_NOWITNESS);
callout_init_mtx(>timer.callout, >timer.mtx, 0);
+}
+
+struct work_struct *
+linux_current_work(void)
+{
+   return (current->work);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r337374 - head/sys/compat/linuxkpi/common/include/asm

2018-08-06 Thread Hans Petter Selasky

On 08/06/18 11:33, Mateusz Guzik wrote:

This code is seriously inferior to atomic_fcmpset_long, which happens to
return the found value just like the linux atomic_long_cmpxchg would.

The atomic_cmpset_* primitives should not be used if the target value is to
be inspected.


Hi,

The LinuxKPI has already has few places of atomic_cmpset_* currently.

Can I assume that atomic_fcmpset_* is available for all platforms where 
atomic_cmpset_* is available?


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


Re: svn commit: r337374 - head/sys/compat/linuxkpi/common/include/asm

2018-08-06 Thread Mateusz Guzik
On Mon, Aug 6, 2018 at 10:40 AM Hans Petter Selasky 
wrote:

> Author: hselasky
> Date: Mon Aug  6 08:40:02 2018
> New Revision: 337374
> URL: https://svnweb.freebsd.org/changeset/base/337374
>
> Log:
>   Implement atomic_long_cmpxchg() function in the LinuxKPI.
>
>   Submitted by: Johannes Lundberg 
>   MFC after:1 week
>   Sponsored by: Mellanox Technologies
>
> Modified:
>   head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
>
> Modified: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
>
> ==
> --- head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Aug  6
> 08:35:16 2018(r337373)
> +++ head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Aug  6
> 08:40:02 2018(r337374)
> @@ -81,6 +81,21 @@ atomic_long_xchg(atomic_long_t *v, long val)
> return atomic_swap_long(>counter, val);
>  }
>
> +static inline long
> +atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
> +{
> +   long ret = old;
> +
> +   for (;;) {
> +   if (atomic_cmpset_long(>counter, old, new))
> +   break;
> +   ret = READ_ONCE(v->counter);
> +   if (ret != old)
> +   break;
> +   }
> +   return (ret);
> +}


This code is seriously inferior to atomic_fcmpset_long, which happens to
return the found value just like the linux atomic_long_cmpxchg would.

The atomic_cmpset_* primitives should not be used if the target value is to
be inspected.

+
>  static inline int
>  atomic_long_add_unless(atomic_long_t *v, long a, long u)
>  {
>
>

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


svn commit: r337375 - head/sys/netinet/tcp_stacks

2018-08-06 Thread Randall Stewart
Author: rrs
Date: Mon Aug  6 09:22:07 2018
New Revision: 337375
URL: https://svnweb.freebsd.org/changeset/base/337375

Log:
  This fixes a bug in Rack where we were
  not properly using the correct value for
  Delayed Ack.
  
  Sponsored by: Netflix Inc.
  Differential Revision: https://reviews.freebsd.org/D16579

Modified:
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Mon Aug  6 08:40:02 2018
(r337374)
+++ head/sys/netinet/tcp_stacks/rack.c  Mon Aug  6 09:22:07 2018
(r337375)
@@ -2275,7 +2275,7 @@ rack_start_hpts_timer(struct tcp_rack *rack, struct tc
}
hpts_timeout = rack_timer_start(tp, rack, cts);
if (tp->t_flags & TF_DELACK) {
-   delayed_ack = tcp_delacktime;
+   delayed_ack = TICKS_2_MSEC(tcp_delacktime);
rack->r_ctl.rc_hpts_flags |= PACE_TMR_DELACK;
}
if (delayed_ack && ((hpts_timeout == 0) ||
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337374 - head/sys/compat/linuxkpi/common/include/asm

2018-08-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  6 08:40:02 2018
New Revision: 337374
URL: https://svnweb.freebsd.org/changeset/base/337374

Log:
  Implement atomic_long_cmpxchg() function in the LinuxKPI.
  
  Submitted by: Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/asm/atomic-long.h

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Aug  6 
08:35:16 2018(r337373)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic-long.h   Mon Aug  6 
08:40:02 2018(r337374)
@@ -81,6 +81,21 @@ atomic_long_xchg(atomic_long_t *v, long val)
return atomic_swap_long(>counter, val);
 }
 
+static inline long
+atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
+{
+   long ret = old;
+
+   for (;;) {
+   if (atomic_cmpset_long(>counter, old, new))
+   break;
+   ret = READ_ONCE(v->counter);
+   if (ret != old)
+   break;
+   }
+   return (ret);
+}
+
 static inline int
 atomic_long_add_unless(atomic_long_t *v, long a, long u)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r337373 - head/sys/compat/linuxkpi/common/include/linux

2018-08-06 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  6 08:35:16 2018
New Revision: 337373
URL: https://svnweb.freebsd.org/changeset/base/337373

Log:
  Define __poll_t type in the LinuxKPI.
  
  Submitted by: Johannes Lundberg 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/types.h

Modified: head/sys/compat/linuxkpi/common/include/linux/types.h
==
--- head/sys/compat/linuxkpi/common/include/linux/types.h   Mon Aug  6 
05:36:00 2018(r337372)
+++ head/sys/compat/linuxkpi/common/include/linux/types.h   Mon Aug  6 
08:35:16 2018(r337373)
@@ -59,6 +59,7 @@ typedef uint64_t loff_t;
 typedef vm_paddr_t resource_size_t;
 typedef uint16_t __bitwise__ __sum16;
 typedef unsigned long pgoff_t;
+typedef unsigned __poll_t;
 
 typedef u64 phys_addr_t;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"