brcm47xx: add support for ipv6 in default network config

Modify /etc/init.d/netconfig to use UCI defaults for building the
default network config, which includes appropriate defaults for IPV6.

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

SVN-Revision: 38294
This commit is contained in:
Hauke Mehrtens 2013-10-02 23:22:18 +00:00
parent caff3b5aee
commit 97b15fc45b

View file

@ -43,28 +43,17 @@ start() {
mkdir -p /etc/config mkdir -p /etc/config
( local cpuport=5
[ -e /sbin/swconfig ] && cpuport=$(swconfig dev switch0 help 2>/dev/null | sed -ne "s|.*cpu @ \([0-9]*\).*|\1|p")
local network_defs=`(
if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
# WGT634u # WGT634u
echo boardtype=wgt634u echo boardtype=wgt634u
else else
strings "$(find_mtd_part nvram)" strings "$(find_mtd_part nvram)"
fi fi
) | awk ' ) | awk -v cpuport="$cpuport" '
function p(cfgname, name) {
if (c[name] != "") print " option " cfgname " \"" c[name] "\""
}
function vlan(id, name) {
if (c[name] != "") {
print "config switch_vlan eth0_" id
print " option device \"eth0\""
print " option vlan " id
print " option ports \"" c[name] "\""
print ""
}
}
function macinc(mac, maca, i, result) { function macinc(mac, maca, i, result) {
split(mac, maca, ":") split(mac, maca, ":")
for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i] for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
@ -91,12 +80,6 @@ start() {
if (mac_check != "") mac_check = mac_check ":" if (mac_check != "") mac_check = mac_check ":"
mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]" mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]"
} }
if (system("[ -d /proc/switch/eth0 ] ") == 0) {
getline cpuport < "/proc/switch/eth0/cpuport"
}
if (system("command -v swconfig > /dev/null") == 0) {
"swconfig dev switch0 help \| sed -ne \"s\|.*cpu @ \\([0-9]*\\).*\|\\1\|p\"" | getline cpuport
}
if (cpuport == "8") { if (cpuport == "8") {
c["vlan1ports"]="1 2 3 4 8t" c["vlan1ports"]="1 2 3 4 8t"
c["vlan2ports"]="0 8t" c["vlan2ports"]="0 8t"
@ -225,43 +208,42 @@ start() {
c["vlan1ports"] = "" c["vlan1ports"] = ""
c["vlan2ports"] = "" c["vlan2ports"] = ""
} }
print "local vlan1ports=\"" c["vlan1ports"] "\";"
print "local vlan2ports=\"" c["vlan2ports"] "\";"
print "local lan_ifname=\"" c["lan_ifname"] "\";"
print "local lan_macaddr=\"" c["lan_macaddr"] "\";"
print "local wan_ifname=\"" c["wan_ifname"] "\";"
print "local wan_macaddr=\"" c["wan_macaddr"] "\";"
}'`
if (c["vlan1ports"] || c["vlan2ports"]) { . /lib/functions/uci-defaults.sh
print "#### VLAN configuration "
print "config switch eth0" touch /etc/config/network
print " option enable 1"
print "" eval "$network_defs"
vlan(1, "vlan1ports")
vlan(2, "vlan2ports") [ -n "$vlan1ports" -o -n "$vlan2ports" ] && {
local cfg=`ucidef_add_switch "switch0" 1 1`
[ -n "$cfg" ] && uci rename network.$cfg=eth0
[ -n "$vlan1ports" ] && {
cfg=`ucidef_add_switch_vlan "switch0" 1 "$vlan1ports"`
[ -n "$cfg" ] && uci rename network.$cfg=eth0_1
} }
print "#### Loopback configuration" [ -n "$vlan2ports" ] && {
print "config interface loopback" cfg=`ucidef_add_switch_vlan "switch0" 2 "$vlan2ports"`
print " option ifname \"lo\"" [ -n "$cfg" ] && uci rename network.$cfg=eth0_2
print " option proto static"
print " option ipaddr 127.0.0.1"
print " option netmask 255.0.0.0"
print ""
print ""
print "#### LAN configuration"
print "config interface lan"
print " option type bridge"
p("ifname", "lan_ifname")
p("macaddr", "lan_macaddr")
print " option proto static"
print " option ipaddr 192.168.1.1"
print " option netmask 255.255.255.0"
print ""
print ""
if (c["wan_ifname"]) {
print "#### WAN configuration"
print "config interface wan"
p("ifname", "wan_ifname")
p("macaddr", "wan_macaddr")
print " option proto dhcp"
} else {
print "#### WAN configuration (disabled)"
print "#config interface wan"
print "# option proto dhcp"
} }
}' > /etc/config/network }
ucidef_set_interface_loopback
ucidef_set_interface_lan "$lan_ifname"
[ -n "$lan_macaddr" ] && ucidef_set_interface_macaddr lan "$lan_macaddr"
[ -n "$wan_ifname" ] && {
ucidef_set_interface_wan "$wan_ifname"
[ -n "$wan_macaddr" ] && ucidef_set_interface_macaddr wan "$wan_macaddr"
}
uci commit network
} }