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>
			
			
This commit is contained in:
		| @@ -91,21 +91,28 @@ generate_static_network() { | |||||||
|  |  | ||||||
| addr_offset=2 | addr_offset=2 | ||||||
| generate_network() { | generate_network() { | ||||||
| 	local ifname macaddr protocol type ipaddr netmask vlan | 	local ports ifname macaddr protocol type ipaddr netmask vlan | ||||||
| 	local bridge=$2 | 	local bridge=$2 | ||||||
|  |  | ||||||
| 	json_select network | 	json_select network | ||||||
| 		json_select "$1" | 		json_select "$1" | ||||||
|  | 			json_get_values ports ports | ||||||
| 			json_get_vars ifname macaddr protocol ipaddr netmask vlan | 			json_get_vars ifname macaddr protocol ipaddr netmask vlan | ||||||
| 		json_select .. | 		json_select .. | ||||||
| 	json_select .. | 	json_select .. | ||||||
|  |  | ||||||
| 	[ -n "$ifname" ] || return | 	[ -n "$ifname" -o -n "$ports" ] || return | ||||||
|  |  | ||||||
| 	# force bridge for multi-interface devices (and lan) | 	# Force bridge for "lan" as it may have other devices (e.g. wireless) | ||||||
| 	case "$1:$ifname" in | 	# bridged | ||||||
| 		*\ * | lan:*) type="bridge" ;; | 	[ "$1" = "lan" -a -z "$ports" ] && { | ||||||
| 	esac | 		ports="$ifname" | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	[ -n "$ports" ] && { | ||||||
|  | 		type="bridge" | ||||||
|  | 		ifname="$ports" | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	[ -n "$bridge" ] && { | 	[ -n "$bridge" ] && { | ||||||
| 		if [ -z "$vlan" ]; then | 		if [ -z "$vlan" ]; then | ||||||
|   | |||||||
| @@ -39,7 +39,13 @@ ucidef_set_interface() { | |||||||
|  |  | ||||||
| 		[ -n "$opt" -a -n "$val" ] || break | 		[ -n "$opt" -a -n "$val" ] || break | ||||||
|  |  | ||||||
|  | 		[ "$opt" = "ifname" -a "$val" != "${val/ //}" ] && { | ||||||
|  | 			json_select_array "ports" | ||||||
|  | 			for e in $val; do json_add_string "" "$e"; done | ||||||
|  | 			json_close_array | ||||||
|  | 		} || { | ||||||
| 			json_add_string "$opt" "$val" | 			json_add_string "$opt" "$val" | ||||||
|  | 		} | ||||||
| 	done | 	done | ||||||
|  |  | ||||||
| 	if ! json_is_a protocol string; then | 	if ! json_is_a protocol string; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rafał Miłecki
					Rafał Miłecki