Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
7a4a865b
Commit
7a4a865b
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
customize makeIntfPair to eliminate fastIntfPair
parent
da4dcf37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mininet/link.py
+13
-29
13 additions, 29 deletions
mininet/link.py
mininet/util.py
+27
-11
27 additions, 11 deletions
mininet/util.py
with
40 additions
and
40 deletions
mininet/link.py
+
13
−
29
View file @
7a4a865b
...
...
@@ -415,8 +415,8 @@ def __init__( self, node1, node2, port1=None, port2=None,
if
fast
:
params1
.
setdefault
(
'
moveIntfFn
'
,
self
.
_ignore
)
params2
.
setdefault
(
'
moveIntfFn
'
,
self
.
_ignore
)
self
.
fast
IntfPair
(
intfName1
,
intfName2
,
addr1
,
addr2
,
node1
=
node
1
,
node2
=
node2
)
self
.
make
IntfPair
(
intfName1
,
intfName2
,
addr1
,
addr2
,
node1
,
node
2
,
deleteIntfs
=
False
)
else
:
self
.
makeIntfPair
(
intfName1
,
intfName2
,
addr1
,
addr2
)
...
...
@@ -446,35 +446,21 @@ def intfName( self, node, n ):
return
node
.
name
+
'
-eth
'
+
repr
(
n
)
@classmethod
def
makeIntfPair
(
cls
,
intfname1
,
intfname2
,
addr1
=
None
,
addr2
=
None
):
def
makeIntfPair
(
cls
,
intfname1
,
intfname2
,
addr1
=
None
,
addr2
=
None
,
node1
=
None
,
node2
=
None
,
deleteIntfs
=
True
):
"""
Create pair of interfaces
intfname1: name of interface 1
intfname2: name of interface 2
intfname1: name for interface 1
intfname2: name for interface 2
addr1: MAC address for interface 1 (optional)
addr2: MAC address for interface 2 (optional)
node1: home node for interface 1 (optional)
node2: home node for interface 2 (optional)
(override this method [and possibly delete()]
to change link type)
"""
# Leave this as a class method for now
assert
cls
return
makeIntfPair
(
intfname1
,
intfname2
,
addr1
,
addr2
)
@classmethod
def
fastIntfPair
(
cls
,
intfname1
,
intfname2
,
addr1
=
None
,
addr2
=
None
,
node1
=
None
,
node2
=
None
):
"""
Create pair of interfaces
'
fast
'
version: no checking, only works with Nodes.
intf1: name of interface 1
intf2: name of interface 2
(override this class method [and possibly delete()]
to change link type)
"""
if
addr1
is
None
and
addr2
is
None
:
return
node1
.
cmd
(
'
ip link add name
'
,
intfname1
,
'
type veth peer name
'
,
intfname2
,
'
netns
'
,
node2
.
pid
)
else
:
return
node1
.
cmd
(
'
ip link add name
'
,
intfname1
,
'
address
'
,
addr1
,
'
type veth peer name
'
,
intfname2
,
'
address
'
,
addr2
,
'
netns
'
,
node2
.
pid
)
return
makeIntfPair
(
intfname1
,
intfname2
,
addr1
,
addr2
,
node1
,
node2
,
deleteIntfs
=
deleteIntfs
)
def
delete
(
self
):
"
Delete this link
"
...
...
@@ -519,12 +505,10 @@ def __init__( self, node1, node2, **kwargs ):
kwargs
.
update
(
cls1
=
OVSIntf
,
cls2
=
OVSIntf
)
Link
.
__init__
(
self
,
node1
,
node2
,
**
kwargs
)
def
fast
IntfPair
(
self
,
*
args
,
**
kwargs
):
def
make
IntfPair
(
self
,
*
args
,
**
kwargs
):
"
Usually delegated to OVSSwitch
"
if
self
.
isPatchLink
:
return
None
,
None
elif
self
.
fast
:
return
Link
.
fastIntfPair
(
*
args
,
**
kwargs
)
else
:
return
Link
.
makeIntfPair
(
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
mininet/util.py
+
27
−
11
View file @
7a4a865b
...
...
@@ -145,22 +145,38 @@ def isShellBuiltin( cmd ):
# live in the root namespace and thus do not have to be
# explicitly moved.
def
makeIntfPair
(
intf1
,
intf2
,
addr1
=
None
,
addr2
=
None
,
runCmd
=
quietRun
):
"""
Make a veth pair connecting intf1 and intf2.
intf1: string, interface
intf2: string, interface
def
makeIntfPair
(
intf1
,
intf2
,
addr1
=
None
,
addr2
=
None
,
node1
=
None
,
node2
=
None
,
deleteIntfs
=
True
,
runCmd
=
None
):
"""
Make a veth pair connnecting new interfaces intf1 and intf2
intf1: name for interface 1
intf2: name for interface 2
addr1: MAC address for interface 1 (optional)
addr2: MAC address for interface 2 (optional)
node1: home node for interface 1 (optional)
node2: home node for interface 2 (optional)
deleteIntfs: delete intfs before creating them
runCmd: function to run shell commands (quietRun)
returns: ip link add result
"""
# Delete any old interfaces with the same names
runCmd
(
'
ip link del
'
+
intf1
)
runCmd
(
'
ip link del
'
+
intf2
)
if
not
runCmd
:
runCmd
=
quietRun
if
not
node1
else
node1
.
cmd
runCmd2
=
quietRun
if
not
node2
else
node2
.
cmd
if
deleteIntfs
:
# Delete any old interfaces with the same names
runCmd
(
'
ip link del
'
+
intf1
)
runCmd2
(
'
ip link del
'
+
intf2
)
# Create new pair
netns
=
1
if
not
node2
else
node2
.
pid
if
addr1
is
None
and
addr2
is
None
:
cmd
=
'
ip link add name
'
+
intf1
+
'
type veth peer name
'
+
intf2
cmdOutput
=
runCmd
(
'
ip link add name %s
'
'
type veth peer name %s
'
'
netns %s
'
%
(
intf1
,
intf2
,
netns
)
)
else
:
cmd
=
(
'
ip link add name
'
+
intf1
+
'
address
'
+
addr1
+
'
type veth peer name
'
+
intf2
+
'
address
'
+
addr2
)
cmdOutput
=
runCmd
(
cmd
)
cmdOutput
=
runCmd
(
'
ip link add name %s
'
'
address %s
'
'
type veth peer name %s
'
'
address %s
'
'
netns %s
'
%
(
intf1
,
addr1
,
intf2
,
addr2
,
netns
)
)
if
cmdOutput
==
''
:
return
True
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment