On Sun, 22 Sep 2013 13:21:10 +0200
Hauke Mehrtens <ha...@hauke-m.de> wrote:

A couple of questions below...

> On 09/22/2013 09:04 AM, Nathan Hintz wrote:
> > Modify /etc/init.d/netconfig to use UCI defaults for building the
> > default network config, which includes appropriate defaults for IPV6.
> 
> This sounds good, I will test it tomorrow, I do not have access to a
> device currently.
> 
> > Signed-off-by: Nathan Hintz <nlhi...@hotmail.com>
> > ---
> >  .../linux/brcm47xx/base-files/etc/init.d/netconfig | 99 
> > +++++++++-------------
> >  1 file changed, 41 insertions(+), 58 deletions(-)
> > 
> > diff --git a/target/linux/brcm47xx/base-files/etc/init.d/netconfig 
> > b/target/linux/brcm47xx/base-files/etc/init.d/netconfig
> > index e420adb..2bf62c8 100755
> > --- a/target/linux/brcm47xx/base-files/etc/init.d/netconfig
> > +++ b/target/linux/brcm47xx/base-files/etc/init.d/netconfig
> > @@ -43,28 +43,18 @@ start() {
> >  
> >     mkdir -p /etc/config
> >  
> > -   (
> > +   local cpuport=5
> > +   [ -d /proc/switch/eth0 ] && cpuport=$(cat /proc/switch/eth0/cpuport)
> 
> You can remove support for the old switch driver in /proc/switch/.
> 
I will remove the line above.

> > +   [ -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
> >                     # WGT634u
> >                     echo boardtype=wgt634u
> >             else
> >                     strings "$(find_mtd_part nvram)"
> >             fi
> > -   ) | awk '
> > -   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 ""
> > -           }
> > -   }
> > -
> > +   ) | awk -v cpuport="$cpuport" '
> >     function macinc(mac, maca, i, result) {
> >             split(mac, maca, ":")
> >             for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
> > @@ -91,12 +81,6 @@ start() {
> >                     if (mac_check != "") mac_check = mac_check ":"
> >                     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") {
> >                     c["vlan1ports"]="1 2 3 4 8t"
> >                     c["vlan2ports"]="0 8t"
> > @@ -225,43 +209,42 @@ start() {
> >                     c["vlan1ports"] = ""
> >                     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"] "\";"
> > +   }'`
> > +
> > +   . /lib/functions/uci-defaults.sh
> >  
> > -           if (c["vlan1ports"] || c["vlan2ports"]) {
> > -                   print "#### VLAN configuration "
> > -                   print "config switch eth0"
> > -                   print " option enable   1"
> > -                   print ""
> > -                   vlan(1, "vlan1ports")
> > -                   vlan(2, "vlan2ports")
> > +   touch /etc/config/network
> > +
> > +   eval "$network_defs"
> > +
> > +   [ -n "$vlan1ports" -o -n "$vlan2ports" ] && {
> > +           local cfg=`ucidef_add_switch "eth0" 1 1`
> > +           [ -n "$cfg" ] && uci rename network.$cfg=eth0
> > +           [ -n "$vlan1ports" ] && {
> > +                   cfg=`ucidef_add_switch_vlan "eth0" 1 "$vlan1ports"`
> > +                   [ -n "$cfg" ] && uci rename network.$cfg=eth0_1

Should this be using "switch0" instead of "eth0" in the calls to 
ucidef_add_switch and
uci_add_switch_vlan (like in the call to swconfig earlier)?  It seems to work 
either way.
Is the renaming of the config sections necessary; if so, should they be changed 
to
something like "switch0_1" or "vlan1" instead of "eth0_1" as well?

> >             }
> > -           print "#### Loopback configuration"
> > -           print "config interface loopback"
> > -           print " option ifname   \"lo\""
> > -           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"
> > +           [ -n "$vlan2ports" ] && {
> > +                   cfg=`ucidef_add_switch_vlan "eth0" 2 "$vlan2ports"`
> > +                   [ -n "$cfg" ] && uci rename network.$cfg=eth0_2
> >             }
> > -   }' > /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
> >  }
> > 
> 
> 



-- 
Nathan
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to