From patchwork Tue Oct 15 10:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Jobling X-Patchwork-Id: 1997291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=N/C9DSEf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSVMm3SSRz1xvP for ; Tue, 15 Oct 2024 21:14:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:To:Subject:Date:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=KW2hNRrmmpQ5Dvskni2e/w8MArTUgalUm22zt9hnEHs=; b=N/C9DSEfvxdmB+2FP840KWVnB3 Dho8+bXGiC8uhO8ss+Viegb+9g1FKVpvGdditEOwohZviv2IgXTRRet8QEIY12LtLyM3W2o3jQrQL WDuV0i9QyEypnV7BZrt+T1JQTZpMHEBhyT5866YR/4GQ1j2bNMkAloS1joMbbPfhrTS+VT2yAsP13 K2ehchbkDEXAt8rcM+c2KrqWvrRAJnMx5Na1nWVC/UKa1gI7BudSKFzmp3mGz8X+tthH2xUmlrgOu qhZQ7FSRaNAoOAMFhXStU3tFI/VAEEBoSin22ABGdCT2AEdOEhQ3o1yjaJmJRL6Z8bfIDyQqhES0C 50gIXrGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0eYY-00000007mvB-20Cy; Tue, 15 Oct 2024 10:13:34 +0000 Date: Tue, 15 Oct 2024 21:13:26 +1100 Subject: [PATCH 3/5] base-files: preinit: add ethernet label name pass To: openwrt-devel MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Evan Jobling via openwrt-devel From: Evan Jobling Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Evan Jobling List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. Add a second pass for renaming in case named devices by path conflict with dsa labels for example. A device specific example: The Firebox M300 by factory has ports eth3-eth7 which are on a DSA switch and which conflict with eth3/eth4 which are the default names for the switch conduits. Signed-off-by: Evan Jobling --- .../files/lib/preinit/10_indicate_preinit | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index 627b56e41d..cb99cbea60 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -77,6 +77,19 @@ preinit_config_port_bypath() { ip link set "$original" name "$netdev" } +preinit_config_port_label() { + local original + + local netdev="$1" + local label="$2" + + [ -d "/sys/class/net/$label" ] && return + + [ "$netdev" = "$label" ] && return + + ip link set "$netdev" name "$label" +} + preinit_config_board() { /bin/board_detect /tmp/board.json @@ -89,7 +102,7 @@ preinit_config_board() { # Find the current highest eth* max_eth=$(grep -o '^ *eth[0-9]*:' /proc/net/dev | tr -dc '[0-9]\n' | sort -n | tail -1) - # Find and move netdevs using eth*s we are configuring + # Find and move netdevs using eth*s we are configuring by path json_get_keys keys "network_device" for netdev in $keys; do json_select "network_device" @@ -123,6 +136,33 @@ preinit_config_board() { [ -n "$device" -o -n "$ports" ] || return + # Find the current highest eth* + max_eth=$(grep -o '^ *eth[0-9]*:' /proc/net/dev | tr -dc '[0-9]\n' | sort -n | tail -1) + # Find and move netdevs using eth*s we are configuring by label + json_get_keys keys "network_device" + for netdev in $keys; do + json_select "network_device" + json_select "$netdev" + json_get_vars label label + if [ -n "$label" -a -h "/sys/class/net/$netdev" ]; then + ip link set "$netdev" down + ip link set "$netdev" name eth$((++max_eth)) + fi + json_select .. + json_select .. + done + + # Move interfaces by old name to their label name + json_get_keys keys "network_device" + for netdev in $keys; do + json_select "network_device" + json_select "$netdev" + json_get_vars label label + [ -n "$label" ] && preinit_config_port_label "$netdev" "$label" + json_select .. + json_select .. + done + # swconfig uses $device and DSA uses ports [ -z "$ports" ] && { ports="$device"