From nobody Sat Nov 18 22:20:07 2023 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 4SXpBC6621z50kl1 for ; Sat, 18 Nov 2023 22:20:35 +0000 (UTC) (envelope-from freebsd@igalic.co) Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "protonmail.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SXpB94J5Fz3CPj for ; Sat, 18 Nov 2023 22:20:33 +0000 (UTC) (envelope-from freebsd@igalic.co) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=igalic.co header.s=protonmail2 header.b=tN3n5tPU; spf=pass (mx1.freebsd.org: domain of freebsd@igalic.co designates 185.70.40.22 as permitted sender) smtp.mailfrom=freebsd@igalic.co; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igalic.co; s=protonmail2; t=1700346028; x=1700605228; bh=AgwD0bYlt0gFpLPJSPrg+aT1DsPVFX+IkH1rJX64pOk=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=tN3n5tPUXQ+oXebkBgBI/JLs5pSR2lFnZB9WLBDcCaIEaXwo4FHzJR/0prJJQwzSP IdYPQLc7P1TMnkRcEeZVrcOhJ01Q0dn/1H7xEh01pcw8kjOA4h5fNdv/KQ8zH6VIyS U1ZvHSAnklpFpp4KdG1CfheqgsXddOjjacTjvYBzoM2xLfhNF64a5Bx28CQLFIE7EZ KQW9EzcVZEKUJG0wmwS5tcSVYanl0UHPWDg93W74Jzkrh0rtKpzX4VOHwoPgfA+MHP OuXjoQEWyRTrkcTcYuI2Xyv4GBBEs9JLzL+iI74COkTQ0yJKjxVuQxME062m4EveKk ebljD+xkCQHyg== Date: Sat, 18 Nov 2023 22:20:07 +0000 To: "freebsd-net@freebsd.org" From: =?utf-8?Q?Mina_Gali=C4=87?= Subject: How to tell if a network interface was renamed (and from what) Message-ID: Feedback-ID: 66573723:user:proton 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 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.90 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RWL_MAILSPIKE_EXCELLENT(-0.40)[185.70.40.22:from]; R_DKIM_ALLOW(-0.20)[igalic.co:s=protonmail2]; R_SPF_ALLOW(-0.20)[+ip4:185.70.40.0/24]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_ZERO(0.00)[0]; MIME_TRACE(0.00)[0:+]; TO_DN_EQ_ADDR_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-net@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:62371, ipnet:185.70.40.0/24, country:CH]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[igalic.co:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_NA(0.00)[igalic.co]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4SXpB94J5Fz3CPj X-Spamd-Bar: --- Hi folks, Linux has an "easy" way of telling if an interface has been renamed. See cloud-init's is_renamed function: https://github.com/canonical/cloud-in= it/blob/5496745b394f9b7b9eaf57fd619330d484ce2da8/cloudinit/net/__init__.py#= L338-L350 This code reads /sys/class/net//name_assign_type and if that is 3 or= 4, it's been renamed. I can't even think of an sensible way of replicating that. I can only think of terrible / wrong way of finding it out: dmesg | grep "changing name to ''" a less terrible method would be to check for, say: sysctl dev..0.%driver if that fails, we probably have a renamed interface=E2=80=A6 but we don't k= now what it was renamed from, and this only works for *real* interfaces, no= t for cloned devices, or epairs. Now, ignoring my terrible hacky attempts at command line tooling, I would a= lso happily accept a solution in C, which is fairly easily accessible from = Python, and which we already use to figure out the uptime (or rather, the b= oottime): https://github.com/canonical/cloud-init/blob/5496745b394f9b7b9eaf= 57fd619330d484ce2da8/cloudinit/util.py#L2073-L2105 Looking forward to reading your ideas. Kind regards, Mina Gali=C4=87