From nobody Mon Oct 18 04:46:03 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 D95B4181666E; Mon, 18 Oct 2021 04:46:16 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) (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 4HXkpv1hxcz3ntR; Mon, 18 Oct 2021 04:46:15 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Received: by mail-ua1-x92e.google.com with SMTP id i22so1544058ual.10; Sun, 17 Oct 2021 21:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=oQwR1gd5Pwp63SjqlpIBKt8Vq3vDc6AF07wH5CLMutQ=; b=AAYdcvQlxPjzV89pxAZYR7SJatpL+cvOlFUteT8GSDXa+w5R9rJ12P3Aw6SXVx3fji e2Z35e0I/x2d4G0IOfkruB+SUtrVmx4ELE2mo7d25pT3Jm9AS80Wgv4WeNVTHDXLcmVQ UUjVuhft67UualNLRDkHHi0v/m0x/JiznMOX/z/Oyr+yfX7I4ZA142PFMTB+YF9MekMp CjR2Q6dIXA6sOaF2Ml5VwQsK+PmrxriTUDwCZq0VlLk8fwOVuC0he8HEDTXBPjurd11d XBHMqU862pJ/jTzkwjdx5SL0Od8mxxVAFm/ZIZOV58hmZ3CsZx8OsW7RJ8LQbWki8uy+ AeBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=oQwR1gd5Pwp63SjqlpIBKt8Vq3vDc6AF07wH5CLMutQ=; b=GFwXyhiZyDhb4jsZTYYn3OAUUgoPrGKbG1R58z4KrEu9RLhsq+MPCNsF3kJBZeV8Jn h8HVimRzgxn+qbGGMpIDutYME1TWNPLg98fpp1Ze0GfMB0civ6RitSuRrBe0DflHD7HX vU5xaAujWVh4zWIc/5t06L2Ijuwb30fG+GirW/bgWA2a4Sz9CX3sgDJrFdc1F3rt6Rsa IN8PLP8eOtbChnJiMjsap9pp6qXL694BM2p3bVrzaVL9muXs40iWpgTDT+/QTzmkcPIW 3WuW8va3nz+Ov9k/HaS+1uuASRDmi7Rd//kKAKTuV8d8XxBLteWk+KtNUdWpH0dXE/go jLZg== X-Gm-Message-State: AOAM532UR7HNOLN5vwuLCFSQonP6PIDSGAeSyvXbbbIP1DmnvgUhoDL7 jgAeIB6FrWeu+qdePYpBGfLgWcEszELiM2VXSoGiW+GvWqc= X-Google-Smtp-Source: ABdhPJxqlUl7KGpDDj6WJaov04gNH/XfY0/KS8bkKHK20b+auHwpfBaOpKm5tRzSX0xZxTXiV7VKEFJRWZVdUr8XxDE= X-Received: by 2002:a67:c903:: with SMTP id w3mr25524083vsk.6.1634532374069; Sun, 17 Oct 2021 21:46:14 -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 From: =?UTF-8?B?w5Z6a2FuIEtJUklL?= Date: Mon, 18 Oct 2021 07:46:03 +0300 Message-ID: Subject: Iterating all VNETs from userspace application To: FreeBSD Net , freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4HXkpv1hxcz3ntR X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=AAYdcvQl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of ozkankirik@gmail.com designates 2607:f8b0:4864:20::92e as permitted sender) smtp.mailfrom=ozkankirik@gmail.com X-Spamd-Result: default: False [0.61 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MID_RHS_MATCH_FROMTLD(0.00)[]; NEURAL_SPAM_SHORT(0.98)[0.980]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::92e:from]; NEURAL_SPAM_LONG(1.00)[1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[]; R_MIXED_CHARSET(0.62)[subject]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N Hi, I'm trying to gather all even within jails/vnet interface stats which interface type ifmd_data.ifi_type == IFT_ETHER (6) for bsnmpd. Related function (not modified) is here: https://github.com/freebsd/freebsd-src/blob/main/contrib/bsnmp/snmp_mibII/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 != 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 nice day Regards