Exemple #1
0
    def _do_ethtool(self, cmd):
        iface = self._get_iface_name()
        data = cast(byref(cmd), c_void_p)

        req = ifreq(ifr_name=iface, ifr_data=data)

        if fcntl.ioctl(self._sk_fileno, SIOCETHTOOL, req, True):
            raise RuntimeError('SIOCETHTOOL ioctl failed', cmd.cmd)
Exemple #2
0
 def _get_iface_name(self):
     """
     :rtype : str
     """
     # TODO: Should never be used. Also, re-create via netlink, and monitor that...
     # generates race-condition, as interface name may be changed after calling this
     # function and before using returned name
     req = ifreq(ifr_ifindex=self.index)
     if fcntl.ioctl(self._sk_fileno, SIOCGIFNAME, req, True):
         raise RuntimeError('SIOCGIFNAME ioctl failed')
     return req.ifr_name