From owner-freebsd-net@FreeBSD.ORG Tue Jan 17 12:21:45 2012 Return-Path: Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1F4D106566B; Tue, 17 Jan 2012 12:21:45 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 273968FC0A; Tue, 17 Jan 2012 12:21:44 +0000 (UTC) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id q0HCLSBG034507; Tue, 17 Jan 2012 13:21:43 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id q0HCLRsh034506; Tue, 17 Jan 2012 13:21:27 +0100 (CET) (envelope-from olli) Date: Tue, 17 Jan 2012 13:21:27 +0100 (CET) Message-Id: <201201171221.q0HCLRsh034506@lurza.secnetix.de> From: Oliver Fromme To: Kostik Belousov , freebsd-net@FreeBSD.ORG, Julian Elischer , freebsd-hackers@FreeBSD.ORG, Oliver Fromme In-Reply-To: X-Newsgroups: list.freebsd-net User-Agent: tin/1.9.6-20101126 ("Burnside") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (lurza.secnetix.de [127.0.0.1]); Tue, 17 Jan 2012 13:21:43 +0100 (CET) Cc: Subject: Re: Processes' FIBs X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2012 12:21:45 -0000 Kostik Belousov wrote: > The patch misses compat32 bits and breaks compat32 ps/top. Right, thank you for pointing it out! I missed it because I only have i386 for testing. I've created new patch sets for releng8 and current. These include compat32 support and an entry for the manual page. Would someone with amd64 please test the compat32 part? I've been using this code on i386 for a few days without any problems. I've attached the patch for current below. Both patch sets are also available from this URL: http://www.secnetix.de/olli/tmp/ki_fibnum/ Testing is easy: Apply the patch, rebuild bin/ps and kernel. Make sure that your kernel config has "options ROUTETABLES=16" so multiple FIBs are supported. Reboot. Open a shell with setfib, e.g. "setfib 3 /bin/sh" (no root required), type "ps -ax -o user,pid,fib,command" or something similar, and verify that the shell process and its children are listed with the correct FIB. When testing on amd64, use both the native ps and an i386 binary. Thank you very much! Best regards Oliver --- sys/sys/user.h.orig 2011-11-07 22:13:19.000000000 +0100 +++ sys/sys/user.h 2012-01-17 11:33:59.000000000 +0100 @@ -83,7 +83,7 @@ * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and * function kvm_proclist in lib/libkvm/kvm_proc.c . */ -#define KI_NSPARE_INT 9 +#define KI_NSPARE_INT 8 #define KI_NSPARE_LONG 12 #define KI_NSPARE_PTR 6 @@ -186,6 +186,7 @@ */ char ki_sparestrings[50]; /* spare string space */ int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ + int ki_fibnum; /* Default FIB number */ u_int ki_cr_flags; /* Credential flags */ int ki_jid; /* Process jail ID */ int ki_numthreads; /* XXXKSE number of threads in total */ --- sys/kern/kern_proc.c.orig 2012-01-15 19:47:24.000000000 +0100 +++ sys/kern/kern_proc.c 2012-01-17 12:52:36.000000000 +0100 @@ -836,6 +836,7 @@ kp->ki_swtime = (ticks - p->p_swtick) / hz; kp->ki_pid = p->p_pid; kp->ki_nice = p->p_nice; + kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; timevaladd(&kp->ki_start, &boottime); PROC_SLOCK(p); @@ -1121,6 +1122,7 @@ bcopy(ki->ki_comm, ki32->ki_comm, COMMLEN + 1); bcopy(ki->ki_emul, ki32->ki_emul, KI_EMULNAMELEN + 1); bcopy(ki->ki_loginclass, ki32->ki_loginclass, LOGINCLASSLEN + 1); + CP(*ki, *ki32, ki_fibnum); CP(*ki, *ki32, ki_cr_flags); CP(*ki, *ki32, ki_jid); CP(*ki, *ki32, ki_numthreads); --- sys/compat/freebsd32/freebsd32.h.orig 2011-11-11 08:17:00.000000000 +0100 +++ sys/compat/freebsd32/freebsd32.h 2012-01-17 11:34:00.000000000 +0100 @@ -319,6 +319,7 @@ char ki_loginclass[LOGINCLASSLEN+1]; char ki_sparestrings[50]; int ki_spareints[KI_NSPARE_INT]; + int ki_fibnum; u_int ki_cr_flags; int ki_jid; int ki_numthreads; --- bin/ps/keyword.c.orig 2011-09-29 08:31:42.000000000 +0200 +++ bin/ps/keyword.c 2012-01-17 12:54:49.000000000 +0100 @@ -85,6 +85,7 @@ {"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0}, {"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0}, {"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0}, + {"fib", "FIB", NULL, 0, kvar, NULL, 2, KOFF(ki_fibnum), INT, "d", 0}, {"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0}, {"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0}, {"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0}, --- bin/ps/ps.1.orig 2011-11-22 22:53:06.000000000 +0100 +++ bin/ps/ps.1 2012-01-17 12:56:17.000000000 +0100 @@ -29,7 +29,7 @@ .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD: src/bin/ps/ps.1,v 1.112 2011/11/22 21:53:06 trociny Exp $ .\" -.Dd November 22, 2011 +.Dd January 17, 2012 .Dt PS 1 .Os .Sh NAME @@ -506,6 +506,9 @@ minutes:seconds. .It Cm etimes elapsed running time, in decimal integer seconds +.It Cm fib +default FIB number, see +.Xr setfib 1 .It Cm flags the process flags, in hexadecimal (alias .Cm f )