From nobody Mon Oct 18 08:07:26 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 3019A17FB9FC; Mon, 18 Oct 2021 08:07:37 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HXqHF0PXFz3k1m; Mon, 18 Oct 2021 08:07:37 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Received: by mail-ua1-x92b.google.com with SMTP id a17so455633uax.12; Mon, 18 Oct 2021 01:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=o+9bC1vJ4pWPjp4SoIypU5RojCMPw7I3dlDYUjc6ceU=; b=nzF/LKLAuuRut7B82cqStez1t9SwnA9POKJThA24FKruFARD6jSP7Dd0Re8Oog9N8k dwl5QRdTfCk4tJ8+ejur5+fitSPfRVKxQ1vuhjGTd7iUQq9GiRPuhyh20Jwdk+h2MRTI 2mt/cpJ4N+PccXareqNco1+BlkeE1XYvq7EWN7aNjUo2nNpXAzk81o2MJPSP/gH8kC8/ HQEREzzTIv+3Jw/ZBIdGNxIZ+sXGErRPQ27cXFHInT0cAHotz9YSVTxVazN25cVf7qIV wtJkRW62UomjK9XaohB3TV0R6yEUpSSYHHhArPPgudk/33IFShYyg6IZjatDAfSIYqt6 898w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=o+9bC1vJ4pWPjp4SoIypU5RojCMPw7I3dlDYUjc6ceU=; b=zEgOO96WtQAGbQKs0O6BjTa2j0k8aMUf8dVg/5lLP2YEQKEsKAsAFe5qjuFx6AjaTC EDOpljyfOdhVP3WkZ2uY61ACG+SnPyKiIpCEJfkhRnucvp23htXtDfNt1zb51YZFJ+At SujXSihbflPIZgnuNxousxOHQv5bMP0Qhg6u4nnHPfPwaXYMXbJUSBf6zzVaXG8R6yqI 44YaduGPTqLtTKFgM289SWVqqdud7/lAtV2rnMo17HSEDGtG7spaYynf3Hof1G1Tu7wF D6vr4bFlxLFm0cm0UZGurV0BVy46a6SxTf3cqbvSuMPoQ0MJPShaoban1wf9bZmig7t4 BJcQ== X-Gm-Message-State: AOAM531ST/i4nwCx6fhZG8TFf8BErNqD5TQaRQDWwOXHW83H3deDN2HF pj0y+j0U5vO7yPM5aV01+4MwxbvA6qHdD7Le58kaaIze X-Google-Smtp-Source: ABdhPJwwh61c86PxDXo+wrwwGiHwfCRjEneP6rnqFsrYoHa0ErUuMhd3g5hMDvHS2tgUQbhbmuj0SeuB4BDxz8h/UI4= X-Received: by 2002:a67:c903:: with SMTP id w3mr25877100vsk.6.1634544456691; Mon, 18 Oct 2021 01:07:36 -0700 (PDT) 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 References: In-Reply-To: From: =?UTF-8?B?w5Z6a2FuIEtJUklL?= Date: Mon, 18 Oct 2021 11:07:26 +0300 Message-ID: Subject: Re: Iterating all VNETs from userspace application To: "Bjoern A. Zeeb" Cc: FreeBSD Net , freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4HXqHF0PXFz3k1m X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Thank you Bjoern, I'll have al On Mon, Oct 18, 2021 at 10:49 AM Bjoern A. Zeeb wrote: > > 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 >