[OpenWrt-Devel] [PATCH] package/config/netifd: Replace ifconfig/route with ip command

Bastian Bittorf bittorf at bluebottle.com
Wed Jan 20 04:24:20 EST 2016


* Daniel Dickinson <openwrt at daniel.thecshore.com> [20.01.2016 10:18]:
> >>+	local prefix="$(
> >>+		eval "$(ipcalc.sh 0.0.0.0 ${subnet:-255.255.255.0})"
> >>+		echo -n $PREFIX
> >
> >dont use '-n'
> 
> Why not?  It prevents echo from emitting an unwanted newline.

it's not POSIX and really unneeded here (it does not matter for eval).
BTW: if you need this, use: printf '%s' "$string" or just: printf "$string"

> >>+	echo "udhcpc: ip address add $ip/${prefix:-24} ${broadcast:-+} dev $interface"
> >>+	ip address add $ip/${prefix:-24} ${broadcast:-+} dev $interface"
> >
> >please dont double-fallback. It's ok to have it once default to '255.255.255.0',
> >so just use $prefix
> 
> The second fallback is in case the interpolation fails.

ok, i will not discuss this and accept.

> >>-		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";"}
> >
> >the code leaves the default-gateway if already set and removes all other
> >default routes. i dont like the awk-approach, maybe something like:
> 
> I wasn't planning on reworking the udhcpc script beyond making it
> work with ip vs ifconfig/route.  You're talking about changing more
> unrelated things, which really should go in a separate patch.

ok.

> >the rest looks good! there are still a lot of other users
> >for route/ifconfig, but thats a good start!
> 
> Actually according to grep, only openvpn after this in base (there
> are < 10 others in packages feed as well, and I am planning on
> creating a minimalist busybox package (calling the binary e.g.
> net-tools) to supply ifconfig/route for those packages that aren't
> converted yet, or for third party use of ifconfig/route (in the
> packages feeds; doesn't belong in base).

git grep 'ifconfig'
shows a *lot* - but dont mind - thanks for your input.

bye, bastian
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list