Re: svn commit: r363891 - head/sys/kern

2020-08-05 Thread Don Lewis
On  5 Aug, Mateusz Guzik wrote:
> Author: mjg
> Date: Wed Aug  5 09:24:38 2020
> New Revision: 363891
> URL: https://svnweb.freebsd.org/changeset/base/363891
> 
> Log:
>   cache: reduce zone alignment to 8 bytes
>   
>   It used to be sizeof of the given struct to accomodate for 32 bit mips
>   doing 64 bit loads, but the same can be achieved with requireing just
>   64 bit alignment.
>   
>   While here reorder struct namecache so that most commonly used fields
>   are closer.
> 
> Modified:
>   head/sys/kern/vfs_cache.c
> 
> Modified: head/sys/kern/vfs_cache.c
> ==
> --- head/sys/kern/vfs_cache.c Wed Aug  5 09:24:00 2020(r363890)
> +++ head/sys/kern/vfs_cache.c Wed Aug  5 09:24:38 2020(r363891)
> @@ -122,9 +122,9 @@ _Static_assert(sizeof(struct negstate) <= sizeof(struc
>  "the state must fit in a union with a pointer without growing it");
>  
>  struct   namecache {
> - CK_LIST_ENTRY(namecache) nc_hash;/* hash chain */
>   LIST_ENTRY(namecache) nc_src;   /* source vnode list */
>   TAILQ_ENTRY(namecache) nc_dst;  /* destination vnode list */
> + CK_LIST_ENTRY(namecache) nc_hash;/* hash chain */
>   struct  vnode *nc_dvp;  /* vnode of parent of name */
>   union {
>   struct  vnode *nu_vp;   /* vnode the name refers to */
> @@ -142,6 +142,8 @@ structnamecache {
>   * to be stored.  The nc_dotdottime field is used when a cache entry is 
> mapping
>   * both a non-dotdot directory name plus dotdot for the directory's
>   * parent.
> + *
> + * See below for alignment requirement.
>   */
>  struct   namecache_ts {
>   struct  timespec nc_time;   /* timespec provided by fs */
> @@ -150,6 +152,14 @@ struct   namecache_ts {
>   struct namecache nc_nc;
>  };
>  
> +/*
> + * At least mips n32 performs 64-bit accesses to timespec as found
> + * in namecache_ts and requires them to be aligned. Since others
> + * may be in the same spot suffer a little bit and enforce the
> + * alignment for everyone. Note this is a nop for 64-bit platforms.
> + */
> +#define CACHE_ZONE_ALIGNMENT UMA_ALIGNOF(time_t)

time_t is only 32 bits on i386

___
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: r363658 - stable/12

2020-07-28 Thread Don Lewis
Author: truckman
Date: Wed Jul 29 04:36:45 2020
New Revision: 363658
URL: https://svnweb.freebsd.org/changeset/base/363658

Log:
  Make lex a bootstrap tool when cross-building on recent 13-CURRENT if
  binutils/ld is going to be built.  The latter is no longer true by default.
  
  The import of flex 2.6.4 into -CURRENT changed the type of yy_n_chars
  in the lex skeleton from yy_size_t to int, which breaks the build of
  binutils/ld when using the host copy of lex.
  
  ldlex.c:3216:3: error: incompatible pointer types passing 'int *' to parameter
of type 'yy_size_t *' (aka 'unsigned long *')
[-Werror,-Wincompatible-pointer-types]
...YY_INPUT( (_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
   ^
  
  This is a direct commit to stable/12 since binutils/ld has been removed
  from -CURRENT, and it would require a different fix there since the
  bootstrap tool version of lex would also cause breakage.  This is similar
  to the stable/11 change in r363653, but in stable/12 we only need to
  build lex as a bootstrap tool if binutils/ld is going to be built.

Modified:
  stable/12/Makefile.inc1

Modified: stable/12/Makefile.inc1
==
--- stable/12/Makefile.inc1 Wed Jul 29 00:34:24 2020(r363657)
+++ stable/12/Makefile.inc1 Wed Jul 29 04:36:45 2020(r363658)
@@ -2066,10 +2066,15 @@ _vtfontcvt= usr.bin/vtfontcvt
 
 .if ${BOOTSTRAPPING} < 133
 _m4=   usr.bin/m4
-_lex=  usr.bin/lex
 
 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
+.endif
+
+# flex 2.6.4 introduced in 13-CURRRENT r362333 breaks binutils/ld build
+.if ${BOOTSTRAPPING} < 133 || \
+(${BOOTSTRAPPING} > 1300098 && ${MK_LLD_IS_LD} == "no")
+_lex=  usr.bin/lex
 .endif
 
 # r245440 mtree -N support added
___
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: r363653 - stable/11

2020-07-28 Thread Don Lewis
Author: truckman
Date: Tue Jul 28 19:35:24 2020
New Revision: 363653
URL: https://svnweb.freebsd.org/changeset/base/363653

Log:
  Make lex a bootstrap tool when cross-building on recent 13-CURRENT.
  
  The import of flex 2.6.4 into -CURRENT changed the type of yy_n_chars
  in the lex skeleton from yy_size_t to int, which breaks the build of
  binutils/ld when using the host copy of lex.
  
  ldlex.c:3216:3: error: incompatible pointer types passing 'int *' to parameter
of type 'yy_size_t *' (aka 'unsigned long *')
[-Werror,-Wincompatible-pointer-types]
...YY_INPUT( (_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
   ^
  
  This is a direct commit to stable/11 since binutils/ld has been removed
  from -CURRENT, and it would require a different fix there since the
  bootstrap tool version of lex would also cause breakage.

Modified:
  stable/11/Makefile.inc1

Modified: stable/11/Makefile.inc1
==
--- stable/11/Makefile.inc1 Tue Jul 28 17:09:15 2020(r363652)
+++ stable/11/Makefile.inc1 Tue Jul 28 19:35:24 2020(r363653)
@@ -1724,10 +1724,14 @@ _vtfontcvt= usr.bin/vtfontcvt
 .if ${BOOTSTRAPPING} < 133
 _libopenbsd=   lib/libopenbsd
 _m4=   usr.bin/m4
-_lex=  usr.bin/lex
 
 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
+.endif
+
+# flex 2.6.4 introduced in 13-CURRRENT r362333 breaks binutils/ld build
+.if ${BOOTSTRAPPING} < 133 || ${BOOTSTRAPPING} > 1300098
+_lex=  usr.bin/lex
 .endif
 
 # r245440 mtree -N support added
___
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: r363536 - in stable/11: libexec/ftpd usr.bin/localedef usr.sbin/rrenumd

2020-07-25 Thread Don Lewis
Author: truckman
Date: Sat Jul 25 23:08:51 2020
New Revision: 363536
URL: https://svnweb.freebsd.org/changeset/base/363536

Log:
  MFC r362569 (by jkim):
  
  Fix build with recent byacc.
  
  S3curity:

Modified:
  stable/11/libexec/ftpd/ftpcmd.y
  stable/11/usr.bin/localedef/localedef.c
  stable/11/usr.bin/localedef/localedef.h
  stable/11/usr.sbin/rrenumd/parser.y
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/ftpd/ftpcmd.y
==
--- stable/11/libexec/ftpd/ftpcmd.y Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/libexec/ftpd/ftpcmd.y Sat Jul 25 23:08:51 2020
(r363536)
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #include "extern.h"
 #include "pathnames.h"
 
+#defineyylex   ftpcmd_yylex
+
 off_t  restart_point;
 
 static int cmd_type;

Modified: stable/11/usr.bin/localedef/localedef.c
==
--- stable/11/usr.bin/localedef/localedef.c Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.bin/localedef/localedef.c Sat Jul 25 23:08:51 2020
(r363536)
@@ -257,7 +257,9 @@ main(int argc, char **argv)
init_numeric();
init_time();
 
+#if YYDEBUG
yydebug = 0;
+#endif
 
(void) setlocale(LC_ALL, "");
 

Modified: stable/11/usr.bin/localedef/localedef.h
==
--- stable/11/usr.bin/localedef/localedef.h Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.bin/localedef/localedef.h Sat Jul 25 23:08:51 2020
(r363536)
@@ -47,7 +47,9 @@ extern int mb_cur_max;
 extern int mb_cur_min;
 extern int last_kw;
 extern int verbose;
+#if YYDEBUG
 extern int yydebug;
+#endif
 extern int lineno;
 extern int undefok;/* mostly ignore undefined symbols */
 extern int warnok;

Modified: stable/11/usr.sbin/rrenumd/parser.y
==
--- stable/11/usr.sbin/rrenumd/parser.y Sat Jul 25 23:06:47 2020
(r363535)
+++ stable/11/usr.sbin/rrenumd/parser.y Sat Jul 25 23:08:51 2020
(r363536)
@@ -139,7 +139,7 @@ statement:
 debug_statement:
DEBUG_CMD flag EOS
{
-#ifdef YYDEBUG
+#if YYDEBUG
yydebug = $2;
 #endif /* YYDEBUG */
}
___
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: r363535 - in stable/12: libexec/ftpd usr.bin/localedef usr.sbin/rrenumd

2020-07-25 Thread Don Lewis
Author: truckman
Date: Sat Jul 25 23:06:47 2020
New Revision: 363535
URL: https://svnweb.freebsd.org/changeset/base/363535

Log:
  MFC r362569 (by jkim):
  
  Fix build with recent byacc.

Modified:
  stable/12/libexec/ftpd/ftpcmd.y
  stable/12/usr.bin/localedef/localedef.c
  stable/12/usr.bin/localedef/localedef.h
  stable/12/usr.sbin/rrenumd/parser.y
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/ftpd/ftpcmd.y
==
--- stable/12/libexec/ftpd/ftpcmd.y Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/libexec/ftpd/ftpcmd.y Sat Jul 25 23:06:47 2020
(r363535)
@@ -74,6 +74,8 @@ __FBSDID("$FreeBSD$");
 #include "extern.h"
 #include "pathnames.h"
 
+#defineyylex   ftpcmd_yylex
+
 off_t  restart_point;
 
 static int cmd_type;

Modified: stable/12/usr.bin/localedef/localedef.c
==
--- stable/12/usr.bin/localedef/localedef.c Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.bin/localedef/localedef.c Sat Jul 25 23:06:47 2020
(r363535)
@@ -273,7 +273,9 @@ main(int argc, char **argv)
init_numeric();
init_time();
 
+#if YYDEBUG
yydebug = 0;
+#endif
 
(void) setlocale(LC_ALL, "");
 

Modified: stable/12/usr.bin/localedef/localedef.h
==
--- stable/12/usr.bin/localedef/localedef.h Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.bin/localedef/localedef.h Sat Jul 25 23:06:47 2020
(r363535)
@@ -47,7 +47,9 @@ extern int mb_cur_max;
 extern int mb_cur_min;
 extern int last_kw;
 extern int verbose;
+#if YYDEBUG
 extern int yydebug;
+#endif
 extern int lineno;
 extern int undefok;/* mostly ignore undefined symbols */
 extern int warnok;

Modified: stable/12/usr.sbin/rrenumd/parser.y
==
--- stable/12/usr.sbin/rrenumd/parser.y Sat Jul 25 21:37:07 2020
(r363534)
+++ stable/12/usr.sbin/rrenumd/parser.y Sat Jul 25 23:06:47 2020
(r363535)
@@ -141,7 +141,7 @@ statement:
 debug_statement:
DEBUG_CMD flag EOS
{
-#ifdef YYDEBUG
+#if YYDEBUG
yydebug = $2;
 #endif /* YYDEBUG */
}
___
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: r357407 - head

2020-02-04 Thread Don Lewis
On  2 Feb, Warner Losh wrote:
> Author: imp
> Date: Sun Feb  2 11:37:27 2020
> New Revision: 357407
> URL: https://svnweb.freebsd.org/changeset/base/357407
> 
> Log:
>   Per the firm plan, start to remove sparc64
>   
>   The sparc64 architecture is being removed from FreeBSD 13, starting
>   now. This removes it from the top level only. It is the only
>   architecture that didn't see substantial work after the call to get
>   things working with the external toolchain.

Sigh ... I finally got around to fixing the motherboard in my Ultra 10
over the weekend, bad CPU VRM caps.  I'm currently upgrading to a more
recent version of FreeBSD.  It's taking a while since this beast is
really slow.


___
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: r357133 - stable/11/sbin/swapon

2020-01-25 Thread Don Lewis
Author: truckman
Date: Sun Jan 26 01:45:22 2020
New Revision: 357133
URL: https://svnweb.freebsd.org/changeset/base/357133

Log:
  MFC r33
  
  Fix a logic bug in error handling code.  It is an error if p == NULL.
  The linelen tests are only meaningful when p != NULL.
  
  Reported by:  Coverity
  Coverity CID: 1368655

Modified:
  stable/11/sbin/swapon/swapon.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/swapon/swapon.c
==
--- stable/11/sbin/swapon/swapon.c  Sun Jan 26 01:42:47 2020
(r357132)
+++ stable/11/sbin/swapon/swapon.c  Sun Jan 26 01:45:22 2020
(r357133)
@@ -521,7 +521,7 @@ swap_on_off_md(const char *name, char *mntops, int doi
goto err;
}
p = fgetln(sfd, );
-   if (p == NULL &&
+   if (p == NULL ||
(linelen < 2 || linelen > sizeof(linebuf))) {
warn("mdconfig (attach) unexpected output");
ret = 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: r357132 - stable/12/sbin/swapon

2020-01-25 Thread Don Lewis
Author: truckman
Date: Sun Jan 26 01:42:47 2020
New Revision: 357132
URL: https://svnweb.freebsd.org/changeset/base/357132

Log:
  MFC r33
  
  Fix a logic bug in error handling code.  It is an error if p == NULL.
  The linelen tests are only meaningful when p != NULL.
  
  Reported by:  Coverity
  Coverity CID: 1368655

Modified:
  stable/12/sbin/swapon/swapon.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/swapon/swapon.c
==
--- stable/12/sbin/swapon/swapon.c  Sun Jan 26 00:41:38 2020
(r357131)
+++ stable/12/sbin/swapon/swapon.c  Sun Jan 26 01:42:47 2020
(r357132)
@@ -542,7 +542,7 @@ swap_on_off_md(const char *name, char *mntops, int doi
goto err;
}
p = fgetln(sfd, );
-   if (p == NULL &&
+   if (p == NULL ||
(linelen < 2 || linelen > sizeof(linebuf))) {
warn("mdconfig (attach) unexpected output");
ret = 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: r355553 - head/sbin/swapon

2019-12-08 Thread Don Lewis
Author: truckman
Date: Mon Dec  9 07:18:40 2019
New Revision: 33
URL: https://svnweb.freebsd.org/changeset/base/33

Log:
  Fix a logic bug in error handling code.  It is an error if p == NULL.
  The linelen tests are only meaningful when p != NULL.
  
  Reported by:  Coverity
  Coverity CID: 1368655
  MFC after:1 month

Modified:
  head/sbin/swapon/swapon.c

Modified: head/sbin/swapon/swapon.c
==
--- head/sbin/swapon/swapon.c   Mon Dec  9 05:09:46 2019(r32)
+++ head/sbin/swapon/swapon.c   Mon Dec  9 07:18:40 2019(r33)
@@ -542,7 +542,7 @@ swap_on_off_md(const char *name, char *mntops, int doi
goto err;
}
p = fgetln(sfd, );
-   if (p == NULL &&
+   if (p == NULL ||
(linelen < 2 || linelen > sizeof(linebuf))) {
warn("mdconfig (attach) unexpected output");
ret = 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"


Re: svn commit: r349256 - head/libexec/rc/rc.d

2019-06-21 Thread Don Lewis
On 21 Jun, Xin LI wrote:

> But ultimately, I think the real design question here that needs to be
> solved would probably be "Why are piling up multiple layers of workarounds
> around motd? Does it even need to be located in /etc?"  The contents is
> meant to be updated every time when there is a kernel change, and to that
> extent it seems to be more appropriate for /var/run and generated at boot
> from a template located somewhere in /etc.  The benefit of this approach is
> that you would have one less file to merge for each etcupdate/mergemaster
> (or at least only need to do it when some customization is made), and there
> is no need to worry about write durability.

+1

This is something that has bothered me for a long time.  It should be
possible to run with a read-only /etc (obviously with some functional
limitations).

___
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: r339293 - stable/11/sys/net

2018-10-10 Thread Don Lewis
On 10 Oct, John Baldwin wrote:
> Author: jhb
> Date: Wed Oct 10 21:28:04 2018
> New Revision: 339293
> URL: https://svnweb.freebsd.org/changeset/base/339293
> 
> Log:
>   Disable the KASSERT for curcpu == 0 in netisr for EARLY_AP_STARTUP.
>   
>   In the EARLY_AP_STARTUP case, thread0 can migrate to another CPU
>   before this SYSINIT is run.  However, the only part of this SYSINIT
>   that assumes it runs on CPU 0 is in the !EARLY_AP_STARTUP case when it
>   creates the netisr for the boot CPU.  In the EARLY_AP_STARTUP case we
>   start up the netisr's for the first N CPUs during the SYSINIT itself
>   and don't depend on running on the boot CPU for correct operation.
>   
>   This is a direct comit to stable/11 as the assertion was removed as part
>   of a different change in r302595.
>   
>   Reported by:rwatson, truckman, jkim, FreeNAS bug 45611

Thanks!

___
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: r337678 - stable/11/sys/kern

2018-08-11 Thread Don Lewis
Author: truckman
Date: Sun Aug 12 03:22:28 2018
New Revision: 337678
URL: https://svnweb.freebsd.org/changeset/base/337678

Log:
  MFC r336855
  
  Fix the long term ULE load balancer so that it actually works.  The
  initial call to sched_balance() during startup is meant to initialize
  balance_ticks, but does not actually do that since smp_started is
  still zero at that time.  Since balance_ticks does not get set,
  there are no further calls to sched_balance().  Fix this by setting
  balance_ticks in sched_initticks() since we know the value of
  balance_interval at that time, and eliminate the useless startup
  call to sched_balance().  We don't need to randomize the intial
  value of balance_ticks.
  
  Since there is now only one call to sched_balance(), we can hoist
  the tests at the top of this function out to the caller and avoid
  the overhead of the function call when running a SMP kernel on UP
  hardware.
  
  PR:   223914
  Reviewed by:  kib

Modified:
  stable/11/sys/kern/sched_ule.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/sched_ule.c
==
--- stable/11/sys/kern/sched_ule.c  Sun Aug 12 03:15:30 2018
(r337677)
+++ stable/11/sys/kern/sched_ule.c  Sun Aug 12 03:22:28 2018
(r337678)
@@ -882,9 +882,6 @@ sched_balance(void)
 {
struct tdq *tdq;
 
-   if (smp_started == 0 || rebalance == 0)
-   return;
-
balance_ticks = max(balance_interval / 2, 1) +
(sched_random() % balance_interval);
tdq = TDQ_SELF();
@@ -1408,7 +1405,6 @@ sched_setup_smp(void)
panic("Can't find cpu group for %d\n", i);
}
balance_tdq = TDQ_SELF();
-   sched_balance();
 }
 #endif
 
@@ -1469,6 +1465,7 @@ sched_initticks(void *dummy)
 * what realstathz is.
 */
balance_interval = realstathz;
+   balance_ticks = balance_interval;
affinity = SCHED_AFFINITY_DEFAULT;
 #endif
if (sched_idlespinthresh < 0)
@@ -2384,7 +2381,7 @@ sched_clock(struct thread *td)
/*
 * We run the long term load balancer infrequently on the first cpu.
 */
-   if (balance_tdq == tdq) {
+   if (balance_tdq == tdq && smp_started != 0 && rebalance != 0) {
if (balance_ticks && --balance_ticks == 0)
sched_balance();
}
___
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: r336859 - head/sbin/init/rc.d

2018-07-29 Thread Don Lewis
On 29 Jul, Ian Lepore wrote:
> On Sun, 2018-07-29 at 09:59 -0700, Don Lewis wrote:
>> On 29 Jul, Ian Lepore wrote:
>> > On Sun, 2018-07-29 at 05:42 +, Don Lewis wrote:
>> >> Author: truckman
>> >> Date: Sun Jul 29 05:42:07 2018
>> >> New Revision: 336859
>> >> URL: https://svnweb.freebsd.org/changeset/base/336859
>> >> 
>> >> Log:
>> >>   Fix a variable name typo in r336845 that prevented the rc.d scripts
>> >>   from being installed in the correct directory.
>> >>   
>> >>   Resurrect a few rc.d scripts that were prematurely deleted from the
>> >>   Makefile by r336845.
>> >>   
>> >>   Reviewed by:   brd
>> >> 
>> >> Modified:
>> >>   head/sbin/init/rc.d/Makefile
>> >> 
>> >> Modified: head/sbin/init/rc.d/Makefile
>> >> =
>> >> =
>> >> --- head/sbin/init/rc.d/Makefile Sun Jul 29 05:14:26 2018
>> >> (r336858)
>> >> +++ head/sbin/init/rc.d/Makefile Sun Jul 29 05:42:07 2018
>> >> (r336859)
>> >> @@ -2,7 +2,7 @@
>> >>  
>> >>  .include 
>> >>  
>> >> -CONFSDIR=   /etc/rc.d
>> >> +CONFDIR=/etc/rc.d
>> >>  CONFGROUPS= CONFS
>> >>  
>> > 
>> > I'm pretty sure CONFSDIR was right here. You are now trapped in a maze
>> > of small twisty variable names, all alike.
>> 
>> Without this change, the rc.d scripts get installed directly under
>> /var/tmp/temproot/etc/ and mergemaster wants to delete the scripts under
>> /etc/rc.d.  Answering yes to that mergemaster question results in an
>> unbootable system.
>> 
>> I see the following in /usr/share/mk/bsd.confs.mk:
>>   ${group}DIR?=   ${CONFDIR}
>> but I don't see ${CONFSDIR} anywhere.
>> 
> 
> You don't see CONFSDIR because it appears as ${group}DIR and with
> CONFGROUPS?= CONFS that turns into CONFSDIR. So now the question is why
> doesn't setting CONFSDIR work in this makefile, but it works in others?

I don't know, but with undoing my change with this:

Index: sbin/init/rc.d/Makefile
===
--- sbin/init/rc.d/Makefile (revision 336859)
+++ sbin/init/rc.d/Makefile (working copy)
@@ -2,7 +2,7 @@
 
 .include 
 
-CONFDIR=   /etc/rc.d
+CONFSDIR=  /etc/rc.d
 CONFGROUPS=CONFS
 
 CONFS= DAEMON \


gives me this in mergemaster:

*** Beginning comparison

   *** Checking /etc/rc.d for stale files

   *** The following files exist in /etc/rc.d but not in
   /var/tmp/temproot/etc/rc.d/:

 accounting amd apm bsnmpd hastd jail local_unbound power_profile sendmail sshd 
virecover zfs zfsbe zfsd zvol

   The presence of stale files in this directory can cause the
   dreaded unpredictable results, and therefore it is highly
   recommended that you delete them.

   *** Delete them now? [n] 

___
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: r336859 - head/sbin/init/rc.d

2018-07-29 Thread Don Lewis
On 29 Jul, Ian Lepore wrote:
> On Sun, 2018-07-29 at 05:42 +0000, Don Lewis wrote:
>> Author: truckman
>> Date: Sun Jul 29 05:42:07 2018
>> New Revision: 336859
>> URL: https://svnweb.freebsd.org/changeset/base/336859
>> 
>> Log:
>>   Fix a variable name typo in r336845 that prevented the rc.d scripts
>>   from being installed in the correct directory.
>>   
>>   Resurrect a few rc.d scripts that were prematurely deleted from the
>>   Makefile by r336845.
>>   
>>   Reviewed by:   brd
>> 
>> Modified:
>>   head/sbin/init/rc.d/Makefile
>> 
>> Modified: head/sbin/init/rc.d/Makefile
>> =
>> =
>> --- head/sbin/init/rc.d/Makefile Sun Jul 29 05:14:26 2018
>> (r336858)
>> +++ head/sbin/init/rc.d/Makefile Sun Jul 29 05:42:07 2018
>> (r336859)
>> @@ -2,7 +2,7 @@
>>  
>>  .include 
>>  
>> -CONFSDIR=   /etc/rc.d
>> +CONFDIR=/etc/rc.d
>>  CONFGROUPS= CONFS
>>  
> 
> I'm pretty sure CONFSDIR was right here. You are now trapped in a maze
> of small twisty variable names, all alike.

Without this change, the rc.d scripts get installed directly under
/var/tmp/temproot/etc/ and mergemaster wants to delete the scripts under
/etc/rc.d.  Answering yes to that mergemaster question results in an
unbootable system.

I see the following in /usr/share/mk/bsd.confs.mk:
  ${group}DIR?=   ${CONFDIR}
but I don't see ${CONFSDIR} anywhere.

After this commit, mergemaster works properly again.

> CONFGROUPS=CONFS is the default set by bsd.conf.mk, and it's the only
> one that needs CONF to be singular. Perhaps if we establish the idiom
> of not re-specifying the default value in all the individual makefiles,
> that'll leave everything as CONFS* and it'll be a bit less confusing?
> 
> -- Ian

___
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: r336859 - head/sbin/init/rc.d

2018-07-28 Thread Don Lewis
Author: truckman
Date: Sun Jul 29 05:42:07 2018
New Revision: 336859
URL: https://svnweb.freebsd.org/changeset/base/336859

Log:
  Fix a variable name typo in r336845 that prevented the rc.d scripts
  from being installed in the correct directory.
  
  Resurrect a few rc.d scripts that were prematurely deleted from the
  Makefile by r336845.
  
  Reviewed by:  brd

Modified:
  head/sbin/init/rc.d/Makefile

Modified: head/sbin/init/rc.d/Makefile
==
--- head/sbin/init/rc.d/MakefileSun Jul 29 05:14:26 2018
(r336858)
+++ head/sbin/init/rc.d/MakefileSun Jul 29 05:42:07 2018
(r336859)
@@ -2,7 +2,7 @@
 
 .include 
 
-CONFSDIR=  /etc/rc.d
+CONFDIR=   /etc/rc.d
 CONFGROUPS=CONFS
 
 CONFS= DAEMON \
@@ -75,6 +75,7 @@ CONFS=DAEMON \
netif \
netoptions \
netwait \
+   newsyslog \
nfsclient \
nfscbd \
nfsd \
@@ -112,6 +113,8 @@ CONFS=  DAEMON \
stf \
swap \
swaplate \
+   sysctl \
+   syslogd \
tmp \
${_ubthidhci} \
ugidfw \
___
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: r336855 - head/sys/kern

2018-07-28 Thread Don Lewis
Author: truckman
Date: Sun Jul 29 00:30:06 2018
New Revision: 336855
URL: https://svnweb.freebsd.org/changeset/base/336855

Log:
  Fix the long term ULE load balancer so that it actually works.  The
  initial call to sched_balance() during startup is meant to initialize
  balance_ticks, but does not actually do that since smp_started is
  still zero at that time.  Since balance_ticks does not get set,
  there are no further calls to sched_balance().  Fix this by setting
  balance_ticks in sched_initticks() since we know the value of
  balance_interval at that time, and eliminate the useless startup
  call to sched_balance().  We don't need to randomize the intial
  value of balance_ticks.
  
  Since there is now only one call to sched_balance(), we can hoist
  the tests at the top of this function out to the caller and avoid
  the overhead of the function call when running a SMP kernel on UP
  hardware.
  
  PR:   223914
  Reviewed by:  kib
  MFC after:2 weeks

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Sun Jul 29 00:12:16 2018(r336854)
+++ head/sys/kern/sched_ule.c   Sun Jul 29 00:30:06 2018(r336855)
@@ -884,9 +884,6 @@ sched_balance(void)
 {
struct tdq *tdq;
 
-   if (smp_started == 0 || rebalance == 0)
-   return;
-
balance_ticks = max(balance_interval / 2, 1) +
(sched_random() % balance_interval);
tdq = TDQ_SELF();
@@ -1413,7 +1410,6 @@ sched_setup_smp(void)
panic("Can't find cpu group for %d\n", i);
}
balance_tdq = TDQ_SELF();
-   sched_balance();
 }
 #endif
 
@@ -1474,6 +1470,7 @@ sched_initticks(void *dummy)
 * what realstathz is.
 */
balance_interval = realstathz;
+   balance_ticks = balance_interval;
affinity = SCHED_AFFINITY_DEFAULT;
 #endif
if (sched_idlespinthresh < 0)
@@ -2382,7 +2379,7 @@ sched_clock(struct thread *td)
/*
 * We run the long term load balancer infrequently on the first cpu.
 */
-   if (balance_tdq == tdq) {
+   if (balance_tdq == tdq && smp_started != 0 && rebalance != 0) {
if (balance_ticks && --balance_ticks == 0)
sched_balance();
}
___
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: r336025 - in head/sys: amd64/include i386/include

2018-07-06 Thread Don Lewis
On  7 Jul, Alexey Dokuchaev wrote:
> On Fri, Jul 06, 2018 at 05:06:03PM -0700, Don Lewis wrote:
>> The other machine is my Pentium-M laptop, which is mostly used for light
>> browsing and as a VNC client when I'm on the road.  Performance is
>> acceptable for those uses.  Both machines run stripped down UP kernels to
>> avoid wasting RAM unnecessarily and to optimize CPU cycles on the laptop.
>> 
>> [...] I've managed to commit changes that break UP builds and not known
>> it until I received reports of broken builds from other users.
> 
> :-) That's funny: you run custom UP kernels, and yet managed to break UP
> builds with the breakage being unknown to you until you received reports
> from other users, lol.

Yeah, definitely ironic ...

The Via machine basically only gets security updates.   With only 256 MB
of RAM, it's probably too wimpy to self-host, and I hate to think about
how long buildworld would take.  I cross build releases on a more modern
machine and use a custom freebsd-update to keep it up to date, with
itself is a PITA. I think packaged base would be less of a hassle.

The laptop gets more frequent updates and is able to self-host.  Doing
buildworld + buildkernel takes a really long time.  It looks like my
last buildworld (11-STABLE) took nearly 14 hours.  This was my fastest
machine for quite a while.  I'm planning on doing an update this weekend
in preparation for an upcoming trip.

> On a related note, did you measure how much (e.g. in terms of battery
> life) your laptop gains from using the UP kernel?  Could you also share
> your config?  I'm using Pentium-M laptop as my primary machine as well,
> and always eager to squeeze something more out of it.  Thanks,

I don't have any data for battery life.  Almost all of my usage is with
line power.

Config file:
include GENERIC

nooptions   SMP

nodeviceahci
nodevicemvs
nodevicesiis
nodeviceahc
nodeviceahd
nodeviceesp
nodevicehptiop
nodeviceisp
nodevicempt
nodevicemps
nodevicempr
nodevicencr
nodevicesym
nodevicetrm
nodeviceadv
nodeviceadw
nodeviceaha
nodeviceaic
nodevicebt
nodevicencv
nodevicensp
nodevicestg
nodeviceisci
nodevicech
nodeviceses
nodevicectl
nodeviceamr
nodevicearcmsr
nodeviceasr
nodeviceciss
nodevicedpt
nodevicehptmv
nodevicehptnr
nodevicehptrr
nodevicehpt27xx
nodeviceiir
nodeviceips
nodevicemly
nodevicetwa
nodevicetws
nodeviceaac
nodeviceaacp
nodeviceaacraid
nodeviceida
nodevicemfi
nodevicemlx
nodevicemrsas
nodevicepmspcv
nodevicepst
nodevicetwe
nodevicenvme
nodevicenvd
nodevicepuc
nodevicebxe
nodevicede
nodeviceem
nodeviceigb
nodeviceixgb
nodevicele
nodeviceti
nodevicetxp
nodevicevx
nodeviceae
nodeviceage
nodevicealc
nodeviceale
nodevicebce
nodevicebfe
nodevicebge
nodevicecas
nodevicedc
nodeviceet
nodevicegem
nodevicehme
nodevicejme
nodevicelge
nodevicemsk
nodevicenge
nodevicenve
nodevicepcn
nodevicesf
nodevicesge
nodevicesis
nodevicesk
nodeviceste
nodevicestge
nodevicetl
nodevicetx
nodevicevge
nodevicevr
nodevicevte
nodevicewb
nodevicexl
nodevicecs
nodeviceed
nodeviceex
nodeviceep
nodevicefe
nodeviceie
nodevicesn
nodevicexe
nodevicebwi
nodevicebwn
nodeviceipw
nodeviceiwi
nodeviceiwn
nodevicemalo
nodevicemwl
nodeviceral
nodevicewi
nodevicewpi
nodevicevirtio
nodevicevirtio_pci
nodevicevtnet
nodevicevirtio_blk
nodevicevirtio_scsi
nodevicevirtio_balloon
nooptions   HYPERV
nodevicehyperv
nooptions   XENHVM
nodevicexenpci
nodevicevmx

___
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: r336025 - in head/sys: amd64/include i386/include

2018-07-06 Thread Don Lewis
On  6 Jul, Warner Losh wrote:
> On Fri, Jul 6, 2018 at 6:06 PM, Don Lewis  wrote:
> 
>> On  6 Jul, Warner Losh wrote:
>> > On Fri, Jul 6, 2018 at 9:32 AM, Rodney W. Grimes <
>> > free...@pdx.rh.cn85.dnsmgr.net> wrote:
>> >
>> >> > Author: hselasky
>> >> > Date: Fri Jul  6 10:13:42 2018
>> >> > New Revision: 336025
>> >> > URL: https://svnweb.freebsd.org/changeset/base/336025
>> >> >
>> >> > Log:
>> >> >   Make sure kernel modules built by default are portable between UP
>> and
>> >> >   SMP systems by extending defined(SMP) to include
>> defined(KLD_MODULE).
>> >> >
>> >> >   This is a regression issue after r335873 .
>> >> >
>> >> >   Discussed with: mmacy@
>> >> >   Sponsored by:   Mellanox Technologies
>> >>
>> >> Though this fixes the issue, it also means that now when
>> >> anyone intentionally builds a UP kernel with modules
>> >> they are getting SMP support in the modules and I am
>> >> not sure they would want that.  I know I don't.
>> >>
>> >
>> >
>> > On UP systems, these additional opcodes are harmless. They take a few
>> extra
>> > cycles (since they lock an uncontested bus) and add a couple extra memory
>> > barriers (which will be NOPs). On MP systems, atomics now work by
>> default.
>> > Had we not defaulted like this, all modules built outside of a kernel
>> build
>> > env would have broken atomics. Given that (a) the overwhelming majority
>> > (99% or more) is SMP and (b) the MP code merely adds a few cycles to
>> what's
>> > already a not-too-expensive operation, this was the right choice.
>> >
>> > It simply doesn't matter for systems that are relevant to the project
>> > today. While one could try to optimize this a little (for example, by
>> > having SMP defined to be 0 or 1, say, and changing all the ifdef SMP to
>> if
>> > (defined(SMP) && SMP != 0)), it's likely not going to matter enough for
>> > anybody to make the effort. UP on x86 is simply not relevant enough to
>> > optimize for it. Even in VMs, people run SMP kernels typically even when
>> > they just allocate one CPU to the VM.
>> >
>> > So while we still support the UP config, and we'll let people build
>> > optimized kernels for x86, we've flipped the switch from pessimized for
>> SMP
>> > modules to pessimized for UP modules, which seems like quite the
>> reasonable
>> > trade-off.
>> >
>> > Were it practical to do so, I'd suggest de-orbiting UP on x86. However,
>> > it's a lot of work for not much benefit and we'd need to invent much
>> crazy
>> > to get there.
>>
>> I would distinguish i386 from amd64 here.  SMP is pretty rare and exotic
>> in the i386 world
> 
> 
> I don't know I'd say that. There's been MP systems widely available since
> Pentium Pro days. They aren't in laptops, but they were fairly common in
> i386 land since the mid 90's, especially in server class machines. Not
> cheap, but not too pricy as to be uncommon

Back in the mid-90's to early 00's I was running a fairly large
collection of i386-class FreeBSD servers, starting with Pentium CPUs
which were mostly replaced by Pentium III's by the end.  They used
desktop motherboards and were all UP.   They were stacked on shelves in
our raised-floor computer room next to the VAX, so I consider them
servers. We stopped at FreeBSD 4.x, so SMP would not have been that
great anyway.

The Pentium III motherboard that I purchased required the use of special
Pentium III CPU chips.  They were hard to find on Ebay as I recall.

What is kind of funny is that the workloads I was running back in those
days were mostly I/O bound.  Now that CPUs have gotten so much faster
and CPUs have grown so many cores, my workloads are now mostly CPU
limited.
  
___
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: r336025 - in head/sys: amd64/include i386/include

2018-07-06 Thread Don Lewis
On  6 Jul, Warner Losh wrote:
> On Fri, Jul 6, 2018 at 9:32 AM, Rodney W. Grimes <
> free...@pdx.rh.cn85.dnsmgr.net> wrote:
> 
>> > Author: hselasky
>> > Date: Fri Jul  6 10:13:42 2018
>> > New Revision: 336025
>> > URL: https://svnweb.freebsd.org/changeset/base/336025
>> >
>> > Log:
>> >   Make sure kernel modules built by default are portable between UP and
>> >   SMP systems by extending defined(SMP) to include defined(KLD_MODULE).
>> >
>> >   This is a regression issue after r335873 .
>> >
>> >   Discussed with: mmacy@
>> >   Sponsored by:   Mellanox Technologies
>>
>> Though this fixes the issue, it also means that now when
>> anyone intentionally builds a UP kernel with modules
>> they are getting SMP support in the modules and I am
>> not sure they would want that.  I know I don't.
>>
> 
> 
> On UP systems, these additional opcodes are harmless. They take a few extra
> cycles (since they lock an uncontested bus) and add a couple extra memory
> barriers (which will be NOPs). On MP systems, atomics now work by default.
> Had we not defaulted like this, all modules built outside of a kernel build
> env would have broken atomics. Given that (a) the overwhelming majority
> (99% or more) is SMP and (b) the MP code merely adds a few cycles to what's
> already a not-too-expensive operation, this was the right choice.
> 
> It simply doesn't matter for systems that are relevant to the project
> today. While one could try to optimize this a little (for example, by
> having SMP defined to be 0 or 1, say, and changing all the ifdef SMP to if
> (defined(SMP) && SMP != 0)), it's likely not going to matter enough for
> anybody to make the effort. UP on x86 is simply not relevant enough to
> optimize for it. Even in VMs, people run SMP kernels typically even when
> they just allocate one CPU to the VM.
> 
> So while we still support the UP config, and we'll let people build
> optimized kernels for x86, we've flipped the switch from pessimized for SMP
> modules to pessimized for UP modules, which seems like quite the reasonable
> trade-off.
> 
> Were it practical to do so, I'd suggest de-orbiting UP on x86. However,
> it's a lot of work for not much benefit and we'd need to invent much crazy
> to get there.

I would distinguish i386 from amd64 here.  SMP is pretty rare and exotic
in the i386 world.  I do have one dual socket Pentium 3 machine here and
even though I bought the parts for it used on eBay, it was still pretty
pricey.  That purchase was kind of a waste since it was shortly before
the Athlon 64 X2 CPUs were released.

I still have two viable 32-bit x86 machines here that get frequent
usage.  One runs 24x7 and has a Via C3 CPU.  I started looking at
migrating off this hardware.  To get lower power consumption as well as
ECC RAM I'd probably have to go with one of the Supermicro Atom boards.
Those are pretty expensive, so I'd probably end up spending about half
as much as what it cost to put together my fully-loaded Ryzen machine
last summer.  At that price, the payback time from the power savings is
really long.  This machine is mostly idle, so I really don't need more
CPU power or RAM.  The other machine is my Pentium-M laptop, which is
mostly used for light browsing and as a vnc client when I'm on the road.
Performance is acceptable for those uses.  Both machines run stripped
down UP kernels to avoid wasting RAM unnecessarily and to optimize CPU
cycles on the laptop.

A good reason for continuing UP support on x86 is to make it easy to
test UP builds in the MI parts of the kernel so that we don't break
things for the embedded architectures.  Unfortunately "make universe"
currently doesn't have any UP kernels, so I've managed to commit changes
that break UP builds and not known it until I received reports of broken
builds from other users.

___
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: r334543 - head/usr.bin/top

2018-06-03 Thread Don Lewis
On  2 Jun, Rodney W. Grimes wrote:
>> Author: eadler
>> Date: Sat Jun  2 22:06:27 2018
>> New Revision: 334543
>> URL: https://svnweb.freebsd.org/changeset/base/334543
>> 
>> Log:
>>   top(1): chdir to / as init; remove unneeded comment
>>   
>>   - chdir to / to allow unmounting of wd
>>   - remove warning about running top(1) as setuid. If this is a concern we
>>   should just drop privs instead.
>> 
>> Modified:
>>   head/usr.bin/top/machine.c
>>   head/usr.bin/top/top.c
>> 
>> Modified: head/usr.bin/top/machine.c
>> ==
>> --- head/usr.bin/top/machine.c   Sat Jun  2 21:50:00 2018
>> (r334542)
>> +++ head/usr.bin/top/machine.c   Sat Jun  2 22:06:27 2018
>> (r334543)
>> @@ -1613,11 +1613,6 @@ compare_ivcsw(const void *arg1, const void *arg2)
>>  /*
>>   * proc_owner(pid) - returns the uid that owns process "pid", or -1 if
>>   *  the process does not exist.
>> - *  It is EXTREMELY IMPORTANT that this function work correctly.
>> - *  If top runs setuid root (as in SVR4), then this function
>> - *  is the only thing that stands in the way of a serious
>> - *  security problem.  It validates requests for the "kill"
>> - *  and "renice" commands.
>>   */
>>  
>>  int
>> 
>> Modified: head/usr.bin/top/top.c
>> ==
>> --- head/usr.bin/top/top.c   Sat Jun  2 21:50:00 2018(r334542)
>> +++ head/usr.bin/top/top.c   Sat Jun  2 22:06:27 2018(r334543)
>> @@ -260,6 +260,15 @@ main(int argc, char *argv[])
>>  #define CMD_order   26
>>  #define CMD_pid 27
>>  
>> +/*
>> + * Since top(1) is often long running and
>> + * doesn't typically care about where its running from
>> + * chdir to the root to allow unmounting of its
>> + * originall wd. Failure is alright as this is
>> + * just a courtesy for users.
>> + */
>> +chdir("/");
>> +
> 
> Bad side effect of doing that is it is not hard to get a "core"
> from top when run as a user, as it is going to try to write
> to /, and it probably does not have permission for that.
> 
> Better might be a cd to /tmp, or /var/tmp, which are usually
> hard to unmount for these reasons anyway.

Unless you start top using the exec shell builtin, the shell that you
use to launch top will also be long running and will also prevent its
$cwd from being unmounted.

If you do use exec, then you will get logged out when you kill top ...



___
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: r331541 - stable/11/sys/kern

2018-03-25 Thread Don Lewis
Author: truckman
Date: Mon Mar 26 04:41:23 2018
New Revision: 331541
URL: https://svnweb.freebsd.org/changeset/base/331541

Log:
  MFC r329844
  MFC r329875 (by kib)
  
  r329844 | truckman | 2018-02-22 16:12:51 -0800 (Thu, 22 Feb 2018) | 52 lines
  
  Decrease latency by not wrapping the idle loop's potentially lengthy
  search for a thread to steal inside a critical section.  Since this
  allows the search to be preempted, restart the search if preemption
  happens since the search results found earlier may no longer be
  valid.
  
  Decrease the latency of starting a thread that may be assigned to
  this CPU during the search by polling for incoming threads during
  the search and switching to that thread instead of continuing the
  search.
  
  Test for stale search results and restart the search before going
  through the expense of calling tdq_lock_pair().  Retry some tests
  after grabbing the locks since things may have changed while waiting
  to get both locks.
  
  Eliminate special case handling for stealing from an SMT peer that
  uses 1 as the steal threshold.  This can only succeed if a thread
  has been assigned but our SMT peer has not yet started executing
  it.  This is quite rare and when it happens the other SMT thread
  is generally waiting for the same tdq lock that we hold.  Basically
  both SMT threads are racing to grab the same spin lock.
  
  Add the kern.sched.always_steal knob from a ULE patch by jeff@.
  
  Incorporate another idea from Jeff's ULE patch.  If the sched_switch()
  detects that the CPU is about to go idle, try to steal a thread
  before switching to the idle thread.  Since the search for a thread
  to steal has to be done inside a critical section in this context,
  limit the impact on latency by adding the knob kern.sched.trysteal_limit
  to limit the topological distance of the search and don't restart
  the search if we detect stale results.  If this search can't find
  an stealable thread, the idle loop can do a more complete search.
  Also poll for threads being assigned to this CPU during the search
  and switch to them instead of continuing the search.  This change
  is responsibile for the majority of the improvement in parallel
  buildworld times.
  
  In sched_balance_group() change the minimum threshold from stealing
  a thread from 1 to 2.  Poaching a newly assigned thread from a CPU
  that is waking up hasn't yet switched to that thread from idle is
  likely very rare and is likely to have the same lock race as is
  seen when stealing threads in the idle loop.  Also use tdq_notify()
  to kick the destintation CPU instead of always sending an IPI.
  Update a stale comment, the number of transferable threads is not
  calculated.
  
  
  r329875 | kib | 2018-02-23 10:26:31 -0800 (Fri, 23 Feb 2018) | 5 lines
  
  Restore UP build.
  
  Reviewed by:  kib (earlier version, r329844)
  Reviewed by:  truckman (r329875)
  Comments by:  avg, jeff, mav (r329844)
  Differential Revision:https://reviews.freebsd.org/D12130

Modified:
  stable/11/sys/kern/sched_ule.c

Modified: stable/11/sys/kern/sched_ule.c
==
--- stable/11/sys/kern/sched_ule.c  Mon Mar 26 00:30:46 2018
(r331540)
+++ stable/11/sys/kern/sched_ule.c  Mon Mar 26 04:41:23 2018
(r331541)
@@ -238,9 +238,9 @@ struct tdq {
volatile inttdq_load;   /* Aggregate load. */
volatile inttdq_cpu_idle;   /* cpu_idle() is active. */
int tdq_sysload;/* For loadavg, !ITHD load. */
-   int tdq_transferable;   /* Transferable thread count. */
-   short   tdq_switchcnt;  /* Switches this tick. */
-   short   tdq_oldswitchcnt;   /* Switches last tick. */
+   volatile inttdq_transferable;   /* Transferable thread count. */
+   volatile short  tdq_switchcnt;  /* Switches this tick. */
+   volatile short  tdq_oldswitchcnt;   /* Switches last tick. */
u_char  tdq_lowpri; /* Lowest priority thread. */
u_char  tdq_ipipending; /* IPI pending. */
u_char  tdq_idx;/* Current insert index. */
@@ -272,6 +272,8 @@ static int balance_interval = 128;  /* Default set in s
 static int affinity;
 static int steal_idle = 1;
 static int steal_thresh = 2;
+static int always_steal = 0;
+static int trysteal_limit = 2;
 
 /*
  * One thread queue per processor.
@@ -317,7 +319,7 @@ void tdq_print(int cpu);
 static void runq_print(struct runq *rq);
 static void tdq_add(struct tdq *, struct thread *, int);
 #ifdef SMP
-static int tdq_move(struct tdq *, struct tdq *);
+static struct thread *tdq_move(struct tdq *, struct tdq *);
 static int tdq_idled(struct tdq *);
 static void tdq_notify(struct tdq *, struct thread *);
 static 

Re: svn commit: r329875 - head/sys/kern

2018-02-23 Thread Don Lewis
On 23 Feb, Rick Macklem wrote:
> Konstantin Belousov wrote:
>>Author: kib
>>Date: Fri Feb 23 18:26:31 2018
>>New Revision: 329875
>>URL: https://svnweb.freebsd.org/changeset/base/329875
>>
>>Log:
>>  Restore UP build.
>>
>>  Reviewed by:  truckman
>>  Sponsored by: The FreeBSD Foundation
>>
>>Modified:
>>  head/sys/kern/sched_ule.c
>>
>>Modified: head/sys/kern/sched_ule.c
>>==
>>--- head/sys/kern/sched_ule.c   Fri Feb 23 18:18:42 2018(r329874)
>>+++ head/sys/kern/sched_ule.c   Fri Feb 23 18:26:31 2018(r329875)
>>@@ -1864,6 +1864,7 @@ sched_lend_user_prio(struct thread *td, u_char prio)
>>td->td_flags |= TDF_NEEDRESCHED;
>> }
>>
>>+#ifdef SMP
>> /*
>>  * This tdq is about to idle.  Try to steal a thread from another CPU before
>>  * choosing the idle thread.
>>@@ -1945,6 +1946,7 @@ tdq_trysteal(struct tdq *tdq)
>>}
>>spinlock_exit();
>  >}
>>+#endif
>>
>> /*
>>  * Handle migration from sched_switch().  This happens only for
>>@@ -2058,8 +2060,10 @@ sched_switch(struct thread *td, struct thread *newtd,
>>TDQ_LOCK(tdq);
>>mtx = thread_lock_block(td);
>>tdq_load_rem(tdq, td);
>>+#ifdef SMP
>>if (tdq->tdq_load == 0)
> Since the function isn't called for UP, should this "if" also check for ncpus 
> > 1 by any chance?
> (I know nothing about ULE, so please ignore this if it doesn't make sense;-)
>>tdq_trysteal(tdq);
>>+#endif
>>}
>>
>> #if (KTR_COMPILE & KTR_SCHED) != 0

That would probably be a microoptimization.  I think one of the tests at
the top of tdq_trysteal() will cause an immediate return.  Basically
you'd be eliminating an extraneous function call in the path to
switching to the idle thread after you have already determined that you
don't have any work to do.

___
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: r329844 - head/sys/kern

2018-02-22 Thread Don Lewis
Author: truckman
Date: Fri Feb 23 00:12:51 2018
New Revision: 329844
URL: https://svnweb.freebsd.org/changeset/base/329844

Log:
  Decrease latency by not wrapping the idle loop's potentially lengthy
  search for a thread to steal inside a critical section.  Since this
  allows the search to be preempted, restart the search if preemption
  happens since the search results found earlier may no longer be
  valid.
  
  Decrease the latency of starting a thread that may be assigned to
  this CPU during the search by polling for incoming threads during
  the search and switching to that thread instead of continuing the
  search.
  
  Test for stale search results and restart the search before going
  through the expense of calling tdq_lock_pair().  Retry some tests
  after grabbing the locks since things may have changed while waiting
  to get both locks.
  
  Eliminate special case handling for stealing from an SMT peer that
  uses 1 as the steal threshold.  This can only succeed if a thread
  has been assigned but our SMT peer has not yet started executing
  it.  This is quite rare and when it happens the other SMT thread
  is generally waiting for the same tdq lock that we hold.  Basically
  both SMT threads are racing to grab the same spin lock.
  
  Add the kern.sched.always_steal knob from a ULE patch by jeff@.
  
  Incorporate another idea from Jeff's ULE patch.  If the sched_switch()
  detects that the CPU is about to go idle, try to steal a thread
  before switching to the idle thread.  Since the search for a thread
  to steal has to be done inside a critical section in this context,
  limit the impact on latency by adding the knob kern.sched.trysteal_limit
  to limit the topological distance of the search and don't restart
  the search if we detect stale results.  If this search can't find
  an stealable thread, the idle loop can do a more complete search.
  Also poll for threads being assigned to this CPU during the search
  and switch to them instead of continuing the search.  This change
  is responsibile for the majority of the improvement in parallel
  buildworld times.
  
  In sched_balance_group() change the minimum threshold from stealing
  a thread from 1 to 2.  Poaching a newly assigned thread from a CPU
  that is waking up hasn't yet switched to that thread from idle is
  likely very rare and is likely to have the same lock race as is
  seen when stealing threads in the idle loop.  Also use tdq_notify()
  to kick the destintation CPU instead of always sending an IPI.
  Update a stale comment, the number of transferable threads is not
  calculated.
  
  Reviewed by:  kib (earlier version)
  Comments by:  avg, jeff, mav
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D12130

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Thu Feb 22 23:18:46 2018(r329843)
+++ head/sys/kern/sched_ule.c   Fri Feb 23 00:12:51 2018(r329844)
@@ -240,9 +240,9 @@ struct tdq {
volatile inttdq_load;   /* Aggregate load. */
volatile inttdq_cpu_idle;   /* cpu_idle() is active. */
int tdq_sysload;/* For loadavg, !ITHD load. */
-   int tdq_transferable;   /* Transferable thread count. */
-   short   tdq_switchcnt;  /* Switches this tick. */
-   short   tdq_oldswitchcnt;   /* Switches last tick. */
+   volatile inttdq_transferable;   /* Transferable thread count. */
+   volatile short  tdq_switchcnt;  /* Switches this tick. */
+   volatile short  tdq_oldswitchcnt;   /* Switches last tick. */
u_char  tdq_lowpri; /* Lowest priority thread. */
u_char  tdq_ipipending; /* IPI pending. */
u_char  tdq_idx;/* Current insert index. */
@@ -274,6 +274,8 @@ static int balance_interval = 128;  /* Default set in s
 static int affinity;
 static int steal_idle = 1;
 static int steal_thresh = 2;
+static int always_steal = 0;
+static int trysteal_limit = 2;
 
 /*
  * One thread queue per processor.
@@ -319,7 +321,7 @@ void tdq_print(int cpu);
 static void runq_print(struct runq *rq);
 static void tdq_add(struct tdq *, struct thread *, int);
 #ifdef SMP
-static int tdq_move(struct tdq *, struct tdq *);
+static struct thread *tdq_move(struct tdq *, struct tdq *);
 static int tdq_idled(struct tdq *);
 static void tdq_notify(struct tdq *, struct thread *);
 static struct thread *tdq_steal(struct tdq *, int);
@@ -841,7 +843,7 @@ sched_balance_group(struct cpu_group *cg)
 
CPU_FILL();
for (;;) {
-   high = sched_highest(cg, hmask, 1);
+   high = sched_highest(cg, hmask, 2);
/* Stop if there is no more CPU with transferrable threads. */
if (high 

svn commit: r329767 - in stable/11: share/man/man4 stand/forth sys/amd64/conf sys/conf sys/dev/amdsmn sys/dev/amdtemp sys/modules sys/modules/amdsmn

2018-02-21 Thread Don Lewis
Author: truckman
Date: Thu Feb 22 00:36:12 2018
New Revision: 329767
URL: https://svnweb.freebsd.org/changeset/base/329767

Log:
  MFC r323067, r323184, r323185, r323195, r323196 (by cem)
  
  
  r323067 | cem | 2017-08-31 11:39:18 -0700 (Thu, 31 Aug 2017) | 4 lines
  
  amdtemp.4: Update BKDG URL to current location
  
  Sponsored by: Dell EMC Isilon
  
  
  r323184 | cem | 2017-09-05 08:13:41 -0700 (Tue, 05 Sep 2017) | 10 lines
  
  Add smn(4) driver for AMD System Management Network
  
  AMD Family 17h CPUs have an internal network used to communicate between
  the host CPU and the PSP and SMU coprocessors.  It exposes a simple
  32-bit register space.
  
  Reviewed by:  avg (no +1), mjoras, truckman
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12217
  
  
  r323185 | cem | 2017-09-05 08:19:14 -0700 (Tue, 05 Sep 2017) | 13 lines
  
  amdtemp(4): Add support for Family 17h temperature sensor
  
  The sensor value is formatted similarly to previous models (same
  bitfield sizes, same units), but must be read off of the internal
  System Management Network (SMN) from the System Management Unit (SMU)
  co-processor.
  
  PR:   218264
  Reported and tested by:   Nils Beyer 
  Reviewed by:  avg (no +1), mjoras, truckman
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12217
  
  
  r323195 | cem | 2017-09-05 13:35:25 -0700 (Tue, 05 Sep 2017) | 8 lines
  
  amdtemp(4): Do not probe not matching hostbridges
  
  Some systems have hostbs that do not match our PCI device id criteria.
  Detect and ignore these devices in probe.
  
  PR:   218264
  Sponsored by: Dell EMC Isilon
  
  
  r323196 | cem | 2017-09-05 14:00:33 -0700 (Tue, 05 Sep 2017) | 8 lines
  
  amdsmn(4): Do not probe not matching hostbridges
  
  Similar to r323195, but for amdsmn(4) driver (which borrowed some design).
  
  Ignore hostbs that do not match our PCI device id criteria.
  
  Sponsored by: Dell EMC Isilon
  
  PR:   218264
  Differential Revision:https://reviews.freebsd.org/D12217

Added:
  stable/11/share/man/man4/amdsmn.4
 - copied unchanged from r323184, head/share/man/man4/amdsmn.4
  stable/11/sys/dev/amdsmn/
 - copied from r323184, head/sys/dev/amdsmn/
  stable/11/sys/modules/amdsmn/
 - copied from r323184, head/sys/modules/amdsmn/
Modified:
  stable/11/share/man/man4/Makefile
  stable/11/share/man/man4/amdtemp.4
  stable/11/stand/forth/loader.conf
  stable/11/sys/amd64/conf/NOTES
  stable/11/sys/conf/files.amd64
  stable/11/sys/conf/files.i386
  stable/11/sys/dev/amdsmn/amdsmn.c
  stable/11/sys/dev/amdtemp/amdtemp.c
  stable/11/sys/modules/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/Makefile
==
--- stable/11/share/man/man4/Makefile   Thu Feb 22 00:09:15 2018
(r329766)
+++ stable/11/share/man/man4/Makefile   Thu Feb 22 00:36:12 2018
(r329767)
@@ -46,6 +46,7 @@ MAN=  aac.4 \
amdpm.4 \
${_amdsbwd.4} \
${_amdsmb.4} \
+   ${_amdsmn.4} \
${_amdtemp.4} \
${_bxe.4} \
amr.4 \
@@ -792,6 +793,7 @@ _attimer.4= attimer.4
 _aibs.4=   aibs.4
 _amdsbwd.4=amdsbwd.4
 _amdsmb.4= amdsmb.4
+_amdsmn.4= amdsmn.4
 _amdtemp.4=amdtemp.4
 _asmc.4=   asmc.4
 _bxe.4=bxe.4

Copied: stable/11/share/man/man4/amdsmn.4 (from r323184, 
head/share/man/man4/amdsmn.4)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/share/man/man4/amdsmn.4   Thu Feb 22 00:36:12 2018
(r329767, copy of r323184, head/share/man/man4/amdsmn.4)
@@ -0,0 +1,64 @@
+.\"-
+.\" Copyright (c) 2017 Conrad Meyer 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES 

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Don Lewis
On 19 Jan, Conrad Meyer wrote:
> On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes
>  wrote:
>> If you think in assembler it is easy to understand why this is UB,
>> most (all) architectures Right Logic or Arithmetic Shift only accept an
>> operand that is a size that can hold log2(wordsize).
> 
> This is a logical right shift by a constant larger than the width of
> the left operand.  As a result, it would a constant zero in any
> emitted machine code.  It is a bug in the C standard and a concession
> to naive, non-optimizing compilers that this is considered UB.

Generating one answer when compiler knows that everything is constant
and can figure out the "correct" value at compile time, but generating
an entirely different answer when the shift value is still constant, but
passed in as a function parameter and hides that information from the
compiler so the result is generated at runtime sounds like a good way to
introduce bugs.

___
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: r328159 - head/sys/modules

2018-01-19 Thread Don Lewis
On 19 Jan, David Chisnall wrote:
> On 19 Jan 2018, at 05:07, Conrad Meyer  wrote:
>> 
>> The spec says the behavior is undefined; not that the compiler has to
>> produce a warning or error message.  The compiler *does* get to
>> arbitrarily decide what it wants to do when it encounters UB.  It is
>> wholly free to implement this particular UB with the logical result
>> and no warning/error.
> 
> First, you are not correct that the only logical outcome of a shift of
> greater than the width of a type is 0.  In C, a right-shift of a
> signed type propagates the sign bit.  Right shifting a negative 32-bit
> int by 16 and then again by 16 is not undefined behaviour (though
> doing the shift as a single operation is) and will give you a value of
> -1.

Propagating the sign when doing a right shift is the common behaviour,
but I believe this is actually implemenation defined.  If the machine
doesn't have arithmetic shift instructions, then a logical shift which
fills in zeros on the left is also conformant.  See the edit to the
first answer here:
  
https://stackoverflow.com/questions/1857928/right-shifting-negative-numbers-in-c
I think powerpc falls into this category.

___
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: r326758 - in head/sys/i386: conf include

2017-12-11 Thread Don Lewis
On 12 Dec, Eugene Grosbein wrote:

> Now I run FreeBSD 11/i386 as my home router with IPSEC and torrent
> client, and I run several virtualized routers with IPSEC tunnels,
> jabber and mail server, squid and ZFS for src/obj/ports compression
> and they all easily crash unless kern.kstack_pages raised upto 4. Same
> for some other my i386 installations having IPSEC tunnels.

IPSEC definitely used to wwith with kstack_pages=2 since I ran that way
for a number of years.  I haven't used IPSEC since I upgraded from
FreeBSD 8.x to 10.x a while back, so it could be broken now.

___
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: r326376 - head/sys/kern

2017-11-29 Thread Don Lewis
On 29 Nov, Cy Schubert wrote:
> In message <201711292328.vatnseom046...@repo.freebsd.org>, Hans Petter 
> Selasky
> writes:
>> Author: hselasky
>> Date: Wed Nov 29 23:28:40 2017
>> New Revision: 326376
>> URL: https://svnweb.freebsd.org/changeset/base/326376
>>
>> Log:
>>   The sched_add() function is not only used when the thread is initially
>>   started, but also by the turnstiles to mark a thread as runnable for
>>   all locks, for instance sleepqueues do:
>>   setrunnable()->sched_wakeup()->sched_add()
>>   
>>   In r326218 code was added to allow booting from non-zero CPU numbers
>>   by setting the ts_cpu field inside the ULE scheduler's sched_add()
>>   function. This had an undesired side-effect that prior sched_pin() and
>>   sched_bind() calls got disregarded. This patch fixes the
>>   initialization of the ts_cpu field for the ULE scheduler to only
>>   happen once when the initial thread is constructed during system
>>   init. Forking will then later on ensure that a valid ts_cpu value gets
>>   copied to all children.
>>   
>>   Reviewed by:   jhb, kib
>>   Discussed with:nwhitehorn
>>   MFC after: 1 month
>>   Differential revision: https://reviews.freebsd.org/D13298
>>   Sponsored by:  Mellanox Technologies
>>
>> Modified:
>>   head/sys/kern/sched_ule.c
>>
>> Modified: head/sys/kern/sched_ule.c
>> =
>> =
>> --- head/sys/kern/sched_ule.cWed Nov 29 21:16:14 2017
>> (r326375)
>> +++ head/sys/kern/sched_ule.cWed Nov 29 23:28:40 2017
>> (r326376)
>> @@ -1405,7 +1405,6 @@ sched_setup(void *dummy)
>>  
>>  /* Add thread0's load since it's running. */
>>  TDQ_LOCK(tdq);
>> -td_get_sched()->ts_cpu = curcpu; /* Something valid to start */
>>  thread0.td_lock = TDQ_LOCKPTR(TDQ_SELF());
>>  tdq_load_add(tdq, );
>>  tdq->tdq_lowpri = thread0.td_priority;
>> @@ -1642,6 +1641,7 @@ schedinit(void)
>>  ts0->ts_ltick = ticks;
>>  ts0->ts_ftick = ticks;
>>  ts0->ts_slice = 0;
>> +ts0->ts_cpu = curcpu;   /* set valid CPU number */
>>  }
>>  
>>  /*
>> @@ -2453,7 +2453,6 @@ sched_add(struct thread *td, int flags)
>>   * Pick the destination cpu and if it isn't ours transfer to the
>>   * target cpu.
>>   */
>> -td_get_sched(td)->ts_cpu = curcpu; /* Pick something valid to start */
>>  cpu = sched_pickcpu(td, flags);
>>  tdq = sched_setcpu(td, cpu, flags);
>>  tdq_add(tdq, td, flags);
>>
> 
> Hi Hans,
> 
> Sorry I didn't get to this sooner: $JOB (and I have a change window in an 
> hour).
> 
> I sent you a couple of photos from my laptop however I've been able to 
> reproduce this on my testbed.
> 
> It boots okay without INVARIANTS and and WITNESS however with them it gets 
> a double fault.
> 
> Type '?' for a list of commands, 'help' for more detailed help.
> OK include /boot/testbed/amd64-current-t
> /
> 
> testbed/amd64-current-t (12.0-CURRENT) loader file selected
> /
> unload complete
> vfs.zfs.arc_max set to 1024M
> vm.kmem_size set to 1536M
> vm.kmem_size_max set to 1536M
> currdev set to disk1s3f:
> 
> /boot/kernel/kernel text=0xc3262c data=0xc5288+0x3a5048 
> syms=[0x8+0x116508+0x8+0x11285a]
> /boot/kernel/if_sk.ko size 0x17cd0 at 0x16c6000
> /boot/kernel/if_nfe.ko size 0x1a710 at 0x16de000
> /boot/kernel/opensolaris.ko size 0xd6e0 at 0x16f9000
> /boot/kernel/zfs.ko size 0x4ef290 at 0x1707000
> /boot/kernel/amdtemp.ko size 0x53d0 at 0x1bf7000
> loading required module 'amdsmn'
> /boot/kernel/amdsmn.ko size 0x2d78 at 0x1bfd000
> /boot/kernel/cpufreq.ko size 0x168c0 at 0x1c0
> /boot/kernel/tmpfs.ko size 0x203b0 at 0x1c17000
> /boot/kernel/fdescfs.ko size 0x9d98 at 0x1c38000
> /boot/kernel/nullfs.ko size 0xd308 at 0x1c42000
> -
> new kernel has been loaded
> 
> OK boot
> Booting...
> GDB: no debug ports present
> KDB: debugger backends: ddb
> KDB: current backend: ddb
> Copyright (c) 1992-2017 The FreeBSD Project.
> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
>   The Regents of the University of California. All rights reserved.
> FreeBSD is a registered trademark of The FreeBSD Foundation.
> FreeBSD 12.0-CURRENT #0 r326382M: Wed Nov 29 19:44:24 PST 2017
> root@bob:/export/obj/opt/src/svn-current/amd64.amd64/sys/BREAK4 amd64
> FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on LLVM 
> 5.0.0svn)
> WARNING: WITNESS option enabled, expect reduced performance.
> VT(vga): text 80x25
> CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 5000+ (2612.09-MHz K8-class 
> CPU)
>   Origin="AuthenticAMD"  Id=0x60fb2  Family=0xf  Model=0x6b  Stepping=2
>   Features=0x178bfbff CA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
>   Features2=0x2001
>   AMD Features=0xea500800
>   AMD Features2=0x11f
>   SVM: NAsids=64
> real memory  

svn commit: r325731 - stable/10/sys/netpfil/ipfw

2017-11-11 Thread Don Lewis
Author: truckman
Date: Sun Nov 12 01:28:20 2017
New Revision: 325731
URL: https://svnweb.freebsd.org/changeset/base/325731

Log:
  MFC r325008
  
  Fix Dummynet AQM packet marking function ecn_mark() and fq_codel /
  fq_pie schedulers packet classification functions in layer2 (bridge mode).
  
  Dummynet AQM packet marking function ecn_mark() and fq_codel/fq_pie
  schedulers packet classification functions (fq_codel_classify_flow()
  and fq_pie_classify_flow()) assume mbuf is pointing at L3 (IP)
  packet. However, this assumption is incorrect if ipfw/dummynet is
  used to manage layer2 traffic (bridge mode) since mbuf will point
  at L2 frame.  This patch solves this problem by identifying the
  source of the frame/packet (L2 or L3) and adding ETHER_HDR_LEN
  offset when converting an mbuf pointer to ip pointer if the traffic
  is from layer2.  More specifically, in dummynet packet tagging
  function, tag_mbuf(), iphdr_off is set to ETHER_HDR_LEN if the
  traffic is from layer2 and set to zero otherwise. Whenever an access
  to IP header is required, mtodo(m, dn_tag_get(m)->iphdr_off) is
  used instead of mtod(m, struct ip *) to correctly convert mbuf
  pointer to ip pointer in both L2 and L3 traffic.
  
  Submitted by: lstewart
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D12506

Modified:
  stable/10/sys/netpfil/ipfw/dn_sched_fifo.c
  stable/10/sys/netpfil/ipfw/dn_sched_fq_codel.c
  stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
  stable/10/sys/netpfil/ipfw/dn_sched_prio.c
  stable/10/sys/netpfil/ipfw/dn_sched_qfq.c
  stable/10/sys/netpfil/ipfw/dn_sched_rr.c
  stable/10/sys/netpfil/ipfw/dn_sched_wf2q.c
  stable/10/sys/netpfil/ipfw/ip_dn_io.c
  stable/10/sys/netpfil/ipfw/ip_dn_private.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fifo.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fifo.c  Sun Nov 12 01:26:43 2017
(r325730)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fifo.c  Sun Nov 12 01:28:20 2017
(r325731)
@@ -33,13 +33,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include /* IFNAMSIZ */
 #include 
 #include /* ipfw_rule_ref */
 #include  /* flow_id */
 #include 
+#include 
 #include 
 #include 
 #ifdef NEW_AQM

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_codel.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_codel.c  Sun Nov 12 01:26:43 
2017(r325730)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_codel.c  Sun Nov 12 01:28:20 
2017(r325731)
@@ -218,13 +218,14 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -253,7 +254,6 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cSun Nov 12 01:26:43 
2017(r325730)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cSun Nov 12 01:28:20 
2017(r325731)
@@ -792,13 +792,14 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -826,7 +827,6 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: stable/10/sys/netpfil/ipfw/dn_sched_prio.c
==
--- 

svn commit: r325730 - stable/11/sys/netpfil/ipfw

2017-11-11 Thread Don Lewis
Author: truckman
Date: Sun Nov 12 01:26:43 2017
New Revision: 325730
URL: https://svnweb.freebsd.org/changeset/base/325730

Log:
  MFC r325008
  
  Fix Dummynet AQM packet marking function ecn_mark() and fq_codel /
  fq_pie schedulers packet classification functions in layer2 (bridge mode).
  
  Dummynet AQM packet marking function ecn_mark() and fq_codel/fq_pie
  schedulers packet classification functions (fq_codel_classify_flow()
  and fq_pie_classify_flow()) assume mbuf is pointing at L3 (IP)
  packet. However, this assumption is incorrect if ipfw/dummynet is
  used to manage layer2 traffic (bridge mode) since mbuf will point
  at L2 frame.  This patch solves this problem by identifying the
  source of the frame/packet (L2 or L3) and adding ETHER_HDR_LEN
  offset when converting an mbuf pointer to ip pointer if the traffic
  is from layer2.  More specifically, in dummynet packet tagging
  function, tag_mbuf(), iphdr_off is set to ETHER_HDR_LEN if the
  traffic is from layer2 and set to zero otherwise. Whenever an access
  to IP header is required, mtodo(m, dn_tag_get(m)->iphdr_off) is
  used instead of mtod(m, struct ip *) to correctly convert mbuf
  pointer to ip pointer in both L2 and L3 traffic.
  
  Submitted by: lstewart
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D12506

Modified:
  stable/11/sys/netpfil/ipfw/dn_sched_fifo.c
  stable/11/sys/netpfil/ipfw/dn_sched_fq_codel.c
  stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
  stable/11/sys/netpfil/ipfw/dn_sched_prio.c
  stable/11/sys/netpfil/ipfw/dn_sched_qfq.c
  stable/11/sys/netpfil/ipfw/dn_sched_rr.c
  stable/11/sys/netpfil/ipfw/dn_sched_wf2q.c
  stable/11/sys/netpfil/ipfw/ip_dn_io.c
  stable/11/sys/netpfil/ipfw/ip_dn_private.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fifo.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fifo.c  Sun Nov 12 00:00:38 2017
(r325729)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fifo.c  Sun Nov 12 01:26:43 2017
(r325730)
@@ -33,13 +33,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include /* IFNAMSIZ */
 #include 
 #include /* ipfw_rule_ref */
 #include  /* flow_id */
 #include 
+#include 
 #include 
 #include 
 #ifdef NEW_AQM

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_codel.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_codel.c  Sun Nov 12 00:00:38 
2017(r325729)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_codel.c  Sun Nov 12 01:26:43 
2017(r325730)
@@ -218,13 +218,14 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -253,7 +254,6 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSun Nov 12 00:00:38 
2017(r325729)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSun Nov 12 01:26:43 
2017(r325730)
@@ -792,13 +792,14 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -826,7 +827,6 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: stable/11/sys/netpfil/ipfw/dn_sched_prio.c
==
--- 

Re: svn commit: r325404 - head/share/mk

2017-11-04 Thread Don Lewis
On  4 Nov, Bryan Drewery wrote:
> On 11/4/2017 3:30 PM, Cy Schubert wrote:
>> In message <0fc7e918-dcf8-0197-6b50-5936dee23...@freebsd.org>, Bryan 
>> Drewery wr
>> ites:
>>> This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
>>> --dokLDw6wDnv1gUfKm3uwMSMnWeibN2RaD
>>> Content-Type: multipart/mixed; boundary="MKHGkKGfLlBFL1Vl1W5AEj2BccB14C28h";
>>>  protected-headers="v1"
>>> From: Bryan Drewery 
>>> To: "O. Hartmann" , "Simon J. Gerraty"
>>>  
>>> Cc: svn-src-h...@freebsd.org, svn-src-all@freebsd.org,
>>>  src-committ...@freebsd.org
>>> Message-ID: <0fc7e918-dcf8-0197-6b50-5936dee23...@freebsd.org>
>>> Subject: Re: svn commit: r325404 - head/share/mk
>>> References: <201711042102.va4l2rur063...@repo.freebsd.org>
>>>  <20171104223133.00f5b...@thor.intern.walstatt.dynvpn.de>
>>>  <20171104223650.77c06...@thor.intern.walstatt.dynvpn.de>
>>> In-Reply-To: <20171104223650.77c06...@thor.intern.walstatt.dynvpn.de>
>>>
>>> --MKHGkKGfLlBFL1Vl1W5AEj2BccB14C28h
>>> Content-Type: text/plain; charset=utf-8
>>> Content-Language: en-US
>>> Content-Transfer-Encoding: quoted-printable
>>>
>>> On 11/4/2017 2:36 PM, O. Hartmann wrote:
 Am Sat, 4 Nov 2017 22:31:33 +0100
 "O. Hartmann"  schrieb:
 =20
> Am Sat, 4 Nov 2017 21:02:27 + (UTC)
> "Simon J. Gerraty"  schrieb:
>
>> Author: sjg
>> Date: Sat Nov  4 21:02:26 2017
>> New Revision: 325404
>> URL: https://svnweb.freebsd.org/changeset/base/325404
>>
>> Log:
>>   Ensure .OBJDIR has known value
>>  =20
>>   If for any reason we cannot set .OBJDIR=3D=3D_objdir as desired
>>   use .CURDIR so that at least the classic
>>   .if ${.OBJDIR} !=3D ${.CURDIR}
>>   works and dangerous misstakes can be avoided.
>>  =20
>>   Reviewed by: bdrewery
>>
>> Modified:
>>   head/share/mk/auto.obj.mk
>>
>> Modified: head/share/mk/auto.obj.mk
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>> =3D=3D=3D=3D=3D
>> --- head/share/mk/auto.obj.mkSat Nov  4 16:23:34 2017(r32540
>>> 3)
>> +++ head/share/mk/auto.obj.mkSat Nov  4 21:02:26 2017(r32540
>>> 4)
>> @@ -61,11 +61,17 @@ __objdir_made !=3D echo ${__objdir}/; umask ${OBJ=
>>> DIR_UMA
>>  .endif
>>  # This causes make to use the specified directory as .OBJDIR
>>  .OBJDIR: ${__objdir}
>> -.if ${.OBJDIR:tA} !=3D ${__objdir:tA} && ${__objdir_made:Uno:M${__ob=
>>> jdir}/*} !=3D ""
>> +.if ${.OBJDIR:tA} !=3D ${__objdir:tA}
>> +# we did not get what we want - do we care?
>> +.if ${__objdir_made:Uno:M${__objdir}/*} !=3D ""
>>  # watch out for __objdir being relative path
>>  .if !(${__objdir:M/*} =3D=3D "" && ${.OBJDIR:tA} =3D=3D ${${.CURDIR}=
>>> /${__objdir}:L:tA})
>>  .error could not use ${__objdir}: .OBJDIR=3D${.OBJDIR}
>>  .endif
>> +.endif
>> +# apparently we can live with it
>> +# make sure we know what we have
>> +.OBJDIR: ${.CURDIR}
>>  .endif
>>  .endif
>>  .endif
>> ___
>> svn-src-h...@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/svn-src-head
>> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.or=
>>> g" =20
>
> With the recent patches, nvidia driver x11/nvidia-driver fails tobuild=
>>>  with the error
> shown below:
>
> [...]
> =3D=3D=3D> src/nvidia (all) =20
> make[7]: "/usr/src/share/mk/bsd.obj.mk" line 87: Malformed conditional=
>>>
> (${CANONICALOBJDIR} =3D=3D /${RELDIR} || ${.OBJDIR} =3D=3D /${RELDIR})=
>>>  make[7]: Fatal errors
> encountered -- cannot continue
> [...]
 =20
 The very same with emulators/virtualbox-ose-kmod:
 =20
 [...]
 kBuild:
 Installing /usr/obj/usr/src/amd64.amd64/sys/THOR/usr/ports/emulators/vi=
>>> rtualbox-ose-kmod/work/VirtualBox-5.2.0/out/freebsd.amd64/release/bin/src=
>>> /vboxdrv/Makefile
 =3D=3D=3D Building 'vboxdrv' module =3D=3D=3D make[6]: "/usr/src/share/=
>>> mk/bsd.obj.mk" line 87:
 Malformed conditional (${CANONICALOBJDIR} =3D=3D /${RELDIR} || ${.OBJDI=
>>> R} =3D=3D /${RELDIR})
 make[6]: Fatal errors encountered -- cannot continue make[6]: stopped
 in /usr/obj/usr/src/amd64.amd64/sys/THOR/usr/ports/emulators/virtualbox=
>>> -ose-kmod/work/VirtualBox-5.2.0/out/freebsd.amd64/release/bin/src/vboxdrv=
>>>
 *** Error code 1
 =20
 Stop.
 make[5]: stopped
 in /usr/obj/usr/src/amd64.amd64/sys/THOR/usr/ports/emulators/virtualbox=
>>> -ose-kmod/work/VirtualBox-5.2.0/out/freebsd.amd64/release/bin/src
 =3D=3D=3D> Compilation failed unexpectedly. Try to set MAKE_JOBS_UNSAFE=
>>> =3Dyes and rebuild 

svn commit: r325008 - head/sys/netpfil/ipfw

2017-10-26 Thread Don Lewis
Author: truckman
Date: Thu Oct 26 10:11:35 2017
New Revision: 325008
URL: https://svnweb.freebsd.org/changeset/base/325008

Log:
  Fix Dummynet AQM packet marking function ecn_mark() and fq_codel /
  fq_pie schedulers packet classification functions in layer2 (bridge mode).
  
  Dummynet AQM packet marking function ecn_mark() and fq_codel/fq_pie
  schedulers packet classification functions (fq_codel_classify_flow()
  and fq_pie_classify_flow()) assume mbuf is pointing at L3 (IP)
  packet. However, this assumption is incorrect if ipfw/dummynet is
  used to manage layer2 traffic (bridge mode) since mbuf will point
  at L2 frame.  This patch solves this problem by identifying the
  source of the frame/packet (L2 or L3) and adding ETHER_HDR_LEN
  offset when converting an mbuf pointer to ip pointer if the traffic
  is from layer2.  More specifically, in dummynet packet tagging
  function, tag_mbuf(), iphdr_off is set to ETHER_HDR_LEN if the
  traffic is from layer2 and set to zero otherwise. Whenever an access
  to IP header is required, mtodo(m, dn_tag_get(m)->iphdr_off) is
  used instead of mtod(m, struct ip *) to correctly convert mbuf
  pointer to ip pointer in both L2 and L3 traffic.
  
  Submitted by: lstewart
  MFC after:2 weeks
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D12506

Modified:
  head/sys/netpfil/ipfw/dn_sched_fifo.c
  head/sys/netpfil/ipfw/dn_sched_fq_codel.c
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c
  head/sys/netpfil/ipfw/dn_sched_prio.c
  head/sys/netpfil/ipfw/dn_sched_qfq.c
  head/sys/netpfil/ipfw/dn_sched_rr.c
  head/sys/netpfil/ipfw/dn_sched_wf2q.c
  head/sys/netpfil/ipfw/ip_dn_io.c
  head/sys/netpfil/ipfw/ip_dn_private.h

Modified: head/sys/netpfil/ipfw/dn_sched_fifo.c
==
--- head/sys/netpfil/ipfw/dn_sched_fifo.c   Thu Oct 26 09:29:35 2017
(r325007)
+++ head/sys/netpfil/ipfw/dn_sched_fifo.c   Thu Oct 26 10:11:35 2017
(r325008)
@@ -33,13 +33,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include /* IFNAMSIZ */
 #include 
 #include /* ipfw_rule_ref */
 #include  /* flow_id */
 #include 
+#include 
 #include 
 #include 
 #ifdef NEW_AQM

Modified: head/sys/netpfil/ipfw/dn_sched_fq_codel.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_codel.c   Thu Oct 26 09:29:35 2017
(r325007)
+++ head/sys/netpfil/ipfw/dn_sched_fq_codel.c   Thu Oct 26 10:11:35 2017
(r325008)
@@ -218,13 +218,14 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -253,7 +254,6 @@ fq_codel_classify_flow(struct mbuf *m, uint16_t fcount
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Thu Oct 26 09:29:35 2017
(r325007)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Thu Oct 26 10:11:35 2017
(r325008)
@@ -792,13 +792,14 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
uint8_t tuple[41];
uint16_t hash=0;
 
+   ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off);
 //#ifdef INET6
struct ip6_hdr *ip6;
int isip6;
-   isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
+   isip6 = (ip->ip_v == 6);
 
if(isip6) {
-   ip6 = mtod(m, struct ip6_hdr *);
+   ip6 = (struct ip6_hdr *)ip;
*((uint8_t *) [0]) = ip6->ip6_nxt;
*((uint32_t *) [1]) = si->perturbation;
memcpy([5], ip6->ip6_src.s6_addr, 16);
@@ -826,7 +827,6 @@ fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, 
 //#endif
 
/* IPv4 */
-   ip = mtod(m, struct ip *);
*((uint8_t *) [0]) = ip->ip_p;
*((uint32_t *) [1]) = si->perturbation;
*((uint32_t *) [5]) = ip->ip_src.s_addr;

Modified: head/sys/netpfil/ipfw/dn_sched_prio.c
==
--- head/sys/netpfil/ipfw/dn_sched_prio.c   Thu Oct 26 09:29:35 2017
(r325007)
+++ head/sys/netpfil/ipfw/dn_sched_prio.c   Thu Oct 

Re: svn commit: r324313 - head/sys/amd64/amd64

2017-10-08 Thread Don Lewis
On  8 Oct, Konstantin Belousov wrote:
> On Sat, Oct 07, 2017 at 01:54:05PM -0700, Don Lewis wrote:
>> On  7 Oct, Konstantin Belousov wrote:
>> > On Sat, Oct 07, 2017 at 01:04:09PM -0700, Don Lewis wrote:
>> >> On  5 Oct, Konstantin Belousov wrote:
>> >> > Author: kib
>> >> > Date: Thu Oct  5 12:50:03 2017
>> >> > New Revision: 324313
>> >> > URL: https://svnweb.freebsd.org/changeset/base/324313
>> >> > 
>> >> > Log:
>> >> >   Avoid a race betweem freeing LDT and context switches.
>> >> >   
>> >> >   cpu_switch.S uses curproc->p_md.md_ldt value as the flag indicating
>> >> >   presence of the process LDT.  The flag is checked and then ldt segment
>> >> >   descriptor is copied into the CPU' GDT slot.
>> >> >   
>> >> >   Disallow context switches around clearing of the curproc LDT state by
>> >> >   performing the cleanup in critical section.  Ensure that the md_ldt
>> >> >   flag is cleared before md_ldt_sd descriptor content is destroyed by
>> >> >   inserting fence between the operations.
>> >> >   
>> >> >   We depend on the x86 memory model strong ordering guarantees, in
>> >> >   particular, that cpu_switch.S observes the writes to md_ldt and
>> >> >   md_ldt_sd in the expected order.
>> >> 
>> >> I don't know which of this series of commits is responsible, but I think
>> >> that it fixed the build of lang/ghc on Ryzen.
>> >> 
>> >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221029#c102
>> > 
>> > Does ghc use LDT on amd64 ?  This sounds unbelievable.
>> 
>> I have no idea, but ghc would reliably fail to build on my Ryzen machine
>> up through r323398, and at r324367 it seems to reliably build.
> Could you try to bisect ?
> 
> I reviewed all kernel changes and do not see anything which could be
> marked as possible fix for whatever kernel issue causing usermode
> fault.  

I need to bisect at least userland for another reason.  I've recently
been seeing sporadic build runaways when using poudriere to build ports.
This has happened both on my replacement Ryzen CPU and also on my AMD
FX-8320E, more frequently on the Ryzen.  My reason for suspecting a
userland problem is that I've only seen this when building ports in a
12.0-CURRENT jail, and not 10.4 or 11.1.  I first started seeing this a
couple weeks ago.

This will be slow going because even on the Ryzen, my full package set
builds take about nine hours and I don't see the failure every time.

I'll also see if ghc is affected by the userland version.

___
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: r324313 - head/sys/amd64/amd64

2017-10-07 Thread Don Lewis
On  7 Oct, Konstantin Belousov wrote:
> On Sat, Oct 07, 2017 at 01:04:09PM -0700, Don Lewis wrote:
>> On  5 Oct, Konstantin Belousov wrote:
>> > Author: kib
>> > Date: Thu Oct  5 12:50:03 2017
>> > New Revision: 324313
>> > URL: https://svnweb.freebsd.org/changeset/base/324313
>> > 
>> > Log:
>> >   Avoid a race betweem freeing LDT and context switches.
>> >   
>> >   cpu_switch.S uses curproc->p_md.md_ldt value as the flag indicating
>> >   presence of the process LDT.  The flag is checked and then ldt segment
>> >   descriptor is copied into the CPU' GDT slot.
>> >   
>> >   Disallow context switches around clearing of the curproc LDT state by
>> >   performing the cleanup in critical section.  Ensure that the md_ldt
>> >   flag is cleared before md_ldt_sd descriptor content is destroyed by
>> >   inserting fence between the operations.
>> >   
>> >   We depend on the x86 memory model strong ordering guarantees, in
>> >   particular, that cpu_switch.S observes the writes to md_ldt and
>> >   md_ldt_sd in the expected order.
>> 
>> I don't know which of this series of commits is responsible, but I think
>> that it fixed the build of lang/ghc on Ryzen.
>> 
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221029#c102
> 
> Does ghc use LDT on amd64 ?  This sounds unbelievable.

I have no idea, but ghc would reliably fail to build on my Ryzen machine
up through r323398, and at r324367 it seems to reliably build.

___
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: r324313 - head/sys/amd64/amd64

2017-10-07 Thread Don Lewis
On  5 Oct, Konstantin Belousov wrote:
> Author: kib
> Date: Thu Oct  5 12:50:03 2017
> New Revision: 324313
> URL: https://svnweb.freebsd.org/changeset/base/324313
> 
> Log:
>   Avoid a race betweem freeing LDT and context switches.
>   
>   cpu_switch.S uses curproc->p_md.md_ldt value as the flag indicating
>   presence of the process LDT.  The flag is checked and then ldt segment
>   descriptor is copied into the CPU' GDT slot.
>   
>   Disallow context switches around clearing of the curproc LDT state by
>   performing the cleanup in critical section.  Ensure that the md_ldt
>   flag is cleared before md_ldt_sd descriptor content is destroyed by
>   inserting fence between the operations.
>   
>   We depend on the x86 memory model strong ordering guarantees, in
>   particular, that cpu_switch.S observes the writes to md_ldt and
>   md_ldt_sd in the expected order.

I don't know which of this series of commits is responsible, but I think
that it fixed the build of lang/ghc on Ryzen.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221029#c102

___
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: r322569 - in stable/11/sys/amd64: amd64 include linux

2017-08-16 Thread Don Lewis
Author: truckman
Date: Wed Aug 16 07:59:57 2017
New Revision: 322569
URL: https://svnweb.freebsd.org/changeset/base/322569

Log:
  MFC r321899
  
  Lower the amd64 shared page, which contains the signal trampoline,
  from the top of user memory to one page lower on machines with the
  Ryzen (AMD Family 17h) CPU.  This pushes ps_strings and the stack
  down by one page as well.  On Ryzen there is some sort of interaction
  between code running at the top of user memory address space and
  interrupts that can cause FreeBSD to either hang or silently reset.
  This sounds similar to the problem found with DragonFly BSD that
  was fixed with this commit:

https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20
  but our signal trampoline location was already lower than the address
  that DragonFly moved their signal trampoline to.  It also does not
  appear to be related to SMT as described here:

https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498
  
"Hi, Matt Dillon here. Yes, I did find what I believe to be a
 hardware issue with Ryzen related to concurrent operations. In a
 nutshell, for any given hyperthread pair, if one hyperthread is
 in a cpu-bound loop of any kind (can be in user mode), and the
 other hyperthread is returning from an interrupt via IRETQ, the
 hyperthread issuing the IRETQ can stall indefinitely until the
 other hyperthread with the cpu-bound loop pauses (aka HLT until
 next interrupt). After this situation occurs, the system appears
 to destabilize. The situation does not occur if the cpu-bound
 loop is on a different core than the core doing the IRETQ. The
 %rip the IRETQ returns to (e.g. userland %rip address) matters a
 *LOT*. The problem occurs more often with high %rip addresses
 such as near the top of the user stack, which is where DragonFly's
 signal trampoline traditionally resides. So a user program taking
 a signal on one thread while another thread is cpu-bound can cause
 this behavior. Changing the location of the signal trampoline
 makes it more difficult to reproduce the problem. I have not
 been because the able to completely mitigate it. When a cpu-thread
 stalls in this manner it appears to stall INSIDE the microcode
 for IRETQ. It doesn't make it to the return pc, and the cpu thread
 cannot take any IPIs or other hardware interrupts while in this
 state."
  since the system instability has been observed on FreeBSD with SMT
  disabled.  Interrupts to appear to play a factor since running a
  signal-intensive process on the first CPU core, which handles most
  of the interrupts on my machine, is far more likely to trigger the
  problem than running such a process on any other core.
  
  Also lower sv_maxuser to prevent a malicious user from using mmap()
  to load and execute code in the top page of user memory that was made
  available when the shared page was moved down.
  
  Make the same changes to the 64-bit Linux emulator.
  
  PR:   219399
  Reported by:  n...@renzel.net
  Reviewed by:  kib
  Reviewed by:  dchagin (previous version)
  Tested by:n...@renzel.net (earlier version)
  Differential Revision:https://reviews.freebsd.org/D11780

Modified:
  stable/11/sys/amd64/amd64/elf_machdep.c
  stable/11/sys/amd64/amd64/initcpu.c
  stable/11/sys/amd64/include/md_var.h
  stable/11/sys/amd64/linux/linux_sysvec.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/elf_machdep.c
==
--- stable/11/sys/amd64/amd64/elf_machdep.c Wed Aug 16 06:43:50 2017
(r322568)
+++ stable/11/sys/amd64/amd64/elf_machdep.c Wed Aug 16 07:59:57 2017
(r322569)
@@ -84,6 +84,25 @@ struct sysentvec elf64_freebsd_sysvec = {
 };
 INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
 
+void
+amd64_lower_shared_page(struct sysentvec *sv)
+{
+   if (hw_lower_amd64_sharedpage != 0) {
+   sv->sv_maxuser -= PAGE_SIZE;
+   sv->sv_shared_page_base -= PAGE_SIZE;
+   sv->sv_usrstack -= PAGE_SIZE;
+   sv->sv_psstrings -= PAGE_SIZE;
+   }
+}
+
+/*
+ * Do this fixup before INIT_SYSENTVEC (SI_ORDER_ANY) because the latter
+ * uses the value of sv_shared_page_base.
+ */
+SYSINIT(elf64_sysvec_fixup, SI_SUB_EXEC, SI_ORDER_FIRST,
+   (sysinit_cfunc_t) amd64_lower_shared_page,
+   _freebsd_sysvec);
+
 static Elf64_Brandinfo freebsd_brand_info = {
.brand  = ELFOSABI_FREEBSD,
.machine= EM_X86_64,

Modified: stable/11/sys/amd64/amd64/initcpu.c
==
--- stable/11/sys/amd64/amd64/initcpu.c Wed Aug 16 06:43:50 2017
(r322568)
+++ 

svn commit: r321899 - in head/sys/amd64: amd64 include linux

2017-08-01 Thread Don Lewis
Author: truckman
Date: Wed Aug  2 01:43:35 2017
New Revision: 321899
URL: https://svnweb.freebsd.org/changeset/base/321899

Log:
  Lower the amd64 shared page, which contains the signal trampoline,
  from the top of user memory to one page lower on machines with the
  Ryzen (AMD Family 17h) CPU.  This pushes ps_strings and the stack
  down by one page as well.  On Ryzen there is some sort of interaction
  between code running at the top of user memory address space and
  interrupts that can cause FreeBSD to either hang or silently reset.
  This sounds similar to the problem found with DragonFly BSD that
  was fixed with this commit:

https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20
  but our signal trampoline location was already lower than the address
  that DragonFly moved their signal trampoline to.  It also does not
  appear to be related to SMT as described here:

https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498
  
"Hi, Matt Dillon here. Yes, I did find what I believe to be a
 hardware issue with Ryzen related to concurrent operations. In a
 nutshell, for any given hyperthread pair, if one hyperthread is
 in a cpu-bound loop of any kind (can be in user mode), and the
 other hyperthread is returning from an interrupt via IRETQ, the
 hyperthread issuing the IRETQ can stall indefinitely until the
 other hyperthread with the cpu-bound loop pauses (aka HLT until
 next interrupt). After this situation occurs, the system appears
 to destabilize. The situation does not occur if the cpu-bound
 loop is on a different core than the core doing the IRETQ. The
 %rip the IRETQ returns to (e.g. userland %rip address) matters a
 *LOT*. The problem occurs more often with high %rip addresses
 such as near the top of the user stack, which is where DragonFly's
 signal trampoline traditionally resides. So a user program taking
 a signal on one thread while another thread is cpu-bound can cause
 this behavior. Changing the location of the signal trampoline
 makes it more difficult to reproduce the problem. I have not
 been because the able to completely mitigate it. When a cpu-thread
 stalls in this manner it appears to stall INSIDE the microcode
 for IRETQ. It doesn't make it to the return pc, and the cpu thread
 cannot take any IPIs or other hardware interrupts while in this
 state."
  since the system instability has been observed on FreeBSD with SMT
  disabled.  Interrupts to appear to play a factor since running a
  signal-intensive process on the first CPU core, which handles most
  of the interrupts on my machine, is far more likely to trigger the
  problem than running such a process on any other core.
  
  Also lower sv_maxuser to prevent a malicious user from using mmap()
  to load and execute code in the top page of user memory that was made
  available when the shared page was moved down.
  
  Make the same changes to the 64-bit Linux emulator.
  
  PR:   219399
  Reported by:  n...@renzel.net
  Reviewed by:  kib
  Reviewed by:  dchagin (previous version)
  Tested by:n...@renzel.net (earlier version)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D11780

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/amd64/amd64/initcpu.c
  head/sys/amd64/include/md_var.h
  head/sys/amd64/linux/linux_sysvec.c

Modified: head/sys/amd64/amd64/elf_machdep.c
==
--- head/sys/amd64/amd64/elf_machdep.c  Wed Aug  2 01:23:17 2017
(r321898)
+++ head/sys/amd64/amd64/elf_machdep.c  Wed Aug  2 01:43:35 2017
(r321899)
@@ -84,6 +84,25 @@ struct sysentvec elf64_freebsd_sysvec = {
 };
 INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
 
+void
+amd64_lower_shared_page(struct sysentvec *sv)
+{
+   if (hw_lower_amd64_sharedpage != 0) {
+   sv->sv_maxuser -= PAGE_SIZE;
+   sv->sv_shared_page_base -= PAGE_SIZE;
+   sv->sv_usrstack -= PAGE_SIZE;
+   sv->sv_psstrings -= PAGE_SIZE;
+   }
+}
+
+/*
+ * Do this fixup before INIT_SYSENTVEC (SI_ORDER_ANY) because the latter
+ * uses the value of sv_shared_page_base.
+ */
+SYSINIT(elf64_sysvec_fixup, SI_SUB_EXEC, SI_ORDER_FIRST,
+   (sysinit_cfunc_t) amd64_lower_shared_page,
+   _freebsd_sysvec);
+
 static Elf64_Brandinfo freebsd_brand_info = {
.brand  = ELFOSABI_FREEBSD,
.machine= EM_X86_64,

Modified: head/sys/amd64/amd64/initcpu.c
==
--- head/sys/amd64/amd64/initcpu.c  Wed Aug  2 01:23:17 2017
(r321898)
+++ head/sys/amd64/amd64/initcpu.c  Wed Aug  2 01:43:35 2017
(r321899)
@@ -48,6 +48,11 @@ __FBSDID("$FreeBSD$");

Re: svn commit: r318441 - in head/etc: . cron.d

2017-06-05 Thread Don Lewis
On  3 Jun, Rodney W. Grimes wrote:
 
> As far as fixing the builds for optional stuff that is rather
> easily done in the Makefile with some if's to build a list of
> files that can then be catted to conf.foo, using m4 or even
> cpp to pre process conf.foo.src, etc, several very easy ways
> to solve that and leave the system administration interface
> alone.

That doesn't help with packaged base where you can add one of the
optional pieces later.

___
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: r318905 - stable/10/sys/netpfil/ipfw

2017-05-25 Thread Don Lewis
Author: truckman
Date: Thu May 25 22:41:34 2017
New Revision: 318905
URL: https://svnweb.freebsd.org/changeset/base/318905

Log:
  MFC r318527
  
  Fix the queue delay estimation in PIE/FQ-PIE when the timestamp
  (TS) method is used.  When packet timestamp is used, the "current_qdelay"
  keeps storing the last queue delay value calculated in the dequeue
  function.  Therefore, when a burst of packets arrives followed by
  a pause, the "current_qdelay" will store a high value caused by the
  burst and stick to that value during the pause because the queue
  delay measurement is done inside the dequeue function.  This causes
  the drop probability calculation function to calculate high drop
  probability value instead of zero and prevents the burst allowance
  mechanism from working properly.  Fix this problem by resetting
  "current_qdelay" inside the drop probability calculation function
  when the queue length is zero and TS option is used.
  
  Submitted by: Rasool Al-Saadi 

Modified:
  stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
  stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 22:39:48 2017
(r318904)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 22:41:34 2017
(r318905)
@@ -211,11 +211,16 @@ calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process. 
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes *
pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS;
-   }
+   else 
+   if (!pst->pq->ni.len_bytes)
+pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 22:39:48 
2017(r318904)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 22:41:34 
2017(r318905)
@@ -383,11 +383,16 @@ fq_calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process.
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)q->stats.len_bytes  * 
pst->avg_dq_time)
>> PIE_DQ_THRESHOLD_BITS;
-   }
+   else
+   if (!q->stats.len_bytes)
+   pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 
___
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: r318904 - stable/11/sys/netpfil/ipfw

2017-05-25 Thread Don Lewis
Author: truckman
Date: Thu May 25 22:39:48 2017
New Revision: 318904
URL: https://svnweb.freebsd.org/changeset/base/318904

Log:
  MFC r318527
  
  Fix the queue delay estimation in PIE/FQ-PIE when the timestamp
  (TS) method is used.  When packet timestamp is used, the "current_qdelay"
  keeps storing the last queue delay value calculated in the dequeue
  function.  Therefore, when a burst of packets arrives followed by
  a pause, the "current_qdelay" will store a high value caused by the
  burst and stick to that value during the pause because the queue
  delay measurement is done inside the dequeue function.  This causes
  the drop probability calculation function to calculate high drop
  probability value instead of zero and prevents the burst allowance
  mechanism from working properly.  Fix this problem by resetting
  "current_qdelay" inside the drop probability calculation function
  when the queue length is zero and TS option is used.
  
  Submitted by: Rasool Al-Saadi 

Modified:
  stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
  stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 21:59:19 2017
(r318903)
+++ stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 22:39:48 2017
(r318904)
@@ -211,11 +211,16 @@ calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process. 
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes *
pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS;
-   }
+   else 
+   if (!pst->pq->ni.len_bytes)
+pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 21:59:19 
2017(r318903)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 22:39:48 
2017(r318904)
@@ -383,11 +383,16 @@ fq_calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process.
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)q->stats.len_bytes  * 
pst->avg_dq_time)
>> PIE_DQ_THRESHOLD_BITS;
-   }
+   else
+   if (!q->stats.len_bytes)
+   pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 
___
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: r318886 - stable/10/sys/netpfil/ipfw

2017-05-25 Thread Don Lewis
Author: truckman
Date: Thu May 25 17:23:26 2017
New Revision: 318886
URL: https://svnweb.freebsd.org/changeset/base/318886

Log:
  MFC r318511
  
  The result of right shifting a negative signed value is implementation
  defined.  On machines without arithmetic shift instructions, zero bits
  may be shifted in from the left, giving a large positive result instead
  of the desired divide-by power-of-2.  Fix this by operating on the
  absolute value and compensating for the possible negation later.
  
  Reverse the order of the underflow/overflow tests and the exponential
  decay calculation to avoid the possibility of an erroneous overflow
  detection if p is a sufficiently small non-negative value.  Also
  check for negative values of prob before doing the exponential decay
  to avoid another instance of of right shifting a negative value.
  
  Tested by:Rasool Al-Saadi 

Modified:
  stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
  stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 17:22:13 2017
(r318885)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 17:23:26 2017
(r318886)
@@ -206,6 +206,7 @@ calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
struct dn_aqm_pie_parms *pprms;
struct pie_status *pst = (struct pie_status *) x;
+   int p_isneg;
 
pprms = pst->parms;
prob = pst->drop_prob;
@@ -221,6 +222,12 @@ calculate_drop_prob(void *x)
((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); 
p +=(int64_t) pprms->beta * 
((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); 
+
+   /* take absolute value so right shift result is well defined */
+   p_isneg = p < 0;
+   if (p_isneg) {
+   p = -p;
+   }

/* We PIE_MAX_PROB shift by 12-bits to increase the division precision 
*/
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
@@ -243,37 +250,47 @@ calculate_drop_prob(void *x)
 
oldprob = prob;
 
-   /* Cap Drop adjustment */
-   if ((pprms->flags & PIE_CAPDROP_ENABLED) && prob >= PIE_MAX_PROB / 10
-   && p > PIE_MAX_PROB / 50 ) 
-   p = PIE_MAX_PROB / 50;
+   if (p_isneg) {
+   prob = prob - p;
 
-   prob = prob + p;
-
-   /* decay the drop probability exponentially */
-   if (pst->current_qdelay == 0 && pst->qdelay_old == 0)
-   /* 0.98 ~= 1- 1/64 */
-   prob = prob - (prob >> 6); 
+   /* check for multiplication underflow */
+   if (prob > oldprob) {
+   prob= 0;
+   D("underflow");
+   }
+   } else {
+   /* Cap Drop adjustment */
+   if ((pprms->flags & PIE_CAPDROP_ENABLED) &&
+   prob >= PIE_MAX_PROB / 10 &&
+   p > PIE_MAX_PROB / 50 ) {
+   p = PIE_MAX_PROB / 50;
+   }
 
+   prob = prob + p;
 
-   /* check for multiplication overflow/underflow */
-   if (p>0) {
+   /* check for multiplication overflow */
if (proboldprob) {
-   prob= 0;
-   D("underflow");
-   }
 
-   /* make drop probability between 0 and PIE_MAX_PROB*/
-   if (prob < 0)
+   /*
+* decay the drop probability exponentially
+* and restrict it to range 0 to PIE_MAX_PROB
+*/
+   if (prob < 0) {
prob = 0;
-   else if (prob > PIE_MAX_PROB)
-   prob = PIE_MAX_PROB;
+   } else {
+   if (pst->current_qdelay == 0 && pst->qdelay_old == 0) {
+   /* 0.98 ~= 1- 1/64 */
+   prob = prob - (prob >> 6); 
+   }
+
+   if (prob > PIE_MAX_PROB) {
+   prob = PIE_MAX_PROB;
+   }
+   }
 
pst->drop_prob = prob;


Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 17:22:13 
2017(r318885)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 17:23:26 
2017(r318886)
@@ -377,6 +377,7 @@ fq_calculate_drop_prob(void *x)
struct dn_aqm_pie_parms *pprms; 
int64_t p, prob, oldprob;
aqm_time_t now;
+   int p_isneg;
 
now = AQM_UNOW;
pprms = pst->parms;
@@ -393,6 +394,12 @@ fq_calculate_drop_prob(void *x)
  

svn commit: r318885 - stable/11/sys/netpfil/ipfw

2017-05-25 Thread Don Lewis
Author: truckman
Date: Thu May 25 17:22:13 2017
New Revision: 318885
URL: https://svnweb.freebsd.org/changeset/base/318885

Log:
  MFC r318511
  
  The result of right shifting a negative signed value is implementation
  defined.  On machines without arithmetic shift instructions, zero bits
  may be shifted in from the left, giving a large positive result instead
  of the desired divide-by power-of-2.  Fix this by operating on the
  absolute value and compensating for the possible negation later.
  
  Reverse the order of the underflow/overflow tests and the exponential
  decay calculation to avoid the possibility of an erroneous overflow
  detection if p is a sufficiently small non-negative value.  Also
  check for negative values of prob before doing the exponential decay
  to avoid another instance of of right shifting a negative value.
  
  Tested by:Rasool Al-Saadi 

Modified:
  stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
  stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 16:41:07 2017
(r318884)
+++ stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu May 25 17:22:13 2017
(r318885)
@@ -206,6 +206,7 @@ calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
struct dn_aqm_pie_parms *pprms;
struct pie_status *pst = (struct pie_status *) x;
+   int p_isneg;
 
pprms = pst->parms;
prob = pst->drop_prob;
@@ -221,6 +222,12 @@ calculate_drop_prob(void *x)
((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); 
p +=(int64_t) pprms->beta * 
((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); 
+
+   /* take absolute value so right shift result is well defined */
+   p_isneg = p < 0;
+   if (p_isneg) {
+   p = -p;
+   }

/* We PIE_MAX_PROB shift by 12-bits to increase the division precision 
*/
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
@@ -243,37 +250,47 @@ calculate_drop_prob(void *x)
 
oldprob = prob;
 
-   /* Cap Drop adjustment */
-   if ((pprms->flags & PIE_CAPDROP_ENABLED) && prob >= PIE_MAX_PROB / 10
-   && p > PIE_MAX_PROB / 50 ) 
-   p = PIE_MAX_PROB / 50;
+   if (p_isneg) {
+   prob = prob - p;
 
-   prob = prob + p;
-
-   /* decay the drop probability exponentially */
-   if (pst->current_qdelay == 0 && pst->qdelay_old == 0)
-   /* 0.98 ~= 1- 1/64 */
-   prob = prob - (prob >> 6); 
+   /* check for multiplication underflow */
+   if (prob > oldprob) {
+   prob= 0;
+   D("underflow");
+   }
+   } else {
+   /* Cap Drop adjustment */
+   if ((pprms->flags & PIE_CAPDROP_ENABLED) &&
+   prob >= PIE_MAX_PROB / 10 &&
+   p > PIE_MAX_PROB / 50 ) {
+   p = PIE_MAX_PROB / 50;
+   }
 
+   prob = prob + p;
 
-   /* check for multiplication overflow/underflow */
-   if (p>0) {
+   /* check for multiplication overflow */
if (proboldprob) {
-   prob= 0;
-   D("underflow");
-   }
 
-   /* make drop probability between 0 and PIE_MAX_PROB*/
-   if (prob < 0)
+   /*
+* decay the drop probability exponentially
+* and restrict it to range 0 to PIE_MAX_PROB
+*/
+   if (prob < 0) {
prob = 0;
-   else if (prob > PIE_MAX_PROB)
-   prob = PIE_MAX_PROB;
+   } else {
+   if (pst->current_qdelay == 0 && pst->qdelay_old == 0) {
+   /* 0.98 ~= 1- 1/64 */
+   prob = prob - (prob >> 6); 
+   }
+
+   if (prob > PIE_MAX_PROB) {
+   prob = PIE_MAX_PROB;
+   }
+   }
 
pst->drop_prob = prob;


Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 16:41:07 
2017(r318884)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cThu May 25 17:22:13 
2017(r318885)
@@ -377,6 +377,7 @@ fq_calculate_drop_prob(void *x)
struct dn_aqm_pie_parms *pprms; 
int64_t p, prob, oldprob;
aqm_time_t now;
+   int p_isneg;
 
now = AQM_UNOW;
pprms = pst->parms;
@@ -393,6 +394,12 @@ fq_calculate_drop_prob(void *x)
  

svn commit: r318527 - head/sys/netpfil/ipfw

2017-05-19 Thread Don Lewis
Author: truckman
Date: Fri May 19 08:38:03 2017
New Revision: 318527
URL: https://svnweb.freebsd.org/changeset/base/318527

Log:
  Fix the queue delay estimation in PIE/FQ-PIE when the timestamp
  (TS) method is used.  When packet timestamp is used, the "current_qdelay"
  keeps storing the last queue delay value calculated in the dequeue
  function.  Therefore, when a burst of packets arrives followed by
  a pause, the "current_qdelay" will store a high value caused by the
  burst and stick to that value during the pause because the queue
  delay measurement is done inside the dequeue function.  This causes
  the drop probability calculation function to calculate high drop
  probability value instead of zero and prevents the burst allowance
  mechanism from working properly.  Fix this problem by resetting
  "current_qdelay" inside the drop probability calculation function
  when the queue length is zero and TS option is used.
  
  Submitted by: Rasool Al-Saadi 
  MFC after:1 week

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.c
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.c  Fri May 19 08:26:41 2017
(r318526)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.c  Fri May 19 08:38:03 2017
(r318527)
@@ -211,11 +211,16 @@ calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process. 
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes *
pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS;
-   }
+   else 
+   if (!pst->pq->ni.len_bytes)
+pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 

Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Fri May 19 08:26:41 2017
(r318526)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Fri May 19 08:38:03 2017
(r318527)
@@ -383,11 +383,16 @@ fq_calculate_drop_prob(void *x)
pprms = pst->parms;
prob = pst->drop_prob;
 
-   /* calculate current qdelay */
-   if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
+   /* calculate current qdelay using DRE method.
+* If TS is used and no data in the queue, reset current_qdelay
+* as it stays at last value during dequeue process.
+   */
+   if (pprms->flags & PIE_DEPRATEEST_ENABLED)
pst->current_qdelay = ((uint64_t)q->stats.len_bytes  * 
pst->avg_dq_time)
>> PIE_DQ_THRESHOLD_BITS;
-   }
+   else
+   if (!q->stats.len_bytes)
+   pst->current_qdelay = 0;
 
/* calculate drop probability */
p = (int64_t)pprms->alpha * 
___
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: r318511 - head/sys/netpfil/ipfw

2017-05-18 Thread Don Lewis
Author: truckman
Date: Fri May 19 01:23:06 2017
New Revision: 318511
URL: https://svnweb.freebsd.org/changeset/base/318511

Log:
  The result of right shifting a negative signed value is implementation
  defined.  On machines without arithmetic shift instructions, zero bits
  may be shifted in from the left, giving a large positive result instead
  of the desired divide-by power-of-2.  Fix this by operating on the
  absolute value and compensating for the possible negation later.
  
  Reverse the order of the underflow/overflow tests and the exponential
  decay calculation to avoid the possibility of an erroneous overflow
  detection if p is a sufficiently small non-negative value.  Also
  check for negative values of prob before doing the exponential decay
  to avoid another instance of of right shifting a negative value.
  
  Tested by:Rasool Al-Saadi 
  MFC after:1 week

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.c
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.c  Fri May 19 00:43:49 2017
(r318510)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.c  Fri May 19 01:23:06 2017
(r318511)
@@ -206,6 +206,7 @@ calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
struct dn_aqm_pie_parms *pprms;
struct pie_status *pst = (struct pie_status *) x;
+   int p_isneg;
 
pprms = pst->parms;
prob = pst->drop_prob;
@@ -221,6 +222,12 @@ calculate_drop_prob(void *x)
((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); 
p +=(int64_t) pprms->beta * 
((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); 
+
+   /* take absolute value so right shift result is well defined */
+   p_isneg = p < 0;
+   if (p_isneg) {
+   p = -p;
+   }

/* We PIE_MAX_PROB shift by 12-bits to increase the division precision 
*/
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
@@ -243,37 +250,47 @@ calculate_drop_prob(void *x)
 
oldprob = prob;
 
-   /* Cap Drop adjustment */
-   if ((pprms->flags & PIE_CAPDROP_ENABLED) && prob >= PIE_MAX_PROB / 10
-   && p > PIE_MAX_PROB / 50 ) 
-   p = PIE_MAX_PROB / 50;
+   if (p_isneg) {
+   prob = prob - p;
 
-   prob = prob + p;
-
-   /* decay the drop probability exponentially */
-   if (pst->current_qdelay == 0 && pst->qdelay_old == 0)
-   /* 0.98 ~= 1- 1/64 */
-   prob = prob - (prob >> 6); 
+   /* check for multiplication underflow */
+   if (prob > oldprob) {
+   prob= 0;
+   D("underflow");
+   }
+   } else {
+   /* Cap Drop adjustment */
+   if ((pprms->flags & PIE_CAPDROP_ENABLED) &&
+   prob >= PIE_MAX_PROB / 10 &&
+   p > PIE_MAX_PROB / 50 ) {
+   p = PIE_MAX_PROB / 50;
+   }
 
+   prob = prob + p;
 
-   /* check for multiplication overflow/underflow */
-   if (p>0) {
+   /* check for multiplication overflow */
if (proboldprob) {
-   prob= 0;
-   D("underflow");
-   }
 
-   /* make drop probability between 0 and PIE_MAX_PROB*/
-   if (prob < 0)
+   /*
+* decay the drop probability exponentially
+* and restrict it to range 0 to PIE_MAX_PROB
+*/
+   if (prob < 0) {
prob = 0;
-   else if (prob > PIE_MAX_PROB)
-   prob = PIE_MAX_PROB;
+   } else {
+   if (pst->current_qdelay == 0 && pst->qdelay_old == 0) {
+   /* 0.98 ~= 1- 1/64 */
+   prob = prob - (prob >> 6); 
+   }
+
+   if (prob > PIE_MAX_PROB) {
+   prob = PIE_MAX_PROB;
+   }
+   }
 
pst->drop_prob = prob;


Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Fri May 19 00:43:49 2017
(r318510)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Fri May 19 01:23:06 2017
(r318511)
@@ -377,6 +377,7 @@ fq_calculate_drop_prob(void *x)
struct dn_aqm_pie_parms *pprms; 
int64_t p, prob, oldprob;
aqm_time_t now;
+   int p_isneg;
 
now = AQM_UNOW;
pprms = pst->parms;
@@ -393,6 +394,12 @@ fq_calculate_drop_prob(void *x)
((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); 
p +=(int64_t) 

svn commit: r317489 - stable/10/sys/netpfil/ipfw

2017-04-27 Thread Don Lewis
Author: truckman
Date: Thu Apr 27 07:32:07 2017
New Revision: 317489
URL: https://svnweb.freebsd.org/changeset/base/317489

Log:
  MFC r316777 (by cem)
  
  dummynet: Use strlcpy to appease static checkers
  
  Some dummynet modules used strcpy() to copy from a larger buffer
  (dn_aqm->name) to a smaller buffer (dn_extra_parms->name).  It happens that
  the lengths of the strings in the dn_aqm buffers were always hardcoded to be
  smaller than the dn_extra_parms buffer ("CODEL", "PIE").
  
  Use strlcpy() instead, to appease static checkers.  No functional change.
  
  Reported by:  Coverity
  CIDs: 1356163, 1356165
  Sponsored by: Dell EMC Isilon

Modified:
  stable/10/sys/netpfil/ipfw/dn_aqm_codel.c
  stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_codel.c
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_codel.c   Thu Apr 27 07:30:48 2017
(r317488)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_codel.c   Thu Apr 27 07:32:07 2017
(r317489)
@@ -416,7 +416,7 @@ aqm_codel_getconfig(struct dn_fsk *fs, s
struct dn_aqm_codel_parms *ccfg;
 
if (fs->aqmcfg) {
-   strcpy(ep->name, codel_desc.name);
+   strlcpy(ep->name, codel_desc.name, sizeof(ep->name));
ccfg = fs->aqmcfg;
ep->par[0] = ccfg->target / AQM_TIME_1US;
ep->par[1] = ccfg->interval / AQM_TIME_1US;

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu Apr 27 07:30:48 2017
(r317488)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Thu Apr 27 07:32:07 2017
(r317489)
@@ -755,7 +755,7 @@ aqm_pie_getconfig (struct dn_fsk *fs, st
 {
struct dn_aqm_pie_parms *pcfg;
if (fs->aqmcfg) {
-   strcpy(ep->name, pie_desc.name);
+   strlcpy(ep->name, pie_desc.name, sizeof(ep->name));
pcfg = fs->aqmcfg;
ep->par[0] = pcfg->qdelay_ref / AQM_TIME_1US;
ep->par[1] = pcfg->tupdate / AQM_TIME_1US;
___
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: r317488 - stable/11/sys/netpfil/ipfw

2017-04-27 Thread Don Lewis
Author: truckman
Date: Thu Apr 27 07:30:48 2017
New Revision: 317488
URL: https://svnweb.freebsd.org/changeset/base/317488

Log:
  MFC r316777 (by cem)
  
  dummynet: Use strlcpy to appease static checkers
  
  Some dummynet modules used strcpy() to copy from a larger buffer
  (dn_aqm->name) to a smaller buffer (dn_extra_parms->name).  It happens that
  the lengths of the strings in the dn_aqm buffers were always hardcoded to be
  smaller than the dn_extra_parms buffer ("CODEL", "PIE").
  
  Use strlcpy() instead, to appease static checkers.  No functional change.
  
  Reported by:  Coverity
  CIDs: 1356163, 1356165
  Sponsored by: Dell EMC Isilon

Modified:
  stable/11/sys/netpfil/ipfw/dn_aqm_codel.c
  stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_aqm_codel.c
==
--- stable/11/sys/netpfil/ipfw/dn_aqm_codel.c   Thu Apr 27 06:52:30 2017
(r317487)
+++ stable/11/sys/netpfil/ipfw/dn_aqm_codel.c   Thu Apr 27 07:30:48 2017
(r317488)
@@ -416,7 +416,7 @@ aqm_codel_getconfig(struct dn_fsk *fs, s
struct dn_aqm_codel_parms *ccfg;
 
if (fs->aqmcfg) {
-   strcpy(ep->name, codel_desc.name);
+   strlcpy(ep->name, codel_desc.name, sizeof(ep->name));
ccfg = fs->aqmcfg;
ep->par[0] = ccfg->target / AQM_TIME_1US;
ep->par[1] = ccfg->interval / AQM_TIME_1US;

Modified: stable/11/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu Apr 27 06:52:30 2017
(r317487)
+++ stable/11/sys/netpfil/ipfw/dn_aqm_pie.c Thu Apr 27 07:30:48 2017
(r317488)
@@ -755,7 +755,7 @@ aqm_pie_getconfig (struct dn_fsk *fs, st
 {
struct dn_aqm_pie_parms *pcfg;
if (fs->aqmcfg) {
-   strcpy(ep->name, pie_desc.name);
+   strlcpy(ep->name, pie_desc.name, sizeof(ep->name));
pcfg = fs->aqmcfg;
ep->par[0] = pcfg->qdelay_ref / AQM_TIME_1US;
ep->par[1] = pcfg->tupdate / AQM_TIME_1US;
___
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: r316325 - stable/10/sys/netpfil/ipfw

2017-03-31 Thread Don Lewis
Author: truckman
Date: Fri Mar 31 06:33:20 2017
New Revision: 316325
URL: https://svnweb.freebsd.org/changeset/base/316325

Log:
  MFC r315516
  
  Change several constants used by the PIE algorithm from unsigned to signed.
  
   - PIE_MAX_PROB is compared to variable of int64_t and the type promotion
 rules can cause the value of that variable to be treated as unsigned.
 If the value is actually negative, then the result of the comparsion
 is incorrect, causing the algorithm to perform poorly in some
 situations.  Changing the constant to be signed cause the comparision
 to work correctly.
  
   - PIE_SCALE is also compared to signed values.  Fortunately they are
 also compared to zero and negative values are discarded so this is
 more of a cosmetic fix.
  
   - PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
 enough that the automatic promotion to unsigned is harmless.
  
  Submitted by: Rasool Al-Saadi 

Modified:
  stable/10/sys/netpfil/ipfw/dn_aqm_pie.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_pie.h
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_pie.h Fri Mar 31 06:20:06 2017
(r316324)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_pie.h Fri Mar 31 06:33:20 2017
(r316325)
@@ -37,16 +37,16 @@
 #define DN_AQM_PIE 2
 #define PIE_DQ_THRESHOLD_BITS 14
 /* 2^14 =16KB */
-#define PIE_DQ_THRESHOLD (1UL << PIE_DQ_THRESHOLD_BITS) 
+#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) 
 #define MEAN_PKTSIZE 800
 
 /* 31-bits because random() generates range from 0->(2**31)-1 */
 #define PIE_PROB_BITS 31
-#define PIE_MAX_PROB ((1ULL<

svn commit: r316324 - stable/11/sys/netpfil/ipfw

2017-03-31 Thread Don Lewis
Author: truckman
Date: Fri Mar 31 06:20:06 2017
New Revision: 316324
URL: https://svnweb.freebsd.org/changeset/base/316324

Log:
  MFC r315516
  
  Change several constants used by the PIE algorithm from unsigned to signed.
  
   - PIE_MAX_PROB is compared to variable of int64_t and the type promotion
 rules can cause the value of that variable to be treated as unsigned.
 If the value is actually negative, then the result of the comparsion
 is incorrect, causing the algorithm to perform poorly in some
 situations.  Changing the constant to be signed cause the comparision
 to work correctly.
  
   - PIE_SCALE is also compared to signed values.  Fortunately they are
 also compared to zero and negative values are discarded so this is
 more of a cosmetic fix.
  
   - PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
 enough that the automatic promotion to unsigned is harmless.
  
  Submitted by: Rasool Al-Saadi 

Modified:
  stable/11/sys/netpfil/ipfw/dn_aqm_pie.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_aqm_pie.h
==
--- stable/11/sys/netpfil/ipfw/dn_aqm_pie.h Fri Mar 31 04:51:08 2017
(r316323)
+++ stable/11/sys/netpfil/ipfw/dn_aqm_pie.h Fri Mar 31 06:20:06 2017
(r316324)
@@ -37,16 +37,16 @@
 #define DN_AQM_PIE 2
 #define PIE_DQ_THRESHOLD_BITS 14
 /* 2^14 =16KB */
-#define PIE_DQ_THRESHOLD (1UL << PIE_DQ_THRESHOLD_BITS) 
+#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) 
 #define MEAN_PKTSIZE 800
 
 /* 31-bits because random() generates range from 0->(2**31)-1 */
 #define PIE_PROB_BITS 31
-#define PIE_MAX_PROB ((1ULL<

svn commit: r315516 - head/sys/netpfil/ipfw

2017-03-18 Thread Don Lewis
Author: truckman
Date: Sat Mar 18 23:00:13 2017
New Revision: 315516
URL: https://svnweb.freebsd.org/changeset/base/315516

Log:
  Change several constants used by the PIE algorithm from unsigned to signed.
  
   - PIE_MAX_PROB is compared to variable of int64_t and the type promotion
 rules can cause the value of that variable to be treated as unsigned.
 If the value is actually negative, then the result of the comparsion
 is incorrect, causing the algorithm to perform poorly in some
 situations.  Changing the constant to be signed cause the comparision
 to work correctly.
  
   - PIE_SCALE is also compared to signed values.  Fortunately they are
 also compared to zero and negative values are discarded so this is
 more of a cosmetic fix.
  
   - PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
 enough that the automatic promotion to unsigned is harmless.
  
  Submitted by: Rasool Al-Saadi 
  MFC after:1 week

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.h

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.h
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.h  Sat Mar 18 22:19:23 2017
(r315515)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.h  Sat Mar 18 23:00:13 2017
(r315516)
@@ -37,16 +37,16 @@
 #define DN_AQM_PIE 2
 #define PIE_DQ_THRESHOLD_BITS 14
 /* 2^14 =16KB */
-#define PIE_DQ_THRESHOLD (1UL << PIE_DQ_THRESHOLD_BITS) 
+#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) 
 #define MEAN_PKTSIZE 800
 
 /* 31-bits because random() generates range from 0->(2**31)-1 */
 #define PIE_PROB_BITS 31
-#define PIE_MAX_PROB ((1ULL<

Re: svn commit: r285050 - in head: lib/libutil usr.sbin/pwd_mkdb

2016-10-13 Thread Don Lewis
On 13 Oct, Alan Somers wrote:
> On Thu, Jul 2, 2015 at 11:31 AM, Renato Botelho  wrote:
>> Author: garga (ports committer)
>> Date: Thu Jul  2 17:30:59 2015
>> New Revision: 285050
>> URL: https://svnweb.freebsd.org/changeset/base/285050
>>
>> Log:
>>   When passwd or group information is changed (by pw, vipw, chpass, ...)
>>   temporary file is created and then a rename() call move it to official 
>> file.
>>   This operation didn't have any check to make sure data was written to disk
>>   and if a power cycle happens system could end up with a 0 length passwd
>>   or group database.
>>
>>   There is a pfSense bug with more infor about it:
>>
>>   https://redmine.pfsense.org/issues/4523
>>
>>   The following changes were made to protect passwd and group operations:
>>
>>   * lib/libutil/gr_util.c:
>>- Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
>>- After rename(), fsync() call on directory for faster result
>>
>>   * lib/libutil/pw_util.c
>>- Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
>>
>>   * usr.sbin/pwd_mkdb/pwd_mkdb.c
>>- Added O_SYNC flag on dbopen() calls
>>- After rename(), fsync() call on directory for faster result
>>
>>   * lib/libutil/pw_util.3
>>- pw_lock() returns a file descriptor to master password file on success
>>
>>   Differential Revision:https://reviews.freebsd.org/D2978
>>   Approved by:  bapt
>>   Sponsored by: Netgate
>>
>> Modified:
>>   head/lib/libutil/gr_util.c
>>   head/lib/libutil/pw_util.3
>>   head/lib/libutil/pw_util.c
>>   head/usr.sbin/pwd_mkdb/pwd_mkdb.c
> 
> This change is making certain pw operations very slow on ZFS root
> systems.  The problem is that when you open a file with O_SYNC, every
> single write(2) call turns into a zil_commit on ZFS, which is fairly
> expensive.  Did you consider using fsync(2) on the temporary files
> instead of opening them with O_SYNC?  I just tried that now, and I see
> a considerable speedup when running the tests in
> /usr/tests/usr.sbin/pw:
> 
> Using O_SYNC, as CURRENT does: 4 minutes 5.2 seconds
> No synchronous operations at all: 49.5 seconds
> Using fsync(2): 56.0 seconds

pwd_mkdb was fixed back in February with by switching to fsync() in
r295925.  It looks like libutil was not fixed, though.


___
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: r302987 - stable/10/sys/netpfil/ipfw

2016-07-18 Thread Don Lewis
Author: truckman
Date: Mon Jul 18 06:09:52 2016
New Revision: 302987
URL: https://svnweb.freebsd.org/changeset/base/302987

Log:
  MFC r302667
  
  Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
  cause a crash.
  
  Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
  is not able to use callout_drain() to make sure that all callouts are
  finished before it returns, and callout_stop() is not sufficient to make
  that guarantee.  After pie_cleanup() returns, dummynet will free a
  structure that any remaining callouts will want to access.
  
  Fix these problems by allocating a separate structure to contain the
  data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
  to replace the normal callout with a cleanup callout that does the cleanup
  work for each sub-queue.  The instance of the cleanup callout that
  destroys the last flow will also free the extra allocated block of memory.
  Protect the reference count manipulation in the cleanup callout with
  DN_BH_WLOCK() to be consistent with all of the other usage of the reference
  count where this lock is held by the dummynet code.
  
  Submitted by: Rasool Al-Saadi 
  Differential Revision:https://reviews.freebsd.org/D7174

Modified:
  stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cMon Jul 18 05:36:31 
2016(r302986)
+++ stable/10/sys/netpfil/ipfw/dn_sched_fq_pie.cMon Jul 18 06:09:52 
2016(r302987)
@@ -111,7 +111,7 @@ struct fq_pie_flow {
int deficit;
int active; /* 1: flow is active (in a list) */
struct pie_status pst;  /* pie status variables */
-   struct fq_pie_si *psi;  /* parent scheduler instance */
+   struct fq_pie_si_extra *psi_extra;
STAILQ_ENTRY(fq_pie_flow) flowchain;
 };
 
@@ -120,23 +120,30 @@ struct fq_pie_schk {
struct dn_sch_fq_pie_parms cfg;
 };
 
+
+/* fq_pie scheduler instance extra state vars.
+ * The purpose of separation this structure is to preserve number of active
+ * sub-queues and the flows array pointer even after the scheduler instance
+ * is destroyed.
+ * Preserving these varaiables allows freeing the allocated memory by
+ * fqpie_callout_cleanup() independently from fq_pie_free_sched().
+ */
+struct fq_pie_si_extra {
+   uint32_t nr_active_q;   /* number of active queues */
+   struct fq_pie_flow *flows;  /* array of flows (queues) */
+   };
+
 /* fq_pie scheduler instance */
 struct fq_pie_si {
-   struct dn_sch_inst _si; /* standard scheduler instance */
+   struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST 
*/ 
struct dn_queue main_q; /* main queue is after si directly */
-   uint32_t nr_active_q;
-   struct fq_pie_flow *flows;  /* array of flows (queues) */
uint32_t perturbation;  /* random value */
struct fq_pie_list newflows;/* list of new queues */
struct fq_pie_list oldflows;/* list of old queues */
+   struct fq_pie_si_extra *si_extra; /* extra state vars*/
 };
 
 
-struct mem_to_free {
-   void *mem_flows;
-   void *mem_callout;
-};
-static struct mtx freemem_mtx;
 static struct dn_alg fq_pie_desc;
 
 /*  Default FQ-PIE parameters including PIE */
@@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
aqm_time_t now;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   q->psi->nr_active_q--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
now = AQM_UNOW;
pprms = pst->parms;
prob = pst->drop_prob;
@@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst
   * Initialize PIE for sub-queue 'q'
   */
 static int
-pie_init(struct fq_pie_flow *q)
+pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk)
 {
struct pie_status *pst=>pst;
struct dn_aqm_pie_parms *pprms = pst->parms;
-   struct fq_pie_schk *fqpie_schk;
-   
-   fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1);
-   int err = 0;
 
+   int err = 0;
if (!pprms){
D("AQM_PIE is not configured");
err = EINVAL;
} else {
-   q->psi->nr_active_q++;
+   q->psi_extra->nr_active_q++;
 
/* For speed optimization, we caculate 1/3 queue size once here 
*/
// XXX 

svn commit: r302927 - stable/11/sys/netpfil/ipfw

2016-07-16 Thread Don Lewis
Author: truckman
Date: Sat Jul 16 06:41:02 2016
New Revision: 302927
URL: https://svnweb.freebsd.org/changeset/base/302927

Log:
  MFC r302667
  
  Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
  cause a crash.
  
  Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
  is not able to use callout_drain() to make sure that all callouts are
  finished before it returns, and callout_stop() is not sufficient to make
  that guarantee.  After pie_cleanup() returns, dummynet will free a
  structure that any remaining callouts will want to access.
  
  Fix these problems by allocating a separate structure to contain the
  data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
  to replace the normal callout with a cleanup callout that does the cleanup
  work for each sub-queue.  The instance of the cleanup callout that
  destroys the last flow will also free the extra allocated block of memory.
  Protect the reference count manipulation in the cleanup callout with
  DN_BH_WLOCK() to be consistent with all of the other usage of the reference
  count where this lock is held by the dummynet code.
  
  Submitted by: Rasool Al-Saadi 
  Approved by:  re (gjb)
  Differential Revision:https://reviews.freebsd.org/D7174

Modified:
  stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSat Jul 16 02:57:37 
2016(r302926)
+++ stable/11/sys/netpfil/ipfw/dn_sched_fq_pie.cSat Jul 16 06:41:02 
2016(r302927)
@@ -111,7 +111,7 @@ struct fq_pie_flow {
int deficit;
int active; /* 1: flow is active (in a list) */
struct pie_status pst;  /* pie status variables */
-   struct fq_pie_si *psi;  /* parent scheduler instance */
+   struct fq_pie_si_extra *psi_extra;
STAILQ_ENTRY(fq_pie_flow) flowchain;
 };
 
@@ -120,23 +120,30 @@ struct fq_pie_schk {
struct dn_sch_fq_pie_parms cfg;
 };
 
+
+/* fq_pie scheduler instance extra state vars.
+ * The purpose of separation this structure is to preserve number of active
+ * sub-queues and the flows array pointer even after the scheduler instance
+ * is destroyed.
+ * Preserving these varaiables allows freeing the allocated memory by
+ * fqpie_callout_cleanup() independently from fq_pie_free_sched().
+ */
+struct fq_pie_si_extra {
+   uint32_t nr_active_q;   /* number of active queues */
+   struct fq_pie_flow *flows;  /* array of flows (queues) */
+   };
+
 /* fq_pie scheduler instance */
 struct fq_pie_si {
-   struct dn_sch_inst _si; /* standard scheduler instance */
+   struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST 
*/ 
struct dn_queue main_q; /* main queue is after si directly */
-   uint32_t nr_active_q;
-   struct fq_pie_flow *flows;  /* array of flows (queues) */
uint32_t perturbation;  /* random value */
struct fq_pie_list newflows;/* list of new queues */
struct fq_pie_list oldflows;/* list of old queues */
+   struct fq_pie_si_extra *si_extra; /* extra state vars*/
 };
 
 
-struct mem_to_free {
-   void *mem_flows;
-   void *mem_callout;
-};
-static struct mtx freemem_mtx;
 static struct dn_alg fq_pie_desc;
 
 /*  Default FQ-PIE parameters including PIE */
@@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
aqm_time_t now;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   q->psi->nr_active_q--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
now = AQM_UNOW;
pprms = pst->parms;
prob = pst->drop_prob;
@@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst
   * Initialize PIE for sub-queue 'q'
   */
 static int
-pie_init(struct fq_pie_flow *q)
+pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk)
 {
struct pie_status *pst=>pst;
struct dn_aqm_pie_parms *pprms = pst->parms;
-   struct fq_pie_schk *fqpie_schk;
-   
-   fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1);
-   int err = 0;
 
+   int err = 0;
if (!pprms){
D("AQM_PIE is not configured");
err = EINVAL;
} else {
-   q->psi->nr_active_q++;
+   q->psi_extra->nr_active_q++;
 
/* For speed optimization, we caculate 1/3 queue size once here 

svn commit: r302667 - head/sys/netpfil/ipfw

2016-07-12 Thread Don Lewis
Author: truckman
Date: Tue Jul 12 17:32:40 2016
New Revision: 302667
URL: https://svnweb.freebsd.org/changeset/base/302667

Log:
  Fix problems in the FQ-PIE AQM cleanup code that could leak memory or
  cause a crash.
  
  Because dummynet calls pie_cleanup() while holding a mutex, pie_cleanup()
  is not able to use callout_drain() to make sure that all callouts are
  finished before it returns, and callout_stop() is not sufficient to make
  that guarantee.  After pie_cleanup() returns, dummynet will free a
  structure that any remaining callouts will want to access.
  
  Fix these problems by allocating a separate structure to contain the
  data used by the callouts.  In pie_cleanup(), call callout_reset_sbt()
  to replace the normal callout with a cleanup callout that does the cleanup
  work for each sub-queue.  The instance of the cleanup callout that
  destroys the last flow will also free the extra allocated block of memory.
  Protect the reference count manipulation in the cleanup callout with
  DN_BH_WLOCK() to be consistent with all of the other usage of the reference
  count where this lock is held by the dummynet code.
  
  Submitted by: Rasool Al-Saadi 
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D7174

Modified:
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c

Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Tue Jul 12 17:30:37 2016
(r302666)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Tue Jul 12 17:32:40 2016
(r302667)
@@ -111,7 +111,7 @@ struct fq_pie_flow {
int deficit;
int active; /* 1: flow is active (in a list) */
struct pie_status pst;  /* pie status variables */
-   struct fq_pie_si *psi;  /* parent scheduler instance */
+   struct fq_pie_si_extra *psi_extra;
STAILQ_ENTRY(fq_pie_flow) flowchain;
 };
 
@@ -120,23 +120,30 @@ struct fq_pie_schk {
struct dn_sch_fq_pie_parms cfg;
 };
 
+
+/* fq_pie scheduler instance extra state vars.
+ * The purpose of separation this structure is to preserve number of active
+ * sub-queues and the flows array pointer even after the scheduler instance
+ * is destroyed.
+ * Preserving these varaiables allows freeing the allocated memory by
+ * fqpie_callout_cleanup() independently from fq_pie_free_sched().
+ */
+struct fq_pie_si_extra {
+   uint32_t nr_active_q;   /* number of active queues */
+   struct fq_pie_flow *flows;  /* array of flows (queues) */
+   };
+
 /* fq_pie scheduler instance */
 struct fq_pie_si {
-   struct dn_sch_inst _si; /* standard scheduler instance */
+   struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST 
*/ 
struct dn_queue main_q; /* main queue is after si directly */
-   uint32_t nr_active_q;
-   struct fq_pie_flow *flows;  /* array of flows (queues) */
uint32_t perturbation;  /* random value */
struct fq_pie_list newflows;/* list of new queues */
struct fq_pie_list oldflows;/* list of old queues */
+   struct fq_pie_si_extra *si_extra; /* extra state vars*/
 };
 
 
-struct mem_to_free {
-   void *mem_flows;
-   void *mem_callout;
-};
-static struct mtx freemem_mtx;
 static struct dn_alg fq_pie_desc;
 
 /*  Default FQ-PIE parameters including PIE */
@@ -371,22 +378,6 @@ fq_calculate_drop_prob(void *x)
int64_t p, prob, oldprob;
aqm_time_t now;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   q->psi->nr_active_q--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
now = AQM_UNOW;
pprms = pst->parms;
prob = pst->drop_prob;
@@ -524,20 +515,17 @@ fq_deactivate_pie(struct pie_status *pst
   * Initialize PIE for sub-queue 'q'
   */
 static int
-pie_init(struct fq_pie_flow *q)
+pie_init(struct fq_pie_flow *q, struct fq_pie_schk *fqpie_schk)
 {
struct pie_status *pst=>pst;
struct dn_aqm_pie_parms *pprms = pst->parms;
-   struct fq_pie_schk *fqpie_schk;
-   
-   fqpie_schk = (struct fq_pie_schk *)(q->psi->_si.sched+1);
-   int err = 0;
 
+   int err = 0;
if (!pprms){
D("AQM_PIE is not configured");
err = EINVAL;
} else {
-   q->psi->nr_active_q++;
+   q->psi_extra->nr_active_q++;
 
/* For speed optimization, we caculate 1/3 queue size once here 
*/
// XXX limit divided by number of queues divided by 3 ??? 
@@ -553,8 +541,36 @@ 

svn commit: r302422 - stable/10/sys/netpfil/ipfw

2016-07-07 Thread Don Lewis
Author: truckman
Date: Fri Jul  8 02:52:39 2016
New Revision: 302422
URL: https://svnweb.freebsd.org/changeset/base/302422

Log:
  MFC r302338
  
  Fix a race condition between the main thread in aqm_pie_cleanup() and the
  callout thread that can cause a kernel panic.  Always do the final cleanup
  in the callout thread by passing a separate callout function for that task
  to callout_reset_sbt().
  
  Protect the ref_count decrement in the callout with DN_BH_WLOCK().  All
  other ref_count manipulation is protected with this lock.
  
  There is still a tiny window between ref_count reaching zero and the end
  of the callout function where it is unsafe to unload the module.  Fixing
  this would require the use of callout_drain(), but this can't be done
  because dummynet holds a mutex and callout_drain() might sleep.
  
  Remove the callout_pending(), callout_active(), and callout_deactivate()
  calls from calculate_drop_prob().  They are not needed because this callout
  uses callout_init_mtx().
  
  Submitted by: Rasool Al-Saadi 
  Differential Revision:https://reviews.freebsd.org/D6928

Modified:
  stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Fri Jul  8 02:34:04 2016
(r302421)
+++ stable/10/sys/netpfil/ipfw/dn_aqm_pie.c Fri Jul  8 02:52:39 2016
(r302422)
@@ -207,24 +207,6 @@ calculate_drop_prob(void *x)
struct dn_aqm_pie_parms *pprms;
struct pie_status *pst = (struct pie_status *) x;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   free(x, M_DUMMYNET);
-   //pst->pq->aqm_status = NULL;
-   pie_desc.ref_count--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
pprms = pst->parms;
prob = pst->drop_prob;
 
@@ -576,7 +558,7 @@ aqm_pie_init(struct dn_queue *q)

do { /* exit with break when error occurs*/
if (!pprms){
-   D("AQM_PIE is not configured");
+   DX(2, "AQM_PIE is not configured");
err = EINVAL;
break;
}
@@ -615,6 +597,22 @@ aqm_pie_init(struct dn_queue *q)
 }
 
 /* 
+ * Callout function to destroy pie mtx and free PIE status memory
+ */
+static void
+pie_callout_cleanup(void *x)
+{
+   struct pie_status *pst = (struct pie_status *) x;
+
+   mtx_unlock(>lock_mtx);
+   mtx_destroy(>lock_mtx);
+   free(x, M_DUMMYNET);
+   DN_BH_WLOCK();
+   pie_desc.ref_count--;
+   DN_BH_WUNLOCK();
+}
+
+/* 
  * Clean up PIE status for queue 'q' 
  * Destroy memory allocated for PIE status.
  */
@@ -640,22 +638,19 @@ aqm_pie_cleanup(struct dn_queue *q)
return 1;
}
 
+   /* 
+* Free PIE status allocated memory using pie_callout_cleanup() callout
+* function to avoid any potential race.
+* We reset aqm_pie_callout to call pie_callout_cleanup() in next 1um. 
This
+* stops the scheduled calculate_drop_prob() callout and call 
pie_callout_cleanup() 
+* which does memory freeing.
+*/
mtx_lock(>lock_mtx);
+   callout_reset_sbt(>aqm_pie_callout,
+   SBT_1US, 0, pie_callout_cleanup, pst, 0);
+   q->aqm_status = NULL;
+   mtx_unlock(>lock_mtx);
 
-   /* stop callout timer */
-   if (callout_stop(>aqm_pie_callout) || !(pst->sflags & PIE_ACTIVE)) 
{
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   free(q->aqm_status, M_DUMMYNET);
-   q->aqm_status = NULL;
-   pie_desc.ref_count--;
-   return 0;
-   } else {
-   q->aqm_status = NULL;
-   mtx_unlock(>lock_mtx);
-   DX(2, "PIE callout has not been stoped from cleanup!");
-   return EBUSY;
-   }
return 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: r302377 - in stable/10: lib/libcam sbin/camcontrol sbin/iscontrol sys/cam usr.sbin/camdd usr.sbin/mptutil

2016-07-06 Thread Don Lewis
Author: truckman
Date: Wed Jul  6 17:45:38 2016
New Revision: 302377
URL: https://svnweb.freebsd.org/changeset/base/302377

Log:
  MFC r300547
  
  Fix multiple Coverity Out-of-bounds access false postive issues in CAM
  
  The currently used idiom for clearing the part of a ccb after its
  header generates one or two Coverity errors for each time it is
  used.  All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
  error because of the treatment of the header as a two element array,
  with a pointer to the non-existent second element being passed as
  the starting address to bzero().  Some instances also alsp generate
  Out-of-bounds access (OVERRUN) errors, probably because the space
  being cleared is larger than the sizeofstruct ccb_hdr).
  
  In addition, this idiom is difficult for humans to understand and
  it is error prone.  The user has to chose the proper struct ccb_*
  type (which does not appear in the surrounding code) for the sizeof()
  in the length calculation.  I found several instances where the
  length was incorrect, which could cause either an actual out of
  bounds write, or incompletely clear the ccb.
  
  A better way is to write the code to clear the ccb itself starting
  at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
  the length based on the specific type of struct ccb_* being cleared
  as specified by the union ccb member being used.  The latter can
  normally be seen in the nearby code.  This is friendlier for Coverity
  and other static analysis tools because they will see that the
  intent is to clear the trailing part of the ccb.
  
  Wrap all of the boilerplate code in a convenient macro that only
  requires a pointer to the desired union ccb member (or a pointer
  to the union ccb itself) as an argument.
  
  Reported by:  Coverity
  CID:  1007578, 1008684, 1009724, 1009773, 1011304, 1011306
  CID:  1011307, 1011308, 1011309, 1011310, 1011311, 1011312
  CID:  1011313, 1011314, 1011315, 1011316, 1011317, 1011318
  CID:  1011319, 1011320, 1011321, 1011322, 1011324, 1011325
  CID:  1011326, 1011327, 1011328, 1011329, 1011330, 1011374
  CID:  1011390, 1011391, 1011392, 1011393, 1011394, 1011395
  CID:  1011396, 1011397, 1011398, 1011399, 1011400, 1011401
  CID:  1011402, 1011403, 1011404, 1011405, 1011406, 1011408
  CID:  1011409, 1011410, 1011411, 1011412, 1011413, 1011414
  CID:  1017461, 1018387, 1086860, 1086874, 1194257, 1229897
  CID:  1229968, 1306229, 1306234, 1331282, 1331283, 1331294
  CID:  1331295, 1331535, 1331536, 1331539, 1331540, 1341623
  CID:  1341624, 1341637, 1341638, 1355264, 1355324
  Reviewed by:  scottl, ken, delphij, imp
  MFH:  1 month
  Differential Revision:https://reviews.freebsd.org/D6496

Modified:
  stable/10/lib/libcam/camlib.c
  stable/10/sbin/camcontrol/attrib.c
  stable/10/sbin/camcontrol/camcontrol.c
  stable/10/sbin/camcontrol/fwdownload.c
  stable/10/sbin/camcontrol/persist.c
  stable/10/sbin/iscontrol/fsm.c
  stable/10/sys/cam/cam_ccb.h
  stable/10/usr.sbin/camdd/camdd.c
  stable/10/usr.sbin/mptutil/mpt_cam.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libcam/camlib.c
==
--- stable/10/lib/libcam/camlib.c   Wed Jul  6 17:42:09 2016
(r302376)
+++ stable/10/lib/libcam/camlib.c   Wed Jul  6 17:45:38 2016
(r302377)
@@ -619,7 +619,7 @@ cam_real_open_device(const char *path, i
/*
 * Zero the payload, the kernel does look at the flags.
 */
-   bzero(&(_h)[1], sizeof(struct ccb_trans_settings));
+   CCB_CLEAR_ALL_EXCEPT_HDR();
 
/*
 * Get transfer settings for this device.

Modified: stable/10/sbin/camcontrol/attrib.c
==
--- stable/10/sbin/camcontrol/attrib.c  Wed Jul  6 17:42:09 2016
(r302376)
+++ stable/10/sbin/camcontrol/attrib.c  Wed Jul  6 17:45:38 2016
(r302377)
@@ -137,8 +137,7 @@ scsiattrib(struct cam_device *device, in
goto bailout;
}
 
-   bzero(&(>ccb_h)[1],
- sizeof(union ccb) - sizeof(struct ccb_hdr));
+   CCB_CLEAR_ALL_EXCEPT_HDR(>csio);
 
STAILQ_INIT(_attr_list);
 

Modified: stable/10/sbin/camcontrol/camcontrol.c
==
--- stable/10/sbin/camcontrol/camcontrol.c  Wed Jul  6 17:42:09 2016
(r302376)
+++ stable/10/sbin/camcontrol/camcontrol.c  Wed Jul  6 17:45:38 2016
(r302377)
@@ -838,8 +838,7 @@ scsiinquiry(struct cam_device *device, i
}
 
/* cam_getccb cleans up the header, caller has to zero the payload */
-   bzero(&(>ccb_h)[1],
- sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
+   CCB_CLEAR_ALL_EXCEPT_HDR(>csio);
 
  

svn commit: r302376 - in stable/10: sbin/camcontrol sys/cam sys/cam/scsi

2016-07-06 Thread Don Lewis
Author: truckman
Date: Wed Jul  6 17:42:09 2016
New Revision: 302376
URL: https://svnweb.freebsd.org/changeset/base/302376

Log:
  MFC r299371 (by trasz)
  
  Add "camcontrol reprobe" subcommand, and implement it for da(4).
  This makes it possible to manually force updating capacity data
  after the disk got resized. Without it it might be neccessary to
  reboot before FreeBSD notices updated disk size under eg VMWare.
  
  Differential Revision:https://reviews.freebsd.org/D6108

Modified:
  stable/10/sbin/camcontrol/camcontrol.8
  stable/10/sbin/camcontrol/camcontrol.c
  stable/10/sys/cam/cam_ccb.h
  stable/10/sys/cam/cam_xpt.c
  stable/10/sys/cam/scsi/scsi_da.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/camcontrol/camcontrol.8
==
--- stable/10/sbin/camcontrol/camcontrol.8  Wed Jul  6 16:20:10 2016
(r302375)
+++ stable/10/sbin/camcontrol/camcontrol.8  Wed Jul  6 17:42:09 2016
(r302376)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 6, 2015
+.Dd April 26, 2016
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -98,6 +98,9 @@
 .Op device id
 .Op generic args
 .Nm
+.Ic reprobe
+.Op device id
+.Nm
 .Ic rescan
 .Aq all | bus Ns Op :target:lun
 .Nm
@@ -518,6 +521,12 @@ are not specified).
 Print out the last logical block or the size of the device only, and omit
 the blocksize.
 .El
+.Pp
+Note that this command only displays the information, it does not update
+the kernel data structures.
+Use the
+.Nm 
+reprobe subcommand to do that.
 .It Ic start
 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
 start bit set.
@@ -539,6 +548,12 @@ The user
 may specify a scan of all busses, a single bus, or a lun.
 Scanning all luns
 on a target is not supported.
+.It Ic reprobe
+Tell the kernel to refresh the information about the device and
+notify the upper layer,
+.Xr GEOM 4 .
+This includes sending the SCSI READ CAPACITY command and updating
+the disk size visible to the rest of the system.
 .It Ic reset
 Tell the kernel to reset all busses in the system (with the
 .Ar all

Modified: stable/10/sbin/camcontrol/camcontrol.c
==
--- stable/10/sbin/camcontrol/camcontrol.c  Wed Jul  6 16:20:10 2016
(r302375)
+++ stable/10/sbin/camcontrol/camcontrol.c  Wed Jul  6 17:42:09 2016
(r302376)
@@ -100,7 +100,8 @@ typedef enum {
CAM_CMD_APM = 0x0021,
CAM_CMD_AAM = 0x0022,
CAM_CMD_ATTRIB  = 0x0023,
-   CAM_CMD_OPCODES = 0x0024
+   CAM_CMD_OPCODES = 0x0024,
+   CAM_CMD_REPROBE = 0x0025
 } cam_cmdmask;
 
 typedef enum {
@@ -190,6 +191,7 @@ static struct camcontrol_opts option_tab
{"eject", CAM_CMD_STARTSTOP, CAM_ARG_EJECT, NULL},
{"reportluns", CAM_CMD_REPORTLUNS, CAM_ARG_NONE, "clr:"},
{"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHNqs"},
+   {"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL},
 #endif /* MINIMALISTIC */
{"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL},
{"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL},
@@ -328,6 +330,7 @@ static int scsiprintopcodes(struct cam_d
 static int scsiopcodes(struct cam_device *device, int argc, char **argv,
   char *combinedopt, int retry_count, int timeout,
   int verbose);
+static int scsireprobe(struct cam_device *device);
 
 #endif /* MINIMALISTIC */
 #ifndef min
@@ -8662,6 +8665,42 @@ bailout:
 
 #endif /* MINIMALISTIC */
 
+static int
+scsireprobe(struct cam_device *device)
+{
+   union ccb *ccb;
+   int retval = 0;
+
+   ccb = cam_getccb(device);
+
+   if (ccb == NULL) {
+   warnx("%s: error allocating ccb", __func__);
+   return (1);
+   }
+
+   bzero(&(>ccb_h)[1],
+ sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
+
+   ccb->ccb_h.func_code = XPT_REPROBE_LUN;
+
+   if (cam_send_ccb(device, ccb) < 0) {
+   warn("error sending XPT_REPROBE_LUN CCB");
+   retval = 1;
+   goto bailout;
+   }
+
+   if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+   cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr);
+   retval = 1;
+   goto bailout;
+   }
+
+bailout:
+   cam_freeccb(ccb);
+
+   return (retval);
+}
+
 void
 usage(int printlong)
 {
@@ -8681,6 +8720,7 @@ usage(int printlong)
 "camcontrol stop   [dev_id][generic args]\n"
 "camcontrol load   [dev_id][generic args]\n"
 "camcontrol eject  [dev_id][generic args]\n"
+"camcontrol reprobe[dev_id][generic args]\n"
 #endif /* MINIMALISTIC */
 "camcontrol rescan \n"
 "camcontrol reset  \n"
@@ -8753,6 +8793,7 @@ usage(int printlong)
 "stop

svn commit: r302338 - head/sys/netpfil/ipfw

2016-07-04 Thread Don Lewis
Author: truckman
Date: Tue Jul  5 00:53:01 2016
New Revision: 302338
URL: https://svnweb.freebsd.org/changeset/base/302338

Log:
  Fix a race condition between the main thread in aqm_pie_cleanup() and the
  callout thread that can cause a kernel panic.  Always do the final cleanup
  in the callout thread by passing a separate callout function for that task
  to callout_reset_sbt().
  
  Protect the ref_count decrement in the callout with DN_BH_WLOCK().  All
  other ref_count manipulation is protected with this lock.
  
  There is still a tiny window between ref_count reaching zero and the end
  of the callout function where it is unsafe to unload the module.  Fixing
  this would require the use of callout_drain(), but this can't be done
  because dummynet holds a mutex and callout_drain() might sleep.
  
  Remove the callout_pending(), callout_active(), and callout_deactivate()
  calls from calculate_drop_prob().  They are not needed because this callout
  uses callout_init_mtx().
  
  Submitted by: Rasool Al-Saadi 
  Approved by:  re (gjb)
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D6928

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.c

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.c  Mon Jul  4 21:18:57 2016
(r302337)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.c  Tue Jul  5 00:53:01 2016
(r302338)
@@ -207,24 +207,6 @@ calculate_drop_prob(void *x)
struct dn_aqm_pie_parms *pprms;
struct pie_status *pst = (struct pie_status *) x;
 
-   /* dealing with race condition */
-   if (callout_pending(>aqm_pie_callout)) {
-   /* callout was reset */
-   mtx_unlock(>lock_mtx);
-   return;
-   }
-
-   if (!callout_active(>aqm_pie_callout)) {
-   /* callout was stopped */
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   free(x, M_DUMMYNET);
-   //pst->pq->aqm_status = NULL;
-   pie_desc.ref_count--;
-   return;
-   }
-   callout_deactivate(>aqm_pie_callout);
-
pprms = pst->parms;
prob = pst->drop_prob;
 
@@ -576,7 +558,7 @@ aqm_pie_init(struct dn_queue *q)

do { /* exit with break when error occurs*/
if (!pprms){
-   D("AQM_PIE is not configured");
+   DX(2, "AQM_PIE is not configured");
err = EINVAL;
break;
}
@@ -615,6 +597,22 @@ aqm_pie_init(struct dn_queue *q)
 }
 
 /* 
+ * Callout function to destroy pie mtx and free PIE status memory
+ */
+static void
+pie_callout_cleanup(void *x)
+{
+   struct pie_status *pst = (struct pie_status *) x;
+
+   mtx_unlock(>lock_mtx);
+   mtx_destroy(>lock_mtx);
+   free(x, M_DUMMYNET);
+   DN_BH_WLOCK();
+   pie_desc.ref_count--;
+   DN_BH_WUNLOCK();
+}
+
+/* 
  * Clean up PIE status for queue 'q' 
  * Destroy memory allocated for PIE status.
  */
@@ -640,22 +638,19 @@ aqm_pie_cleanup(struct dn_queue *q)
return 1;
}
 
+   /* 
+* Free PIE status allocated memory using pie_callout_cleanup() callout
+* function to avoid any potential race.
+* We reset aqm_pie_callout to call pie_callout_cleanup() in next 1um. 
This
+* stops the scheduled calculate_drop_prob() callout and call 
pie_callout_cleanup() 
+* which does memory freeing.
+*/
mtx_lock(>lock_mtx);
+   callout_reset_sbt(>aqm_pie_callout,
+   SBT_1US, 0, pie_callout_cleanup, pst, 0);
+   q->aqm_status = NULL;
+   mtx_unlock(>lock_mtx);
 
-   /* stop callout timer */
-   if (callout_stop(>aqm_pie_callout) || !(pst->sflags & PIE_ACTIVE)) 
{
-   mtx_unlock(>lock_mtx);
-   mtx_destroy(>lock_mtx);
-   free(q->aqm_status, M_DUMMYNET);
-   q->aqm_status = NULL;
-   pie_desc.ref_count--;
-   return 0;
-   } else {
-   q->aqm_status = NULL;
-   mtx_unlock(>lock_mtx);
-   DX(2, "PIE callout has not been stoped from cleanup!");
-   return EBUSY;
-   }
return 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: r302032 - stable/10/sys/netinet

2016-06-20 Thread Don Lewis
Author: truckman
Date: Mon Jun 20 19:00:47 2016
New Revision: 302032
URL: https://svnweb.freebsd.org/changeset/base/302032

Log:
  MFC r300240
  
  Change net.inet.tcp.ecn.enable sysctl mib from a binary off/on
  control to a three way setting.
0 - Totally disable ECN. (no change)
1 - Enable ECN if incoming connections request it.  Outgoing
connections will request ECN.  (no change from present != 0 setting)
2 - Enable ECN if incoming connections request it.  Outgoing
conections will not request ECN.
  
  Change the default value of net.inet.tcp.ecn.enable from 0 to 2.
  
  Linux version 2.4.20 and newer, Solaris, and Mac OS X 10.5 and newer have
  similar capabilities.  The actual values above match Linux, and the default
  matches the current Linux default.
  
  Reviewed by:  eadler
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D6386

Modified:
  stable/10/sys/netinet/tcp_input.c
  stable/10/sys/netinet/tcp_output.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/tcp_input.c
==
--- stable/10/sys/netinet/tcp_input.c   Mon Jun 20 18:14:51 2016
(r302031)
+++ stable/10/sys/netinet/tcp_input.c   Mon Jun 20 19:00:47 2016
(r302032)
@@ -184,7 +184,7 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO,
 
 static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
 
-VNET_DEFINE(int, tcp_do_ecn) = 0;
+VNET_DEFINE(int, tcp_do_ecn) = 2;
 SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_RW,
 _NAME(tcp_do_ecn), 0,
 "TCP ECN support");

Modified: stable/10/sys/netinet/tcp_output.c
==
--- stable/10/sys/netinet/tcp_output.c  Mon Jun 20 18:14:51 2016
(r302031)
+++ stable/10/sys/netinet/tcp_output.c  Mon Jun 20 19:00:47 2016
(r302032)
@@ -1109,7 +1109,7 @@ send:
 * resend those bits a number of times as per
 * RFC 3168.
 */
-   if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn) {
+   if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn == 1) {
if (tp->t_rxtshift >= 1) {
if (tp->t_rxtshift <= V_tcp_ecn_maxretries)
flags |= TH_ECE|TH_CWR;
___
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: r301917 - stable/10/games/random

2016-06-15 Thread Don Lewis
Author: truckman
Date: Wed Jun 15 06:27:43 2016
New Revision: 301917
URL: https://svnweb.freebsd.org/changeset/base/301917

Log:
  MFC r299484, r301574
  
  r299484 | cem | 2016-05-11 15:04:28 -0700 (Wed, 11 May 2016) | 13 lines
  
  random(6): Fix double-close
  
  In the case where a file lacks a trailing newline, there is some "evil" code 
to
  reverse goto the tokenizing code ("make_token") for the final token in the
  file.  In this case, 'fd' is closed more than once.  Use a negative sentinel
  value to guard close(2), preventing the double close.
  
  Ideally, this code would be restructured to avoid this ugly construction.
  
  r301574 | truckman | 2016-06-07 19:14:05 -0700 (Tue, 07 Jun 2016) | 15 lines
  
  Fix a (false positive?) Argument cannot be negative coverity defect.
  
  Rather than guarding close(fd) with an fd >= 0 test and setting fd
  to -1 when it is closed to avoid a potential double-close, just
  move the close() call after the conditional "goto make_token".  This
  moves the close() call totally outside the loop to avoid the
  possibility of calling it twice.  This should also prevent a Coverity
  warning about checking fd for validity after it was previously passed
  to read().
  
  Reported by:  Coverity
  CID:  1006123, 1355335

Modified:
  stable/10/games/random/randomize_fd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/games/random/randomize_fd.c
==
--- stable/10/games/random/randomize_fd.c   Wed Jun 15 06:08:05 2016
(r301916)
+++ stable/10/games/random/randomize_fd.c   Wed Jun 15 06:27:43 2016
(r301917)
@@ -174,7 +174,7 @@ randomize_fd(int fd, int type, int uniqu
if ((type == RANDOM_TYPE_LINES && buf[i] == '\n') ||
(type == RANDOM_TYPE_WORDS && isspace(buf[i])) ||
(eof && i == buflen - 1)) {
-   make_token:
+make_token:
if (numnode == RANDOM_MAX_PLUS1) {
errno = EFBIG;
err(1, "too many delimiters");
@@ -199,14 +199,14 @@ randomize_fd(int fd, int type, int uniqu
}
}
 
-   (void)close(fd);
-
/* Necessary evil to compensate for files that don't end with a newline 
*/
if (bufc != i) {
i--;
goto make_token;
}
 
+   (void)close(fd);
+
free(buf);
 
for (i = numnode; i > 0; i--) {
___
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: r301921 - stable/10/lib/libc/gen

2016-06-15 Thread Don Lewis
Author: truckman
Date: Wed Jun 15 06:42:30 2016
New Revision: 301921
URL: https://svnweb.freebsd.org/changeset/base/301921

Log:
  MFC r301596
  
  Don't leak olinep if malloc() fails.
  
  If malloc() fails to allocate linep, then free olinep (if it exists)
  before returning to avoid a memory leak.
  
  Reported by:  Coverity
  CID:  1016716
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D6755

Modified:
  stable/10/lib/libc/gen/getnetgrent.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/getnetgrent.c
==
--- stable/10/lib/libc/gen/getnetgrent.cWed Jun 15 06:40:30 2016
(r301920)
+++ stable/10/lib/libc/gen/getnetgrent.cWed Jun 15 06:42:30 2016
(r301921)
@@ -615,6 +615,8 @@ read_for_group(const char *group)
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
+   if (olen > 0)
+   free(olinep);
return (NULL);
}
if (olen > 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: r301920 - stable/10/lib/libc/resolv

2016-06-15 Thread Don Lewis
Author: truckman
Date: Wed Jun 15 06:40:30 2016
New Revision: 301920
URL: https://svnweb.freebsd.org/changeset/base/301920

Log:
  MFC r301592
  
  Don't leak addrinfo if ai->ai_addrlen <= minsiz test fails.
  
  If the ai->ai_addrlen <= minsiz test fails, then freeaddrinfo()
  does not get called to free the memory just allocated by getaddrinfo().
  Fix by moving ai->ai_addrlen <= minsiz to a separate nested if
  block, and keep freeaddrinfo() in the outer block so that freeaddrinfo()
  will be called whenever getaddrinfo() succeeds.
  
  Reported by:  Coverity
  CID:  1273652
  Reviewed by:  ume
  Differential Revision:https://reviews.freebsd.org/D6756

Modified:
  stable/10/lib/libc/resolv/res_init.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/resolv/res_init.c
==
--- stable/10/lib/libc/resolv/res_init.cWed Jun 15 06:33:40 2016
(r301919)
+++ stable/10/lib/libc/resolv/res_init.cWed Jun 15 06:40:30 2016
(r301920)
@@ -412,20 +412,21 @@ __res_vinit(res_state statp, int preinit
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%u", NAMESERVER_PORT);
-   if (getaddrinfo(cp, sbuf, , ) == 0 &&
-   ai->ai_addrlen <= minsiz) {
-   if (statp->_u._ext.ext != NULL) {
-   memcpy(>_u._ext.ext->nsaddrs[nserv],
-   ai->ai_addr, ai->ai_addrlen);
+   if (getaddrinfo(cp, sbuf, , ) == 0) {
+   if (ai->ai_addrlen <= minsiz) {
+   if (statp->_u._ext.ext != NULL) {
+   memcpy(>_u._ext.ext->nsaddrs[nserv],
+   ai->ai_addr, ai->ai_addrlen);
+   }
+   if (ai->ai_addrlen <=
+   sizeof(statp->nsaddr_list[nserv])) {
+   memcpy(>nsaddr_list[nserv],
+   ai->ai_addr, ai->ai_addrlen);
+   } else
+   statp->nsaddr_list[nserv].sin_family = 0;
+   nserv++;
}
-   if (ai->ai_addrlen <=
-   sizeof(statp->nsaddr_list[nserv])) {
-   memcpy(>nsaddr_list[nserv],
-   ai->ai_addr, ai->ai_addrlen);
-   } else
-   statp->nsaddr_list[nserv].sin_family = 0;
freeaddrinfo(ai);
-   nserv++;
}
}
continue;
___
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: r301919 - stable/10/bin/setfacl

2016-06-15 Thread Don Lewis
Author: truckman
Date: Wed Jun 15 06:33:40 2016
New Revision: 301919
URL: https://svnweb.freebsd.org/changeset/base/301919

Log:
  MFC r301582
  
  Explicitly NUL terminate the buffer filled by fread().
  
  The fix in r300649 was not sufficient to convince Coverity that the
  buffer was NUL terminated, even with the buffer pre-zeroed.  Swap
  the size and nmemb arguments to fread() so that a valid lenght is
  returned, which we can use to terminate the string in the buffer
  at the correct location.  This should also quiet the complaint about
  the return value of fread() not being checked.
  
  Reported by:  Coverity
  CID:  1019054, 1009614
  Secur3ty:
  Sponsore dby:

Modified:
  stable/10/bin/setfacl/file.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/setfacl/file.c
==
--- stable/10/bin/setfacl/file.cWed Jun 15 06:32:00 2016
(r301918)
+++ stable/10/bin/setfacl/file.cWed Jun 15 06:33:40 2016
(r301919)
@@ -43,13 +43,12 @@ acl_t
 get_acl_from_file(const char *filename)
 {
FILE *file;
+   size_t len;
char buf[BUFSIZ+1];
 
if (filename == NULL)
err(1, "(null) filename in get_acl_from_file()");
 
-   bzero(, sizeof(buf));
-
if (strcmp(filename, "-") == 0) {
if (have_stdin != 0)
err(1, "cannot specify more than one stdin");
@@ -61,7 +60,8 @@ get_acl_from_file(const char *filename)
err(1, "fopen() %s failed", filename);
}
 
-   fread(buf, sizeof(buf) - 1, (size_t)1, file);
+   len = fread(buf, (size_t)1, sizeof(buf) - 1, file);
+   buf[len] = '\0';
if (ferror(file) != 0) {
fclose(file);
err(1, "error reading from %s", filename);
___
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: r301772 - in stable/10: sbin/ipfw sys/conf sys/modules/dummynet sys/netinet sys/netpfil/ipfw

2016-06-09 Thread Don Lewis
Author: truckman
Date: Fri Jun 10 00:00:25 2016
New Revision: 301772
URL: https://svnweb.freebsd.org/changeset/base/301772

Log:
  MFC r300779, r300781, r300783, r300784, r300949, r301162, r301180
  
  r300779 | truckman | 2016-05-26 14:40:13 -0700 (Thu, 26 May 2016) | 64 lines
  
  Import Dummynet AQM version 0.2.1 (CoDel, FQ-CoDel, PIE and FQ-PIE).
  
  Centre for Advanced Internet Architectures
  
  Implementing AQM in FreeBSD
  
  * Overview 
  
  * Articles, Papers and Presentations

  
  * Patches and Tools 
  
  Overview
  
  Recent years have seen a resurgence of interest in better managing
  the depth of bottleneck queues in routers, switches and other places
  that get congested. Solutions include transport protocol enhancements
  at the end-hosts (such as delay-based or hybrid congestion control
  schemes) and active queue management (AQM) schemes applied within
  bottleneck queues.
  
  The notion of AQM has been around since at least the late 1990s
  (e.g. RFC 2309). In recent years the proliferation of oversized
  buffers in all sorts of network devices (aka bufferbloat) has
  stimulated keen community interest in four new AQM schemes -- CoDel,
  FQ-CoDel, PIE and FQ-PIE.
  
  The IETF AQM working group is looking to document these schemes,
  and independent implementations are a corner-stone of the IETF's
  process for confirming the clarity of publicly available protocol
  descriptions. While significant development work on all three schemes
  has occured in the Linux kernel, there is very little in FreeBSD.
  
  Project Goals
  
  This project began in late 2015, and aims to design and implement
  functionally-correct versions of CoDel, FQ-CoDel, PIE and FQ_PIE
  in FreeBSD (with code BSD-licensed as much as practical). We have
  chosen to do this as extensions to FreeBSD's ipfw/dummynet firewall
  and traffic shaper. Implementation of these AQM schemes in FreeBSD
  will:
  * Demonstrate whether the publicly available documentation is
sufficient to enable independent, functionally equivalent implementations
  
  * Provide a broader suite of AQM options for sections the networking
community that rely on FreeBSD platforms
  
  Program Members:
  
  * Rasool Al Saadi (developer)
  
  * Grenville Armitage (project lead)
  
  Acknowledgements:
  
  This project has been made possible in part by a gift from the
  Comcast Innovation Fund.
  
  Submitted by: Rasool Al-Saadi 
  X-No objection:   core
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D6388
  
  [Remove some code that was added to the mq_append() inline function in
  HEAD by r258457, which was not merged to stable/10.  The AQM patch
  moved mq_append() from ip_dn_io.c to the new file ip_dn_private.h, so
  we need to remove that copy of the r258457 changes.]
  
  r300781 | truckman | 2016-05-26 14:44:52 -0700 (Thu, 26 May 2016) | 7 lines
  
  Modify BOUND_VAR() macro to wrap all of its arguments in () and tweak
  its expression to work on powerpc and sparc64 (gcc compatibility).
  
  Correct a typo in a nearby comment.
  
  MFC after:2 weeks (with r300779)
  
  
  r300783 | truckman | 2016-05-26 15:03:28 -0700 (Thu, 26 May 2016) | 4 lines
  
  Correct a typo in a comment.
  
  MFC after:2 weeks (with r300779)
  
  
  r300784 | truckman | 2016-05-26 15:07:09 -0700 (Thu, 26 May 2016) | 5 lines
  
  Include the new AQM files when compiling a kernel with options DUMMYNET.
  
  Reported by:  Nikolay Denev 
  MFC after:2 weeks (with r300779)
  
  
  r300949 | truckman | 2016-05-29 00:23:56 -0700 (Sun, 29 May 2016) | 10 lines
  
  Cast some expressions that multiply a long long constant by a
  floating point constant to int64_t.  This avoids the runtime
  conversion of the the other operand in a set of comparisons from
  int64_t to floating point and doing the comparisions in floating
  point.
  
  Suggested by: lidl
  Submitted by: Rasool Al-Saadi 
  MFC after:2 weeks (with r300779)
  
  
  r301162 | truckman | 2016-06-01 13:04:24 -0700 (Wed, 01 Jun 2016) | 9 lines
  
  Replace constant expressions that contain multiplications by
  fractional floating point values with integer divides.  This will
  eliminate any chance that the compiler will generate code to evaluate
  the expression using floating point at runtime.
  
  Suggested by: bde
  Submitted by: Rasool Al-Saadi 
  MFC after:8 days (with r300779 and 

svn commit: r301596 - head/lib/libc/gen

2016-06-08 Thread Don Lewis
Author: truckman
Date: Wed Jun  8 10:25:16 2016
New Revision: 301596
URL: https://svnweb.freebsd.org/changeset/base/301596

Log:
  Don't leak olinep if malloc() fails.
  
  If malloc() fails to allocate linep, then free olinep (if it exists)
  before returning to avoid a memory leak.
  
  Reported by:  Coverity
  CID:  1016716
  Reviewed by:  kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D6755

Modified:
  head/lib/libc/gen/getnetgrent.c

Modified: head/lib/libc/gen/getnetgrent.c
==
--- head/lib/libc/gen/getnetgrent.c Wed Jun  8 10:00:43 2016
(r301595)
+++ head/lib/libc/gen/getnetgrent.c Wed Jun  8 10:25:16 2016
(r301596)
@@ -614,6 +614,8 @@ read_for_group(const char *group)
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
+   if (olen > 0)
+   free(olinep);
return (NULL);
}
if (olen > 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: r301592 - head/lib/libc/resolv

2016-06-08 Thread Don Lewis
Author: truckman
Date: Wed Jun  8 09:40:06 2016
New Revision: 301592
URL: https://svnweb.freebsd.org/changeset/base/301592

Log:
  Don't leak addrinfo if ai->ai_addrlen <= minsiz test fails.
  
  If the ai->ai_addrlen <= minsiz test fails, then freeaddrinfo()
  does not get called to free the memory just allocated by getaddrinfo().
  Fix by moving ai->ai_addrlen <= minsiz to a separate nested if
  block, and keep freeaddrinfo() in the outer block so that freeaddrinfo()
  will be called whenever getaddrinfo() succeeds.
  
  Reported by:  Coverity
  CID:  1273652
  Reviewed by:  ume
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D6756

Modified:
  head/lib/libc/resolv/res_init.c

Modified: head/lib/libc/resolv/res_init.c
==
--- head/lib/libc/resolv/res_init.c Wed Jun  8 09:36:07 2016
(r301591)
+++ head/lib/libc/resolv/res_init.c Wed Jun  8 09:40:06 2016
(r301592)
@@ -411,20 +411,21 @@ __res_vinit(res_state statp, int preinit
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%u", NAMESERVER_PORT);
-   if (getaddrinfo(cp, sbuf, , ) == 0 &&
-   ai->ai_addrlen <= minsiz) {
-   if (statp->_u._ext.ext != NULL) {
-   memcpy(>_u._ext.ext->nsaddrs[nserv],
-   ai->ai_addr, ai->ai_addrlen);
+   if (getaddrinfo(cp, sbuf, , ) == 0) {
+   if (ai->ai_addrlen <= minsiz) {
+   if (statp->_u._ext.ext != NULL) {
+   memcpy(>_u._ext.ext->nsaddrs[nserv],
+   ai->ai_addr, ai->ai_addrlen);
+   }
+   if (ai->ai_addrlen <=
+   sizeof(statp->nsaddr_list[nserv])) {
+   memcpy(>nsaddr_list[nserv],
+   ai->ai_addr, ai->ai_addrlen);
+   } else
+   statp->nsaddr_list[nserv].sin_family = 0;
+   nserv++;
}
-   if (ai->ai_addrlen <=
-   sizeof(statp->nsaddr_list[nserv])) {
-   memcpy(>nsaddr_list[nserv],
-   ai->ai_addr, ai->ai_addrlen);
-   } else
-   statp->nsaddr_list[nserv].sin_family = 0;
freeaddrinfo(ai);
-   nserv++;
}
}
continue;
___
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: r301582 - head/bin/setfacl

2016-06-07 Thread Don Lewis
Author: truckman
Date: Wed Jun  8 05:32:39 2016
New Revision: 301582
URL: https://svnweb.freebsd.org/changeset/base/301582

Log:
  Explicitly NUL terminate the buffer filled by fread().
  
  The fix in r300649 was not sufficient to convince Coverity that the
  buffer was NUL terminated, even with the buffer pre-zeroed.  Swap
  the size and nmemb arguments to fread() so that a valid lenght is
  returned, which we can use to terminate the string in the buffer
  at the correct location.  This should also quiet the complaint about
  the return value of fread() not being checked.
  
  Reported by:  Coverity
  CID:  1019054, 1009614
  MFC after:1 week

Modified:
  head/bin/setfacl/file.c

Modified: head/bin/setfacl/file.c
==
--- head/bin/setfacl/file.c Wed Jun  8 04:49:20 2016(r301581)
+++ head/bin/setfacl/file.c Wed Jun  8 05:32:39 2016(r301582)
@@ -43,13 +43,12 @@ acl_t
 get_acl_from_file(const char *filename)
 {
FILE *file;
+   size_t len;
char buf[BUFSIZ+1];
 
if (filename == NULL)
err(1, "(null) filename in get_acl_from_file()");
 
-   bzero(, sizeof(buf));
-
if (strcmp(filename, "-") == 0) {
if (have_stdin != 0)
err(1, "cannot specify more than one stdin");
@@ -61,7 +60,8 @@ get_acl_from_file(const char *filename)
err(1, "fopen() %s failed", filename);
}
 
-   fread(buf, sizeof(buf) - 1, (size_t)1, file);
+   len = fread(buf, (size_t)1, sizeof(buf) - 1, file);
+   buf[len] = '\0';
if (ferror(file) != 0) {
fclose(file);
err(1, "error reading from %s", filename);
___
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: r301574 - head/usr.bin/random

2016-06-07 Thread Don Lewis
Author: truckman
Date: Wed Jun  8 02:14:05 2016
New Revision: 301574
URL: https://svnweb.freebsd.org/changeset/base/301574

Log:
  Fix a (false positive?) Argument cannot be negative coverity defect.
  
  Rather than guarding close(fd) with an fd >= 0 test and setting fd
  to -1 when it is closed to avoid a potential double-close, just
  move the close() call after the conditional "goto make_token".  This
  moves the close() call totally outside the loop to avoid the
  possibility of calling it twice.  This should also prevent a Coverity
  warning about checking fd for validity after it was previously passed
  to read().
  
  Reported by:  Coverity
  CID:  1355335
  MFC after:1 week
  X-MFC with:   r299484

Modified:
  head/usr.bin/random/randomize_fd.c

Modified: head/usr.bin/random/randomize_fd.c
==
--- head/usr.bin/random/randomize_fd.c  Wed Jun  8 02:09:14 2016
(r301573)
+++ head/usr.bin/random/randomize_fd.c  Wed Jun  8 02:14:05 2016
(r301574)
@@ -199,17 +199,14 @@ make_token:
}
}
 
-   if (fd >= 0) {
-   (void)close(fd);
-   fd = -1;
-   }
-
/* Necessary evil to compensate for files that don't end with a newline 
*/
if (bufc != i) {
i--;
goto make_token;
}
 
+   (void)close(fd);
+
free(buf);
 
for (i = numnode; i > 0; i--) {
___
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: r301571 - stable/10/bin/sh

2016-06-07 Thread Don Lewis
Author: truckman
Date: Wed Jun  8 01:17:22 2016
New Revision: 301571
URL: https://svnweb.freebsd.org/changeset/base/301571

Log:
  MFC r301139
  
  The (i < PROMPTLEN - 1) test added by r300442 in the code for the default
  case of \c in the prompt format string is a no-op.  We already passed
  this test at the top of the loop, and i has not yet been incremented in
  this path.  Change this test to (i < PROMPTLEN - 2).
  
  Reported by:  Coverity
  CID:  1008328
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D6552

Modified:
  stable/10/bin/sh/parser.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/sh/parser.c
==
--- stable/10/bin/sh/parser.c   Wed Jun  8 00:29:48 2016(r301570)
+++ stable/10/bin/sh/parser.c   Wed Jun  8 01:17:22 2016(r301571)
@@ -2039,7 +2039,7 @@ getprompt(void *unused __unused)
 */
default:
ps[i] = '\\';
-   if (i < PROMPTLEN - 1)
+   if (i < PROMPTLEN - 2)
ps[++i] = *fmt;
break;
}
___
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: r301557 - stable/10/usr.sbin/pw

2016-06-07 Thread Don Lewis
Author: truckman
Date: Tue Jun  7 16:56:15 2016
New Revision: 301557
URL: https://svnweb.freebsd.org/changeset/base/301557

Log:
  MFC r300564
  
  Fix CID 1006692 in /usr/sbin/pw pw_log() function and other fixes
  
  The length of the name returned from the $LOGNAME and $USER can be
  very long and it was being concatenated to a fixed length buffer
  with no bounds checking.  Fix this problem by limiting the length
  of the name copied.
  
  Additionally, this name is actually used to create a format string
  to be used in adding log file entries so embedded % characters in
  the name could confuse *printf(), and embedded whitespace could
  confuse a log file parser.  Handle the former by escaping each %
  with an additional %, and handle the latter by simply stripping it
  out.
  
  Clean up the code by moving the variable declarations to the top
  of the function, formatting them to conform with style, and moving
  intialization elsewhere.
  
  Reduce code indentation by returning early in a couple of places.
  
  Reported by:  Coverity
  CID:  1006692
  Reviewed by:  markj (previous version)
  Differential Revision:https://reviews.freebsd.org/D6490

Modified:
  stable/10/usr.sbin/pw/pw_log.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/pw/pw_log.c
==
--- stable/10/usr.sbin/pw/pw_log.c  Tue Jun  7 16:53:05 2016
(r301556)
+++ stable/10/usr.sbin/pw/pw_log.c  Tue Jun  7 16:56:15 2016
(r301557)
@@ -29,40 +29,90 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
+#include 
+#include 
 #include 
 #include 
 #include 
 
 #include "pw.h"
 
-static FILE*logfile = NULL;
+static FILE*logfile = NULL;
 
 void
 pw_log(struct userconf * cnf, int mode, int which, char const * fmt,...)
 {
-   if (cnf->logfile && *cnf->logfile) {
-   if (logfile == NULL) {  /* With umask==0 we need to control 
file access modes on create */
-   int fd = open(cnf->logfile, O_WRONLY | 
O_CREAT | O_APPEND, 0600);
+   va_list argp;
+   time_t  now;
+   const char  *cp, *name;
+   struct tm   *t;
+   int fd, i, rlen;
+   charnfmt[256], sname[32];
 
-   if (fd != -1)
-   logfile = fdopen(fd, "a");
+   if (cnf->logfile == NULL || cnf->logfile[0] == '\0') {
+   return;
+   }
+
+   if (logfile == NULL) {
+   /* With umask==0 we need to control file access modes on create 
*/
+   fd = open(cnf->logfile, O_WRONLY | O_CREAT | O_APPEND, 0600);
+   if (fd == -1) {
+   return;
}
-   if (logfile != NULL) {
-   va_list argp;
-   time_t  now = time(NULL);
-   struct tm  *t = localtime();
-   charnfmt[256];
-   const char *name;
-
-   if ((name = getenv("LOGNAME")) == NULL && (name = 
getenv("USER")) == NULL)
-   name = "unknown";
-   /* ISO 8601 International Standard Date format */
-   strftime(nfmt, sizeof nfmt, "%Y-%m-%d %T ", t);
-   sprintf(nfmt + strlen(nfmt), "[%s:%s%s] %s\n", name, 
Which[which], Modes[mode], fmt);
-   va_start(argp, fmt);
-   vfprintf(logfile, nfmt, argp);
-   va_end(argp);
-   fflush(logfile);
+   logfile = fdopen(fd, "a");
+   if (logfile == NULL) {
+   return;
}
}
+
+   if ((name = getenv("LOGNAME")) == NULL &&
+   (name = getenv("USER")) == NULL) {
+   strcpy(sname, "unknown");
+   } else {
+   /*
+* Since "name" will be embedded in a printf-like format,
+* we must sanitize it:
+*
+*Limit its length so other information in the message
+*is not truncated
+*
+*Squeeze out embedded whitespace for the benefit of
+*log file parsers
+*
+*Escape embedded % characters with another %
+*/
+   for (i = 0, cp = name;
+   *cp != '\0' && i < (int)sizeof(sname) - 1; cp++) {
+   if (*cp == '%') {
+   if (i < (int)sizeof(sname) - 2) {
+   sname[i++] = '%';
+   sname[i++] = '%';
+   } else {
+   break;
+   }
+   } else 

svn commit: r301556 - stable/10/sbin/ifconfig

2016-06-07 Thread Don Lewis
Author: truckman
Date: Tue Jun  7 16:53:05 2016
New Revision: 301556
URL: https://svnweb.freebsd.org/changeset/base/301556

Log:
  MFC r299921
  
  Add an assertion to catch a potential underflow in an array index
  calculation, though this should not happen in the current code.
  
  Reported by:  Coverity
  CID:  1008486

Modified:
  stable/10/sbin/ifconfig/ifieee80211.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/ifconfig/ifieee80211.c
==
--- stable/10/sbin/ifconfig/ifieee80211.c   Tue Jun  7 16:51:56 2016
(r301555)
+++ stable/10/sbin/ifconfig/ifieee80211.c   Tue Jun  7 16:53:05 2016
(r301556)
@@ -3626,6 +3626,7 @@ list_txpow(int s)
/* suppress duplicates as above */
if (isset(reported, c->ic_ieee) && !verbose) {
/* XXX we assume duplicates are adjacent */
+   assert(achans->ic_nchans > 0);
prev = >ic_chans[achans->ic_nchans-1];
/* display highest power on channel */
if (c->ic_maxpower > prev->ic_maxpower)
___
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: r301546 - head/release/doc/en_US.ISO8859-1/relnotes

2016-06-07 Thread Don Lewis
On  7 Jun, Steven Kreuzer wrote:
> Author: skreuzer (doc,ports committer)
> Date: Tue Jun  7 14:11:15 2016
> New Revision: 301546
> URL: https://svnweb.freebsd.org/changeset/base/301546
> 
> Log:
>   Document 300779, Dummynet AQM version 0.2.1
>   
>   Approved by:re (gjb, implicit, relnotes)
> 
> Modified:
>   head/release/doc/en_US.ISO8859-1/relnotes/article.xml
> 
> Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml
> ==
> --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Tue Jun  7 
> 13:58:52 2016(r301545)
> +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Tue Jun  7 
> 14:11:15 2016(r301546)
> @@ -1771,6 +1771,10 @@
>   
>
>  
> +  Dummynet AQM, an independent implementation of
> +  CoDel and FQ-CoDel for ipfw/dummynet has been imported to the base
> +  system.
> +
>  
>
>  
> 

PIE and FQ-PIE are also included.

___
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: r301231 - in stable/10: sbin/ipfw sys/netinet sys/netpfil/ipfw

2016-06-02 Thread Don Lewis
Author: truckman
Date: Fri Jun  3 00:48:50 2016
New Revision: 301231
URL: https://svnweb.freebsd.org/changeset/base/301231

Log:
  MFC r266941, r266955
  
  Needed for anticipated dummynet AQM MFC next week.
  
  r266941 | hiren | 2014-06-01 00:28:24 -0700 (Sun, 01 Jun 2014) | 9 lines
  
  ECN marking implenetation for dummynet.
  Changes include both DCTCP and RFC 3168 ECN marking methodology.
  
  DCTCP draft: http://tools.ietf.org/html/draft-bensley-tcpm-dctcp-00
  
  Submitted by: Midori Kato (aoimidor...@gmail.com)
  Worked with:  Lars Eggert (l...@netapp.com)
  Reviewed by:  luigi, hiren
  
  r266955 | hiren | 2014-06-01 13:19:17 -0700 (Sun, 01 Jun 2014) | 5 lines
  
  DNOLD_IS_ECN introduced by r266941 is not required.
  DNOLD_* flags are for compat with old binaries.
  
  Suggested by: luigi
  
  Discussed with:   hiren
  Relnotes: yes

Modified:
  stable/10/sbin/ipfw/dummynet.c
  stable/10/sbin/ipfw/ipfw.8
  stable/10/sbin/ipfw/ipfw2.h
  stable/10/sys/netinet/ip_dummynet.h
  stable/10/sys/netpfil/ipfw/ip_dn_io.c
  stable/10/sys/netpfil/ipfw/ip_dummynet.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/ipfw/dummynet.c
==
--- stable/10/sbin/ipfw/dummynet.c  Fri Jun  3 00:06:24 2016
(r301230)
+++ stable/10/sbin/ipfw/dummynet.c  Fri Jun  3 00:48:50 2016
(r301231)
@@ -56,6 +56,7 @@ static struct _s_x dummynet_params[] = {
{ "sched_mask", TOK_SCHED_MASK },
{ "flow_mask",  TOK_FLOW_MASK },
{ "droptail",   TOK_DROPTAIL },
+   { "ecn",TOK_ECN },
{ "red",TOK_RED },
{ "gred",   TOK_GRED },
{ "bw", TOK_BW },
@@ -239,7 +240,7 @@ print_flowset_parms(struct dn_fs *fs, ch
else
plr[0] = '\0';
 
-   if (fs->flags & DN_IS_RED)  /* RED parameters */
+   if (fs->flags & DN_IS_RED) {/* RED parameters */
sprintf(red,
"\n\t %cRED w_q %f min_th %d max_th %d max_p %f",
(fs->flags & DN_IS_GENTLE_RED) ? 'G' : ' ',
@@ -247,7 +248,9 @@ print_flowset_parms(struct dn_fs *fs, ch
fs->min_th,
fs->max_th,
1.0 * fs->max_p / (double)(1 << SCALE_RED));
-   else
+   if (fs->flags & DN_IS_ECN)
+   strncat(red, " (ecn)", 6);
+   } else
sprintf(red, "droptail");
 
if (prefix[0]) {
@@ -1046,13 +1049,17 @@ end_mask:
}
if ((end = strsep([0], "/"))) {
double max_p = strtod(end, NULL);
-   if (max_p > 1 || max_p <= 0)
-   errx(EX_DATAERR, "0 < max_p <= 1");
+   if (max_p > 1 || max_p < 0)
+   errx(EX_DATAERR, "0 <= max_p <= 1");
fs->max_p = (int)(max_p * (1 << SCALE_RED));
}
ac--; av++;
break;
 
+   case TOK_ECN:
+   fs->flags |= DN_IS_ECN;
+   break;
+
case TOK_DROPTAIL:
NEED(fs, "droptail is only for flowsets");
fs->flags &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
@@ -1175,13 +1182,20 @@ end_mask:
errx(EX_DATAERR, "2 <= queue size <= %ld", limit);
}
 
+   if ((fs->flags & DN_IS_ECN) && !(fs->flags & DN_IS_RED))
+   errx(EX_USAGE, "enable red/gred for ECN");
+
if (fs->flags & DN_IS_RED) {
size_t len;
int lookup_depth, avg_pkt_size;
 
-   if (fs->min_th >= fs->max_th)
+   if (!(fs->flags & DN_IS_ECN) && (fs->min_th >= fs->max_th))
errx(EX_DATAERR, "min_th %d must be < than max_th %d",
fs->min_th, fs->max_th);
+   else if ((fs->flags & DN_IS_ECN) && (fs->min_th > fs->max_th))
+   errx(EX_DATAERR, "min_th %d must be =< than max_th %d",
+   fs->min_th, fs->max_th);
+
if (fs->max_th == 0)
errx(EX_DATAERR, "max_th must be > 0");
 

Modified: stable/10/sbin/ipfw/ipfw.8
==
--- stable/10/sbin/ipfw/ipfw.8  Fri Jun  3 00:06:24 2016(r301230)
+++ stable/10/sbin/ipfw/ipfw.8  Fri Jun  3 00:48:50 2016(r301231)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 25, 2012
+.Dd May 31, 2014
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -2442,22 +2442,23 @@ and
 control the maximum lengths that can be specified.
 .Pp
 .It Cm red | gred Ar w_q Ns / Ns Ar min_th Ns / Ns Ar max_th Ns / Ns Ar max_p
+[ecn]
 Make use of the RED (Random Early Detection) queue management algorithm.

svn commit: r301178 - stable/10/games/fortune/unstr

2016-06-02 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 22:39:15 2016
New Revision: 301178
URL: https://svnweb.freebsd.org/changeset/base/301178

Log:
  MFC r300705 (compensating for fortune moving from games to usr.bin)
  
  Avoid buffer overflow when copying the input file name and appending .dat.
  
  Check the return value from fread() to be sure that it was successful.
  
  Reported by:  Coverity
  CID:  1006709, 1009452

Modified:
  stable/10/games/fortune/unstr/unstr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/games/fortune/unstr/unstr.c
==
--- stable/10/games/fortune/unstr/unstr.c   Wed Jun  1 22:34:21 2016
(r301177)
+++ stable/10/games/fortune/unstr/unstr.c   Wed Jun  1 22:39:15 2016
(r301178)
@@ -86,13 +86,19 @@ main(int argc, char *argv[])
exit(1);
}
Infile = argv[1];
-   strcpy(Datafile, Infile);
-   strcat(Datafile, ".dat");
+   if ((size_t)snprintf(Datafile, sizeof(Datafile), "%s.dat", Infile) >=
+   sizeof(Datafile)) 
+   errx(1, "%s name too long", Infile);
if ((Inf = fopen(Infile, "r")) == NULL)
err(1, "%s", Infile);
if ((Dataf = fopen(Datafile, "r")) == NULL)
err(1, "%s", Datafile);
-   fread((char *), sizeof(tbl), 1, Dataf);
+   if (fread((char *), sizeof(tbl), 1, Dataf) != 1) {
+   if (feof(Dataf))
+   errx(1, "%s read EOF", Datafile);
+   else
+   err(1, "%s read", Datafile);
+   }
tbl.str_version = be32toh(tbl.str_version);
tbl.str_numstr = be32toh(tbl.str_numstr);
tbl.str_longlen = be32toh(tbl.str_longlen);
___
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: r301180 - head/sbin/ipfw

2016-06-02 Thread Don Lewis
Author: truckman
Date: Thu Jun  2 00:42:15 2016
New Revision: 301180
URL: https://svnweb.freebsd.org/changeset/base/301180

Log:
  Belatedly bump .Dd date for Dummynet AQM import in r300779.

Modified:
  head/sbin/ipfw/ipfw.8

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Wed Jun  1 23:20:32 2016(r301179)
+++ head/sbin/ipfw/ipfw.8   Thu Jun  2 00:42:15 2016(r301180)
@@ -1,7 +1,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 13, 2015
+.Dd May 26, 2016
 .Dt IPFW 8
 .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: r301162 - head/sys/netpfil/ipfw

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 20:04:24 2016
New Revision: 301162
URL: https://svnweb.freebsd.org/changeset/base/301162

Log:
  Replace constant expressions that contain multiplications by
  fractional floating point values with integer divides.  This will
  eliminate any chance that the compiler will generate code to evaluate
  the expression using floating point at runtime.
  
  Suggested by: bde
  Submitted by: Rasool Al-Saadi 
  MFC after:8 days (with r300779 and r300949)

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.c
  head/sys/netpfil/ipfw/dn_aqm_pie.h
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.c  Wed Jun  1 19:54:17 2016
(r301161)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.c  Wed Jun  1 20:04:24 2016
(r301162)
@@ -244,20 +244,20 @@ calculate_drop_prob(void *x)
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
 
/* auto-tune drop probability */
-   if (prob < (int64_t)(PIE_MAX_PROB * 0.01))
-   p >>= 11 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
-   p >>= 9 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001))
-   p >>= 7 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.001))
-   p >>= 5 + PIE_FIX_POINT_BITS+12;
-   elseif (prob < (int64_t)(PIE_MAX_PROB * 0.01))
-   p >>= 3 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
-   p >>= 1 + PIE_FIX_POINT_BITS+12;
+   if (prob < (PIE_MAX_PROB / 100)) /* 0.01 */
+   p >>= 11 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 10)) /* 0.1 */
+   p >>= 9 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 1)) /* 0.0001 */
+   p >>= 7 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 1000)) /* 0.001 */
+   p >>= 5 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 100)) /* 0.01 */
+   p >>= 3 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 10)) /* 0.1 */
+   p >>= 1 + PIE_FIX_POINT_BITS + 12;
else
-   p >>= PIE_FIX_POINT_BITS+12;
+   p >>= PIE_FIX_POINT_BITS + 12;
 
oldprob = prob;
 

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.h
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.h  Wed Jun  1 19:54:17 2016
(r301161)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.h  Wed Jun  1 20:04:24 2016
(r301162)
@@ -132,11 +132,13 @@ drop_early(struct pie_status *pst, uint3
 * if accu_prob < 0.85 -> enqueue
 * if accu_prob>8.5 ->drop
 * between 0.85 and 8.5 || !De-randomize --> drop on prob
+* 
+* (0.85 = 17/20 ,8.5 = 17/2)
 */
if (pprms->flags & PIE_DERAND_ENABLED) {
-   if(pst->accu_prob < (uint64_t) (PIE_MAX_PROB * 0.85))
+   if(pst->accu_prob < (uint64_t) (PIE_MAX_PROB * 17 / 20))
return ENQUE;
-if( pst->accu_prob >= (uint64_t) (PIE_MAX_PROB * 8.5))
+if( pst->accu_prob >= (uint64_t) (PIE_MAX_PROB * 17 / 2))
return DROP;
}
 

Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Wed Jun  1 19:54:17 2016
(r301161)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Wed Jun  1 20:04:24 2016
(r301162)
@@ -407,20 +407,20 @@ fq_calculate_drop_prob(void *x)
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
 
/* auto-tune drop probability */
-   if (prob < (int64_t)(PIE_MAX_PROB * 0.01))
-   p >>= 11 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
-   p >>= 9 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001))
-   p >>= 7 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.001))
-   p >>= 5 + PIE_FIX_POINT_BITS+12;
-   elseif (prob < (int64_t)(PIE_MAX_PROB * 0.01))
-   p >>= 3 + PIE_FIX_POINT_BITS+12;
-   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
-   p >>= 1 + PIE_FIX_POINT_BITS+12;
+   if (prob < (PIE_MAX_PROB / 100)) /* 0.01 */
+   p >>= 11 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 10)) /* 0.1 */
+   p >>= 9 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 1)) /* 0.0001 */
+   p >>= 7 + PIE_FIX_POINT_BITS + 12;
+   else if (prob < (PIE_MAX_PROB / 1000)) /* 0.001 */
+   

svn commit: r301156 - stable/10/usr.sbin/tzsetup

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:57:56 2016
New Revision: 301156
URL: https://svnweb.freebsd.org/changeset/base/301156

Log:
  MFC r300706
  
  Avoid buffer overflow or truncation when constructing path_zoneinfo_file.
  
  Reported by:  Coverity
  CID:  1011160

Modified:
  stable/10/usr.sbin/tzsetup/tzsetup.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/tzsetup/tzsetup.c
==
--- stable/10/usr.sbin/tzsetup/tzsetup.cWed Jun  1 17:47:34 2016
(r301155)
+++ stable/10/usr.sbin/tzsetup/tzsetup.cWed Jun  1 17:57:56 2016
(r301156)
@@ -837,7 +837,9 @@ install_zoneinfo(const char *zoneinfo)
FILE*f;
charpath_zoneinfo_file[MAXPATHLEN];
 
-   sprintf(path_zoneinfo_file, "%s/%s", path_zoneinfo, zoneinfo);
+   if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
+   "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
+   errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo);
rv = install_zoneinfo_file(path_zoneinfo_file);
 
/* Save knowledge for later */
___
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: r301155 - stable/10/bin/ed

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:47:34 2016
New Revision: 301155
URL: https://svnweb.freebsd.org/changeset/base/301155

Log:
  MFC r300692
  
  Close the input FILE * in read_file() and the output FILE * in write_file()
  if read_stream() or write_stream() fails to avoid leaking the FILE.
  
  Reported by:  Coverity
  CID:  977702
  Reviewed by:  pfg
  Differential Revision:https://reviews.freebsd.org/D6554

Modified:
  stable/10/bin/ed/io.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/ed/io.c
==
--- stable/10/bin/ed/io.c   Wed Jun  1 17:45:00 2016(r301154)
+++ stable/10/bin/ed/io.c   Wed Jun  1 17:47:34 2016(r301155)
@@ -36,20 +36,24 @@ read_file(char *fn, long n)
 {
FILE *fp;
long size;
-
+   int cs;
 
fp = (*fn == '!') ? popen(fn + 1, "r") : fopen(strip_escapes(fn), "r");
if (fp == NULL) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot open input file";
return ERR;
-   } else if ((size = read_stream(fp, n)) < 0)
-   return ERR;
-else if (((*fn == '!') ?  pclose(fp) : fclose(fp)) < 0) {
+   }
+   if ((size = read_stream(fp, n)) < 0) {
+   fprintf(stderr, "%s: %s\n", fn, strerror(errno));
+   errmsg = "error reading input file";
+   }
+   if ((cs = (*fn == '!') ?  pclose(fp) : fclose(fp)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot close input file";
-   return ERR;
}
+   if (size < 0 || cs < 0)
+   return ERR;
if (!scripted)
fprintf(stdout, "%lu\n", size);
return current_addr - n;
@@ -143,19 +147,24 @@ write_file(char *fn, const char *mode, l
 {
FILE *fp;
long size;
+   int cs;
 
fp = (*fn == '!') ? popen(fn+1, "w") : fopen(strip_escapes(fn), mode);
if (fp == NULL) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot open output file";
return ERR;
-   } else if ((size = write_stream(fp, n, m)) < 0)
-   return ERR;
-else if (((*fn == '!') ?  pclose(fp) : fclose(fp)) < 0) {
+   }
+   if ((size = write_stream(fp, n, m)) < 0) {
+   fprintf(stderr, "%s: %s\n", fn, strerror(errno));
+   errmsg = "error writing output file";
+   }
+   if ((cs = (*fn == '!') ?  pclose(fp) : fclose(fp)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot close output file";
-   return ERR;
}
+   if (size < 0 || cs < 0)
+   return ERR;
if (!scripted)
fprintf(stdout, "%lu\n", size);
return n ? m - n + 1 : 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: r301154 - stable/10/lib/libfetch

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:45:00 2016
New Revision: 301154
URL: https://svnweb.freebsd.org/changeset/base/301154

Log:
  MFC r300666
  
  Call closedir() before returning from fetchListFile() to avoid a leak.
  
  Reported by:  Coverity
  CID:  1016697

Modified:
  stable/10/lib/libfetch/file.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libfetch/file.c
==
--- stable/10/lib/libfetch/file.c   Wed Jun  1 17:43:04 2016
(r301153)
+++ stable/10/lib/libfetch/file.c   Wed Jun  1 17:45:00 2016
(r301154)
@@ -149,5 +149,6 @@ fetchListFile(struct url *u, const char 
fetch_add_entry(, , , de->d_name, );
}
 
+   closedir(dir);
return (ue);
 }
___
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: r301153 - stable/10/lib/libfetch

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:43:04 2016
New Revision: 301153
URL: https://svnweb.freebsd.org/changeset/base/301153

Log:
  MFC r300665
  
  Don't leak addrinfo in fetch_bind()
  
  Submitted by: Coverity
  CID:  1225038

Modified:
  stable/10/lib/libfetch/common.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libfetch/common.c
==
--- stable/10/lib/libfetch/common.c Wed Jun  1 17:41:00 2016
(r301152)
+++ stable/10/lib/libfetch/common.c Wed Jun  1 17:43:04 2016
(r301153)
@@ -256,8 +256,11 @@ fetch_bind(int sd, int af, const char *a
if ((err = getaddrinfo(addr, NULL, , )) != 0)
return (-1);
for (res = res0; res; res = res->ai_next)
-   if (bind(sd, res->ai_addr, res->ai_addrlen) == 0)
+   if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) {
+   freeaddrinfo(res0);
return (0);
+   }
+   freeaddrinfo(res0);
return (-1);
 }
 
___
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: r301152 - stable/10/lib/libcompat/4.3

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:41:00 2016
New Revision: 301152
URL: https://svnweb.freebsd.org/changeset/base/301152

Log:
  MFC r300664
  
  Fix Coverity CID 978183 Resource leak in rexec().
  
  Close the socket if connect() fails to avoid leaking it.
  
  Reported by:  Coverity
  CID:  978183

Modified:
  stable/10/lib/libcompat/4.3/rexec.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libcompat/4.3/rexec.c
==
--- stable/10/lib/libcompat/4.3/rexec.c Wed Jun  1 17:39:03 2016
(r301151)
+++ stable/10/lib/libcompat/4.3/rexec.c Wed Jun  1 17:41:00 2016
(r301152)
@@ -330,6 +330,7 @@ retry:
goto retry;
}
perror(hp->h_name);
+   (void) close(s);
return (-1);
}
if (fd2p == 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: r301151 - stable/10/lib/libc/gen

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:39:03 2016
New Revision: 301151
URL: https://svnweb.freebsd.org/changeset/base/301151

Log:
  MFC r300662
  
  Fix Coverity CID 1016714 Resource leak in process_file_actions_entry()
  
  Don't leak a file descriptor of _dup2() fails (shouldn't happen).
  
  Reported by:  Coverity
  CID:  1016714

Modified:
  stable/10/lib/libc/gen/posix_spawn.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/posix_spawn.c
==
--- stable/10/lib/libc/gen/posix_spawn.cWed Jun  1 17:37:16 2016
(r301150)
+++ stable/10/lib/libc/gen/posix_spawn.cWed Jun  1 17:39:03 2016
(r301151)
@@ -140,7 +140,7 @@ process_spawnattr(const posix_spawnattr_
 static int
 process_file_actions_entry(posix_spawn_file_actions_entry_t *fae)
 {
-   int fd;
+   int fd, saved_errno;
 
switch (fae->fae_action) {
case FAE_OPEN:
@@ -149,8 +149,11 @@ process_file_actions_entry(posix_spawn_f
if (fd < 0)
return (errno);
if (fd != fae->fae_fildes) {
-   if (_dup2(fd, fae->fae_fildes) == -1)
-   return (errno);
+   if (_dup2(fd, fae->fae_fildes) == -1) {
+   saved_errno = errno;
+   (void)_close(fd);
+   return (saved_errno);
+   }
if (_close(fd) != 0) {
if (errno == EBADF)
return (EBADF);
___
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: r301150 - stable/10/lib/libc/gen

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:37:16 2016
New Revision: 301150
URL: https://svnweb.freebsd.org/changeset/base/301150

Log:
  MFC r300660
  
  Fix 1016718 Resource leak.
  
  Don't leak a file descriptor if fchdir() fails.
  
  Reported by:  Coverity
  CID:  1016718

Modified:
  stable/10/lib/libc/gen/fts-compat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/fts-compat.c
==
--- stable/10/lib/libc/gen/fts-compat.c Wed Jun  1 17:35:03 2016
(r301149)
+++ stable/10/lib/libc/gen/fts-compat.c Wed Jun  1 17:37:16 2016
(r301150)
@@ -586,8 +586,10 @@ __fts_children_44bsd(sp, instr)
if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
-   if (fchdir(fd))
+   if (fchdir(fd)) {
+   (void)_close(fd);
return (NULL);
+   }
(void)_close(fd);
return (sp->fts_child);
 }
___
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: r301149 - stable/10/bin/setfacl

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:35:03 2016
New Revision: 301149
URL: https://svnweb.freebsd.org/changeset/base/301149

Log:
  MFC r300649
  
  Fix Coverity CID 1019054 (String not null terminated) in setfacl.
  
  Increase the size of buf[] by one to allow room for a NUL character
  at the end.
  
  Reported by:  Coverity
  CID:  1019054

Modified:
  stable/10/bin/setfacl/file.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/setfacl/file.c
==
--- stable/10/bin/setfacl/file.cWed Jun  1 17:33:02 2016
(r301148)
+++ stable/10/bin/setfacl/file.cWed Jun  1 17:35:03 2016
(r301149)
@@ -43,7 +43,7 @@ acl_t
 get_acl_from_file(const char *filename)
 {
FILE *file;
-   char buf[BUFSIZ];
+   char buf[BUFSIZ+1];
 
if (filename == NULL)
err(1, "(null) filename in get_acl_from_file()");
@@ -61,7 +61,7 @@ get_acl_from_file(const char *filename)
err(1, "fopen() %s failed", filename);
}
 
-   fread(buf, sizeof(buf), (size_t)1, file);
+   fread(buf, sizeof(buf) - 1, (size_t)1, file);
if (ferror(file) != 0) {
fclose(file);
err(1, "error reading from %s", filename);
___
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: r301148 - stable/10/bin/ps

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:33:02 2016
New Revision: 301148
URL: https://svnweb.freebsd.org/changeset/base/301148

Log:
  MFC r300648
  
  Fix CID 1011370 (Resource leak) in ps.
  
  There is no need to to call strdup() on the value returned by fmt().
  The latter calls fmt_argv() which always returns a dynamically
  allocated string, and calling strdup() on that leaks the memory
  allocated by fmt_argv().  Wave some const magic on ki_args and
  ki_env to make the direct assignment happy.  This requires a tweak
  to the asprintf() case to avoid a const vs. non-const mismatch.
  
  Reported by:  Coverity
  CID:  1011370

Modified:
  stable/10/bin/ps/ps.c
  stable/10/bin/ps/ps.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/ps/ps.c
==
--- stable/10/bin/ps/ps.c   Wed Jun  1 17:30:50 2016(r301147)
+++ stable/10/bin/ps/ps.c   Wed Jun  1 17:33:02 2016(r301148)
@@ -1217,6 +1217,7 @@ fmt(char **(*fn)(kvm_t *, const struct k
 static void
 saveuser(KINFO *ki)
 {
+   char *argsp;
 
if (ki->ki_p->ki_flag & P_INMEM) {
/*
@@ -1235,10 +1236,12 @@ saveuser(KINFO *ki)
if (ki->ki_p->ki_stat == SZOMB)
ki->ki_args = strdup("");
else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL))
-   ki->ki_args = strdup(fmt(kvm_getargv, ki,
-   ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN));
-   else
-   asprintf(>ki_args, "(%s)", ki->ki_p->ki_comm);
+   ki->ki_args = fmt(kvm_getargv, ki,
+   ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN);
+   else {
+   asprintf(, "(%s)", ki->ki_p->ki_comm);
+   ki->ki_args = argsp;
+   }
if (ki->ki_args == NULL)
errx(1, "malloc failed");
} else {
@@ -1246,8 +1249,8 @@ saveuser(KINFO *ki)
}
if (needenv) {
if (UREADOK(ki))
-   ki->ki_env = strdup(fmt(kvm_getenvv, ki,
-   (char *)NULL, (char *)NULL, 0));
+   ki->ki_env = fmt(kvm_getenvv, ki,
+   (char *)NULL, (char *)NULL, 0);
else
ki->ki_env = strdup("()");
if (ki->ki_env == NULL)

Modified: stable/10/bin/ps/ps.h
==
--- stable/10/bin/ps/ps.h   Wed Jun  1 17:30:50 2016(r301147)
+++ stable/10/bin/ps/ps.h   Wed Jun  1 17:33:02 2016(r301148)
@@ -42,8 +42,8 @@ typedef struct kinfo_str {
 
 typedef struct kinfo {
struct kinfo_proc *ki_p;/* kinfo_proc structure */
-   char *ki_args;  /* exec args */
-   char *ki_env;   /* environment */
+   const char *ki_args;/* exec args */
+   const char *ki_env; /* environment */
int ki_valid;   /* 1 => uarea stuff valid */
double   ki_pcpu;   /* calculated in main() */
segsz_t  ki_memsize;/* calculated in main() */
___
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: r301147 - stable/10/bin/mv

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:30:50 2016
New Revision: 301147
URL: https://svnweb.freebsd.org/changeset/base/301147

Log:
  MFC r300643
  
  Close from_fd if malloc() fails to avoid a file descriptor leak.
  
  Reported by:  Coverity
  CID:  1007203

Modified:
  stable/10/bin/mv/mv.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/mv/mv.c
==
--- stable/10/bin/mv/mv.c   Wed Jun  1 17:29:15 2016(r301146)
+++ stable/10/bin/mv/mv.c   Wed Jun  1 17:30:50 2016(r301147)
@@ -285,6 +285,7 @@ fastcopy(const char *from, const char *t
}
if (bp == NULL && (bp = malloc((size_t)blen)) == NULL) {
warnx("malloc(%u) failed", blen);
+   (void)close(from_fd);
return (1);
}
while ((to_fd =
___
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: r301146 - stable/10/bin/sh

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:29:15 2016
New Revision: 301146
URL: https://svnweb.freebsd.org/changeset/base/301146

Log:
  MFC r300642
  
  Match the descriptions of the \H and \h prompt string sequences to reality.
  They were swapped.
  
  X-Confirmed by:   jilles

Modified:
  stable/10/bin/sh/sh.1
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/sh/sh.1
==
--- stable/10/bin/sh/sh.1   Wed Jun  1 17:22:15 2016(r301145)
+++ stable/10/bin/sh/sh.1   Wed Jun  1 17:29:15 2016(r301146)
@@ -32,7 +32,7 @@
 .\"from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd November 7, 2014
+.Dd May 24, 2016
 .Dt SH 1
 .Os
 .Sh NAME
@@ -1371,9 +1371,9 @@ may include any of the following formatt
 which are replaced by the given information:
 .Bl -tag -width indent
 .It Li \eH
-The local hostname.
-.It Li \eh
 The fully-qualified hostname.
+.It Li \eh
+The local hostname.
 .It Li \eW
 The final component of the current working directory.
 .It Li \ew
___
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: r301144 - stable/10/usr.sbin/ypserv

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:20:36 2016
New Revision: 301144
URL: https://svnweb.freebsd.org/changeset/base/301144

Log:
  MFC r300636
  
  Delay calling yp_malloc_dnsent() until after some additional sanity
  checks to avoid leaking memory on error returns.
  
  Reported by:  Coverity
  CID:  1007416

Modified:
  stable/10/usr.sbin/ypserv/yp_dnslookup.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ypserv/yp_dnslookup.c
==
--- stable/10/usr.sbin/ypserv/yp_dnslookup.cWed Jun  1 17:18:35 2016
(r301143)
+++ stable/10/usr.sbin/ypserv/yp_dnslookup.cWed Jun  1 17:20:36 2016
(r301144)
@@ -489,9 +489,6 @@ yp_async_lookup_addr(struct svc_req *rqs
yp_find_dnsqent(svcudp_get_xid(rqstp->rq_xprt),BY_RPC_XID) != NULL)
return(YP_TRUE);
 
-   if ((q = yp_malloc_dnsent()) == NULL)
-   return(YP_YPERR);
-
switch (af) {
case AF_INET:
if (inet_aton(addr, (struct in_addr *)uaddr) != 1)
@@ -516,6 +513,9 @@ yp_async_lookup_addr(struct svc_req *rqs
return(YP_YPERR);
}
 
+   if ((q = yp_malloc_dnsent()) == NULL)
+   return(YP_YPERR);
+
if (debug)
yp_error("DNS address is: %s", buf);
 
___
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: r301143 - stable/10/usr.sbin/ypserv

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:18:35 2016
New Revision: 301143
URL: https://svnweb.freebsd.org/changeset/base/301143

Log:
  MFC r300635
  
  Call free(cur) if strdup(dirp->d_name) fails to avoid a memory leak.
  
  Reported by:  Coverity
  CID:  1007414

Modified:
  stable/10/usr.sbin/ypserv/yp_server.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ypserv/yp_server.c
==
--- stable/10/usr.sbin/ypserv/yp_server.c   Wed Jun  1 17:16:35 2016
(r301142)
+++ stable/10/usr.sbin/ypserv/yp_server.c   Wed Jun  1 17:18:35 2016
(r301143)
@@ -711,6 +711,7 @@ yp_maplist_create(const char *domain)
yp_error("strdup() failed: %s",strerror(errno));
closedir(dird);
yp_maplist_free(yp_maplist);
+   free(cur);
return(NULL);
}
cur->next = yp_maplist;
___
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: r301142 - stable/10/usr.sbin/acpi/acpidb

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:16:35 2016
New Revision: 301142
URL: https://svnweb.freebsd.org/changeset/base/301142

Log:
  MFC r300633
  
  Fix acpidb CIDs 1011279 (Buffer not null terminated) and 978405 and
  1199380 (Resource leak).
  
  load_dsdt() calls strncpy() to copy a filename and Coverity warns
  that the destination buffer may not be NUL terminated.  Fix this
  by using strlcpy() instead.  If silent truncation occurs, then the
  filename was not valid anyway.
  
  load_dsdt() leaks an fd (CID 978405) and a memory region allocated
  using mmap() (CID 1199380) when it returns.  Fix these by calling
  close() and munmap() as appropriate.
  
  Don't bother fixing the minor memory leak "list", allocated by
  AcGetAllTablesFromFile() (CID 1355191).
  
  Check for truncation when creating the temp file name.
  
  Set a flag to indicate that the temp file should be unlinked.
  Relying on a strcmp() test could delete the input file in contrived
  cases.
  
  Reported by:  Coverity
  CID:  1011279, 978405, 1199380
  Reviewed by:  jkim
  Differential Revision:https://reviews.freebsd.org/D6368

Modified:
  stable/10/usr.sbin/acpi/acpidb/acpidb.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/acpi/acpidb/acpidb.c
==
--- stable/10/usr.sbin/acpi/acpidb/acpidb.c Wed Jun  1 17:13:43 2016
(r301141)
+++ stable/10/usr.sbin/acpi/acpidb/acpidb.c Wed Jun  1 17:16:35 2016
(r301142)
@@ -383,8 +383,7 @@ load_dsdt(const char *dsdtfile)
charfiletmp[PATH_MAX];
u_int8_t*code;
struct stat sb;
-   int fd, fd2;
-   int error;
+   int dounlink, error, fd;
 
fd = open(dsdtfile, O_RDONLY, 0);
if (fd == -1) {
@@ -397,11 +396,13 @@ load_dsdt(const char *dsdtfile)
return (-1);
}
code = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, 
(off_t)0);
+   close(fd);
if (code == NULL) {
perror("mmap");
return (-1);
}
if ((error = AcpiInitializeSubsystem()) != AE_OK) {
+   munmap(code, (size_t)sb.st_size);
return (-1);
}
 
@@ -409,21 +410,30 @@ load_dsdt(const char *dsdtfile)
 * make sure DSDT data contains table header or not.
 */
if (strncmp((char *)code, "DSDT", 4) == 0) {
-   strncpy(filetmp, dsdtfile, sizeof(filetmp));
+   dounlink = 0;
+   strlcpy(filetmp, dsdtfile, sizeof(filetmp));
} else {
+   dounlink = 1;
mode_t  mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
dummy_dsdt_table.Length = sizeof(ACPI_TABLE_HEADER) + 
sb.st_size;
-   snprintf(filetmp, sizeof(filetmp), "%s.tmp", dsdtfile);
-   fd2 = open(filetmp, O_WRONLY | O_CREAT | O_TRUNC, mode);
-   if (fd2 == -1) {
+   if ((size_t)snprintf(filetmp, sizeof(filetmp), "%s.tmp",
+   dsdtfile) > sizeof(filetmp) - 1) {
+   fprintf(stderr, "file name too long\n");
+   munmap(code, (size_t)sb.st_size);
+   return (-1);
+   }
+   fd = open(filetmp, O_WRONLY | O_CREAT | O_TRUNC, mode);
+   if (fd == -1) {
perror("open");
+   munmap(code, (size_t)sb.st_size);
return (-1);
}
-   write(fd2, _dsdt_table, sizeof(ACPI_TABLE_HEADER));
+   write(fd, _dsdt_table, sizeof(ACPI_TABLE_HEADER));
 
-   write(fd2, code, sb.st_size);
-   close(fd2);
+   write(fd, code, sb.st_size);
+   close(fd);
}
+   munmap(code, (size_t)sb.st_size);
 
/*
 * Install the virtual machine version of address space handlers.
@@ -484,7 +494,7 @@ load_dsdt(const char *dsdtfile)
AcpiGbl_DebuggerConfiguration = 0;
AcpiDbUserCommands(':', NULL);
 
-   if (strcmp(dsdtfile, filetmp) != 0) {
+   if (dounlink) {
unlink(filetmp);
}
 
___
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: r301141 - stable/10/usr.sbin/acpi/acpidump

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:13:43 2016
New Revision: 301141
URL: https://svnweb.freebsd.org/changeset/base/301141

Log:
  MFC r300632
  
  Fix acpidump CID 1011278 (Buffer not null terminated) and other issues
  
  Coverity reports that a buffer used for temporary file generation
  might not be NUL terminated by strncpy().  This is probably not
  true because the input gets passed through realpath(), but if the
  path name is sufficiently long the name could be truncated and cause
  other problems.  The code for generating the temp file names is
  also overly complex.  Instead of a bunch of calls to strncpy() and
  and strncat(), simplify the code by using snprintf() and add checks
  for unexpected truncation.
  
  The output file created by iasl -d is predictable.  Fix this by
  using  mkdtemp() to create a directory to hold the iasl input and
  output files.
  
  Check the return values of more syscalls.
  
  Reported by:  Coverity
  CID:  1011278
  Reviewed by:  jkim
  Differential Revision:https://reviews.freebsd.org/D6360

Modified:
  stable/10/usr.sbin/acpi/acpidump/acpi.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/acpi/acpidump/acpi.c
==
--- stable/10/usr.sbin/acpi/acpidump/acpi.c Wed Jun  1 17:09:50 2016
(r301140)
+++ stable/10/usr.sbin/acpi/acpidump/acpi.c Wed Jun  1 17:13:43 2016
(r301141)
@@ -1465,27 +1465,34 @@ dsdt_save_file(char *outfile, ACPI_TABLE
 void
 aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp)
 {
-   char buf[PATH_MAX], tmpstr[PATH_MAX];
+   char buf[PATH_MAX], tmpstr[PATH_MAX], wrkdir[PATH_MAX];
+   const char *iname = "/acpdump.din";
+   const char *oname = "/acpdump.dsl";
const char *tmpdir;
-   char *tmpext;
FILE *fp;
size_t len;
-   int fd;
+   int fd, status;
+   pid_t pid;
 
tmpdir = getenv("TMPDIR");
if (tmpdir == NULL)
tmpdir = _PATH_TMP;
-   strncpy(tmpstr, tmpdir, sizeof(tmpstr));
-   if (realpath(tmpstr, buf) == NULL) {
+   if (realpath(tmpdir, buf) == NULL) {
perror("realpath tmp dir");
return;
}
-   strncpy(tmpstr, buf, sizeof(tmpstr));
-   strncat(tmpstr, "/acpidump.", sizeof(tmpstr) - strlen(buf));
-   len = strlen(tmpstr);
-   tmpext = tmpstr + len;
-   strncpy(tmpext, "XX", sizeof(tmpstr) - len);
-   fd = mkstemp(tmpstr);
+   len = sizeof(wrkdir) - strlen(iname);
+   if ((size_t)snprintf(wrkdir, len, "%s/acpidump.XX", buf) > len-1 ) {
+   fprintf(stderr, "$TMPDIR too long\n");
+   return;
+   }
+   if  (mkdtemp(wrkdir) == NULL) {
+   perror("mkdtemp tmp working dir");
+   return;
+   }
+   assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, iname)
+   <= sizeof(tmpstr) - 1);
+   fd = open(tmpstr, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
if (fd < 0) {
perror("iasl tmp file");
return;
@@ -1494,28 +1501,46 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt,
close(fd);
 
/* Run iasl -d on the temp file */
-   if (fork() == 0) {
+   if ((pid = fork()) == 0) {
close(STDOUT_FILENO);
if (vflag == 0)
close(STDERR_FILENO);
execl("/usr/sbin/iasl", "iasl", "-d", tmpstr, NULL);
err(1, "exec");
}
-
-   wait(NULL);
-   unlink(tmpstr);
+   if (pid > 0)
+   wait();
+   if (unlink(tmpstr) < 0) {
+   perror("unlink");
+   goto out;
+   }
+   if (pid < 0) {
+   perror("fork");
+   goto out;
+   }
+   if (status != 0) {
+   fprintf(stderr, "iast exit status = %d\n", status);
+   }
 
/* Dump iasl's output to stdout */
-   strncpy(tmpext, "dsl", sizeof(tmpstr) - len);
+   assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, oname)
+   <= sizeof(tmpstr) -1);
fp = fopen(tmpstr, "r");
-   unlink(tmpstr);
+   if (unlink(tmpstr) < 0) {
+   perror("unlink");
+   goto out;
+   }
if (fp == NULL) {
perror("iasl tmp file (read)");
-   return;
+   goto out;
}
while ((len = fread(buf, 1, sizeof(buf), fp)) > 0)
fwrite(buf, 1, len, stdout);
fclose(fp);
+
+out:
+   if (rmdir(wrkdir) < 0)
+   perror("rmdir");
 }
 
 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"


svn commit: r301140 - stable/10/bin/sh

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 17:09:50 2016
New Revision: 301140
URL: https://svnweb.freebsd.org/changeset/base/301140

Log:
  MFC r300442
  
  Hopefully fix Coverity CID 1008328 (Out-of-bounds write) in /bin/sh.
  
  Replace the magic constant 127 in the loop interation count with
  "PROMPTLEN - 1".
  
  gethostname() is not guaranteed to NUL terminate the destination
  string if it is too short. Decrease the length passed to gethostname()
  by one, and add a NUL at the end of the buffer to make sure the
  following loop to find the end of the name properly terminates.
  
  The default: case is the likely cause of Coverity CID 1008328.  If
  i is 126 at the top of the loop interation where the default case
  is triggered, i will be incremented to 127 by the default case,
  then incremented to 128 at the top of the loop before being compared
  to 127 (PROMPTLENT - 1) and terminating the loop. Then the NUL
  termination code after the loop will write to ps[128].  Fix by
  checking for overflow before incrementing the index and storing the
  second character in the buffer.
  
  These fixes are not guaranteed to satisfy Coverity. The code that
  increments i in the 'h'/'H' and 'w'/'W' cases may be beyond its
  capability to analyze, but the code appears to be safe.
  
  Reported by:  Coverity
  CID:  1008328
  Reviewed by:  jilles, cem
  Differential Revision:https://reviews.freebsd.org/D6482

Modified:
  stable/10/bin/sh/parser.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/sh/parser.c
==
--- stable/10/bin/sh/parser.c   Wed Jun  1 16:56:29 2016(r301139)
+++ stable/10/bin/sh/parser.c   Wed Jun  1 17:09:50 2016(r301140)
@@ -1974,7 +1974,7 @@ getprompt(void *unused __unused)
/*
 * Format prompt string.
 */
-   for (i = 0; (i < 127) && (*fmt != '\0'); i++, fmt++)
+   for (i = 0; (i < PROMPTLEN - 1) && (*fmt != '\0'); i++, fmt++)
if (*fmt == '\\')
switch (*++fmt) {
 
@@ -1987,7 +1987,8 @@ getprompt(void *unused __unused)
case 'h':
case 'H':
ps[i] = '\0';
-   gethostname([i], PROMPTLEN - i);
+   gethostname([i], PROMPTLEN - i - 1);
+   ps[PROMPTLEN - 1] = '\0';
/* Skip to end of hostname. */
trim = (*fmt == 'h') ? '.' : '\0';
while ((ps[i] != '\0') && (ps[i] != trim))
@@ -2037,8 +2038,9 @@ getprompt(void *unused __unused)
 * Emit unrecognized formats verbatim.
 */
default:
-   ps[i++] = '\\';
-   ps[i] = *fmt;
+   ps[i] = '\\';
+   if (i < PROMPTLEN - 1)
+   ps[++i] = *fmt;
break;
}
else
___
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: r301139 - head/bin/sh

2016-06-01 Thread Don Lewis
On  1 Jun, To: src-committ...@freebsd.org wrote:
> Author: truckman
> Date: Wed Jun  1 16:56:29 2016
> New Revision: 301139
> URL: https://svnweb.freebsd.org/changeset/base/301139
> 
> Log:
>   The (i < PROMPTLEN - 1) test added by r300442 in the code for the default
>   case of \c in the prompt format string is a no-op.  We already passed
>   this test at the top of the loop, and i has not yet been incremented in
>   this path.  Change this test to (i < PROMPTLEN - 2).
>   
>   Reported by:Coverity
>   CID:1008328
>   Reviewed by:cem
>   MFC after:  1 week

Differential Revision:  https://reviews.freebsd.org/D6552
___
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: r301139 - head/bin/sh

2016-06-01 Thread Don Lewis
Author: truckman
Date: Wed Jun  1 16:56:29 2016
New Revision: 301139
URL: https://svnweb.freebsd.org/changeset/base/301139

Log:
  The (i < PROMPTLEN - 1) test added by r300442 in the code for the default
  case of \c in the prompt format string is a no-op.  We already passed
  this test at the top of the loop, and i has not yet been incremented in
  this path.  Change this test to (i < PROMPTLEN - 2).
  
  Reported by:  Coverity
  CID:  1008328
  Reviewed by:  cem
  MFC after:1 week

Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cWed Jun  1 16:53:02 2016(r301138)
+++ head/bin/sh/parser.cWed Jun  1 16:56:29 2016(r301139)
@@ -2063,7 +2063,7 @@ getprompt(void *unused __unused)
 */
default:
ps[i] = '\\';
-   if (i < PROMPTLEN - 1)
+   if (i < PROMPTLEN - 2)
ps[++i] = *fmt;
break;
}
___
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: r300952 - head/usr.sbin/services_mkdb

2016-05-30 Thread Don Lewis
On 29 May, Alan Somers wrote:
> On Sun, May 29, 2016 at 4:41 AM, Ed Schouten  wrote:
>> Author: ed
>> Date: Sun May 29 10:41:27 2016
>> New Revision: 300952
>> URL: https://svnweb.freebsd.org/changeset/base/300952
>>
>> Log:
>>   Invoke the dirname() function in a POSIX compliant way.
>>
>>   POSIX requires that the argument of dirname() is of type "char *". In
>>   other words, the input buffer can be modified by the function to store
>>   the directory name.
>>
>>   Pull a copy of the string before calling dirname(). We don't care about
>>   freeing up the memory afterwards, as this is done at the very bottom of
>>   main(), right before the program terminates.
>>
>>   Reviewed by:  bapt
>>   Differential Revision:https://reviews.freebsd.org/D6628
>>
>> Modified:
>>   head/usr.sbin/services_mkdb/services_mkdb.c
>>
>> Modified: head/usr.sbin/services_mkdb/services_mkdb.c
>> ==
>> --- head/usr.sbin/services_mkdb/services_mkdb.c Sun May 29 07:39:56 2016 
>>(r300951)
>> +++ head/usr.sbin/services_mkdb/services_mkdb.c Sun May 29 10:41:27 2016 
>>(r300952)
>> @@ -92,7 +92,7 @@ main(int argc, char *argv[])
>> size_t   cnt = 0;
>> StringList *sl, ***svc;
>> size_t port, proto;
>> -   char *dbname_dir;
>> +   char *dbname_dir, *dbname_dirbuf;
>> int dbname_dir_fd = -1;
>>
>> setprogname(argv[0]);
>> @@ -172,7 +172,8 @@ main(int argc, char *argv[])
>>  * fsync() to the directory where file lies
>>  */
>> if (rename(tname, dbname) == -1 ||
>> -   (dbname_dir = dirname(dbname)) == NULL ||
>> +   (dbname_dirbuf = strdup(dbname)) == NULL ||
>> +   (dbname_dir = dirname(dbname_dirbuf)) == NULL ||
>> (dbname_dir_fd = open(dbname_dir, O_RDONLY|O_DIRECTORY)) == -1 ||
>> fsync(dbname_dir_fd) != 0) {
>> if (dbname_dir_fd != -1)
>>
> 
> Even though the program is about to exit, it's worth freeing the
> memory just to make Coverity shut up.

I usually don't bother in that situation because it's not worth the
added code complexity.  In Coverity, I'll mark them as a bug, set the
severity to insignficant, and set action to ignore.  The situation is
different if I think the code might get used elsewhere and the memory
could be wasted for a longer period of time.

I've also run into situations where there is a real downside to doing
this sort of cleanup before calling exit().  Generally this is with a
process that has allocated some sort of large data structure in memory
over a long period of time, especially if the process has grown larger
than physical RAM and is partially resident in swap.  It's maddening to
watch the process page madly for an extended period of time as it chases
pointers all of ther place and calls free() zillions of times when it
would be so much faster to just call exit().  Adding more RAM may not be
an option in such cases, since I've had to endure this on machines that
had the maximum amount of RAM that they could hold.

___
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: r300949 - head/sys/netpfil/ipfw

2016-05-30 Thread Don Lewis
On 29 May, Bruce Evans wrote:
> On Sun, 29 May 2016, Don Lewis wrote:
> 
>> Log:
>>  Cast some expressions that multiply a long long constant by a
>>  floating point constant to int64_t.  This avoids the runtime
>>  conversion of the the other operand in a set of comparisons from
>>  int64_t to floating point and doing the comparisions in floating
>>  point.
>>
>>  Suggested by:   lidl
>>  Submitted by:   Rasool Al-Saadi <ralsa...@swin.edu.au>
>>  MFC after:  2 weeks (with r300779)
> 
> Compilers are still permitted to (and perhaps even required to)
> evaluate FP constant expressions at runtime (to get rounding and/or
> exception flags right).  They probably don't in practice, but it is
> unclear what happens for -O0 and the rules for rounding are too hard
> to understand.
> 
>> Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
>> ==
>> --- head/sys/netpfil/ipfw/dn_aqm_pie.c   Sun May 29 07:14:51 2016
>> (r300948)
>> +++ head/sys/netpfil/ipfw/dn_aqm_pie.c   Sun May 29 07:23:56 2016
>> (r300949)
>> @@ -244,17 +244,17 @@ calculate_drop_prob(void *x)
>>  p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
>>
>>  /* auto-tune drop probability */
>> -if (prob< PIE_MAX_PROB * 0.01)
>> +if (prob < (int64_t)(PIE_MAX_PROB * 0.01))
>>  p >>= 11 + PIE_FIX_POINT_BITS+12;
>> +else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
>>  p >>= 9 + PIE_FIX_POINT_BITS+12;
> 
> Why not just divide by integer powers of 10?
> 
> This might not give a suitably monotonic/continuous scaling at the
> endpoints, but it is unclear if the FP gives that either even if we
> are more careful with the rounding mode.
> 
> A table of endpoints could be used to get precise control.  Then FP
> can be used more safely, since it is clear that constants in tables
> must be evaluated at compile time.
> 
>> ...
> 
> Similarly for all cases.

Thanks.  I've passed this upstream.

___
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: r300950 - in head/sys: conf modules/dummynet

2016-05-29 Thread Don Lewis
Author: truckman
Date: Sun May 29 07:29:35 2016
New Revision: 300950
URL: https://svnweb.freebsd.org/changeset/base/300950

Log:
  Now that PIE is free of runtime floating point,  revert r300853 to
  reconnect PIE to the build.

Modified:
  head/sys/conf/files
  head/sys/modules/dummynet/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sun May 29 07:23:56 2016(r300949)
+++ head/sys/conf/files Sun May 29 07:29:35 2016(r300950)
@@ -3824,9 +3824,11 @@ netnatm/natm.c   optional natm
 netnatm/natm_pcb.c optional natm
 netnatm/natm_proto.c   optional natm
 netpfil/ipfw/dn_aqm_codel.coptional inet dummynet
+netpfil/ipfw/dn_aqm_pie.c  optional inet dummynet
 netpfil/ipfw/dn_heap.c optional inet dummynet
 netpfil/ipfw/dn_sched_fifo.c   optional inet dummynet
 netpfil/ipfw/dn_sched_fq_codel.c   optional inet dummynet
+netpfil/ipfw/dn_sched_fq_pie.c optional inet dummynet
 netpfil/ipfw/dn_sched_prio.c   optional inet dummynet
 netpfil/ipfw/dn_sched_qfq.coptional inet dummynet
 netpfil/ipfw/dn_sched_rr.c optional inet dummynet

Modified: head/sys/modules/dummynet/Makefile
==
--- head/sys/modules/dummynet/Makefile  Sun May 29 07:23:56 2016
(r300949)
+++ head/sys/modules/dummynet/Makefile  Sun May 29 07:29:35 2016
(r300950)
@@ -4,9 +4,9 @@
 KMOD=   dummynet
 SRCS=   ip_dummynet.c
 SRCS+= ip_dn_glue.c ip_dn_io.c
-SRCS+= dn_aqm_codel.c
+SRCS+= dn_aqm_codel.c dn_aqm_pie.c
 SRCS+= dn_heap.c dn_sched_fifo.c dn_sched_qfq.c dn_sched_rr.c dn_sched_wf2q.c 
-SRCS+= dn_sched_prio.c dn_sched_fq_codel.c
+SRCS+= dn_sched_prio.c dn_sched_fq_codel.c dn_sched_fq_pie.c
 SRCS+= opt_inet6.h
 
 .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: r300949 - head/sys/netpfil/ipfw

2016-05-29 Thread Don Lewis
Author: truckman
Date: Sun May 29 07:23:56 2016
New Revision: 300949
URL: https://svnweb.freebsd.org/changeset/base/300949

Log:
  Cast some expressions that multiply a long long constant by a
  floating point constant to int64_t.  This avoids the runtime
  conversion of the the other operand in a set of comparisons from
  int64_t to floating point and doing the comparisions in floating
  point.
  
  Suggested by: lidl
  Submitted by: Rasool Al-Saadi 
  MFC after:2 weeks (with r300779)

Modified:
  head/sys/netpfil/ipfw/dn_aqm_pie.c
  head/sys/netpfil/ipfw/dn_sched_fq_pie.c

Modified: head/sys/netpfil/ipfw/dn_aqm_pie.c
==
--- head/sys/netpfil/ipfw/dn_aqm_pie.c  Sun May 29 07:14:51 2016
(r300948)
+++ head/sys/netpfil/ipfw/dn_aqm_pie.c  Sun May 29 07:23:56 2016
(r300949)
@@ -244,17 +244,17 @@ calculate_drop_prob(void *x)
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
 
/* auto-tune drop probability */
-   if (prob< PIE_MAX_PROB * 0.01)
+   if (prob < (int64_t)(PIE_MAX_PROB * 0.01))
p >>= 11 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.1)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
p >>= 9 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.0001)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001))
p >>= 7 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.001)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.001))
p >>= 5 + PIE_FIX_POINT_BITS+12;
-   elseif (prob < PIE_MAX_PROB * 0.01)
+   elseif (prob < (int64_t)(PIE_MAX_PROB * 0.01))
p >>= 3 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.1)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
p >>= 1 + PIE_FIX_POINT_BITS+12;
else
p >>= PIE_FIX_POINT_BITS+12;

Modified: head/sys/netpfil/ipfw/dn_sched_fq_pie.c
==
--- head/sys/netpfil/ipfw/dn_sched_fq_pie.c Sun May 29 07:14:51 2016
(r300948)
+++ head/sys/netpfil/ipfw/dn_sched_fq_pie.c Sun May 29 07:23:56 2016
(r300949)
@@ -407,17 +407,17 @@ fq_calculate_drop_prob(void *x)
p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S;
 
/* auto-tune drop probability */
-   if (prob< PIE_MAX_PROB * 0.01)
+   if (prob < (int64_t)(PIE_MAX_PROB * 0.01))
p >>= 11 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.1)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
p >>= 9 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.0001)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.0001))
p >>= 7 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.001)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.001))
p >>= 5 + PIE_FIX_POINT_BITS+12;
-   elseif (prob < PIE_MAX_PROB * 0.01)
+   elseif (prob < (int64_t)(PIE_MAX_PROB * 0.01))
p >>= 3 + PIE_FIX_POINT_BITS+12;
-   else if (prob < PIE_MAX_PROB * 0.1)
+   else if (prob < (int64_t)(PIE_MAX_PROB * 0.1))
p >>= 1 + PIE_FIX_POINT_BITS+12;
else
p >>= PIE_FIX_POINT_BITS+12;
___
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: r300853 - in head/sys: conf modules/dummynet

2016-05-27 Thread Don Lewis
Author: truckman
Date: Fri May 27 17:07:07 2016
New Revision: 300853
URL: https://svnweb.freebsd.org/changeset/base/300853

Log:
  Disconnect PIE from the build until it is free of floating point math.
  
  Reported by:  lidl, adrian

Modified:
  head/sys/conf/files
  head/sys/modules/dummynet/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri May 27 17:00:15 2016(r300852)
+++ head/sys/conf/files Fri May 27 17:07:07 2016(r300853)
@@ -3824,11 +3824,9 @@ netnatm/natm.c   optional natm
 netnatm/natm_pcb.c optional natm
 netnatm/natm_proto.c   optional natm
 netpfil/ipfw/dn_aqm_codel.coptional inet dummynet
-netpfil/ipfw/dn_aqm_pie.c  optional inet dummynet
 netpfil/ipfw/dn_heap.c optional inet dummynet
 netpfil/ipfw/dn_sched_fifo.c   optional inet dummynet
 netpfil/ipfw/dn_sched_fq_codel.c   optional inet dummynet
-netpfil/ipfw/dn_sched_fq_pie.c optional inet dummynet
 netpfil/ipfw/dn_sched_prio.c   optional inet dummynet
 netpfil/ipfw/dn_sched_qfq.coptional inet dummynet
 netpfil/ipfw/dn_sched_rr.c optional inet dummynet

Modified: head/sys/modules/dummynet/Makefile
==
--- head/sys/modules/dummynet/Makefile  Fri May 27 17:00:15 2016
(r300852)
+++ head/sys/modules/dummynet/Makefile  Fri May 27 17:07:07 2016
(r300853)
@@ -4,9 +4,9 @@
 KMOD=   dummynet
 SRCS=   ip_dummynet.c
 SRCS+= ip_dn_glue.c ip_dn_io.c
-SRCS+= dn_aqm_codel.c dn_aqm_pie.c
+SRCS+= dn_aqm_codel.c
 SRCS+= dn_heap.c dn_sched_fifo.c dn_sched_qfq.c dn_sched_rr.c dn_sched_wf2q.c 
-SRCS+= dn_sched_prio.c dn_sched_fq_codel.c dn_sched_fq_pie.c
+SRCS+= dn_sched_prio.c dn_sched_fq_codel.c
 SRCS+= opt_inet6.h
 
 .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"


Re: svn commit: r300779 - in head: sbin/ipfw sys/modules/dummynet sys/netinet sys/netpfil/ipfw

2016-05-27 Thread Don Lewis
On 27 May, Adrian Chadd wrote:
> Hi,
> 
> Did this introduce floating point into the kernel?

Cr*p, it did.  It looks fixable, but I'll disconnect PIE from the build
for now.


___
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: r300779 - in head: sbin/ipfw sys/modules/dummynet sys/netinet sys/netpfil/ipfw

2016-05-26 Thread Don Lewis
On 26 May, To: src-committ...@freebsd.org wrote:
> Author: truckman
> Date: Thu May 26 21:40:13 2016
> New Revision: 300779
> URL: https://svnweb.freebsd.org/changeset/base/300779
> 
> Log:
>   Import Dummynet AQM version 0.2.1 (CoDel, FQ-CoDel, PIE and FQ-PIE).
>   
>   Centre for Advanced Internet Architectures
>   
>   Implementing AQM in FreeBSD
>   
>   * Overview 
>   
>   * Articles, Papers and Presentations
> 
>   
>   * Patches and Tools 
>   
>   Overview
>   
>   Recent years have seen a resurgence of interest in better managing
>   the depth of bottleneck queues in routers, switches and other places
>   that get congested. Solutions include transport protocol enhancements
>   at the end-hosts (such as delay-based or hybrid congestion control
>   schemes) and active queue management (AQM) schemes applied within
>   bottleneck queues.
>   
>   The notion of AQM has been around since at least the late 1990s
>   (e.g. RFC 2309). In recent years the proliferation of oversized
>   buffers in all sorts of network devices (aka bufferbloat) has
>   stimulated keen community interest in four new AQM schemes -- CoDel,
>   FQ-CoDel, PIE and FQ-PIE.
>   
>   The IETF AQM working group is looking to document these schemes,
>   and independent implementations are a corner-stone of the IETF's
>   process for confirming the clarity of publicly available protocol
>   descriptions. While significant development work on all three schemes
>   has occured in the Linux kernel, there is very little in FreeBSD.
>   
>   Project Goals
>   
>   This project began in late 2015, and aims to design and implement
>   functionally-correct versions of CoDel, FQ-CoDel, PIE and FQ_PIE
>   in FreeBSD (with code BSD-licensed as much as practical). We have
>   chosen to do this as extensions to FreeBSD's ipfw/dummynet firewall
>   and traffic shaper. Implementation of these AQM schemes in FreeBSD
>   will:
>   * Demonstrate whether the publicly available documentation is
> sufficient to enable independent, functionally equivalent implementations
>   
>   * Provide a broader suite of AQM options for sections the networking
> community that rely on FreeBSD platforms
>   
>   Program Members:
>   
>   * Rasool Al Saadi (developer)
>   
>   * Grenville Armitage (project lead)
>   
>   Acknowledgements:
>   
>   This project has been made possible in part by a gift from the
>   Comcast Innovation Fund.
>   
>   Submitted by:   Rasool Al-Saadi 
>   X-No objection: core
>   MFC after:  2 weeks
>   Differential Revision:  https://reviews.freebsd.org/D6388

Sigh ... should also be:

Relnotes:   yes

___
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"


  1   2   3   4   >