From owner-freebsd-hackers@freebsd.org Sat Apr 7 02:58:19 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 63A8AF9E6F7 for ; Sat, 7 Apr 2018 02:58:19 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com [IPv6:2a00:1450:4010:c07::229]) (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 C52BD83EBA for ; Sat, 7 Apr 2018 02:58:18 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: by mail-lf0-x229.google.com with SMTP id g203-v6so2987725lfg.11 for ; Fri, 06 Apr 2018 19:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=C22rTm6S0PV7PTtJ1CVRh7XtFRTo/f/gVZ6q0dqKCHQ=; b=vavVav3i5oeYMMkmzXlUtS0IzsEpnt+tNu8xXWR4NPbTCBb8FDl5Ti2VhkXeY2cAV7 UrMgH2AnkHL+LcOLuHrkbQFObAW7j1Qydekk1oiHkQxbttvhwG6ag1O/zbdK67RFW1v4 Xd7hLPA20gSN8Ndrs7AFevBRIBJDnCiThNhECX0wYSuMIuiRz8+n+O0Q8hgqlwzldXFP zzaBFLrU/PsfpbyeB5+W1nMMyiiHDH2Dh8fwQ3gKygyH1bdAmXaushdvDkXb5QwnMl88 +mCIaKwdxczZwI9fFemvdGWOrXiAOaKao2QrWmJ5QwqXWs90maKMd/NG2qVf3XobgVsS Ry3g== 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:subject:message-id :mime-version:content-disposition:user-agent; bh=C22rTm6S0PV7PTtJ1CVRh7XtFRTo/f/gVZ6q0dqKCHQ=; b=rhmZkeCdRtIMaHd/LM6TgOGwxyxp5kUVVN+Q1XWDZTLf7g7HktLhQVSRayd4xMXoT3 WG3QTcbaK+zVNYLDGHBqZY04YnM9WMqxxfvOxoaSa0uVFvIB07pGxK6pBrY/Hyk2DVY1 WwAQCoByoMcLDCh10WK9bvecSns+uo7cjbJf5nlMUJVToSz0FEaN6Dy8LuO4baextj5m Ut7rDkcNXEOERJaZusmHRGlULJ7pAjVewJf4fwOuzFOi2r+FndEoi4j6VvdvkCf3Yvik pvO9kFL5zHpuccnTClKlxPAkyCOIl7jN4vgh1iDE6bbgJxoBc1nMLMJlzcnk9iIpclG4 xh0Q== X-Gm-Message-State: ALQs6tDkaAbVLlciT8Op5jz6TM5fsjEyyUYd4L85jUIehQXfwohBw9J6 qZ/1km9n4gtOxTY1Ah3NbIOe6Q== X-Google-Smtp-Source: AIpwx4/cgcsqwhcYpE3Ljq8zwKkVxBh9H45vdnBbqEOP2xDYzwCBD2JKTXLWqFRbSXDWoUV+csU3gA== X-Received: by 10.46.120.24 with SMTP id t24mr5475985ljc.68.1523069896032; Fri, 06 Apr 2018 19:58:16 -0700 (PDT) Received: from kloomba ([217.65.211.123]) by smtp.gmail.com with ESMTPSA id y1sm1962953lji.59.2018.04.06.19.58.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 19:58:15 -0700 (PDT) Sender: Roman Bogorodskiy Date: Sat, 7 Apr 2018 06:58:09 +0400 From: Roman Bogorodskiy To: freebsd-hackers@freebsd.org Subject: Getting /dev entry by interface name Message-ID: <20180407025807.GA18883@kloomba> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline 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: Sat, 07 Apr 2018 02:58:19 -0000 --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I have the following scenario: 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. The question is: given that I didn't save the original name before renaming, what are the ways to map 'testif' to its /dev entry (/dev/tap2 in our example)? The only way I found so far is to iterate over /dev/tap*, calling TAPGIFNAME and checking if result matches the name I'm trying to look up. This approach doesn't look good for a number of reasons, main are: 1. It's inefficient, esp. if there are many tap(4) devices, 2. It has annoying side effects, such as if the interface was up, after opening it it will be down (unless net.link.tap.up_on_open is set to 1, which I don't want to rely on). Is there a cleaner way maybe? I wasn't able to get this information via data returned by getifaddrs(3) for example, but probably I'm missing something. Roman Bogorodskiy --rwEMma7ioTxnRzrJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJayDO/AAoJEMltX/4IwiJqAa8IAKibUjov9RQtCjT77H2jYXI7 OcnLt+GDIBB/dIHTwL1defUBI/lkyXLoyVfaUKDGOMXXxvdZ0qG1fhAAMRtguUHM rl7P6nEF+EnZZmbnbrcWY0L7ViY2o+w5RbLtUy1YBi669I6PDNWXl1MJf9bMJBg4 ydO1QQDN6jSj8GAT3yVhRSW3pVqkibtPeUneA4X5RnGtCYNR0NfoqioMEorDRRyG CYATAl6t8ReqrIULsp5FQqDbwmjL/y5dbp5sPnP6C2/dMPjz65NAhqn6vSv5IQ5D WC0vtt1AToPJH5/8Cb546RoYdVyrWzTH3l27I4hG4etE0BCvZD22mx8xkvPMyrA= =nFLX -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ--