From nobody Sun Nov 19 09:54:49 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 4SY5bW24v9z51XkJ for ; Sun, 19 Nov 2023 09:55:03 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) (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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SY5bV73gfz4cZw; Sun, 19 Nov 2023 09:55:02 +0000 (UTC) (envelope-from ozkan.kirik@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5098e423ba2so4779067e87.2; Sun, 19 Nov 2023 01:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700387700; x=1700992500; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vKX26DjUGLEI69mlDz50njWJMa8yLA8FnZhqVlXIGQU=; b=kTQYS24gNvGQn6F/CDoRKxHi2JDX86eKWhhmuAYxPUrLw/2vTTOdh4hDazCyY9LntI jYFzvYKAmcNdt6Xs6BhQSUH43OjkkiNmYJK2r+Dd5fNe2bYECdkYmBjz3LdkIbrNSUhN SRMpqjqsjuwTifOsTFPlpWnamplivWum6fr/pSvSnwC0X6+Ewz6kbScZfDkSfTyUQH4Y zpfgFsSqO8CGOVc0zeel0AKR8hF8istoJVYc6cd+1rjumTjXv93T0umcZlz5lKzMz8YT 92xLo+GuQaHlO49qa0/m+/7sUQorIwfl7Pt+vb9FQ6WX8TuBe8R5UHWAo5e2JFCOuVib lhWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700387700; x=1700992500; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vKX26DjUGLEI69mlDz50njWJMa8yLA8FnZhqVlXIGQU=; b=Zb5lRdp2/tD/ipKLkxHMUR3582+ViPx/CF7aQmblx5N5k7nMFq/RQf84kIIQzWh2PI eMa0eiBCMQYUEMQIsONF6RUKwUTswqSA0v8/QX4naM4SimYFN0Z8HlCL+VdR9T8Q1XZj VlDB0FIduYhpEB4TR/54v9MjPH01GOSLhwADsGFIfNfThD109rlS06nQJjMp5MrSa1j8 KbXsP0zw4s2Ow8ywd+ue5GxFdN1pkzU3vjH1XPy/2zCW6FuKiyhki3oujz8ho71xeBIT 4dY34GSeQf6fMBoUSLLv/sLNNNZ6c968fp4fuUwEtm5KtI/230w2lNjzrRTn4+NwaXTT EcBQ== X-Gm-Message-State: AOJu0YxV6XRn5R7bndc0vDVRIhHllQWHV4bnMZA4bZjUHG+Tl7uzuOxd EEzs9ZP5nu6U0xJiL2gjOagfu6Ft4SXoRGy/T3aITrtF X-Google-Smtp-Source: AGHT+IGWbV+APre3h54FHBZz0lRwzW9WwSGFYt+0AwP9S+IlMKNnSL9oP7U/5j2ndnE7D5lCuU0rR6TSy6WT6MayiZM= X-Received: by 2002:ac2:5216:0:b0:50a:77bf:1efe with SMTP id a22-20020ac25216000000b0050a77bf1efemr3006360lfl.27.1700387700104; Sun, 19 Nov 2023 01:55:00 -0800 (PST) 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: <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org> In-Reply-To: <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org> From: =?UTF-8?B?w5Z6a2FuIEtJUklL?= Date: Sun, 19 Nov 2023 12:54:49 +0300 Message-ID: Subject: Re: How to tell if a network interface was renamed (and from what) To: Kyle Evans Cc: freebsd-net@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4SY5bV73gfz4cZw It would be better if FreeBSD could have "interface altname feature" like Linux has. Kyle Evans , 19 Kas 2023 Paz, 07:50 tarihinde =C5=9Funu= yazd=C4=B1: > > On 11/18/23 19:15, Zhenlei Huang wrote: > > > > > >> On Nov 19, 2023, at 6:20 AM, Mina Gali=C4=87 >> > wrote: > >> > >> 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-init/blob/5496745b394f9b7b9eaf57fd6= 19330d484ce2da8/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 do= n't know > >> what it was renamed from, and this only works for *real* interfaces, > >> not for cloned devices, or epairs. > >> > >> Now, ignoring my terrible hacky attempts at command line tooling, I > >> would also 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 boottime): > >> https://github.com/canonical/cloud-init/blob/5496745b394f9b7b9eaf57fd6= 19330d484ce2da8/cloudinit/util.py#L2073-L2105 > >> > >> Looking forward to reading your ideas. > > > > FreeBSD currently does not preserve the old ( original ) name of > > interfaces if it is renamed ( either physical or cloned ones ). > > While there's an attempt https://reviews.freebsd.org/D28247 > > to get the device name (physical > > ones) but it is not perfect and not completed. > > > > So may I ask why you need to know if a network interface was renamed ? > > > > Just last week I found this quite a pain as well; once an interface has > been renamed, if it's not a pseudo-interface with an obvious group > there's no clear way, AFAICT, to determine which driver created it > without perusing pciconf output or whatnot and hopefully being able to > associate the NICs listed with the new names (easier when there's only > one NIC, of course). Kind of a pain when you're working on a remote > machine that you're not at all familiar with. > > Thanks, > > Kyle Evans >