Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2004 13:19:09 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 52868 for review
Message-ID:  <200405162019.i4GKJ94o002194@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52868

Change 52868 by peter@peter_overcee on 2004/05/16 13:18:39

	IFC @52867

Affected files ...

.. //depot/projects/hammer/share/man/man4/ng_ether.4#3 integrate
.. //depot/projects/hammer/sys/alpha/alpha/elf_machdep.c#12 integrate
.. //depot/projects/hammer/sys/amd64/amd64/elf_machdep.c#24 integrate
.. //depot/projects/hammer/sys/arm/arm/elf_machdep.c#2 integrate
.. //depot/projects/hammer/sys/conf/files.amd64#44 integrate
.. //depot/projects/hammer/sys/conf/kmod.mk#26 integrate
.. //depot/projects/hammer/sys/i386/i386/elf_machdep.c#12 integrate
.. //depot/projects/hammer/sys/ia64/ia64/elf_machdep.c#14 integrate
.. //depot/projects/hammer/sys/kern/link_elf.c#17 integrate
.. //depot/projects/hammer/sys/netgraph/ng_ether.c#9 integrate
.. //depot/projects/hammer/sys/powerpc/powerpc/elf_machdep.c#11 integrate
.. //depot/projects/hammer/sys/sparc64/sparc64/elf_machdep.c#12 integrate
.. //depot/projects/hammer/sys/sys/linker.h#12 integrate
.. //depot/projects/hammer/usr.sbin/acpi/acpidump/acpi_user.c#6 integrate
.. //depot/projects/hammer/usr.sbin/cron/cron/cron.8#2 integrate
.. //depot/projects/hammer/usr.sbin/cron/cron/cron.c#2 integrate
.. //depot/projects/hammer/usr.sbin/cron/cron/cron.h#2 integrate
.. //depot/projects/hammer/usr.sbin/cron/cron/do_command.c#3 integrate

Differences ...

==== //depot/projects/hammer/share/man/man4/ng_ether.4#3 (text+ko) ====

@@ -32,7 +32,7 @@
 .\"
 .\" Author: Archie Cobbs <archie@FreeBSD.org>
 .\"
-.\" $FreeBSD: src/share/man/man4/ng_ether.4,v 1.20 2004/04/21 19:47:33 ru Exp $
+.\" $FreeBSD: src/share/man/man4/ng_ether.4,v 1.21 2004/05/16 19:31:35 archie Exp $
 .\"
 .Dd April 21, 2004
 .Dt NG_ETHER 4
@@ -97,12 +97,12 @@
 hook is equivalent to
 .Va lower ,
 except that only unrecognized packets (that would otherwise be discarded)
-are written to the hook, and normal incoming traffic is unaffected.
-At most one of
+are written to the hook, while other normal incoming traffic is unaffected.
+Unrecognized packets written to
+.Va upper
+will be forwarded back out to
 .Va orphans
-and
-.Va lower
-may be connected at any time.
+if connected.
 .Pp
 In all cases, frames are raw Ethernet frames with the standard
 14 byte Ethernet header (but no checksum).

==== //depot/projects/hammer/sys/alpha/alpha/elf_machdep.c#12 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/alpha/elf_machdep.c,v 1.17 2003/12/23 02:42:38 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/alpha/elf_machdep.c,v 1.18 2004/05/16 20:00:27 peter Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

==== //depot/projects/hammer/sys/amd64/amd64/elf_machdep.c#24 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/elf_machdep.c,v 1.19 2003/12/23 02:42:37 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/elf_machdep.c,v 1.20 2004/05/16 20:00:27 peter Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

==== //depot/projects/hammer/sys/arm/arm/elf_machdep.c#2 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/arm/elf_machdep.c,v 1.1 2004/05/14 11:46:42 cognet Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/arm/elf_machdep.c,v 1.2 2004/05/16 20:00:27 peter Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -104,9 +104,9 @@
 
 /* Process one elf relocation with addend. */
 static int
-elf_reloc_internal(linker_file_t lf, const void *data, int type, int local)
+elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
+    int type, int local, elf_lookup_fn lookup)
 {
-	Elf_Addr relocbase = (Elf_Addr) lf->address;
 	Elf_Addr *where;
 	Elf_Addr addr;
 	Elf_Addr addend;
@@ -148,7 +148,7 @@
 			break;
 
 		case R_ARM_PC24:	/* S + A - P */
-			addr = elf_lookup(lf, symidx, 1);
+			addr = lookup(lf, symidx, 1);
 			if (addr == 0)
 				return -1;
 			addr += addend - (Elf_Addr)where;
@@ -166,7 +166,7 @@
 			break;
 
 		case R_ARM_GLOB_DAT:	/* S */
-			addr = elf_lookup(lf, symidx, 1);
+			addr = lookup(lf, symidx, 1);
 			if (addr == 0)
 				return -1;
 			if (*where != addr)
@@ -185,17 +185,19 @@
 }
 
 int
-elf_reloc(linker_file_t lf, const void *data, int type)
+elf_reloc(linker_file_t lf, Elf_Addr relocbase, const void *data, int type,
+    elf_lookup_fn lookup)
 {
 
-	return (elf_reloc_internal(lf, data, type, 0));
+	return (elf_reloc_internal(lf, relocbase, data, type, 0, lookup));
 }
 
 int
-elf_reloc_local(linker_file_t lf, const void *data, int type)
+elf_reloc_local(linker_file_t lf, Elf_Addr relocbase, const void *data,
+    int type, elf_lookup_fn lookup)
 {
 
-	return (elf_reloc_internal(lf, data, type, 1));
+	return (elf_reloc_internal(lf, relocbase, data, type, 1, lookup));
 }
 
 int

==== //depot/projects/hammer/sys/conf/files.amd64#44 (text+ko) ====

@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: src/sys/conf/files.amd64,v 1.31 2004/04/23 14:41:23 tjr Exp $
+# $FreeBSD: src/sys/conf/files.amd64,v 1.32 2004/05/16 20:11:38 peter Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and

==== //depot/projects/hammer/sys/conf/kmod.mk#26 (text+ko) ====

@@ -1,5 +1,5 @@
 #	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
-# $FreeBSD: src/sys/conf/kmod.mk,v 1.156 2004/03/14 01:29:05 trhodes Exp $
+# $FreeBSD: src/sys/conf/kmod.mk,v 1.157 2004/05/16 20:11:38 peter Exp $
 #
 # The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
 # drivers (KLD's).
@@ -170,7 +170,7 @@
 	xargs -J% ${OBJCOPY} % ${.TARGET}
 .endif
 .endif
-.if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} != amd64
+.if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} == amd64
 	${OBJCOPY} --strip-debug ${.TARGET}
 .endif
 

==== //depot/projects/hammer/sys/i386/i386/elf_machdep.c#12 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/elf_machdep.c,v 1.18 2003/12/23 02:42:39 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/elf_machdep.c,v 1.19 2004/05/16 20:00:27 peter Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

==== //depot/projects/hammer/sys/ia64/ia64/elf_machdep.c#14 (text+ko) ====

@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/ia64/ia64/elf_machdep.c,v 1.16 2003/12/23 02:42:39 peter Exp $
+ * $FreeBSD: src/sys/ia64/ia64/elf_machdep.c,v 1.17 2004/05/16 20:00:27 peter Exp $
  */
 
 #include <sys/param.h>

==== //depot/projects/hammer/sys/kern/link_elf.c#17 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.76 2003/08/11 07:14:07 bms Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.77 2004/05/16 20:00:28 peter Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mac.h"
@@ -929,7 +929,8 @@
     if (rel) {
 	rellim = (const Elf_Rel *)((const char *)ef->rel + ef->relsize);
 	while (rel < rellim) {
-	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, elf_lookup)) {
+	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL,
+			  elf_lookup)) {
 		symname = symbol_name(ef, rel->r_info);
 		printf("link_elf: symbol %s undefined\n", symname);
 		return ENOENT;
@@ -943,7 +944,8 @@
     if (rela) {
 	relalim = (const Elf_Rela *)((const char *)ef->rela + ef->relasize);
 	while (rela < relalim) {
-	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, elf_lookup)) {
+	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA,
+			  elf_lookup)) {
 		symname = symbol_name(ef, rela->r_info);
 		printf("link_elf: symbol %s undefined\n", symname);
 		return ENOENT;
@@ -957,7 +959,8 @@
     if (rel) {
 	rellim = (const Elf_Rel *)((const char *)ef->pltrel + ef->pltrelsize);
 	while (rel < rellim) {
-	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, elf_lookup)) {
+	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL,
+			  elf_lookup)) {
 		symname = symbol_name(ef, rel->r_info);
 		printf("link_elf: symbol %s undefined\n", symname);
 		return ENOENT;
@@ -971,7 +974,8 @@
     if (rela) {
 	relalim = (const Elf_Rela *)((const char *)ef->pltrela + ef->pltrelasize);
 	while (rela < relalim) {
-	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, elf_lookup)) {
+	    if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA,
+			  elf_lookup)) {
 		symname = symbol_name(ef, rela->r_info);
 		printf("link_elf: symbol %s undefined\n", symname);
 		return ENOENT;
@@ -1298,7 +1302,8 @@
     if ((rel = ef->rel) != NULL) {
 	rellim = (const Elf_Rel *)((const char *)ef->rel + ef->relsize);
 	while (rel < rellim) {
-	    elf_reloc_local(lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, elf_lookup);
+	    elf_reloc_local(lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL,
+			    elf_lookup);
 	    rel++;
 	}
     }
@@ -1307,7 +1312,8 @@
     if ((rela = ef->rela) != NULL) {
 	relalim = (const Elf_Rela *)((const char *)ef->rela + ef->relasize);
 	while (rela < relalim) {
-	    elf_reloc_local(lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, elf_lookup);
+	    elf_reloc_local(lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA,
+			    elf_lookup);
 	    rela++;
 	}
     }

==== //depot/projects/hammer/sys/netgraph/ng_ether.c#9 (text+ko) ====

@@ -37,7 +37,7 @@
  * Authors: Archie Cobbs <archie@freebsd.org>
  *	    Julian Elischer <julian@freebsd.org>
  *
- * $FreeBSD: src/sys/netgraph/ng_ether.c,v 1.33 2004/04/18 01:15:32 luigi Exp $
+ * $FreeBSD: src/sys/netgraph/ng_ether.c,v 1.34 2004/05/16 19:31:35 archie Exp $
  */
 
 /*
@@ -70,8 +70,8 @@
 struct private {
 	struct ifnet	*ifp;		/* associated interface */
 	hook_p		upper;		/* upper hook connection */
-	hook_p		lower;		/* lower OR orphan hook connection */
-	u_char		lowerOrphan;	/* whether lower is lower or orphan */
+	hook_p		lower;		/* lower hook connection */
+	hook_p		orphan;		/* orphan hook connection */
 	u_char		autoSrcAddr;	/* always overwrite source address */
 	u_char		promisc;	/* promiscuous mode enabled */
 	u_long		hwassist;	/* hardware checksum capabilities */
@@ -94,7 +94,6 @@
 static void	ng_ether_detach(struct ifnet *ifp); 
 
 /* Other functions */
-static void	ng_ether_input2(node_p node, struct mbuf **mp);
 static int	ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta);
 static int	ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta);
 
@@ -201,11 +200,12 @@
 {
 	const node_p node = IFP2NG(ifp);
 	const priv_p priv = NG_NODE_PRIVATE(node);
+	int error;
 
 	/* If "lower" hook not connected, let packet continue */
-	if (priv->lower == NULL || priv->lowerOrphan)
+	if (priv->lower == NULL)
 		return;
-	ng_ether_input2(node, mp);
+	NG_SEND_DATA_ONLY(error, priv->lower, *mp);	/* sets *mp = NULL */
 }
 
 /*
@@ -219,33 +219,14 @@
 {
 	const node_p node = IFP2NG(ifp);
 	const priv_p priv = NG_NODE_PRIVATE(node);
+	int error;
 
-	/* If "orphan" hook not connected, let packet continue */
-	if (priv->lower == NULL || !priv->lowerOrphan) {
+	/* If "orphan" hook not connected, discard packet */
+	if (priv->orphan == NULL) {
 		m_freem(m);
 		return;
 	}
-	ng_ether_input2(node, &m);
-	if (m != NULL)
-		m_freem(m);
-}
-
-/*
- * Handle a packet that has come in on an ethernet interface.
- * The Ethernet header has already been detached from the mbuf,
- * so we have to put it back.
- *
- * NOTE: this function will get called at splimp()
- */
-static void
-ng_ether_input2(node_p node, struct mbuf **mp)
-{
-	const priv_p priv = NG_NODE_PRIVATE(node);
-	int error;
-
-	/* Send out lower/orphan hook */
-	NG_SEND_DATA_ONLY(error, priv->lower, *mp);
-	*mp = NULL;
+	NG_SEND_DATA_ONLY(error, priv->orphan, m);
 }
 
 /*
@@ -352,7 +333,6 @@
 ng_ether_newhook(node_p node, hook_p hook, const char *name)
 {
 	const priv_p priv = NG_NODE_PRIVATE(node);
-	u_char orphan = priv->lowerOrphan;
 	hook_p *hookptr;
 
 	/* Divert hook is an alias for lower */
@@ -362,13 +342,11 @@
 	/* Which hook? */
 	if (strcmp(name, NG_ETHER_HOOK_UPPER) == 0)
 		hookptr = &priv->upper;
-	else if (strcmp(name, NG_ETHER_HOOK_LOWER) == 0) {
+	else if (strcmp(name, NG_ETHER_HOOK_LOWER) == 0)
 		hookptr = &priv->lower;
-		orphan = 0;
-	} else if (strcmp(name, NG_ETHER_HOOK_ORPHAN) == 0) {
-		hookptr = &priv->lower;
-		orphan = 1;
-	} else
+	else if (strcmp(name, NG_ETHER_HOOK_ORPHAN) == 0)
+		hookptr = &priv->orphan;
+	else
 		return (EINVAL);
 
 	/* Check if already connected (shouldn't be, but doesn't hurt) */
@@ -381,7 +359,6 @@
 
 	/* OK */
 	*hookptr = hook;
-	priv->lowerOrphan = orphan;
 	return (0);
 }
 
@@ -514,18 +491,18 @@
 	NGI_GET_M(item, m);
 	NGI_GET_META(item, meta);
 	NG_FREE_ITEM(item);
-	if (hook == priv->lower)
+	if (hook == priv->lower || hook == priv->orphan)
 		return ng_ether_rcv_lower(node, m, meta);
 	if (hook == priv->upper)
 		return ng_ether_rcv_upper(node, m, meta);
 	panic("%s: weird hook", __func__);
-#ifdef RESTARTABLE_PANICS /* so we don;t get an error msg in LINT */
+#ifdef RESTARTABLE_PANICS /* so we don't get an error msg in LINT */
 	return NULL;
 #endif
 }
 
 /*
- * Handle an mbuf received on the "lower" hook.
+ * Handle an mbuf received on the "lower" or "orphan" hook.
  */
 static int
 ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta)
@@ -629,10 +606,11 @@
 		priv->upper = NULL;
 		if (priv->ifp != NULL)		/* restore h/w csum */
 			priv->ifp->if_hwassist = priv->hwassist;
-	} else if (hook == priv->lower) {
+	} else if (hook == priv->lower)
 		priv->lower = NULL;
-		priv->lowerOrphan = 0;
-	} else
+	else if (hook == priv->orphan)
+		priv->orphan = NULL;
+	else
 		panic("%s: weird hook", __func__);
 	if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
 	&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))

==== //depot/projects/hammer/sys/powerpc/powerpc/elf_machdep.c#11 (text+ko) ====

@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/powerpc/powerpc/elf_machdep.c,v 1.17 2003/12/23 02:42:39 peter Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/elf_machdep.c,v 1.18 2004/05/16 20:00:28 peter Exp $
  */
 
 #include <sys/param.h>

==== //depot/projects/hammer/sys/sparc64/sparc64/elf_machdep.c#12 (text+ko) ====

@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  *	from: NetBSD: mdreloc.c,v 1.5 2001/04/25 12:24:51 kleink Exp
- * $FreeBSD: src/sys/sparc64/sparc64/elf_machdep.c,v 1.16 2003/12/23 02:42:39 peter Exp $
+ * $FreeBSD: src/sys/sparc64/sparc64/elf_machdep.c,v 1.17 2004/05/16 20:00:28 peter Exp $
  */
 
 #include <sys/param.h>

==== //depot/projects/hammer/sys/sys/linker.h#12 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/sys/linker.h,v 1.36 2003/05/01 03:31:17 peter Exp $
+ * $FreeBSD: src/sys/sys/linker.h,v 1.37 2004/05/16 20:00:28 peter Exp $
  */
 
 #ifndef _SYS_LINKER_H_

==== //depot/projects/hammer/usr.sbin/acpi/acpidump/acpi_user.c#6 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/usr.sbin/acpi/acpidump/acpi_user.c,v 1.9 2004/05/16 05:31:40 njl Exp $
+ *	$FreeBSD: src/usr.sbin/acpi/acpidump/acpi_user.c,v 1.10 2004/05/16 18:02:47 njl Exp $
  */
 
 #include <sys/param.h>
@@ -96,6 +96,7 @@
 acpi_get_rsdp(u_long addr)
 {
 	struct ACPIrsdp rsdp;
+	size_t len;
 
 	/* Read in the table signature and check it. */
 	pread(acpi_mem_fd, &rsdp, 8, addr);
@@ -108,12 +109,16 @@
 	/* Run the checksum only over the version 1 header. */
 	if (acpi_checksum(&rsdp, 20))
 		return (NULL);
+
+	/* If the revision is 0, assume a version 1 length. */
 	if (rsdp.revision == 0)
-		return (NULL);
+		len = 20;
+	else
+		len = rsdp.length;
 
 	/* XXX Should handle ACPI 2.0 RSDP extended checksum here. */
 
-	return (acpi_map_physical(addr, rsdp.length));
+	return (acpi_map_physical(addr, len));
 }
 
 /*

==== //depot/projects/hammer/usr.sbin/cron/cron/cron.8#2 (text+ko) ====

@@ -15,7 +15,7 @@
 .\" * Paul Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
 .\" */
 .\"
-.\" $FreeBSD: src/usr.sbin/cron/cron/cron.8,v 1.20 2002/07/14 14:42:51 charnier Exp $
+.\" $FreeBSD: src/usr.sbin/cron/cron/cron.8,v 1.21 2004/05/16 19:29:33 yar Exp $
 .\"
 .Dd December 20, 1993
 .Dt CRON 8
@@ -25,6 +25,8 @@
 .Nd daemon to execute scheduled commands (Vixie Cron)
 .Sh SYNOPSIS
 .Nm
+.Op Fl j Ar jitter
+.Op Fl J Ar rootjitter
 .Op Fl s
 .Op Fl o
 .Op Fl x Ar debugflag Ns Op , Ns Ar ...
@@ -78,6 +80,27 @@
 .Pp
 Available options:
 .Bl -tag -width indent
+.It Fl j Ar jitter
+Enable time jitter.
+Prior to executing commands,
+.Nm
+will sleep a random number of seconds in the range from 0 to
+.Ar jitter .
+This won't affect superuser jobs (see
+.Fl J ) .
+A value for
+.Ar jitter
+must be between 0 and 60 inclusive.
+Default is 0, which effectively disables time jitter.
+.Pp
+This option can help to smooth down system load spikes during
+moments when a lot of jobs are likely to start at once, e.g.,
+at the beginning of the first minute of each hour.
+.It Fl J Ar rootjitter
+Enable time jitter for superuser jobs.
+The same as
+.Fl j
+except that it will affect jobs run by the superuser only.
 .It Fl s
 Enable special handling of situations when the GMT offset of the local
 timezone changes, such as the switches between the standard time and

==== //depot/projects/hammer/usr.sbin/cron/cron/cron.c#2 (text+ko) ====

@@ -17,7 +17,7 @@
 
 #if !defined(lint) && !defined(LINT)
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/cron/cron/cron.c,v 1.14 2001/03/09 03:14:09 babkin Exp $";
+  "$FreeBSD: src/usr.sbin/cron/cron/cron.c,v 1.15 2004/05/16 19:29:33 yar Exp $";
 #endif
 
 #define	MAIN_PROGRAM
@@ -51,7 +51,8 @@
 usage() {
     char **dflags;
 
-	fprintf(stderr, "usage: cron [-s] [-o] [-x debugflag[,...]]\n");
+	fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] "
+			"[-s] [-o] [-x debugflag[,...]]\n");
 	fprintf(stderr, "\ndebugflags: ");
 
         for(dflags = DebugFlagNames; *dflags; dflags++) {
@@ -414,9 +415,22 @@
 	char	*argv[];
 {
 	int	argch;
+	char	*endp;
 
-	while ((argch = getopt(argc, argv, "osx:")) != -1) {
+	while ((argch = getopt(argc, argv, "j:J:osx:")) != -1) {
 		switch (argch) {
+		case 'j':
+			Jitter = strtoul(optarg, &endp, 10);
+			if (*optarg == '\0' || *endp != '\0' || Jitter > 60)
+				errx(ERROR_EXIT,
+				     "bad value for jitter: %s", optarg);
+			break;
+		case 'J':
+			RootJitter = strtoul(optarg, &endp, 10);
+			if (*optarg == '\0' || *endp != '\0' || RootJitter > 60)
+				errx(ERROR_EXIT,
+				     "bad value for root jitter: %s", optarg);
+			break;
 		case 'o':
 			dst_enabled = 0;
 			break;

==== //depot/projects/hammer/usr.sbin/cron/cron/cron.h#2 (text+ko) ====

@@ -17,7 +17,7 @@
 
 /* cron.h - header for vixie's cron
  *
- * $FreeBSD: src/usr.sbin/cron/cron/cron.h,v 1.14 2001/03/09 03:14:09 babkin Exp $
+ * $FreeBSD: src/usr.sbin/cron/cron/cron.h,v 1.15 2004/05/16 19:29:33 yar Exp $
  *
  * vix 14nov88 [rest of log is in RCS]
  * vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley]
@@ -269,6 +269,8 @@
 
 char	*ProgramName;
 int	LineNumber;
+unsigned Jitter,
+	RootJitter;
 time_t	TargetTime;
 
 # if DEBUGGING
@@ -284,6 +286,8 @@
 		*DowNames[],
 		*ProgramName;
 extern	int	LineNumber;
+extern unsigned	Jitter,
+		RootJitter;
 extern	time_t	TargetTime;
 # if DEBUGGING
 extern	int	DebugFlags;

==== //depot/projects/hammer/usr.sbin/cron/cron/do_command.c#3 (text+ko) ====

@@ -17,7 +17,7 @@
 
 #if !defined(lint) && !defined(LINT)
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/cron/cron/do_command.c,v 1.21 2003/06/19 20:04:51 silby Exp $";
+  "$FreeBSD: src/usr.sbin/cron/cron/do_command.c,v 1.22 2004/05/16 19:29:33 yar Exp $";
 #endif
 
 
@@ -166,6 +166,13 @@
 		Debug(DPROC, ("[%d] grandchild process Vfork()'ed\n",
 			      getpid()))
 
+		if (e->uid == ROOT_UID)
+			Jitter = RootJitter;
+		if (Jitter != 0) {
+			srandom(getpid());
+			sleep(random() % Jitter);
+		}
+
 		/* write a log message.  we've waited this long to do it
 		 * because it was not until now that we knew the PID that
 		 * the actual user command shell was going to get and the



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405162019.i4GKJ94o002194>