From patchwork Wed Apr 7 14:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 4118 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4FFnXq3sNbz3yBV for ; Wed, 7 Apr 2021 14:56:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4FFnXq12Z0zpM; Wed, 7 Apr 2021 14:56:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4FFnXq0V1rz2ySy; Wed, 7 Apr 2021 14:56:43 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4FFnXp04wnz2xCN for ; Wed, 7 Apr 2021 14:56:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4FFnXn2wYJzQ1; Wed, 7 Apr 2021 14:56:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1617807401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qFGTQ9W0WQ1oQg/XaLpPNMkkHgIfrUKeBlT8rLEScPQ=; b=BK9FZ/+S0qdE/hhDy2meHVvwnvxy4evZh+g6rIDB9azQnvlLXR6U9PNhbjEhkJkdKDVWuR Ws1qKA62Jg+6JZDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1617807401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qFGTQ9W0WQ1oQg/XaLpPNMkkHgIfrUKeBlT8rLEScPQ=; b=SRNQ5tK5+Nz71Lbgj3U6uRE8++tl7Z5rCktyayzei1vvNNoeMr0M/4Mbw3kTUYukxP6wRf jIyRym8hrulrrx1d9/ThgyPtX+orjmvQ4HQ21zc3g/sy5MjgJnPAV0m6lShQzmoUJSUbnf JplU/Gl9me4kdvKU9rF2pkycDkJI4NRtXgaZ6U5FMNqYF3ZLXJkZjR6wnUGpeioBVM/Uv4 xiBz/OEz+J5SaT/rDSiPP+ESuYa9h4Id6ntUGUNgRLulF8kjNfw2pcuTTbEntuga4iNA5u 5TTNAEJ86W+BxSmm/i4yCXo62lysUWLd7z0tiQso2+XTOjV1dN007ZPw+IJyOg== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] udev: Fix renaming bridged interfaces Date: Wed, 7 Apr 2021 14:56:36 +0000 Message-Id: <20210407145636.15829-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" From: Daniel Weismüller Since using random interface names is always trouble, we will order all slave interfaces and number them in order as they appear in the SLAVES variable. Signed-off-by: Michael Tremer --- config/udev/network-hotplug-rename | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/config/udev/network-hotplug-rename b/config/udev/network-hotplug-rename index 71a25c317..8807e0ab8 100644 --- a/config/udev/network-hotplug-rename +++ b/config/udev/network-hotplug-rename @@ -58,18 +58,25 @@ for zone in ${ZONES}; do address="${zone}_MACADDR" device="${zone}_DEV" mode="${zone}_MODE" + slaves="${zone}_SLAVES" - # Skip if address or device is unset - [ -n "${!address}" -a -n "${!device}" ] || continue - - # Compare MAC addresses - [ "${ADDRESS}" = "${!address,,}" ] || continue + # Return DEV when the address matches + if [ "${!address,,}" = "${ADDRESS,,}" ]; then + echo "${!device}" + exit 0 + fi # If a matching interface has been found we will # print the name to which udev will rename it. case "${!mode}" in bridge) - echo "${!device%0}phys0" + counter=0 + for slave in ${!slaves}; do + if [ "${slave,,}" = "${ADDRESS,,}" ]; then + echo "${!device}p${counter}" + fi + (( counter += 1 )) + done ;; macvtap) @@ -81,13 +88,7 @@ for zone in ${ZONES}; do echo "${!device%0}phys0" fi ;; - - *) - echo "${!device}" - ;; esac - - exit 0 done # If we get here we have not found a matching device,