From owner-p4-projects@FreeBSD.ORG Fri Jun 23 08:29:22 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8B3E316A4A5; Fri, 23 Jun 2006 08:29:22 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6222C16A492 for ; Fri, 23 Jun 2006 08:29:22 +0000 (UTC) (envelope-from cdjones@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D480E43D5A for ; Fri, 23 Jun 2006 08:29:21 +0000 (GMT) (envelope-from cdjones@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5N8TLtU073184 for ; Fri, 23 Jun 2006 08:29:21 GMT (envelope-from cdjones@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5N8TLrk073180 for perforce@freebsd.org; Fri, 23 Jun 2006 08:29:21 GMT (envelope-from cdjones@FreeBSD.org) Date: Fri, 23 Jun 2006 08:29:21 GMT Message-Id: <200606230829.k5N8TLrk073180@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to cdjones@FreeBSD.org using -f From: Chris Jones To: Perforce Change Reviews Cc: Subject: PERFORCE change 99857 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jun 2006 08:29:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=99857 Change 99857 by cdjones@cdjones_ides on 2006/06/23 08:29:06 Add a 'priority' value to the jail and prison structs, with corresponding changes to jail(8). Affected files ... .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_jail.c#2 edit .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/jail.h#2 edit .. //depot/projects/soc2006/cdjones_jail/src/usr.sbin/jail/jail.c#2 edit Differences ... ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_jail.c#2 (text+ko) ==== @@ -135,6 +135,7 @@ goto e_dropvnref; pr->pr_ip = j.ip_number; pr->pr_linux = NULL; + pr->pr_priority = j.priority; pr->pr_securelevel = securelevel; /* Determine next pr_id and add prison to allprison list. */ ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/jail.h#2 (text+ko) ==== @@ -18,6 +18,8 @@ char *path; char *hostname; u_int32_t ip_number; + unsigned int priority; +/* CJ TODO --- add reference to preferred scheduler, e.g. by name? */ }; struct xprison { @@ -29,6 +31,10 @@ }; #define XPRISON_VERSION 1 +#define JAIL_DEFAULT_PRIORITY 10 +#define JAIL_MINIMUM_PRIORITY 1 +#define JAIL_MAXIMUM_PRIORITY 100 + #ifndef _KERNEL int jail(struct jail *); @@ -73,6 +79,8 @@ int pr_securelevel; /* (p) securelevel */ struct task pr_task; /* (d) destroy task */ struct mtx pr_mtx; + unsigned int pr_priority; /* (p) jail priority */ +/* CJ TODO scheduler reference. */ }; #endif /* _KERNEL || _WANT_PRISON */ ==== //depot/projects/soc2006/cdjones_jail/src/usr.sbin/jail/jail.c#2 (text+ko) ==== @@ -63,11 +63,12 @@ FILE *fp; iflag = Jflag = lflag = uflag = Uflag = 0; + priority = JAIL_DEFAULT_PRIORITY; securelevel = -1; username = JidFile = cleanenv = NULL; fp = NULL; - while ((ch = getopt(argc, argv, "ils:u:U:J:")) != -1) { + while ((ch = getopt(argc, argv, "ilp:s:u:U:J:")) != -1) { switch (ch) { case 'i': iflag = 1; @@ -76,6 +77,12 @@ JidFile = optarg; Jflag = 1; break; + case 'p': + priority = atoi(optarg); + if (priority < JAIL_MINIMUM_PRIORITY || + priority > JAIL_MAXIMUM_PRIORITY) + errx(1, "invalid priority: `%s'", optarg); + break; case 's': ltmp = strtol(optarg, &ep, 0); if (*ep || ep == optarg || ltmp > INT_MAX || !ltmp) @@ -118,6 +125,7 @@ if (inet_aton(argv[2], &in) == 0) errx(1, "Could not make sense of ip-number: %s", argv[2]); j.ip_number = ntohl(in.s_addr); + j.priority = priority; if (Jflag) { fp = fopen(JidFile, "w"); if (fp == NULL) @@ -183,7 +191,8 @@ { (void)fprintf(stderr, "%s%s%s\n", - "usage: jail [-i] [-J jid_file] [-s securelevel] [-l -u ", + "usage: jail [-i] [-J jid_file] [-p priority] [-s securelevel]", + " [-l -u ", "username | -U username]", " path hostname ip-number command ..."); exit(1);