[openwrt/openwrt] base-files: add ucidef_set_interface_netdev_range function
LEDE Commits
lede-commits at lists.infradead.org
Mon Oct 6 10:06:33 PDT 2025
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/055d877a207afa6a270c6bee7e7f92969a41d66e
commit 055d877a207afa6a270c6bee7e7f92969a41d66e
Author: Til Kaiser <mail at tk154.de>
AuthorDate: Fri Nov 22 15:20:10 2024 +0100
base-files: add ucidef_set_interface_netdev_range function
The ucidef_set_interface* functions can be used to
add network interfaces to a default network configuration.
Such network interfaces often have the same base interface
name (e.g., eth* or lan*). On devices with many network ports,
adding all ports to the default config can become inconvenient.
This commit adds a new uci function ucidef_set_interface_netdev_range,
which adds network interfaces for a specific port range to a given
OpenWrt interface. The first parameter is the OpenWrt interface, the
second is the base interface name, the third is the port start, and
the fourth is the port end range.
Signed-off-by: Til Kaiser <mail at tk154.de>
Link: https://github.com/openwrt/openwrt/pull/17251
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../base-files/files/lib/functions/uci-defaults.sh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 5293ce12c0..f77ce4ab27 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -771,6 +771,27 @@ ucidef_add_wlan() {
ucidef_wlan_idx="$((ucidef_wlan_idx + 1))"
}
+ucidef_set_interface_netdev_range() {
+ local interface="$1"
+ local base_netdev="$2"
+ local start="$3"
+ local stop="$4"
+ local netdevs
+ local i
+
+ if [ "$stop" -ge "$start" ]; then
+ i="$start"
+ netdevs="$base_netdev$i"
+
+ while [ "$i" -lt "$stop" ]; do
+ i=$((i + 1))
+ netdevs="$netdevs $base_netdev$i"
+ done
+
+ ucidef_set_interface "$interface" device "$netdevs"
+ fi
+}
+
board_config_update() {
json_init
[ -f ${CFG} ] && json_load "$(cat ${CFG})"
More information about the lede-commits
mailing list