base-files: uci-defaults-new, config_generate: allow force tagged cpu ports
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47679
This commit is contained in:
		@@ -173,7 +173,8 @@ calculate_switch_vlans() {
 | 
				
			|||||||
			if [ "$role" != "$prev_role" ]; then
 | 
								if [ "$role" != "$prev_role" ]; then
 | 
				
			||||||
				if [ -n "$vlan_ports" ]; then
 | 
									if [ -n "$vlan_ports" ]; then
 | 
				
			||||||
					let cpu_port="cpu$((vlan_off % n_cpu))"
 | 
										let cpu_port="cpu$((vlan_off % n_cpu))"
 | 
				
			||||||
					[ $n_vlan -gt $n_cpu ] && cpu_port="${cpu_port}t"
 | 
										let need_tag="tag$((vlan_off % n_cpu))"
 | 
				
			||||||
 | 
										[ $n_vlan -gt $n_cpu -o $need_tag -eq 1 ] && cpu_port="${cpu_port}t"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					uci -q batch <<-EOF
 | 
										uci -q batch <<-EOF
 | 
				
			||||||
						add network switch_vlan
 | 
											add network switch_vlan
 | 
				
			||||||
@@ -198,8 +199,9 @@ calculate_switch_vlans() {
 | 
				
			|||||||
	# autogenerate interfaces
 | 
						# autogenerate interfaces
 | 
				
			||||||
	vlan_off=0; while [ $vlan_off -lt $n_vlan ]; do
 | 
						vlan_off=0; while [ $vlan_off -lt $n_vlan ]; do
 | 
				
			||||||
		eval role="\$role$((vlan_off))"
 | 
							eval role="\$role$((vlan_off))"
 | 
				
			||||||
		eval device="\$dev$((vlan_off++ % n_cpu))"
 | 
							eval device="\$dev$((vlan_off % n_cpu))"
 | 
				
			||||||
		[ $n_vlan -gt $n_cpu ] && device="$device.$vlan_off"
 | 
							let need_tag="tag$((vlan_off++ % n_cpu))"
 | 
				
			||||||
 | 
							[ $n_vlan -gt $n_cpu -o $need_tag -eq 1 ] && device="$device.$vlan_off"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# quirk: append ifnames for subsequent switches
 | 
							# quirk: append ifnames for subsequent switches
 | 
				
			||||||
		case "$switch" in switch[1-9])
 | 
							case "$switch" in switch[1-9])
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,7 +116,7 @@ ucidef_add_switch_attr() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ucidef_add_switch_ports() {
 | 
					ucidef_add_switch_ports() {
 | 
				
			||||||
	local name="$1"; shift
 | 
						local name="$1"; shift
 | 
				
			||||||
	local port num role dev idx
 | 
						local port num role dev idx tag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	json_select_object switch
 | 
						json_select_object switch
 | 
				
			||||||
	json_select_object "$name"
 | 
						json_select_object "$name"
 | 
				
			||||||
@@ -127,6 +127,11 @@ ucidef_add_switch_ports() {
 | 
				
			|||||||
			[0-9]*@*)
 | 
								[0-9]*@*)
 | 
				
			||||||
				num="${port%%@*}"
 | 
									num="${port%%@*}"
 | 
				
			||||||
				dev="${port##*@}"
 | 
									dev="${port##*@}"
 | 
				
			||||||
 | 
									tag=0
 | 
				
			||||||
 | 
									[ "${num%t}" != "$num" ] && {
 | 
				
			||||||
 | 
										num="${num%t}"
 | 
				
			||||||
 | 
										tag=1
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			;;
 | 
								;;
 | 
				
			||||||
			[0-9]*:*:[0-9]*)
 | 
								[0-9]*:*:[0-9]*)
 | 
				
			||||||
				num="${port%%:*}"
 | 
									num="${port%%:*}"
 | 
				
			||||||
@@ -143,12 +148,13 @@ ucidef_add_switch_ports() {
 | 
				
			|||||||
			json_add_object
 | 
								json_add_object
 | 
				
			||||||
			json_add_int num "$num"
 | 
								json_add_int num "$num"
 | 
				
			||||||
			[ -n "$dev" ] && json_add_string device "$dev"
 | 
								[ -n "$dev" ] && json_add_string device "$dev"
 | 
				
			||||||
 | 
								[ -n "$tag" ] && json_add_boolean need_tag "$tag"
 | 
				
			||||||
			[ -n "$role" ] && json_add_string role "$role"
 | 
								[ -n "$role" ] && json_add_string role "$role"
 | 
				
			||||||
			[ -n "$idx" ] && json_add_int index "$idx"
 | 
								[ -n "$idx" ] && json_add_int index "$idx"
 | 
				
			||||||
			json_close_object
 | 
								json_close_object
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		unset num dev role idx
 | 
							unset num dev role idx tag
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	json_select ..
 | 
						json_select ..
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user