From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 12 01:00:33 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F5541065692; Thu, 12 Jan 2012 01:00:33 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id 46ED88FC30; Thu, 12 Jan 2012 01:00:27 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 1BCD625D3899; Thu, 12 Jan 2012 01:00:25 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 2928FBD800E; Thu, 12 Jan 2012 01:00:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id K5lL9u9LTk22; Thu, 12 Jan 2012 01:00:23 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 989DBBD8010; Thu, 12 Jan 2012 01:00:22 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201201111506.q0BF6eAx067588@haluter.fromme.com> Date: Thu, 12 Jan 2012 01:00:22 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201201111506.q0BF6eAx067588@haluter.fromme.com> To: Oliver Fromme X-Mailer: Apple Mail (2.1084) Cc: freebsd-net@freebsd.org, olli@secnetix.de, "Paul A. Procacci" , freebsd-hackers@freebsd.org Subject: Re: Processes' FIBs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 01:00:33 -0000 On 11. Jan 2012, at 15:06 , Oliver Fromme wrote: >=20 > Bjoern A. Zeeb wrote: >> On 10. Jan 2012, at 20:32 , Paul A. Procacci wrote: >>> On Tue, Jan 10, 2012 at 09:12:17PM +0100, Oliver Fromme wrote: >>>> Is there a way to find out the default FIB number of a >>>> process (from a shell script)? I've checked the >>>> manpages of ps and procstat, but they don't mention >>>> FIBs. I'm using stable/8, if that matters. >>>=20 >>> = http://lists.freebsd.org/pipermail/freebsd-questions/2009-April/196532.htm= l >>>=20 >>> Not sure about ps/et al, but you can do it according to that post. = Nearly 2 years old now. >=20 > To be honest, I prefer not to fumble around in kernel memory > with kgdb in a shell script. Also, it requires root privilege > (setfib does not). >=20 >> If you are thinking in terms of multiple forwarding information = bases, yes >> sysctl net.my_fibnum >=20 > Thanks. Would it make sense to document that in setfib(1)? >=20 > However, I need to find the default FIB number for arbitrary > processes, not necessarily for the calling process. >=20 > I'm currently looking at the source code of ps, but adding > a field for the FIB isn't as trivial as I thought because > ps only sees struct kinfo_proc (via sysctl kern.proc.*) > which doesn't contain the FIB. procstat does the same. >=20 > I'm currently trying to write a patch that copies p_fibnum > from struct proc to struct kinfo_proc (just like p_nice, > for example). Does that make sense? If so, does the patch > below look reasonable? (I've made it on a stable/8 system, > but it should apply to 9 and 10, too.) I am not sure it makes too much sense in ps. It might make sense in sockstat maybe? > Best regards > Oliver >=20 > --- ./sys/sys/user.h.orig 2011-07-12 14:23:54.000000000 +0200 > +++ ./sys/sys/user.h 2012-01-11 15:35:50.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 >=20 > @@ -177,6 +177,7 @@ > */ > char ki_sparestrings[68]; /* 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 2011-07-12 14:19:26.000000000 = +0200 > +++ ./sys/kern/kern_proc.c 2012-01-11 15:36:22.000000000 +0100 > @@ -775,6 +775,7 @@ > kp->ki_swtime =3D (ticks - p->p_swtick) / hz; > kp->ki_pid =3D p->p_pid; > kp->ki_nice =3D p->p_nice; > + kp->ki_fibnum =3D p->p_fibnum; > PROC_SLOCK(p); > rufetch(p, &kp->ki_rusage); > kp->ki_runtime =3D cputick2usec(p->p_rux.rux_runtime); > --- ./bin/ps/keyword.c.orig 2011-07-12 13:42:48.000000000 +0200 > +++ ./bin/ps/keyword.c 2012-01-11 15:44:27.000000000 +0100 > @@ -90,6 +90,7 @@ > NULL, 0}, > {"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, = NULL, 0}, > {"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0}, > + {"fib", "FIB", NULL, 0, kvar, NULL, 2, KOFF(ki_fibnum), INT, = "d", 0}, > {"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, > {"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, = 0}, > {"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), = LONG, >=20 > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do!