svn commit: r312124 - head/sys/fs/tmpfs

2017-01-13 Thread Mateusz Guzik
Author: mjg
Date: Sat Jan 14 06:20:36 2017
New Revision: 312124
URL: https://svnweb.freebsd.org/changeset/base/312124

Log:
  tmpfs: manage tm_pages_used with atomics
  
  Reviewed by:  kib (previous version)

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Sat Jan 14 06:18:54 2017(r312123)
+++ head/sys/fs/tmpfs/tmpfs.h   Sat Jan 14 06:20:36 2017(r312124)
@@ -312,12 +312,12 @@ struct tmpfs_mount {
/* Maximum number of memory pages available for use by the file
 * system, set during mount time.  This variable must never be
 * used directly as it may be bigger than the current amount of
-* free memory; in the extreme case, it will hold the SIZE_MAX
+* free memory; in the extreme case, it will hold the ULONG_MAX
 * value. */
-   size_t  tm_pages_max;
+   u_long  tm_pages_max;
 
/* Number of pages in use by the file system. */
-   size_t  tm_pages_used;
+   u_long  tm_pages_used;
 
/* Pointer to the node representing the root directory of this
 * file system. */

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Sat Jan 14 06:18:54 2017
(r312123)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Sat Jan 14 06:20:36 2017
(r312124)
@@ -129,7 +129,7 @@ tmpfs_pages_check_avail(struct tmpfs_mou
if (tmpfs_mem_avail() < req_pages)
return (0);
 
-   if (tmp->tm_pages_max != SIZE_MAX &&
+   if (tmp->tm_pages_max != ULONG_MAX &&
tmp->tm_pages_max < req_pages + tmpfs_pages_used(tmp))
return (0);
 
@@ -327,9 +327,7 @@ tmpfs_free_node(struct tmpfs_mount *tmp,
case VREG:
uobj = node->tn_reg.tn_aobj;
if (uobj != NULL) {
-   TMPFS_LOCK(tmp);
-   tmp->tm_pages_used -= uobj->size;
-   TMPFS_UNLOCK(tmp);
+   atomic_subtract_long(>tm_pages_used, uobj->size);
KASSERT((uobj->flags & OBJ_TMPFS) == 0,
("leaked OBJ_TMPFS node %p vm_obj %p", node, uobj));
vm_object_deallocate(uobj);
@@ -1417,9 +1415,7 @@ retry:
uobj->size = newpages;
VM_OBJECT_WUNLOCK(uobj);
 
-   TMPFS_LOCK(tmp);
-   tmp->tm_pages_used += (newpages - oldpages);
-   TMPFS_UNLOCK(tmp);
+   atomic_add_long(>tm_pages_used, newpages - oldpages);
 
node->tn_size = newsize;
return (0);

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- head/sys/fs/tmpfs/tmpfs_vfsops.cSat Jan 14 06:18:54 2017
(r312123)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.cSat Jan 14 06:20:36 2017
(r312124)
@@ -397,7 +397,7 @@ tmpfs_statfs(struct mount *mp, struct st
sbp->f_bsize = PAGE_SIZE;
 
used = tmpfs_pages_used(tmp);
-   if (tmp->tm_pages_max != SIZE_MAX)
+   if (tmp->tm_pages_max != ULONG_MAX)
 sbp->f_blocks = tmp->tm_pages_max;
else
 sbp->f_blocks = used + tmpfs_mem_avail();
___
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: r312123 - in vendor/NetBSD/tests/dist: dev/clock_subr kernel kernel/arch kernel/arch/amd64 kernel/arch/i386 lib/libc/gen/exect lib/libpthread_dbg lib/librefuse net/if_tun net/if_vlan sy...

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 06:18:54 2017
New Revision: 312123
URL: https://svnweb.freebsd.org/changeset/base/312123

Log:
  Add additional tests missed in previous merges
  
  Reminder: use cvs up -APd to pull new directories

Added:
  vendor/NetBSD/tests/dist/dev/clock_subr/
  vendor/NetBSD/tests/dist/dev/clock_subr/clock_subr_test_data_gen.sh   
(contents, props changed)
  vendor/NetBSD/tests/dist/dev/clock_subr/t_clock_subr.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/
  vendor/NetBSD/tests/dist/kernel/arch/amd64/
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_wait.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_wait3.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_wait4.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_wait6.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_waitid.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/amd64/t_ptrace_waitpid.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_wait.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_wait3.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_wait4.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_wait6.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_waitid.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/kernel/arch/i386/t_ptrace_waitpid.c   (contents, 
props changed)
  vendor/NetBSD/tests/dist/lib/libc/gen/exect/
  vendor/NetBSD/tests/dist/lib/libc/gen/exect/t_exect.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/lib/libpthread_dbg/
  vendor/NetBSD/tests/dist/lib/libpthread_dbg/h_common.h   (contents, props 
changed)
  vendor/NetBSD/tests/dist/lib/libpthread_dbg/t_dummy.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/lib/libpthread_dbg/t_threads.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/lib/librefuse/
  vendor/NetBSD/tests/dist/lib/librefuse/t_refuse_opt.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/net/if_tun/
  vendor/NetBSD/tests/dist/net/if_tun/t_tun.sh   (contents, props changed)
  vendor/NetBSD/tests/dist/net/if_vlan/
  vendor/NetBSD/tests/dist/net/if_vlan/t_vlan.sh   (contents, props changed)
  vendor/NetBSD/tests/dist/sys/uvm/
  vendor/NetBSD/tests/dist/sys/uvm/t_uvm_physseg.c   (contents, props changed)
  vendor/NetBSD/tests/dist/sys/uvm/t_uvm_physseg_load.c   (contents, props 
changed)
  vendor/NetBSD/tests/dist/usr.bin/mixerctl/
  vendor/NetBSD/tests/dist/usr.bin/mixerctl/t_mixerctl.sh   (contents, props 
changed)
  vendor/NetBSD/tests/dist/usr.bin/uniq/
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_basic.in   (contents, props changed)
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_basic.out
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_counts.out
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_input.in   (contents, props changed)
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_show_duplicates.out
  vendor/NetBSD/tests/dist/usr.bin/uniq/d_show_uniques.out
  vendor/NetBSD/tests/dist/usr.bin/uniq/t_uniq.sh   (contents, props changed)
Modified:
  vendor/NetBSD/tests/dist/kernel/t_ptrace_wait.c

Added: vendor/NetBSD/tests/dist/dev/clock_subr/clock_subr_test_data_gen.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/tests/dist/dev/clock_subr/clock_subr_test_data_gen.sh Sat Jan 
14 06:18:54 2017(r312123)
@@ -0,0 +1,25 @@
+#!/bin/ksh
+
+export TZ=Etc/Universal
+
+datesub() {
+   gdate "$@" '+   FILL(%_11s,%_4Y,%_m,%_d,%w,%_H,%_M,%_S), // %a %b %e 
%H:%M:%S %Z %Y'
+}
+
+(
+   datesub -d '1970/01/01 00:00:00'
+   datesub -d '1981/04/12 12:00:03'
+   datesub -d '2011/07/21 09:57:00'
+   datesub -d @2147483647
+   datesub -d @2147483648
+   datesub -d '2063/04/05 00:00:00'
+   for year in `seq 1970 1 2030`; do
+   datesub -d "${year}/01/01 00:00:00"
+   datesub -d "${year}/07/01 00:00:00"
+   done
+   for year in `seq 2000 25 2600`; do
+   datesub -d "$((${year} - 1))/12/31 23:59:59"
+   datesub -d "$((${year} + 0))/01/01 00:00:00"
+   datesub -d "$((${year} + 1))/01/01 00:00:00"
+   done
+)|sort -u

Added: vendor/NetBSD/tests/dist/dev/clock_subr/t_clock_subr.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/tests/dist/dev/clock_subr/t_clock_subr.c  Sat Jan 14 
06:18:54 2017(r312123)
@@ -0,0 +1,309 @@
+/* $NetBSD: t_clock_subr.c,v 1.3 2017/01/13 21:30:39 christos Exp $ */
+
+/*
+ * Copyright (c) 2016 Jonathan A. Kollasch
+ * All rights 

svn commit: r312122 - head/contrib/netbsd-tests/fs/nfs/nfsservice/rpcbind

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 06:16:57 2017
New Revision: 312122
URL: https://svnweb.freebsd.org/changeset/base/312122

Log:
  Remove contrib/netbsd-tests/fs/nfs/nfsservice/rpcbind
  
  This should have been pruned in r305358
  
  MFC after:3 days
  Sponsored by: Dell EMC Isilon

Deleted:
  head/contrib/netbsd-tests/fs/nfs/nfsservice/rpcbind/
___
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: r312121 - head/tests/sys/kern/execve

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 05:24:35 2017
New Revision: 312121
URL: https://svnweb.freebsd.org/changeset/base/312121

Log:
  Follow up to r312118
  
  State that execve failed instead of just printing out the program name
  and strerror(errno) via err(3).
  
  MFC after:3 days
  X-MFC with:   r312118
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/kern/execve/execve_helper.c

Modified: head/tests/sys/kern/execve/execve_helper.c
==
--- head/tests/sys/kern/execve/execve_helper.c  Sat Jan 14 05:18:18 2017
(r312120)
+++ head/tests/sys/kern/execve/execve_helper.c  Sat Jan 14 05:24:35 2017
(r312121)
@@ -50,5 +50,5 @@ main(int argc, char **argv)
}
 
execve(argv[1], [1], NULL);
-   err(1, "%s", "");
+   err(1, "execve failed");
 }
___
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: r312120 - head/tests/sys/mac/bsdextended

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 05:18:18 2017
New Revision: 312120
URL: https://svnweb.freebsd.org/changeset/base/312120

Log:
  Fix warnings
  
  - Staticize test_num
  - Promote i to size_t to deal with -Wsign-compare issues
  
  Tested with:  clang, gcc, gcc49
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/mac/bsdextended/ugidfw_test.c

Modified: head/tests/sys/mac/bsdextended/ugidfw_test.c
==
--- head/tests/sys/mac/bsdextended/ugidfw_test.cSat Jan 14 05:06:14 
2017(r312119)
+++ head/tests/sys/mac/bsdextended/ugidfw_test.cSat Jan 14 05:18:18 
2017(r312120)
@@ -71,7 +71,7 @@ static const char *test_groups[] = {
"bin",
 };
 
-int test_num;
+static int test_num;
 
 /*
  * List of test strings that must go in (and come out) of libugidfw intact.
@@ -149,7 +149,8 @@ test_libugidfw_strings(void)
struct mac_bsdextended_rule rule;
char errorstr[256];
char rulestr[256];
-   int error, i;
+   size_t i;
+   int error;
 
for (i = 0; i < nitems(test_users); i++, test_num++) {
if (getpwnam(test_users[i]) == NULL)
@@ -171,7 +172,7 @@ test_libugidfw_strings(void)
error = bsde_parse_rule_string(test_strings[i], ,
sizeof(errorstr), errorstr);
if (error == -1)
-   printf("not ok %d # bsde_parse_rule_string: '%s' (%d) "
+   printf("not ok %d # bsde_parse_rule_string: '%s' (%zu) "
"failed: %s\n", test_num, test_strings[i], i, 
errorstr);
else
printf("ok %d\n", test_num);
___
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: r312119 - head/sys/kern

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 05:06:14 2017
New Revision: 312119
URL: https://svnweb.freebsd.org/changeset/base/312119

Log:
  encode_long, encode_timeval: mechanically replace `exp` with `exponent`
  
  This helps fix a -Wshadow issue with exp(3) with tests/sys/acct/acct_test,
  which include math.h, which in turn defines exp(3)
  
  MFC after:2 weeks
  Tested with:  clang, gcc 4.2.1, gcc 4.9
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/kern_acct.c

Modified: head/sys/kern/kern_acct.c
==
--- head/sys/kern/kern_acct.c   Sat Jan 14 05:02:53 2017(r312118)
+++ head/sys/kern/kern_acct.c   Sat Jan 14 05:06:14 2017(r312119)
@@ -469,8 +469,8 @@ static uint32_t
 encode_timeval(struct timeval tv)
 {
int log2_s;
-   int val, exp;   /* Unnormalized value and exponent */
-   int norm_exp;   /* Normalized exponent */
+   int val, exponent;  /* Unnormalized value and exponent */
+   int norm_exponent;  /* Normalized exponent */
int shift;
 
/*
@@ -481,7 +481,7 @@ encode_timeval(struct timeval tv)
if (tv.tv_sec == 0) {
if (tv.tv_usec == 0)
return (0);
-   exp = 0;
+   exponent = 0;
val = tv.tv_usec;
} else {
/*
@@ -490,24 +490,24 @@ encode_timeval(struct timeval tv)
 */
log2_s = fls(tv.tv_sec) - 1;
if (log2_s + LOG2_1M < CALC_BITS) {
-   exp = 0;
+   exponent = 0;
val = 100 * tv.tv_sec + tv.tv_usec;
} else {
-   exp = log2_s + LOG2_1M - CALC_BITS;
+   exponent = log2_s + LOG2_1M - CALC_BITS;
val = (unsigned int)(((uint64_t)100 * tv.tv_sec +
-   tv.tv_usec) >> exp);
+   tv.tv_usec) >> exponent);
}
}
/* Now normalize and pack the value into an IEEE-754 float. */
-   norm_exp = fls(val) - 1;
-   shift = FLT_MANT_DIG - norm_exp - 1;
+   norm_exponent = fls(val) - 1;
+   shift = FLT_MANT_DIG - norm_exponent - 1;
 #ifdef ACCT_DEBUG
printf("val=%d exp=%d shift=%d log2(val)=%d\n",
-   val, exp, shift, norm_exp);
-   printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exp,
+   val, exponent, shift, norm_exponent);
+   printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exponent + norm_exponent,
((shift > 0 ? (val << shift) : (val >> -shift)) & MANT_MASK));
 #endif
-   return (((FLT_MAX_EXP - 1 + exp + norm_exp) << (FLT_MANT_DIG - 1)) |
+   return (((FLT_MAX_EXP - 1 + exponent + norm_exponent) << (FLT_MANT_DIG 
- 1)) |
((shift > 0 ? val << shift : val >> -shift) & MANT_MASK));
 }
 
@@ -518,7 +518,7 @@ encode_timeval(struct timeval tv)
 static uint32_t
 encode_long(long val)
 {
-   int norm_exp;   /* Normalized exponent */
+   int norm_exponent;  /* Normalized exponent */
int shift;
 
if (val == 0)
@@ -529,15 +529,15 @@ encode_long(long val)
val);
val = LONG_MAX;
}
-   norm_exp = fls(val) - 1;
-   shift = FLT_MANT_DIG - norm_exp - 1;
+   norm_exponent = fls(val) - 1;
+   shift = FLT_MANT_DIG - norm_exponent - 1;
 #ifdef ACCT_DEBUG
printf("val=%d shift=%d log2(val)=%d\n",
-   val, shift, norm_exp);
-   printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exp,
+   val, shift, norm_exponent);
+   printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exponent,
((shift > 0 ? (val << shift) : (val >> -shift)) & MANT_MASK));
 #endif
-   return (((FLT_MAX_EXP - 1 + norm_exp) << (FLT_MANT_DIG - 1)) |
+   return (((FLT_MAX_EXP - 1 + norm_exponent) << (FLT_MANT_DIG - 1)) |
((shift > 0 ? val << shift : val >> -shift) & MANT_MASK));
 }
 
___
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: r312118 - head/tests/sys/kern/execve

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 05:02:53 2017
New Revision: 312118
URL: https://svnweb.freebsd.org/changeset/base/312118

Log:
  Fix -Wformat issue with zero-length format string passed to err(3)
  
  MFC after:3 days
  Tested with:  clang, gcc 4.2.1, gcc 4.9
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/kern/execve/execve_helper.c

Modified: head/tests/sys/kern/execve/execve_helper.c
==
--- head/tests/sys/kern/execve/execve_helper.c  Sat Jan 14 04:34:30 2017
(r312117)
+++ head/tests/sys/kern/execve/execve_helper.c  Sat Jan 14 05:02:53 2017
(r312118)
@@ -50,5 +50,5 @@ main(int argc, char **argv)
}
 
execve(argv[1], [1], NULL);
-   err(1, "");
+   err(1, "%s", "");
 }
___
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: r312117 - stable/10/sys/dev/cxgbe/tom

2017-01-13 Thread Navdeep Parhar
Author: np
Date: Sat Jan 14 04:34:30 2017
New Revision: 312117
URL: https://svnweb.freebsd.org/changeset/base/312117

Log:
  MFC r311569, r311657, and r311949.
  
  r311569:
  Fix comment in t4_tom.  No functional change.
  
  r311657:
  cxgbe/t4_tom: Fix tid accounting.  An offloaded IPv6 connection uses 2
  tids, not 1, in the hardware.
  
  r311949:
  cxgbe/tom: Add VIMAGE support to the TOE driver.
  
  Active Open:
  - Save the socket's vnet at the time of the active open (t4_connect) and
switch to it when processing the reply (do_act_open_rpl or
do_act_establish).
  
  Passive Open:
  - Save the listening socket's vnet in the driver's listen_ctx and switch
to it when processing incoming SYNs for the socket.
  - Reject SYNs that arrive on an ifnet that's not in the same vnet as the
listening socket.
  
  CLIP (Compressed Local IPv6) table:
  - Add only those IPv6 addresses to the CLIP that are in a vnet
associated with one of the card's ifnets.
  
  Misc:
  - Set vnet from the toepcb when processing TCP state transitions.
  - The kernel sets the vnet when calling the driver's output routine
so t4_push_frames runs in proper vnet context already.  One exception
is when incoming credits trigger tx within the driver's ithread.  Set
the vnet explicitly in do_fw4_ack for that case.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/10/sys/dev/cxgbe/tom/t4_connect.c
  stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c
  stable/10/sys/dev/cxgbe/tom/t4_ddp.c
  stable/10/sys/dev/cxgbe/tom/t4_listen.c
  stable/10/sys/dev/cxgbe/tom/t4_tom.c
  stable/10/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/cxgbe/tom/t4_connect.c
==
--- stable/10/sys/dev/cxgbe/tom/t4_connect.cSat Jan 14 04:24:49 2017
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_connect.cSat Jan 14 04:34:30 2017
(r312117)
@@ -107,7 +107,7 @@ free_atid(struct adapter *sc, int atid)
 }
 
 /*
- * Active open failed.
+ * Active open succeeded.
  */
 static int
 do_act_establish(struct sge_iq *iq, const struct rss_header *rss,
@@ -126,9 +126,10 @@ do_act_establish(struct sge_iq *iq, cons
CTR3(KTR_CXGBE, "%s: atid %u, tid %u", __func__, atid, tid);
free_atid(sc, atid);
 
+   CURVNET_SET(toep->vnet);
INP_WLOCK(inp);
toep->tid = tid;
-   insert_tid(sc, tid, toep);
+   insert_tid(sc, tid, toep, inp->inp_vflag & INP_IPV6 ? 2 : 1);
if (inp->inp_flags & INP_DROPPED) {
 
/* socket closed by the kernel before hw told us it connected */
@@ -141,6 +142,7 @@ do_act_establish(struct sge_iq *iq, cons
make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt);
 done:
INP_WUNLOCK(inp);
+   CURVNET_RESTORE();
return (0);
 }
 
@@ -178,6 +180,7 @@ act_open_failure_cleanup(struct adapter 
free_atid(sc, atid);
toep->tid = -1;
 
+   CURVNET_SET(toep->vnet);
if (status != EAGAIN)
INP_INFO_RLOCK(_tcbinfo);
INP_WLOCK(inp);
@@ -185,8 +188,12 @@ act_open_failure_cleanup(struct adapter 
final_cpl_received(toep);   /* unlocks inp */
if (status != EAGAIN)
INP_INFO_RUNLOCK(_tcbinfo);
+   CURVNET_RESTORE();
 }
 
+/*
+ * Active open failed.
+ */
 static int
 do_act_open_rpl(struct sge_iq *iq, const struct rss_header *rss,
 struct mbuf *m)
@@ -357,6 +364,7 @@ t4_connect(struct toedev *tod, struct so
if (wr == NULL)
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
 
+   toep->vnet = so->so_vnet;
if (sc->tt.ddp && (so->so_options & SO_NO_DDP) == 0)
set_tcpddp_ulp_mode(toep);
else

Modified: stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c Sat Jan 14 04:24:49 2017
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c Sat Jan 14 04:34:30 2017
(r312117)
@@ -302,7 +302,6 @@ make_established(struct toepcb *toep, ui
uint16_t tcpopt = be16toh(opt);
struct flowc_tx_params ftxp;
 
-   CURVNET_SET(so->so_vnet);
INP_WLOCK_ASSERT(inp);
KASSERT(tp->t_state == TCPS_SYN_SENT ||
tp->t_state == TCPS_SYN_RECEIVED,
@@ -353,7 +352,6 @@ make_established(struct toepcb *toep, ui
send_flowc_wr(toep, );
 
soisconnected(so);
-   CURVNET_RESTORE();
 }
 
 static int
@@ -1107,6 +1105,7 @@ do_peer_close(struct sge_iq *iq, const s
 
KASSERT(toep->tid == tid, ("%s: toep tid mismatch", __func__));
 
+   CURVNET_SET(toep->vnet);
INP_INFO_RLOCK(_tcbinfo);
INP_WLOCK(inp);
tp = intotcpcb(inp);
@@ -1150,6 +1149,7 @@ do_peer_close(struct sge_iq *iq, const s
tcp_twstart(tp);
INP_UNLOCK_ASSERT(inp);  /* safe, we have a ref on the inp */
  

svn commit: r312116 - stable/11/sys/dev/cxgbe/tom

2017-01-13 Thread Navdeep Parhar
Author: np
Date: Sat Jan 14 04:24:49 2017
New Revision: 312116
URL: https://svnweb.freebsd.org/changeset/base/312116

Log:
  MFC r311569, r311657, and r311949.
  
  r311569:
  Fix comment in t4_tom.  No functional change.
  
  r311657:
  cxgbe/t4_tom: Fix tid accounting.  An offloaded IPv6 connection uses 2
  tids, not 1, in the hardware.
  
  r311949:
  cxgbe/tom: Add VIMAGE support to the TOE driver.
  
  Active Open:
  - Save the socket's vnet at the time of the active open (t4_connect) and
switch to it when processing the reply (do_act_open_rpl or
do_act_establish).
  
  Passive Open:
  - Save the listening socket's vnet in the driver's listen_ctx and switch
to it when processing incoming SYNs for the socket.
  - Reject SYNs that arrive on an ifnet that's not in the same vnet as the
listening socket.
  
  CLIP (Compressed Local IPv6) table:
  - Add only those IPv6 addresses to the CLIP that are in a vnet
associated with one of the card's ifnets.
  
  Misc:
  - Set vnet from the toepcb when processing TCP state transitions.
  - The kernel sets the vnet when calling the driver's output routine
so t4_push_frames runs in proper vnet context already.  One exception
is when incoming credits trigger tx within the driver's ithread.  Set
the vnet explicitly in do_fw4_ack for that case.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/11/sys/dev/cxgbe/tom/t4_connect.c
  stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c
  stable/11/sys/dev/cxgbe/tom/t4_ddp.c
  stable/11/sys/dev/cxgbe/tom/t4_listen.c
  stable/11/sys/dev/cxgbe/tom/t4_tom.c
  stable/11/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/tom/t4_connect.c
==
--- stable/11/sys/dev/cxgbe/tom/t4_connect.cSat Jan 14 04:20:42 2017
(r312115)
+++ stable/11/sys/dev/cxgbe/tom/t4_connect.cSat Jan 14 04:24:49 2017
(r312116)
@@ -107,7 +107,7 @@ free_atid(struct adapter *sc, int atid)
 }
 
 /*
- * Active open failed.
+ * Active open succeeded.
  */
 static int
 do_act_establish(struct sge_iq *iq, const struct rss_header *rss,
@@ -126,9 +126,10 @@ do_act_establish(struct sge_iq *iq, cons
CTR3(KTR_CXGBE, "%s: atid %u, tid %u", __func__, atid, tid);
free_atid(sc, atid);
 
+   CURVNET_SET(toep->vnet);
INP_WLOCK(inp);
toep->tid = tid;
-   insert_tid(sc, tid, toep);
+   insert_tid(sc, tid, toep, inp->inp_vflag & INP_IPV6 ? 2 : 1);
if (inp->inp_flags & INP_DROPPED) {
 
/* socket closed by the kernel before hw told us it connected */
@@ -141,6 +142,7 @@ do_act_establish(struct sge_iq *iq, cons
make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt);
 done:
INP_WUNLOCK(inp);
+   CURVNET_RESTORE();
return (0);
 }
 
@@ -178,6 +180,7 @@ act_open_failure_cleanup(struct adapter 
free_atid(sc, atid);
toep->tid = -1;
 
+   CURVNET_SET(toep->vnet);
if (status != EAGAIN)
INP_INFO_RLOCK(_tcbinfo);
INP_WLOCK(inp);
@@ -185,8 +188,12 @@ act_open_failure_cleanup(struct adapter 
final_cpl_received(toep);   /* unlocks inp */
if (status != EAGAIN)
INP_INFO_RUNLOCK(_tcbinfo);
+   CURVNET_RESTORE();
 }
 
+/*
+ * Active open failed.
+ */
 static int
 do_act_open_rpl(struct sge_iq *iq, const struct rss_header *rss,
 struct mbuf *m)
@@ -357,6 +364,7 @@ t4_connect(struct toedev *tod, struct so
if (wr == NULL)
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
 
+   toep->vnet = so->so_vnet;
if (sc->tt.ddp && (so->so_options & SO_NO_DDP) == 0)
set_tcpddp_ulp_mode(toep);
else

Modified: stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c Sat Jan 14 04:20:42 2017
(r312115)
+++ stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c Sat Jan 14 04:24:49 2017
(r312116)
@@ -306,7 +306,6 @@ make_established(struct toepcb *toep, ui
uint16_t tcpopt = be16toh(opt);
struct flowc_tx_params ftxp;
 
-   CURVNET_SET(so->so_vnet);
INP_WLOCK_ASSERT(inp);
KASSERT(tp->t_state == TCPS_SYN_SENT ||
tp->t_state == TCPS_SYN_RECEIVED,
@@ -357,7 +356,6 @@ make_established(struct toepcb *toep, ui
send_flowc_wr(toep, );
 
soisconnected(so);
-   CURVNET_RESTORE();
 }
 
 static int
@@ -1146,6 +1144,7 @@ do_peer_close(struct sge_iq *iq, const s
 
KASSERT(toep->tid == tid, ("%s: toep tid mismatch", __func__));
 
+   CURVNET_SET(toep->vnet);
INP_INFO_RLOCK(_tcbinfo);
INP_WLOCK(inp);
tp = intotcpcb(inp);
@@ -1191,6 +1190,7 @@ do_peer_close(struct sge_iq *iq, const s
tcp_twstart(tp);
INP_UNLOCK_ASSERT(inp);  /* safe, we have a ref on the inp */
  

Re: svn commit: r312103 - head/tests/sys/vfs

2017-01-13 Thread Cy Schubert
No problem.

My make.conf doesn't adjust any warning levels, they're vanilla so, the 
build barfed at that line.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


In message 
, Conrad Meyer writes:
> Hi Cy,
> 
> r312107 fixes it.  If the warning-cleanups and major changes were
> committed separately, the more major changes could then have been
> reverted independently.  Unfortunately, they were not.  The warnings
> are harmless, though, so just turning them down again is fine.
> 
> Best,
> Conrad
> 
> On Fri, Jan 13, 2017 at 6:39 PM, Cy Schubert  wrote
> :
> > In message <201701140103.v0e13k8b068...@repo.freebsd.org>, "Conrad E.
> > Meyer" wr
> > ites:
> >> Author: cem
> >> Date: Sat Jan 14 01:03:20 2017
> >> New Revision: 312103
> >> URL: https://svnweb.freebsd.org/changeset/base/312103
> >>
> >> Log:
> >>   Revert r310994
> >>
> >>   Don't implement some terrible hack on a test by test basis.  The
> >>   framework fix is straightforward and can be chased up in the original
> >>   bug.
> >>
> >>   Reviewed by:ngie ("be my guest")
> >>
> >> Modified:
> >>   head/tests/sys/vfs/lookup_cap_dotdot.c
> >>
> >> Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
> >> ==
> ===
> >> =
> >> --- head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:01:02 2017
> >>   (r312102)
> >> +++ head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:03:20 2017
> >>   (r312103)
> >> @@ -31,27 +31,23 @@ __FBSDID("$FreeBSD$");
> >>  #include 
> >>  #include 
> >>  #include 
> >> -#include 
> >>
> >>  #include 
> >> -#include 
> >>  #include 
> >>  #include 
> >>  #include 
> >>
> >>  #include "freebsd_test_suite/macros.h"
> >>
> >> -static char  *abspath;
> >> -static int   dirfd = -1;
> >> -
> >> -typedef  void (*child_test_fn_t)(void);
> >> +static int dirfd = -1;
> >> +static char *abspath;
> >>
> >>  static void
> >> -touchat(int _dirfd, const char *name)
> >> +touchat(int dirfd, const char *name)
> >
> > Buildworld is busted right here. It's probably best to leave the underbar
> > here and in the ATF_REQIRE below.
> >
> >>  {
> >>   int fd;
> >>
> >> - ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
> >> + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
> >
> > Here too.
> >
> >>   0777)) >= 0);
> >>   ATF_REQUIRE(close(fd) == 0);
> >>  }
> >
> >
> > --
> > Cheers,
> > Cy Schubert 
> > FreeBSD UNIX:     Web:  http://www.FreeBSD.org
> >
> > The need of the many outweighs the greed of the few.
> >
> >
> 


___
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: r312115 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:20:42 2017
New Revision: 312115
URL: https://svnweb.freebsd.org/changeset/base/312115

Log:
  Remove WARNS set globally by ../Makefile.inc now
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/vfs/Makefile

Modified: head/tests/sys/vfs/Makefile
==
--- head/tests/sys/vfs/Makefile Sat Jan 14 04:20:06 2017(r312114)
+++ head/tests/sys/vfs/Makefile Sat Jan 14 04:20:42 2017(r312115)
@@ -9,6 +9,4 @@ CFLAGS.lookup_cap_dotdot.c+=-I${SRCTOP}
 
 PLAIN_TESTS_SH+=   trailing_slash
 
-WARNS?=6
-
 .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: r312114 - head/tests/sys

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:20:06 2017
New Revision: 312114
URL: https://svnweb.freebsd.org/changeset/base/312114

Log:
  Enable WARNS?= 6 across all of tests/sys
  
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Added:
  head/tests/sys/Makefile.inc   (contents, props changed)

Added: head/tests/sys/Makefile.inc
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/Makefile.inc Sat Jan 14 04:20:06 2017(r312114)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+WARNS?=6
___
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: r312113 - head/sys/kern

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:16:13 2017
New Revision: 312113
URL: https://svnweb.freebsd.org/changeset/base/312113

Log:
  Clean up trailing whitespace
  
  MFC after:3 days
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/subr_unit.c

Modified: head/sys/kern/subr_unit.c
==
--- head/sys/kern/subr_unit.c   Sat Jan 14 04:13:28 2017(r312112)
+++ head/sys/kern/subr_unit.c   Sat Jan 14 04:16:13 2017(r312113)
@@ -216,7 +216,7 @@ ub_full(struct unrb *ub, int len)
  * Consistency check function.
  *
  * Checks the internal consistency as well as we can.
- * 
+ *
  * Called at all boundaries of this API.
  */
 static void
@@ -240,7 +240,7 @@ check_unrhdr(struct unrhdr *uh, int line
w = 0;
bit_count(ub->map, 0, up->len, );
y += w;
-   } else if (up->ptr != NULL) 
+   } else if (up->ptr != NULL)
y += up->len;
}
KASSERT (y == uh->busy,
@@ -375,7 +375,7 @@ is_bitmap(struct unrhdr *uh, struct unr 
 /*
  * Look for sequence of items which can be combined into a bitmap, if
  * multiple are present, take the one which saves most memory.
- * 
+ *
  * Return (1) if a sequence was found to indicate that another call
  * might be able to do more.  Return (0) if we found no suitable sequence.
  *
@@ -591,7 +591,7 @@ alloc_unrl(struct unrhdr *uh)
}
 
/*
-* We can always allocate from the first list element, so if we have 
+* We can always allocate from the first list element, so if we have
 * nothing on the list, we must have run out of unit numbers.
 */
if (up == NULL)
@@ -803,7 +803,7 @@ free_unrl(struct unrhdr *uh, u_int item,
/* Handle bitmap items */
if (is_bitmap(uh, up)) {
ub = up->ptr;
-   
+
KASSERT(bit_test(ub->map, item) != 0,
("UNR: Freeing free item %d (bitmap)\n", item));
bit_clear(ub->map, item);
@@ -909,7 +909,7 @@ print_unr(struct unrhdr *uh, struct unr 
for (x = 0; x < up->len; x++) {
if (bit_test(ub->map, x))
printf("#");
-   else 
+   else
printf(" ");
}
printf("]\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"


svn commit: r312112 - head/sys/kern

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:13:28 2017
New Revision: 312112
URL: https://svnweb.freebsd.org/changeset/base/312112

Log:
  Fix -Wunused on gcc 4.9 (x was set but not used)
  
  MFC after:3 days
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/subr_unit.c

Modified: head/sys/kern/subr_unit.c
==
--- head/sys/kern/subr_unit.c   Sat Jan 14 04:10:04 2017(r312111)
+++ head/sys/kern/subr_unit.c   Sat Jan 14 04:13:28 2017(r312112)
@@ -986,7 +986,7 @@ main(int argc, char **argv)
long count = 1; /* Number of unrs to test */
long reps = 1, m;
int ch;
-   u_int i, x, j;
+   u_int i, j;
 
verbose = false;
 
@@ -999,7 +999,7 @@ main(int argc, char **argv)
usage(argv);
exit(2);
}
-   
+
break;
case 'v':
verbose = true;
@@ -1026,7 +1026,6 @@ main(int argc, char **argv)
printf("sizeof(struct unrb) %zu\n", sizeof(struct unrb));
printf("sizeof(struct unrhdr) %zu\n", sizeof(struct unrhdr));
printf("NBITS %lu\n", (unsigned long)NBITS);
-   x = 1;
for (m = 0; m < count * reps; m++) {
j = random();
i = (j >> 1) % count;
___
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: r312111 - head/tests/sys/file

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:10:04 2017
New Revision: 312111
URL: https://svnweb.freebsd.org/changeset/base/312111

Log:
  Remove unused vars to fix -Wunused issues
  
  MFC after:3 days
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/file/ftruncate_test.c

Modified: head/tests/sys/file/ftruncate_test.c
==
--- head/tests/sys/file/ftruncate_test.cSat Jan 14 04:09:01 2017
(r312110)
+++ head/tests/sys/file/ftruncate_test.cSat Jan 14 04:10:04 2017
(r312111)
@@ -57,7 +57,7 @@ static off_t lengths[] = {0, 1, 2, 3, 4,
 static int lengths_count = sizeof(lengths) / sizeof(off_t);
 
 int
-main(int argc, char *argv[])
+main(void)
 {
int error, fd, fds[2], i, read_only_fd;
char path[PATH_MAX];
___
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: r312110 - head/tests/sys/vm

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:09:01 2017
New Revision: 312110
URL: https://svnweb.freebsd.org/changeset/base/312110

Log:
  Fix -Wsign-compare warnings
  
  The loop index (i) doesn't need to be size_t as its comparison is signed
  
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/vm/mmap_test.c

Modified: head/tests/sys/vm/mmap_test.c
==
--- head/tests/sys/vm/mmap_test.c   Sat Jan 14 04:00:26 2017
(r312109)
+++ head/tests/sys/vm/mmap_test.c   Sat Jan 14 04:09:01 2017
(r312110)
@@ -184,8 +184,7 @@ ATF_TC_WITHOUT_HEAD(mmap__dev_zero_priva
 ATF_TC_BODY(mmap__dev_zero_private, tc)
 {
char *p1, *p2, *p3;
-   size_t i;
-   int fd, pagesize;
+   int fd, i, pagesize;
 
ATF_REQUIRE((pagesize = getpagesize()) > 0);
ATF_REQUIRE((fd = open("/dev/zero", O_RDONLY)) >= 0);
@@ -197,7 +196,7 @@ ATF_TC_BODY(mmap__dev_zero_private, tc)
ATF_REQUIRE(p2 != MAP_FAILED);
 
for (i = 0; i < pagesize; i++)
-   ATF_REQUIRE_EQ_MSG(0, p1[i], "byte at p1[%zu] is %x", i, p1[i]);
+   ATF_REQUIRE_EQ_MSG(0, p1[i], "byte at p1[%d] is %x", i, p1[i]);
 
ATF_REQUIRE(memcmp(p1, p2, pagesize) == 0);
 
@@ -224,8 +223,7 @@ ATF_TC_WITHOUT_HEAD(mmap__dev_zero_share
 ATF_TC_BODY(mmap__dev_zero_shared, tc)
 {
char *p1, *p2, *p3;
-   size_t i;
-   int fd, pagesize;
+   int fd, i, pagesize;
 
ATF_REQUIRE((pagesize = getpagesize()) > 0);
ATF_REQUIRE((fd = open("/dev/zero", O_RDWR)) >= 0);
@@ -237,7 +235,7 @@ ATF_TC_BODY(mmap__dev_zero_shared, tc)
ATF_REQUIRE(p2 != MAP_FAILED);
 
for (i = 0; i < pagesize; i++)
-   ATF_REQUIRE_EQ_MSG(0, p1[i], "byte at p1[%zu] is %x", i, p1[i]);
+   ATF_REQUIRE_EQ_MSG(0, p1[i], "byte at p1[%d] is %x", i, p1[i]);
 
ATF_REQUIRE(memcmp(p1, p2, pagesize) == 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"


Re: svn commit: r312103 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 7:50 PM, Conrad Meyer  wrote:
> 
> Hi Cy,
> 
> r312107 fixes it.  If the warning-cleanups and major changes were
> committed separately, the more major changes could then have been
> reverted independently.  Unfortunately, they were not.  The warnings
> are harmless, though, so just turning them down again is fine.

Trivial fixes reapplied in r312109.
___
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: r312109 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 04:00:26 2017
New Revision: 312109
URL: https://svnweb.freebsd.org/changeset/base/312109

Log:
  Bump WARNS up to 6 again
  
  Has not been tested (can't be after r312103 without cem's hacks
  to atf/kyua)!

Modified:
  head/tests/sys/vfs/Makefile
  head/tests/sys/vfs/lookup_cap_dotdot.c

Modified: head/tests/sys/vfs/Makefile
==
--- head/tests/sys/vfs/Makefile Sat Jan 14 03:54:23 2017(r312108)
+++ head/tests/sys/vfs/Makefile Sat Jan 14 04:00:26 2017(r312109)
@@ -9,4 +9,6 @@ CFLAGS.lookup_cap_dotdot.c+=-I${SRCTOP}
 
 PLAIN_TESTS_SH+=   trailing_slash
 
+WARNS?=6
+
 .include 

Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
==
--- head/tests/sys/vfs/lookup_cap_dotdot.c  Sat Jan 14 03:54:23 2017
(r312108)
+++ head/tests/sys/vfs/lookup_cap_dotdot.c  Sat Jan 14 04:00:26 2017
(r312109)
@@ -43,11 +43,11 @@ static int dirfd = -1;
 static char *abspath;
 
 static void
-touchat(int dirfd, const char *name)
+touchat(int _dirfd, const char *name)
 {
int fd;
 
-   ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
+   ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
0777)) >= 0);
ATF_REQUIRE(close(fd) == 0);
 }
@@ -117,7 +117,6 @@ ATF_TC_HEAD(lookup_cap_dotdot__basic, tc
 ATF_TC_BODY(lookup_cap_dotdot__basic, tc)
 {
cap_rights_t rights;
-   int fd;
 
check_capsicum();
prepare_dotdot_tests();
@@ -141,7 +140,6 @@ ATF_TC_HEAD(lookup_cap_dotdot__advanced,
 ATF_TC_BODY(lookup_cap_dotdot__advanced, tc)
 {
cap_rights_t rights;
-   int fd;
 
check_capsicum();
prepare_dotdot_tests();
@@ -220,7 +218,6 @@ ATF_TC_HEAD(lookup_cap_dotdot__negative,
 ATF_TC_BODY(lookup_cap_dotdot__negative, tc)
 {
cap_rights_t rights;
-   int fd;
 
check_capsicum();
prepare_dotdot_tests();
___
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: r312108 - head/contrib/netbsd-tests/lib/libc/gen/posix_spawn

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 03:54:23 2017
New Revision: 312108
URL: https://svnweb.freebsd.org/changeset/base/312108

Log:
  Delete trailing whitespace and use __arraycount instead of nitems in contrib 
code
  
  MFC after:1 week

Modified:
  head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c

Modified: head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
==
--- head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.cSat Jan 
14 02:29:25 2017(r312107)
+++ head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.cSat Jan 
14 03:54:23 2017(r312108)
@@ -60,16 +60,16 @@ get_different_scheduler(void)
 
/* get current schedule policy */
scheduler = sched_getscheduler(0);
-   for (i = 0; i < nitems(schedulers); i++) {
+   for (i = 0; i < __arraycount(schedulers); i++) {
if (schedulers[i] == scheduler)
break;
}
-   ATF_REQUIRE_MSG(i < nitems(schedulers),
+   ATF_REQUIRE_MSG(i < __arraycount(schedulers),
"Unknown current scheduler %d", scheduler);
-   
+
/* new scheduler */
i++;
-   if (i >= nitems(schedulers))
+   if (i >= __arraycount(schedulers))
i = 0;
return schedulers[i];
 }
@@ -85,7 +85,7 @@ get_different_priority(int scheduler)
 
sched_getparam(0, );
priority = param.sched_priority;
-   
+
/*
 * Change numerical value of the priority, to ensure that it
 * was set for the spawned child.
@@ -127,7 +127,7 @@ ATF_TC_BODY(t_spawnattr, tc)
scheduler = get_different_scheduler();
priority = get_different_priority(scheduler);
sp.sched_priority = priority;
-   
+
sigemptyset();
sigaddset(, SIGUSR1);
 
___
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: r312103 - head/tests/sys/vfs

2017-01-13 Thread Conrad Meyer
Hi Cy,

r312107 fixes it.  If the warning-cleanups and major changes were
committed separately, the more major changes could then have been
reverted independently.  Unfortunately, they were not.  The warnings
are harmless, though, so just turning them down again is fine.

Best,
Conrad

On Fri, Jan 13, 2017 at 6:39 PM, Cy Schubert  wrote:
> In message <201701140103.v0e13k8b068...@repo.freebsd.org>, "Conrad E.
> Meyer" wr
> ites:
>> Author: cem
>> Date: Sat Jan 14 01:03:20 2017
>> New Revision: 312103
>> URL: https://svnweb.freebsd.org/changeset/base/312103
>>
>> Log:
>>   Revert r310994
>>
>>   Don't implement some terrible hack on a test by test basis.  The
>>   framework fix is straightforward and can be chased up in the original
>>   bug.
>>
>>   Reviewed by:ngie ("be my guest")
>>
>> Modified:
>>   head/tests/sys/vfs/lookup_cap_dotdot.c
>>
>> Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
>> =
>> =
>> --- head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:01:02 2017
>>   (r312102)
>> +++ head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:03:20 2017
>>   (r312103)
>> @@ -31,27 +31,23 @@ __FBSDID("$FreeBSD$");
>>  #include 
>>  #include 
>>  #include 
>> -#include 
>>
>>  #include 
>> -#include 
>>  #include 
>>  #include 
>>  #include 
>>
>>  #include "freebsd_test_suite/macros.h"
>>
>> -static char  *abspath;
>> -static int   dirfd = -1;
>> -
>> -typedef  void (*child_test_fn_t)(void);
>> +static int dirfd = -1;
>> +static char *abspath;
>>
>>  static void
>> -touchat(int _dirfd, const char *name)
>> +touchat(int dirfd, const char *name)
>
> Buildworld is busted right here. It's probably best to leave the underbar
> here and in the ATF_REQIRE below.
>
>>  {
>>   int fd;
>>
>> - ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
>> + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
>
> Here too.
>
>>   0777)) >= 0);
>>   ATF_REQUIRE(close(fd) == 0);
>>  }
>
>
> --
> Cheers,
> Cy Schubert 
> FreeBSD UNIX:     Web:  http://www.FreeBSD.org
>
> The need of the many outweighs the greed of the few.
>
>
___
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: r312103 - head/tests/sys/vfs

2017-01-13 Thread Cy Schubert
In message <201701140103.v0e13k8b068...@repo.freebsd.org>, "Conrad E. 
Meyer" wr
ites:
> Author: cem
> Date: Sat Jan 14 01:03:20 2017
> New Revision: 312103
> URL: https://svnweb.freebsd.org/changeset/base/312103
> 
> Log:
>   Revert r310994
>   
>   Don't implement some terrible hack on a test by test basis.  The
>   framework fix is straightforward and can be chased up in the original
>   bug.
>   
>   Reviewed by:ngie ("be my guest")
> 
> Modified:
>   head/tests/sys/vfs/lookup_cap_dotdot.c
> 
> Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
> =
> =
> --- head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:01:02 2017
>   (r312102)
> +++ head/tests/sys/vfs/lookup_cap_dotdot.cSat Jan 14 01:03:20 2017
>   (r312103)
> @@ -31,27 +31,23 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> -#include 
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  
>  #include "freebsd_test_suite/macros.h"
>  
> -static char  *abspath;
> -static int   dirfd = -1;
> -
> -typedef  void (*child_test_fn_t)(void);
> +static int dirfd = -1;
> +static char *abspath;
>  
>  static void
> -touchat(int _dirfd, const char *name)
> +touchat(int dirfd, const char *name)

Buildworld is busted right here. It's probably best to leave the underbar 
here and in the ATF_REQIRE below.

>  {
>   int fd;
>  
> - ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
> + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,

Here too.

>   0777)) >= 0);
>   ATF_REQUIRE(close(fd) == 0);
>  }


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
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: r312107 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 18:29, Conrad E. Meyer  wrote:
> 
> Author: cem
> Date: Sat Jan 14 02:29:25 2017
> New Revision: 312107
> URL: https://svnweb.freebsd.org/changeset/base/312107
> 
> Log:
>  Follow-up to r312103:
> 
>  Revert r310995 as well.
> 
> Modified:
>  head/tests/sys/vfs/Makefile
> 
> Modified: head/tests/sys/vfs/Makefile
> ==
> --- head/tests/sys/vfs/Makefile   Sat Jan 14 02:26:46 2017
> (r312106)
> +++ head/tests/sys/vfs/Makefile   Sat Jan 14 02:29:25 2017
> (r312107)
> @@ -9,6 +9,4 @@ CFLAGS.lookup_cap_dotdot.c+=  -I${SRCTOP}
> 
> PLAIN_TESTS_SH+=  trailing_slash
> 
> -WARNS?=  6
> -
> .include 

Why don’t you fix the test code to be -Werror clean instead with WARNS?


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r312107 - head/tests/sys/vfs

2017-01-13 Thread Conrad E. Meyer
Author: cem
Date: Sat Jan 14 02:29:25 2017
New Revision: 312107
URL: https://svnweb.freebsd.org/changeset/base/312107

Log:
  Follow-up to r312103:
  
  Revert r310995 as well.

Modified:
  head/tests/sys/vfs/Makefile

Modified: head/tests/sys/vfs/Makefile
==
--- head/tests/sys/vfs/Makefile Sat Jan 14 02:26:46 2017(r312106)
+++ head/tests/sys/vfs/Makefile Sat Jan 14 02:29:25 2017(r312107)
@@ -9,6 +9,4 @@ CFLAGS.lookup_cap_dotdot.c+=-I${SRCTOP}
 
 PLAIN_TESTS_SH+=   trailing_slash
 
-WARNS?=6
-
 .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: r312106 - in vendor/NetBSD/tests/dist: dev/cgd dev/scsipi dev/sysmon fs/common fs/ffs fs/hfs fs/kernfs fs/lfs fs/msdosfs fs/nfs fs/nullfs fs/ptyfs fs/puffs fs/tmpfs fs/umapfs fs/union f...

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 02:26:46 2017
New Revision: 312106
URL: https://svnweb.freebsd.org/changeset/base/312106

Log:
  Commit more accepted upstream changes from /tests/...
  
  This includes a number of accepted patches for:
  - lib/libc/sys
  - lib/libm
  
  christos was also nice enough to do the heavy lifting with the h_macros.h
  #includes so testcases which use h_macros.h now can work more easily with
  the FreeBSD tree's layout for contrib/netbsd-tests vs the testcases.

Modified:
  vendor/NetBSD/tests/dist/dev/cgd/t_cgd_3des.c
  vendor/NetBSD/tests/dist/dev/cgd/t_cgd_aes.c
  vendor/NetBSD/tests/dist/dev/cgd/t_cgd_blowfish.c
  vendor/NetBSD/tests/dist/dev/scsipi/t_cd.c
  vendor/NetBSD/tests/dist/dev/sysmon/t_swwdog.c
  vendor/NetBSD/tests/dist/fs/common/h_fsmacros.h
  vendor/NetBSD/tests/dist/fs/ffs/h_quota2_tests.c
  vendor/NetBSD/tests/dist/fs/ffs/t_fifos.c
  vendor/NetBSD/tests/dist/fs/ffs/t_mount.c
  vendor/NetBSD/tests/dist/fs/ffs/t_quota2_1.c
  vendor/NetBSD/tests/dist/fs/ffs/t_quota2_remount.c
  vendor/NetBSD/tests/dist/fs/ffs/t_snapshot.c
  vendor/NetBSD/tests/dist/fs/ffs/t_snapshot_log.c
  vendor/NetBSD/tests/dist/fs/ffs/t_snapshot_v2.c
  vendor/NetBSD/tests/dist/fs/hfs/t_pathconvert.c
  vendor/NetBSD/tests/dist/fs/kernfs/t_basic.c
  vendor/NetBSD/tests/dist/fs/lfs/t_pr.c
  vendor/NetBSD/tests/dist/fs/msdosfs/t_snapshot.c
  vendor/NetBSD/tests/dist/fs/nfs/t_mountd.c
  vendor/NetBSD/tests/dist/fs/nullfs/t_basic.c
  vendor/NetBSD/tests/dist/fs/ptyfs/t_nullpts.c
  vendor/NetBSD/tests/dist/fs/ptyfs/t_ptyfs.c
  vendor/NetBSD/tests/dist/fs/puffs/t_basic.c
  vendor/NetBSD/tests/dist/fs/puffs/t_fuzz.c
  vendor/NetBSD/tests/dist/fs/puffs/t_io.c
  vendor/NetBSD/tests/dist/fs/tmpfs/t_renamerace.c
  vendor/NetBSD/tests/dist/fs/umapfs/t_basic.c
  vendor/NetBSD/tests/dist/fs/union/t_pr.c
  vendor/NetBSD/tests/dist/fs/vfs/t_full.c
  vendor/NetBSD/tests/dist/fs/vfs/t_io.c
  vendor/NetBSD/tests/dist/fs/vfs/t_renamerace.c
  vendor/NetBSD/tests/dist/fs/vfs/t_ro.c
  vendor/NetBSD/tests/dist/fs/vfs/t_union.c
  vendor/NetBSD/tests/dist/fs/vfs/t_unpriv.c
  vendor/NetBSD/tests/dist/fs/vfs/t_vfsops.c
  vendor/NetBSD/tests/dist/fs/vfs/t_vnops.c
  vendor/NetBSD/tests/dist/include/sys/t_socket.c
  vendor/NetBSD/tests/dist/kernel/kqueue/read/t_fifo.c
  vendor/NetBSD/tests/dist/kernel/kqueue/read/t_file.c
  vendor/NetBSD/tests/dist/kernel/kqueue/read/t_file2.c
  vendor/NetBSD/tests/dist/kernel/kqueue/read/t_pipe.c
  vendor/NetBSD/tests/dist/kernel/kqueue/read/t_ttypty.c
  vendor/NetBSD/tests/dist/kernel/kqueue/t_ioctl.c
  vendor/NetBSD/tests/dist/kernel/kqueue/t_proc1.c
  vendor/NetBSD/tests/dist/kernel/kqueue/t_proc2.c
  vendor/NetBSD/tests/dist/kernel/kqueue/t_proc3.c
  vendor/NetBSD/tests/dist/kernel/kqueue/t_sig.c
  vendor/NetBSD/tests/dist/kernel/kqueue/write/t_fifo.c
  vendor/NetBSD/tests/dist/kernel/kqueue/write/t_pipe.c
  vendor/NetBSD/tests/dist/kernel/kqueue/write/t_ttypty.c
  vendor/NetBSD/tests/dist/kernel/t_extent.c
  vendor/NetBSD/tests/dist/kernel/t_filedesc.c
  vendor/NetBSD/tests/dist/kernel/t_lock.c
  vendor/NetBSD/tests/dist/kernel/t_ptrace.c
  vendor/NetBSD/tests/dist/kernel/t_ptrace_wait.c
  vendor/NetBSD/tests/dist/kernel/t_pty.c
  vendor/NetBSD/tests/dist/kernel/t_rnd.c
  vendor/NetBSD/tests/dist/lib/libc/gen/t_glob.c
  vendor/NetBSD/tests/dist/lib/libc/regex/debug.c
  vendor/NetBSD/tests/dist/lib/libc/regex/t_exhaust.c
  vendor/NetBSD/tests/dist/lib/libc/regex/t_regex_att.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_clock_gettime.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_connect.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_dup.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_getrusage.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_link.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_listen.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_mmap.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_msgctl.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_msgrcv.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_msgsnd.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_nanosleep.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_pipe.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_pipe2.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_posix_fadvise.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_revoke.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_select.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_setrlimit.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_sigaction.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_sigqueue.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_socketpair.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_stat.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_truncate.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_umask.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_unlink.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_wait.c
  vendor/NetBSD/tests/dist/lib/libc/sys/t_write.c
  vendor/NetBSD/tests/dist/lib/libm/t_ilogb.c
  vendor/NetBSD/tests/dist/lib/libm/t_scalbn.c
  vendor/NetBSD/tests/dist/lib/libposix/t_rename.c
  vendor/NetBSD/tests/dist/lib/librumpclient/t_fd.c
  

Re: svn commit: r312103 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 17:07, Ngie Cooper (yaneurabeya)  
> wrote:
> 
> 
>> On Jan 13, 2017, at 17:06, Ngie Cooper (yaneurabeya)  
>> wrote:
>> 
>>> 
>>> On Jan 13, 2017, at 17:03, Conrad E. Meyer  wrote:
>>> 
>>> Author: cem
>>> Date: Sat Jan 14 01:03:20 2017
>>> New Revision: 312103
>>> URL: https://svnweb.freebsd.org/changeset/base/312103
>>> 
>>> Log:
>>> Revert r310994
>>> 
>>> Don't implement some terrible hack on a test by test basis.  The
>>> framework fix is straightforward and can be chased up in the original
>>> bug.
>>> 
>>> Reviewed by:ngie ("be my guest")
>> 
>> You should have filed an issue with atf/kyua, had the fix done, then done 
>> the necessary parts in releasing a new port/package. Please disable the test 
>> because it doesn’t work at all right now on CURRENT and it will ping the 
>> sh’t out of the jenkins email until fixed.
>> -Ngie
> 
> PS Saying “be my guest” isn’t review in any shape or form, nor is it my 
> consent towards your change being implemented now.

Oh yeah… this commit broke the build too because I turned on WARNS: 
https://jenkins.freebsd.org/job/FreeBSD_HEAD_i386/4653/
Cheers,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r312105 - head/usr.sbin/inetd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 01:37:03 2017
New Revision: 312105
URL: https://svnweb.freebsd.org/changeset/base/312105

Log:
  Conditionalize libwrap support into inetd based on MK_TCP_WRAPPERS
  
  This will allow inetd to stand by itself without libwrap.
  
  MFC after:2 weeks
  Relnotes: yes
  Reviewed by:  hrs (earlier version)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D9056

Modified:
  head/usr.sbin/inetd/Makefile
  head/usr.sbin/inetd/inetd.c

Modified: head/usr.sbin/inetd/Makefile
==
--- head/usr.sbin/inetd/MakefileSat Jan 14 01:08:04 2017
(r312104)
+++ head/usr.sbin/inetd/MakefileSat Jan 14 01:37:03 2017
(r312105)
@@ -16,7 +16,12 @@ CFLAGS+= -DLOGIN_CAP
 CFLAGS+= -DINET6
 .endif
 
-LIBADD=util wrap
+LIBADD=util
+
+.if ${MK_TCP_WRAPPERS} != "no"
+CFLAGS+=   -DLIBWRAP
+LIBADD+=   wrap
+.endif
 
 # XXX for src/release/picobsd
 .if !defined(RELEASE_CRUNCH)

Modified: head/usr.sbin/inetd/inetd.c
==
--- head/usr.sbin/inetd/inetd.c Sat Jan 14 01:08:04 2017(r312104)
+++ head/usr.sbin/inetd/inetd.c Sat Jan 14 01:37:03 2017(r312105)
@@ -336,9 +336,11 @@ main(int argc, char **argv)
 #ifdef LOGIN_CAP
login_cap_t *lc = NULL;
 #endif
+#ifdef LIBWRAP
struct request_info req;
int denied;
char *service = NULL;
+#endif
struct sockaddr_storage peer;
int i;
struct addrinfo hints, *res;
@@ -748,6 +750,7 @@ main(int argc, char **argv)
_exit(0);
}
}
+#ifdef LIBWRAP
if (ISWRAP(sep)) {
inetd_setproctitle("wrapping", ctrl);
service = sep->se_server_name ?
@@ -776,6 +779,7 @@ main(int argc, char **argv)
(whichaf() == AF_INET6) ? "6" : "");
}
}
+#endif
if (sep->se_bi) {
(*sep->se_bi->bi_fn)(ctrl, sep);
} 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: r312104 - head/usr.sbin/fstyp/tests

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 17:08, Conrad E. Meyer  wrote:
> 
> Author: cem
> Date: Sat Jan 14 01:08:04 2017
> New Revision: 312104
> URL: https://svnweb.freebsd.org/changeset/base/312104
> 
> Log:
>  Fix broken fstyp exfat testcase
> 
>  Introduced in r312010.
> 
>  It helps to read the documentation before trying to test something.

It helps when the documentation is correct as well. Not fixed until r312078.
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r312104 - head/usr.sbin/fstyp/tests

2017-01-13 Thread Conrad E. Meyer
Author: cem
Date: Sat Jan 14 01:08:04 2017
New Revision: 312104
URL: https://svnweb.freebsd.org/changeset/base/312104

Log:
  Fix broken fstyp exfat testcase
  
  Introduced in r312010.
  
  It helps to read the documentation before trying to test something.

Modified:
  head/usr.sbin/fstyp/tests/fstyp_test.sh

Modified: head/usr.sbin/fstyp/tests/fstyp_test.sh
==
--- head/usr.sbin/fstyp/tests/fstyp_test.sh Sat Jan 14 01:03:20 2017
(r312103)
+++ head/usr.sbin/fstyp/tests/fstyp_test.sh Sat Jan 14 01:08:04 2017
(r312104)
@@ -64,7 +64,7 @@ exfat_head() {
 }
 exfat_body() {
bzcat $(atf_get_srcdir)/dfr-01-xfat.img.bz2 > exfat.img
-   atf_check -s exit:0 -o inline:"exfat\n" fstyp exfat.img
+   atf_check -s exit:0 -o inline:"exfat\n" fstyp -u exfat.img
 }
 
 atf_test_case empty
___
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: r312103 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 17:06, Ngie Cooper (yaneurabeya)  
> wrote:
> 
>> 
>> On Jan 13, 2017, at 17:03, Conrad E. Meyer  wrote:
>> 
>> Author: cem
>> Date: Sat Jan 14 01:03:20 2017
>> New Revision: 312103
>> URL: https://svnweb.freebsd.org/changeset/base/312103
>> 
>> Log:
>> Revert r310994
>> 
>> Don't implement some terrible hack on a test by test basis.  The
>> framework fix is straightforward and can be chased up in the original
>> bug.
>> 
>> Reviewed by: ngie ("be my guest")
> 
> You should have filed an issue with atf/kyua, had the fix done, then done the 
> necessary parts in releasing a new port/package. Please disable the test 
> because it doesn’t work at all right now on CURRENT and it will ping the sh’t 
> out of the jenkins email until fixed.
> -Ngie

PS Saying “be my guest” isn’t review in any shape or form, nor is it my consent 
towards your change being implemented now.


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r312103 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 17:03, Conrad E. Meyer  wrote:
> 
> Author: cem
> Date: Sat Jan 14 01:03:20 2017
> New Revision: 312103
> URL: https://svnweb.freebsd.org/changeset/base/312103
> 
> Log:
>  Revert r310994
> 
>  Don't implement some terrible hack on a test by test basis.  The
>  framework fix is straightforward and can be chased up in the original
>  bug.
> 
>  Reviewed by: ngie ("be my guest")

You should have filed an issue with atf/kyua, had the fix done, then done the 
necessary parts in releasing a new port/package. Please disable the test 
because it doesn’t work at all right now on CURRENT and it will ping the sh’t 
out of the jenkins email until fixed.
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r312103 - head/tests/sys/vfs

2017-01-13 Thread Conrad E. Meyer
Author: cem
Date: Sat Jan 14 01:03:20 2017
New Revision: 312103
URL: https://svnweb.freebsd.org/changeset/base/312103

Log:
  Revert r310994
  
  Don't implement some terrible hack on a test by test basis.  The
  framework fix is straightforward and can be chased up in the original
  bug.
  
  Reviewed by:  ngie ("be my guest")

Modified:
  head/tests/sys/vfs/lookup_cap_dotdot.c

Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
==
--- head/tests/sys/vfs/lookup_cap_dotdot.c  Sat Jan 14 01:01:02 2017
(r312102)
+++ head/tests/sys/vfs/lookup_cap_dotdot.c  Sat Jan 14 01:03:20 2017
(r312103)
@@ -31,27 +31,23 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
 
 #include "freebsd_test_suite/macros.h"
 
-static char*abspath;
-static int dirfd = -1;
-
-typedefvoid (*child_test_fn_t)(void);
+static int dirfd = -1;
+static char *abspath;
 
 static void
-touchat(int _dirfd, const char *name)
+touchat(int dirfd, const char *name)
 {
int fd;
 
-   ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
+   ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
0777)) >= 0);
ATF_REQUIRE(close(fd) == 0);
 }
@@ -82,43 +78,10 @@ prepare_dotdot_tests(void)
 static void
 check_capsicum(void)
 {
-
ATF_REQUIRE_FEATURE("security_capabilities");
ATF_REQUIRE_FEATURE("security_capability_mode");
 }
 
-static void
-run_capsicum_test(child_test_fn_t test_func)
-{
-   int child_exit_code, child_status;
-   pid_t child_pid;
-
-   check_capsicum();
-   prepare_dotdot_tests();
-
-   ATF_REQUIRE_MSG((child_pid = fork()) != -1,
-   "fork failed: %s", strerror(errno));
-
-   if (child_pid == 0) {
-   test_func();
-   _exit(0);
-   }
-
-   ATF_REQUIRE_MSG(waitpid(child_pid, _status, 0) != -1,
-   "waitpid failed: %s", strerror(errno));
-   if (WIFEXITED(child_status)) {
-   child_exit_code = WEXITSTATUS(child_status);
-   ATF_REQUIRE_MSG(child_exit_code == 0,
-   "child exited with non-zero exit code: %d",
-   child_exit_code);
-   } else if (WIFSIGNALED(child_status))
-   atf_tc_fail("child exited with signal: %d",
-   WTERMSIG(child_status));
-   else
-   atf_tc_fail("child exited with unexpected status: %d",
-   child_status);
-}
-
 /*
  * Positive tests
  */
@@ -130,7 +93,6 @@ ATF_TC_HEAD(openat__basic_positive, tc)
 
 ATF_TC_BODY(openat__basic_positive, tc)
 {
-
prepare_dotdot_tests();
 
ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0);
@@ -152,22 +114,21 @@ ATF_TC_HEAD(lookup_cap_dotdot__basic, tc
"Validate cap-mode (testdir)/d1/.. lookup");
 }
 
-static void
-lookup_cap_dotdot__basic_child(void)
+ATF_TC_BODY(lookup_cap_dotdot__basic, tc)
 {
cap_rights_t rights;
+   int fd;
 
-   cap_rights_init(, CAP_LOOKUP, CAP_READ);
+   check_capsicum();
+   prepare_dotdot_tests();
 
-   assert(cap_rights_limit(dirfd, ) >= 0);
-   assert(cap_enter() >= 0);
-   assert(openat(dirfd, "d1/..", O_RDONLY) >= 0);
-}
+   cap_rights_init(, CAP_LOOKUP, CAP_READ);
+   ATF_REQUIRE(cap_rights_limit(dirfd, ) >= 0);
 
-ATF_TC_BODY(lookup_cap_dotdot__basic, tc)
-{
+   ATF_REQUIRE(cap_enter() >= 0);
 
-   run_capsicum_test(lookup_cap_dotdot__basic_child);
+   ATF_REQUIRE_MSG(openat(dirfd, "d1/..", O_RDONLY) >= 0, "%s",
+   strerror(errno));
 }
 
 ATF_TC(lookup_cap_dotdot__advanced);
@@ -177,26 +138,23 @@ ATF_TC_HEAD(lookup_cap_dotdot__advanced,
"Validate cap-mode (testdir)/d1/.. lookup");
 }
 
-static void
-lookup_cap_dotdot__advanced_child(void)
+ATF_TC_BODY(lookup_cap_dotdot__advanced, tc)
 {
cap_rights_t rights;
+   int fd;
 
-   cap_rights_init(, CAP_LOOKUP, CAP_READ);
-   assert(cap_rights_limit(dirfd, ) >= 0);
-
-   assert(cap_enter() >= 0);
+   check_capsicum();
+   prepare_dotdot_tests();
 
-   assert(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0);
-   assert(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0);
-   assert(openat(dirfd, "l3/ld1", O_RDONLY) >= 0);
-   assert(openat(dirfd, "l3/lf1", O_RDONLY) >= 0);
-}
+   cap_rights_init(, CAP_LOOKUP, CAP_READ);
+   ATF_REQUIRE(cap_rights_limit(dirfd, ) >= 0);
 
-ATF_TC_BODY(lookup_cap_dotdot__advanced, tc)
-{
+   ATF_REQUIRE(cap_enter() >= 0);
 
-   run_capsicum_test(lookup_cap_dotdot__advanced_child);
+   ATF_REQUIRE(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0);
+   ATF_REQUIRE(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0);
+   ATF_REQUIRE(openat(dirfd, "l3/ld1", O_RDONLY) >= 0);
+   ATF_REQUIRE(openat(dirfd, "l3/lf1", O_RDONLY) >= 0);
 }
 
 /*
@@ -210,7 

svn commit: r312102 - head/contrib/netbsd-tests/lib/libc/gen

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 01:01:02 2017
New Revision: 312102
URL: https://svnweb.freebsd.org/changeset/base/312102

Log:
  Note that sys/types.h is required on FreeBSD for kqueue(2), unlike NetBSD
  
  MFC after:12 days
  X-MFC with:   r305358
  Sponsored by: Dell EMC Isilon

Modified:
  head/contrib/netbsd-tests/lib/libc/gen/t_sleep.c

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
==
--- head/contrib/netbsd-tests/lib/libc/gen/t_sleep.cSat Jan 14 00:39:58 
2017(r312101)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_sleep.cSat Jan 14 01:01:02 
2017(r312102)
@@ -27,6 +27,7 @@
  */
 
 #ifdef __FreeBSD__
+/* kqueue(2) on FreeBSD requires sys/types.h for uintptr_t; NetBSD doesn't. */
 #include 
 #endif
 #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: r312100 - stable/10/tools/tools/gensnmpdef

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:39:55 2017
New Revision: 312100
URL: https://svnweb.freebsd.org/changeset/base/312100

Log:
  MFC r311748:
  
  Bump WARNS up from 0 to 6

Modified:
  stable/10/tools/tools/gensnmpdef/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tools/tools/gensnmpdef/Makefile
==
--- stable/10/tools/tools/gensnmpdef/Makefile   Sat Jan 14 00:36:50 2017
(r312099)
+++ stable/10/tools/tools/gensnmpdef/Makefile   Sat Jan 14 00:39:55 2017
(r312100)
@@ -19,4 +19,6 @@ LDFLAGS+= -L${LOCALBASE}/lib
 
 LDADD+=-lsmi
 
+WARNS?=6
+
 .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: r312101 - stable/11/tools/tools/gensnmpdef

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:39:58 2017
New Revision: 312101
URL: https://svnweb.freebsd.org/changeset/base/312101

Log:
  MFC r311748:
  
  Bump WARNS up from 0 to 6

Modified:
  stable/11/tools/tools/gensnmpdef/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tools/tools/gensnmpdef/Makefile
==
--- stable/11/tools/tools/gensnmpdef/Makefile   Sat Jan 14 00:39:55 2017
(r312100)
+++ stable/11/tools/tools/gensnmpdef/Makefile   Sat Jan 14 00:39:58 2017
(r312101)
@@ -19,4 +19,6 @@ LDFLAGS+= -L${LOCALBASE}/lib
 
 LDADD+=-lsmi
 
+WARNS?=6
+
 .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: r310994 - head/tests/sys/vfs

2017-01-13 Thread Ngie Cooper (yaneurabeya)

> On Jan 13, 2017, at 16:09, Conrad Meyer  wrote:
> 
> Um, this is garbage and ruins the entire point of using a standardized
> framework like ATF.  Please revert it.
> 
> Instead, just have the Kyua framework preopen its output files before
> running tests.  The diff will be an order of magnitude smaller than
> this one is and it will fix the problem generally instead of adding
> fork/wait cruft and undetailed assert()s to every test.

If you know how to fix it to work with kyua and make it work more optimally, 
please be my guest.
Thanks,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r312098 - stable/10/contrib/bsnmp/gensnmpdef

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:36:48 2017
New Revision: 312098
URL: https://svnweb.freebsd.org/changeset/base/312098

Log:
  MFC r311750,r311754,r311757:
  
  r311750:
  
  Check result from smiGetFirstNode and smiGetNodeByOID
  
  This avoids a segfault with malformed or unanticipated files,
  like IPV6-TC.txt (a file containing just TEXTUAL-CONVENTIONS).
  
  Found with:   gensnmpdef /usr/local/share/snmp/mibs/IPV6-TC.txt
  
  r311754:
  
  Use calloc instead of malloc + memset(.., 0, ..)
  
  r311757:
  
  Similar to r311750, check for the result from smiGetModule to avoid a segfault
  when dereferencing a NULL pointer later on.
  
  Choose to just check for the NULL pointer in the next for-loop for now to fix
  the issue with a minimal amount of code churn
  
  sys/queue.h use here would make more sense than using a static table

Modified:
  stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c
==
--- stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Jan 14 00:33:07 
2017(r312097)
+++ stable/10/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Jan 14 00:36:48 
2017(r312098)
@@ -126,9 +126,11 @@ open_node(const SmiNode *n, u_int level,
 
while (level < n->oidlen - 1) {
if (level >= cut) {
+   n1 = smiGetNodeByOID(level + 1, n->oid);
+   if (n1 == NULL)
+   continue;
pindent(level);
printf("(%u", n->oid[level]);
-   n1 = smiGetNodeByOID(level + 1, n->oid);
printf(" ");
print_name(n1);
printf("\n");
@@ -397,12 +399,11 @@ static void
 save_typdef(char *name)
 {
struct tdef *t;
-   t = malloc(sizeof(struct tdef));
 
+   t = calloc(1, sizeof(struct tdef));
if (t == NULL)
err(1, NULL);
 
-   memset(t, 0 , sizeof(struct tdef));
t->name = name;
SLIST_INSERT_HEAD(, t, link);
 }
@@ -559,7 +560,11 @@ main(int argc, char *argv[])
level = 0;
last = NULL;
for (opt = 0; opt < argc; opt++) {
+   if (mods[opt] == NULL) /* smiGetModule failed above */
+   continue;
n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY);
+   if (n == NULL)
+   continue;
for (;;) {
if (do_typedef == 0) {
level = open_node(n, level, );
___
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: r310994 - head/tests/sys/vfs

2017-01-13 Thread Conrad Meyer
Um, this is garbage and ruins the entire point of using a standardized
framework like ATF.  Please revert it.

Instead, just have the Kyua framework preopen its output files before
running tests.  The diff will be an order of magnitude smaller than
this one is and it will fix the problem generally instead of adding
fork/wait cruft and undetailed assert()s to every test.

Conrad

On Sat, Dec 31, 2016 at 8:01 PM, Ngie Cooper  wrote:
> Author: ngie
> Date: Sun Jan  1 04:01:27 2017
> New Revision: 310994
> URL: https://svnweb.freebsd.org/changeset/base/310994
>
> Log:
>   Make sys/vfs/lookup_cap_dotdot actually work with "kyua test"
>
>   The tests don't work when reading/writing to file descriptors in the
>   sandbox after entering capability mode (and wouldn't have, regardless
>   of the framework), so adjust the tests so they function within the
>   framework.
>
>   For tests that enter capability mode over the course of the test, the
>   following is now done:
>
> 1. Fork child process for capability mode test.
> 2. In child...
>i.   Enter capability mode.
>ii.  Test invariants.
>iii. Exit after calling test function.
> 3. Collect status for child and determine whether or not it completed
>successfully.
>
>   In order to test the invariants in the child process, they now use assert(3)
>   instead of ATF_REQUIRE*, as the atf-c-api functions right to results files
>   in the directories in order to determine where and how tests fail.
>
>   While in the area, fix several -Wshadow and -Wunused warnings found when I
>   bumped WARNS up to 6, and fix some minor style(9) issues with indentation
>   and type alignment.
>
>   PR:   215690
>
> Modified:
>   head/tests/sys/vfs/lookup_cap_dotdot.c
>
> Modified: head/tests/sys/vfs/lookup_cap_dotdot.c
> ==
> --- head/tests/sys/vfs/lookup_cap_dotdot.c  Sun Jan  1 00:43:20 2017  
>   (r310993)
> +++ head/tests/sys/vfs/lookup_cap_dotdot.c  Sun Jan  1 04:01:27 2017  
>   (r310994)
> @@ -31,23 +31,27 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>
>  #include "freebsd_test_suite/macros.h"
>
> -static int dirfd = -1;
> -static char *abspath;
> +static char*abspath;
> +static int dirfd = -1;
> +
> +typedefvoid (*child_test_fn_t)(void);
>
>  static void
> -touchat(int dirfd, const char *name)
> +touchat(int _dirfd, const char *name)
>  {
> int fd;
>
> -   ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
> +   ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY,
> 0777)) >= 0);
> ATF_REQUIRE(close(fd) == 0);
>  }
> @@ -78,10 +82,43 @@ prepare_dotdot_tests(void)
>  static void
>  check_capsicum(void)
>  {
> +
> ATF_REQUIRE_FEATURE("security_capabilities");
> ATF_REQUIRE_FEATURE("security_capability_mode");
>  }
>
> +static void
> +run_capsicum_test(child_test_fn_t test_func)
> +{
> +   int child_exit_code, child_status;
> +   pid_t child_pid;
> +
> +   check_capsicum();
> +   prepare_dotdot_tests();
> +
> +   ATF_REQUIRE_MSG((child_pid = fork()) != -1,
> +   "fork failed: %s", strerror(errno));
> +
> +   if (child_pid == 0) {
> +   test_func();
> +   _exit(0);
> +   }
> +
> +   ATF_REQUIRE_MSG(waitpid(child_pid, _status, 0) != -1,
> +   "waitpid failed: %s", strerror(errno));
> +   if (WIFEXITED(child_status)) {
> +   child_exit_code = WEXITSTATUS(child_status);
> +   ATF_REQUIRE_MSG(child_exit_code == 0,
> +   "child exited with non-zero exit code: %d",
> +   child_exit_code);
> +   } else if (WIFSIGNALED(child_status))
> +   atf_tc_fail("child exited with signal: %d",
> +   WTERMSIG(child_status));
> +   else
> +   atf_tc_fail("child exited with unexpected status: %d",
> +   child_status);
> +}
> +
>  /*
>   * Positive tests
>   */
> @@ -93,6 +130,7 @@ ATF_TC_HEAD(openat__basic_positive, tc)
>
>  ATF_TC_BODY(openat__basic_positive, tc)
>  {
> +
> prepare_dotdot_tests();
>
> ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0);
> @@ -114,21 +152,22 @@ ATF_TC_HEAD(lookup_cap_dotdot__basic, tc
> "Validate cap-mode (testdir)/d1/.. lookup");
>  }
>
> -ATF_TC_BODY(lookup_cap_dotdot__basic, tc)
> +static void
> +lookup_cap_dotdot__basic_child(void)
>  {
> cap_rights_t rights;
> -   int fd;
> -
> -   check_capsicum();
> -   prepare_dotdot_tests();
>
> cap_rights_init(, CAP_LOOKUP, CAP_READ);
> -   ATF_REQUIRE(cap_rights_limit(dirfd, ) >= 0);
>
> -   ATF_REQUIRE(cap_enter() >= 0);
> +   assert(cap_rights_limit(dirfd, ) >= 0);
> +   assert(cap_enter() >= 0);
> +   

svn commit: r312099 - stable/11/contrib/bsnmp/gensnmpdef

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:36:50 2017
New Revision: 312099
URL: https://svnweb.freebsd.org/changeset/base/312099

Log:
  MFC r311750,r311754,r311757:
  
  r311750:
  
  Check result from smiGetFirstNode and smiGetNodeByOID
  
  This avoids a segfault with malformed or unanticipated files,
  like IPV6-TC.txt (a file containing just TEXTUAL-CONVENTIONS).
  
  Found with:   gensnmpdef /usr/local/share/snmp/mibs/IPV6-TC.txt
  
  r311754:
  
  Use calloc instead of malloc + memset(.., 0, ..)
  
  r311757:
  
  Similar to r311750, check for the result from smiGetModule to avoid a segfault
  when dereferencing a NULL pointer later on.
  
  Choose to just check for the NULL pointer in the next for-loop for now to fix
  the issue with a minimal amount of code churn
  
  sys/queue.h use here would make more sense than using a static table

Modified:
  stable/11/contrib/bsnmp/gensnmpdef/gensnmpdef.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/gensnmpdef/gensnmpdef.c
==
--- stable/11/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Jan 14 00:36:48 
2017(r312098)
+++ stable/11/contrib/bsnmp/gensnmpdef/gensnmpdef.c Sat Jan 14 00:36:50 
2017(r312099)
@@ -126,9 +126,11 @@ open_node(const SmiNode *n, u_int level,
 
while (level < n->oidlen - 1) {
if (level >= cut) {
+   n1 = smiGetNodeByOID(level + 1, n->oid);
+   if (n1 == NULL)
+   continue;
pindent(level);
printf("(%u", n->oid[level]);
-   n1 = smiGetNodeByOID(level + 1, n->oid);
printf(" ");
print_name(n1);
printf("\n");
@@ -397,12 +399,11 @@ static void
 save_typdef(char *name)
 {
struct tdef *t;
-   t = malloc(sizeof(struct tdef));
 
+   t = calloc(1, sizeof(struct tdef));
if (t == NULL)
err(1, NULL);
 
-   memset(t, 0 , sizeof(struct tdef));
t->name = name;
SLIST_INSERT_HEAD(, t, link);
 }
@@ -559,7 +560,11 @@ main(int argc, char *argv[])
level = 0;
last = NULL;
for (opt = 0; opt < argc; opt++) {
+   if (mods[opt] == NULL) /* smiGetModule failed above */
+   continue;
n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY);
+   if (n == NULL)
+   continue;
for (;;) {
if (do_typedef == 0) {
level = open_node(n, level, );
___
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: r312096 - stable/10/contrib/netbsd-tests/lib/libc/sys

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:33:03 2017
New Revision: 312096
URL: https://svnweb.freebsd.org/changeset/base/312096

Log:
  MFC r311236,r311919:
  
  r311236:
  
  unlink_fifo: don't leak the file descriptors opened with mkfifo and open
  
  MFC fater:3 days
  CID:  978316, 978317
  
  r311919:
  
  Partially revert r311236
  
  There's no sense in trying to close a file descriptor from the negative cases
  with unlink_test; it's best to ignore these cases.
  
  The mkfifo case does make sense to keep though.

Modified:
  stable/10/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/sys/t_unlink.c  Sat Jan 14 
00:29:55 2017(r312095)
+++ stable/10/contrib/netbsd-tests/lib/libc/sys/t_unlink.c  Sat Jan 14 
00:33:03 2017(r312096)
@@ -111,8 +111,15 @@ ATF_TC_HEAD(unlink_fifo, tc)
 
 ATF_TC_BODY(unlink_fifo, tc)
 {
+#ifdef __FreeBSD__
+   int fd;
 
+   ATF_REQUIRE_MSG((fd = mkfifo(path, 0666)) == 0,
+   "mkfifo failed: %s", strerror(errno));
+   (void)close(fd);
+#else
ATF_REQUIRE(mkfifo(path, 0666) == 0);
+#endif
ATF_REQUIRE(unlink(path) == 0);
 
errno = 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: r312097 - stable/11/contrib/netbsd-tests/lib/libc/sys

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:33:07 2017
New Revision: 312097
URL: https://svnweb.freebsd.org/changeset/base/312097

Log:
  MFC r311236,r311919:
  
  r311236:
  
  unlink_fifo: don't leak the file descriptors opened with mkfifo and open
  
  MFC fater:3 days
  CID:  978316, 978317
  
  r311919:
  
  Partially revert r311236
  
  There's no sense in trying to close a file descriptor from the negative cases
  with unlink_test; it's best to ignore these cases.
  
  The mkfifo case does make sense to keep though.

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/sys/t_unlink.c  Sat Jan 14 
00:33:03 2017(r312096)
+++ stable/11/contrib/netbsd-tests/lib/libc/sys/t_unlink.c  Sat Jan 14 
00:33:07 2017(r312097)
@@ -111,8 +111,15 @@ ATF_TC_HEAD(unlink_fifo, tc)
 
 ATF_TC_BODY(unlink_fifo, tc)
 {
+#ifdef __FreeBSD__
+   int fd;
 
+   ATF_REQUIRE_MSG((fd = mkfifo(path, 0666)) == 0,
+   "mkfifo failed: %s", strerror(errno));
+   (void)close(fd);
+#else
ATF_REQUIRE(mkfifo(path, 0666) == 0);
+#endif
ATF_REQUIRE(unlink(path) == 0);
 
errno = 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: r312095 - stable/10/contrib/netbsd-tests/lib/libc/gen

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:29:55 2017
New Revision: 312095
URL: https://svnweb.freebsd.org/changeset/base/312095

Log:
  MFC r311924:
  
  Fix whitespace in comment

Modified:
  stable/10/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
  stable/10/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c   Sat Jan 
14 00:29:55 2017(r312094)
+++ stable/10/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c   Sat Jan 
14 00:29:55 2017(r312095)
@@ -64,7 +64,7 @@ ATF_TC_BODY(setdomainname_basic, tc)
(void)memset(name, 0, sizeof(name));
 
 #ifdef __FreeBSD__
-   /* 
+   /*
 * Sanity checks to ensure that the wrong invariant isn't being
 * tested for per PR # 181127
 */

Modified: stable/10/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c Sat Jan 14 
00:29:55 2017(r312094)
+++ stable/10/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c Sat Jan 14 
00:29:55 2017(r312095)
@@ -66,7 +66,7 @@ ATF_TC_BODY(sethostname_basic, tc)
(void)memset(name, 0, sizeof(name));
 
 #ifdef __FreeBSD__
-   /* 
+   /*
 * Sanity checks to ensure that the wrong invariant isn't being
 * tested for per PR # 181127
 */
___
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: r312094 - stable/11/contrib/netbsd-tests/lib/libc/gen

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:29:55 2017
New Revision: 312094
URL: https://svnweb.freebsd.org/changeset/base/312094

Log:
  MFC r311924:
  
  Fix whitespace in comment

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
  stable/11/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c   Sat Jan 
14 00:28:23 2017(r312093)
+++ stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c   Sat Jan 
14 00:29:55 2017(r312094)
@@ -64,7 +64,7 @@ ATF_TC_BODY(setdomainname_basic, tc)
(void)memset(name, 0, sizeof(name));
 
 #ifdef __FreeBSD__
-   /* 
+   /*
 * Sanity checks to ensure that the wrong invariant isn't being
 * tested for per PR # 181127
 */

Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c Sat Jan 14 
00:28:23 2017(r312093)
+++ stable/11/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c Sat Jan 14 
00:29:55 2017(r312094)
@@ -66,7 +66,7 @@ ATF_TC_BODY(sethostname_basic, tc)
(void)memset(name, 0, sizeof(name));
 
 #ifdef __FreeBSD__
-   /* 
+   /*
 * Sanity checks to ensure that the wrong invariant isn't being
 * tested for per PR # 181127
 */
___
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: r312092 - stable/10/contrib/netbsd-tests/lib/libc/regex

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:28:21 2017
New Revision: 312092
URL: https://svnweb.freebsd.org/changeset/base/312092

Log:
  MFC r311926:
  
  Consolidate __NetBSD__ #ifdef

Modified:
  stable/10/contrib/netbsd-tests/lib/libc/regex/debug.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libc/regex/debug.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/regex/debug.c   Sat Jan 14 
00:26:52 2017(r312091)
+++ stable/10/contrib/netbsd-tests/lib/libc/regex/debug.c   Sat Jan 14 
00:28:21 2017(r312092)
@@ -48,9 +48,7 @@
 #ifdef __NetBSD__
 static void s_print(struct re_guts *, FILE *);
 static char *regchar(int);
-#endif
 
-#ifdef __NetBSD__
 /*
  * regprint - print a regexp for debugging
  */
___
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: r312093 - stable/11/contrib/netbsd-tests/lib/libc/regex

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:28:23 2017
New Revision: 312093
URL: https://svnweb.freebsd.org/changeset/base/312093

Log:
  MFC r311926:
  
  Consolidate __NetBSD__ #ifdef

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/regex/debug.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/regex/debug.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/regex/debug.c   Sat Jan 14 
00:28:21 2017(r312092)
+++ stable/11/contrib/netbsd-tests/lib/libc/regex/debug.c   Sat Jan 14 
00:28:23 2017(r312093)
@@ -48,9 +48,7 @@
 #ifdef __NetBSD__
 static void s_print(struct re_guts *, FILE *);
 static char *regchar(int);
-#endif
 
-#ifdef __NetBSD__
 /*
  * regprint - print a regexp for debugging
  */
___
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: r312091 - stable/10/contrib/netbsd-tests/lib/libc/gen

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:26:52 2017
New Revision: 312091
URL: https://svnweb.freebsd.org/changeset/base/312091

Log:
  MFC r311227,r311917:
  
  r311227:
  
  seekdir_basic: fix various Coverity issues
  
  Address..
  - .. resource leaks of file descriptors and memory
  - .. unchecked return values from creat(2), mkdir(2), and telldir(3)
  - .. potential NULL derefs after calling readdir(3)
  
  CID:  975255, 975256, 976989, 978989, 978990
  
  r311917:
  
  Fix up r311227
  
  Check for creat returning a value != -1, not a non-zero value
  
  Pointyhat to: ngie
  CID:  1368366

Modified:
  stable/10/contrib/netbsd-tests/lib/libc/gen/t_dir.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libc/gen/t_dir.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/gen/t_dir.c Sat Jan 14 00:26:50 
2017(r312090)
+++ stable/10/contrib/netbsd-tests/lib/libc/gen/t_dir.c Sat Jan 14 00:26:52 
2017(r312091)
@@ -39,6 +39,10 @@
 
 #include 
 
+#ifdef __FreeBSD__
+#include 
+#endif
+
 ATF_TC(seekdir_basic);
 ATF_TC_HEAD(seekdir_basic, tc)
 {
@@ -54,10 +58,26 @@ ATF_TC_BODY(seekdir_basic, tc)
struct dirent *entry;
long here;
 
+#ifdef __FreeBSD__
+#defineCREAT(x, m) do {
\
+   int _creat_fd;  \
+   ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))) != -1,\
+   "creat(%s, %x) failed: %s", (x), (m),   \
+   strerror(errno));   \
+   (void)close(_creat_fd); \
+   } while(0);
+
+   ATF_REQUIRE_MSG(mkdir("t", 0755) == 0,
+   "mkdir failed: %s", strerror(errno));
+   CREAT("t/a", 0600);
+   CREAT("t/b", 0600);
+   CREAT("t/c", 0600);
+#else
mkdir("t", 0755);
creat("t/a", 0600);
creat("t/b", 0600);
creat("t/c", 0600);
+#endif
 
dp = opendir("t");
if ( dp == NULL)
@@ -70,9 +90,17 @@ ATF_TC_BODY(seekdir_basic, tc)
/* get first entry */
entry = readdir(dp);
here = telldir(dp);
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(here != -1,
+   "telldir failed: %s", strerror(errno));
+#endif
 
/* get second entry */
entry = readdir(dp);
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(entry != NULL,
+   "readdir failed: %s", strerror(errno));
+#endif
wasname = strdup(entry->d_name);
if (wasname == NULL)
atf_tc_fail("cannot allocate memory");
@@ -109,6 +137,9 @@ ATF_TC_BODY(seekdir_basic, tc)
atf_tc_fail("3rd seekdir found wrong name");
 
closedir(dp);
+#ifdef __FreeBSD__
+   free(wasname);
+#endif
 }
 
 ATF_TC(telldir_leak);
___
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: r312090 - stable/11/contrib/netbsd-tests/lib/libc/gen

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:26:50 2017
New Revision: 312090
URL: https://svnweb.freebsd.org/changeset/base/312090

Log:
  MFC r311227,r311917:
  
  r311227:
  
  seekdir_basic: fix various Coverity issues
  
  Address..
  - .. resource leaks of file descriptors and memory
  - .. unchecked return values from creat(2), mkdir(2), and telldir(3)
  - .. potential NULL derefs after calling readdir(3)
  
  CID:  975255, 975256, 976989, 978989, 978990
  
  r311917:
  
  Fix up r311227
  
  Check for creat returning a value != -1, not a non-zero value
  
  Pointyhat to: ngie
  CID:  1368366

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/gen/t_dir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_dir.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/gen/t_dir.c Sat Jan 14 00:24:46 
2017(r312089)
+++ stable/11/contrib/netbsd-tests/lib/libc/gen/t_dir.c Sat Jan 14 00:26:50 
2017(r312090)
@@ -39,6 +39,10 @@
 
 #include 
 
+#ifdef __FreeBSD__
+#include 
+#endif
+
 ATF_TC(seekdir_basic);
 ATF_TC_HEAD(seekdir_basic, tc)
 {
@@ -54,10 +58,26 @@ ATF_TC_BODY(seekdir_basic, tc)
struct dirent *entry;
long here;
 
+#ifdef __FreeBSD__
+#defineCREAT(x, m) do {
\
+   int _creat_fd;  \
+   ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))) != -1,\
+   "creat(%s, %x) failed: %s", (x), (m),   \
+   strerror(errno));   \
+   (void)close(_creat_fd); \
+   } while(0);
+
+   ATF_REQUIRE_MSG(mkdir("t", 0755) == 0,
+   "mkdir failed: %s", strerror(errno));
+   CREAT("t/a", 0600);
+   CREAT("t/b", 0600);
+   CREAT("t/c", 0600);
+#else
mkdir("t", 0755);
creat("t/a", 0600);
creat("t/b", 0600);
creat("t/c", 0600);
+#endif
 
dp = opendir("t");
if ( dp == NULL)
@@ -70,9 +90,17 @@ ATF_TC_BODY(seekdir_basic, tc)
/* get first entry */
entry = readdir(dp);
here = telldir(dp);
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(here != -1,
+   "telldir failed: %s", strerror(errno));
+#endif
 
/* get second entry */
entry = readdir(dp);
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(entry != NULL,
+   "readdir failed: %s", strerror(errno));
+#endif
wasname = strdup(entry->d_name);
if (wasname == NULL)
atf_tc_fail("cannot allocate memory");
@@ -109,6 +137,9 @@ ATF_TC_BODY(seekdir_basic, tc)
atf_tc_fail("3rd seekdir found wrong name");
 
closedir(dp);
+#ifdef __FreeBSD__
+   free(wasname);
+#endif
 }
 
 /* There is no sbrk on AArch64 and RISC-V */
___
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: r312088 - stable/11/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:24:44 2017
New Revision: 312088
URL: https://svnweb.freebsd.org/changeset/base/312088

Log:
  MFC r310950:
  
  MIB-II: use strlcpy when copying interface names to .ifr_name
  
  .ifra_name is assumed to be NUL terminated; using strlcpy(3)
  ensures that it's indeed NUL terminated whereas strncpy does
  not.
  
  Tested and verified as follows with a combination of ifconfig,
  snmpget, and snmpset:
  
% ifconfig create lo1 127.0.0.2/8
% SNMPARGS="-v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des -X 
bsnmptest localhost"
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
% snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 2
IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
% snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 1
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
  
  CID:  1009652-1009656, 1349850

Modified:
  stable/11/contrib/bsnmp/snmp_mibII/mibII.c
  stable/11/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmp_mibII/mibII.c
==
--- stable/11/contrib/bsnmp/snmp_mibII/mibII.c  Fri Jan 13 22:16:41 2017
(r312087)
+++ stable/11/contrib/bsnmp/snmp_mibII/mibII.c  Sat Jan 14 00:24:44 2017
(r312088)
@@ -265,7 +265,7 @@ mib_if_admin(struct mibif *ifp, int up)
 {
struct ifreq ifr;
 
-   strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
+   strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "SIOCGIFFLAGS(%s): %m", ifp->name);
return (-1);
@@ -515,7 +515,7 @@ mib_fetch_ifmib(struct mibif *ifp)
}
 
   out:
-   strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
+   strlcpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
if (ioctl(mib_netsock, SIOCGIFDESCR, ) == -1) {
@@ -1384,7 +1384,7 @@ siocaifaddr(char *ifname, struct in_addr
struct sockaddr_in *sa;
 
memset(, 0, sizeof(addreq));
-   strncpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name));
+   strlcpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name));
 
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
@@ -1414,7 +1414,7 @@ siocdifaddr(const char *ifname, struct i
struct sockaddr_in *sa;
 
memset(, 0, sizeof(delreq));
-   strncpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name));
+   strlcpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name));
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
sa->sin_len = sizeof(*sa);
@@ -1433,7 +1433,7 @@ verify_ifa(const char *name, struct mibi
struct sockaddr_in *sa;
 
memset(, 0, sizeof(req));
-   strncpy(req.ifr_name, name, sizeof(req.ifr_name));
+   strlcpy(req.ifr_name, name, sizeof(req.ifr_name));
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
sa->sin_len = sizeof(*sa);

Modified: stable/11/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
==
--- stable/11/contrib/bsnmp/snmp_mibII/mibII_interfaces.c   Fri Jan 13 
22:16:41 2017(r312087)
+++ stable/11/contrib/bsnmp/snmp_mibII/mibII_interfaces.c   Sat Jan 14 
00:24:44 2017(r312088)
@@ -77,7 +77,7 @@ ifchange_func(struct snmp_context *ctx _
switch (op) {
 
  case SNMP_DEPOP_COMMIT:
-   strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
+   strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name);
return (SNMP_ERR_GENERR);
@@ -95,7 +95,7 @@ ifchange_func(struct snmp_context *ctx _
ifc->rb |= IFRB_FLAGS;
}
if (ifc->rb & IFRB_FLAGS) {
-   strncpy(ifr1.ifr_name, ifp->name, 
sizeof(ifr1.ifr_name));
+   strlcpy(ifr1.ifr_name, ifp->name, 
sizeof(ifr1.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name);
return (SNMP_ERR_GENERR);
@@ -116,7 +116,7 @@ ifchange_func(struct snmp_context *ctx _
 
  case SNMP_DEPOP_ROLLBACK:
if (ifc->rb & IFRB_FLAGS) {
-   strncpy(ifr.ifr_name, ifp->name, 

svn commit: r312089 - stable/10/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 00:24:46 2017
New Revision: 312089
URL: https://svnweb.freebsd.org/changeset/base/312089

Log:
  MFC r310950:
  
  MIB-II: use strlcpy when copying interface names to .ifr_name
  
  .ifra_name is assumed to be NUL terminated; using strlcpy(3)
  ensures that it's indeed NUL terminated whereas strncpy does
  not.
  
  Tested and verified as follows with a combination of ifconfig,
  snmpget, and snmpset:
  
% ifconfig create lo1 127.0.0.2/8
% SNMPARGS="-v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des -X 
bsnmptest localhost"
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
% snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 2
IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
% snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 1
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
% snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
  
  CID:  1009652-1009656, 1349850

Modified:
  stable/10/contrib/bsnmp/snmp_mibII/mibII.c
  stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII.c
==
--- stable/10/contrib/bsnmp/snmp_mibII/mibII.c  Sat Jan 14 00:24:44 2017
(r312088)
+++ stable/10/contrib/bsnmp/snmp_mibII/mibII.c  Sat Jan 14 00:24:46 2017
(r312089)
@@ -265,7 +265,7 @@ mib_if_admin(struct mibif *ifp, int up)
 {
struct ifreq ifr;
 
-   strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
+   strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "SIOCGIFFLAGS(%s): %m", ifp->name);
return (-1);
@@ -515,7 +515,7 @@ mib_fetch_ifmib(struct mibif *ifp)
}
 
   out:
-   strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
+   strlcpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
if (ioctl(mib_netsock, SIOCGIFDESCR, ) == -1) {
@@ -1384,7 +1384,7 @@ siocaifaddr(char *ifname, struct in_addr
struct sockaddr_in *sa;
 
memset(, 0, sizeof(addreq));
-   strncpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name));
+   strlcpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name));
 
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
@@ -1414,7 +1414,7 @@ siocdifaddr(const char *ifname, struct i
struct sockaddr_in *sa;
 
memset(, 0, sizeof(delreq));
-   strncpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name));
+   strlcpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name));
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
sa->sin_len = sizeof(*sa);
@@ -1433,7 +1433,7 @@ verify_ifa(const char *name, struct mibi
struct sockaddr_in *sa;
 
memset(, 0, sizeof(req));
-   strncpy(req.ifr_name, name, sizeof(req.ifr_name));
+   strlcpy(req.ifr_name, name, sizeof(req.ifr_name));
sa = (struct sockaddr_in *)(void *)_addr;
sa->sin_family = AF_INET;
sa->sin_len = sizeof(*sa);

Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
==
--- stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c   Sat Jan 14 
00:24:44 2017(r312088)
+++ stable/10/contrib/bsnmp/snmp_mibII/mibII_interfaces.c   Sat Jan 14 
00:24:46 2017(r312089)
@@ -77,7 +77,7 @@ ifchange_func(struct snmp_context *ctx _
switch (op) {
 
  case SNMP_DEPOP_COMMIT:
-   strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
+   strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name);
return (SNMP_ERR_GENERR);
@@ -95,7 +95,7 @@ ifchange_func(struct snmp_context *ctx _
ifc->rb |= IFRB_FLAGS;
}
if (ifc->rb & IFRB_FLAGS) {
-   strncpy(ifr1.ifr_name, ifp->name, 
sizeof(ifr1.ifr_name));
+   strlcpy(ifr1.ifr_name, ifp->name, 
sizeof(ifr1.ifr_name));
if (ioctl(mib_netsock, SIOCGIFFLAGS, ) == -1) {
syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name);
return (SNMP_ERR_GENERR);
@@ -116,7 +116,7 @@ ifchange_func(struct snmp_context *ctx _
 
  case SNMP_DEPOP_ROLLBACK:
if (ifc->rb & IFRB_FLAGS) {
-   strncpy(ifr.ifr_name, ifp->name, 

svn commit: r312087 - in head/sys: kern sys

2017-01-13 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 13 22:16:41 2017
New Revision: 312087
URL: https://svnweb.freebsd.org/changeset/base/312087

Log:
  Remove deprecated fgetsock() and fputsock().

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/file.h
  head/sys/sys/param.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jan 13 21:52:53 2017
(r312086)
+++ head/sys/kern/kern_descrip.cFri Jan 13 22:16:41 2017
(r312087)
@@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2840,61 +2839,6 @@ fgetvp_write(struct thread *td, int fd, 
 #endif
 
 /*
- * Like fget() but loads the underlying socket, or returns an error if the
- * descriptor does not represent a socket.
- *
- * We bump the ref count on the returned socket.  XXX Also obtain the SX lock
- * in the future.
- *
- * Note: fgetsock() and fputsock() are deprecated, as consumers should rely
- * on their file descriptor reference to prevent the socket from being free'd
- * during use.
- */
-int
-fgetsock(struct thread *td, int fd, cap_rights_t *rightsp, struct socket **spp,
-u_int *fflagp)
-{
-   struct file *fp;
-   int error;
-
-   *spp = NULL;
-   if (fflagp != NULL)
-   *fflagp = 0;
-   if ((error = _fget(td, fd, , 0, rightsp, NULL)) != 0)
-   return (error);
-   if (fp->f_type != DTYPE_SOCKET) {
-   error = ENOTSOCK;
-   } else {
-   *spp = fp->f_data;
-   if (fflagp)
-   *fflagp = fp->f_flag;
-   SOCK_LOCK(*spp);
-   soref(*spp);
-   SOCK_UNLOCK(*spp);
-   }
-   fdrop(fp, td);
-
-   return (error);
-}
-
-/*
- * Drop the reference count on the socket and XXX release the SX lock in the
- * future.  The last reference closes the socket.
- *
- * Note: fputsock() is deprecated, see comment for fgetsock().
- */
-void
-fputsock(struct socket *so)
-{
-
-   ACCEPT_LOCK();
-   SOCK_LOCK(so);
-   CURVNET_SET(so->so_vnet);
-   sorele(so);
-   CURVNET_RESTORE();
-}
-
-/*
  * Handle the last reference to a file being closed.
  */
 int

Modified: head/sys/sys/file.h
==
--- head/sys/sys/file.h Fri Jan 13 21:52:53 2017(r312086)
+++ head/sys/sys/file.h Fri Jan 13 22:16:41 2017(r312087)
@@ -50,8 +50,6 @@ struct thread;
 struct uio;
 struct knote;
 struct vnode;
-struct socket;
-
 
 #endif /* _KERNEL */
 
@@ -267,10 +265,6 @@ int fgetvp_read(struct thread *td, int f
 int fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp,
 struct vnode **vpp);
 
-int fgetsock(struct thread *td, int fd, cap_rights_t *rightsp,
-struct socket **spp, u_int *fflagp);
-void fputsock(struct socket *sp);
-
 static __inline int
 _fnoop(void)
 {

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hFri Jan 13 21:52:53 2017(r312086)
+++ head/sys/sys/param.hFri Jan 13 22:16:41 2017(r312087)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1200019  /* Master, propagated to newvers */
+#define __FreeBSD_version 1200020  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r312086 - in head/sys: mips/mips sparc64/sparc64

2017-01-13 Thread John Baldwin
Author: jhb
Date: Fri Jan 13 21:52:53 2017
New Revision: 312086
URL: https://svnweb.freebsd.org/changeset/base/312086

Log:
  Trim a few comments on platforms that did not implement mmap of /dev/kmem.
  
  After r307332, no platforms implement mmap for /dev/kmem, so the lack of
  it for these platforms is no longer unique.

Modified:
  head/sys/mips/mips/mem.c
  head/sys/sparc64/sparc64/mem.c

Modified: head/sys/mips/mips/mem.c
==
--- head/sys/mips/mips/mem.cFri Jan 13 21:42:36 2017(r312085)
+++ head/sys/mips/mips/mem.cFri Jan 13 21:52:53 2017(r312086)
@@ -151,12 +151,6 @@ int
 memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
 int prot, vm_memattr_t *memattr)
 {
-   /*
-* /dev/mem is the only one that makes sense through this
-* interface.  For /dev/kmem any physaddr we return here
-* could be transient and hence incorrect or invalid at
-* a later time.
-*/
if (dev2unit(dev) != CDEV_MINOR_MEM)
return (-1);
 

Modified: head/sys/sparc64/sparc64/mem.c
==
--- head/sys/sparc64/sparc64/mem.c  Fri Jan 13 21:42:36 2017
(r312085)
+++ head/sys/sparc64/sparc64/mem.c  Fri Jan 13 21:52:53 2017
(r312086)
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
 /*
  * Memory special file
  *
- * NOTE: other architectures support mmap()'ing the mem and kmem devices; this
+ * NOTE: other architectures support mmap()'ing the mem device; this
  * might cause illegal aliases to be created for the locked kernel page(s), so
  * it is not implemented.
  */
___
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: r312085 - in stable: 10/sys/conf 11/sys/conf

2017-01-13 Thread John Baldwin
Author: jhb
Date: Fri Jan 13 21:42:36 2017
New Revision: 312085
URL: https://svnweb.freebsd.org/changeset/base/312085

Log:
  MFC 304492,310721,310734: Update cxgbe info in NOTES.
  
  304492:
  Move cxgb and cxgbe down to the non-mii PCI NIC section.
  
  310721:
  Mention T6 and 100GbE in description of cxgbe.
  
  310734:
  Note that the Chelsio T6 also supports 25Gbps.
  
  To avoid overflowing 80 columns, condense the cxgbe description a bit.

Modified:
  stable/10/sys/conf/NOTES
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/conf/NOTES
Directory Properties:
  stable/11/   (props changed)

Modified: stable/10/sys/conf/NOTES
==
--- stable/10/sys/conf/NOTESFri Jan 13 21:30:18 2017(r312084)
+++ stable/10/sys/conf/NOTESFri Jan 13 21:42:36 2017(r312085)
@@ -1922,8 +1922,9 @@ devicexmphy   # XaQti XMAC II
 # cm:  Arcnet SMC COM90c26 / SMC COM90c56
 #  (and SMC COM90c66 in '56 compatibility mode) adapters.
 # cxgb: Chelsio T3 based 1GbE/10GbE PCIe Ethernet adapters.
-# cxgbe:Chelsio T4 and T5 based 1GbE/10GbE/40GbE PCIe Ethernet adapters.
-# cxgbev: Chelsio T4 and T5 based PCIe Virtual Functions.
+# cxgbe:Chelsio T4, T5, and T6-based 1/10/25/40/100GbE PCIe Ethernet
+#  adapters.
+# cxgbev: Chelsio T4, T5, and T6-based PCIe Virtual Functions.
 # dc:   Support for PCI fast ethernet adapters based on the DEC/Intel 21143
 #   and various workalikes including:
 #   the ADMtek AL981 Comet and AN985 Centaur, the ASIX Electronics
@@ -2072,9 +2073,6 @@ devicebce # Broadcom 
BCM5706/BCM5708 
 device bfe # Broadcom BCM440x 10/100 Ethernet
 device bge # Broadcom BCM570xx Gigabit Ethernet
 device cas # Sun Cassini/Cassini+ and NS DP83065 Saturn
-device cxgb# Chelsio T3 10 Gigabit Ethernet
-device cxgb_t3fw   # Chelsio T3 10 Gigabit Ethernet firmware
-device cxgbe   # Chelsio T4 and T5 1GbE/10GbE/40GbE
 device dc  # DEC/Intel 21143 and various workalikes
 device et  # Agere ET1310 10/100/Gigabit Ethernet
 device fxp # Intel EtherExpress PRO/100B (82557, 82558)
@@ -2105,7 +2103,10 @@ device   wb  # Winbond W89C840F
 device xl  # 3Com 3c90x (``Boomerang'', ``Cyclone'')
 
 # PCI Ethernet NICs.
-device cxgbev  # Chelsio T4 and T5 1GbE/10GbE/40GbE VF
+device cxgb# Chelsio T3 10 Gigabit Ethernet
+device cxgb_t3fw   # Chelsio T3 10 Gigabit Ethernet firmware
+device cxgbe   # Chelsio T4-T6 1/10/25/40/100 Gigabit Ethernet
+device cxgbev  # Chelsio T4-T6 Virtual Functions
 device de  # DEC/Intel DC21x4x (``Tulip'')
 device em  # Intel Pro/1000 Gigabit Ethernet
 device igb # Intel Pro/1000 PCIE Gigabit Ethernet
___
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: r312085 - in stable: 10/sys/conf 11/sys/conf

2017-01-13 Thread John Baldwin
Author: jhb
Date: Fri Jan 13 21:42:36 2017
New Revision: 312085
URL: https://svnweb.freebsd.org/changeset/base/312085

Log:
  MFC 304492,310721,310734: Update cxgbe info in NOTES.
  
  304492:
  Move cxgb and cxgbe down to the non-mii PCI NIC section.
  
  310721:
  Mention T6 and 100GbE in description of cxgbe.
  
  310734:
  Note that the Chelsio T6 also supports 25Gbps.
  
  To avoid overflowing 80 columns, condense the cxgbe description a bit.

Modified:
  stable/11/sys/conf/NOTES
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/conf/NOTES
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/sys/conf/NOTES
==
--- stable/11/sys/conf/NOTESFri Jan 13 21:30:18 2017(r312084)
+++ stable/11/sys/conf/NOTESFri Jan 13 21:42:36 2017(r312085)
@@ -1950,8 +1950,9 @@ devicexmphy   # XaQti XMAC II
 # cm:  Arcnet SMC COM90c26 / SMC COM90c56
 #  (and SMC COM90c66 in '56 compatibility mode) adapters.
 # cxgb: Chelsio T3 based 1GbE/10GbE PCIe Ethernet adapters.
-# cxgbe:Chelsio T4 and T5 based 1GbE/10GbE/40GbE PCIe Ethernet adapters.
-# cxgbev: Chelsio T4 and T5 based PCIe Virtual Functions.
+# cxgbe:Chelsio T4, T5, and T6-based 1/10/25/40/100GbE PCIe Ethernet
+#  adapters.
+# cxgbev: Chelsio T4, T5, and T6-based PCIe Virtual Functions.
 # dc:   Support for PCI fast ethernet adapters based on the DEC/Intel 21143
 #   and various workalikes including:
 #   the ADMtek AL981 Comet and AN985 Centaur, the ASIX Electronics
@@ -2102,9 +2103,6 @@ devicebce # Broadcom 
BCM5706/BCM5708 
 device bfe # Broadcom BCM440x 10/100 Ethernet
 device bge # Broadcom BCM570xx Gigabit Ethernet
 device cas # Sun Cassini/Cassini+ and NS DP83065 Saturn
-device cxgb# Chelsio T3 10 Gigabit Ethernet
-device cxgb_t3fw   # Chelsio T3 10 Gigabit Ethernet firmware
-device cxgbe   # Chelsio T4 and T5 1GbE/10GbE/40GbE
 device dc  # DEC/Intel 21143 and various workalikes
 device et  # Agere ET1310 10/100/Gigabit Ethernet
 device fxp # Intel EtherExpress PRO/100B (82557, 82558)
@@ -2135,7 +2133,10 @@ device   wb  # Winbond W89C840F
 device xl  # 3Com 3c90x (``Boomerang'', ``Cyclone'')
 
 # PCI Ethernet NICs.
-device cxgbev  # Chelsio T4 and T5 1GbE/10GbE/40GbE VF
+device cxgb# Chelsio T3 10 Gigabit Ethernet
+device cxgb_t3fw   # Chelsio T3 10 Gigabit Ethernet firmware
+device cxgbe   # Chelsio T4-T6 1/10/25/40/100 Gigabit Ethernet
+device cxgbev  # Chelsio T4-T6 Virtual Functions
 device de  # DEC/Intel DC21x4x (``Tulip'')
 device em  # Intel Pro/1000 Gigabit Ethernet
 device igb # Intel Pro/1000 PCIE Gigabit Ethernet
___
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: r312084 - stable/11/usr.bin/truss

2017-01-13 Thread John Baldwin
Author: jhb
Date: Fri Jan 13 21:30:18 2017
New Revision: 312084
URL: https://svnweb.freebsd.org/changeset/base/312084

Log:
  MFC 309589: Rework syscall structure lookups.
  
  Avoid always using an O(n^2) loop over known syscall structures with
  strcmp() on each system call.  Instead, use a per-ABI cache indexed by
  the system call number. The first 1024 system calls (which should cover
  all of the normal system calls in currently-supported ABIs) use a flat array
  indexed by the system call number to find system call structure.  For other
  system calls, a linked list of structures storing an integer to structure
  mapping is stored in the ABI.  The linked list isn't very smart, but it
  should only be used by buggy applications invoking unknown system calls.
  
  This also fixes handling of unknown system calls which currently trigger
  a NULL pointer dereference.

Modified:
  stable/11/usr.bin/truss/aarch64-cloudabi64.c
  stable/11/usr.bin/truss/aarch64-freebsd.c
  stable/11/usr.bin/truss/amd64-cloudabi64.c
  stable/11/usr.bin/truss/amd64-freebsd.c
  stable/11/usr.bin/truss/amd64-freebsd32.c
  stable/11/usr.bin/truss/amd64-linux.c
  stable/11/usr.bin/truss/amd64-linux32.c
  stable/11/usr.bin/truss/arm-freebsd.c
  stable/11/usr.bin/truss/i386-freebsd.c
  stable/11/usr.bin/truss/i386-linux.c
  stable/11/usr.bin/truss/mips-freebsd.c
  stable/11/usr.bin/truss/powerpc-freebsd.c
  stable/11/usr.bin/truss/powerpc64-freebsd.c
  stable/11/usr.bin/truss/powerpc64-freebsd32.c
  stable/11/usr.bin/truss/setup.c
  stable/11/usr.bin/truss/sparc64-freebsd.c
  stable/11/usr.bin/truss/syscall.h
  stable/11/usr.bin/truss/syscalls.c
  stable/11/usr.bin/truss/truss.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/truss/aarch64-cloudabi64.c
==
--- stable/11/usr.bin/truss/aarch64-cloudabi64.cFri Jan 13 19:41:02 
2017(r312083)
+++ stable/11/usr.bin/truss/aarch64-cloudabi64.cFri Jan 13 21:30:18 
2017(r312084)
@@ -80,7 +80,9 @@ static struct procabi aarch64_cloudabi64
"CloudABI ELF64",
SYSDECODE_ABI_CLOUDABI64,
aarch64_cloudabi64_fetch_args,
-   aarch64_cloudabi64_fetch_retval
+   aarch64_cloudabi64_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(aarch64_cloudabi64.extra_syscalls),
+   { NULL }
 };
 
 PROCABI(aarch64_cloudabi64);

Modified: stable/11/usr.bin/truss/aarch64-freebsd.c
==
--- stable/11/usr.bin/truss/aarch64-freebsd.c   Fri Jan 13 19:41:02 2017
(r312083)
+++ stable/11/usr.bin/truss/aarch64-freebsd.c   Fri Jan 13 21:30:18 2017
(r312084)
@@ -102,7 +102,9 @@ static struct procabi aarch64_freebsd = 
"FreeBSD ELF64",
SYSDECODE_ABI_FREEBSD,
aarch64_fetch_args,
-   aarch64_fetch_retval
+   aarch64_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(aarch64_freebsd.extra_syscalls),
+   { NULL }
 };
 
 PROCABI(aarch64_freebsd);

Modified: stable/11/usr.bin/truss/amd64-cloudabi64.c
==
--- stable/11/usr.bin/truss/amd64-cloudabi64.c  Fri Jan 13 19:41:02 2017
(r312083)
+++ stable/11/usr.bin/truss/amd64-cloudabi64.c  Fri Jan 13 21:30:18 2017
(r312084)
@@ -89,7 +89,9 @@ static struct procabi amd64_cloudabi64 =
"CloudABI ELF64",
SYSDECODE_ABI_CLOUDABI64,
amd64_cloudabi64_fetch_args,
-   amd64_cloudabi64_fetch_retval
+   amd64_cloudabi64_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(amd64_cloudabi64.extra_syscalls),
+   { NULL }
 };
 
 PROCABI(amd64_cloudabi64);

Modified: stable/11/usr.bin/truss/amd64-freebsd.c
==
--- stable/11/usr.bin/truss/amd64-freebsd.c Fri Jan 13 19:41:02 2017
(r312083)
+++ stable/11/usr.bin/truss/amd64-freebsd.c Fri Jan 13 21:30:18 2017
(r312084)
@@ -124,7 +124,9 @@ static struct procabi amd64_freebsd = {
"FreeBSD ELF64",
SYSDECODE_ABI_FREEBSD,
amd64_fetch_args,
-   amd64_fetch_retval
+   amd64_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(amd64_freebsd.extra_syscalls),
+   { NULL }
 };
 
 PROCABI(amd64_freebsd);

Modified: stable/11/usr.bin/truss/amd64-freebsd32.c
==
--- stable/11/usr.bin/truss/amd64-freebsd32.c   Fri Jan 13 19:41:02 2017
(r312083)
+++ stable/11/usr.bin/truss/amd64-freebsd32.c   Fri Jan 13 21:30:18 2017
(r312084)
@@ -120,7 +120,9 @@ static struct procabi amd64_freebsd32 = 
"FreeBSD ELF32",
SYSDECODE_ABI_FREEBSD32,
amd64_freebsd32_fetch_args,
-   amd64_freebsd32_fetch_retval
+   amd64_freebsd32_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(amd64_freebsd32.extra_syscalls),
+   { NULL }
 };
 
 

svn commit: r312083 - head/lib/libc/sys

2017-01-13 Thread Warren Block
Author: wblock (doc committer)
Date: Fri Jan 13 19:41:02 2017
New Revision: 312083
URL: https://svnweb.freebsd.org/changeset/base/312083

Log:
  Update the shm_open.2 man page to reflect objective reality.
  
  PR:   215612
  Submitted by: rwatson
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9066

Modified:
  head/lib/libc/sys/shm_open.2

Modified: head/lib/libc/sys/shm_open.2
==
--- head/lib/libc/sys/shm_open.2Fri Jan 13 19:22:22 2017
(r312082)
+++ head/lib/libc/sys/shm_open.2Fri Jan 13 19:41:02 2017
(r312083)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 18, 2013
+.Dd January 13, 2017
 .Dt SHM_OPEN 2
 .Os
 .Sh NAME
@@ -171,7 +171,8 @@ and
 .Dv O_TRUNC
 flags may be used in portable programs.
 .Pp
-The result of using
+.Tn POSIX
+specifications state that the result of using
 .Xr open 2 ,
 .Xr read 2 ,
 or
@@ -179,19 +180,43 @@ or
 on a shared memory object, or on the descriptor returned by
 .Fn shm_open ,
 is undefined.
-It is also undefined whether the shared memory object itself, or its
-contents, persist across reboots.
-.Pp
-In FreeBSD,
+However, the
+.Fx
+kernel implementation explicitly includes support for
 .Xr read 2
 and
-.Xr write 2
-on a shared memory object will fail with
-.Er EOPNOTSUPP
-and neither shared memory objects nor their contents persist across reboots.
+.Xr write 2 .
+.Pp
+Neither shared memory objects nor their contents persist across reboots.
+.Pp
+Writes do not extend shared memory objects, so
+.Xr ftruncate 2
+must be called before any data can be written.
+See
+.Sx EXAMPLES .
+.Sh EXAMPLES
+This example fails without the call to
+.Xr ftruncate 2 :
+.Bd -literal -compact
+
+uint8_t buffer[getpagesize()];
+ssize_t len;
+int fd;
+
+fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600);
+if (fd < 0)
+err(EX_OSERR, "%s: shm_open", __func__);
+if (ftruncate(fd, getpagesize()) < 0)
+err(EX_IOERR, "%s: ftruncate", __func__);
+len = pwrite(fd, buffer, getpagesize(), 0);
+if (len < 0)
+err(EX_IOERR, "%s: pwrite", __func__);
+if (len != getpagesize())
+errx(EX_IOERR, "%s: pwrite length mismatch", __func__);
+.Ed
 .Sh ERRORS
-The following errors are defined for
-.Fn shm_open :
+.Fn shm_open
+fails with these error codes for these conditions:
 .Bl -tag -width Er
 .It Bq Er EINVAL
 A flag other than
@@ -235,8 +260,8 @@ are specified and the named shared memor
 The required permissions (for reading or reading and writing) are denied.
 .El
 .Pp
-The following errors are defined for
-.Fn shm_unlink :
+.Fn shm_unlink
+fails with these error codes for these conditions:
 .Bl -tag -width Er
 .It Bq Er EFAULT
 The
___
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: r312082 - stable/11/sys/tools

2017-01-13 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Fri Jan 13 19:22:22 2017
New Revision: 312082
URL: https://svnweb.freebsd.org/changeset/base/312082

Log:
  MFC r311881:
  
  Replace using of objdump with elfdump
  
  In-tree objdump is too old to dump new ELF headers.  But for example if we
  use: `make CROSS_TOOLCHAIN=riscv64-gcc TARGET_ARCH=riscv64` and do not specify
  CROSS_BINUTILS_PREFIX in env, embed_mfs.sh cannot find the correct objdump.
  This patch just replaces using of objdump with elfdump to collect needed
  information.
  
  Later we may also put an ELFDUMP in CROSSENV and use it in embed_mfs.sh .
  
  Reviewed by:  emaste, br
  Differential Revision:https://reviews.freebsd.org/D9062

Modified:
  stable/11/sys/tools/embed_mfs.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/tools/embed_mfs.sh
==
--- stable/11/sys/tools/embed_mfs.shFri Jan 13 18:36:46 2017
(r312081)
+++ stable/11/sys/tools/embed_mfs.shFri Jan 13 19:22:22 2017
(r312082)
@@ -36,12 +36,12 @@ mfs_size=`stat -f '%z' $2 2> /dev/null`
 # If we can't determine MFS image size - bail.
 [ -z ${mfs_size} ] && echo "Can't determine MFS image size" && exit 1
 
-sec_info=`objdump -h $1 2> /dev/null | grep " oldmfs "`
+sec_info=`elfdump -c $1 2> /dev/null | grep -A 5 -E "sh_name: oldmfs$"`
 # If we can't find the mfs section within the given kernel - bail.
 [ -z "${sec_info}" ] && echo "Can't locate mfs section within kernel" && exit 1
 
-sec_size=`echo ${sec_info} | awk '{printf("%d", "0x" $3)}' 2> /dev/null`
-sec_start=`echo ${sec_info} | awk '{printf("%d", "0x" $6)}' 2> /dev/null`
+sec_size=`echo "${sec_info}" | awk '/sh_size/ {print $2}' 2> /dev/null`
+sec_start=`echo "${sec_info}" | awk '/sh_offset/ {print $2}' 2> /dev/null`
 
 # If the mfs section size is smaller than the mfs image - bail.
 [ ${sec_size} -lt ${mfs_size} ] && echo "MFS image too large" && exit 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: r312081 - head/sys/dev/iscsi_initiator

2017-01-13 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 13 18:36:46 2017
New Revision: 312081
URL: https://svnweb.freebsd.org/changeset/base/312081

Log:
  Use getsock_cap() instead of deprecated fgetsock().
  
  Reviewed by:  Daniel Braniss 

Modified:
  head/sys/dev/iscsi_initiator/isc_soc.c
  head/sys/dev/iscsi_initiator/iscsi.c

Modified: head/sys/dev/iscsi_initiator/isc_soc.c
==
--- head/sys/dev/iscsi_initiator/isc_soc.c  Fri Jan 13 17:03:23 2017
(r312080)
+++ head/sys/dev/iscsi_initiator/isc_soc.c  Fri Jan 13 18:36:46 2017
(r312081)
@@ -680,7 +680,6 @@ isc_stop_receiver(isc_session_t *sp)
 
  if(sp->fp != NULL)
  fdrop(sp->fp, sp->td);
- fputsock(sp->soc);
  sp->soc = NULL;
  sp->fp = NULL;
 

Modified: head/sys/dev/iscsi_initiator/iscsi.c
==
--- head/sys/dev/iscsi_initiator/iscsi.cFri Jan 13 17:03:23 2017
(r312080)
+++ head/sys/dev/iscsi_initiator/iscsi.cFri Jan 13 18:36:46 2017
(r312081)
@@ -388,20 +388,14 @@ i_setsoc(isc_session_t *sp, int fd, stru
  if(sp->soc != NULL)
  isc_stop_receiver(sp);
 
- error = fget(td, fd, cap_rights_init(, CAP_SOCK_CLIENT), >fp);
+ error = getsock_cap(td, fd, cap_rights_init(, CAP_SOCK_CLIENT),
+>fp, NULL, NULL);
  if(error)
  return error;
 
- error = fgetsock(td, fd, cap_rights_init(, CAP_SOCK_CLIENT),
->soc, 0);
- if(error == 0) {
- sp->td = td;
- isc_start_receiver(sp);
- }
- else {
- fdrop(sp->fp, td);
- sp->fp = NULL;
- }
+ sp->soc = sp->fp->f_data;
+ sp->td = td;
+ isc_start_receiver(sp);
 
  return error;
 }
___
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: r312080 - head/sys/kern

2017-01-13 Thread Ian Lepore
Author: ian
Date: Fri Jan 13 17:03:23 2017
New Revision: 312080
URL: https://svnweb.freebsd.org/changeset/base/312080

Log:
  Correct the comments about how much buffer is allocated.

Modified:
  head/sys/kern/tty.c

Modified: head/sys/kern/tty.c
==
--- head/sys/kern/tty.c Fri Jan 13 16:54:44 2017(r312079)
+++ head/sys/kern/tty.c Fri Jan 13 17:03:23 2017(r312080)
@@ -117,7 +117,7 @@ tty_watermarks(struct tty *tp)
size_t bs = 0;
int error;
 
-   /* Provide an input buffer for 0.2 seconds of data. */
+   /* Provide an input buffer for 2 seconds of data. */
if (tp->t_termios.c_cflag & CREAD)
bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
error = ttyinq_setsize(>t_inq, tp, bs);
@@ -127,7 +127,7 @@ tty_watermarks(struct tty *tp)
/* Set low watermark at 10% (when 90% is available). */
tp->t_inlow = (ttyinq_getallocatedsize(>t_inq) * 9) / 10;
 
-   /* Provide an output buffer for 0.2 seconds of data. */
+   /* Provide an output buffer for 2 seconds of data. */
bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
error = ttyoutq_setsize(>t_outq, tp, bs);
if (error != 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: r312079 - head/sys/netinet

2017-01-13 Thread Gleb Smirnoff
Author: glebius
Date: Fri Jan 13 16:54:44 2017
New Revision: 312079
URL: https://svnweb.freebsd.org/changeset/base/312079

Log:
  Use getsock_cap() instead of deprecated fgetsock().
  
  Reviewed by:  tuexen

Modified:
  head/sys/netinet/sctp_syscalls.c

Modified: head/sys/netinet/sctp_syscalls.c
==
--- head/sys/netinet/sctp_syscalls.cFri Jan 13 16:46:01 2017
(r312078)
+++ head/sys/netinet/sctp_syscalls.cFri Jan 13 16:54:44 2017
(r312079)
@@ -121,17 +121,18 @@ sys_sctp_peeloff(td, uap)
} */ *uap;
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
-   struct file *nfp = NULL;
+   struct file *headfp, *nfp = NULL;
struct socket *head, *so;
cap_rights_t rights;
u_int fflag;
int error, fd;
 
AUDIT_ARG_FD(uap->sd);
-   error = fgetsock(td, uap->sd, cap_rights_init(, CAP_PEELOFF),
-   , );
+   error = getsock_cap(td, uap->sd, cap_rights_init(, CAP_PEELOFF),
+   , , NULL);
if (error != 0)
goto done2;
+   head = headfp->f_data;
if (head->so_proto->pr_protocol != IPPROTO_SCTP) {
error = EOPNOTSUPP;
goto done;
@@ -196,7 +197,7 @@ noconnection:
 done:
if (nfp != NULL)
fdrop(nfp, td);
-   fputsock(head);
+   fdrop(headfp, td);
 done2:
return (error);
 #else  /* SCTP */
___
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: r312078 - head/usr.sbin/fstyp

2017-01-13 Thread Conrad E. Meyer
Author: cem
Date: Fri Jan 13 16:46:01 2017
New Revision: 312078
URL: https://svnweb.freebsd.org/changeset/base/312078

Log:
  fstyp.8: Move initial exFAT blurb to the -u section
  
  Didn't notice the second list in r312003.
  
  Reported by:  trasz@

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

Modified: head/usr.sbin/fstyp/fstyp.8
==
--- head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 16:37:38 2017(r312077)
+++ head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 16:46:01 2017(r312078)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 12, 2017
+.Dd January 13, 2017
 .Dt FSTYP 8
 .Os
 .Sh NAME
@@ -43,7 +43,7 @@
 The
 .Nm
 utility is used to determine the filesystem type on a given device.
-It can recognize ISO-9660, exFAT, Ext2, FAT, NTFS, and UFS filesystems.
+It can recognize ISO-9660, Ext2, FAT, NTFS, and UFS filesystems.
 When the
 .Fl u
 flag is specified,
@@ -51,9 +51,10 @@ flag is specified,
 also recognizes certain additional metadata formats that cannot be
 handled using
 .Xr mount 8 ,
-such as ZFS pools and
+such as exFAT filesystems,
 .Xr geli 8
-providers.
+providers, and
+ZFS pools.
 .Pp
 The filesystem name is printed to the standard output
 as, respectively:
___
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: r312077 - in head/sys: kern sys

2017-01-13 Thread Ian Lepore
Author: ian
Date: Fri Jan 13 16:37:38 2017
New Revision: 312077
URL: https://svnweb.freebsd.org/changeset/base/312077

Log:
  Check tty_gone() after allocating IO buffers.  The tty lock has to be
  dropped then reacquired due to using M_WAITOK, which opens a window in
  which the tty device can disappear.  Check for this and return ENXIO
  back up the call chain so that callers can cope.
  
  This closes a race where TF_GONE would get set while buffers were being
  allocated as part of ttydev_open(), causing a subsequent call to
  ttydevsw_modem() later in ttydev_open() to assert.
  
  Reported by:  pho
  Reviewed by:  kib

Modified:
  head/sys/kern/tty.c
  head/sys/kern/tty_inq.c
  head/sys/kern/tty_outq.c
  head/sys/sys/ttyqueue.h

Modified: head/sys/kern/tty.c
==
--- head/sys/kern/tty.c Fri Jan 13 15:17:25 2017(r312076)
+++ head/sys/kern/tty.c Fri Jan 13 16:37:38 2017(r312077)
@@ -105,25 +105,38 @@ SYSCTL_INT(_kern, OID_AUTO, tty_drainwai
 
 #defineTTYBUF_MAX  65536
 
-static void
+/*
+ * Allocate buffer space if necessary, and set low watermarks, based on speed.
+ * Note that the ttyxxxq_setsize() functions may drop and then reacquire the 
tty
+ * lock during memory allocation.  They will return ENXIO if the tty disappears
+ * while unlocked.
+ */
+static int
 tty_watermarks(struct tty *tp)
 {
size_t bs = 0;
+   int error;
 
/* Provide an input buffer for 0.2 seconds of data. */
if (tp->t_termios.c_cflag & CREAD)
bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
-   ttyinq_setsize(>t_inq, tp, bs);
+   error = ttyinq_setsize(>t_inq, tp, bs);
+   if (error != 0)
+   return (error);
 
/* Set low watermark at 10% (when 90% is available). */
tp->t_inlow = (ttyinq_getallocatedsize(>t_inq) * 9) / 10;
 
/* Provide an output buffer for 0.2 seconds of data. */
bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
-   ttyoutq_setsize(>t_outq, tp, bs);
+   error = ttyoutq_setsize(>t_outq, tp, bs);
+   if (error != 0)
+   return (error);
 
/* Set low watermark at 10% (when 90% is available). */
tp->t_outlow = (ttyoutq_getallocatedsize(>t_outq) * 9) / 10;
+
+   return (0);
 }
 
 static int
@@ -318,7 +331,9 @@ ttydev_open(struct cdev *dev, int oflags
goto done;
 
ttydisc_open(tp);
-   tty_watermarks(tp); /* XXXGL: drops lock */
+   error = tty_watermarks(tp);
+   if (error != 0)
+   goto done;
}
 
/* Wait for Carrier Detect. */
@@ -1627,7 +1642,9 @@ tty_generic_ioctl(struct tty *tp, u_long
tp->t_termios.c_ospeed = t->c_ospeed;
 
/* Baud rate has changed - update watermarks. */
-   tty_watermarks(tp);
+   error = tty_watermarks(tp);
+   if (error)
+   return (error);
}
 
/* Copy new non-device driver parameters. */

Modified: head/sys/kern/tty_inq.c
==
--- head/sys/kern/tty_inq.c Fri Jan 13 15:17:25 2017(r312076)
+++ head/sys/kern/tty_inq.c Fri Jan 13 16:37:38 2017(r312077)
@@ -112,7 +112,7 @@ static uma_zone_t ttyinq_zone;
TTYINQ_INSERT_TAIL(ti, tib);\
 } while (0)
 
-void
+int 
 ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t size)
 {
struct ttyinq_block *tib;
@@ -134,8 +134,14 @@ ttyinq_setsize(struct ttyinq *ti, struct
tib = uma_zalloc(ttyinq_zone, M_WAITOK);
tty_lock(tp);
 
+   if (tty_gone(tp)) {
+   uma_zfree(ttyinq_zone, tib);
+   return (ENXIO);
+   }
+
TTYINQ_INSERT_TAIL(ti, tib);
}
+   return (0);
 }
 
 void

Modified: head/sys/kern/tty_outq.c
==
--- head/sys/kern/tty_outq.cFri Jan 13 15:17:25 2017(r312076)
+++ head/sys/kern/tty_outq.cFri Jan 13 16:37:38 2017(r312077)
@@ -89,7 +89,7 @@ ttyoutq_flush(struct ttyoutq *to)
to->to_end = 0;
 }
 
-void
+int
 ttyoutq_setsize(struct ttyoutq *to, struct tty *tp, size_t size)
 {
struct ttyoutq_block *tob;
@@ -111,8 +111,14 @@ ttyoutq_setsize(struct ttyoutq *to, stru
tob = uma_zalloc(ttyoutq_zone, M_WAITOK);
tty_lock(tp);
 
+   if (tty_gone(tp)) {
+   uma_zfree(ttyoutq_zone, tob);
+   return (ENXIO);
+   }
+
TTYOUTQ_INSERT_TAIL(to, tob);
}
+   return (0);
 }
 
 void

Modified: head/sys/sys/ttyqueue.h

svn commit: r312076 - head/lib/libgcc_s

2017-01-13 Thread Ed Maste
Author: emaste
Date: Fri Jan 13 15:17:25 2017
New Revision: 312076
URL: https://svnweb.freebsd.org/changeset/base/312076

Log:
  libgcc_s: add libc DT_NEEDED to fix underlinking
  
  PR:   216012
  Reported by:  jbeich
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/lib/libgcc_s/Makefile

Modified: head/lib/libgcc_s/Makefile
==
--- head/lib/libgcc_s/Makefile  Fri Jan 13 13:50:44 2017(r312075)
+++ head/lib/libgcc_s/Makefile  Fri Jan 13 15:17:25 2017(r312076)
@@ -8,6 +8,7 @@ MK_SSP= no
 WARNS?=2
 
 LDFLAGS+=  -nodefaultlibs
+LIBADD+=   c
 VERSION_MAP=   ${.CURDIR}/Version.map
 
 .include "../libcompiler_rt/Makefile.inc"
___
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: r312075 - stable/11/sys/dev/drm2/i915

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 13:50:44 2017
New Revision: 312075
URL: https://svnweb.freebsd.org/changeset/base/312075

Log:
  MFC r309712:
  Use the populate() driver paging method for i915 driver.
  
  MFC r310027:
  Fix bug in r309712, do not leak gem object pin count in case of error
  or retry.

Modified:
  stable/11/sys/dev/drm2/i915/i915_gem.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/drm2/i915/i915_gem.c
==
--- stable/11/sys/dev/drm2/i915/i915_gem.c  Fri Jan 13 13:47:26 2017
(r312074)
+++ stable/11/sys/dev/drm2/i915/i915_gem.c  Fri Jan 13 13:50:44 2017
(r312075)
@@ -1474,8 +1474,8 @@ i915_gem_pager_ctor(void *handle, vm_oof
 int i915_intr_pf;
 
 static int
-i915_gem_pager_fault(vm_object_t vm_obj, vm_ooffset_t offset, int prot,
-vm_page_t *mres)
+i915_gem_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type,
+vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
 {
struct drm_gem_object *gem_obj = vm_obj->handle;
struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
@@ -1483,31 +1483,9 @@ i915_gem_pager_fault(vm_object_t vm_obj,
drm_i915_private_t *dev_priv = dev->dev_private;
vm_page_t page;
int ret = 0;
-#ifdef FREEBSD_WIP
-   bool write = (prot & VM_PROT_WRITE) != 0;
-#else
-   bool write = true;
-#endif /* FREEBSD_WIP */
+   bool write = (max_prot & VM_PROT_WRITE) != 0;
bool pinned;
 
-   vm_object_pip_add(vm_obj, 1);
-
-   /*
-* Remove the placeholder page inserted by vm_fault() from the
-* object before dropping the object lock. If
-* i915_gem_release_mmap() is active in parallel on this gem
-* object, then it owns the drm device sx and might find the
-* placeholder already. Then, since the page is busy,
-* i915_gem_release_mmap() sleeps waiting for the busy state
-* of the page cleared. We will be unable to acquire drm
-* device lock until i915_gem_release_mmap() is able to make a
-* progress.
-*/
-   if (*mres != NULL) {
-   vm_page_lock(*mres);
-   vm_page_remove(*mres);
-   vm_page_unlock(*mres);
-   }
VM_OBJECT_WUNLOCK(vm_obj);
 retry:
ret = 0;
@@ -1527,7 +1505,7 @@ retry:
 * mapping for the page.  Recheck.
 */
VM_OBJECT_WLOCK(vm_obj);
-   page = vm_page_lookup(vm_obj, OFF_TO_IDX(offset));
+   page = vm_page_lookup(vm_obj, pidx);
if (page != NULL) {
if (vm_page_busied(page)) {
DRM_UNLOCK(dev);
@@ -1556,20 +1534,19 @@ retry:
 
obj->fault_mappable = true;
 
-   VM_OBJECT_WLOCK(vm_obj);
-   page = PHYS_TO_VM_PAGE(dev_priv->mm.gtt_base_addr + obj->gtt_offset + 
offset);
-   KASSERT((page->flags & PG_FICTITIOUS) != 0,
-   ("physical address %#jx not fictitious",
-   (uintmax_t)(dev_priv->mm.gtt_base_addr + obj->gtt_offset + 
offset)));
+   page = PHYS_TO_VM_PAGE(dev_priv->mm.gtt_base_addr + obj->gtt_offset +
+   IDX_TO_OFF(pidx));
if (page == NULL) {
-   VM_OBJECT_WUNLOCK(vm_obj);
ret = -EFAULT;
goto unpin;
}
KASSERT((page->flags & PG_FICTITIOUS) != 0,
-   ("not fictitious %p", page));
+   ("physical address %#jx not fictitious, page %p",
+   (uintmax_t)(dev_priv->mm.gtt_base_addr + obj->gtt_offset +
+   IDX_TO_OFF(pidx)), page));
KASSERT(page->wire_count == 1, ("wire_count not 1 %p", page));
 
+   VM_OBJECT_WLOCK(vm_obj);
if (vm_page_busied(page)) {
i915_gem_object_unpin(obj);
DRM_UNLOCK(dev);
@@ -1578,7 +1555,7 @@ retry:
vm_page_busy_sleep(page, "915pbs", false);
goto retry;
}
-   if (vm_page_insert(page, vm_obj, OFF_TO_IDX(offset))) {
+   if (vm_page_insert(page, vm_obj, pidx)) {
i915_gem_object_unpin(obj);
DRM_UNLOCK(dev);
VM_OBJECT_WUNLOCK(vm_obj);
@@ -1589,24 +1566,17 @@ retry:
 have_page:
vm_page_xbusy(page);
 
-   CTR4(KTR_DRM, "fault %p %jx %x phys %x", gem_obj, offset, prot,
+   CTR4(KTR_DRM, "fault %p %jx %x phys %x", gem_obj, pidx, fault_type,
page->phys_addr);
if (pinned) {
/*
 * We may have not pinned the object if the page was
-* found by the call to vm_page_lookup()
+* found by the call to vm_page_lookup().
 */
i915_gem_object_unpin(obj);
}
DRM_UNLOCK(dev);
-   if (*mres != NULL) {
-   KASSERT(*mres != page, ("losing %p %p", *mres, page));
-   vm_page_lock(*mres);
-   vm_page_free(*mres);
-   vm_page_unlock(*mres);
-   }
-   *mres = 

svn commit: r312074 - stable/11/sys/vm

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 13:47:26 2017
New Revision: 312074
URL: https://svnweb.freebsd.org/changeset/base/312074

Log:
  MFC r309711:
  Implement the populate() pager method for phys pager.

Modified:
  stable/11/sys/vm/phys_pager.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/vm/phys_pager.c
==
--- stable/11/sys/vm/phys_pager.c   Fri Jan 13 13:45:34 2017
(r312073)
+++ stable/11/sys/vm/phys_pager.c   Fri Jan 13 13:47:26 2017
(r312074)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* list of phys pager objects */
@@ -98,6 +99,7 @@ phys_pager_alloc(void *handle, vm_ooffse
object = object1;
object1 = NULL;
object->handle = handle;
+   vm_object_set_flag(object, OBJ_POPULATE);
TAILQ_INSERT_TAIL(_pager_object_list,
object, pager_object_list);
}
@@ -109,6 +111,7 @@ phys_pager_alloc(void *handle, vm_ooffse
vm_object_deallocate(object1);
} else {
object = vm_object_allocate(OBJT_PHYS, pindex);
+   vm_object_set_flag(object, OBJ_POPULATE);
}
 
return (object);
@@ -157,32 +160,101 @@ phys_pager_getpages(vm_object_t object, 
return (VM_PAGER_OK);
 }
 
-static void
-phys_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t 
sync,
-int *rtvals)
-{
-
-   panic("phys_pager_putpage called");
-}
-
 /*
  * Implement a pretty aggressive clustered getpages strategy.  Hint that
  * everything in an entire 4MB window should be prefaulted at once.
  *
- * XXX 4MB (1024 slots per page table page) is convenient for x86,
+ * 4MB (1024 slots per page table page) is convenient for x86,
  * but may not be for other arches.
  */
 #ifndef PHYSCLUSTER
 #define PHYSCLUSTER 1024
 #endif
+static int phys_pager_cluster = PHYSCLUSTER;
+SYSCTL_INT(_vm, OID_AUTO, phys_pager_cluster, CTLFLAG_RWTUN,
+_pager_cluster, 0,
+"prefault window size for phys pager");
+
+/*
+ * Max hint to vm_page_alloc() about the further allocation needs
+ * inside the phys_pager_populate() loop.  The number of bits used to
+ * implement VM_ALLOC_COUNT() determines the hard limit on this value.
+ * That limit is currently 65535.
+ */
+#definePHYSALLOC   16
+
+static int
+phys_pager_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type __unused, vm_prot_t max_prot __unused, vm_pindex_t *first,
+vm_pindex_t *last)
+{
+   vm_page_t m;
+   vm_pindex_t base, end, i;
+   int ahead;
+
+   base = rounddown(pidx, phys_pager_cluster);
+   end = base + phys_pager_cluster - 1;
+   if (end >= object->size)
+   end = object->size - 1;
+   if (*first > base)
+   base = *first;
+   if (end > *last)
+   end = *last;
+   *first = base;
+   *last = end;
+
+   for (i = base; i <= end; i++) {
+retry:
+   m = vm_page_lookup(object, i);
+   if (m == NULL) {
+   ahead = MIN(end - i, PHYSALLOC);
+   m = vm_page_alloc(object, i, VM_ALLOC_NORMAL |
+   VM_ALLOC_ZERO | VM_ALLOC_COUNT(ahead));
+   if (m == NULL) {
+   VM_OBJECT_WUNLOCK(object);
+   VM_WAIT;
+   VM_OBJECT_WLOCK(object);
+   goto retry;
+   }
+   if ((m->flags & PG_ZERO) == 0)
+   pmap_zero_page(m);
+   m->valid = VM_PAGE_BITS_ALL;
+   } else if (vm_page_xbusied(m)) {
+   vm_page_lock(m);
+   VM_OBJECT_WUNLOCK(object);
+   vm_page_busy_sleep(m, "physb", true);
+   VM_OBJECT_WLOCK(object);
+   goto retry;
+   } else {
+   vm_page_xbusy(m);
+   if (m->valid != VM_PAGE_BITS_ALL)
+   vm_page_zero_invalid(m, TRUE);
+   }
+
+   KASSERT(m->valid == VM_PAGE_BITS_ALL,
+   ("phys_pager_populate: partially valid page %p", m));
+   KASSERT(m->dirty == 0,
+   ("phys_pager_populate: dirty page %p", m));
+   }
+   return (VM_PAGER_OK);
+}
+
+static void
+phys_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t 
sync,
+int *rtvals)
+{
+
+   panic("phys_pager_putpage called");
+}
+
 static boolean_t
 phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
 int *after)
 {
vm_pindex_t base, end;
 
-   base = 

svn commit: r312073 - stable/11/sys/vm

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 13:45:34 2017
New Revision: 312073
URL: https://svnweb.freebsd.org/changeset/base/312073

Log:
  MFC r309710:
  Add a new populate() pager method and extend device pager ops vector
  with cdev_pg_populate() to provide device drivers access to it.
  
  MFC r310849:
  Fix two similar bugs in the populate vm_fault() code.

Modified:
  stable/11/sys/vm/device_pager.c
  stable/11/sys/vm/vm_fault.c
  stable/11/sys/vm/vm_object.h
  stable/11/sys/vm/vm_pager.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/vm/device_pager.c
==
--- stable/11/sys/vm/device_pager.c Fri Jan 13 13:37:09 2017
(r312072)
+++ stable/11/sys/vm/device_pager.c Fri Jan 13 13:45:34 2017
(r312073)
@@ -63,6 +63,8 @@ static int dev_pager_getpages(vm_object_
 static void dev_pager_putpages(vm_object_t, vm_page_t *, int, int, int *);
 static boolean_t dev_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
 static void dev_pager_free_page(vm_object_t object, vm_page_t m);
+static int dev_pager_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type, vm_prot_t, vm_pindex_t *first, vm_pindex_t *last);
 
 /* list of device pager objects */
 static struct pagerlst dev_pager_object_list;
@@ -84,6 +86,7 @@ struct pagerops mgtdevicepagerops = {
.pgo_getpages = dev_pager_getpages,
.pgo_putpages = dev_pager_putpages,
.pgo_haspage =  dev_pager_haspage,
+   .pgo_populate = dev_pager_populate,
 };
 
 static int old_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
@@ -127,6 +130,8 @@ cdev_pager_allocate(void *handle, enum o
 
if (tp != OBJT_DEVICE && tp != OBJT_MGTDEVICE)
return (NULL);
+   KASSERT(tp == OBJT_MGTDEVICE || ops->cdev_pg_populate == NULL,
+   ("populate on unmanaged device pager"));
 
/*
 * Offset should be page aligned.
@@ -179,6 +184,8 @@ cdev_pager_allocate(void *handle, enum o
object->handle = handle;
TAILQ_INSERT_TAIL(_pager_object_list, object,
pager_object_list);
+   if (ops->cdev_pg_populate != NULL)
+   vm_object_set_flag(object, OBJ_POPULATE);
}
} else {
if (pindex > object->size)
@@ -268,6 +275,8 @@ dev_pager_getpages(vm_object_t object, v
/* Since our haspage reports zero after/before, the count is 1. */
KASSERT(count == 1, ("%s: count %d", __func__, count));
VM_OBJECT_ASSERT_WLOCKED(object);
+   if (object->un_pager.devp.ops->cdev_pg_fault == NULL)
+   return (VM_PAGER_FAIL);
error = object->un_pager.devp.ops->cdev_pg_fault(object,
IDX_TO_OFF(ma[0]->pindex), PROT_READ, [0]);
 
@@ -293,6 +302,18 @@ dev_pager_getpages(vm_object_t object, v
 }
 
 static int
+dev_pager_populate(vm_object_t object, vm_pindex_t pidx, int fault_type,
+vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
+{
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+   if (object->un_pager.devp.ops->cdev_pg_populate == NULL)
+   return (VM_PAGER_FAIL);
+   return (object->un_pager.devp.ops->cdev_pg_populate(object, pidx,
+   fault_type, max_prot, first, last));
+}
+
+static int
 old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
 vm_page_t *mres)
 {

Modified: stable/11/sys/vm/vm_fault.c
==
--- stable/11/sys/vm/vm_fault.c Fri Jan 13 13:37:09 2017(r312072)
+++ stable/11/sys/vm/vm_fault.c Fri Jan 13 13:45:34 2017(r312073)
@@ -289,6 +289,157 @@ vm_fault_soft_fast(struct faultstate *fs
return (KERN_SUCCESS);
 }
 
+static void
+vm_fault_restore_map_lock(struct faultstate *fs)
+{
+
+   VM_OBJECT_ASSERT_WLOCKED(fs->first_object);
+   MPASS(fs->first_object->paging_in_progress > 0);
+
+   if (!vm_map_trylock_read(fs->map)) {
+   VM_OBJECT_WUNLOCK(fs->first_object);
+   vm_map_lock_read(fs->map);
+   VM_OBJECT_WLOCK(fs->first_object);
+   }
+   fs->lookup_still_valid = true;
+}
+
+static void
+vm_fault_populate_check_page(vm_page_t m)
+{
+
+   /*
+* Check each page to ensure that the pager is obeying the
+* interface: the page must be installed in the object, fully
+* valid, and exclusively busied.
+*/
+   MPASS(m != NULL);
+   MPASS(m->valid == VM_PAGE_BITS_ALL);
+   MPASS(vm_page_xbusied(m));
+}
+
+static void
+vm_fault_populate_cleanup(vm_object_t object, vm_pindex_t first,
+vm_pindex_t last)
+{
+   vm_page_t m;
+   vm_pindex_t pidx;
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+   MPASS(first <= last);
+   for (pidx = first, m = vm_page_lookup(object, pidx);
+   pidx <= last; pidx++, m = vm_page_next(m)) {
+ 

svn commit: r312072 - in stable/11: bin/pax contrib/mtree sbin/fsck_ffs sys/fs/nfsclient sys/fs/tmpfs sys/ufs/ffs sys/ufs/ufs tests/sys/kern/pipe usr.bin/find usr.bin/gzip usr.sbin/fmtree

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 13:37:09 2017
New Revision: 312072
URL: https://svnweb.freebsd.org/changeset/base/312072

Log:
  MFC r311522:
  Use type-independent formats for printing nlink_t and ino_t.

Modified:
  stable/11/bin/pax/gen_subs.c
  stable/11/contrib/mtree/create.c
  stable/11/contrib/mtree/spec.c
  stable/11/contrib/mtree/specspec.c
  stable/11/sbin/fsck_ffs/suj.c
  stable/11/sys/fs/nfsclient/nfs_clvnops.c
  stable/11/sys/fs/tmpfs/tmpfs_vnops.c
  stable/11/sys/ufs/ffs/ffs_softdep.c
  stable/11/sys/ufs/ufs/ufs_vnops.c
  stable/11/tests/sys/kern/pipe/pipe_ino_test.c
  stable/11/usr.bin/find/ls.c
  stable/11/usr.bin/gzip/gzip.c
  stable/11/usr.sbin/fmtree/compare.c
  stable/11/usr.sbin/fmtree/create.c
  stable/11/usr.sbin/fmtree/specspec.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/bin/pax/gen_subs.c
==
--- stable/11/bin/pax/gen_subs.cFri Jan 13 13:03:47 2017
(r312071)
+++ stable/11/bin/pax/gen_subs.cFri Jan 13 13:37:09 2017
(r312072)
@@ -109,7 +109,8 @@ ls_list(ARCHD *arcn, time_t now, FILE *f
 */
if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
f_date[0] = '\0';
-   (void)fprintf(fp, "%s%2u %-12s %-12s ", f_mode, sbp->st_nlink,
+   (void)fprintf(fp, "%s%2ju %-12s %-12s ", f_mode,
+   (uintmax_t)sbp->st_nlink,
name_uid(sbp->st_uid, 1), name_gid(sbp->st_gid, 1));
 
/*

Modified: stable/11/contrib/mtree/create.c
==
--- stable/11/contrib/mtree/create.cFri Jan 13 13:03:47 2017
(r312071)
+++ stable/11/contrib/mtree/create.cFri Jan 13 13:37:09 2017
(r312072)
@@ -224,7 +224,8 @@ statf(FILE *fp, int indent, FTSENT *p)
output(fp, indent, , "device=%#jx",
(uintmax_t)p->fts_statp->st_rdev);
if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
-   output(fp, indent, , "nlink=%u", p->fts_statp->st_nlink);
+   output(fp, indent, , "nlink=%ju",
+   (uintmax_t)p->fts_statp->st_nlink);
if (keys & F_SIZE &&
(flavor == F_FREEBSD9 || S_ISREG(p->fts_statp->st_mode)))
output(fp, indent, , "size=%ju",

Modified: stable/11/contrib/mtree/spec.c
==
--- stable/11/contrib/mtree/spec.c  Fri Jan 13 13:03:47 2017
(r312071)
+++ stable/11/contrib/mtree/spec.c  Fri Jan 13 13:37:09 2017
(r312072)
@@ -363,7 +363,8 @@ dump_nodes(FILE *fp, const char *dir, NO
appendfield(fp, pathlast, "device=%#jx",
(uintmax_t)cur->st_rdev);
if (MATCHFLAG(F_NLINK))
-   appendfield(fp, pathlast, "nlink=%d", cur->st_nlink);
+   appendfield(fp, pathlast, "nlink=%ju",
+   (uintmax_t)cur->st_nlink);
if (MATCHFLAG(F_SLINK))
appendfield(fp, pathlast, "link=%s",
vispath(cur->slink));

Modified: stable/11/contrib/mtree/specspec.c
==
--- stable/11/contrib/mtree/specspec.c  Fri Jan 13 13:03:47 2017
(r312071)
+++ stable/11/contrib/mtree/specspec.c  Fri Jan 13 13:37:09 2017
(r312072)
@@ -73,7 +73,7 @@ shownode(NODE *n, int f, char const *pat
if (f & F_MODE)
printf(" mode=%o", n->st_mode);
if (f & F_NLINK)
-   printf(" nlink=%d", n->st_nlink);
+   printf(" nlink=%ju", (uintmax_t)n->st_nlink);
if (f & F_SIZE)
printf(" size=%jd", (intmax_t)n->st_size);
if (f & F_UID)

Modified: stable/11/sbin/fsck_ffs/suj.c
==
--- stable/11/sbin/fsck_ffs/suj.c   Fri Jan 13 13:03:47 2017
(r312071)
+++ stable/11/sbin/fsck_ffs/suj.c   Fri Jan 13 13:37:09 2017
(r312072)
@@ -1396,11 +1396,12 @@ ino_adjust(struct suj_ino *sino)
ip = ino_read(ino);
mode = DIP(ip, di_mode) & IFMT;
if (nlink > LINK_MAX)
-   err_suj("ino %ju nlink manipulation error, new %d, old %d\n",
-   (uintmax_t)ino, nlink, DIP(ip, di_nlink));
+   err_suj("ino %ju nlink manipulation error, new %ju, old %d\n",
+   (uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink));
if (debug)
-   printf("Adjusting ino %ju, nlink %d, old link %d lastmode %o\n",
-   (uintmax_t)ino, nlink, DIP(ip, di_nlink), sino->si_mode);
+  printf("Adjusting ino %ju, nlink %ju, old link %d lastmode %o\n",
+   (uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink),
+   

Re: svn commit: r286649 - in head: contrib/netbsd-tests/lib/libc/locale lib/libc/tests/locale

2017-01-13 Thread Jilles Tjoelker
On Wed, Jan 11, 2017 at 02:14:13AM -0800, Ngie Cooper (yaneurabeya) wrote:

> > On Aug 11, 2015, at 6:45 PM, Craig Rodrigues  wrote:
> > 
> > On Tue, Aug 11, 2015 at 2:59 PM, Jilles Tjoelker  > > wrote:
> > Author: jilles
> > Date: Tue Aug 11 21:59:36 2015
> > New Revision: 286649
> > URL: https://svnweb.freebsd.org/changeset/base/286649 
> > 

> > Log:
> >   Fix and re-enable UTF-8 tests.

> > Modified:
> >   head/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c
> >   head/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c
> >   head/lib/libc/tests/locale/Makefile

> > Thanks for fixing this.  What is the procedure that FreeBSD
> > developers need to follow to push this kind of change upstream to
> > NetBSD?

>   I’m submitting PRs with NetBSD as needed. To be frank, I’m not
> sure that this change is needed upstream (I’m probably going to #ifdef
> the code — some things I found when trying to push things back).

I think the change is required upstream as well, since UTF-8 no longer
includes code points greater than 0x10 per RFC 3629 (this change
made the code point ranges of UTF-8 and UTF-16 the same). The sequences
that used to correspond to code points greater than 0x10 shall be
treated as invalid. See also SVN r286490, r286491, r287125.

I suppose I should have included this reasoning in the original commit
message.

-- 
Jilles Tjoelker
___
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: r312069 - stable/10/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:47:44 2017
New Revision: 312069
URL: https://svnweb.freebsd.org/changeset/base/312069

Log:
  MFC r311525:
  Lock tmpfs node tn_status updates done under the shared vnode lock.

Modified:
  stable/10/sys/fs/tmpfs/tmpfs.h
  stable/10/sys/fs/tmpfs/tmpfs_fifoops.c
  stable/10/sys/fs/tmpfs/tmpfs_subr.c
  stable/10/sys/fs/tmpfs/tmpfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/tmpfs/tmpfs.h
==
--- stable/10/sys/fs/tmpfs/tmpfs.h  Fri Jan 13 12:45:54 2017
(r312068)
+++ stable/10/sys/fs/tmpfs/tmpfs.h  Fri Jan 13 12:47:44 2017
(r312069)
@@ -199,7 +199,9 @@ struct tmpfs_node {
 * allocated for it or it has been reclaimed). */
struct vnode *  tn_vnode;
 
-   /* interlock to protect tn_vpstate */
+   /* Interlock to protect tn_vpstate, and tn_status under shared
+* vnode lock.
+*/
struct mtx  tn_interlock;
 
/* Identify if current node has vnode assiocate with
@@ -420,6 +422,7 @@ int tmpfs_chtimes(struct vnode *, struct
 void   tmpfs_itimes(struct vnode *, const struct timespec *,
const struct timespec *);
 
+void   tmpfs_set_status(struct tmpfs_node *node, int status);
 void   tmpfs_update(struct vnode *);
 inttmpfs_truncate(struct vnode *, off_t);
 

Modified: stable/10/sys/fs/tmpfs/tmpfs_fifoops.c
==
--- stable/10/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:45:54 2017
(r312068)
+++ stable/10/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:47:44 2017
(r312069)
@@ -52,11 +52,11 @@ static int
 tmpfs_fifo_close(struct vop_close_args *v)
 {
struct tmpfs_node *node;
-   node = VP_TO_TMPFS_NODE(v->a_vp);
-   node->tn_status |= TMPFS_NODE_ACCESSED;
 
+   node = VP_TO_TMPFS_NODE(v->a_vp);
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
tmpfs_update(v->a_vp);
-   return fifo_specops.vop_close(v);
+   return (fifo_specops.vop_close(v));
 }
 
 /*

Modified: stable/10/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/10/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:45:54 2017
(r312068)
+++ stable/10/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:47:44 2017
(r312069)
@@ -1092,9 +1092,9 @@ tmpfs_dir_getdotdent(struct tmpfs_node *
else
error = uiomove(, dent.d_reclen, uio);
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1137,9 +1137,9 @@ tmpfs_dir_getdotdotdent(struct tmpfs_nod
else
error = uiomove(, dent.d_reclen, uio);
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1282,7 +1282,7 @@ tmpfs_dir_getdents(struct tmpfs_node *no
node->tn_dir.tn_readdir_lastn = off;
node->tn_dir.tn_readdir_lastp = de;
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
return error;
 }
 
@@ -1733,15 +1733,25 @@ tmpfs_chtimes(struct vnode *vp, struct v
return (0);
 }
 
-/* Sync timestamps */
 void
-tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
+tmpfs_set_status(struct tmpfs_node *node, int status)
+{
+
+   if ((node->tn_status & status) == status)
+   return;
+   TMPFS_NODE_LOCK(node);
+   node->tn_status |= status;
+   TMPFS_NODE_UNLOCK(node);
+}
+
+/* Sync timestamps */
+static void
+tmpfs_itimes_locked(struct tmpfs_node *node, const struct timespec *acc,
 const struct timespec *mod)
 {
-   struct tmpfs_node *node;
struct timespec now;
 
-   node = VP_TO_TMPFS_NODE(vp);
+   TMPFS_ASSERT_LOCKED(node);
 
if ((node->tn_status & (TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
TMPFS_NODE_CHANGED)) == 0)
@@ -1758,11 +1768,25 @@ tmpfs_itimes(struct vnode *vp, const str
mod = 
node->tn_mtime = *mod;
}
-   if (node->tn_status & TMPFS_NODE_CHANGED) {
+   if (node->tn_status & TMPFS_NODE_CHANGED)
node->tn_ctime = now;
-   }
-   node->tn_status &=
-   ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED);
+   node->tn_status &= ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
+   TMPFS_NODE_CHANGED);
+}
+
+void
+tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
+const struct timespec *mod)
+{
+   struct tmpfs_node *node;
+
+   ASSERT_VOP_LOCKED(vp, "tmpfs_itimes");
+   node = VP_TO_TMPFS_NODE(vp);
+
+   TMPFS_NODE_LOCK(node);
+   tmpfs_itimes_locked(node, acc, mod);
+   TMPFS_NODE_UNLOCK(node);
+
 }
 
 void
@@ -1794,14 

svn commit: r312068 - stable/10/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:45:54 2017
New Revision: 312068
URL: https://svnweb.freebsd.org/changeset/base/312068

Log:
  MFC r311524:
  Use vnode lock assertion expression, assert exclusive ownership.

Modified:
  stable/10/sys/fs/tmpfs/tmpfs_subr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/10/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:44:52 2017
(r312067)
+++ stable/10/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:45:54 2017
(r312068)
@@ -1458,7 +1458,7 @@ tmpfs_chflags(struct vnode *vp, u_long f
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chflags");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1498,9 +1498,9 @@ tmpfs_chflags(struct vnode *vp, u_long f
node->tn_flags = flags;
node->tn_status |= TMPFS_NODE_CHANGED;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chflags2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1514,7 +1514,7 @@ tmpfs_chmod(struct vnode *vp, mode_t mod
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chmod");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1554,9 +1554,9 @@ tmpfs_chmod(struct vnode *vp, mode_t mod
 
node->tn_status |= TMPFS_NODE_CHANGED;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chmod2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1575,7 +1575,7 @@ tmpfs_chown(struct vnode *vp, uid_t uid,
uid_t ouid;
gid_t ogid;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chown");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1625,9 +1625,9 @@ tmpfs_chown(struct vnode *vp, uid_t uid,
node->tn_mode &= ~(S_ISUID | S_ISGID);
}
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chown2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1642,7 +1642,7 @@ tmpfs_chsize(struct vnode *vp, u_quad_t 
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chsize");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1680,9 +1680,9 @@ tmpfs_chsize(struct vnode *vp, u_quad_t 
/* tmpfs_truncate will raise the NOTE_EXTEND and NOTE_ATTRIB kevents
 * for us, as will update tn_status; no need to do that here. */
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chsize2");
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1697,7 +1697,7 @@ tmpfs_chtimes(struct vnode *vp, struct v
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chtimes");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1728,9 +1728,9 @@ tmpfs_chtimes(struct vnode *vp, struct v
if (vap->va_birthtime.tv_nsec != VNOVAL &&
vap->va_birthtime.tv_nsec != VNOVAL)
node->tn_birthtime = vap->va_birthtime;
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chtimes2");
 
-   return 0;
+   return (0);
 }
 
 /* Sync timestamps */
___
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: r312067 - stable/10/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:44:52 2017
New Revision: 312067
URL: https://svnweb.freebsd.org/changeset/base/312067

Log:
  MFC r311523:
  Remove dead code.

Modified:
  stable/10/sys/fs/tmpfs/tmpfs_fifoops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/tmpfs/tmpfs_fifoops.c
==
--- stable/10/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:38:25 2017
(r312066)
+++ stable/10/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:44:52 2017
(r312067)
@@ -49,27 +49,6 @@
 #include 
 
 static int
-tmpfs_fifo_kqfilter(struct vop_kqfilter_args *ap)
-{
-   struct vnode *vp;
-   struct tmpfs_node *node;
-
-   vp = ap->a_vp;
-   node = VP_TO_TMPFS_NODE(vp);
-
-   switch (ap->a_kn->kn_filter){
-   case EVFILT_READ:
-   node->tn_status |= TMPFS_NODE_ACCESSED;
-   break;
-   case EVFILT_WRITE:
-   node->tn_status |= TMPFS_NODE_MODIFIED;
-   break;
-   }
-
-   return fifo_specops.vop_kqfilter(ap);
-}
-
-static int
 tmpfs_fifo_close(struct vop_close_args *v)
 {
struct tmpfs_node *node;
@@ -90,6 +69,5 @@ struct vop_vector tmpfs_fifoop_entries =
.vop_access =   tmpfs_access,
.vop_getattr =  tmpfs_getattr,
.vop_setattr =  tmpfs_setattr,
-   .vop_kqfilter = tmpfs_fifo_kqfilter,
 };
 
___
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: r312066 - stable/11/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:38:25 2017
New Revision: 312066
URL: https://svnweb.freebsd.org/changeset/base/312066

Log:
  MFC r311525:
  Lock tmpfs node tn_status updates done under the shared vnode lock.

Modified:
  stable/11/sys/fs/tmpfs/tmpfs.h
  stable/11/sys/fs/tmpfs/tmpfs_fifoops.c
  stable/11/sys/fs/tmpfs/tmpfs_subr.c
  stable/11/sys/fs/tmpfs/tmpfs_vnops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/tmpfs/tmpfs.h
==
--- stable/11/sys/fs/tmpfs/tmpfs.h  Fri Jan 13 12:36:53 2017
(r312065)
+++ stable/11/sys/fs/tmpfs/tmpfs.h  Fri Jan 13 12:38:25 2017
(r312066)
@@ -199,7 +199,9 @@ struct tmpfs_node {
 * allocated for it or it has been reclaimed). */
struct vnode *  tn_vnode;
 
-   /* interlock to protect tn_vpstate */
+   /* Interlock to protect tn_vpstate, and tn_status under shared
+* vnode lock.
+*/
struct mtx  tn_interlock;
 
/* Identify if current node has vnode assiocate with
@@ -420,6 +422,7 @@ int tmpfs_chtimes(struct vnode *, struct
 void   tmpfs_itimes(struct vnode *, const struct timespec *,
const struct timespec *);
 
+void   tmpfs_set_status(struct tmpfs_node *node, int status);
 void   tmpfs_update(struct vnode *);
 inttmpfs_truncate(struct vnode *, off_t);
 

Modified: stable/11/sys/fs/tmpfs/tmpfs_fifoops.c
==
--- stable/11/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:36:53 2017
(r312065)
+++ stable/11/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:38:25 2017
(r312066)
@@ -52,11 +52,11 @@ static int
 tmpfs_fifo_close(struct vop_close_args *v)
 {
struct tmpfs_node *node;
-   node = VP_TO_TMPFS_NODE(v->a_vp);
-   node->tn_status |= TMPFS_NODE_ACCESSED;
 
+   node = VP_TO_TMPFS_NODE(v->a_vp);
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
tmpfs_update(v->a_vp);
-   return fifo_specops.vop_close(v);
+   return (fifo_specops.vop_close(v));
 }
 
 /*

Modified: stable/11/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/11/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:36:53 2017
(r312065)
+++ stable/11/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:38:25 2017
(r312066)
@@ -1093,9 +1093,9 @@ tmpfs_dir_getdotdent(struct tmpfs_node *
else
error = uiomove(, dent.d_reclen, uio);
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1138,9 +1138,9 @@ tmpfs_dir_getdotdotdent(struct tmpfs_nod
else
error = uiomove(, dent.d_reclen, uio);
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1283,7 +1283,7 @@ tmpfs_dir_getdents(struct tmpfs_node *no
node->tn_dir.tn_readdir_lastn = off;
node->tn_dir.tn_readdir_lastp = de;
 
-   node->tn_status |= TMPFS_NODE_ACCESSED;
+   tmpfs_set_status(node, TMPFS_NODE_ACCESSED);
return error;
 }
 
@@ -1731,15 +1731,25 @@ tmpfs_chtimes(struct vnode *vp, struct v
return (0);
 }
 
-/* Sync timestamps */
 void
-tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
+tmpfs_set_status(struct tmpfs_node *node, int status)
+{
+
+   if ((node->tn_status & status) == status)
+   return;
+   TMPFS_NODE_LOCK(node);
+   node->tn_status |= status;
+   TMPFS_NODE_UNLOCK(node);
+}
+
+/* Sync timestamps */
+static void
+tmpfs_itimes_locked(struct tmpfs_node *node, const struct timespec *acc,
 const struct timespec *mod)
 {
-   struct tmpfs_node *node;
struct timespec now;
 
-   node = VP_TO_TMPFS_NODE(vp);
+   TMPFS_ASSERT_LOCKED(node);
 
if ((node->tn_status & (TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
TMPFS_NODE_CHANGED)) == 0)
@@ -1756,11 +1766,25 @@ tmpfs_itimes(struct vnode *vp, const str
mod = 
node->tn_mtime = *mod;
}
-   if (node->tn_status & TMPFS_NODE_CHANGED) {
+   if (node->tn_status & TMPFS_NODE_CHANGED)
node->tn_ctime = now;
-   }
-   node->tn_status &=
-   ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED);
+   node->tn_status &= ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
+   TMPFS_NODE_CHANGED);
+}
+
+void
+tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
+const struct timespec *mod)
+{
+   struct tmpfs_node *node;
+
+   ASSERT_VOP_LOCKED(vp, "tmpfs_itimes");
+   node = VP_TO_TMPFS_NODE(vp);
+
+   TMPFS_NODE_LOCK(node);
+   tmpfs_itimes_locked(node, acc, mod);
+   TMPFS_NODE_UNLOCK(node);
+
/* XXX: FIX? The 

svn commit: r312065 - stable/11/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:36:53 2017
New Revision: 312065
URL: https://svnweb.freebsd.org/changeset/base/312065

Log:
  MFC r311524:
  Use vnode lock assertion expression, assert exclusive ownership.

Modified:
  stable/11/sys/fs/tmpfs/tmpfs_subr.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/11/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:31:56 2017
(r312064)
+++ stable/11/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 13 12:36:53 2017
(r312065)
@@ -1458,7 +1458,7 @@ tmpfs_chflags(struct vnode *vp, u_long f
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chflags");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1498,9 +1498,9 @@ tmpfs_chflags(struct vnode *vp, u_long f
node->tn_flags = flags;
node->tn_status |= TMPFS_NODE_CHANGED;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chflags2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1514,7 +1514,7 @@ tmpfs_chmod(struct vnode *vp, mode_t mod
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chmod");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1554,9 +1554,9 @@ tmpfs_chmod(struct vnode *vp, mode_t mod
 
node->tn_status |= TMPFS_NODE_CHANGED;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chmod2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1575,7 +1575,7 @@ tmpfs_chown(struct vnode *vp, uid_t uid,
uid_t ouid;
gid_t ogid;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chown");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1625,9 +1625,9 @@ tmpfs_chown(struct vnode *vp, uid_t uid,
node->tn_mode &= ~(S_ISUID | S_ISGID);
}
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chown2");
 
-   return 0;
+   return (0);
 }
 
 /*
@@ -1642,7 +1642,7 @@ tmpfs_chsize(struct vnode *vp, u_quad_t 
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chsize");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1680,9 +1680,9 @@ tmpfs_chsize(struct vnode *vp, u_quad_t 
/* tmpfs_truncate will raise the NOTE_EXTEND and NOTE_ATTRIB kevents
 * for us, as will update tn_status; no need to do that here. */
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chsize2");
 
-   return error;
+   return (error);
 }
 
 /*
@@ -1697,7 +1697,7 @@ tmpfs_chtimes(struct vnode *vp, struct v
int error;
struct tmpfs_node *node;
 
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chtimes");
 
node = VP_TO_TMPFS_NODE(vp);
 
@@ -1726,9 +1726,9 @@ tmpfs_chtimes(struct vnode *vp, struct v
 
if (vap->va_birthtime.tv_sec != VNOVAL)
node->tn_birthtime = vap->va_birthtime;
-   MPASS(VOP_ISLOCKED(vp));
+   ASSERT_VOP_ELOCKED(vp, "chtimes2");
 
-   return 0;
+   return (0);
 }
 
 /* Sync timestamps */
___
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: r312064 - stable/11/sys/fs/tmpfs

2017-01-13 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 13 12:31:56 2017
New Revision: 312064
URL: https://svnweb.freebsd.org/changeset/base/312064

Log:
  MFC r311523:
  Remove dead code.

Modified:
  stable/11/sys/fs/tmpfs/tmpfs_fifoops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/tmpfs/tmpfs_fifoops.c
==
--- stable/11/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 10:55:26 2017
(r312063)
+++ stable/11/sys/fs/tmpfs/tmpfs_fifoops.c  Fri Jan 13 12:31:56 2017
(r312064)
@@ -49,27 +49,6 @@
 #include 
 
 static int
-tmpfs_fifo_kqfilter(struct vop_kqfilter_args *ap)
-{
-   struct vnode *vp;
-   struct tmpfs_node *node;
-
-   vp = ap->a_vp;
-   node = VP_TO_TMPFS_NODE(vp);
-
-   switch (ap->a_kn->kn_filter){
-   case EVFILT_READ:
-   node->tn_status |= TMPFS_NODE_ACCESSED;
-   break;
-   case EVFILT_WRITE:
-   node->tn_status |= TMPFS_NODE_MODIFIED;
-   break;
-   }
-
-   return fifo_specops.vop_kqfilter(ap);
-}
-
-static int
 tmpfs_fifo_close(struct vop_close_args *v)
 {
struct tmpfs_node *node;
@@ -90,6 +69,5 @@ struct vop_vector tmpfs_fifoop_entries =
.vop_access =   tmpfs_access,
.vop_getattr =  tmpfs_getattr,
.vop_setattr =  tmpfs_setattr,
-   .vop_kqfilter = tmpfs_fifo_kqfilter,
 };
 
___
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: r312063 - head/sys/netinet

2017-01-13 Thread Michael Tuexen
Author: tuexen
Date: Fri Jan 13 10:55:26 2017
New Revision: 312063
URL: https://svnweb.freebsd.org/changeset/base/312063

Log:
  Ensure that the buffer length and the length provided in the IPv4
  header match when using a raw socket to send IPv4 packets and
  providing the header. If they don't match, let send return -1
  and set errno to EINVAL.
  
  Before this patch is was only enforced that the length in the header
  is not larger then the buffer length.
  
  PR:   212283
  Reviewed by:  ae, gnn
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9161

Modified:
  head/sys/netinet/raw_ip.c

Modified: head/sys/netinet/raw_ip.c
==
--- head/sys/netinet/raw_ip.c   Fri Jan 13 10:28:26 2017(r312062)
+++ head/sys/netinet/raw_ip.c   Fri Jan 13 10:55:26 2017(r312063)
@@ -508,7 +508,7 @@ rip_output(struct mbuf *m, struct socket
 * and don't allow packet length sizes that will crash.
 */
if (((ip->ip_hl != (sizeof (*ip) >> 2)) && inp->inp_options)
-   || (ntohs(ip->ip_len) > m->m_pkthdr.len)
+   || (ntohs(ip->ip_len) != m->m_pkthdr.len)
|| (ntohs(ip->ip_len) < (ip->ip_hl << 2))) {
INP_RUNLOCK(inp);
m_freem(m);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r312061 - stable/10/contrib/bzip2

2017-01-13 Thread Dmitry Marakasov
Author: amdmi3 (ports committer)
Date: Fri Jan 13 10:28:24 2017
New Revision: 312061
URL: https://svnweb.freebsd.org/changeset/base/312061

Log:
  MFC r310718:
  
  bzip2 does not exit after showing license as requested with --version
  or --license as most apps would do, instead it waits for data to
  compress on stdin. Because of that, if `bzip2 --version' is called,
  bogus `bzip2: I won't write compressed data to a terminal' error
  message will be displayed, and checking for bzip2 version in scripts
  as in
  
  bzip2 --version 2>&1 | grep -o "Version [^,]*"
  
  will hand as bzip2 would wait for data to compress on stdin. Fix
  this by exiting right after showing version/license text.
  
  I've tried to push this upstream for more than a year, but author
  is unresponsive, so upstream may be considered dead.
  
  Ubuntu applies similar fix, for the note.
  
  PR:   199443
  Approved by:  dim, bapt
  Differential Revision:D8924

Modified:
  stable/10/contrib/bzip2/bzip2.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bzip2/bzip2.c
==
--- stable/10/contrib/bzip2/bzip2.c Fri Jan 13 09:32:11 2017
(r312060)
+++ stable/10/contrib/bzip2/bzip2.c Fri Jan 13 10:28:24 2017
(r312061)
@@ -1890,7 +1890,9 @@ IntNative main ( IntNative argc, Char *a
case '8': blockSize100k= 8; break;
case '9': blockSize100k= 9; break;
case 'V':
-   case 'L': license();break;
+   case 'L': license();
+ exit ( 0 );
+ break;
case 'v': verbosity++; break;
case 'h': usage ( progName );
  exit ( 0 );
@@ -1916,8 +1918,8 @@ IntNative main ( IntNative argc, Char *a
   if (ISFLAG("--keep"))  keepInputFiles   = True;else
   if (ISFLAG("--small")) smallMode= True;else
   if (ISFLAG("--quiet")) noisy= False;   else
-  if (ISFLAG("--version"))   license();  else
-  if (ISFLAG("--license"))   license();  else
+  if (ISFLAG("--version"))   { license(); exit ( 0 ); }  else
+  if (ISFLAG("--license"))   { license(); exit ( 0 ); }  else
   if (ISFLAG("--exponential"))   workFactor = 1; else 
   if (ISFLAG("--repetitive-best"))   redundant(aa->name);else
   if (ISFLAG("--repetitive-fast"))   redundant(aa->name);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"


svn commit: r312062 - stable/11/contrib/bzip2

2017-01-13 Thread Dmitry Marakasov
Author: amdmi3 (ports committer)
Date: Fri Jan 13 10:28:26 2017
New Revision: 312062
URL: https://svnweb.freebsd.org/changeset/base/312062

Log:
  MFC r310718:
  
  bzip2 does not exit after showing license as requested with --version
  or --license as most apps would do, instead it waits for data to
  compress on stdin. Because of that, if `bzip2 --version' is called,
  bogus `bzip2: I won't write compressed data to a terminal' error
  message will be displayed, and checking for bzip2 version in scripts
  as in
  
  bzip2 --version 2>&1 | grep -o "Version [^,]*"
  
  will hand as bzip2 would wait for data to compress on stdin. Fix
  this by exiting right after showing version/license text.
  
  I've tried to push this upstream for more than a year, but author
  is unresponsive, so upstream may be considered dead.
  
  Ubuntu applies similar fix, for the note.
  
  PR:   199443
  Approved by:  dim, bapt
  Differential Revision:D8924

Modified:
  stable/11/contrib/bzip2/bzip2.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bzip2/bzip2.c
==
--- stable/11/contrib/bzip2/bzip2.c Fri Jan 13 10:28:24 2017
(r312061)
+++ stable/11/contrib/bzip2/bzip2.c Fri Jan 13 10:28:26 2017
(r312062)
@@ -1890,7 +1890,9 @@ IntNative main ( IntNative argc, Char *a
case '8': blockSize100k= 8; break;
case '9': blockSize100k= 9; break;
case 'V':
-   case 'L': license();break;
+   case 'L': license();
+ exit ( 0 );
+ break;
case 'v': verbosity++; break;
case 'h': usage ( progName );
  exit ( 0 );
@@ -1916,8 +1918,8 @@ IntNative main ( IntNative argc, Char *a
   if (ISFLAG("--keep"))  keepInputFiles   = True;else
   if (ISFLAG("--small")) smallMode= True;else
   if (ISFLAG("--quiet")) noisy= False;   else
-  if (ISFLAG("--version"))   license();  else
-  if (ISFLAG("--license"))   license();  else
+  if (ISFLAG("--version"))   { license(); exit ( 0 ); }  else
+  if (ISFLAG("--license"))   { license(); exit ( 0 ); }  else
   if (ISFLAG("--exponential"))   workFactor = 1; else 
   if (ISFLAG("--repetitive-best"))   redundant(aa->name);else
   if (ISFLAG("--repetitive-fast"))   redundant(aa->name);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"


svn commit: r312059 - stable/11/contrib/bsnmp/snmpd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:19:09 2017
New Revision: 312059
URL: https://svnweb.freebsd.org/changeset/base/312059

Log:
  MFC r311381:
  
  lsock_init_port: address issues with initializing sockaddr_un object
  
  - Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*].
  - Use SUN_LEN(..) instead of spelling out calculation longhand (inspired
by comment by jmallett).
  
  Tested with:  dgram and stream support with both bsnmpwalk and snmpwalk
  
  CID:  1006825

Modified:
  stable/11/contrib/bsnmp/snmpd/trans_lsock.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmpd/trans_lsock.c
==
--- stable/11/contrib/bsnmp/snmpd/trans_lsock.c Fri Jan 13 09:19:04 2017
(r312058)
+++ stable/11/contrib/bsnmp/snmpd/trans_lsock.c Fri Jan 13 09:19:09 2017
(r312059)
@@ -305,10 +305,9 @@ lsock_init_port(struct tport *tp)
return (SNMP_ERR_RES_UNAVAIL);
}
 
-   strcpy(sa.sun_path, p->name);
+   strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
sa.sun_family = AF_LOCAL;
-   sa.sun_len = strlen(p->name) +
-   offsetof(struct sockaddr_un, sun_path);
+   sa.sun_len = SUN_LEN();
 
(void)remove(p->name);
 
@@ -360,10 +359,9 @@ lsock_init_port(struct tport *tp)
return (SNMP_ERR_GENERR);
}
 
-   strcpy(sa.sun_path, p->name);
+   strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
sa.sun_family = AF_LOCAL;
-   sa.sun_len = strlen(p->name) +
-   offsetof(struct sockaddr_un, sun_path);
+   sa.sun_len = SUN_LEN();
 
(void)remove(p->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: r312058 - stable/10/contrib/bsnmp/snmpd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:19:04 2017
New Revision: 312058
URL: https://svnweb.freebsd.org/changeset/base/312058

Log:
  MFC r310586,r310587,r310588,r311381:
  
  r310586:
  
  Refactor transport sources a bit to facilitate changes coming down pipeline
  
  Add recv callback to transport layer to better facilitate code reuse and
  readability and for symmetry with send callback. Move recv_dgram and
  recv_stream to udp_recv and lsock_recv, respectively, and make the
  beforementioned functions recv callbacks for the udp and lsock transports,
  respectively.
  
  Consolidate the check_priv* functions in their relevant trans*.c source to
  limit scope/use.
  
  Note: this code is roughly based content from the submitter, although this
  was modified to be more of a direct move from snmpd/main.c to the trans_*.c
  sources, and to reduce unnecessary static function declarations.
  
  r310587:
  
  Fix definition for recv_dgram(..); it should be "ssize_t", not "int"
  
  I'm not sure why this wasn't flagged as an issue by the compiler, yet
  
  r310588:
  
  Fix return type for `ret` (recv callback) and sort variables by alignment
  
  Again, for reasons I don't yet understand, this is not being flagged by the
  compiler. Unlike the issue addressed in r310587, this problem existed prior
  to r310586
  
  r311381:
  
  lsock_init_port: address issues with initializing sockaddr_un object
  
  - Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*].
  - Use SUN_LEN(..) instead of spelling out calculation longhand (inspired
by comment by jmallett).
  
  Tested with:  dgram and stream support with both bsnmpwalk and snmpwalk
  
  CID:  1006825

Modified:
  stable/10/contrib/bsnmp/snmpd/main.c
  stable/10/contrib/bsnmp/snmpd/snmpd.h
  stable/10/contrib/bsnmp/snmpd/trans_lsock.c
  stable/10/contrib/bsnmp/snmpd/trans_udp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/snmpd/main.c
==
--- stable/10/contrib/bsnmp/snmpd/main.cFri Jan 13 09:11:11 2017
(r312057)
+++ stable/10/contrib/bsnmp/snmpd/main.cFri Jan 13 09:19:04 2017
(r312058)
@@ -1024,154 +1024,6 @@ snmp_input_consume(struct port_input *pi
pi->length -= pi->consumed;
 }
 
-static void
-check_priv_dgram(struct port_input *pi, struct sockcred *cred)
-{
-
-   /* process explicitly sends credentials */
-   if (cred)
-   pi->priv = (cred->sc_euid == 0);
-   else
-   pi->priv = 0;
-}
-
-static void
-check_priv_stream(struct port_input *pi)
-{
-   struct xucred ucred;
-   socklen_t ucredlen;
-
-   /* obtain the accept time credentials */
-   ucredlen = sizeof(ucred);
-
-   if (getsockopt(pi->fd, 0, LOCAL_PEERCRED, , ) == 0 &&
-   ucredlen >= sizeof(ucred) && ucred.cr_version == XUCRED_VERSION)
-   pi->priv = (ucred.cr_uid == 0);
-   else
-   pi->priv = 0;
-}
-
-/*
- * Input from a stream socket.
- */
-static int
-recv_stream(struct port_input *pi)
-{
-   struct msghdr msg;
-   struct iovec iov[1];
-   ssize_t len;
-
-   if (pi->buf == NULL) {
-   /* no buffer yet - allocate one */
-   if ((pi->buf = buf_alloc(0)) == NULL) {
-   /* ups - could not get buffer. Return an error
-* the caller must close the transport. */
-   return (-1);
-   }
-   pi->buflen = buf_size(0);
-   pi->consumed = 0;
-   pi->length = 0;
-   }
-
-   /* try to get a message */
-   msg.msg_name = pi->peer;
-   msg.msg_namelen = pi->peerlen;
-   msg.msg_iov = iov;
-   msg.msg_iovlen = 1;
-   msg.msg_control = NULL;
-   msg.msg_controllen = 0;
-   msg.msg_flags = 0;
-
-   iov[0].iov_base = pi->buf + pi->length;
-   iov[0].iov_len = pi->buflen - pi->length;
-
-   len = recvmsg(pi->fd, , 0);
-
-   if (len == -1 || len == 0)
-   /* receive error */
-   return (-1);
-
-   pi->length += len;
-
-   if (pi->cred)
-   check_priv_stream(pi);
-
-   return (0);
-}
-
-/*
- * Input from a datagram socket.
- * Each receive should return one datagram.
- */
-static int
-recv_dgram(struct port_input *pi, struct in_addr *laddr)
-{
-   u_char embuf[1000];
-   char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) +
-   CMSG_SPACE(sizeof(struct in_addr))];
-   struct msghdr msg;
-   struct iovec iov[1];
-   ssize_t len;
-   struct cmsghdr *cmsg;
-   struct sockcred *cred = NULL;
-
-   if (pi->buf == NULL) {
-   /* no buffer yet - allocate one */
-   if ((pi->buf = buf_alloc(0)) == NULL) {
-   /* ups - could not get buffer. Read away input
-* and drop it */
-   (void)recvfrom(pi->fd, 

svn commit: r312057 - stable/11/contrib/bsnmp/snmpd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:11:11 2017
New Revision: 312057
URL: https://svnweb.freebsd.org/changeset/base/312057

Log:
  MFC r310586,r310587,r310588:
  
  r310586:
  
  Refactor transport sources a bit to facilitate changes coming down pipeline
  
  Add recv callback to transport layer to better facilitate code reuse and
  readability and for symmetry with send callback. Move recv_dgram and
  recv_stream to udp_recv and lsock_recv, respectively, and make the
  beforementioned functions recv callbacks for the udp and lsock transports,
  respectively.
  
  Consolidate the check_priv* functions in their relevant trans*.c source to
  limit scope/use.
  
  Note: this code is roughly based content from the submitter, although this
  was modified to be more of a direct move from snmpd/main.c to the trans_*.c
  sources, and to reduce unnecessary static function declarations.
  
  r310587:
  
  Fix definition for recv_dgram(..); it should be "ssize_t", not "int"
  
  I'm not sure why this wasn't flagged as an issue by the compiler, yet
  
  r310588:
  
  Fix return type for `ret` (recv callback) and sort variables by alignment
  
  Again, for reasons I don't yet understand, this is not being flagged by the
  compiler. Unlike the issue addressed in r310587, this problem existed prior
  to r310586

Modified:
  stable/11/contrib/bsnmp/snmpd/main.c
  stable/11/contrib/bsnmp/snmpd/snmpd.h
  stable/11/contrib/bsnmp/snmpd/trans_lsock.c
  stable/11/contrib/bsnmp/snmpd/trans_udp.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmpd/main.c
==
--- stable/11/contrib/bsnmp/snmpd/main.cFri Jan 13 09:07:29 2017
(r312056)
+++ stable/11/contrib/bsnmp/snmpd/main.cFri Jan 13 09:11:11 2017
(r312057)
@@ -1024,154 +1024,6 @@ snmp_input_consume(struct port_input *pi
pi->length -= pi->consumed;
 }
 
-static void
-check_priv_dgram(struct port_input *pi, struct sockcred *cred)
-{
-
-   /* process explicitly sends credentials */
-   if (cred)
-   pi->priv = (cred->sc_euid == 0);
-   else
-   pi->priv = 0;
-}
-
-static void
-check_priv_stream(struct port_input *pi)
-{
-   struct xucred ucred;
-   socklen_t ucredlen;
-
-   /* obtain the accept time credentials */
-   ucredlen = sizeof(ucred);
-
-   if (getsockopt(pi->fd, 0, LOCAL_PEERCRED, , ) == 0 &&
-   ucredlen >= sizeof(ucred) && ucred.cr_version == XUCRED_VERSION)
-   pi->priv = (ucred.cr_uid == 0);
-   else
-   pi->priv = 0;
-}
-
-/*
- * Input from a stream socket.
- */
-static int
-recv_stream(struct port_input *pi)
-{
-   struct msghdr msg;
-   struct iovec iov[1];
-   ssize_t len;
-
-   if (pi->buf == NULL) {
-   /* no buffer yet - allocate one */
-   if ((pi->buf = buf_alloc(0)) == NULL) {
-   /* ups - could not get buffer. Return an error
-* the caller must close the transport. */
-   return (-1);
-   }
-   pi->buflen = buf_size(0);
-   pi->consumed = 0;
-   pi->length = 0;
-   }
-
-   /* try to get a message */
-   msg.msg_name = pi->peer;
-   msg.msg_namelen = pi->peerlen;
-   msg.msg_iov = iov;
-   msg.msg_iovlen = 1;
-   msg.msg_control = NULL;
-   msg.msg_controllen = 0;
-   msg.msg_flags = 0;
-
-   iov[0].iov_base = pi->buf + pi->length;
-   iov[0].iov_len = pi->buflen - pi->length;
-
-   len = recvmsg(pi->fd, , 0);
-
-   if (len == -1 || len == 0)
-   /* receive error */
-   return (-1);
-
-   pi->length += len;
-
-   if (pi->cred)
-   check_priv_stream(pi);
-
-   return (0);
-}
-
-/*
- * Input from a datagram socket.
- * Each receive should return one datagram.
- */
-static int
-recv_dgram(struct port_input *pi, struct in_addr *laddr)
-{
-   u_char embuf[1000];
-   char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) +
-   CMSG_SPACE(sizeof(struct in_addr))];
-   struct msghdr msg;
-   struct iovec iov[1];
-   ssize_t len;
-   struct cmsghdr *cmsg;
-   struct sockcred *cred = NULL;
-
-   if (pi->buf == NULL) {
-   /* no buffer yet - allocate one */
-   if ((pi->buf = buf_alloc(0)) == NULL) {
-   /* ups - could not get buffer. Read away input
-* and drop it */
-   (void)recvfrom(pi->fd, embuf, sizeof(embuf),
-   0, NULL, NULL);
-   /* return error */
-   return (-1);
-   }
-   pi->buflen = buf_size(0);
-   }
-
-   /* try to get a message */
-   msg.msg_name = pi->peer;
-   msg.msg_namelen = pi->peerlen;
-   msg.msg_iov = iov;
-   msg.msg_iovlen = 

svn commit: r312056 - in stable/11/usr.sbin/bsnmpd/modules: snmp_atm snmp_hast snmp_hostres snmp_mibII snmp_target snmp_usm snmp_vacm

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:07:29 2017
New Revision: 312056
URL: https://svnweb.freebsd.org/changeset/base/312056

Log:
  MFC r311739:
  
  Use SRCTOP instead of spelling out the full path with .CURDIR
  
  This helps condense the output for CFLAGS and .PATH

Modified:
  stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_target/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
  stable/11/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile Fri Jan 13 09:07:25 
2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile Fri Jan 13 09:07:29 
2017(r312056)
@@ -2,7 +2,7 @@
 #
 # Author: Harti Brandt 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/ngatm
+CONTRIB= ${SRCTOP}/contrib/ngatm
 .PATH: ${CONTRIB}/snmp_atm
 
 MOD=   atm

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_hast/MakefileFri Jan 13 
09:07:25 2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_hast/MakefileFri Jan 13 
09:07:29 2017(r312056)
@@ -2,7 +2,7 @@
 
 .include 
 
-.PATH: ${.CURDIR}/../../../../sbin/hastd
+.PATH: ${SRCTOP}/sbin/hastd
 
 MOD=   hast
 SRCS=  ebuf.c
@@ -18,7 +18,7 @@ MAN=  snmp_hast.3
 NO_WFORMAT=
 NO_WCAST_ALIGN=
 NO_WMISSING_VARIABLE_DECLARATIONS=
-CFLAGS+=-I${.CURDIR}/../../../../sbin/hastd
+CFLAGS+=-I${SRCTOP}/sbin/hastd
 CFLAGS+=-DHAVE_CAPSICUM
 CFLAGS+=-DINET
 .if ${MK_INET6_SUPPORT} != "no"

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile Fri Jan 13 
09:07:25 2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile Fri Jan 13 
09:07:29 2017(r312056)
@@ -28,7 +28,7 @@
 # $FreeBSD$
 #
 
-LPRSRC=${.CURDIR}/../../../lpr/common_source
+LPRSRC=${SRCTOP}/usr.sbin/lpr/common_source
 .PATH: ${LPRSRC}
 
 MOD=   hostres

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile   Fri Jan 13 
09:07:25 2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile   Fri Jan 13 
09:07:29 2017(r312056)
@@ -2,7 +2,7 @@
 #
 # Author: Harti Brandt 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_mibII
 
 MOD=   mibII

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_target/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_target/Makefile  Fri Jan 13 
09:07:25 2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_target/Makefile  Fri Jan 13 
09:07:29 2017(r312056)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_target
 
 MOD=   target

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_usm/Makefile Fri Jan 13 09:07:25 
2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_usm/Makefile Fri Jan 13 09:07:29 
2017(r312056)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_usm
 
 MOD=   usm

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_vacm/MakefileFri Jan 13 
09:07:25 2017(r312055)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_vacm/MakefileFri Jan 13 
09:07:29 2017(r312056)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_vacm
 
 MOD=   vacm
___
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: r312055 - in stable/10/usr.sbin/bsnmpd/modules: snmp_atm snmp_hast snmp_hostres snmp_mibII snmp_target snmp_usm snmp_vacm

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:07:25 2017
New Revision: 312055
URL: https://svnweb.freebsd.org/changeset/base/312055

Log:
  MFC r311739:
  
  Use SRCTOP instead of spelling out the full path with .CURDIR
  
  This helps condense the output for CFLAGS and .PATH

Modified:
  stable/10/usr.sbin/bsnmpd/modules/snmp_atm/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_target/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
  stable/10/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_atm/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_atm/Makefile Fri Jan 13 09:04:29 
2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_atm/Makefile Fri Jan 13 09:07:25 
2017(r312055)
@@ -2,7 +2,7 @@
 #
 # Author: Harti Brandt 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/ngatm
+CONTRIB= ${SRCTOP}/contrib/ngatm
 .PATH: ${CONTRIB}/snmp_atm
 
 MOD=   atm

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_hast/MakefileFri Jan 13 
09:04:29 2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_hast/MakefileFri Jan 13 
09:07:25 2017(r312055)
@@ -2,7 +2,7 @@
 
 .include 
 
-.PATH: ${.CURDIR}/../../../../sbin/hastd
+.PATH: ${SRCTOP}/sbin/hastd
 
 MOD=   hast
 SRCS=  ebuf.c
@@ -18,7 +18,7 @@ MAN=  snmp_hast.3
 NO_WFORMAT=
 NO_WCAST_ALIGN=
 NO_WMISSING_VARIABLE_DECLARATIONS=
-CFLAGS+=-I${.CURDIR}/../../../../sbin/hastd
+CFLAGS+=-I${SRCTOP}/sbin/hastd
 CFLAGS+=-DHAVE_CAPSICUM
 CFLAGS+=-DINET
 .if ${MK_INET6_SUPPORT} != "no"

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile Fri Jan 13 
09:04:29 2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile Fri Jan 13 
09:07:25 2017(r312055)
@@ -28,7 +28,7 @@
 # $FreeBSD$
 #
 
-LPRSRC=${.CURDIR}/../../../lpr/common_source
+LPRSRC=${SRCTOP}/usr.sbin/lpr/common_source
 .PATH: ${LPRSRC}
 
 MOD=   hostres

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile   Fri Jan 13 
09:04:29 2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile   Fri Jan 13 
09:07:25 2017(r312055)
@@ -2,7 +2,7 @@
 #
 # Author: Harti Brandt 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_mibII
 
 MOD=   mibII

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_target/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_target/Makefile  Fri Jan 13 
09:04:29 2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_target/Makefile  Fri Jan 13 
09:07:25 2017(r312055)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_target
 
 MOD=   target

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_usm/Makefile Fri Jan 13 09:04:29 
2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_usm/Makefile Fri Jan 13 09:07:25 
2017(r312055)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_usm
 
 MOD=   usm

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_vacm/MakefileFri Jan 13 
09:04:29 2017(r312054)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_vacm/MakefileFri Jan 13 
09:07:25 2017(r312055)
@@ -2,7 +2,7 @@
 #
 # Author: Shteryana Shopova 
 
-CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+CONTRIB= ${SRCTOP}/contrib/bsnmp
 .PATH: ${CONTRIB}/snmp_vacm
 
 MOD=   vacm
___
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: r312054 - stable/10/contrib/bsnmp/snmpd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:04:29 2017
New Revision: 312054
URL: https://svnweb.freebsd.org/changeset/base/312054

Log:
  MFC r311378:
  
  lm_load: fix string copying issues
  
  - Ensure `section` doesn't overrun section by using strlcpy instead of
strcpy [*].
  - Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity,
but is an opportunistic change).
  
  CID:  1006826 [*]

Modified:
  stable/10/contrib/bsnmp/snmpd/main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/snmpd/main.c
==
--- stable/10/contrib/bsnmp/snmpd/main.cFri Jan 13 09:04:26 2017
(r312053)
+++ stable/10/contrib/bsnmp/snmpd/main.cFri Jan 13 09:04:29 2017
(r312054)
@@ -2508,13 +2508,12 @@ lm_load(const char *path, const char *se
}
m->handle = NULL;
m->flags = 0;
-   strcpy(m->section, section);
+   strlcpy(m->section, section, sizeof(m->section));
 
-   if ((m->path = malloc(strlen(path) + 1)) == NULL) {
+   if ((m->path = strdup(path)) == NULL) {
syslog(LOG_ERR, "lm_load: %m");
goto err;
}
-   strcpy(m->path, path);
 
/*
 * Make index
___
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: r312053 - stable/11/contrib/bsnmp/snmpd

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:04:26 2017
New Revision: 312053
URL: https://svnweb.freebsd.org/changeset/base/312053

Log:
  MFC r311378:
  
  lm_load: fix string copying issues
  
  - Ensure `section` doesn't overrun section by using strlcpy instead of
strcpy [*].
  - Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity,
but is an opportunistic change).
  
  CID:  1006826 [*]

Modified:
  stable/11/contrib/bsnmp/snmpd/main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmpd/main.c
==
--- stable/11/contrib/bsnmp/snmpd/main.cFri Jan 13 09:01:09 2017
(r312052)
+++ stable/11/contrib/bsnmp/snmpd/main.cFri Jan 13 09:04:26 2017
(r312053)
@@ -2508,13 +2508,12 @@ lm_load(const char *path, const char *se
}
m->handle = NULL;
m->flags = 0;
-   strcpy(m->section, section);
+   strlcpy(m->section, section, sizeof(m->section));
 
-   if ((m->path = malloc(strlen(path) + 1)) == NULL) {
+   if ((m->path = strdup(path)) == NULL) {
syslog(LOG_ERR, "lm_load: %m");
goto err;
}
-   strcpy(m->path, path);
 
/*
 * Make index
___
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: r312052 - stable/10/contrib/bsnmp/lib

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:01:09 2017
New Revision: 312052
URL: https://svnweb.freebsd.org/changeset/base/312052

Log:
  MFC r311390:
  
  snmp_table_fetch_async: don't leak `work` if snmp_pdu_send(..) fails
  
  CID:  1017276

Modified:
  stable/10/contrib/bsnmp/lib/snmpclient.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/lib/snmpclient.c
==
--- stable/10/contrib/bsnmp/lib/snmpclient.cFri Jan 13 09:01:06 2017
(r312051)
+++ stable/10/contrib/bsnmp/lib/snmpclient.cFri Jan 13 09:01:09 2017
(r312052)
@@ -728,8 +728,11 @@ snmp_table_fetch_async(const struct snmp
work->last_change = 0;
table_init_pdu(descr, >pdu);
 
-   if (snmp_pdu_send(>pdu, table_cb, work) == -1)
+   if (snmp_pdu_send(>pdu, table_cb, work) == -1) {
+   free(work);
+   work = NULL;
return (-1);
+   }
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: r312051 - stable/11/contrib/bsnmp/lib

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 09:01:06 2017
New Revision: 312051
URL: https://svnweb.freebsd.org/changeset/base/312051

Log:
  MFC r311390:
  
  snmp_table_fetch_async: don't leak `work` if snmp_pdu_send(..) fails
  
  CID:  1017276

Modified:
  stable/11/contrib/bsnmp/lib/snmpclient.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/lib/snmpclient.c
==
--- stable/11/contrib/bsnmp/lib/snmpclient.cFri Jan 13 08:59:22 2017
(r312050)
+++ stable/11/contrib/bsnmp/lib/snmpclient.cFri Jan 13 09:01:06 2017
(r312051)
@@ -728,8 +728,11 @@ snmp_table_fetch_async(const struct snmp
work->last_change = 0;
table_init_pdu(descr, >pdu);
 
-   if (snmp_pdu_send(>pdu, table_cb, work) == -1)
+   if (snmp_pdu_send(>pdu, table_cb, work) == -1) {
+   free(work);
+   work = NULL;
return (-1);
+   }
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: r312050 - stable/10/usr.sbin/bsnmpd/tools/bsnmptools

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:59:22 2017
New Revision: 312050
URL: https://svnweb.freebsd.org/changeset/base/312050

Log:
  MFC r310892,r310894,r310989:
  
  r310892:
  
  Don't call snmp_pdu_free(..) until finished with the pdu and when ready to
  allocate a new one via snmp_pdu_create(..)
  
  This fixes bsnmpwalk, so it no longer crashes after r310729
  
  r310894:
  
  snmp_pdu_free the right object at the right time in snmptool_walk
  
  r310892 was on the right track, but unfortunately it was resolving
  the problem incorrectly and accidentally leaking memory in the
  process.
  
  - Call snmp_pdu_free on req before calling snmp_pdu_create on it
at the bottom of the outer while loop
  - Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create
in the inner loop
  
  r310989:
  
  Call snmp_pdu_free on req/resp with a consistent, correct pattern
  
  - snmp_pdu_free should be called before snmp_pdu_create is called
again
  - snmp_pdu_free should be called on the resp to snmp_dialog when
successful
  
  Tested with the following bsnmp commands:
  
% export SNMPUSER=bsnmp SNMPPASSWD=bsnmptest
% SNMP_ARGS="-A proto=sha -C context='' -K -P proto=des -v 3 -r 0"
% bsnmpset $SNMP_ARGS sysLocation="MyAgent"
% bsnmpget $SNMP_ARGS sysLocation
% bsnmpwalk $SNMP_ARGS

Modified:
  stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
==
--- stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c   Fri Jan 13 
08:59:08 2017(r312049)
+++ stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c   Fri Jan 13 
08:59:22 2017(r312050)
@@ -400,13 +400,16 @@ snmptool_get(struct snmp_toolinfo *snmpt
 
if (snmp_parse_resp(, ) >= 0) {
snmp_output_resp(snmptoolctx, , NULL);
+   snmp_pdu_free();
break;
}
 
snmp_output_err_resp(snmptoolctx, );
if (GET_PDUTYPE(snmptoolctx) == SNMP_PDU_GETBULK ||
-   !ISSET_RETRY(snmptoolctx))
+   !ISSET_RETRY(snmptoolctx)) {
+   snmp_pdu_free();
break;
+   }
 
/*
 * Loop through the object list and set object->error to the
@@ -414,15 +417,17 @@ snmptool_get(struct snmp_toolinfo *snmpt
 */
if (snmp_object_seterror(snmptoolctx,
&(resp.bindings[resp.error_index - 1]),
-   resp.error_status) <= 0)
+   resp.error_status) <= 0) {
+   snmp_pdu_free();
break;
+   }
 
fprintf(stderr, "Retrying...\n");
snmp_pdu_free();
snmp_pdu_create(, GET_PDUTYPE(snmptoolctx));
}
 
-   snmp_pdu_free();
+   snmp_pdu_free();
 
return (0);
 }
@@ -498,27 +503,29 @@ snmptool_walk(struct snmp_toolinfo *snmp
}
 
outputs += rc;
-   snmp_pdu_free();
 
-   if ((u_int)rc < resp.nbindings)
+   if ((u_int)rc < resp.nbindings) {
+   snmp_pdu_free();
break;
+   }
 
snmpwalk_nextpdu_create(op,
&(resp.bindings[resp.nbindings - 1].var), );
if (op == SNMP_PDU_GETBULK)
snmpget_fix_getbulk(, 
GET_MAXREP(snmptoolctx),
GET_NONREP(snmptoolctx));
+   snmp_pdu_free();
}
 
/* Just in case our root was a leaf. */
if (outputs == 0) {
snmpwalk_nextpdu_create(SNMP_PDU_GET, , );
if (snmp_dialog(, ) == SNMP_CODE_OK) {
-   if (snmp_parse_resp(,) < 0)
+   if (snmp_parse_resp(, ) < 0)
snmp_output_err_resp(snmptoolctx, 
);
else
-   snmp_output_resp(snmptoolctx, &(resp), 
NULL);
-
+   snmp_output_resp(snmptoolctx, ,
+   NULL);
snmp_pdu_free();
} else
warn("Snmp dialog");
@@ -529,9 +536,12 @@ snmptool_walk(struct snmp_toolinfo *snmp
break;
}
 
+   snmp_pdu_free();
snmp_pdu_create(, op);
}
 
+   snmp_pdu_free();
+
if (rc == 0)
return (0);
else
@@ -1089,25 +1099,29 @@ 

svn commit: r312049 - stable/11/usr.sbin/bsnmpd/tools/bsnmptools

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:59:08 2017
New Revision: 312049
URL: https://svnweb.freebsd.org/changeset/base/312049

Log:
  MFC r310892,r310894,r310989:
  
  r310892:
  
  Don't call snmp_pdu_free(..) until finished with the pdu and when ready to
  allocate a new one via snmp_pdu_create(..)
  
  This fixes bsnmpwalk, so it no longer crashes after r310729
  
  r310894:
  
  snmp_pdu_free the right object at the right time in snmptool_walk
  
  r310892 was on the right track, but unfortunately it was resolving
  the problem incorrectly and accidentally leaking memory in the
  process.
  
  - Call snmp_pdu_free on req before calling snmp_pdu_create on it
at the bottom of the outer while loop
  - Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create
in the inner loop
  
  r310989:
  
  Call snmp_pdu_free on req/resp with a consistent, correct pattern
  
  - snmp_pdu_free should be called before snmp_pdu_create is called
again
  - snmp_pdu_free should be called on the resp to snmp_dialog when
successful
  
  Tested with the following bsnmp commands:
  
% export SNMPUSER=bsnmp SNMPPASSWD=bsnmptest
% SNMP_ARGS="-A proto=sha -C context='' -K -P proto=des -v 3 -r 0"
% bsnmpset $SNMP_ARGS sysLocation="MyAgent"
% bsnmpget $SNMP_ARGS sysLocation
% bsnmpwalk $SNMP_ARGS

Modified:
  stable/11/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
==
--- stable/11/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c   Fri Jan 13 
08:55:41 2017(r312048)
+++ stable/11/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c   Fri Jan 13 
08:59:08 2017(r312049)
@@ -400,13 +400,16 @@ snmptool_get(struct snmp_toolinfo *snmpt
 
if (snmp_parse_resp(, ) >= 0) {
snmp_output_resp(snmptoolctx, , NULL);
+   snmp_pdu_free();
break;
}
 
snmp_output_err_resp(snmptoolctx, );
if (GET_PDUTYPE(snmptoolctx) == SNMP_PDU_GETBULK ||
-   !ISSET_RETRY(snmptoolctx))
+   !ISSET_RETRY(snmptoolctx)) {
+   snmp_pdu_free();
break;
+   }
 
/*
 * Loop through the object list and set object->error to the
@@ -414,15 +417,17 @@ snmptool_get(struct snmp_toolinfo *snmpt
 */
if (snmp_object_seterror(snmptoolctx,
&(resp.bindings[resp.error_index - 1]),
-   resp.error_status) <= 0)
+   resp.error_status) <= 0) {
+   snmp_pdu_free();
break;
+   }
 
fprintf(stderr, "Retrying...\n");
snmp_pdu_free();
snmp_pdu_create(, GET_PDUTYPE(snmptoolctx));
}
 
-   snmp_pdu_free();
+   snmp_pdu_free();
 
return (0);
 }
@@ -498,27 +503,29 @@ snmptool_walk(struct snmp_toolinfo *snmp
}
 
outputs += rc;
-   snmp_pdu_free();
 
-   if ((u_int)rc < resp.nbindings)
+   if ((u_int)rc < resp.nbindings) {
+   snmp_pdu_free();
break;
+   }
 
snmpwalk_nextpdu_create(op,
&(resp.bindings[resp.nbindings - 1].var), );
if (op == SNMP_PDU_GETBULK)
snmpget_fix_getbulk(, 
GET_MAXREP(snmptoolctx),
GET_NONREP(snmptoolctx));
+   snmp_pdu_free();
}
 
/* Just in case our root was a leaf. */
if (outputs == 0) {
snmpwalk_nextpdu_create(SNMP_PDU_GET, , );
if (snmp_dialog(, ) == SNMP_CODE_OK) {
-   if (snmp_parse_resp(,) < 0)
+   if (snmp_parse_resp(, ) < 0)
snmp_output_err_resp(snmptoolctx, 
);
else
-   snmp_output_resp(snmptoolctx, &(resp), 
NULL);
-
+   snmp_output_resp(snmptoolctx, ,
+   NULL);
snmp_pdu_free();
} else
warn("Snmp dialog");
@@ -529,9 +536,12 @@ snmptool_walk(struct snmp_toolinfo *snmp
break;
}
 
+   snmp_pdu_free();
snmp_pdu_create(, op);
}
 
+   snmp_pdu_free();
+
if (rc == 0)
return (0);
else
@@ -1089,25 +1099,29 @@ 

svn commit: r312047 - stable/10/contrib/bsnmp/lib

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:55:37 2017
New Revision: 312047
URL: https://svnweb.freebsd.org/changeset/base/312047

Log:
  MFC r310729:
  
  Prevent improper memory accesses after calling snmp_pdu_free and 
snmp_value_free
  
  snmp_pdu_free: set pdu->nbindings to 0 to limit the damage that
  could happen if a pdu was reused after calling the function, and
  as both stack and heap allocation types are used in contrib/bsnmp
  and usr.sbin/bsnmpd.
  
  snmp_value_free: NULL out value->v.octetstring.octets after calling
  free on it to prevent a double-free from occurring.

Modified:
  stable/10/contrib/bsnmp/lib/snmp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/lib/snmp.c
==
--- stable/10/contrib/bsnmp/lib/snmp.c  Fri Jan 13 08:54:09 2017
(r312046)
+++ stable/10/contrib/bsnmp/lib/snmp.c  Fri Jan 13 08:55:37 2017
(r312047)
@@ -1154,8 +1154,11 @@ snmp_pdu_dump(const struct snmp_pdu *pdu
 void
 snmp_value_free(struct snmp_value *value)
 {
-   if (value->syntax == SNMP_SYNTAX_OCTETSTRING)
+
+   if (value->syntax == SNMP_SYNTAX_OCTETSTRING) {
free(value->v.octetstring.octets);
+   value->v.octetstring.octets = NULL;
+   }
value->syntax = SNMP_SYNTAX_NULL;
 }
 
@@ -1216,6 +1219,7 @@ snmp_pdu_free(struct snmp_pdu *pdu)
 
for (i = 0; i < pdu->nbindings; i++)
snmp_value_free(>bindings[i]);
+   pdu->nbindings = 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: r312048 - stable/11/contrib/bsnmp/lib

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:55:41 2017
New Revision: 312048
URL: https://svnweb.freebsd.org/changeset/base/312048

Log:
  MFC r310729:
  
  Prevent improper memory accesses after calling snmp_pdu_free and 
snmp_value_free
  
  snmp_pdu_free: set pdu->nbindings to 0 to limit the damage that
  could happen if a pdu was reused after calling the function, and
  as both stack and heap allocation types are used in contrib/bsnmp
  and usr.sbin/bsnmpd.
  
  snmp_value_free: NULL out value->v.octetstring.octets after calling
  free on it to prevent a double-free from occurring.

Modified:
  stable/11/contrib/bsnmp/lib/snmp.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/lib/snmp.c
==
--- stable/11/contrib/bsnmp/lib/snmp.c  Fri Jan 13 08:55:37 2017
(r312047)
+++ stable/11/contrib/bsnmp/lib/snmp.c  Fri Jan 13 08:55:41 2017
(r312048)
@@ -1154,8 +1154,11 @@ snmp_pdu_dump(const struct snmp_pdu *pdu
 void
 snmp_value_free(struct snmp_value *value)
 {
-   if (value->syntax == SNMP_SYNTAX_OCTETSTRING)
+
+   if (value->syntax == SNMP_SYNTAX_OCTETSTRING) {
free(value->v.octetstring.octets);
+   value->v.octetstring.octets = NULL;
+   }
value->syntax = SNMP_SYNTAX_NULL;
 }
 
@@ -1216,6 +1219,7 @@ snmp_pdu_free(struct snmp_pdu *pdu)
 
for (i = 0; i < pdu->nbindings; i++)
snmp_value_free(>bindings[i]);
+   pdu->nbindings = 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: r312046 - stable/11/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:54:09 2017
New Revision: 312046
URL: https://svnweb.freebsd.org/changeset/base/312046

Log:
  MFC r311733:
  
  Use nitems(mib) instead of hardcoding mib's length when calling sysctl(3)

Modified:
  stable/11/contrib/bsnmp/snmp_mibII/mibII.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmp_mibII/mibII.c
==
--- stable/11/contrib/bsnmp/snmp_mibII/mibII.c  Fri Jan 13 08:54:06 2017
(r312045)
+++ stable/11/contrib/bsnmp/snmp_mibII/mibII.c  Fri Jan 13 08:54:09 2017
(r312046)
@@ -319,7 +319,7 @@ fetch_generic_mib(struct mibif *ifp, con
name[5] = IFDATA_GENERAL;
 
len = sizeof(ifp->mib);
-   if (sysctl(name, 6, >mib, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), >mib, , NULL, 0) == -1) {
if (errno != ENOENT)
syslog(LOG_WARNING, "sysctl(ifmib, %s) failed %m",
ifp->name);
@@ -480,7 +480,7 @@ mib_fetch_ifmib(struct mibif *ifp)
name[3] = IFMIB_IFDATA;
name[4] = ifp->sysindex;
name[5] = IFDATA_LINKSPECIFIC;
-   if (sysctl(name, 6, NULL, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), NULL, , NULL, 0) == -1) {
syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m",
ifp->name);
if (ifp->specmib != NULL) {
@@ -506,7 +506,7 @@ mib_fetch_ifmib(struct mibif *ifp)
ifp->specmib = newmib;
ifp->specmiblen = len;
}
-   if (sysctl(name, 6, ifp->specmib, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), ifp->specmib, , NULL, 0) == -1) {
syslog(LOG_WARNING, "sysctl linkmib (%s): %m", ifp->name);
if (ifp->specmib != NULL) {
ifp->specmib = NULL;
@@ -902,7 +902,7 @@ mib_refresh_iflist(void)
for (idx = 1; idx <= count; idx++) {
name[4] = idx;
len = sizeof(mib);
-   if (sysctl(name, 6, , , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), , , NULL, 0) == -1) {
if (errno == ENOENT)
continue;
syslog(LOG_ERR, "ifmib(%u): %m", idx);
@@ -1213,7 +1213,7 @@ mib_fetch_rtab(int af, int info, int arg
*lenp = 0;
 
/* initial estimate */
-   if (sysctl(name, 6, NULL, lenp, NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), NULL, lenp, NULL, 0) == -1) {
syslog(LOG_ERR, "sysctl estimate (%d,%d,%d,%d,%d,%d): %m",
name[0], name[1], name[2], name[3], name[4], name[5]);
return (NULL);
@@ -1230,7 +1230,7 @@ mib_fetch_rtab(int af, int info, int arg
}
buf = newbuf;
 
-   if (sysctl(name, 6, buf, lenp, NULL, 0) == 0)
+   if (sysctl(name, nitems(name), buf, lenp, NULL, 0) == 0)
break;
 
if (errno != ENOMEM) {
___
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: r312045 - stable/10/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:54:06 2017
New Revision: 312045
URL: https://svnweb.freebsd.org/changeset/base/312045

Log:
  MFC r311733:
  
  Use nitems(mib) instead of hardcoding mib's length when calling sysctl(3)

Modified:
  stable/10/contrib/bsnmp/snmp_mibII/mibII.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/snmp_mibII/mibII.c
==
--- stable/10/contrib/bsnmp/snmp_mibII/mibII.c  Fri Jan 13 08:51:46 2017
(r312044)
+++ stable/10/contrib/bsnmp/snmp_mibII/mibII.c  Fri Jan 13 08:54:06 2017
(r312045)
@@ -319,7 +319,7 @@ fetch_generic_mib(struct mibif *ifp, con
name[5] = IFDATA_GENERAL;
 
len = sizeof(ifp->mib);
-   if (sysctl(name, 6, >mib, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), >mib, , NULL, 0) == -1) {
if (errno != ENOENT)
syslog(LOG_WARNING, "sysctl(ifmib, %s) failed %m",
ifp->name);
@@ -480,7 +480,7 @@ mib_fetch_ifmib(struct mibif *ifp)
name[3] = IFMIB_IFDATA;
name[4] = ifp->sysindex;
name[5] = IFDATA_LINKSPECIFIC;
-   if (sysctl(name, 6, NULL, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), NULL, , NULL, 0) == -1) {
syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m",
ifp->name);
if (ifp->specmib != NULL) {
@@ -506,7 +506,7 @@ mib_fetch_ifmib(struct mibif *ifp)
ifp->specmib = newmib;
ifp->specmiblen = len;
}
-   if (sysctl(name, 6, ifp->specmib, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), ifp->specmib, , NULL, 0) == -1) {
syslog(LOG_WARNING, "sysctl linkmib (%s): %m", ifp->name);
if (ifp->specmib != NULL) {
ifp->specmib = NULL;
@@ -902,7 +902,7 @@ mib_refresh_iflist(void)
for (idx = 1; idx <= count; idx++) {
name[4] = idx;
len = sizeof(mib);
-   if (sysctl(name, 6, , , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), , , NULL, 0) == -1) {
if (errno == ENOENT)
continue;
syslog(LOG_ERR, "ifmib(%u): %m", idx);
@@ -1213,7 +1213,7 @@ mib_fetch_rtab(int af, int info, int arg
*lenp = 0;
 
/* initial estimate */
-   if (sysctl(name, 6, NULL, lenp, NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), NULL, lenp, NULL, 0) == -1) {
syslog(LOG_ERR, "sysctl estimate (%d,%d,%d,%d,%d,%d): %m",
name[0], name[1], name[2], name[3], name[4], name[5]);
return (NULL);
@@ -1230,7 +1230,7 @@ mib_fetch_rtab(int af, int info, int arg
}
buf = newbuf;
 
-   if (sysctl(name, 6, buf, lenp, NULL, 0) == 0)
+   if (sysctl(name, nitems(name), buf, lenp, NULL, 0) == 0)
break;
 
if (errno != ENOMEM) {
___
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: r312044 - stable/10/usr.sbin/bsnmpd/modules/snmp_bridge

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:51:46 2017
New Revision: 312044
URL: https://svnweb.freebsd.org/changeset/base/312044

Log:
  MFC r311290,r311293,r311294:
  
  r311290:
  
  Use strlcpy instead of strcpy when copying the bridge name to ifr.ifr_name
  to avoid buffer overflows
  
  CID:  1006735, 1006737, 1006738
  
  r311293:
  
  bridge_do_pfctl: allocate mib_name dynamically using asprintf
  
  This is being done to reduce wasted space, simplify complexity in
  the code, and to quell a Coverity warning about buffer overruns.
  warning about buffer overruns.
  
  CID:  1006736
  
  r311294:
  
  style cleanup
  
  - bridge_pf_dump: use nitems instead of spelling it out longhand
  - bridge_do_pfctl: sort variables by alignment for type

Modified:
  stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
==
--- stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c  Fri Jan 13 
08:51:43 2017(r312043)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c  Fri Jan 13 
08:51:46 2017(r312044)
@@ -485,7 +485,7 @@ bridge_set_if_up(const char* b_name, int
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, (caddr_t) ) < 0) {
syslog(LOG_ERR, "set bridge up: ioctl(SIOCGIFFLAGS) "
"failed: %s", strerror(errno));
@@ -516,7 +516,7 @@ bridge_create(const char *b_name)
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
if (ioctl(sock, SIOCIFCREATE, ) < 0) {
syslog(LOG_ERR, "create bridge: ioctl(SIOCIFCREATE) "
@@ -549,7 +549,7 @@ bridge_destroy(const char *b_name)
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
if (ioctl(sock, SIOCIFDESTROY, ) < 0) {
syslog(LOG_ERR, "destroy bridge: ioctl(SIOCIFDESTROY) "
@@ -1459,9 +1459,9 @@ bridge_get_pfval(uint8_t which)
 int32_t
 bridge_do_pfctl(int32_t bridge_ctl, enum snmp_op op, int32_t *val)
 {
-   char mib_name[100];
-   int32_t i, s_i;
+   char *mib_oid;
size_t len, s_len;
+   int32_t i, s_i;
 
if (bridge_ctl >= LEAF_begemotBridgeLayer2PfStatus)
return (-2);
@@ -1474,19 +1474,24 @@ bridge_do_pfctl(int32_t bridge_ctl, enum
 
len = sizeof(i);
 
-   strcpy(mib_name, bridge_sysctl);
+   asprintf(_oid, "%s%s", bridge_sysctl,
+   bridge_pf_sysctl[bridge_ctl].name);
+   if (mib_oid == NULL)
+   return (-1);
 
-   if (sysctlbyname(strcat(mib_name,
-   bridge_pf_sysctl[bridge_ctl].name), , ,
-   (op == SNMP_OP_SET ? _i : NULL), s_len) == -1) {
-   syslog(LOG_ERR, "sysctl(%s%s) failed - %s", bridge_sysctl,
-   bridge_pf_sysctl[bridge_ctl].name, strerror(errno));
+   if (sysctlbyname(mib_oid, , , (op == SNMP_OP_SET ? _i : NULL),
+   s_len) == -1) {
+   syslog(LOG_ERR, "sysctl(%s) failed - %s", mib_oid,
+   strerror(errno));
+   free(mib_oid);
return (-1);
}
 
bridge_pf_sysctl[bridge_ctl].val = i;
*val = i;
 
+   free(mib_oid);
+
return (i);
 }
 
@@ -1495,8 +1500,7 @@ bridge_pf_dump(void)
 {
uint8_t i;
 
-   for (i = 0; i < sizeof(bridge_pf_sysctl) / sizeof(bridge_pf_sysctl[0]);
-   i++) {
+   for (i = 0; i < nitems(bridge_pf_sysctl); i++) {
syslog(LOG_ERR, "%s%s = %d", bridge_sysctl,
bridge_pf_sysctl[i].name, bridge_pf_sysctl[i].val);
}
___
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: r312043 - stable/11/usr.sbin/bsnmpd/modules/snmp_bridge

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:51:43 2017
New Revision: 312043
URL: https://svnweb.freebsd.org/changeset/base/312043

Log:
  MFC r311290,r311293,r311294:
  
  r311290:
  
  Use strlcpy instead of strcpy when copying the bridge name to ifr.ifr_name
  to avoid buffer overflows
  
  CID:  1006735, 1006737, 1006738
  
  r311293:
  
  bridge_do_pfctl: allocate mib_name dynamically using asprintf
  
  This is being done to reduce wasted space, simplify complexity in
  the code, and to quell a Coverity warning about buffer overruns.
  warning about buffer overruns.
  
  CID:  1006736
  
  r311294:
  
  style cleanup
  
  - bridge_pf_dump: use nitems instead of spelling it out longhand
  - bridge_do_pfctl: sort variables by alignment for type

Modified:
  stable/11/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
==
--- stable/11/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c  Fri Jan 13 
08:49:22 2017(r312042)
+++ stable/11/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c  Fri Jan 13 
08:51:43 2017(r312043)
@@ -485,7 +485,7 @@ bridge_set_if_up(const char* b_name, int
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, (caddr_t) ) < 0) {
syslog(LOG_ERR, "set bridge up: ioctl(SIOCGIFFLAGS) "
"failed: %s", strerror(errno));
@@ -516,7 +516,7 @@ bridge_create(const char *b_name)
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
if (ioctl(sock, SIOCIFCREATE, ) < 0) {
syslog(LOG_ERR, "create bridge: ioctl(SIOCIFCREATE) "
@@ -549,7 +549,7 @@ bridge_destroy(const char *b_name)
struct ifreq ifr;
 
bzero(, sizeof(ifr));
-   strcpy(ifr.ifr_name, b_name);
+   strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
if (ioctl(sock, SIOCIFDESTROY, ) < 0) {
syslog(LOG_ERR, "destroy bridge: ioctl(SIOCIFDESTROY) "
@@ -1459,9 +1459,9 @@ bridge_get_pfval(uint8_t which)
 int32_t
 bridge_do_pfctl(int32_t bridge_ctl, enum snmp_op op, int32_t *val)
 {
-   char mib_name[100];
-   int32_t i, s_i;
+   char *mib_oid;
size_t len, s_len;
+   int32_t i, s_i;
 
if (bridge_ctl >= LEAF_begemotBridgeLayer2PfStatus)
return (-2);
@@ -1474,19 +1474,24 @@ bridge_do_pfctl(int32_t bridge_ctl, enum
 
len = sizeof(i);
 
-   strcpy(mib_name, bridge_sysctl);
+   asprintf(_oid, "%s%s", bridge_sysctl,
+   bridge_pf_sysctl[bridge_ctl].name);
+   if (mib_oid == NULL)
+   return (-1);
 
-   if (sysctlbyname(strcat(mib_name,
-   bridge_pf_sysctl[bridge_ctl].name), , ,
-   (op == SNMP_OP_SET ? _i : NULL), s_len) == -1) {
-   syslog(LOG_ERR, "sysctl(%s%s) failed - %s", bridge_sysctl,
-   bridge_pf_sysctl[bridge_ctl].name, strerror(errno));
+   if (sysctlbyname(mib_oid, , , (op == SNMP_OP_SET ? _i : NULL),
+   s_len) == -1) {
+   syslog(LOG_ERR, "sysctl(%s) failed - %s", mib_oid,
+   strerror(errno));
+   free(mib_oid);
return (-1);
}
 
bridge_pf_sysctl[bridge_ctl].val = i;
*val = i;
 
+   free(mib_oid);
+
return (i);
 }
 
@@ -1495,8 +1500,7 @@ bridge_pf_dump(void)
 {
uint8_t i;
 
-   for (i = 0; i < sizeof(bridge_pf_sysctl) / sizeof(bridge_pf_sysctl[0]);
-   i++) {
+   for (i = 0; i < nitems(bridge_pf_sysctl); i++) {
syslog(LOG_ERR, "%s%s = %d", bridge_sysctl,
bridge_pf_sysctl[i].name, bridge_pf_sysctl[i].val);
}
___
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: r312041 - stable/11/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:49:10 2017
New Revision: 312041
URL: https://svnweb.freebsd.org/changeset/base/312041

Log:
  MFC r311282:
  
  snmp_mibII(3) requires net/if.h and net/if_mib.h
  
  Document that requirement

Modified:
  stable/11/contrib/bsnmp/snmp_mibII/snmp_mibII.3
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmp_mibII/snmp_mibII.3
==
--- stable/11/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Fri Jan 13 08:48:20 
2017(r312040)
+++ stable/11/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Fri Jan 13 08:49:10 
2017(r312041)
@@ -31,7 +31,7 @@
 .\"
 .\" $Begemot: bsnmp/snmp_mibII/snmp_mibII.3,v 1.10 2005/10/04 08:46:52 
brandt_h Exp $
 .\"
-.Dd October 4, 2005
+.Dd January 4, 2017
 .Dt SNMP_MIBII 3
 .Os
 .Sh NAME
@@ -63,6 +63,8 @@
 .Sh LIBRARY
 .Pq begemotSnmpdModulePath."mibII" = "@MODPATH@snmp_mibII.so"
 .Sh SYNOPSIS
+.In net/if.h
+.In net/if_mib.h
 .In bsnmp/snmpmod.h
 .In bsnmp/snmp_mibII.h
 .Ft typedef 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: r312042 - stable/10/contrib/bsnmp/snmp_mibII

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:49:22 2017
New Revision: 312042
URL: https://svnweb.freebsd.org/changeset/base/312042

Log:
  MFC r311282:
  
  snmp_mibII(3) requires net/if.h and net/if_mib.h
  
  Document that requirement

Modified:
  stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3
==
--- stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Fri Jan 13 08:49:10 
2017(r312041)
+++ stable/10/contrib/bsnmp/snmp_mibII/snmp_mibII.3 Fri Jan 13 08:49:22 
2017(r312042)
@@ -31,7 +31,7 @@
 .\"
 .\" $Begemot: bsnmp/snmp_mibII/snmp_mibII.3,v 1.10 2005/10/04 08:46:52 
brandt_h Exp $
 .\"
-.Dd October 4, 2005
+.Dd January 4, 2017
 .Dt SNMP_MIBII 3
 .Os
 .Sh NAME
@@ -63,6 +63,8 @@
 .Sh LIBRARY
 .Pq begemotSnmpdModulePath."mibII" = "@MODPATH@snmp_mibII.so"
 .Sh SYNOPSIS
+.In net/if.h
+.In net/if_mib.h
 .In bsnmp/snmpmod.h
 .In bsnmp/snmp_mibII.h
 .Ft typedef 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: r312039 - stable/10/contrib/netbsd-tests/lib/libc/sys

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:48:17 2017
New Revision: 312039
URL: https://svnweb.freebsd.org/changeset/base/312039

Log:
  MFC r311268:
  
  Clarify lifetime of child(..) function
  
  Ensure child exits when complete as it's always run in a forked
  process.
  
  Add a missing break statement in :pselect_sigmask when calling
  child(..) for clarity and to avoid weird domino effects if the
  child process somehow does something it's not supposed to do
  with the logfiles, file descriptors, etc
  
  CID:  1223369, 1223370, 1300301

Modified:
  stable/10/contrib/netbsd-tests/lib/libc/sys/t_select.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_select.c
==
--- stable/10/contrib/netbsd-tests/lib/libc/sys/t_select.c  Fri Jan 13 
08:46:49 2017(r312038)
+++ stable/10/contrib/netbsd-tests/lib/libc/sys/t_select.c  Fri Jan 13 
08:48:17 2017(r312039)
@@ -135,6 +135,9 @@ child(const struct timespec *ts)
"after timeout %s != %s",
prmask(, nbuf, sizeof(nbuf)),
prmask(, obuf, sizeof(obuf)));
+#ifdef __FreeBSD__
+   _exit(0);
+#endif
 }
 
 ATF_TC(pselect_sigmask);
@@ -154,6 +157,9 @@ ATF_TC_BODY(pselect_sigmask, tc)
switch (pid = fork()) {
case 0:
child(NULL);
+#ifdef __FreeBSD__
+   break;
+#endif
case -1:
err(1, "fork");
default:
___
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: r312040 - stable/11/contrib/netbsd-tests/lib/libc/sys

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:48:20 2017
New Revision: 312040
URL: https://svnweb.freebsd.org/changeset/base/312040

Log:
  MFC r311268:
  
  Clarify lifetime of child(..) function
  
  Ensure child exits when complete as it's always run in a forked
  process.
  
  Add a missing break statement in :pselect_sigmask when calling
  child(..) for clarity and to avoid weird domino effects if the
  child process somehow does something it's not supposed to do
  with the logfiles, file descriptors, etc
  
  CID:  1223369, 1223370, 1300301

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/sys/t_select.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/sys/t_select.c
==
--- stable/11/contrib/netbsd-tests/lib/libc/sys/t_select.c  Fri Jan 13 
08:48:17 2017(r312039)
+++ stable/11/contrib/netbsd-tests/lib/libc/sys/t_select.c  Fri Jan 13 
08:48:20 2017(r312040)
@@ -135,6 +135,9 @@ child(const struct timespec *ts)
"after timeout %s != %s",
prmask(, nbuf, sizeof(nbuf)),
prmask(, obuf, sizeof(obuf)));
+#ifdef __FreeBSD__
+   _exit(0);
+#endif
 }
 
 ATF_TC(pselect_sigmask);
@@ -154,6 +157,9 @@ ATF_TC_BODY(pselect_sigmask, tc)
switch (pid = fork()) {
case 0:
child(NULL);
+#ifdef __FreeBSD__
+   break;
+#endif
case -1:
err(1, "fork");
default:
___
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: r312037 - stable/11/contrib/netbsd-tests/lib/libpthread

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:46:46 2017
New Revision: 312037
URL: https://svnweb.freebsd.org/changeset/base/312037

Log:
  MFC r311265,r311274:
  
  r311265:
  
  fpu: ensure calls to pthread_create succeed and test sched_yield to make
  sure it returns 0
  
  sched_yield tests for values returning 0 of type int and sched_yield is
  of type long, so the test is a mismatch
  
  CID:  1254953, 1254954, 1254965, 1254966
  
  r311274:
  
  run: ensure pthread_condattr_{init,setclock} is successful
  
  CID:  1268631, 1268633

Modified:
  stable/11/contrib/netbsd-tests/lib/libpthread/t_condwait.c
  stable/11/contrib/netbsd-tests/lib/libpthread/t_fpu.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libpthread/t_condwait.c
==
--- stable/11/contrib/netbsd-tests/lib/libpthread/t_condwait.c  Fri Jan 13 
08:42:11 2017(r312036)
+++ stable/11/contrib/netbsd-tests/lib/libpthread/t_condwait.c  Fri Jan 13 
08:46:46 2017(r312037)
@@ -42,6 +42,8 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 201
 
 #ifdef __FreeBSD__
 #include 
+
+#include "h_common.h"
 #endif
 
 #define WAITTIME 2 /* Timeout wait secound */
@@ -60,8 +62,13 @@ run(void *param)
 
 
clck = *(clockid_t *)param;
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_condattr_init());
+   PTHREAD_REQUIRE(pthread_condattr_setclock(, clck));
+#else
pthread_condattr_init();
pthread_condattr_setclock(, clck); /* MONOTONIC or MONOTONIC */
+#endif
pthread_cond_init(, );
 
ATF_REQUIRE_EQ((ret = pthread_mutex_lock()), 0);

Modified: stable/11/contrib/netbsd-tests/lib/libpthread/t_fpu.c
==
--- stable/11/contrib/netbsd-tests/lib/libpthread/t_fpu.c   Fri Jan 13 
08:42:11 2017(r312036)
+++ stable/11/contrib/netbsd-tests/lib/libpthread/t_fpu.c   Fri Jan 13 
08:46:46 2017(r312037)
@@ -58,6 +58,11 @@ __RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/
 
 #include 
 
+#ifdef __FreeBSD__
+#include 
+#include 
+#endif
+
 #include "h_common.h"
 
 #define N_RECURSE 10
@@ -77,14 +82,24 @@ stir(void *p)
 
for (;;) {
x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6)));
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(sched_yield() == 0,
+   "sched_yield failed: %s", strerror(errno));
+#else
PTHREAD_REQUIRE(sched_yield());
+#endif
}
 }
 
 static double
 mul3(double x, double y, double z)
 {
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(sched_yield() == 0,
+   "sched_yield failed: %s", strerror(errno));
+#else
PTHREAD_REQUIRE(sched_yield());
+#endif
 
return x * y * z;
 }
@@ -114,7 +129,11 @@ bar(void *p)
 static void
 recurse(void) {
pthread_t s2;
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_create(, 0, bar, 0));
+#else
pthread_create(, 0, bar, 0);
+#endif
sleep(20); /* XXX must be long enough for our slowest machine */
 }
 
@@ -134,7 +153,11 @@ ATF_TC_BODY(fpu, tc)
 
PTHREAD_REQUIRE(pthread_mutex_init(_depth_lock, 0));
 
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_create(, 0, stir, stirseed));
+#else
pthread_create(, 0, stir, stirseed);
+#endif
recurse();
 
atf_tc_fail("exiting from 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: r312038 - stable/10/contrib/netbsd-tests/lib/libpthread

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:46:49 2017
New Revision: 312038
URL: https://svnweb.freebsd.org/changeset/base/312038

Log:
  MFC r311265,r311274:
  
  r311265:
  
  fpu: ensure calls to pthread_create succeed and test sched_yield to make
  sure it returns 0
  
  sched_yield tests for values returning 0 of type int and sched_yield is
  of type long, so the test is a mismatch
  
  CID:  1254953, 1254954, 1254965, 1254966
  
  r311274:
  
  run: ensure pthread_condattr_{init,setclock} is successful
  
  CID:  1268631, 1268633

Modified:
  stable/10/contrib/netbsd-tests/lib/libpthread/t_condwait.c
  stable/10/contrib/netbsd-tests/lib/libpthread/t_fpu.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/lib/libpthread/t_condwait.c
==
--- stable/10/contrib/netbsd-tests/lib/libpthread/t_condwait.c  Fri Jan 13 
08:46:46 2017(r312037)
+++ stable/10/contrib/netbsd-tests/lib/libpthread/t_condwait.c  Fri Jan 13 
08:46:49 2017(r312038)
@@ -42,6 +42,8 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 201
 
 #ifdef __FreeBSD__
 #include 
+
+#include "h_common.h"
 #endif
 
 #define WAITTIME 2 /* Timeout wait secound */
@@ -60,8 +62,13 @@ run(void *param)
 
 
clck = *(clockid_t *)param;
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_condattr_init());
+   PTHREAD_REQUIRE(pthread_condattr_setclock(, clck));
+#else
pthread_condattr_init();
pthread_condattr_setclock(, clck); /* MONOTONIC or MONOTONIC */
+#endif
pthread_cond_init(, );
 
ATF_REQUIRE_EQ((ret = pthread_mutex_lock()), 0);

Modified: stable/10/contrib/netbsd-tests/lib/libpthread/t_fpu.c
==
--- stable/10/contrib/netbsd-tests/lib/libpthread/t_fpu.c   Fri Jan 13 
08:46:46 2017(r312037)
+++ stable/10/contrib/netbsd-tests/lib/libpthread/t_fpu.c   Fri Jan 13 
08:46:49 2017(r312038)
@@ -58,6 +58,11 @@ __RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/
 
 #include 
 
+#ifdef __FreeBSD__
+#include 
+#include 
+#endif
+
 #include "h_common.h"
 
 #define N_RECURSE 10
@@ -77,14 +82,24 @@ stir(void *p)
 
for (;;) {
x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6)));
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(sched_yield() == 0,
+   "sched_yield failed: %s", strerror(errno));
+#else
PTHREAD_REQUIRE(sched_yield());
+#endif
}
 }
 
 static double
 mul3(double x, double y, double z)
 {
+#ifdef __FreeBSD__
+   ATF_REQUIRE_MSG(sched_yield() == 0,
+   "sched_yield failed: %s", strerror(errno));
+#else
PTHREAD_REQUIRE(sched_yield());
+#endif
 
return x * y * z;
 }
@@ -114,7 +129,11 @@ bar(void *p)
 static void
 recurse(void) {
pthread_t s2;
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_create(, 0, bar, 0));
+#else
pthread_create(, 0, bar, 0);
+#endif
sleep(20); /* XXX must be long enough for our slowest machine */
 }
 
@@ -134,7 +153,11 @@ ATF_TC_BODY(fpu, tc)
 
PTHREAD_REQUIRE(pthread_mutex_init(_depth_lock, 0));
 
+#ifdef __FreeBSD__
+   PTHREAD_REQUIRE(pthread_create(, 0, stir, stirseed));
+#else
pthread_create(, 0, stir, stirseed);
+#endif
recurse();
 
atf_tc_fail("exiting from 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: r312035 - stable/11/lib/libprocstat

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:42:05 2017
New Revision: 312035
URL: https://svnweb.freebsd.org/changeset/base/312035

Log:
  MFC r311715:
  
  Use nitems({mib,name}) instead of hardcoding their value

Modified:
  stable/11/lib/libprocstat/libprocstat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libprocstat/libprocstat.c
==
--- stable/11/lib/libprocstat/libprocstat.c Fri Jan 13 08:40:58 2017
(r312034)
+++ stable/11/lib/libprocstat/libprocstat.c Fri Jan 13 08:42:05 2017
(r312035)
@@ -282,7 +282,7 @@ procstat_getprocs(struct procstat *procs
name[1] = KERN_PROC;
name[2] = what;
name[3] = arg;
-   error = sysctl(name, 4, NULL, , NULL, 0);
+   error = sysctl(name, nitems(name), NULL, , NULL, 0);
if (error < 0 && errno != EPERM) {
warn("sysctl(kern.proc)");
goto fail;
@@ -299,7 +299,7 @@ procstat_getprocs(struct procstat *procs
goto fail;
}
olen = len;
-   error = sysctl(name, 4, p, , NULL, 0);
+   error = sysctl(name, nitems(name), p, , NULL, 0);
} while (error < 0 && errno == ENOMEM && olen == len);
if (error < 0 && errno != EPERM) {
warn("sysctl(kern.proc)");
@@ -1760,7 +1760,7 @@ getargv(struct procstat *procstat, struc
name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
name[3] = kp->ki_pid;
len = nchr;
-   error = sysctl(name, 4, av->buf, , NULL, 0);
+   error = sysctl(name, nitems(name), av->buf, , NULL, 0);
if (error != 0 && errno != ESRCH && errno != EPERM)
warn("sysctl(kern.proc.%s)", env ? "env" : "args");
if (error != 0 || len == 0)
@@ -1983,7 +1983,7 @@ procstat_getgroups_sysctl(pid_t pid, uns
warn("malloc(%zu)", len);
return (NULL);
}
-   if (sysctl(mib, 4, groups, , NULL, 0) == -1) {
+   if (sysctl(mib, nitems(mib), groups, , NULL, 0) == -1) {
warn("sysctl: kern.proc.groups: %d", pid);
free(groups);
return (NULL);
@@ -2059,7 +2059,7 @@ procstat_getumask_sysctl(pid_t pid, unsi
mib[2] = KERN_PROC_UMASK;
mib[3] = pid;
len = sizeof(*maskp);
-   error = sysctl(mib, 4, maskp, , NULL, 0);
+   error = sysctl(mib, nitems(mib), maskp, , NULL, 0);
if (error != 0 && errno != ESRCH && errno != EPERM)
warn("sysctl: kern.proc.umask: %d", pid);
return (error);
@@ -2139,7 +2139,7 @@ procstat_getrlimit_sysctl(pid_t pid, int
name[3] = pid;
name[4] = which;
len = sizeof(struct rlimit);
-   error = sysctl(name, 5, rlimit, , NULL, 0);
+   error = sysctl(name, nitems(name), rlimit, , NULL, 0);
if (error < 0 && errno != ESRCH) {
warn("sysctl: kern.proc.rlimit: %d", pid);
return (-1);
@@ -2201,7 +2201,7 @@ procstat_getpathname_sysctl(pid_t pid, c
name[2] = KERN_PROC_PATHNAME;
name[3] = pid;
len = maxlen;
-   error = sysctl(name, 4, pathname, , NULL, 0);
+   error = sysctl(name, nitems(name), pathname, , NULL, 0);
if (error != 0 && errno != ESRCH)
warn("sysctl: kern.proc.pathname: %d", pid);
if (len == 0)
@@ -2281,7 +2281,7 @@ procstat_getosrel_sysctl(pid_t pid, int 
name[2] = KERN_PROC_OSREL;
name[3] = pid;
len = sizeof(*osrelp);
-   error = sysctl(name, 4, osrelp, , NULL, 0);
+   error = sysctl(name, nitems(name), osrelp, , NULL, 0);
if (error != 0 && errno != ESRCH)
warn("sysctl: kern.proc.osrel: %d", pid);
return (error);
@@ -2341,7 +2341,7 @@ is_elf32_sysctl(pid_t pid)
name[2] = KERN_PROC_SV_NAME;
name[3] = pid;
len = sizeof(sv_name);
-   error = sysctl(name, 4, sv_name, , NULL, 0);
+   error = sysctl(name, nitems(name), sv_name, , NULL, 0);
if (error != 0 || len == 0)
return (0);
for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
@@ -2372,7 +2372,7 @@ procstat_getauxv32_sysctl(pid_t pid, uns
warn("malloc(%zu)", len);
goto out;
}
-   if (sysctl(name, 4, auxv32, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), auxv32, , NULL, 0) == -1) {
if (errno != ESRCH && errno != EPERM)
warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
goto out;
@@ -2421,7 +2421,7 @@ procstat_getauxv_sysctl(pid_t pid, unsig
warn("malloc(%zu)", len);
return (NULL);
}
-   if (sysctl(name, 4, auxv, 

svn commit: r312036 - stable/10/lib/libprocstat

2017-01-13 Thread Ngie Cooper
Author: ngie
Date: Fri Jan 13 08:42:11 2017
New Revision: 312036
URL: https://svnweb.freebsd.org/changeset/base/312036

Log:
  MFC r311715:
  
  Use nitems({mib,name}) instead of hardcoding their value

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

Modified: stable/10/lib/libprocstat/libprocstat.c
==
--- stable/10/lib/libprocstat/libprocstat.c Fri Jan 13 08:42:05 2017
(r312035)
+++ stable/10/lib/libprocstat/libprocstat.c Fri Jan 13 08:42:11 2017
(r312036)
@@ -282,7 +282,7 @@ procstat_getprocs(struct procstat *procs
name[1] = KERN_PROC;
name[2] = what;
name[3] = arg;
-   error = sysctl(name, 4, NULL, , NULL, 0);
+   error = sysctl(name, nitems(name), NULL, , NULL, 0);
if (error < 0 && errno != EPERM) {
warn("sysctl(kern.proc)");
goto fail;
@@ -299,7 +299,7 @@ procstat_getprocs(struct procstat *procs
goto fail;
}
olen = len;
-   error = sysctl(name, 4, p, , NULL, 0);
+   error = sysctl(name, nitems(name), p, , NULL, 0);
} while (error < 0 && errno == ENOMEM && olen == len);
if (error < 0 && errno != EPERM) {
warn("sysctl(kern.proc)");
@@ -1760,7 +1760,7 @@ getargv(struct procstat *procstat, struc
name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
name[3] = kp->ki_pid;
len = nchr;
-   error = sysctl(name, 4, av->buf, , NULL, 0);
+   error = sysctl(name, nitems(name), av->buf, , NULL, 0);
if (error != 0 && errno != ESRCH && errno != EPERM)
warn("sysctl(kern.proc.%s)", env ? "env" : "args");
if (error != 0 || len == 0)
@@ -1983,7 +1983,7 @@ procstat_getgroups_sysctl(pid_t pid, uns
warn("malloc(%zu)", len);
return (NULL);
}
-   if (sysctl(mib, 4, groups, , NULL, 0) == -1) {
+   if (sysctl(mib, nitems(mib), groups, , NULL, 0) == -1) {
warn("sysctl: kern.proc.groups: %d", pid);
free(groups);
return (NULL);
@@ -2059,7 +2059,7 @@ procstat_getumask_sysctl(pid_t pid, unsi
mib[2] = KERN_PROC_UMASK;
mib[3] = pid;
len = sizeof(*maskp);
-   error = sysctl(mib, 4, maskp, , NULL, 0);
+   error = sysctl(mib, nitems(mib), maskp, , NULL, 0);
if (error != 0 && errno != ESRCH && errno != EPERM)
warn("sysctl: kern.proc.umask: %d", pid);
return (error);
@@ -2139,7 +2139,7 @@ procstat_getrlimit_sysctl(pid_t pid, int
name[3] = pid;
name[4] = which;
len = sizeof(struct rlimit);
-   error = sysctl(name, 5, rlimit, , NULL, 0);
+   error = sysctl(name, nitems(name), rlimit, , NULL, 0);
if (error < 0 && errno != ESRCH) {
warn("sysctl: kern.proc.rlimit: %d", pid);
return (-1);
@@ -2201,7 +2201,7 @@ procstat_getpathname_sysctl(pid_t pid, c
name[2] = KERN_PROC_PATHNAME;
name[3] = pid;
len = maxlen;
-   error = sysctl(name, 4, pathname, , NULL, 0);
+   error = sysctl(name, nitems(name), pathname, , NULL, 0);
if (error != 0 && errno != ESRCH)
warn("sysctl: kern.proc.pathname: %d", pid);
if (len == 0)
@@ -2281,7 +2281,7 @@ procstat_getosrel_sysctl(pid_t pid, int 
name[2] = KERN_PROC_OSREL;
name[3] = pid;
len = sizeof(*osrelp);
-   error = sysctl(name, 4, osrelp, , NULL, 0);
+   error = sysctl(name, nitems(name), osrelp, , NULL, 0);
if (error != 0 && errno != ESRCH)
warn("sysctl: kern.proc.osrel: %d", pid);
return (error);
@@ -2341,7 +2341,7 @@ is_elf32_sysctl(pid_t pid)
name[2] = KERN_PROC_SV_NAME;
name[3] = pid;
len = sizeof(sv_name);
-   error = sysctl(name, 4, sv_name, , NULL, 0);
+   error = sysctl(name, nitems(name), sv_name, , NULL, 0);
if (error != 0 || len == 0)
return (0);
for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
@@ -2372,7 +2372,7 @@ procstat_getauxv32_sysctl(pid_t pid, uns
warn("malloc(%zu)", len);
goto out;
}
-   if (sysctl(name, 4, auxv32, , NULL, 0) == -1) {
+   if (sysctl(name, nitems(name), auxv32, , NULL, 0) == -1) {
if (errno != ESRCH && errno != EPERM)
warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
goto out;
@@ -2421,7 +2421,7 @@ procstat_getauxv_sysctl(pid_t pid, unsig
warn("malloc(%zu)", len);
return (NULL);
}
-   if (sysctl(name, 4, auxv, 

  1   2   >