Review at  https://gerrit.osmocom.org/3464

util: ip_to_iface: Return secondary iface if present

In the following example setup, if osmo-nitb is listening
on 10.42.42.2, we want to return eth1:0 instead of eth1.

ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP 
group default qlen 1000
    link/ether 00:0d:b9:35:3a:41 brd ff:ff:ff:ff:ff:ff
    inet 10.42.42.1/24 brd 10.42.42.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet 10.42.42.2/24 brd 10.42.42.255 scope global secondary eth1:0
       valid_lft forever preferred_lft forever
    inet 10.42.42.3/24 brd 10.42.42.255 scope global secondary eth1:1
       valid_lft forever preferred_lft forever

Change-Id: Ia66e6fd8138fc11a70437a573128aacf6a01b8ff
---
M src/osmo_gsm_tester/util.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/64/3464/1

diff --git a/src/osmo_gsm_tester/util.py b/src/osmo_gsm_tester/util.py
index 266243c..602ae45 100644
--- a/src/osmo_gsm_tester/util.py
+++ b/src/osmo_gsm_tester/util.py
@@ -44,7 +44,7 @@
             proc = subprocess.Popen(['ip', 'addr', 'show', 'dev', iface], 
stdout=subprocess.PIPE, universal_newlines=True)
             for line in proc.stdout.readlines():
                 if 'inet' in line and ' ' + ip + '/' in line:
-                    return iface
+                    return line.split()[-1]
     except Exception as e:
         pass
     return None

-- 
To view, visit https://gerrit.osmocom.org/3464
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia66e6fd8138fc11a70437a573128aacf6a01b8ff
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to