From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1B8CA5A58 for ; Wed, 8 Jul 2015 08:18:58 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 07 Jul 2015 23:18:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,429,1432623600"; d="scan'208";a="760388209" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 07 Jul 2015 23:18:45 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t686Ih5s015573; Wed, 8 Jul 2015 14:18:43 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t686IeCb006961; Wed, 8 Jul 2015 14:18:42 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t686IecP006957; Wed, 8 Jul 2015 14:18:40 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 8 Jul 2015 14:18:39 +0800 Message-Id: <1436336319-6925-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] fix bug that unbound device then run dts will show wrong interface X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2015 06:18:59 -0000 From: Marvin Liu 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 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