From 4419c3dcd3fbaa7b51239c90784af03af2c2c911 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Sat, 9 Jan 2021 00:02:57 +0100 Subject: [PATCH 01/12] build/json: generate json file for initramfs The initramfs images are missing from the profiles.json files. Signed-off-by: Moritz Warning [fix code by exporting device variables] Signed-off-by: Paul Spooren (cherry picked from commit d3140d05296461deddaaa8ca2ce4a4a97a320eff) --- include/image.mk | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/include/image.mk b/include/image.mk index 2530108211..e602f2f4e9 100644 --- a/include/image.mk +++ b/include/image.mk @@ -472,7 +472,8 @@ endef ifndef IB define Device/Build/initramfs $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1)) - $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) + $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) \ + $$(if $$(CONFIG_JSON_OVERVIEW_IMAGE_INFO), $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,) $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE) @@ -481,6 +482,38 @@ define Device/Build/initramfs $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare @rm -f $$@ $$(call concat_cmd,$$(KERNEL_INITRAMFS)) + + $(call Device/Export,$(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,$(1)) + + $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json: $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) + @mkdir -p $$(shell dirname $$@) + DEVICE_ID="$(1)" \ + BIN_DIR="$(BIN_DIR)" \ + SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \ + IMAGE_NAME="$$(notdir $$^)" \ + IMAGE_TYPE="kernel" \ + IMAGE_FILESYSTEM="initramfs" \ + IMAGE_PREFIX="$$(IMAGE_PREFIX)" \ + DEVICE_VENDOR="$$(DEVICE_VENDOR)" \ + DEVICE_MODEL="$$(DEVICE_MODEL)" \ + DEVICE_VARIANT="$$(DEVICE_VARIANT)" \ + DEVICE_ALT0_VENDOR="$$(DEVICE_ALT0_VENDOR)" \ + DEVICE_ALT0_MODEL="$$(DEVICE_ALT0_MODEL)" \ + DEVICE_ALT0_VARIANT="$$(DEVICE_ALT0_VARIANT)" \ + DEVICE_ALT1_VENDOR="$$(DEVICE_ALT1_VENDOR)" \ + DEVICE_ALT1_MODEL="$$(DEVICE_ALT1_MODEL)" \ + DEVICE_ALT1_VARIANT="$$(DEVICE_ALT1_VARIANT)" \ + DEVICE_ALT2_VENDOR="$$(DEVICE_ALT2_VENDOR)" \ + DEVICE_ALT2_MODEL="$$(DEVICE_ALT2_MODEL)" \ + DEVICE_ALT2_VARIANT="$$(DEVICE_ALT2_VARIANT)" \ + DEVICE_TITLE="$$(DEVICE_TITLE)" \ + DEVICE_PACKAGES="$$(DEVICE_PACKAGES)" \ + TARGET="$(BOARD)" \ + SUBTARGET="$(if $(SUBTARGET),$(SUBTARGET),generic)" \ + VERSION_NUMBER="$(VERSION_NUMBER)" \ + VERSION_CODE="$(VERSION_CODE)" \ + SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \ + $(TOPDIR)/scripts/json_add_image_info.py $$@ endef endif From bb8fd58a23d202ce115813468e9119a631507f86 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 24 Feb 2021 21:38:15 +0100 Subject: [PATCH 02/12] build: avoid generating JSON info on missing image Previously, build would fail for targets containing devices with not initramfs image (such as mpc85xx-p1010). Only generate the JSON image info for the initramfs image when we have one to avoid breaking the builds. Fixes commit d3140d052964 ("build/json: generate json file for initramfs") Signed-off-by: David Bauer (cherry picked from commit 512229ce4967814a09ce202855e6b632d2e97a3c) --- include/image.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/image.mk b/include/image.mk index e602f2f4e9..8cfd2155f3 100644 --- a/include/image.mk +++ b/include/image.mk @@ -472,8 +472,8 @@ endef ifndef IB define Device/Build/initramfs $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1)) - $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) \ - $$(if $$(CONFIG_JSON_OVERVIEW_IMAGE_INFO), $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,) + $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) \ + $$(if $$(CONFIG_JSON_OVERVIEW_IMAGE_INFO), $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,)) $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE) From 3f5109f5386577a436f7eaf5be592cae16faf858 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Mon, 8 Mar 2021 14:12:53 +0100 Subject: [PATCH 03/12] arc770: set device vendor and model variables This fixes the profiles.json output. Signed-off-by: Moritz Warning (cherry picked from commit d00bbd9de0719eededc7ee6a7cb2d8f4de6e4540) --- target/linux/arc770/image/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/arc770/image/Makefile b/target/linux/arc770/image/Makefile index 172eb06744..4cb9364ef3 100644 --- a/target/linux/arc770/image/Makefile +++ b/target/linux/arc770/image/Makefile @@ -24,6 +24,8 @@ endef define Device/nsim $(call Device/vmlinux) + DEVICE_VENDOR := Synopsys + DEVICE_MODEL := nSIM DEVICE_PROFILE := nsim DEVICE_DTS := nsim_700 endef From c4926a425520748212298be8535c1a3852cc4bc2 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Mon, 8 Mar 2021 16:34:25 +0100 Subject: [PATCH 04/12] archs38: set device vendor and model variables This fixes the profiles.json output. Signed-off-by: Moritz Warning (cherry picked from commit cc54f65daa6101721c068cd00fdead1815db0bbf) --- target/linux/archs38/image/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/archs38/image/Makefile b/target/linux/archs38/image/Makefile index e8cfb63ce1..1d0beca27f 100644 --- a/target/linux/archs38/image/Makefile +++ b/target/linux/archs38/image/Makefile @@ -24,6 +24,8 @@ endef define Device/nsim_hs $(call Device/vmlinux) + DEVICE_VENDOR := Synopsys + DEVICE_MODEL := nSIM HS DEVICE_PROFILE := nsim_hs DEVICE_DTS := nsim_hs_idu endef From 0b0bec56ea1ac97098a7a546df2ebd62f7011129 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sun, 28 Mar 2021 03:29:59 +0200 Subject: [PATCH 05/12] ipq806x: improve system latency Various report and data show that the freq 384000 is too low and cause some extra latency to the entire system. OEM qsdk code also set the min frequency for this target to 800 mhz. Also some user notice some instability with this idle frequency, solved by setting the min frequency to 600mhz. Fix all these kind of problem by introducing a boot init.d script that set the min frequency to 600mhz and set the ondemand governor to be more aggressive. The script set these value only if the ondemand governor is detected. 384 mhz freq is still available and user can decide to restore the old behavior by disabling this script. Signed-off-by: Ansuel Smith (cherry picked from commit 861b82d36ae43efec8d16e61b82482e38996af92) --- .../linux/ipq806x/base-files/etc/init.d/cpufreq | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 target/linux/ipq806x/base-files/etc/init.d/cpufreq diff --git a/target/linux/ipq806x/base-files/etc/init.d/cpufreq b/target/linux/ipq806x/base-files/etc/init.d/cpufreq new file mode 100755 index 0000000000..19278902ed --- /dev/null +++ b/target/linux/ipq806x/base-files/etc/init.d/cpufreq @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common + +START=15 + +boot() { + local governor + + governor=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor) + + if [ "$governor" = "ondemand" ]; then + # Effective only with ondemand + echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 600000 > /sys/devices/system/cpu/cpufreq/policy1/scaling_min_freq + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + fi +} From 6b6bcca1a05315c019eb55bec2b460a54c65ba1e Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Tue, 18 May 2021 15:36:10 +0200 Subject: [PATCH 06/12] busybox: use $(AUTORELEASE) and SPDX use AUTORELEASE since BusyBox is often updaten and PKG_RELEASE is not consistently bumped. Also use SPDX license headers to be machine readable and bump the copyright year to 2021. Signed-off-by: Paul Spooren (cherry picked from commit 25fdb42249aef7b5eb53675f82f0091c532bf90c) --- package/utils/busybox/Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 475a154fa3..0d5e420943 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -1,15 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later # -# Copyright (C) 2006-2020 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# +# Copyright (C) 2006-2021 OpenWrt.org include $(TOPDIR)/rules.mk PKG_NAME:=busybox PKG_VERSION:=1.33.1 -PKG_RELEASE:=1 +PKG_RELEASE:=$(AUTORELEASE) PKG_FLAGS:=essential PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 From 4b691077e0ae658c3c3d4fc625b09a5b9f01f99d Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Thu, 13 May 2021 23:57:45 +0200 Subject: [PATCH 07/12] busybox: show reproducible timestamp On login busybox shows a timestamp per default contianing the build date. Since the build date isn't reproducible per default this behaviour was disabled by default via 34df4d40 "busybox: disable timestamp in version". This commit modifies busybox so that the printed timestamp reproducible using SOURCE_DATE_EPOCH and therefore shouldn't be disabled anymore. Before: BusyBox v1.33.1 () built-in shell (ash) After: BusyBox v1.33.1 (2021-05-13 09:34:34 UTC) built-in shell (ash) Signed-off-by: Paul Spooren (cherry picked from commit a725382978515abfb2eb7be3bafef735dca97dbd) --- package/utils/busybox/Makefile | 4 - ...ATE_EPOCH-for-timestamp-if-available.patch | 80 +++++++++++++++++++ 2 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 0d5e420943..7ac042e9f7 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -81,10 +81,6 @@ endef Package/busybox-selinux/conffiles = $(Package/busybox/conffiles) endif -# don't create a version string containing the actual timestamp -export KCONFIG_NOTIMESTAMP=1 - - ifndef CONFIG_USE_MUSL LDLIBS:=m crypt endif diff --git a/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch b/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch new file mode 100644 index 0000000000..af473622ed --- /dev/null +++ b/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch @@ -0,0 +1,80 @@ +From 59f773ee81a8945321f4aa20abc5e9577e6483e4 Mon Sep 17 00:00:00 2001 +From: Paul Spooren +Date: Thu, 13 May 2021 11:25:34 +0200 +Subject: [PATCH] use SOURCE_DATE_EPOCH for timestamp if available + +The SOURCE_DATE_EPOCH is an effort of the Reproducible Builds +organization to make timestamps/build dates in compiled tools +deterministic over several repetitive builds. + +Busybox shows by default the build date timestamp which changes whenever +compiled. To have a reasonable accurate build date while staying +reproducible, it's possible to use the *date of last source +modification* rather than the current time and date. + +Further information on SOURCE_DATE_EPOCH are available online [1]. + +This patch modifies `confdata.c` so that the content of the +SOURCE_DATE_EPOCH env variable is used as timestamp. + +To be independent of different timezones between builds, whenever +SOURCE_DATE_EPOCH is defined the GMT time is used. + +[1]: https://reproducible-builds.org/docs/source-date-epoch/ + +Signed-off-by: Paul Spooren +--- + scripts/kconfig/confdata.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index b05b96e45..73c25e3a8 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -342,6 +342,8 @@ int conf_write(const char *name) + time_t now; + int use_timestamp = 1; + char *env; ++ char *source_date_epoch; ++ struct tm *build_time; + + dirname[0] = 0; + if (name && name[0]) { +@@ -378,7 +380,16 @@ int conf_write(const char *name) + } + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); +- time(&now); ++ ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch && *source_date_epoch) { ++ now = strtoull(source_date_epoch, NULL, 10); ++ build_time = gmtime(&now); ++ } else { ++ time(&now); ++ build_time = localtime(&now); ++ } ++ + env = getenv("KCONFIG_NOTIMESTAMP"); + if (env && *env) + use_timestamp = 0; +@@ -398,14 +409,14 @@ int conf_write(const char *name) + if (use_timestamp) { + size_t ret = \ + strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " +- "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now)); ++ "\"%Y-%m-%d %H:%M:%S %Z\"\n", build_time); + /* if user has Factory timezone or some other odd install, the + * %Z above will overflow the string leaving us with undefined + * results ... so let's try again without the timezone. + */ + if (ret == 0) + strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " +- "\"%Y-%m-%d %H:%M:%S\"\n", localtime(&now)); ++ "\"%Y-%m-%d %H:%M:%S\"\n", build_time); + } else { /* bbox */ + strcpy(buf, "#define AUTOCONF_TIMESTAMP \"\"\n"); + } +-- +2.30.2 + From 892fc7caa9eee9f5ef9e172677f871c02841bae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Sat, 15 May 2021 21:06:27 +0200 Subject: [PATCH 08/12] base-files: generate "device" UCI type section for bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This switches from the old way of defining bridges in an "interface" UCI section type (that should be used for layer 3 only). From now a defualt board switch will have its own "device" UCI section type. It's a new & preferred way of defining L2 devices. Before: config interface 'lan' option type 'bridge' option ifname 'lan1 lan2 lan3 lan4' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' After: config device option name 'lan' option type 'bridge' list ports 'lan1' list ports 'lan2' list ports 'lan3' list ports 'lan4' config interface 'lan' option ifname 'lan' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' Signed-off-by: Rafał Miłecki (cherry picked from commit 43fc720657c6e3b30c6ed89d7227ee6e646c158b) --- package/base-files/files/bin/config_generate | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 56f6c4423b..0f6f280cf0 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -110,8 +110,14 @@ generate_network() { } [ -n "$ports" ] && { - type="bridge" - ifname="$ports" + uci -q batch <<-EOF + add network device + set network.@device[-1].name='$1' + set network.@device[-1].type='bridge' + EOF + for port in $ports; do uci add_list network.@device[-1].ports="$port"; done + ifname=$1 + type= } [ -n "$bridge" ] && { From 0d90023633248791bbeb8d2b21669c1f9a5a9a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 20 May 2021 10:32:18 +0200 Subject: [PATCH 09/12] base-files: generate bridge device sections with br- name prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Missing br- prefix could result in name conflict between DSA port interface and bridge interface. Some devices with just one LAN port use "lan" interface name for DSA port. Trying to create bridge with the same "lan" name was failing. Reported-by: David Bauer Fixes: 43fc720657c6 ("base-files: generate "device" UCI type section for bridge") Signed-off-by: Rafał Miłecki (cherry picked from commit 0e459668c5b3b158991803204f628b1b7dce9034) --- package/base-files/files/bin/config_generate | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 0f6f280cf0..efcd734242 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -112,11 +112,11 @@ generate_network() { [ -n "$ports" ] && { uci -q batch <<-EOF add network device - set network.@device[-1].name='$1' + set network.@device[-1].name='br-$1' set network.@device[-1].type='bridge' EOF for port in $ports; do uci add_list network.@device[-1].ports="$port"; done - ifname=$1 + ifname=br-$1 type= } From fc605c01f6d1fd8e2aa8ede83b03ae87f12524a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 24 May 2021 07:46:12 +0200 Subject: [PATCH 10/12] base-files: support setting bridge MAC address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 43fc720657c6 ("base-files: generate "device" UCI type section for bridge") Signed-off-by: Rafał Miłecki (cherry picked from commit 7a90ad3c431031191afe51b163bf97d3ec820d54) --- package/base-files/files/bin/config_generate | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index efcd734242..604c49a709 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -114,10 +114,12 @@ generate_network() { add network device set network.@device[-1].name='br-$1' set network.@device[-1].type='bridge' + set network.@device[-1].macaddr='$macaddr' EOF for port in $ports; do uci add_list network.@device[-1].ports="$port"; done ifname=br-$1 type= + macaddr="" } [ -n "$bridge" ] && { From 77d96e925fef1010f3d94a7cc722d23efd243b1e Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Sun, 23 May 2021 20:30:58 +0900 Subject: [PATCH 11/12] base-files: fix configuration generation of network if "bridge" exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the commit 43fc720657c6e3b30c6ed89d7227ee6e646c158b ("base-files: generate "device UCI type section for bridge"), the wrong network configuration is generated for the devices that already have the bridge device section for VLAN, such as the devices in realtek target. As a result, the bridge device by additional "device" section is specified to the "ports" option in the "bridge-vlan" section and netifd shuts down the switch and the ethernet when the network service started. Fixes: 43fc720657 ("base-files: generate "device" UCI type section for bridge") Signed-off-by: INAGAKI Hiroshi [rmilecki: use $ports for generate_bridge_vlan argument] Signed-off-by: Rafał Miłecki (cherry picked from commit 8cc4e87a2f81df02dbe481759ae6c36cf056c13b) --- package/base-files/files/bin/config_generate | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 604c49a709..be688a4ba3 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -109,7 +109,7 @@ generate_network() { ports="$ifname" } - [ -n "$ports" ] && { + [ -n "$ports" -a -z "$bridge" ] && { uci -q batch <<-EOF add network device set network.@device[-1].name='br-$1' @@ -123,11 +123,12 @@ generate_network() { } [ -n "$bridge" ] && { + [ -z "$ports" ] && ports="$ifname" if [ -z "$vlan" ]; then bridge_vlan_id=$((bridge_vlan_id + 1)) vlan=$bridge_vlan_id fi - generate_bridge_vlan $1 $bridge "$ifname" $vlan + generate_bridge_vlan $1 $bridge "$ports" $vlan ifname=$bridge.$vlan type="" } From 16ccf888ee70c65aa4943641e4b8e74e52dc1930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 24 May 2021 16:45:06 +0200 Subject: [PATCH 12/12] base-files: generate network config with "device" options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace "ifname" with "device" as netifd has been recently patches to used the later one. It's more clear and accurate. Signed-off-by: Rafał Miłecki (cherry picked from commit 4b9a67362d70c544b85078b8d5c661f43f7472d9) --- package/base-files/files/bin/config_generate | 26 +++++++++---------- .../files/lib/functions/uci-defaults.sh | 10 +++---- .../gemini/base-files/etc/board.d/02_network | 6 ++--- .../realtek/base-files/etc/board.d/02_network | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index be688a4ba3..d895090309 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -40,7 +40,7 @@ generate_static_network() { uci -q batch <<-EOF delete network.loopback set network.loopback='interface' - set network.loopback.ifname='lo' + set network.loopback.device='lo' set network.loopback.proto='static' set network.loopback.ipaddr='127.0.0.1' set network.loopback.netmask='255.0.0.0' @@ -91,22 +91,22 @@ generate_static_network() { addr_offset=2 generate_network() { - local ports ifname macaddr protocol type ipaddr netmask vlan + local ports device macaddr protocol type ipaddr netmask vlan local bridge=$2 json_select network json_select "$1" + json_get_vars device macaddr protocol ipaddr netmask vlan json_get_values ports ports - json_get_vars ifname macaddr protocol ipaddr netmask vlan json_select .. json_select .. - [ -n "$ifname" -o -n "$ports" ] || return + [ -n "$device" -o -n "$ports" ] || return # Force bridge for "lan" as it may have other devices (e.g. wireless) # bridged [ "$1" = "lan" -a -z "$ports" ] && { - ports="$ifname" + ports="$device" } [ -n "$ports" -a -z "$bridge" ] && { @@ -117,19 +117,19 @@ generate_network() { set network.@device[-1].macaddr='$macaddr' EOF for port in $ports; do uci add_list network.@device[-1].ports="$port"; done - ifname=br-$1 + device=br-$1 type= macaddr="" } [ -n "$bridge" ] && { - [ -z "$ports" ] && ports="$ifname" + [ -z "$ports" ] && ports="$device" if [ -z "$vlan" ]; then bridge_vlan_id=$((bridge_vlan_id + 1)) vlan=$bridge_vlan_id fi generate_bridge_vlan $1 $bridge "$ports" $vlan - ifname=$bridge.$vlan + device=$bridge.$vlan type="" } @@ -137,12 +137,12 @@ generate_network() { delete network.$1 set network.$1='interface' set network.$1.type='$type' - set network.$1.ifname='$ifname' + set network.$1.device='$device' set network.$1.proto='none' EOF if [ -n "$macaddr" ]; then - for name in $ifname; do + for name in $device; do uci -q batch <<-EOF delete network.$1_${name/./_}_dev set network.$1_${name/./_}_dev='device' @@ -172,14 +172,14 @@ generate_network() { dhcp) # fixup IPv6 slave interface if parent is a bridge - [ "$type" = "bridge" ] && ifname="br-$1" + [ "$type" = "bridge" ] && device="br-$1" uci set network.$1.proto='dhcp' [ -e /proc/sys/net/ipv6 ] && { uci -q batch <<-EOF delete network.${1}6 set network.${1}6='interface' - set network.${1}6.ifname='$ifname' + set network.${1}6.device='$device' set network.${1}6.proto='dhcpv6' EOF } @@ -196,7 +196,7 @@ generate_network() { set network.$1.ipv6='1' delete network.${1}6 set network.${1}6='interface' - set network.${1}6.ifname='@${1}' + set network.${1}6.device='@${1}' set network.${1}6.proto='dhcpv6' EOF } diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 407a9c710f..02882f43ca 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -39,7 +39,7 @@ ucidef_set_interface() { [ -n "$opt" -a -n "$val" ] || break - [ "$opt" = "ifname" -a "$val" != "${val/ //}" ] && { + [ "$opt" = "device" -a "$val" != "${val/ //}" ] && { json_select_array "ports" for e in $val; do json_add_string "" "$e"; done json_close_array @@ -79,11 +79,11 @@ ucidef_set_compat_version() { } ucidef_set_interface_lan() { - ucidef_set_interface "lan" ifname "$1" protocol "${2:-static}" + ucidef_set_interface "lan" device "$1" protocol "${2:-static}" } ucidef_set_interface_wan() { - ucidef_set_interface "wan" ifname "$1" protocol "${2:-dhcp}" + ucidef_set_interface "wan" device "$1" protocol "${2:-dhcp}" } ucidef_set_interfaces_lan_wan() { @@ -201,14 +201,14 @@ _ucidef_finish_switch_roles() { json_select_object "$role" # attach previous interfaces (for multi-switch devices) - json_get_var devices ifname + json_get_var devices device if ! list_contains devices "$device"; then devices="${devices:+$devices }$device" fi json_select .. json_select .. - ucidef_set_interface "$role" ifname "$devices" + ucidef_set_interface "$role" device "$devices" done } diff --git a/target/linux/gemini/base-files/etc/board.d/02_network b/target/linux/gemini/base-files/etc/board.d/02_network index f371956a66..9e80fee758 100755 --- a/target/linux/gemini/base-files/etc/board.d/02_network +++ b/target/linux/gemini/base-files/etc/board.d/02_network @@ -7,17 +7,17 @@ board_config_update case "$(board_name)" in dlink,dir-685) # These are all connected to eth0 thru RTL8366RB - ucidef_set_interface "eth" ifname "eth0" protocol "none" + ucidef_set_interface "eth" device "eth0" protocol "none" ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan" ;; itian,sq201) # These are all connected to eth1 thru VSC7395 - ucidef_set_interface "eth" ifname "eth1" protocol "none" + ucidef_set_interface "eth" device "eth1" protocol "none" ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth0" ;; storlink,gemini324) # These are all connected to eth1 thru VSC7385 - ucidef_set_interface "eth" ifname "eth1" protocol "none" + ucidef_set_interface "eth" device "eth1" protocol "none" ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth0" ;; esac diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index 2568fd2e0e..45ab84ee9e 100755 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -24,7 +24,7 @@ for lan in /sys/class/net/lan*; do done ucidef_set_bridge_device switch ucidef_set_interface_wan "$lan_list" -ucidef_set_interface "lan" ifname "lan1:t" protocol "static" vlan 100 +ucidef_set_interface "lan" device "lan1:t" protocol "static" vlan 100 lan_mac="" wan_mac=""