[PATCH 2/2] package: replace remaining occurrences of ifconfig with ip

Adrian Schmutzler freifunk at adrianschmutzler.de
Thu Jul 30 11:25:21 EDT 2020


ifconfig is effectively deprecated for quite some time now. Let's
replace the remaining occurrences for our target setup by the
corresponding ip commands now.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 .../config/netifd/files/usr/share/udhcpc/default.script     | 6 +++---
 .../config/qos-scripts/files/usr/lib/qos/generate.sh        | 2 +-
 2 files changed, 4 insertions(+), 4 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 ac765a6363..0a9eb0180e 100755
--- a/package/network/config/netifd/files/usr/share/udhcpc/default.script
+++ b/package/network/config/netifd/files/usr/share/udhcpc/default.script
@@ -14,8 +14,8 @@ set_classless_routes() {
 }
 
 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:-+}
+	echo "udhcpc: ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface"
+	ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface
 
 	[ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && {
 		echo "udhcpc: setting default routers: $router"
@@ -41,7 +41,7 @@ setup_interface() {
 applied=
 case "$1" in
 	deconfig)
-		ifconfig "$interface" 0.0.0.0
+		ip -4 addr flush dev "$interface"
 	;;
 	renew)
 		setup_interface update
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
index 024be0c170..32f15581f8 100755
--- a/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
@@ -326,7 +326,7 @@ start_interface() {
 			append cstr "$classnr:$prio:$avgrate:$pktsize:$pktdelay:$maxrate:$qdisc:$filter" "$N"
 		done
 		append ${prefix}q "$(tcrules)" "$N"
-		export dev_${dir}="ifconfig $dev up >&- 2>&-
+		export dev_${dir}="ip link set $dev up >&- 2>&-
 tc qdisc del dev $dev root >&- 2>&-
 tc qdisc add dev $dev root handle 1: hfsc default ${class_default}0
 tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${rate}kbit"
-- 
2.20.1




More information about the openwrt-devel mailing list