Skip to content

Commit 055d877

Browse files
tk154robimarko
authored andcommitted
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@tk154.de> Link: openwrt/openwrt#17251 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 8edcd77 commit 055d877

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

package/base-files/files/lib/functions/uci-defaults.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,27 @@ ucidef_add_wlan() {
771771
ucidef_wlan_idx="$((ucidef_wlan_idx + 1))"
772772
}
773773

774+
ucidef_set_interface_netdev_range() {
775+
local interface="$1"
776+
local base_netdev="$2"
777+
local start="$3"
778+
local stop="$4"
779+
local netdevs
780+
local i
781+
782+
if [ "$stop" -ge "$start" ]; then
783+
i="$start"
784+
netdevs="$base_netdev$i"
785+
786+
while [ "$i" -lt "$stop" ]; do
787+
i=$((i + 1))
788+
netdevs="$netdevs $base_netdev$i"
789+
done
790+
791+
ucidef_set_interface "$interface" device "$netdevs"
792+
fi
793+
}
794+
774795
board_config_update() {
775796
json_init
776797
[ -f ${CFG} ] && json_load "$(cat ${CFG})"

0 commit comments

Comments
 (0)