[PATCH rdma-core 1/3] rxe: support iproute2 in rxe_cfg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ifconfig is now deprecated in most distro in favour on iproute2.
Use the ip command when ifconfig is missing.

Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@xxxxxxxx>
---
 providers/rxe/rxe_cfg.in | 64 +++++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 18 deletions(-)

diff --git a/providers/rxe/rxe_cfg.in b/providers/rxe/rxe_cfg.in
index 555a5cde983a..cf9e04ca6818 100755
--- a/providers/rxe/rxe_cfg.in
+++ b/providers/rxe/rxe_cfg.in
@@ -130,6 +130,7 @@ sub get_dev_info {
     my $np;
     my $i = 0;
     my $j = 0;
+    my $ifconfig;
 
     get_mlx4_list();
 
@@ -191,22 +192,43 @@ sub get_dev_info {
 	$ipv4_addr{$eth} = "            ";
 	$eth_mtu{$eth} = "";
 
-	@lines = `ifconfig $eth`;
-	foreach $line (@lines) {
-	    # get IP address
-	    if ($line =~ /inet addr/) {
-		$line =~ s/^\s+inet addr://g;
-		@fields = split(/\s+/, $line);
-		$ipv4_addr{$eth} = $fields[0];
-	    }
-
-	    # get ethernet mtu
-	    if ($line =~ /MTU:/) {
-		$line =~ s/^.*MTU://g;
-		@fields = split(/\s+/, $line);
-		$eth_mtu{$eth} = $fields[0];
-	    }
-	}
+	$ifconfig=`which ifconfig 2> /dev/null`;
+	if ($ifconfig =~ /ifconfig/) {
+		@lines = `ifconfig $eth`;
+		foreach $line (@lines) {
+			# get IP address
+			if ($line =~ /inet addr/) {
+				$line =~ s/^\s+inet addr://g;
+				@fields = split(/\s+/, $line);
+				$ipv4_addr{$eth} = $fields[0];
+			}
+
+			# get ethernet mtu
+			if ($line =~ /MTU:/) {
+				$line =~ s/^.*MTU://g;
+				@fields = split(/\s+/, $line);
+				$eth_mtu{$eth} = $fields[0];
+			}
+		}
+	} else {
+		@lines = `ip addr show $eth`;
+		foreach $line (@lines) {
+			# get IP address
+			if ($line =~ /inet /) {
+				$line =~ s/^\s+inet ([0-9.]+)\//$1 /g;
+				print($line);
+				@fields = split(/\s+/, $line);
+				$ipv4_addr{$eth} = $fields[0];
+			}
+
+			# get ethernet mtu
+			if ($line =~ /mtu /) {
+				$line =~ s/^.*mtu //g;
+				@fields = split(/\s+/, $line);
+				$eth_mtu{$eth} = $fields[0];
+			}
+		}
+    }
     }
 
     # get rxe mtu
@@ -527,8 +549,14 @@ sub do_start {
     foreach my $rxe (@rxe_array) {
 	my $stat = get_devinfo($rxe);
 	if ($stat =~ "PORT_DOWN") {
-	    my $cmd = "ifconfig $eth_names{$rxe} up";
-	    system($cmd);
+		my $ifconfig=`which ifconfig 2> /dev/null`;
+		my $cmd;
+		if ($ifconfig =~ /ifconfig/) {
+			$cmd = "ifconfig $eth_names{$rxe} up";
+		} else {
+			$cmd = "ip link set $eth_names{$rxe} up";
+		}
+		system($cmd);
 	}
     }
 
-- 
2.18.0



Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux