def show_offload(interface, args=None): try: sg = ethtool.get_sg(interface) and "on" or "off" except IOError: sg = "not supported" try: tso = ethtool.get_tso(interface) and "on" or "off" except IOError: tso = "not supported" try: ufo = ethtool.get_ufo(interface) and "on" or "off" except IOError: ufo = "not supported" try: gso = ethtool.get_gso(interface) and "on" or "off" except IOError: gso = "not supported" printtab("scatter-gather: %s" % sg) printtab("tcp segmentation offload: %s" % tso) printtab("udp fragmentation offload: %s" % ufo) printtab("generic segmentation offload: %s" % gso)
def show_offload(interface, args = None): try: sg = ethtool.get_sg(interface) and "on" or "off" except IOError: sg = "not supported" try: tso = ethtool.get_tso(interface) and "on" or "off" except IOError: tso = "not supported" try: ufo = ethtool.get_ufo(interface) and "on" or "off" except IOError: ufo = "not supported" try: gso = ethtool.get_gso(interface) and "on" or "off" except IOError: gso = "not supported" printtab("scatter-gather: %s" % sg) printtab("tcp segmentation offload: %s" % tso) printtab("udp fragmentation offload: %s" % ufo) printtab("generic segmentation offload: %s" % gso)
def _functions_accepting_devnames(self, devname): self.assertIsString(devname) scraped = ifconfig.get_device_by_name(devname) try: broadcast = ethtool.get_broadcast(devname) except (OSError, IOError): # Some devices might end up with # [Errno 99] Cannot assign requested address # That's IOError on 2.7, OSError on 3 assignable = False else: assignable = True self.assertIsString(broadcast) # Broadcast is optional in ifconfig output if scraped.broadcast: self.assertEqualIpv4Str(broadcast, scraped.broadcast) self.assertIsStringExceptForLoopback( ethtool.get_businfo, devname, '[Errno 95] Operation not ' 'supported') self.assertIsInt(ethtool.get_flags(devname)) # flagsint cannot be obtained from old ifconfig format if not ifconfig.oldFormat: self.assertEqual(ethtool.get_flags(devname), scraped.flagsint) self.assertIsInt(ethtool.get_gso(devname)) self.assertIsInt(ethtool.get_gro(devname)) self.assertIsString(ethtool.get_hwaddr(devname)) self.assertEqualHwAddr(ethtool.get_hwaddr(devname), scraped.hwaddr) if assignable: self.assertIsString(ethtool.get_ipaddr(devname)) self.assertEqual(ethtool.get_ipaddr(devname), scraped.inet) self.assertIsStringExceptForLoopback( ethtool.get_module, devname, '[Errno 95] Operation not ' 'supported') if assignable: self.assertIsString(ethtool.get_netmask(devname)) self.assertEqual(ethtool.get_netmask(devname), scraped.netmask) # Operation is not supported only on loopback device if devname == 'lo': self.assertRaisesIOError(ethtool.get_ringparam, (devname, ), '[Errno 95] Operation not supported') self.assertIsInt(ethtool.get_sg(devname)) try: self.assertIsInt(ethtool.get_ufo(devname)) except (OSError, IOError): # This test may fail due to insufficient privileges # That's IOError on 2.7, OSError (PermissionError) on 3 pass self.assertIsInt(ethtool.get_tso(devname))
def test_show_offload_lo(self): self.assertIsNone(peth.show_offload(loopback)) # Check if we have rights to obtain ufo and set proper expected output try: ethtool.get_ufo(loopback) expected_ufo = 'on' except (OSError, IOError): expected_ufo = 'not supported' self.assertEqual( self._output(), '''scatter-gather: on tcp segmentation offload: on udp fragmentation offload: {expected_ufo} generic segmentation offload: on generic receive offload: on '''.format(expected_ufo=expected_ufo))
def show_offload(devname): ''' Queries the specified network device for the state of protocol offload and other features CLI Example: .. code-block:: bash salt '*' ethtool.show_offload <devname> ''' try: sg = ethtool.get_sg(devname) and "on" or "off" except IOError: sg = "not supported" try: tso = ethtool.get_tso(devname) and "on" or "off" except IOError: tso = "not supported" try: ufo = ethtool.get_ufo(devname) and "on" or "off" except IOError: ufo = "not supported" try: gso = ethtool.get_gso(devname) and "on" or "off" except IOError: gso = "not supported" offload = { 'scatter_gather': sg, 'tcp_segmentation_offload': tso, 'udp_fragmentation_offload': ufo, 'generic_segmentation_offload': gso, } return offload