From owner-freebsd-hackers@freebsd.org Sun Apr 8 08:31:15 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93EBAF8E8CA for ; Sun, 8 Apr 2018 08:31:15 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1FE6A6BB15 for ; Sun, 8 Apr 2018 08:31:15 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: by mail-wm0-x22e.google.com with SMTP id u189so11182224wmd.1 for ; Sun, 08 Apr 2018 01:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SZp0NBxYvvXnQmYNUeTjLtpumv8Ec9qy+0+Fgebooas=; b=BLBb6wD9VJ2snPIIqW/uxIkz4XxGVbAoeGWE9xuMIDhKU4f87VjMG6D8tHNXCzlyvU 8vKJQbB4/OeEvQLoFH7xqny1tHBxFKgk482Hjuo26SXCbhrJuumS0Q5awULEd0F8pPCC GVsNB+mDF9Rs7tXMg7KLvzbskRuq3ybCPLtNB91L5HbzXPG/Bf1t7zfwpDybxiTGnYeV +GOkKcRQtSExfiJ4dlYhb9VpIw7BujDBb0aLNOaZuh5U2Yv6x+D+vueda0r9jaU0Fc4m FLKL7rvym0B0W2WM7E2OQMziHgaLGaW6kLZvgfxU0neUKnAaFtGjvUzHoqXCpF5/4QIq Wh1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=SZp0NBxYvvXnQmYNUeTjLtpumv8Ec9qy+0+Fgebooas=; b=l2tDbAk11k0XcjJ9/cqMobTLKK1NNRATjMgTZ62haJHgl4kZAHrUizAzdlAwpg2m7n Qn5zgP4IHD2tRXAWLOHLFD1rg2S1KFLcO0PRjgKx8gEVNDpPMjCOIKrKxx96gY0juQyQ 6i8HYY3qs9+SXDtikmoGCgCeQlPf/E0GpU/hjMX/3xlbhifaONLrArDvR1tuSv0SWl6o ysDxAEAYA8YxELbhKGVonrIeZQNugIbQR7AU6aHC8SHTZksk4kbZMbe1Z8uph6OzVTtq 9Pxx4ww0GmNudTpCy26OfSZeZcp228q92QgupcfooMjrridMum5h7SprUXRr9ymckhsN HCeg== X-Gm-Message-State: ALQs6tAfl8XNhs2IdQp07KmyZvyIQ+SpXGa7z8NQMZpBF1WV4GpOE4Wo 6UOqy1cTUIPiuG5C5iU4O7X4MQ== X-Google-Smtp-Source: AIpwx49HkiLWVxmkRh49Kc+w85DiK0+mvnBKRwTIVcwwf2wDSfatvdbdJCVaXQydV0T1kGwsgsIldg== X-Received: by 10.46.18.150 with SMTP id 22mr19911952ljs.120.1523176273391; Sun, 08 Apr 2018 01:31:13 -0700 (PDT) Received: from kloomba ([217.65.211.123]) by smtp.gmail.com with ESMTPSA id s1sm2402076lji.92.2018.04.08.01.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 01:31:12 -0700 (PDT) Sender: Roman Bogorodskiy Date: Sun, 8 Apr 2018 12:31:05 +0400 From: Roman Bogorodskiy To: Poul-Henning Kamp Cc: freebsd-hackers@freebsd.org Subject: Re: Getting /dev entry by interface name Message-ID: <20180408083104.GA1780@kloomba> References: <20180407025807.GA18883@kloomba> <37078.1523089049@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline In-Reply-To: <37078.1523089049@critter.freebsd.dk> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Apr 2018 08:31:15 -0000 --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Poul-Henning Kamp wrote: > -------- > In message <20180407025807.GA18883@kloomba>, Roman Bogorodskiy writes: >=20 > >1. Create tap(4) like that: > > > ># ifconfig tap create > >tap2 > ># > > > >2. Rename it > > > ># ifconfig tap2 name testif > >testif > > > >Now I can do 'ifconfig testif' and there'll be no signs that it was > >named 'tap2' previously, however, in /dev it's still /dev/tap2. >=20 > I would argue that is an error. >=20 > The /dev entry should also be renamed, or maybe better, a symlink > with the new name should be created, pointing to the /dev/tap%d > entry. >=20 > However, I dont know if that is actually possible, is the device > driver even even told about the new interface name ? >=20 > There is also a name-space validation issue to think about: >=20 > ifconfig tap2 name ../etc I'm not sure if that's possible (or a reasonable thing to do) either. Not only stuff like '../etc' needs to be validated as you mentioned, but also we need to make sure not to clash with other devices. For example, now it's possible to rename tap device to 'null' which will not be possible if we create a symlink. Back to the original question, julian@ suggested to take a look at sysctl, and there's indeed one that reports this information. There's even some sample code in tools/ available: https://svnweb.freebsd.org/base/head/tools/tools/ifinfo/ifinfo.c?view=3Dmar= kup#l123 This sysctl is not easy to find unless you know what you're looking for. Roman Bogorodskiy --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJaydNIAAoJEMltX/4IwiJqtF4H/1m5XUPWap+Ua3og6ofN2Mv2 aoUOBYvJT35KxGmjJ/E5tPtNJ4SIJstyRkZII+xQsrptOswhuFjZmTpRsgDWhhz0 eRw8BDOQGtXtc+XGbcdcS/KScnIJdxb7TN7GE3lX9RXwfpVepqQyEzuSpNBsrIpi uds9nhO6+6QtUSRS10xvH+zpJmE+tZspWHYFH4oMmXG3yi+1UGW6sGtUC5znASu2 OqjfC2JcM4DxZy2N5gKTfTSJw+uh9K2GD1gmsUdN1lfU3UMFot5L8iYcoY5pij+x bvQCmbEECJAT8XvwPi9sLvR79rIslTJZbWoZGUJW2FcEFEsKDXTAmfqQrHLUvq4= =X2y9 -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--