Exemplo n.º 1
0
    def testTogglePromisc(self):
        ipwrapper.getLink(self._bridge.devName).promisc = True
        self.assertTrue(ipwrapper.getLink(self._bridge.devName).promisc,
                        "Could not enable promiscuous mode.")

        ipwrapper.getLink(self._bridge.devName).promisc = False
        self.assertFalse(ipwrapper.getLink(self._bridge.devName).promisc,
                         "Could not disable promiscuous mode.")
Exemplo n.º 2
0
def setPortMirroring(network, target):
    _qdisc_replace_ingress(network)
    _addTarget(network, QDISC_INGRESS, target)

    qdisc.replace(network, 'prio', parent=None)
    qdisc_id = _qdiscs_of_device(network).next()
    _addTarget(network, qdisc_id, target)
    ipwrapper.getLink(network).promisc = True
Exemplo n.º 3
0
 def testEnablePromisc(self):
     link = ipwrapper.getLink(self._bridge.devName)
     with monitor.Monitor(timeout=2, silent_timeout=True) as mon:
         link.promisc = True
         for event in mon:
             if (event['event'] == 'new_link' and
                     event.get('flags', 0) & ipwrapper.Link.IFF_PROMISC):
                 return
     self.fail("Could not enable promiscuous mode.")
Exemplo n.º 4
0
def unsetPortMirroring(network, target):
    # TODO handle the case where we have partial definitions on device due to
    # vdsm crash
    acts = _delTarget(network, QDISC_INGRESS, target)
    try:
        qdisc_id = _qdiscs_of_device(network).next()
        acts += _delTarget(network, qdisc_id, target)
    except StopIteration:
        pass

    if not acts:
        _qdisc_del(network)
        _qdisc_del(network, kind='ingress')
        ipwrapper.getLink(network).promisc = False
Exemplo n.º 5
0
def setPortMirroring(network, target):
    '''
    Copy networkName traffic of a bridge to an interface

    :param networkName: networkName bridge name to capture the traffic from
    :type networkName: string

    :param ifaceName: ifaceName to copy (mirror) the traffic to
    :type ifaceName: string

    this commands mirror all 'networkName' traffic to 'ifaceName'
    '''
    _qdisc_replace_ingress(network)
    _addTarget(network, QDISC_INGRESS, target)

    qdisc.replace(network, 'prio', parent=None)
    qdisc_id = _qdiscs_of_device(network).next()
    _addTarget(network, qdisc_id, target)
    ipwrapper.getLink(network).promisc = True
Exemplo n.º 6
0
def unsetPortMirroring(network, target):
    '''
    Release captured mirror networkName traffic from networkName bridge

    :param networkName: networkName to release the traffic capture
    :type networkName: string
    :param target: target device to release
    :type target: string

    # TODO handle the case where we have partial definitions on device due to
    # vdsm crash
    '''
    acts = _delTarget(network, QDISC_INGRESS, target)
    try:
        qdisc_id = _qdiscs_of_device(network).next()
        acts += _delTarget(network, qdisc_id, target)
    except StopIteration:
        pass

    if not acts:
        _qdisc_del(network)
        _qdisc_del(network, kind='ingress')
        ipwrapper.getLink(network).promisc = False
Exemplo n.º 7
0
 def testDiff(self):
     lo = ipwrapper.getLink('lo')
     s0 = sampling.InterfaceSample(lo)
     s1 = sampling.InterfaceSample(lo)
     s1.operstate = 'x'
     self.assertEquals('operstate:x', s1.connlog_diff(s0))
Exemplo n.º 8
0
 def testGetLink(self):
     link = ipwrapper.getLink(self._bridge.devName)
     self.assertTrue(link.isBRIDGE)
     self.assertEqual(link.master, None)
     self.assertEqual(link.name, self._bridge.devName)
Exemplo n.º 9
0
 def testGetLink(self):
     link = ipwrapper.getLink(self._bridge.devName)
     self.assertTrue(link.isBRIDGE)
     self.assertEqual(link.master, None)
     self.assertEqual(link.name, self._bridge.devName)
Exemplo n.º 10
0
 def testDiff(self):
     lo = ipwrapper.getLink('lo')
     s0 = sampling.InterfaceSample(lo)
     s1 = sampling.InterfaceSample(lo)
     s1.operstate = 'x'
     self.assertEquals('operstate:x', s1.connlog_diff(s0))