From nobody Mon Oct 18 07:49:40 2021 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5242517F24C6; Mon, 18 Oct 2021 07:49:53 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:13b:39f::9f:25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HXptn1Bfmz3MpF; Mon, 18 Oct 2021 07:49:52 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) 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 1EA198D4A212; Mon, 18 Oct 2021 07:49:45 +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 32384E707CB; Mon, 18 Oct 2021 07:49:44 +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 53X6n4w7OZmX; Mon, 18 Oct 2021 07:49:41 +0000 (UTC) Received: from [169.254.86.56] (unknown [IPv6:fde9:577b:c1a9:4902:958c:feeb:258b:6e9f]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id C130BE707AC; Mon, 18 Oct 2021 07:49:41 +0000 (UTC) From: "Bjoern A. Zeeb" To: "=?utf-8?q?=C3=96zkan?= KIRIK" Cc: "FreeBSD Net" , freebsd-hackers@freebsd.org Subject: Re: Iterating all VNETs from userspace application Date: Mon, 18 Oct 2021 07:49:40 +0000 X-Mailer: MailMate (2.0BETAr6151) Message-ID: In-Reply-To: References: List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4HXptn1Bfmz3MpF X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On 18 Oct 2021, at 4:46, =C3=96zkan KIRIK wrote: > Hi, > > I'm trying to gather all even within jails/vnet interface stats which > interface type ifmd_data.ifi_type =3D=3D IFT_ETHER (6) for bsnmpd. Rela= ted > function (not modified) is here: > > https://github.com/freebsd/freebsd-src/blob/main/contrib/bsnmp/snmp_mib= II/mibII.c#L926-L985 > > It's possible to add a filter interface type adding a line below line = > 961: > if (mib.ifmd_data.ifi_type !=3D IFT_ETHER) return; > > I'm looking for a way to iterate VNET instances, but net/vnet.h is > only for kernel space. > VNET_LIST_RLOCK_NOSLEEP(); > VNET_FOREACH(vnet_iter) { > CURVNET_SET(vnet_iter); > mib_refresh_iflist(); > CURVNET_RESTORE(); > } > VNET_LIST_RUNLOCK_NOSLEEP(); > The code above not working in userspace. > > Also I wonder that if it's possible to switch between jails. The > pseudo code I want to write: > > JAIL_FOREACH(jail_iter) { > jail_attach(jail_iter); > mib_refresh_iflist(); > jail_detach(); > } > > What is the right way to gather all interface stats ? Have a look at libkvm; I seem to remember adding vnet support. /bz