diff mbox series

[rdma-core,2/3] rxe: support newer ifconfig

Message ID 17479029-7d54-accb-ee5b-a7baa07beeb3@suse.de (mailing list archive)
State Not Applicable
Delegated to: Leon Romanovsky
Headers show
Series rxe_cfg fixes | expand

Commit Message

Nicolas Morey-Chaisemartin Aug. 1, 2018, 1:36 p.m. UTC
net-tools 2.0 has changed the ifconfig format:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.127  netmask 255.255.255.0  broadcast 10.0.2.255

Fix the regexp to support both older and newer versions of net-tools

Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
---
 providers/rxe/rxe_cfg.in | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/providers/rxe/rxe_cfg.in b/providers/rxe/rxe_cfg.in
index cf9e04ca6818..5d01f3a613c9 100755
--- a/providers/rxe/rxe_cfg.in
+++ b/providers/rxe/rxe_cfg.in
@@ -197,15 +197,15 @@  sub get_dev_info {
 		@lines = `ifconfig $eth`;
 		foreach $line (@lines) {
 			# get IP address
-			if ($line =~ /inet addr/) {
-				$line =~ s/^\s+inet addr://g;
+			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;
+			if ($line =~ /(MTU|mtu)[: ]/) {
+				$line =~ s/^.*(MTU|mtu)[: ]//g;
 				@fields = split(/\s+/, $line);
 				$eth_mtu{$eth} = $fields[0];
 			}