Revision 703c6b10 mininet/link.py

View differences:

mininet/link.py
25 25
"""
26 26

  
27 27
from mininet.log import info, error, debug
28
from mininet.util import makeIntfPair
28
from mininet.util import makeIntfPair, errFail, quietRun
29 29
from time import sleep
30 30
import re
31 31

  
......
109 109
    def rename( self, newname ):
110 110
        "Rename interface"
111 111
        self.ifconfig( 'down' )
112
        result = self.cmd( 'ip link set', self.name, 'name', newname )
112
        result = self.cmd( 'ip link set dev', self.name, 'name', newname )
113 113
        self.name = newname
114 114
        self.ifconfig( 'up' )
115 115
        return result
......
378 378
           intf2: name of interface 2
379 379
           (override this class method [and possibly delete()]
380 380
           to change link type)"""
381
        cmd = 'ip link add %s type veth peer name %s netns ' % ( intf1, intf2 )
382
        if node2.inNamespace:
383
            cmd += node2.name
384
        else:
385
            cmd += '1'
386
        if node1:
387
            node1.cmd( cmd )
388
        else:
389
            errFail( cmd )
381
        # To be compatible with pid namespaces and chroot in the future
382
        # we create links in the root namespace and then move
383
        # the ends as needed.
384
        # First, make sure there aren't stale links sitting around
385
        quietRun( 'ip link delete %s type veth' % intf1 )
386
        quietRun( 'ip link delete %s type veth' % intf2 )
387
        cmd = 'ip link add %s type veth peer name %s' % ( intf1, intf2 )
388
        if node2 and node2.inNamespace:
389
            cmd += ' netns %s' % node2
390
        errFail( cmd )
391
        if node1 and node1.inNamespace:
392
            errFail( 'ip link set dev %s netns %s' % ( intf1, node1 ) )
390 393

  
391 394
    def delete( self ):
392 395
        "Delete this link"
......
396 399
    def __str__( self ):
397 400
        return '%s<->%s' % ( self.intf1, self.intf2 )
398 401

  
402

  
399 403
class TCLink( Link ):
400 404
    "Link with symmetric TC interfaces configured via opts"
401 405
    def __init__( self, node1, node2, port1=None, port2=None,

Also available in: Unified diff