[dts] [PATCH] fix bug that unbound device then run dts will show wrong interface

Qiu, Michael michael.qiu at intel.com
Wed Jul 8 09:24:03 CEST 2015


On 7/8/2015 2:19 PM, Yong Liu wrote:
> From: Marvin Liu <yong.liu at 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 at 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:

Here does "up" need?

> +            return 'N/A'
> +        else:
> +            return out
>  
>      def get_mac_addr_linux(self, intf, bus_id, devfun_id, driver):
>          """



More information about the dts mailing list