svn commit: r243606 - head/sys/dev/ath

2012-11-27 Thread Adrian Chadd
Author: adrian
Date: Tue Nov 27 08:40:48 2012
New Revision: 243606
URL: http://svnweb.freebsd.org/changeset/base/243606

Log:
  Correct some debugging output.

Modified:
  head/sys/dev/ath/if_ath_tdma.c

Modified: head/sys/dev/ath/if_ath_tdma.c
==
--- head/sys/dev/ath/if_ath_tdma.c  Tue Nov 27 08:32:12 2012
(r243605)
+++ head/sys/dev/ath/if_ath_tdma.c  Tue Nov 27 08:40:48 2012
(r243606)
@@ -532,7 +532,7 @@ ath_tdma_update(struct ieee80211_node *n
DPRINTF(sc, ATH_DEBUG_TDMA_TIMER,
"%s: calling ath_hal_adjusttsf: TSF=%llu, tsfdelta=%d\n",
__func__,
-   tsf_1,
+   tsf,
tsfdelta);
 
 #ifdef ATH_DEBUG_ALQ
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Andriy Gapon
on 27/11/2012 08:07 David Xu said the following:
> Author: davidxu
> Date: Tue Nov 27 06:07:58 2012
> New Revision: 243599
> URL: http://svnweb.freebsd.org/changeset/base/243599
> 
> Log:
>   Take first active vnode correctly.
>   
>   Reviewed by:kib
>   MFC after:  3 days
> 
> Modified:
>   head/sys/kern/vfs_subr.c
> 
> Modified: head/sys/kern/vfs_subr.c
> ==
> --- head/sys/kern/vfs_subr.c  Tue Nov 27 06:01:02 2012(r243598)
> +++ head/sys/kern/vfs_subr.c  Tue Nov 27 06:07:58 2012(r243599)
> @@ -4755,7 +4755,7 @@ __mnt_vnode_first_active(struct vnode **
>   MNT_REF(mp);
>   (*mvp)->v_type = VMARKER;
>  
> - vp = TAILQ_NEXT(*mvp, v_actfreelist);
> + vp = TAILQ_FIRST(&mp->mnt_activevnodelist);
>   while (vp != NULL) {
>   VI_LOCK(vp);
>   if (vp->v_mount == mp && vp->v_type != VMARKER &&
> 

Oh, wow, did this even work before?
Did it always just return NULL and no active list iteration happened?

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


svn commit: r243607 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:11:54 2012
New Revision: 243607
URL: http://svnweb.freebsd.org/changeset/base/243607

Log:
  Style fixes (mostly whitespaces).

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 08:40:48 2012(r243606)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:11:54 2012(r243607)
@@ -128,8 +128,8 @@ struct filterops sig_filtops = {
 };
 
 static int kern_logsigexit = 1;
-SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW, 
-&kern_logsigexit, 0, 
+SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW,
+&kern_logsigexit, 0,
 "Log processes quitting on abnormal signals to syslog(3)");
 
 static int kern_forcesigexit = 1;
@@ -171,7 +171,7 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDE
(cr1)->cr_uid == (cr2)->cr_uid)
 
 static int sugid_coredump;
-SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, 
+SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW,
 &sugid_coredump, 0, "Allow setuid and setgid processes to dump core");
 
 static int do_coredump = 1;
@@ -284,9 +284,9 @@ sigqueue_init(sigqueue_t *list, struct p
 /*
  * Get a signal's ksiginfo.
  * Return:
- * 0   -   signal not found
+ * 0   -   signal not found
  * others  -   signal number
- */ 
+ */
 static int
 sigqueue_get(sigqueue_t *sq, int signo, ksiginfo_t *si)
 {
@@ -357,7 +357,7 @@ sigqueue_add(sigqueue_t *sq, int signo, 
int ret = 0;
 
KASSERT(sq->sq_flags & SQ_INIT, ("sigqueue not inited"));
-   
+
if (signo == SIGKILL || signo == SIGSTOP || si == NULL) {
SIGADDSET(sq->sq_kill, signo);
goto out_set_bit;
@@ -377,7 +377,7 @@ sigqueue_add(sigqueue_t *sq, int signo, 
SIGADDSET(sq->sq_kill, signo);
goto out_set_bit;
}
-   
+
if (p != NULL && p->p_pendingcnt >= max_pending_per_proc) {
signal_overflow++;
ret = EAGAIN;
@@ -406,7 +406,7 @@ sigqueue_add(sigqueue_t *sq, int signo, 
 
if (ret != 0)
return (ret);
-   
+
 out_set_bit:
SIGADDSET(sq->sq_signals, signo);
return (ret);
@@ -1158,7 +1158,7 @@ sys_sigwaitinfo(struct thread *td, struc
 
if (uap->info)
error = copyout(&ksi.ksi_info, uap->info, sizeof(siginfo_t));
-   
+
if (error == 0)
td->td_retval[0] = ksi.ksi_signo;
return (error);
@@ -1184,7 +1184,7 @@ kern_sigtimedwait(struct thread *td, sig
if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 10) {
timevalid = 1;
getnanouptime(&rts);
-   ets = rts;
+   ets = rts;
timespecadd(&ets, timeout);
}
}
@@ -1201,7 +1201,7 @@ kern_sigtimedwait(struct thread *td, sig
mtx_unlock(&ps->ps_mtx);
if (sig != 0 && SIGISMEMBER(waitset, sig)) {
if (sigqueue_get(&td->td_sigqueue, sig, ksi) != 0 ||
-   sigqueue_get(&p->p_sigqueue, sig, ksi) != 0) {
+   sigqueue_get(&p->p_sigqueue, sig, ksi) != 0) {
error = 0;
break;
}
@@ -1257,7 +1257,7 @@ kern_sigtimedwait(struct thread *td, sig
 
if (error == 0) {
SDT_PROBE(proc, kernel, , signal_clear, sig, ksi, 0, 0, 0);
-   
+
if (ksi->ksi_code == SI_TIMER)
itimer_accept(p, ksi->ksi_timerid, ksi);
 
@@ -1407,7 +1407,7 @@ osigsetmask(td, uap)
 
 /*
  * Suspend calling thread until signal, providing mask to be set in the
- * meantime. 
+ * meantime.
  */
 #ifndef _SYS_SYSPROTO_H_
 struct sigsuspend_args {
@@ -1643,7 +1643,7 @@ killpg1(struct thread *td, int sig, int 
}
sx_sunlock(&proctree_lock);
LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
-   PROC_LOCK(p); 
+   PROC_LOCK(p);
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM ||
p->p_state == PRS_NEW) {
PROC_UNLOCK(p);
@@ -1881,7 +1881,7 @@ trapsignal(struct thread *td, ksiginfo_t
ktrpsig(sig, ps->ps_sigact[_SIG_IDX(sig)],
&td->td_sigmask, code);
 #endif
-   (*p->p_sysent->sv_sendsig)(ps->ps_sigact[_SIG_IDX(sig)], 
+   (*p->p_sysent->sv_sendsig)(ps->ps_sigact[_SIG_IDX(sig)],
ksi, &td->td_sigmask);
mask = ps->ps_catchmask[_SIG_IDX(sig)];
if (!SIGISMEMBER(ps->ps_signodefer, sig))
@@ -1958,7 +1958,7 @@ sigtd(struct proc *p, int sig, int prop)
  * reg

svn commit: r243608 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:15:58 2012
New Revision: 243608
URL: http://svnweb.freebsd.org/changeset/base/243608

Log:
  More style fixes.

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 10:11:54 2012(r243607)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:15:58 2012(r243608)
@@ -2838,10 +2838,10 @@ killproc(p, why)
 {
 
PROC_LOCK_ASSERT(p, MA_OWNED);
-   CTR3(KTR_PROC, "killproc: proc %p (pid %d, %s)",
-   p, p->p_pid, p->p_comm);
-   log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid, 
p->p_comm,
-   p->p_ucred ? p->p_ucred->cr_uid : -1, why);
+   CTR3(KTR_PROC, "killproc: proc %p (pid %d, %s)", p, p->p_pid,
+   p->p_comm);
+   log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid,
+   p->p_comm, p->p_ucred ? p->p_ucred->cr_uid : -1, why);
p->p_flag |= P_WKILLED;
kern_psignal(p, SIGKILL);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243609 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:16:48 2012
New Revision: 243609
URL: http://svnweb.freebsd.org/changeset/base/243609

Log:
  Allow to modify kern.sugid_coredump and kern.corefile from loader.conf.
  
  Obtained from:WHEEL Systems

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 10:15:58 2012(r243608)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:16:48 2012(r243609)
@@ -171,6 +171,7 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDE
(cr1)->cr_uid == (cr2)->cr_uid)
 
 static int sugid_coredump;
+TUNABLE_INT("kern.sugid_coredump", &sugid_coredump);
 SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW,
 &sugid_coredump, 0, "Allow setuid and setgid processes to dump core");
 
@@ -3015,6 +3016,7 @@ SYSCTL_INT(_kern, OID_AUTO, compress_use
 #endif
 
 static char corefilename[MAXPATHLEN] = {"%N.core"};
+TUNABLE_STR("kern.corefile", corefilename, sizeof(corefilename));
 SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RW, corefilename,
  sizeof(corefilename), "process corefile name format string");
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243610 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:22:40 2012
New Revision: 243610
URL: http://svnweb.freebsd.org/changeset/base/243610

Log:
  Allow to use kill(2) in capability mode, but process can send a signal only
  to himself. For example abort(3) at first tries to do kill(getpid(), SIGABRT)
  which was failing in capability mode, so the code was failing back to exit(1).
  
  Reviewed by:  rwatson
  Obtained from:WHEEL Systems
  MFC after:2 weeks

Modified:
  head/sys/kern/capabilities.conf
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/capabilities.conf
==
--- head/sys/kern/capabilities.conf Tue Nov 27 10:16:48 2012
(r243609)
+++ head/sys/kern/capabilities.conf Tue Nov 27 10:22:40 2012
(r243610)
@@ -337,6 +337,11 @@ issetugid
 kevent
 
 ##
+## Allow kill(2), as we allow the process to send signals only to himself.
+##
+kill
+
+##
 ## Allow message queue operations on file descriptors, subject to capability
 ## rights.
 ##

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 10:16:48 2012(r243609)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:22:40 2012(r243610)
@@ -1679,6 +1679,14 @@ sys_kill(struct thread *td, struct kill_
struct proc *p;
int error;
 
+   /*
+* A process in capability mode can send signals only to himself.
+* The main rationale behind this is that abort(3) is implemented as
+* kill(getpid(), SIGABRT).
+*/
+   if (IN_CAPABILITY_MODE(td) && uap->pid != td->td_proc->p_pid)
+   return (ECAPMODE);
+
AUDIT_ARG_SIGNUM(uap->signum);
AUDIT_ARG_PID(uap->pid);
if ((u_int)uap->signum > _SIG_MAXSIG)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243611 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:25:03 2012
New Revision: 243611
URL: http://svnweb.freebsd.org/changeset/base/243611

Log:
  Regenerate after r243610.

Modified:
  head/sys/kern/init_sysent.c

Modified: head/sys/kern/init_sysent.c
==
--- head/sys/kern/init_sysent.c Tue Nov 27 10:22:40 2012(r243610)
+++ head/sys/kern/init_sysent.c Tue Nov 27 10:25:03 2012(r243611)
@@ -71,7 +71,7 @@ struct sysent sysent[] = {
{ AS(chflags_args), (sy_call_t *)sys_chflags, AUE_CHFLAGS, NULL, 0, 0, 
0, SY_THR_STATIC },  /* 34 = chflags */
{ AS(fchflags_args), (sy_call_t *)sys_fchflags, AUE_FCHFLAGS, NULL, 0, 
0, SYF_CAPENABLED, SY_THR_STATIC },  /* 35 = fchflags */
{ 0, (sy_call_t *)sys_sync, AUE_SYNC, NULL, 0, 0, SYF_CAPENABLED, 
SY_THR_STATIC },  /* 36 = sync */
-   { AS(kill_args), (sy_call_t *)sys_kill, AUE_KILL, NULL, 0, 0, 0, 
SY_THR_STATIC },   /* 37 = kill */
+   { AS(kill_args), (sy_call_t *)sys_kill, AUE_KILL, NULL, 0, 0, 
SYF_CAPENABLED, SY_THR_STATIC },  /* 37 = kill */
{ compat(AS(ostat_args),stat), AUE_STAT, NULL, 0, 0, 0, SY_THR_STATIC 
},/* 38 = old stat */
{ 0, (sy_call_t *)sys_getppid, AUE_GETPPID, NULL, 0, 0, SYF_CAPENABLED, 
SY_THR_STATIC },/* 39 = getppid */
{ compat(AS(olstat_args),lstat), AUE_LSTAT, NULL, 0, 0, 0, 
SY_THR_STATIC }, /* 40 = old lstat */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:32:35 2012
New Revision: 243612
URL: http://svnweb.freebsd.org/changeset/base/243612

Log:
  - Add NOCAPCHECK flag to namei that allows lookup to work even if the process
is in capability mode.
  - Add VN_OPEN_NOCAPCHECK flag for vn_open_cred() to will ne converted into
NOCAPCHECK namei flag.
  
  This functionality will be used to enable core dumps for sandboxed processes.
  
  Reviewed by:  rwatson
  Obtained from:WHEEL Systems
  MFC after:2 weeks

Modified:
  head/sys/kern/vfs_lookup.c
  head/sys/kern/vfs_vnops.c
  head/sys/sys/namei.h
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_lookup.c
==
--- head/sys/kern/vfs_lookup.c  Tue Nov 27 10:25:03 2012(r243611)
+++ head/sys/kern/vfs_lookup.c  Tue Nov 27 10:32:35 2012(r243612)
@@ -183,7 +183,7 @@ namei(struct nameidata *ndp)
 * not an absolute path, and not containing '..' components) to
 * a real file descriptor, not the pseudo-descriptor AT_FDCWD.
 */
-   if (IN_CAPABILITY_MODE(td)) {
+   if (IN_CAPABILITY_MODE(td) && (cnp->cn_flags & NOCAPCHECK) == 0) {
ndp->ni_strictrelative = 1;
if (ndp->ni_dirfd == AT_FDCWD) {
 #ifdef KTRACE

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Tue Nov 27 10:25:03 2012(r243611)
+++ head/sys/kern/vfs_vnops.c   Tue Nov 27 10:32:35 2012(r243612)
@@ -135,6 +135,8 @@ restart:
ndp->ni_cnd.cn_flags |= FOLLOW;
if (!(vn_open_flags & VN_OPEN_NOAUDIT))
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
+   if (vn_open_flags & VN_OPEN_NOCAPCHECK)
+   ndp->ni_cnd.cn_flags |= NOCAPCHECK;
bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
@@ -188,6 +190,8 @@ restart:
ndp->ni_cnd.cn_flags |= LOCKSHARED;
if (!(vn_open_flags & VN_OPEN_NOAUDIT))
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
+   if (vn_open_flags & VN_OPEN_NOCAPCHECK)
+   ndp->ni_cnd.cn_flags |= NOCAPCHECK;
if ((error = namei(ndp)) != 0)
return (error);
vp = ndp->ni_vp;

Modified: head/sys/sys/namei.h
==
--- head/sys/sys/namei.hTue Nov 27 10:25:03 2012(r243611)
+++ head/sys/sys/namei.hTue Nov 27 10:32:35 2012(r243612)
@@ -147,7 +147,8 @@ struct nameidata {
 #defineAUDITVNODE1 0x0400 /* audit the looked up vnode 
information */
 #defineAUDITVNODE2 0x0800 /* audit the looked up vnode 
information */
 #defineTRAILINGSLASH   0x1000 /* path ended in a slash */
-#definePARAMASK0x1e00 /* mask of parameter descriptors */
+#defineNOCAPCHECK  0x2000 /* do not perform capability checks 
*/
+#definePARAMASK0x3e00 /* mask of parameter descriptors */
 
 /*
  * Initialization of a nameidata structure.

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hTue Nov 27 10:25:03 2012(r243611)
+++ head/sys/sys/vnode.hTue Nov 27 10:32:35 2012(r243612)
@@ -565,6 +565,7 @@ vn_canvmio(struct vnode *vp)
 
 /* vn_open_flags */
 #defineVN_OPEN_NOAUDIT 0x0001
+#defineVN_OPEN_NOCAPCHECK  0x0002
 
 /*
  * Public vnode manipulation functions.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243613 - head/sys/kern

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 10:38:11 2012
New Revision: 243613
URL: http://svnweb.freebsd.org/changeset/base/243613

Log:
  Add kern.capmode_coredump sysctl/tunable to allow processes in capability mode
  to dump core.
  
  Reviewed by:  rwatson
  Obtained from:WHEEL Systems
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 10:32:35 2012(r243612)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:38:11 2012(r243613)
@@ -175,6 +175,11 @@ TUNABLE_INT("kern.sugid_coredump", &sugi
 SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW,
 &sugid_coredump, 0, "Allow setuid and setgid processes to dump core");
 
+static int capmode_coredump;
+TUNABLE_INT("kern.capmode_coredump", &capmode_coredump);
+SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RW,
+&capmode_coredump, 0, "Allow processes in capability mode to dump core");
+
 static int do_coredump = 1;
 SYSCTL_INT(_kern, OID_AUTO, coredump, CTLFLAG_RW,
&do_coredump, 0, "Enable/Disable coredumps");
@@ -3134,12 +3139,17 @@ nomem:
int error, n;
int flags = O_CREAT | O_EXCL | FWRITE | O_NOFOLLOW;
int cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+   int oflags = 0;
+
+   if (capmode_coredump)
+   oflags = VN_OPEN_NOCAPCHECK;
 
for (n = 0; n < num_cores; n++) {
temp[indexpos] = '0' + n;
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE,
temp, td);
-   error = vn_open(&nd, &flags, cmode, NULL);
+   error = vn_open_cred(&nd, &flags, cmode, oflags,
+   td->td_ucred, NULL);
if (error) {
if (error == EEXIST)
continue;
@@ -3241,7 +3251,8 @@ coredump(struct thread *td)
 restart:
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td);
flags = O_CREAT | FWRITE | O_NOFOLLOW;
-   error = vn_open_cred(&nd, &flags, S_IRUSR | S_IWUSR, VN_OPEN_NOAUDIT,
+   error = vn_open_cred(&nd, &flags, S_IRUSR | S_IWUSR,
+   VN_OPEN_NOAUDIT | (capmode_coredump ? VN_OPEN_NOCAPCHECK : 0),
cred, NULL);
if (error) {
 #ifdef AUDIT
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243614 - head/sys/dev/ath

2012-11-27 Thread Adrian Chadd
Author: adrian
Date: Tue Nov 27 11:30:39 2012
New Revision: 243614
URL: http://svnweb.freebsd.org/changeset/base/243614

Log:
  * Fix another culprit of my "committed from the wrong directory" nonsense;
now this works for non-debug and debug builds.
  
  * Add a comment reminding me (or someone) to audit all of the relevant
math to ensure there's no weird wrapping issues still lurking about.
  
  But yes, this does seem to be mostly working.
  
  Pointy-hat-to:adrian, yet again

Modified:
  head/sys/dev/ath/if_ath_tdma.c

Modified: head/sys/dev/ath/if_ath_tdma.c
==
--- head/sys/dev/ath/if_ath_tdma.c  Tue Nov 27 10:38:11 2012
(r243613)
+++ head/sys/dev/ath/if_ath_tdma.c  Tue Nov 27 11:30:39 2012
(r243614)
@@ -328,6 +328,16 @@ ath_tdma_config(struct ath_softc *sc, st
  * beacon timers so we follow their schedule.  Note that
  * by using the rx timestamp we implicitly include the
  * propagation delay in our schedule.
+ *
+ * XXX TODO: since the changes for the AR5416 and later chips
+ * involved changing the TSF/TU calculations, we need to make
+ * sure that various calculations wrap consistently.
+ *
+ * A lot of the problems stemmed from the calculations wrapping
+ * at 65,535 TU.  Since a lot of the math is still being done in
+ * TU, please audit it to ensure that when the TU values programmed
+ * into the timers wrap at (2^31)-1 TSF, all the various terms
+ * wrap consistently.
  */
 void
 ath_tdma_update(struct ieee80211_node *ni,
@@ -541,8 +551,8 @@ ath_tdma_update(struct ieee80211_node *n
struct if_ath_alq_tdma_tsf_adjust t;
 
t.tsfdelta = htobe32(tsfdelta);
-   t.tsf64_old = htobe64(tsf_1);
-   t.tsf64_new = htobe64(tsf_1 + tsfdelta);
+   t.tsf64_old = htobe64(tsf);
+   t.tsf64_new = htobe64(tsf + tsfdelta);
if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TDMA_TSF_ADJUST,
sizeof(t), (char *) &t);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243615 - head/sys/net

2012-11-27 Thread David Xu
Author: davidxu
Date: Tue Nov 27 12:23:57 2012
New Revision: 243615
URL: http://svnweb.freebsd.org/changeset/base/243615

Log:
  Pass allocated unit number to make_dev, otherwise kernel panics later while
  cloning second tap.
  
  Reviewed by: kevlo,ed

Modified:
  head/sys/net/if_tap.c

Modified: head/sys/net/if_tap.c
==
--- head/sys/net/if_tap.c   Tue Nov 27 11:30:39 2012(r243614)
+++ head/sys/net/if_tap.c   Tue Nov 27 12:23:57 2012(r243615)
@@ -186,7 +186,7 @@ tap_clone_create(struct if_clone *ifc, i
/* Find any existing device, or allocate new unit number. */
i = clone_create(&tapclones, &tap_cdevsw, &unit, &dev, 0);
if (i) {
-   dev = make_dev(&tap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+   dev = make_dev(&tap_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600,
"%s%d", tapname, unit);
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Attilio Rao
On Tue, Nov 27, 2012 at 6:07 AM, David Xu  wrote:
> Author: davidxu
> Date: Tue Nov 27 06:07:58 2012
> New Revision: 243599
> URL: http://svnweb.freebsd.org/changeset/base/243599
>
> Log:
>   Take first active vnode correctly.

Thanks.
I had send the exact same report to Kirk and Jeff one week ago, and I
was still waiting for responses.

Please note that vfs_msync() was completely broken because of this
change (as not happening at all).
I think that vinactive() and umount were enough to make the issue not
really visible.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread David Xu
On 2012/11/27 21:52, Attilio Rao wrote:
> On Tue, Nov 27, 2012 at 6:07 AM, David Xu  wrote:
>> Author: davidxu
>> Date: Tue Nov 27 06:07:58 2012
>> New Revision: 243599
>> URL: http://svnweb.freebsd.org/changeset/base/243599
>>
>> Log:
>>   Take first active vnode correctly.
> Thanks.
> I had send the exact same report to Kirk and Jeff one week ago, and I
> was still waiting for responses.
>
> Please note that vfs_msync() was completely broken because of this
> change (as not happening at all).
> I think that vinactive() and umount were enough to make the issue not
> really visible.

Yes, I think so, except quota data ?

> Attilio
>
>

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


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

2012-11-27 Thread Attilio Rao
On Tue, Nov 27, 2012 at 2:35 PM, David Xu  wrote:
> On 2012/11/27 21:52, Attilio Rao wrote:
>> On Tue, Nov 27, 2012 at 6:07 AM, David Xu  wrote:
>>> Author: davidxu
>>> Date: Tue Nov 27 06:07:58 2012
>>> New Revision: 243599
>>> URL: http://svnweb.freebsd.org/changeset/base/243599
>>>
>>> Log:
>>>   Take first active vnode correctly.
>> Thanks.
>> I had send the exact same report to Kirk and Jeff one week ago, and I
>> was still waiting for responses.
>>
>> Please note that vfs_msync() was completely broken because of this
>> change (as not happening at all).
>> I think that vinactive() and umount were enough to make the issue not
>> really visible.
>
> Yes, I think so, except quota data ?

Yeah, although I don't think many people use QUOTA out of
servers/production ready machines (which also usually don't run
-CURRENT) and likely only people using QUOTA on STABLE_9 machines
could have really experienced problems with this.

I think this bug fix must be absolutely included into 9.1-REL.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Konstantin Belousov
On Tue, Nov 27, 2012 at 11:59:05AM +0200, Andriy Gapon wrote:
> on 27/11/2012 08:07 David Xu said the following:
> > Author: davidxu
> > Date: Tue Nov 27 06:07:58 2012
> > New Revision: 243599
> > URL: http://svnweb.freebsd.org/changeset/base/243599
> > 
> > Log:
> >   Take first active vnode correctly.
> >   
> >   Reviewed by:  kib
> >   MFC after:3 days
> > 
> > Modified:
> >   head/sys/kern/vfs_subr.c
> > 
> > Modified: head/sys/kern/vfs_subr.c
> > ==
> > --- head/sys/kern/vfs_subr.cTue Nov 27 06:01:02 2012
> > (r243598)
> > +++ head/sys/kern/vfs_subr.cTue Nov 27 06:07:58 2012
> > (r243599)
> > @@ -4755,7 +4755,7 @@ __mnt_vnode_first_active(struct vnode **
> > MNT_REF(mp);
> > (*mvp)->v_type = VMARKER;
> >  
> > -   vp = TAILQ_NEXT(*mvp, v_actfreelist);
> > +   vp = TAILQ_FIRST(&mp->mnt_activevnodelist);
> > while (vp != NULL) {
> > VI_LOCK(vp);
> > if (vp->v_mount == mp && vp->v_type != VMARKER &&
> > 
> 
> Oh, wow, did this even work before?
> Did it always just return NULL and no active list iteration happened?

Yes. Due to some redundancy in the VFS, the consequences were much less
fatal than it could be.


pgpivysiwmpUl.pgp
Description: PGP signature


svn commit: r243617 - head/usr.bin/passwd

2012-11-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Nov 27 16:23:12 2012
New Revision: 243617
URL: http://svnweb.freebsd.org/changeset/base/243617

Log:
  Respect NO_FSCHG and don't set 'schg' flag on passwd/yppasswd is defined.
  
  MFC after:2 weeks

Modified:
  head/usr.bin/passwd/Makefile

Modified: head/usr.bin/passwd/Makefile
==
--- head/usr.bin/passwd/MakefileTue Nov 27 16:20:44 2012
(r243616)
+++ head/usr.bin/passwd/MakefileTue Nov 27 16:23:12 2012
(r243617)
@@ -19,7 +19,9 @@ beforeinstall:
chflags noschg ${DESTDIR}${BINDIR}/$i || true
 .endfor
 
+.if !defined(NO_FSCHG)
 afterinstall:
-chflags schg ${DESTDIR}${BINDIR}/passwd
+.endif
 
 .include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243621 - head/sys/netinet

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 19:07:28 2012
New Revision: 243621
URL: http://svnweb.freebsd.org/changeset/base/243621

Log:
  Add DELACK to list of timers.
  
  MFC after:1 week

Modified:
  head/sys/netinet/tcp_timer.h

Modified: head/sys/netinet/tcp_timer.h
==
--- head/sys/netinet/tcp_timer.hTue Nov 27 19:00:44 2012
(r243620)
+++ head/sys/netinet/tcp_timer.hTue Nov 27 19:07:28 2012
(r243621)
@@ -122,7 +122,7 @@
 
 #ifdef TCPTIMERS
 static const char *tcptimers[] =
-{ "REXMT", "PERSIST", "KEEP", "2MSL" };
+{ "REXMT", "PERSIST", "KEEP", "2MSL", "DELACK" };
 #endif
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243622 - head/sys/dev/iwn

2012-11-27 Thread Bernhard Schmidt
Author: bschmidt
Date: Tue Nov 27 19:09:36 2012
New Revision: 243622
URL: http://svnweb.freebsd.org/changeset/base/243622

Log:
  fix a panic resulting from a stray '&'
  
  MFC after:1 week

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==
--- head/sys/dev/iwn/if_iwn.c   Tue Nov 27 19:07:28 2012(r243621)
+++ head/sys/dev/iwn/if_iwn.c   Tue Nov 27 19:09:36 2012(r243622)
@@ -1253,7 +1253,7 @@ iwn_dma_contig_free(struct iwn_dma_info 
bus_dmamap_sync(dma->tag, dma->map,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(dma->tag, dma->map);
-   bus_dmamem_free(dma->tag, &dma->vaddr, dma->map);
+   bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
dma->vaddr = NULL;
}
bus_dmamap_destroy(dma->tag, dma->map);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243624 - in head/sys: dev/bce dev/bxe net netinet sys

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 19:31:49 2012
New Revision: 243624
URL: http://svnweb.freebsd.org/changeset/base/243624

Log:
  Remove unused and unnecessary CSUM_IP_FRAGS checksumming capability.
  Checksumming the IP header of fragments is no different from doing
  normal IP headers.
  
  Discussed with:   yongari
  MFC after:1 week

Modified:
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bxe/if_bxe.c
  head/sys/net/if_vlan.c
  head/sys/netinet/ip_output.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Tue Nov 27 19:23:54 2012(r243623)
+++ head/sys/dev/bce/if_bce.c   Tue Nov 27 19:31:49 2012(r243624)
@@ -9880,7 +9880,7 @@ bce_dump_mbuf(struct bce_softc *sc, stru
"\15M_FIRSTFRAG\16M_LASTFRAG\21M_VLANTAG"
"\22M_PROMISC\23M_NOFREE",
mp->m_pkthdr.csum_flags,
-   "\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP\4CSUM_IP_FRAGS"
+   "\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP"
"\5CSUM_FRAGMENT\6CSUM_TSO\11CSUM_IP_CHECKED"
"\12CSUM_IP_VALID\13CSUM_DATA_VALID"
"\14CSUM_PSEUDO_HDR");

Modified: head/sys/dev/bxe/if_bxe.c
==
--- head/sys/dev/bxe/if_bxe.c   Tue Nov 27 19:23:54 2012(r243623)
+++ head/sys/dev/bxe/if_bxe.c   Tue Nov 27 19:31:49 2012(r243624)
@@ -16281,7 +16281,7 @@ void bxe_dump_mbuf(struct bxe_softc *sc,
"\15M_FIRSTFRAG\16M_LASTFRAG\21M_VLANTAG"
"\22M_PROMISC\23M_NOFREE",
m->m_pkthdr.csum_flags,
-   "\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP\4CSUM_IP_FRAGS"
+   "\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP"
"\5CSUM_FRAGMENT\6CSUM_TSO\11CSUM_IP_CHECKED"
"\12CSUM_IP_VALID\13CSUM_DATA_VALID"
"\14CSUM_PSEUDO_HDR");

Modified: head/sys/net/if_vlan.c
==
--- head/sys/net/if_vlan.c  Tue Nov 27 19:23:54 2012(r243623)
+++ head/sys/net/if_vlan.c  Tue Nov 27 19:31:49 2012(r243624)
@@ -1493,7 +1493,7 @@ vlan_capabilities(struct ifvlan *ifv)
p->if_capenable & IFCAP_VLAN_HWTAGGING) {
ifp->if_capenable = p->if_capenable & IFCAP_HWCSUM;
ifp->if_hwassist = p->if_hwassist & (CSUM_IP | CSUM_TCP |
-   CSUM_UDP | CSUM_SCTP | CSUM_IP_FRAGS | CSUM_FRAGMENT);
+   CSUM_UDP | CSUM_SCTP | CSUM_FRAGMENT);
} else {
ifp->if_capenable = 0;
ifp->if_hwassist = 0;

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cTue Nov 27 19:23:54 2012
(r243623)
+++ head/sys/netinet/ip_output.cTue Nov 27 19:31:49 2012
(r243624)
@@ -722,14 +722,12 @@ ip_fragment(struct ip *ip, struct mbuf *
 * If the interface will not calculate checksums on
 * fragmented packets, then do it here.
 */
-   if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA &&
-   (if_hwassist_flags & CSUM_IP_FRAGS) == 0) {
+   if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
in_delayed_cksum(m0);
m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
}
 #ifdef SCTP
-   if (m0->m_pkthdr.csum_flags & CSUM_SCTP &&
-   (if_hwassist_flags & CSUM_IP_FRAGS) == 0) {
+   if (m0->m_pkthdr.csum_flags & CSUM_SCTP) {
sctp_delayed_cksum(m0, hlen);
m0->m_pkthdr.csum_flags &= ~CSUM_SCTP;
}

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Tue Nov 27 19:23:54 2012(r243623)
+++ head/sys/sys/mbuf.h Tue Nov 27 19:31:49 2012(r243624)
@@ -279,7 +279,6 @@ struct mbuf {
 #defineCSUM_IP 0x0001  /* will csum IP */
 #defineCSUM_TCP0x0002  /* will csum TCP */
 #defineCSUM_UDP0x0004  /* will csum UDP */
-#defineCSUM_IP_FRAGS   0x0008  /* will csum IP 
fragments */
 #defineCSUM_FRAGMENT   0x0010  /* will do IP 
fragmentation */
 #defineCSUM_TSO0x0020  /* will do TSO */
 #defineCSUM_SCTP   0x0040  /* will csum SCTP */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243627 - head/sys/kern

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 20:04:52 2012
New Revision: 243627
URL: http://svnweb.freebsd.org/changeset/base/243627

Log:
  Fix a race on listen socket teardown where while draining the
  accept queues a new socket/connection may be added to the queue
  due to a race on the ACCEPT_LOCK.
  
  The submitted patch is slightly changed in comments, teardown
  and locking order and extended with KASSERT's.
  
  Submitted by: Vijay Singh 
  Found by: His team.
  MFC after:1 week

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Nov 27 19:35:21 2012(r243626)
+++ head/sys/kern/uipc_socket.c Tue Nov 27 20:04:52 2012(r243627)
@@ -555,6 +555,16 @@ sonewconn(struct socket *head, int conns
so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
so->so_state |= connstatus;
ACCEPT_LOCK();
+   /*
+* The accept socket may be tearing down but we just
+* won a race on the ACCEPT_LOCK.
+*/
+   if (!(so->so_options & SO_ACCEPTCONN)) {
+   SOCK_LOCK(so);
+   so->so_head = NULL;
+   sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */
+   return (NULL);
+   }
if (connstatus) {
TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
so->so_qstate |= SQ_COMP;
@@ -780,9 +790,14 @@ soclose(struct socket *so)
 drop:
if (so->so_proto->pr_usrreqs->pru_close != NULL)
(*so->so_proto->pr_usrreqs->pru_close)(so);
+   ACCEPT_LOCK();
if (so->so_options & SO_ACCEPTCONN) {
struct socket *sp;
-   ACCEPT_LOCK();
+   /*
+* Prevent new additions to the accept queues due
+* to ACCEPT_LOCK races while we are draining them.
+*/
+   so->so_options &= ~SO_ACCEPTCONN;
while ((sp = TAILQ_FIRST(&so->so_incomp)) != NULL) {
TAILQ_REMOVE(&so->so_incomp, sp, so_list);
so->so_incqlen--;
@@ -801,13 +816,15 @@ drop:
soabort(sp);
ACCEPT_LOCK();
}
-   ACCEPT_UNLOCK();
+   KASSERT((TAILQ_EMPTY(&so->so_comp)),
+   ("%s: so_comp populated", __func__));
+   KASSERT((TAILQ_EMPTY(&so->so_incomp)),
+   ("%s: so_incomp populated", __func__));
}
-   ACCEPT_LOCK();
SOCK_LOCK(so);
KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
so->so_state |= SS_NOFDREF;
-   sorele(so);
+   sorele(so); /* NB: Returns with ACCEPT_UNLOCK(). */
CURVNET_RESTORE();
return (error);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243628 - head/sys/sys

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 20:16:01 2012
New Revision: 243628
URL: http://svnweb.freebsd.org/changeset/base/243628

Log:
  Update comment to prefer M_NOWAIT over M_DONTWAIT and
  M_WAITOK over M_WAIT.
  
  MFC after:1 week

Modified:
  head/sys/sys/mbuf.h

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Tue Nov 27 20:04:52 2012(r243627)
+++ head/sys/sys/mbuf.h Tue Nov 27 20:16:01 2012(r243628)
@@ -349,8 +349,8 @@ struct mbstat {
  * Flags specifying how an allocation should be made.
  *
  * The flag to use is as follows:
- * - M_DONTWAIT or M_NOWAIT from an interrupt handler to not block allocation.
- * - M_WAIT or M_WAITOK from wherever it is safe to block.
+ * - M_NOWAIT (M_DONTWAIT) from an interrupt handler to not block allocation.
+ * - M_WAITOK (M_WAIT) from wherever it is safe to block.
  *
  * M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly and
  * if we cannot allocate immediately we may return NULL, whereas
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 21:19:58 2012
New Revision: 243631
URL: http://svnweb.freebsd.org/changeset/base/243631

Log:
  Base the mbuf related limits on the available physical memory or
  kernel memory, whichever is lower.  The overall mbuf related memory
  limit must be set so that mbufs (and clusters of various sizes)
  can't exhaust physical RAM or KVM.
  
  The limit is set to half of the physical RAM or KVM (whichever is
  lower) as the baseline.  In any normal scenario we want to leave
  at least half of the physmem/kvm for other kernel functions and
  userspace to prevent it from swapping too easily.  Via a tunable
  kern.maxmbufmem the limit can be upped to at most 3/4 of physmem/kvm.
  
  At the same time divorce maxfiles from maxusers and set maxfiles to
  physpages / 8 with a floor based on maxusers.  This way busy servers
  can make use of the significantly increased mbuf limits with a much
  larger number of open sockets.
  
  Tidy up ordering in init_param2() and check up on some users of
  those values calculated here.
  
  Out of the overall mbuf memory limit 2K clusters and 4K (page size)
  clusters to get 1/4 each because these are the most heavily used mbuf
  sizes.  2K clusters are used for MTU 1500 ethernet inbound packets.
  4K clusters are used whenever possible for sends on sockets and thus
  outbound packets.  The larger cluster sizes of 9K and 16K are limited
  to 1/6 of the overall mbuf memory limit.  When jumbo MTU's are used
  these large clusters will end up only on the inbound path.  They are
  not used on outbound, there it's still 4K.  Yes, that will stay that
  way because otherwise we run into lots of complications in the
  stack.  And it really isn't a problem, so don't make a scene.
  
  Normal mbufs (256B) weren't limited at all previously.  This was
  problematic as there are certain places in the kernel that on
  allocation failure of clusters try to piece together their packet
  from smaller mbufs.
  
  The mbuf limit is the number of all other mbuf sizes together plus
  some more to allow for standalone mbufs (ACK for example) and to
  send off a copy of a cluster.  Unfortunately there isn't a way to
  set an overall limit for all mbuf memory together as UMA doesn't
  support such a limiting.
  
  NB: Every cluster also has an mbuf associated with it.
  
  Two examples on the revised mbuf sizing limits:
  
  1GB KVM:
   512MB limit for mbufs
   419,430 mbufs
65,536 2K mbuf clusters
32,768 4K mbuf clusters
 9,709 9K mbuf clusters
 5,461 16K mbuf clusters
  
  16GB RAM:
   8GB limit for mbufs
   33,554,432 mbufs
1,048,576 2K mbuf clusters
  524,288 4K mbuf clusters
  155,344 9K mbuf clusters
   87,381 16K mbuf clusters
  
  These defaults should be sufficient for even the most demanding
  network loads.
  
  MFC after:1 month

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/subr_param.c
  head/sys/kern/uipc_socket.c
  head/sys/sys/eventhandler.h
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Tue Nov 27 20:22:36 2012(r243630)
+++ head/sys/kern/kern_mbuf.c   Tue Nov 27 21:19:58 2012(r243631)
@@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$");
  *
  */
 
+int nmbufs;/* limits number of mbufs */
 int nmbclusters;   /* limits number of mbuf clusters */
 int nmbjumbop; /* limits number of page size jumbo clusters */
 int nmbjumbo9; /* limits number of 9k jumbo clusters */
@@ -147,9 +148,11 @@ sysctl_nmbclusters(SYSCTL_HANDLER_ARGS)
newnmbclusters = nmbclusters;
error = sysctl_handle_int(oidp, &newnmbclusters, 0, req); 
if (error == 0 && req->newptr) {
-   if (newnmbclusters > nmbclusters) {
+   if (newnmbclusters > nmbclusters &&
+   nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) 
{
nmbclusters = newnmbclusters;
uma_zone_set_max(zone_clust, nmbclusters);
+   nmbclusters = uma_zone_get_max(zone_clust);
EVENTHANDLER_INVOKE(nmbclusters_change);
} else
error = EINVAL;
@@ -168,9 +171,11 @@ sysctl_nmbjumbop(SYSCTL_HANDLER_ARGS)
newnmbjumbop = nmbjumbop;
error = sysctl_handle_int(oidp, &newnmbjumbop, 0, req); 
if (error == 0 && req->newptr) {
-   if (newnmbjumbop> nmbjumbop) {
+   if (newnmbjumbop > nmbjumbop &&
+   nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) 
{
nmbjumbop = newnmbjumbop;
uma_zone_set_max(zone_jumbop, nmbjumbop);
+   nmbjumbop = uma_zone_get_max(zone_jumbop);
} else
error = EINVAL;
}
@@ -189,9 +194,11 @@ sysctl_nmbjumbo9(SYSCTL_HAN

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

2012-11-27 Thread Bruce Evans

On Tue, 27 Nov 2012, Pawel Jakub Dawidek wrote:


Log:
 Add kern.capmode_coredump sysctl/tunable to allow processes in capability mode
 to dump core.


You missed fixing some style bugs before touching this.


Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cTue Nov 27 10:32:35 2012(r243612)
+++ head/sys/kern/kern_sig.cTue Nov 27 10:38:11 2012(r243613)
@@ -175,6 +175,11 @@ TUNABLE_INT("kern.sugid_coredump", &sugi
SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW,
&sugid_coredump, 0, "Allow setuid and setgid processes to dump core");


Normal indentation.  Abnormal description of a flag.



+static int capmode_coredump;
+TUNABLE_INT("kern.capmode_coredump", &capmode_coredump);
+SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RW,
+&capmode_coredump, 0, "Allow processes in capability mode to dump core");
+


Normal indentation.  Abnormal description of a flag.


static int  do_coredump = 1;
SYSCTL_INT(_kern, OID_AUTO, coredump, CTLFLAG_RW,
&do_coredump, 0, "Enable/Disable coredumps");


Abnormal indentation.  Normal description of a flag as Enable/Disable (but
better if it leaves out "Disable").  I'm not sure if the new flag is
sufficiently different to deserve an "Allow" in it.

The first one certainly doesn't.  It is just another flag that gates
the main one; when it is set, set*id processes aren't "Allowed" to
dump core, but are forced to.  It used to be described more or less
correctly as "Enable coredumping set user/group ID processes", but
this has been broken.  The description was verbose and had bad grammar.
Now it is verbose and has correct grammar, but is not obviously just
a flag.  My version doesn't fix this, but fixes the indentation and
the order of the declarations (the basic do_coredump flag should be
first, since it is first alphabetically, historically (?) and
logically).

The 2 newer flag also have a namespace error (they don't have a do_
prefix like the others).  Among other bugs, this makes it sort
incorrectly with the others.  My version adds a do_ prefix to
the second-newest one.

Suggested rewordings for the old descriptions, and other style fixes
(indentation, namespace):

&do_coredump, 0, "Enable core dumps");

Statistics: on freefall now, sysctl -nda | grep -i ... shows 115 lines
matching "enable", 38 matching "disable", and only 11 matching both;
zgrep -ir on /usr/share/man shows 338 lines matching "core dump" and
168 matching "coredump", with most of the compressed spellings being
for proper names like the coredumpsize rlimit and the wait flag
WCOREDUMP.

&do_sugid_coredump, 0, "Enable core dumps for set*id processes");

Now I don't like the "Enable" wording either.  This flag is in addition
to the other one, and neither "Enable" nor "Allow" fully describes the
logic.  A full verbose description is "Enable core dumps for set*id
processes (if core dumps are not disabled for all processes)".


@@ -3134,12 +3139,17 @@ nomem:
int error, n;
int flags = O_CREAT | O_EXCL | FWRITE | O_NOFOLLOW;
int cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;


Old style bugs:

- nested declarations
- unsorted declarations
- int variables not all in 1 declaration
- initialization in declarations.


+   int oflags = 0;
+
+   if (capmode_coredump)
+   oflags = VN_OPEN_NOCAPCHECK;


New style bugs:
- extend the previous bugs.  Half of the initialization of oflags is in
  its declaration and half in 2 new lines.
- extra blank line
- other verboseness.  The initialization of oflags can be written more
  concisely and clearly as

  oflags = capmode_coredump ? VN_OPEN_NOCAPCHECK : 0;

  This could be squeezed into its declaration line, but shouldn't be.
  Unless you make it slighly clearer by declaring oflags as const --
  then its initialization must be in its declaration.  This often
  applies for variables that hold translations of flags from one set
  to another.  But I wouldn't go that far.

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


svn commit: r243634 - head/usr.sbin/bsdconfig/networking/share

2012-11-27 Thread Devin Teske
Author: dteske
Date: Tue Nov 27 22:05:01 2012
New Revision: 243634
URL: http://svnweb.freebsd.org/changeset/base/243634

Log:
  Comments.
  
  Approved by:  adrian (co-mentor) (implicit)

Modified:
  head/usr.sbin/bsdconfig/networking/share/ipaddr.subr

Modified: head/usr.sbin/bsdconfig/networking/share/ipaddr.subr
==
--- head/usr.sbin/bsdconfig/networking/share/ipaddr.subrTue Nov 27 
21:45:42 2012(r243633)
+++ head/usr.sbin/bsdconfig/networking/share/ipaddr.subrTue Nov 27 
22:05:01 2012(r243634)
@@ -107,7 +107,7 @@ f_validate_ipaddr()
 # f_dialog_iperror $error $ipaddr
 #
 # Display a msgbox with the appropriate error message for an error returned by
-# f_validate_ipaddr above.
+# the f_validate_ipaddr function above.
 #
 f_dialog_iperror()
 {
@@ -285,7 +285,7 @@ f_validate_ipaddr6()
 # f_dialog_ip6error $error $ipv6_addr
 #
 # Display a msgbox with the appropriate error message for an error returned by
-# f_validate_ipaddr6 above.
+# the f_validate_ipaddr6 function above.
 #
 f_dialog_ip6error()
 {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243635 - head/usr.sbin/bsdconfig/share

2012-11-27 Thread Devin Teske
Author: dteske
Date: Tue Nov 27 22:11:53 2012
New Revision: 243635
URL: http://svnweb.freebsd.org/changeset/base/243635

Log:
  Change self-initialization to occur when loaded versus the previous behavior
  which was to self-initialize during the first function-call. This didn't work
  so well because the first call was may or may-not be within a sub-shell
  (which prevented proper setup of the pass-thru file descriptor, resulting in
  dialogs that would not display).
  
  Approved by:  adrian (co-mentor) (implicit)

Modified:
  head/usr.sbin/bsdconfig/share/dialog.subr

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==
--- head/usr.sbin/bsdconfig/share/dialog.subr   Tue Nov 27 22:05:01 2012
(r243634)
+++ head/usr.sbin/bsdconfig/share/dialog.subr   Tue Nov 27 22:11:53 2012
(r243635)
@@ -72,8 +72,7 @@ unset XDIALOG_FORCE_AUTOSIZE
 unset XDIALOG_INFOBOX_TIMEOUT
 
 #
-# Default behavior is to call f_dialog_init() automatically if not already
-# called manually by the time the first f_dialog_*() function is used.
+# Default behavior is to call f_dialog_init() automatically when loaded.
 #
 : ${DIALOG_SELF_INITIALIZE=1}
 
@@ -185,8 +184,6 @@ f_dialog_backtitle_restore()
 #
 f_dialog_infobox_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
local min_width max_size
 
@@ -308,8 +305,6 @@ f_dialog_infobox_size()
 #
 f_dialog_buttonbox_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4"
local size="$( f_dialog_infobox_size \
"$title" "$btitle" "$prompt" "$hline" )"
@@ -355,8 +350,6 @@ f_dialog_buttonbox_size()
 #
 f_dialog_inputbox_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" init="$4" hline="$5" n
local size="$( f_dialog_buttonbox_size \
"$title" "$btitle" "$prompt" "$hline" )"
@@ -422,8 +415,6 @@ f_dialog_inputbox_size()
 #
 f_xdialog_2inputsbox_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3"
local label1="$4" init1="$5" label2="$6" init2="$7" n
local size="$( f_dialog_inputbox_size \
@@ -519,8 +510,6 @@ f_xdialog_2inputsbox_size()
 #
 f_dialog_menu_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
local min_width min_rows max_size
 
@@ -603,8 +592,6 @@ f_dialog_menu_size()
 #
 f_dialog_menu_with_help_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
local min_width min_rows max_size
 
@@ -704,8 +691,6 @@ f_dialog_menu_with_help_size()
 #
 f_dialog_radiolist_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
local min_width min_rows max_size
 
@@ -788,8 +773,6 @@ f_dialog_radiolist_size()
 #
 f_dialog_calendar_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n
local size="$( f_dialog_infobox_size \
"$title" "$btitle" "$prompt" "$hline" )"
@@ -869,8 +852,6 @@ f_dialog_calendar_size()
 #
 f_dialog_timebox_size()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local title="$1" btitle="$2" prompt="$3" hline="$4" n
local size="$( f_dialog_infobox_size \
"$title" "$btitle" "$prompt" "$hline" )"
@@ -934,8 +915,6 @@ f_dialog_timebox_size()
 #
 f_dialog_clear()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
$DIALOG --clear
 }
 
@@ -948,8 +927,6 @@ f_dialog_clear()
 #
 f_dialog_info()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local info_text="$*"
local size="$( f_dialog_infobox_size \
"$DIALOG_TITLE" \
@@ -972,8 +949,6 @@ f_dialog_info()
 #
 f_xdialog_info()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local info_text="$*"
local size="$( f_dialog_infobox_size \
"$DIALOG_TITLE" \
@@ -1000,8 +975,6 @@ f_xdialog_info()
 #
 f_dialog_msgbox()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local msg_text="$*"
local size="$( f_dialog_buttonbox_size \
"$DIALOG_TITLE" \
@@ -1028,8 +1001,6 @@ f_dialog_msgbox()
 #
 f_dialog_textbox()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local file="$1"
local contents retval size
 
@@ -1070,8 +1041,6 @@ f_dialog_textbox()
 #
 f_dialog_yesno()
 {
-   [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
-
local msg_tex

Re: svn commit: r243594 - head/sys/netinet

2012-11-27 Thread Andre Oppermann

On 27.11.2012 04:04, Alfred Perlstein wrote:

Author: alfred
Date: Tue Nov 27 03:04:24 2012
New Revision: 243594
URL: http://svnweb.freebsd.org/changeset/base/243594

Log:
   Auto size the tcbhashsize structure based on max sockets.

   While here, also make the code that enforces power-of-two more
   forgiving, instead of just resetting to 512, graciously round-down
   to the next lower power of two.


The porthash (also a parameter to in_pcbinfo_init()) should not be
scaled the same as tcbhashsize.  It's unlikely that anyone is going
to have more than a thousand listen ports.

The default tcbhashsize scaling factor of maxsockets / 4 is IMHO
excessive.  If someone is running at the limit he's going to up
maxsockets to double the target load.  Dividing by 8 is a better
balance for normal and well used large memory machines.
The hashsize calculation logic is done a bit in a roundabout way.

What do think of the attached patch to fix the porthash and to simplify
the hashsize logic?

--
Andre

Index: netinet/tcp_subr.c
===
--- netinet/tcp_subr.c  (revision 243631)
+++ netinet/tcp_subr.c  (working copy)
@@ -229,14 +229,17 @@
void *ip4hdr, const void *ip6hdr);

 /*
- * Target size of TCP PCB hash tables. Must be a power of two.
+ * Minimal size of TCP PCB hash tables. Must be a power of two.
  *
  * Note that this can be overridden by the kernel environment
  * variable net.inet.tcp.tcbhashsize
  */
-#ifndef TCBHASHSIZE
-#define TCBHASHSIZE0
+#ifndef TCBMINHASHSIZE
+#define TCBMINHASHSIZE 512
 #endif
+#ifndef TCBPORTHASHSIZE
+#define TCBPORTHASHSIZE512
+#endif

 /*
  * XXX
@@ -282,35 +285,10 @@
return (0);
 }

-/*
- * Take a value and get the next power of 2 that doesn't overflow.
- * Used to size the tcp_inpcb hash buckets.
- */
-static int
-maketcp_hashsize(int size)
-{
-   int hashsize;
-
-   /*
-* auto tune.
-* get the next power of 2 higher than maxsockets.
-*/
-   hashsize = 1 << fls(size);
-   /* catch overflow, and just go one power of 2 smaller */
-   if (hashsize < size) {
-   hashsize = 1 << (fls(size) - 1);
-   }
-   return (hashsize);
-}
-
 void
 tcp_init(void)
 {
-   const char *tcbhash_tuneable;
-   int hashsize;

-   tcbhash_tuneable = "net.inet.tcp.tcbhashsize";
-
if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN,
&V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0)
printf("%s: WARNING: unable to register helper hook\n", 
__func__);
@@ -318,49 +296,17 @@
&V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 
0)
printf("%s: WARNING: unable to register helper hook\n", 
__func__);

-   hashsize = TCBHASHSIZE;
-   TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize);
-   if (hashsize == 0) {
-   /*
-* Auto tune the hash size based on maxsockets.
-* A perfect hash would have a 1:1 mapping
-* (hashsize = maxsockets) however it's been
-* suggested that O(2) average is better.
-*/
-   hashsize = maketcp_hashsize(maxsockets / 4);
-   /*
-* Our historical default is 512,
-* do not autotune lower than this.
-*/
-   if (hashsize < 512)
-   hashsize = 512;
-   if (bootverbose)
-   printf("%s: %s auto tuned to %d\n", __func__,
-   tcbhash_tuneable, hashsize);
+   tcp_tcbhashsize = 0x1 << fls((maxsockets / 8) - 1);
+   TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &tcp_tcbhashsize);
+   if (!powerof2(tcp_tcbhashsize) ||
+   tcp_tcbhashsize < TCBMINHASHSIZE) {
+   printf("WARNING: TCB hash size not a power of 2 or too 
small\n");
+   tcp_tcbhashsize = TCBMINHASHSIZE;
}
-   /*
-* We require a hashsize to be a power of two.
-* Previously if it was not a power of two we would just reset it
-* back to 512, which could be a nasty surprise if you did not notice
-* the error message.
-* Instead what we do is clip it to the closest power of two lower
-* than the specified hash value.
-*/
-   if (!powerof2(hashsize)) {
-   int oldhashsize = hashsize;
+   in_pcbinfo_init(&V_tcbinfo, "tcp", &V_tcb, tcp_tcbhashsize,
+   TCBPORTHASHSIZE, "tcp_inpcb", tcp_inpcb_init, NULL,
+   UMA_ZONE_NOFREE, IPI_HASHFIELDS_4TUPLE);

-   hashsize = maketcp_hashsize(hashsize);
-   /* prevent absurdly low value */
-   if (hashsize < 16)
-   hashsize = 16;
-   printf("%s: WARNING: TCB hash size not a power of 2, "
-   "clipped from %d to %d.\n", __func__, oldhashsize,
- 

svn commit: r243636 - head/usr.sbin/bsdconfig/share

2012-11-27 Thread Devin Teske
Author: dteske
Date: Tue Nov 27 22:14:22 2012
New Revision: 243636
URL: http://svnweb.freebsd.org/changeset/base/243636

Log:
  Allow setting of NULL titles with f_dialog_[back]title().
  
  Approved by:  adrian (co-mentor) (implicit)

Modified:
  head/usr.sbin/bsdconfig/share/dialog.subr

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==
--- head/usr.sbin/bsdconfig/share/dialog.subr   Tue Nov 27 22:11:53 2012
(r243635)
+++ head/usr.sbin/bsdconfig/share/dialog.subr   Tue Nov 27 22:14:22 2012
(r243636)
@@ -92,7 +92,7 @@ f_dialog_title()
 {
local new_title="$1"
 
-   if [ "$new_title" ]; then
+   if [ "${1+set}" ]; then
if [ "$USE_XDIALOG" ]; then
_DIALOG_BACKTITLE="$DIALOG_BACKTITLE"
DIALOG_BACKTITLE="$new_title"
@@ -133,7 +133,7 @@ f_dialog_backtitle()
 {
local new_backtitle="$1"
 
-   if [ "$new_backtitle" ]; then
+   if [ "${1+set}" ]; then
if [ "$USE_XDIALOG" ]; then
_DIALOG_TITLE="$DIALOG_TITLE"
DIALOG_TITLE="$new_backtitle"
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Tue Nov 27 22:34:46 2012
New Revision: 243637
URL: http://svnweb.freebsd.org/changeset/base/243637

Log:
  Autoconfigure nfsd threads based on ncpu.
  
  Rick Macklem and I discussed the default number of nfsd threads and
  concluded that it is too low to perform adiquitely on today's hardware.
  
  We decided to auto tune the number of nfsds based on the number of cpus
  in the system.
  
  While I'm here I've also added:
  
  1) ability to set the minthreads/maxthreads from userland.
  2) ability to run nfsd in debug mode via the cli.
  
  Reviewed by: rmacklem
  MFC after: 2 weeks

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

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Tue Nov 27 22:14:22 2012(r243636)
+++ head/usr.sbin/nfsd/nfsd.c   Tue Nov 27 22:34:46 2012(r243637)
@@ -53,6 +53,7 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -71,14 +72,11 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#include 
+
+#include 
 
-/* Global defs */
-#ifdef DEBUG
-#definesyslog(e, s...) fprintf(stderr,s)
-static int debug = 1;
-#else
 static int debug = 0;
-#endif
 
 #defineNFSD_STABLERESTART  "/var/db/nfs-stablerestart"
 #defineNFSD_STABLEBACKUP   "/var/db/nfs-stablerestart.bak"
@@ -86,11 +84,26 @@ static int  debug = 0;
 #defineDEFNFSDCNT   4
 static pid_t children[MAXNFSDCNT]; /* PIDs of children */
 static int nfsdcnt;/* number of children */
+static int nfsdcnt_set;
+static int minthreads;
+static int maxthreads;
 static int new_syscall;
 static int run_v4server = 1;   /* Force running of nfsv4 server */
 static int nfssvc_nfsd;/* Set to correct NFSSVC_xxx flag */
 static int stablefd = -1;  /* Fd for the stable restart file */
 static int backupfd;   /* Fd for the backup stable restart file */
+static const char *getopt_shortopts;
+static const char *getopt_usage;
+
+static int minthreads_set;
+static int maxthreads_set;
+
+static struct option longopts[] = {
+   { "debug", no_argument, &debug, 1 },
+   { "minthreads", required_argument, &minthreads_set, 1 },
+   { "maxthreads", required_argument, &maxthreads_set, 1 },
+   { NULL, 0, NULL, 0}
+};
 
 void   cleanup(int);
 void   child_cleanup(int);
@@ -145,26 +158,28 @@ main(int argc, char **argv)
int udpflag, ecode, error, s, srvcnt;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int nfssvc_addsock;
+   int longindex = 0;
+   const char *lopt;
char **bindhost = NULL;
pid_t pid;
 
nfsdcnt = DEFNFSDCNT;
unregister = reregister = tcpflag = maxsock = 0;
bindanyflag = udpflag = connect_type_cnt = bindhostc = 0;
-#defineGETOPT  "ah:n:rdtueo"
-#defineUSAGE   "[-ardtueo] [-n num_servers] [-h bindip]"
-   while ((ch = getopt(argc, argv, GETOPT)) != -1)
+   getopt_shortopts = "ah:n:rdtueo";
+   getopt_usage =
+   "usage:\n"
+   "  nfsd [-ardtueo] [-h bindip]\n"
+   "   [-n numservers] [--minthreads #] [--maxthreads #]\n";
+   while ((ch = getopt_long(argc, argv, getopt_shortopts, longopts,
+   &longindex)) != -1)
switch (ch) {
case 'a':
bindanyflag = 1;
break;
case 'n':
+   nfsdcnt_set = 1;
nfsdcnt = atoi(optarg);
-   if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
-   warnx("nfsd count %d; reset to %d", nfsdcnt,
-   DEFNFSDCNT);
-   nfsdcnt = DEFNFSDCNT;
-   }
break;
case 'h':
bindhostc++;
@@ -193,6 +208,14 @@ main(int argc, char **argv)
case 'o':
run_v4server = 0;
break;
+   case 0:
+   lopt = longopts[longindex].name;
+   if (!strcmp(lopt, "minthreads")) {
+   minthreads = atoi(optarg);
+   } else if (!strcmp(lopt, "maxthreads")) {
+   maxthreads = atoi(optarg);
+   }
+   break;
default:
case '?':
usage();
@@ -209,6 +232,7 @@ main(int argc, char **argv)
if (argc > 1)
usage();
if (argc == 1) {
+   nfsdcnt_set = 1;
nfsdcnt = atoi(argv[0]);
if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
warnx("nfsd count %d; reset to %d", nfsdcnt,
@@ -356,7 +380,7 @@ main(int argc, char **argv)
(void)signal(SIGCHLD, reapchild);
   

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

2012-11-27 Thread Peter Wemm
Andre.. this breaks incoming connections.  TCP is immediately reset
and never even gets to the listener process.  You need to back out of
fix this urgently please.

On Tue, Nov 27, 2012 at 12:04 PM, Andre Oppermann  wrote:
> Author: andre
> Date: Tue Nov 27 20:04:52 2012
> New Revision: 243627
> URL: http://svnweb.freebsd.org/changeset/base/243627
>
> Log:
>   Fix a race on listen socket teardown where while draining the
>   accept queues a new socket/connection may be added to the queue
>   due to a race on the ACCEPT_LOCK.
>
>   The submitted patch is slightly changed in comments, teardown
>   and locking order and extended with KASSERT's.
>
>   Submitted by: Vijay Singh 
>   Found by: His team.
>   MFC after:1 week
>
> Modified:
>   head/sys/kern/uipc_socket.c
>
> Modified: head/sys/kern/uipc_socket.c
> ==
> --- head/sys/kern/uipc_socket.c Tue Nov 27 19:35:21 2012(r243626)
> +++ head/sys/kern/uipc_socket.c Tue Nov 27 20:04:52 2012(r243627)
> @@ -555,6 +555,16 @@ sonewconn(struct socket *head, int conns
> so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
> so->so_state |= connstatus;
> ACCEPT_LOCK();
> +   /*
> +* The accept socket may be tearing down but we just
> +* won a race on the ACCEPT_LOCK.
> +*/
> +   if (!(so->so_options & SO_ACCEPTCONN)) {
> +   SOCK_LOCK(so);
> +   so->so_head = NULL;
> +   sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */
> +   return (NULL);
> +   }
> if (connstatus) {
> TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
> so->so_qstate |= SQ_COMP;
> @@ -780,9 +790,14 @@ soclose(struct socket *so)
>  drop:
> if (so->so_proto->pr_usrreqs->pru_close != NULL)
> (*so->so_proto->pr_usrreqs->pru_close)(so);
> +   ACCEPT_LOCK();
> if (so->so_options & SO_ACCEPTCONN) {
> struct socket *sp;
> -   ACCEPT_LOCK();
> +   /*
> +* Prevent new additions to the accept queues due
> +* to ACCEPT_LOCK races while we are draining them.
> +*/
> +   so->so_options &= ~SO_ACCEPTCONN;
> while ((sp = TAILQ_FIRST(&so->so_incomp)) != NULL) {
> TAILQ_REMOVE(&so->so_incomp, sp, so_list);
> so->so_incqlen--;
> @@ -801,13 +816,15 @@ drop:
> soabort(sp);
> ACCEPT_LOCK();
> }
> -   ACCEPT_UNLOCK();
> +   KASSERT((TAILQ_EMPTY(&so->so_comp)),
> +   ("%s: so_comp populated", __func__));
> +   KASSERT((TAILQ_EMPTY(&so->so_incomp)),
> +   ("%s: so_incomp populated", __func__));
> }
> -   ACCEPT_LOCK();
> SOCK_LOCK(so);
> KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
> so->so_state |= SS_NOFDREF;
> -   sorele(so);
> +   sorele(so); /* NB: Returns with ACCEPT_UNLOCK(). 
> */
> CURVNET_RESTORE();
> return (error);
>  }



-- 
Peter Wemm - pe...@wemm.org; pe...@freebsd.org; pe...@yahoo-inc.com; KI6FJV
"All of this is for nothing if we don't go to the stars" - JMS/B5
"If Java had true garbage collection, most programs would delete
themselves upon execution." -- Robert Sewell
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243638 - head/sys/kern

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 22:35:48 2012
New Revision: 243638
URL: http://svnweb.freebsd.org/changeset/base/243638

Log:
  Fix r243627 by testing against the head socket instead of the socket
  just created.
  
  MFC after:1 week
  X-MFC-with:   r243627

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Nov 27 22:34:46 2012(r243637)
+++ head/sys/kern/uipc_socket.c Tue Nov 27 22:35:48 2012(r243638)
@@ -556,7 +556,7 @@ sonewconn(struct socket *head, int conns
 * The accept socket may be tearing down but we just
 * won a race on the ACCEPT_LOCK.
 */
-   if (!(so->so_options & SO_ACCEPTCONN)) {
+   if (!(head->so_options & SO_ACCEPTCONN)) {
SOCK_LOCK(so);
so->so_head = NULL;
sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Andre Oppermann

On 27.11.2012 23:35, Peter Wemm wrote:

Andre.. this breaks incoming connections.  TCP is immediately reset
and never even gets to the listener process.  You need to back out of
fix this urgently please.


I just found out and fixed it.  Sorry for the breakage.

--
Andre


On Tue, Nov 27, 2012 at 12:04 PM, Andre Oppermann  wrote:

Author: andre
Date: Tue Nov 27 20:04:52 2012
New Revision: 243627
URL: http://svnweb.freebsd.org/changeset/base/243627

Log:
   Fix a race on listen socket teardown where while draining the
   accept queues a new socket/connection may be added to the queue
   due to a race on the ACCEPT_LOCK.

   The submitted patch is slightly changed in comments, teardown
   and locking order and extended with KASSERT's.

   Submitted by: Vijay Singh 
   Found by: His team.
   MFC after:1 week

Modified:
   head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Nov 27 19:35:21 2012(r243626)
+++ head/sys/kern/uipc_socket.c Tue Nov 27 20:04:52 2012(r243627)
@@ -555,6 +555,16 @@ sonewconn(struct socket *head, int conns
 so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
 so->so_state |= connstatus;
 ACCEPT_LOCK();
+   /*
+* The accept socket may be tearing down but we just
+* won a race on the ACCEPT_LOCK.
+*/
+   if (!(so->so_options & SO_ACCEPTCONN)) {
+   SOCK_LOCK(so);
+   so->so_head = NULL;
+   sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */
+   return (NULL);
+   }
 if (connstatus) {
 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
 so->so_qstate |= SQ_COMP;
@@ -780,9 +790,14 @@ soclose(struct socket *so)
  drop:
 if (so->so_proto->pr_usrreqs->pru_close != NULL)
 (*so->so_proto->pr_usrreqs->pru_close)(so);
+   ACCEPT_LOCK();
 if (so->so_options & SO_ACCEPTCONN) {
 struct socket *sp;
-   ACCEPT_LOCK();
+   /*
+* Prevent new additions to the accept queues due
+* to ACCEPT_LOCK races while we are draining them.
+*/
+   so->so_options &= ~SO_ACCEPTCONN;
 while ((sp = TAILQ_FIRST(&so->so_incomp)) != NULL) {
 TAILQ_REMOVE(&so->so_incomp, sp, so_list);
 so->so_incqlen--;
@@ -801,13 +816,15 @@ drop:
 soabort(sp);
 ACCEPT_LOCK();
 }
-   ACCEPT_UNLOCK();
+   KASSERT((TAILQ_EMPTY(&so->so_comp)),
+   ("%s: so_comp populated", __func__));
+   KASSERT((TAILQ_EMPTY(&so->so_incomp)),
+   ("%s: so_incomp populated", __func__));
 }
-   ACCEPT_LOCK();
 SOCK_LOCK(so);
 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
 so->so_state |= SS_NOFDREF;
-   sorele(so);
+   sorele(so); /* NB: Returns with ACCEPT_UNLOCK(). */
 CURVNET_RESTORE();
 return (error);
  }






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


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

2012-11-27 Thread Robert Watson


On Tue, 27 Nov 2012, Andre Oppermann wrote:


On 27.11.2012 23:35, Peter Wemm wrote:
Andre.. this breaks incoming connections.  TCP is immediately reset and 
never even gets to the listener process.  You need to back out of fix this 
urgently please.


I just found out and fixed it.  Sorry for the breakage.


I'd like to see a much more thorough use of "Reviewed by:" in socket and 
TCP-related commits -- this is very sensitive code, and a second pair of eyes 
is always valuable.  Post-commit review is not a substitute.  Looking back 
over similar changes in the socket code over the last two years, I see that 
almost all have reviewers, so I think it would be reasonable to consider it 
mandatory for these subsystems at this point.  The good news is that we have 
lots of people with expertise in it.


Robert



--
Andre

On Tue, Nov 27, 2012 at 12:04 PM, Andre Oppermann  
wrote:

Author: andre
Date: Tue Nov 27 20:04:52 2012
New Revision: 243627
URL: http://svnweb.freebsd.org/changeset/base/243627

Log:
   Fix a race on listen socket teardown where while draining the
   accept queues a new socket/connection may be added to the queue
   due to a race on the ACCEPT_LOCK.

   The submitted patch is slightly changed in comments, teardown
   and locking order and extended with KASSERT's.

   Submitted by: Vijay Singh 
   Found by: His team.
   MFC after:1 week

Modified:
   head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Nov 27 19:35:21 2012(r243626)
+++ head/sys/kern/uipc_socket.c Tue Nov 27 20:04:52 2012(r243627)
@@ -555,6 +555,16 @@ sonewconn(struct socket *head, int conns
 so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
 so->so_state |= connstatus;
 ACCEPT_LOCK();
+   /*
+* The accept socket may be tearing down but we just
+* won a race on the ACCEPT_LOCK.
+*/
+   if (!(so->so_options & SO_ACCEPTCONN)) {
+   SOCK_LOCK(so);
+   so->so_head = NULL;
+   sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. 
*/

+   return (NULL);
+   }
 if (connstatus) {
 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
 so->so_qstate |= SQ_COMP;
@@ -780,9 +790,14 @@ soclose(struct socket *so)
  drop:
 if (so->so_proto->pr_usrreqs->pru_close != NULL)
 (*so->so_proto->pr_usrreqs->pru_close)(so);
+   ACCEPT_LOCK();
 if (so->so_options & SO_ACCEPTCONN) {
 struct socket *sp;
-   ACCEPT_LOCK();
+   /*
+* Prevent new additions to the accept queues due
+* to ACCEPT_LOCK races while we are draining them.
+*/
+   so->so_options &= ~SO_ACCEPTCONN;
 while ((sp = TAILQ_FIRST(&so->so_incomp)) != NULL) {
 TAILQ_REMOVE(&so->so_incomp, sp, so_list);
 so->so_incqlen--;
@@ -801,13 +816,15 @@ drop:
 soabort(sp);
 ACCEPT_LOCK();
 }
-   ACCEPT_UNLOCK();
+   KASSERT((TAILQ_EMPTY(&so->so_comp)),
+   ("%s: so_comp populated", __func__));
+   KASSERT((TAILQ_EMPTY(&so->so_incomp)),
+   ("%s: so_incomp populated", __func__));
 }
-   ACCEPT_LOCK();
 SOCK_LOCK(so);
 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
 so->so_state |= SS_NOFDREF;
-   sorele(so);
+   sorele(so); /* NB: Returns with 
ACCEPT_UNLOCK(). */

 CURVNET_RESTORE();
 return (error);
  }








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


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

2012-11-27 Thread Andre Oppermann

On 27.11.2012 23:48, Robert Watson wrote:


On Tue, 27 Nov 2012, Andre Oppermann wrote:


On 27.11.2012 23:35, Peter Wemm wrote:

Andre.. this breaks incoming connections.  TCP is immediately reset and never 
even gets to the
listener process.  You need to back out of fix this urgently please.


I just found out and fixed it.  Sorry for the breakage.


I'd like to see a much more thorough use of "Reviewed by:" in socket and 
TCP-related commits -- this
is very sensitive code, and a second pair of eyes is always valuable.  
Post-commit review is not a
substitute.  Looking back over similar changes in the socket code over the last 
two years, I see
that almost all have reviewers, so I think it would be reasonable to consider 
it mandatory for these
subsystems at this point.  The good news is that we have lots of people with 
expertise in it.


Good to see you becoming more active again. :-)  And yes,
you have a point there.

--
Andre

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


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

2012-11-27 Thread Robert N. M. Watson

On 27 Nov 2012, at 22:54, Andre Oppermann wrote:

 Andre.. this breaks incoming connections.  TCP is immediately reset and 
 never even gets to the
 listener process.  You need to back out of fix this urgently please.
>>> 
>>> I just found out and fixed it.  Sorry for the breakage.
>> 
>> I'd like to see a much more thorough use of "Reviewed by:" in socket and 
>> TCP-related commits -- this
>> is very sensitive code, and a second pair of eyes is always valuable.  
>> Post-commit review is not a
>> substitute.  Looking back over similar changes in the socket code over the 
>> last two years, I see
>> that almost all have reviewers, so I think it would be reasonable to 
>> consider it mandatory for these
>> subsystems at this point.  The good news is that we have lots of people with 
>> expertise in it.
> 
> Good to see you becoming more active again. :-)  And yes,
> you have a point there.

Yes -- this is only about three weeks old, however; for the prior six-twelve 
months, I've been fairly non-existent in FreeBSD-land due to outside 
obligations :-).

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


svn commit: r243639 - head/sys/kern

2012-11-27 Thread Andre Oppermann
Author: andre
Date: Tue Nov 27 23:16:56 2012
New Revision: 243639
URL: http://svnweb.freebsd.org/changeset/base/243639

Log:
  Complete r243631 by applying the remainder of kern_mbuf.c that got
  lost while merging into the commit tree.
  
  MFC after:1 month
  X-MFC-with:   r243631

Modified:
  head/sys/kern/kern_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Tue Nov 27 22:35:48 2012(r243638)
+++ head/sys/kern/kern_mbuf.c   Tue Nov 27 23:16:56 2012(r243639)
@@ -107,36 +107,38 @@ struct mbstat mbstat;
  * tunable_mbinit() has to be run before init_maxsockets() thus
  * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets()
  * runs at SI_ORDER_ANY.
+ *
+ * NB: This has to be done before VM init.
  */
 static void
 tunable_mbinit(void *dummy)
 {
 
-   /* This has to be done before VM init. */
TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters);
-   if (nmbclusters == 0) {
-#ifdef VM_AUTOTUNE_NMBCLUSTERS
-   nmbclusters = VM_AUTOTUNE_NMBCLUSTERS;
-#else
-   nmbclusters = 1024 + maxusers * 64;
-#endif
-#ifdef VM_MAX_AUTOTUNE_NMBCLUSTERS
-   if (nmbclusters > VM_MAX_AUTOTUNE_NMBCLUSTERS)
-   nmbclusters = VM_MAX_AUTOTUNE_NMBCLUSTERS;
-#endif
-   }
+   if (nmbclusters == 0)
+   nmbclusters = maxmbufmem / MCLBYTES / 4;
 
TUNABLE_INT_FETCH("kern.ipc.nmbjumbop", &nmbjumbop);
if (nmbjumbop == 0)
-   nmbjumbop = nmbclusters / 2;
+   nmbjumbop = maxmbufmem / MJUMPAGESIZE / 4;
 
TUNABLE_INT_FETCH("kern.ipc.nmbjumbo9", &nmbjumbo9);
if (nmbjumbo9 == 0)
-   nmbjumbo9 = nmbclusters / 4;
+   nmbjumbo9 = maxmbufmem / MJUM9BYTES / 6;
 
TUNABLE_INT_FETCH("kern.ipc.nmbjumbo16", &nmbjumbo16);
if (nmbjumbo16 == 0)
-   nmbjumbo16 = nmbclusters / 8;
+   nmbjumbo16 = maxmbufmem / MJUM16BYTES / 6;
+
+   /*
+* We need at least as many mbufs as we have clusters of
+* the various types added together.
+*/
+   TUNABLE_INT_FETCH("kern.ipc.nmbufs", &nmbufs);
+   if (nmbufs < nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16)
+   nmbufs = lmax(maxmbufmem / MSIZE / 5,
+ nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16);
+
 }
 SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, 
NULL);
 
@@ -241,7 +243,7 @@ sysctl_nmbufs(SYSCTL_HANDLER_ARGS)
if (newnmbufs > nmbufs) {
nmbufs = newnmbufs;
uma_zone_set_max(zone_mbuf, nmbufs);
-   nmbclusters = uma_zone_get_max(zone_mbuf);
+   nmbufs = uma_zone_get_max(zone_mbuf);
EVENTHANDLER_INVOKE(nmbufs_change);
} else
error = EINVAL;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Andre Oppermann

On 28.11.2012 00:16, Andre Oppermann wrote:

Author: andre
Date: Tue Nov 27 23:16:56 2012
New Revision: 243639
URL: http://svnweb.freebsd.org/changeset/base/243639

Log:
   Complete r243631 by applying the remainder of kern_mbuf.c that got
   lost while merging into the commit tree.


Please note that this didn't have any serious negative effects.

--
Andre

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


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

2012-11-27 Thread Andre Oppermann

On 28.11.2012 00:05, Robert N. M. Watson wrote:


On 27 Nov 2012, at 22:54, Andre Oppermann wrote:


Andre.. this breaks incoming connections.  TCP is immediately reset and never 
even gets to the
listener process.  You need to back out of fix this urgently please.


I just found out and fixed it.  Sorry for the breakage.


I'd like to see a much more thorough use of "Reviewed by:" in socket and 
TCP-related commits -- this
is very sensitive code, and a second pair of eyes is always valuable.  
Post-commit review is not a
substitute.  Looking back over similar changes in the socket code over the last 
two years, I see
that almost all have reviewers, so I think it would be reasonable to consider 
it mandatory for these
subsystems at this point.  The good news is that we have lots of people with 
expertise in it.


Good to see you becoming more active again. :-)  And yes,
you have a point there.


Yes -- this is only about three weeks old, however; for the prior six-twelve 
months, I've been fairly non-existent in FreeBSD-land due to outside 
obligations :-).


Just saw that I did indeed send you a review request three weeks ago. ;-)
At the end of a rather long email though.

--
Andre

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


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

2012-11-27 Thread Robert N. M. Watson

On 27 Nov 2012, at 23:29, Andre Oppermann wrote:

>> Andre.. this breaks incoming connections.  TCP is immediately reset and 
>> never even gets to the
>> listener process.  You need to back out of fix this urgently please.
> 
> I just found out and fixed it.  Sorry for the breakage.
 
 I'd like to see a much more thorough use of "Reviewed by:" in socket and 
 TCP-related commits -- this
 is very sensitive code, and a second pair of eyes is always valuable.  
 Post-commit review is not a
 substitute.  Looking back over similar changes in the socket code over the 
 last two years, I see
 that almost all have reviewers, so I think it would be reasonable to 
 consider it mandatory for these
 subsystems at this point.  The good news is that we have lots of people 
 with expertise in it.
>>> 
>>> Good to see you becoming more active again. :-)  And yes,
>>> you have a point there.
>> 
>> Yes -- this is only about three weeks old, however; for the prior six-twelve 
>> months, I've been fairly non-existent in FreeBSD-land due to outside 
>> obligations :-).
> 
> Just saw that I did indeed send you a review request three weeks ago. ;-)
> At the end of a rather long email though.

Yes, indeed -- no patch was attached, and it followed quite a long e-mail on 
your plans to rewrite the TCP stack. I'm afraid that went onto the "read this 
later as time permits" pile as I was at a conference, rather than the fast-path 
"oh, quickly review this patch" pile. However, simply committing the patch 
rather than trying a bit harder to find a reviewer isn't the right answer 
either. To maximise the likelihood of a review, construct an e-mail with a 
subject line like "Review request: (patch description)", attach the patch, and 
include a proposed commit message.

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


svn commit: r243641 - head/sys/fs/ext2fs

2012-11-27 Thread Pedro F. Giffuni
Author: pfg
Date: Wed Nov 28 00:36:40 2012
New Revision: 243641
URL: http://svnweb.freebsd.org/changeset/base/243641

Log:
  Partially bring r242520 to ext2fs.
  
  When a file is first being written, the dynamic block reallocation
  (implemented by ext2_reallocblks) relocates the file's blocks
  so as to cluster them together into a contiguous set of blocks on
  the disk.
  
  When the cluster crosses the boundary into the first indirect block,
  the first indirect block is initially allocated in a position
  immediately following the last direct block.  Block reallocation
  would usually destroy locality by moving the indirect block out of
  the way to keep the data blocks contiguous.
  
  The issue was diagnosed long ago by Bruce Evans on ffs and surfaced
  on ext2fs when block reallocaton was ported. This is only a partial
  solution based on the similarities with FFS. We still require more
  review of the allocation details that vary in ext2fs.
  
  Reported by:  bde
  MFC after:1 week

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==
--- head/sys/fs/ext2fs/ext2_alloc.c Wed Nov 28 00:02:17 2012
(r243640)
+++ head/sys/fs/ext2fs/ext2_alloc.c Wed Nov 28 00:36:40 2012
(r243641)
@@ -197,6 +197,18 @@ ext2_reallocblks(ap)
panic("ext2_reallocblks: non-cluster");
 #endif
/*
+* If the cluster crosses the boundary for the first indirect
+* block, leave space for the indirect block. Indirect blocks
+* are initially laid out in a position after the last direct
+* block. Block reallocation would usually destroy locality by
+* moving the indirect block out of the way to make room for
+* data blocks if we didn't compensate here. We should also do
+* this for other indirect block boundaries, but it is only
+* important for the first one.
+*/
+   if (start_lbn < NDADDR && end_lbn >= NDADDR)
+   return (ENOSPC);
+   /*
 * If the latest allocation is in a new cylinder group, assume that
 * the filesystem has decided to move and do not force it back to
 * the previous cylinder group.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243642 - head/sys/dev/ath

2012-11-27 Thread Adrian Chadd
Author: adrian
Date: Wed Nov 28 01:55:22 2012
New Revision: 243642
URL: http://svnweb.freebsd.org/changeset/base/243642

Log:
  Pull out the debugging code from the critical path and make sure it
  happens _after_ all of the time delta calculations.

Modified:
  head/sys/dev/ath/if_ath_tdma.c

Modified: head/sys/dev/ath/if_ath_tdma.c
==
--- head/sys/dev/ath/if_ath_tdma.c  Wed Nov 28 00:36:40 2012
(r243641)
+++ head/sys/dev/ath/if_ath_tdma.c  Wed Nov 28 01:55:22 2012
(r243642)
@@ -402,28 +402,6 @@ ath_tdma_update(struct ieee80211_node *n
 * not just 0..65535 TU.
 */
nextslottu = TSF_TO_TU(nextslot>>32, nextslot);
-   DPRINTF(sc, ATH_DEBUG_TDMA_TIMER,
-   "rs->rstamp %llu rstamp %llu tsf %llu txtime %d, nextslot %llu, 
nextslottu %d, nextslottume %d\n",
-   (unsigned long long) rs->rs_tstamp, rstamp, tsf, txtime, nextslot, 
nextslottu, TSF_TO_TU(nextslot >> 32, nextslot));
-   DPRINTF(sc, ATH_DEBUG_TDMA,
-   "  beacon tstamp: %llu (0x%016llx)\n",
-   le64toh(ni->ni_tstamp.tsf),
-   le64toh(ni->ni_tstamp.tsf));
-
-#ifdef ATH_DEBUG_ALQ
-   if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_TDMA_BEACON_STATE)) {
-   struct if_ath_alq_tdma_beacon_state t;
-   t.rx_tsf = htobe64(rstamp);
-   t.beacon_tsf = htobe64(le64toh(ni->ni_tstamp.tsf));
-   t.tsf64 = htobe64(tsf);
-   t.nextslot_tsf = htobe64(nextslot);
-   t.nextslot_tu = htobe32(nextslottu);
-   t.txtime = htobe32(txtime);
-   if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TDMA_BEACON_STATE,
-   sizeof(t), (char *) &t);
-   }
-#endif
-
/*
 * Retrieve the hardware NextTBTT in usecs
 * and calculate the difference between what the
@@ -459,27 +437,22 @@ ath_tdma_update(struct ieee80211_node *n
tsfdelta = (int32_t)((nextslot % TU_TO_TSF(HAL_BEACON_PERIOD + 1)) - 
nexttbtt);
 
DPRINTF(sc, ATH_DEBUG_TDMA_TIMER,
+   "rs->rstamp %llu rstamp %llu tsf %llu txtime %d, nextslot %llu, "
+   "nextslottu %d, nextslottume %d\n",
+   (unsigned long long) rs->rs_tstamp, rstamp, tsf, txtime,
+   nextslot, nextslottu, TSF_TO_TU(nextslot >> 32, nextslot));
+   DPRINTF(sc, ATH_DEBUG_TDMA,
+   "  beacon tstamp: %llu (0x%016llx)\n",
+   le64toh(ni->ni_tstamp.tsf),
+   le64toh(ni->ni_tstamp.tsf));
+
+   DPRINTF(sc, ATH_DEBUG_TDMA_TIMER,
"nexttbtt %llu (0x%08llx) tsfdelta %d avg +%d/-%d\n",
nexttbtt,
(long long) nexttbtt,
tsfdelta,
TDMA_AVG(sc->sc_avgtsfdeltap), TDMA_AVG(sc->sc_avgtsfdeltam));
 
-#ifdef ATH_DEBUG_ALQ
-   if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_TDMA_SLOT_CALC)) {
-   struct if_ath_alq_tdma_slot_calc t;
-
-   t.nexttbtt = htobe64(nexttbtt_full);
-   t.next_slot = htobe64(nextslot);
-   t.tsfdelta = htobe32(tsfdelta);
-   t.avg_plus = htobe32(TDMA_AVG(sc->sc_avgtsfdeltap));
-   t.avg_minus = htobe32(TDMA_AVG(sc->sc_avgtsfdeltam));
-
-   if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TDMA_SLOT_CALC,
-   sizeof(t), (char *) &t);
-   }
-#endif
-
if (tsfdelta < 0) {
TDMA_SAMPLE(sc->sc_avgtsfdeltap, 0);
TDMA_SAMPLE(sc->sc_avgtsfdeltam, -tsfdelta);
@@ -496,6 +469,33 @@ ath_tdma_update(struct ieee80211_node *n
}
tudelta = nextslottu - TSF_TO_TU(nexttbtt_full >> 32, nexttbtt_full);
 
+#ifdef ATH_DEBUG_ALQ
+   if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_TDMA_BEACON_STATE)) {
+   struct if_ath_alq_tdma_beacon_state t;
+   t.rx_tsf = htobe64(rstamp);
+   t.beacon_tsf = htobe64(le64toh(ni->ni_tstamp.tsf));
+   t.tsf64 = htobe64(tsf);
+   t.nextslot_tsf = htobe64(nextslot);
+   t.nextslot_tu = htobe32(nextslottu);
+   t.txtime = htobe32(txtime);
+   if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TDMA_BEACON_STATE,
+   sizeof(t), (char *) &t);
+   }
+
+   if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_TDMA_SLOT_CALC)) {
+   struct if_ath_alq_tdma_slot_calc t;
+
+   t.nexttbtt = htobe64(nexttbtt_full);
+   t.next_slot = htobe64(nextslot);
+   t.tsfdelta = htobe32(tsfdelta);
+   t.avg_plus = htobe32(TDMA_AVG(sc->sc_avgtsfdeltap));
+   t.avg_minus = htobe32(TDMA_AVG(sc->sc_avgtsfdeltam));
+
+   if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TDMA_SLOT_CALC,
+   sizeof(t), (char *) &t);
+   }
+#endif
+
/*
 * Copy sender's timetstamp into tdma ie so they can
 * calculate roundtrip time.  We submit a beacon frame
___
svn-s

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

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Wed Nov 28 02:23:59 2012
New Revision: 243644
URL: http://svnweb.freebsd.org/changeset/base/243644

Log:
  Fix typo.
  
  Pointed out by: marck

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

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:03:53 2012(r243643)
+++ head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:23:59 2012(r243644)
@@ -431,7 +431,7 @@ main(int argc, char **argv)
nfsdcnt = DEFNFSDCNT;
}
if (nfsdcnt > MAXNFSDCNT) {
-   warnx("nfsd counta too high %d; reset to %d", nfsdcnt,
+   warnx("nfsd count too high %d; reset to %d", nfsdcnt,
DEFNFSDCNT);
nfsdcnt = MAXNFSDCNT;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2012-11-27 Thread Alfred Perlstein
Author: alfred
Date: Wed Nov 28 02:47:31 2012
New Revision: 243645
URL: http://svnweb.freebsd.org/changeset/base/243645

Log:
  Don't allow minthreads > maxthreads.
  
  Suggested by: rmacklem

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

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:23:59 2012(r243644)
+++ head/usr.sbin/nfsd/nfsd.c   Wed Nov 28 02:47:31 2012(r243645)
@@ -224,6 +224,10 @@ main(int argc, char **argv)
udpflag = 1;
argv += optind;
argc -= optind;
+   if (minthreads_set && maxthreads_set && minthreads > maxthreads)
+   errx(EX_USAGE,
+   "error: minthreads(%d) can't be greater than "
+   "maxthreads(%d)", minthreads, maxthreads);
 
/*
 * XXX
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r243594 - head/sys/netinet

2012-11-27 Thread Alfred Perlstein

On 11/27/12 2:12 PM, Andre Oppermann wrote:

On 27.11.2012 04:04, Alfred Perlstein wrote:

Author: alfred
Date: Tue Nov 27 03:04:24 2012
New Revision: 243594
URL: http://svnweb.freebsd.org/changeset/base/243594

Log:
   Auto size the tcbhashsize structure based on max sockets.

   While here, also make the code that enforces power-of-two more
   forgiving, instead of just resetting to 512, graciously round-down
   to the next lower power of two.


The porthash (also a parameter to in_pcbinfo_init()) should not be
scaled the same as tcbhashsize.  It's unlikely that anyone is going
to have more than a thousand listen ports.

The default tcbhashsize scaling factor of maxsockets / 4 is IMHO
excessive.  If someone is running at the limit he's going to up
maxsockets to double the target load.  Dividing by 8 is a better
balance for normal and well used large memory machines.
The hashsize calculation logic is done a bit in a roundabout way.

What do think of the attached patch to fix the porthash and to simplify
the hashsize logic?


I like the porthash fix.

However your change:
1) removes explanation of what the code is doing. (comments/clarity)
2) removes the more forgiving code that rounds-down the tcp_tcbhashsize.

Can you please maintain the comments (probably keeping the logic of 
maketcp_hashsize() in a separate function).


Can you please maintain the more forgiving code for dealing with 
non-power of 2 tunable?  I like this, it makes it easier for admins and 
less error prone.


-   if (!powerof2(hashsize)) {
-   int oldhashsize = hashsize;

-   hashsize = maketcp_hashsize(hashsize);
-   /* prevent absurdly low value */
-   if (hashsize < 16)
-   hashsize = 16;
-   printf("%s: WARNING: TCB hash size not a power of 2, "
-   "clipped from %d to %d.\n", __func__, oldhashsize,
-   hashsize);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243647 - head/sys/dev/ath

2012-11-27 Thread Adrian Chadd
Author: adrian
Date: Wed Nov 28 06:55:34 2012
New Revision: 243647
URL: http://svnweb.freebsd.org/changeset/base/243647

Log:
  Until I figure out what to do here, remind myself that this needs some
  rate control 'adjustment' when NOACK is set.

Modified:
  head/sys/dev/ath/if_ath_tx.c

Modified: head/sys/dev/ath/if_ath_tx.c
==
--- head/sys/dev/ath/if_ath_tx.cWed Nov 28 03:04:38 2012
(r243646)
+++ head/sys/dev/ath/if_ath_tx.cWed Nov 28 06:55:34 2012
(r243647)
@@ -522,6 +522,16 @@ ath_tx_set_ratectrl(struct ath_softc *sc
if (! bf->bf_state.bfs_ismrr)
rc[1].tries = rc[2].tries = rc[3].tries = 0;
 
+#if 0
+   /*
+* If NOACK is set, just set ntries=1.
+*/
+   else if (bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) {
+   rc[1].tries = rc[2].tries = rc[3].tries = 0;
+   rc[0].tries = 1;
+   }
+#endif
+
/*
 * Always call - that way a retried descriptor will
 * have the MRR fields overwritten.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r243648 - head/sys/dev/ath

2012-11-27 Thread Adrian Chadd
Author: adrian
Date: Wed Nov 28 07:12:08 2012
New Revision: 243648
URL: http://svnweb.freebsd.org/changeset/base/243648

Log:
  Call if_free() with the correct vnet context if and only if ifp_vnet
  isn't NULL.
  
  If the attach fails prematurely and there's no if_vnet context, calling
  CURVNET_SET(ifp->if_vnet) is going to dereference a NULL pointer.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Wed Nov 28 06:55:34 2012(r243647)
+++ head/sys/dev/ath/if_ath.c   Wed Nov 28 07:12:08 2012(r243648)
@@ -918,11 +918,16 @@ bad2:
 bad:
if (ah)
ath_hal_detach(ah);
-   if (ifp != NULL) {
+
+   /*
+* To work around scoping issues with CURVNET_SET/CURVNET_RESTORE..
+*/
+   if (ifp != NULL && ifp->if_vnet) {
CURVNET_SET(ifp->if_vnet);
if_free(ifp);
CURVNET_RESTORE();
-   }
+   } else if (ifp != NULL)
+   if_free(ifp);
sc->sc_invalid = 1;
return error;
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"