Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
e6ff2612
Commit
e6ff2612
authored
Sep 01, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add use_pi flag to tap-related functions, to allow both modes of operation
parent
62e29870
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
8 deletions
+12
-8
src/netns/interface.py
src/netns/interface.py
+2
-2
src/netns/iproute.py
src/netns/iproute.py
+8
-4
src/netns/node.py
src/netns/node.py
+2
-2
No files found.
src/netns/interface.py
View file @
e6ff2612
...
...
@@ -220,13 +220,13 @@ class TapNodeInterface(NSInterface):
"""Class to create a tap interface inside a name space, it
can be connected to a Switch object with emulation of link
characteristics."""
def
__init__
(
self
,
node
):
def
__init__
(
self
,
node
,
use_pi
=
False
):
"""Create a new tap interface. 'node' is the name space in which this
interface should be put."""
self
.
_fd
=
None
self
.
_slave
=
None
iface
=
netns
.
iproute
.
interface
(
name
=
self
.
_gen_if_name
())
iface
,
self
.
_fd
=
netns
.
iproute
.
create_tap
(
iface
)
iface
,
self
.
_fd
=
netns
.
iproute
.
create_tap
(
iface
,
use_pi
)
netns
.
iproute
.
change_netns
(
iface
.
name
,
node
.
pid
)
super
(
TapNodeInterface
,
self
).
__init__
(
node
,
iface
.
index
)
...
...
src/netns/iproute.py
View file @
e6ff2612
...
...
@@ -899,7 +899,7 @@ def set_tc(iface, bandwidth = None, delay = None, delay_jitter = None,
for c in commands:
execute(c)
def create_tap(iface):
def create_tap(iface
, use_pi = False
):
"""Creates a tap device and returns the associated file descriptor"""
if isinstance(iface, str):
iface = interface(name = iface)
...
...
@@ -908,10 +908,14 @@ def create_tap(iface):
IFF_TAP = 0x0002
IFF_NO_PI = 0x1000
TUNSETIFF = 0x400454ca
mode = IFF_TAP | IFF_NO_PI
mode = IFF_TAP
if not use_pi:
mode |= IFF_NO_PI
fd = os.open("/dev/net/tun", os.O_RDWR)
if fd == -1:
raise RuntimeError("Could not open /dev/net/tun")
err = fcntl.ioctl(fd, TUNSETIFF, struct.pack("16sH", iface.name, mode))
if err < 0:
os.close(fd)
...
...
src/netns/node.py
View file @
e6ff2612
...
...
@@ -96,8 +96,8 @@ class Node(object):
setattr
(
i
,
k
,
v
)
return
i
def
add_tap
(
self
,
**
kwargs
):
i
=
netns
.
interface
.
TapNodeInterface
(
self
)
def
add_tap
(
self
,
use_pi
=
False
,
**
kwargs
):
i
=
netns
.
interface
.
TapNodeInterface
(
self
,
use_pi
)
for
k
,
v
in
kwargs
.
items
():
setattr
(
i
,
k
,
v
)
return
i
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment