From patchwork Sat May 29 12:31:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1485368 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: 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=nLzl5khW; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=hauke-m.de header.i=@hauke-m.de header.a=rsa-sha256 header.s=MBO0001 header.b=QnCffvXy; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fsh1S3p33z9sRf for ; Sat, 29 May 2021 22:38:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dQymytlbS8s7bcddxGRLw7K2pZMNrxr6CcCLSojJJzk=; b=nLzl5khW3FwXeW Jn4/xLK1WjOXDy0ad2DD62FltfGhp7RR5tjjbKOj0RQamrCw0Y+9PRZHgFhM2pZU820rzW5JKJZZe vnCxSu1PBvRngHHFpod0zxcdzEw9RS4i+YS8i36dFCjW0rLoz7IBIKUEcMx2CdRf/4SuZCft4lYAh BGLifkxO3dwXT6iQm9aY9aUffJOf4X5k6y+ns3US+hyL11HGdISDxsRj99ZdRTthxswGcRmKh9JbH AZvVHiH76sKgtsGRStTQ1jlnNgduik6RQWOPtJ8Y4WHZPy59iYrY6AwSOF3IENuIp7R2vr6aUKGvt a8uY2N2uN/coHqbyynbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmy8k-005Vqf-Qn; Sat, 29 May 2021 12:32:30 +0000 Received: from mout-p-102.mailbox.org ([80.241.56.152]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmy80-005Vn0-R2 for openwrt-devel@lists.openwrt.org; Sat, 29 May 2021 12:31:46 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4FsgsQ148DzQjxJ; Sat, 29 May 2021 14:31:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hauke-m.de; s=MBO0001; t=1622291496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FvC4xeGMxjxMDmEF69w/znDJG/Q2pTLbqvPXDOr4GWc=; b=QnCffvXy7jthQJX1vk9n8XDwQ6GVJrn7BSNoAE/+SOoNLFzVv9puvqboBbX3BLfXqTUjBD MjC1Qrt/MFWzb3ManSizBdEERG83wrOtN72wO07rCM/2HJlEjcbsqauUQYG8aVrfkjdm9z Gpw7Zaaq49YZMnxm5kDJFlwXOXNY8TzxWTM3Tp52i9ZWlrzOqf2NatDSoayDrTEb2WvZKR OIMFC6hnWMSvC1Wt2WjhPRb8FaCycRoVSslX8jXKDUeAR/l8FcSJeArSVQRXoNyrL6Ers6 mltNvy22uKYCiJGmXdX4919ezIK4BeRRqxfEpt5FcMqtCBHrmhwTqMeC/ZoYQw== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id IhFP1HxUWxKY; Sat, 29 May 2021 14:31:35 +0200 (CEST) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Cc: zajec5@gmail.com, jo@mein.io, Hauke Mehrtens Subject: [PATCH] luci-mod-network: Fix migration overwriting device attribute Date: Sat, 29 May 2021 14:31:24 +0200 Message-Id: <20210529123124.626404-1-hauke@hauke-m.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.62 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4365D1895 X-Rspamd-UID: 100f77 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210529_053145_083174_F9DF5FF5 X-CRM114-Status: GOOD ( 11.91 ) X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Without this patch we first migrate the configuration to the br-lan device entry and change the device option of the network interface to point to the newly created device. In the next step all device [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.152 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Without this patch we first migrate the configuration to the br-lan device entry and change the device option of the network interface to point to the newly created device. In the next step all device options will be overwritten with the ifname entry, this partly reverted the change from the previous migration. The configuration we work on is not changed between these steps, so the functions all work on the same initial configuration. This patch changes the order to first migrate all ifname options to device or ports and do the migration of the bridges as the last step. This way the bridge migration is not overwritten any more. Without this patch this configuration: ------------------------------------------------------------- config interface 'lan' option type 'bridge' option ifname 'lan0 lan1' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' ------------------------------------------------------------- Is migrated to this broken configuration: ------------------------------------------------------------- config interface 'lan' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' option device 'lan0 lan1' config device option name 'br-lan' option type 'bridge' list ports 'lan0' list ports 'lan1' ------------------------------------------------------------- Fixes: 74be304e541f ("treewide: use "device" option in UCI "interface" sections") Signed-off-by: Hauke Mehrtens --- .../resources/view/network/interfaces.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index 6f8fd614b1..38f4b7e60c 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -321,18 +321,10 @@ return view.extend({ var interfaces = this.interfaceBridgeWithIfnameSections(); var tasks = []; - interfaces.forEach(function(ns) { - var device_name = 'br-' + ns['.name']; - - tasks.push(uci.callAdd('network', 'device', null, { - 'name': device_name, - 'type': 'bridge', - 'ports': L.toArray(ns.ifname) - })); - + this.interfaceWithIfnameSections().forEach(function(ns) { tasks.push(uci.callSet('network', ns['.name'], { - 'type': '', - 'device': device_name + 'ifname': '', + 'device': ns.ifname })); }); @@ -343,10 +335,18 @@ return view.extend({ })); }); - this.interfaceWithIfnameSections().forEach(function(ns) { + interfaces.forEach(function(ns) { + var device_name = 'br-' + ns['.name']; + + tasks.push(uci.callAdd('network', 'device', null, { + 'name': device_name, + 'type': 'bridge', + 'ports': L.toArray(ns.ifname) + })); + tasks.push(uci.callSet('network', ns['.name'], { - 'ifname': '', - 'device': ns.ifname + 'type': '', + 'device': device_name })); });