Date: Tue, 17 Jan 2012 13:21:27 +0100 (CET) From: Oliver Fromme <olli@lurza.secnetix.de> To: Kostik Belousov <kostikbel@gmail.com>, freebsd-net@FreeBSD.ORG, Julian Elischer <julian@FreeBSD.ORG>, freebsd-hackers@FreeBSD.ORG, Oliver Fromme <olli@fromme.com> Subject: Re: Processes' FIBs Message-ID: <201201171221.q0HCLRsh034506@lurza.secnetix.de> In-Reply-To: <freebsd-net.64400.1326459396.20120113122749.GG31224@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Kostik Belousov <kostikbel@gmail.com> 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 )
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201171221.q0HCLRsh034506>