From: Daniel Dickinson <open...@daniel.thecshore.com>

ip from busybox is now standard and carrying both
sets of commands is undesirale, therefore move
the only consumer of ifconfig/route still in base
to using ip command.

Signed-off-by: Daniel Dickinson <open...@daniel.thecshore.com>
---
 .../netifd/files/usr/share/udhcpc/default.script     | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git 
a/package/network/config/netifd/files/usr/share/udhcpc/default.script 
b/package/network/config/netifd/files/usr/share/udhcpc/default.script
index ac765a6..9e002c8 100755
--- a/package/network/config/netifd/files/usr/share/udhcpc/default.script
+++ b/package/network/config/netifd/files/usr/share/udhcpc/default.script
@@ -5,30 +5,34 @@ set_classless_routes() {
        local max=128
        local type
        while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
-               [ ${1##*/} -eq 32 ] && type=host || type=net
                echo "udhcpc: adding route for $type $1 via $2"
-               route add -$type "$1" gw "$2" dev "$interface"
+               ip route add "$1" via "$2" dev "$interface"
                max=$(($max-1))
                shift 2
        done
 }
 
 setup_interface() {
-       echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} 
broadcast ${broadcast:-+}"
-       ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast 
${broadcast:-+}
+       local prefix="$(
+               eval "$(ipcalc.sh 0.0.0.0 ${subnet:-255.255.255.0})"
+               echo -n $PREFIX
+       )"
+               
+       echo "udhcpc: ip address add $ip/${prefix:-24} ${broadcast:-+} dev 
$interface"
+       ip address add $ip/${prefix:-24} ${broadcast:-+} dev $interface"
 
        [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != 
"255.255.255.255" ] && {
                echo "udhcpc: setting default routers: $router"
 
                local valid_gw=""
                for i in $router ; do
-                       route add default gw $i dev $interface
+                       ip route add default via $i dev $interface
                        valid_gw="${valid_gw:+$valid_gw|}$i"
                done
                
-               eval $(route -n | awk '
-                       /^0.0.0.0\W{9}('$valid_gw')\W/ {next}
-                       /^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
+               eval $(ip route | awk '
+                       /^default\Wvia\W('$valid_gw')/ {next}
+                       /^default/ {print "ip route del "$1" via "$3";"}
                ')
        }
 
-- 
2.4.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to