aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/bin
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2021-05-14 11:09:57 +0200
committerRafał Miłecki <rafal@milecki.pl>2021-05-18 12:30:16 +0200
commitd42640e389a8b22a31fb0061c12cd9dfbddb87b8 (patch)
treef0fb4c32ef19e1c90a6d1f596fca22c31a94eb97 /package/base-files/files/bin
parent097dc943f1f9b02835c6b249b2a035679da5619f (diff)
downloadupstream-d42640e389a8b22a31fb0061c12cd9dfbddb87b8.tar.gz
upstream-d42640e389a8b22a31fb0061c12cd9dfbddb87b8.tar.bz2
upstream-d42640e389a8b22a31fb0061c12cd9dfbddb87b8.zip
base-files: use "ports" array in board.json network for bridges
Bridge aggregates multiple ports so use a more accurate name ("ports") and format (array) for storing them in board.json. Example: "network": { "lan": { "ports": [ "lan1", "lan2", "lan3", "lan4" ], "protocol": "static" }, "wan": { "ifname": "wan", "protocol": "dhcp" } } Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/base-files/files/bin')
-rwxr-xr-xpackage/base-files/files/bin/config_generate19
1 files changed, 13 insertions, 6 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index ee3958e733..56f6c4423b 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -91,21 +91,28 @@ generate_static_network() {
addr_offset=2
generate_network() {
- local ifname macaddr protocol type ipaddr netmask vlan
+ local ports ifname macaddr protocol type ipaddr netmask vlan
local bridge=$2
json_select network
json_select "$1"
+ json_get_values ports ports
json_get_vars ifname macaddr protocol ipaddr netmask vlan
json_select ..
json_select ..
- [ -n "$ifname" ] || return
+ [ -n "$ifname" -o -n "$ports" ] || return
- # force bridge for multi-interface devices (and lan)
- case "$1:$ifname" in
- *\ * | lan:*) type="bridge" ;;
- esac
+ # Force bridge for "lan" as it may have other devices (e.g. wireless)
+ # bridged
+ [ "$1" = "lan" -a -z "$ports" ] && {
+ ports="$ifname"
+ }
+
+ [ -n "$ports" ] && {
+ type="bridge"
+ ifname="$ports"
+ }
[ -n "$bridge" ] && {
if [ -z "$vlan" ]; then