From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] fix bug that unbound device then run dts will show wrong interface
Date: Wed, 8 Jul 2015 14:18:39 +0800 [thread overview]
Message-ID: <1436336319-6925-1-git-send-email-yong.liu@intel.com> (raw)
From: Marvin Liu <yong.liu@intel.com>
Previously net device interface name only captured in initialization process.
Now every time call get interface function will update it.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/net_device.py b/framework/net_device.py
index f8ad098..a187d27 100644
--- a/framework/net_device.py
+++ b/framework/net_device.py
@@ -59,7 +59,7 @@ class NetDevice(object):
if self.nic_is_pf():
self.default_vf_driver = ''
- self.intf_name = self.get_interface_name()
+ self.get_interface_name()
self.socket = self.get_nic_socket()
def __send_expect(self, cmds, expected, timeout=TIMEOUT, alt_session=True):
@@ -126,11 +126,18 @@ class NetDevice(object):
def get_interface_name(self):
"""
Get interface name of specified pci device.
+ Cal this function will update intf_name everytime
"""
get_interface_name = getattr(
self, 'get_interface_name_%s' %
self.__get_os_type())
- return get_interface_name(self.bus_id, self.devfun_id, self.current_driver)
+ out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver)
+ if "No such file or directory up" in out:
+ self.intf_name = 'N/A'
+ else:
+ self.intf_name = out
+
+ return self.intf_name
def get_interface_name_linux(self, bus_id, devfun_id, driver):
"""
@@ -197,7 +204,11 @@ class NetDevice(object):
Get mac address of specified pci device.
"""
get_mac_addr = getattr(self, 'get_mac_addr_%s' % self.__get_os_type())
- return get_mac_addr(self.intf_name, self.bus_id, self.devfun_id, self.current_driver)
+ out = get_mac_addr(self.intf_name, self.bus_id, self.devfun_id, self.current_driver)
+ if "No such file or directory up" in out:
+ return 'N/A'
+ else:
+ return out
def get_mac_addr_linux(self, intf, bus_id, devfun_id, driver):
"""
--
1.9.3
next reply other threads:[~2015-07-08 6:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 6:18 Yong Liu [this message]
2015-07-08 7:24 ` Qiu, Michael
2015-07-08 7:35 ` Liu, Yong
2015-07-08 7:36 ` [dts] [PATCH V2] " Yong Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436336319-6925-1-git-send-email-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).