Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
8010bf23
Commit
8010bf23
authored
Jul 30, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #99 from iovisor/weichunc_dev
Assign ip address to br
parents
7d5c9870
ee92dcc3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
examples/distributed_bridge/main.py
examples/distributed_bridge/main.py
+1
-1
examples/distributed_bridge/tunnel.py
examples/distributed_bridge/tunnel.py
+5
-0
examples/distributed_bridge/tunnel_mesh.py
examples/distributed_bridge/tunnel_mesh.py
+2
-0
No files found.
examples/distributed_bridge/main.py
View file @
8010bf23
...
@@ -32,7 +32,7 @@ class TunnelSimulation(Simulation):
...
@@ -32,7 +32,7 @@ class TunnelSimulation(Simulation):
host_info
.
append
(
self
.
_create_ns
(
"host%d"
%
i
,
ipaddr
=
ipaddr
,
host_info
.
append
(
self
.
_create_ns
(
"host%d"
%
i
,
ipaddr
=
ipaddr
,
disable_ipv6
=
True
))
disable_ipv6
=
True
))
if
multicast
:
if
multicast
:
cmd
=
[
"python"
,
"tunnel.py"
]
cmd
=
[
"python"
,
"tunnel.py"
,
str
(
i
)
]
else
:
else
:
cmd
=
[
"python"
,
"tunnel_mesh.py"
,
str
(
num_hosts
),
str
(
i
)]
cmd
=
[
"python"
,
"tunnel_mesh.py"
,
str
(
num_hosts
),
str
(
i
)]
p
=
NSPopen
(
host_info
[
i
][
0
].
nl
.
netns
,
cmd
,
stdin
=
PIPE
)
p
=
NSPopen
(
host_info
[
i
][
0
].
nl
.
netns
,
cmd
,
stdin
=
PIPE
)
...
...
examples/distributed_bridge/tunnel.py
View file @
8010bf23
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# Licensed under the Apache License, Version 2.0 (the "License")
from
sys
import
argv
from
bpf
import
BPF
from
bpf
import
BPF
from
builtins
import
input
from
builtins
import
input
from
ctypes
import
c_int
,
c_uint
from
ctypes
import
c_int
,
c_uint
...
@@ -12,6 +13,8 @@ from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
...
@@ -12,6 +13,8 @@ from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from
socket
import
htons
,
AF_INET
from
socket
import
htons
,
AF_INET
from
threading
import
Thread
from
threading
import
Thread
host_id
=
int
(
argv
[
1
])
b
=
BPF
(
src_file
=
"tunnel.c"
)
b
=
BPF
(
src_file
=
"tunnel.c"
)
ingress_fn
=
b
.
load_func
(
"handle_ingress"
,
BPF
.
SCHED_CLS
)
ingress_fn
=
b
.
load_func
(
"handle_ingress"
,
BPF
.
SCHED_CLS
)
egress_fn
=
b
.
load_func
(
"handle_egress"
,
BPF
.
SCHED_CLS
)
egress_fn
=
b
.
load_func
(
"handle_egress"
,
BPF
.
SCHED_CLS
)
...
@@ -60,6 +63,8 @@ def run():
...
@@ -60,6 +63,8 @@ def run():
ifc_gc
.
append
(
v
.
ifname
)
ifc_gc
.
append
(
v
.
ifname
)
ifc_gc
.
append
(
br
.
ifname
)
ifc_gc
.
append
(
br
.
ifname
)
vni2if
[
c_uint
(
vni
)]
=
c_int
(
v
.
index
)
vni2if
[
c_uint
(
vni
)]
=
c_int
(
v
.
index
)
ipaddr
=
"99.1.%d.%d/24"
%
(
i
,
host_id
+
1
)
br
.
add_ip
(
ipaddr
)
try
:
try
:
run
()
run
()
...
...
examples/distributed_bridge/tunnel_mesh.py
View file @
8010bf23
...
@@ -67,6 +67,8 @@ def run():
...
@@ -67,6 +67,8 @@ def run():
br
.
add_port
(
v
)
br
.
add_port
(
v
)
br
.
up
()
br
.
up
()
ifc_gc
.
append
(
v
.
ifname
)
ifc_gc
.
append
(
v
.
ifname
)
ipaddr
=
"99.1.%d.%d/24"
%
(
i
,
host_id
+
1
)
br
.
add_ip
(
ipaddr
)
ifc_gc
.
append
(
br
.
ifname
)
ifc_gc
.
append
(
br
.
ifname
)
try
:
try
:
...
...
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