[ewg] [PATCH] OFED scripts: Get rid of ifconfig

sebastien dugue sebastien.dugue at bull.net
Mon Feb 21 08:18:32 PST 2011


  As ifconfig is obsolete and cannot cope with IB link layer addresses,
replace all instances of ifconfig with the corresponding(s) ip commands
in ofed_scripts.

Signed-off-by: Sebastien Dugue <sebastien.dugue at bull.net>
---
 ofed_scripts/ibdev2netdev |    2 +-
 ofed_scripts/openibd      |   10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ofed_scripts/ibdev2netdev b/ofed_scripts/ibdev2netdev
index 7cffa7e..9faa4e3 100755
--- a/ofed_scripts/ibdev2netdev
+++ b/ofed_scripts/ibdev2netdev
@@ -130,7 +130,7 @@ function find_mac()
 	done
 }
 
-ifcs=$(ifconfig -a | egrep '^eth|^ib' | gawk '{print $1}')
+ifcs=$(/sbin/ip -o link  | awk -F ": " '{print $2}' | egrep '^eth|^ib')
 
 for ifc in $ifcs; do
 	len=$(cat /sys/class/net/$ifc/addr_len)
diff --git a/ofed_scripts/openibd b/ofed_scripts/openibd
index 99b8131..1cd7419 100644
--- a/ofed_scripts/openibd
+++ b/ofed_scripts/openibd
@@ -762,7 +762,9 @@ bring_up()
                     else
                             . ${NETWORK_CONF_DIR}/ifcfg-${i}
                 if [ ! -z ${IPADDR} ] && [ ! -z ${NETMASK} ] && [ ! -z ${BROADCAST} ]; then
-                    /sbin/ifconfig ${i} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} > /dev/null 2>&1
+		    eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
+		    /sbin/ip addr add ${IPADDR}/${PREFIX} broadcast ${BROADCAST} dev ${i} > /dev/null 2>&1
+		    /sbin/ip link set ${i} up > /dev/null 2>&1
                 else
                             /sbin/ifup ${i}
                 fi
@@ -770,12 +772,14 @@ bring_up()
                 ;;
                 SuSE)
                     if [ "$KPREFIX" == "26" ]; then
-                        ifconfig ${i} up > /dev/null 2>&1
+			/sbin/ip link set ${i} up > /dev/null 2>&1
                     fi    
                             # Workaround for ifup issue: two devices with the same IP address
                         . ${NETWORK_CONF_DIR}/ifcfg-${i}
                 if [ ! -z ${IPADDR} ] && [ ! -z ${NETMASK} ] && [ ! -z ${BROADCAST} ]; then
-                    /sbin/ifconfig ${i} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} > /dev/null 2>&1
+		    eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
+		    /sbin/ip addr add ${IPADDR}/${PREFIX} broadcast ${BROADCAST} dev ${i} > /dev/null 2>&1
+		    /sbin/ip link set ${i} up > /dev/null 2>&1
                 else
                             /sbin/ifup ${i}
                 fi
-- 
1.7.1




More information about the ewg mailing list