Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
multicast-study
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
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
multicast-study
Commits
58707f40
Commit
58707f40
authored
May 02, 2022
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
topo-BAC: Factor out link-establishment into xlink
parent
83e1d02a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
42 deletions
+44
-42
namespace_demo/lib.sh
namespace_demo/lib.sh
+29
-0
namespace_demo/topo-B-A-C.sh
namespace_demo/topo-B-A-C.sh
+15
-42
No files found.
namespace_demo/lib.sh
View file @
58707f40
# lib.sh is library of common shell functions for topo-*
PID
=
$$
# `xunshare <dir> ...` -- unshare net/mount/... namespaces to be referenced by dir
xunshare
()
{
ref
=
$1
...
...
@@ -16,3 +18,30 @@ xnsenter() {
shift
nsenter
--mount
=
$ref
/mnt
--net
=
$ref
/net
--wd
=
.
"
$@
"
}
# `xlink A B` sets up veth links in between nodes A and B going through bridge brAB:
#
# A ------- brAB ------- B
# a-b brAB.a brAB.b b-a
xlink
()
{
A
=
$1
B
=
$2
a
=
"
${
A
,,
}
"
# A -> a
b
=
"
${
B
,,
}
"
# B -> b
xnsenter
$A
--
ip
link
add
$a
-
$b
type
veth peer br
$A$B
.
$a
xnsenter
$A
--
ip
link set
br
$A$B
.
$a
netns
$PID
xnsenter
$A
--
ip
link set
$a
-
$b
up
ip
link set
br
$A$B
.
$a
up
xnsenter
$B
--
ip
link
add
$b
-
$a
type
veth peer br
$A$B
.
$b
xnsenter
$B
--
ip
link set
br
$A$B
.
$b
netns
$PID
xnsenter
$B
--
ip
link set
$b
-
$a
up
ip
link set
br
$A$B
.
$b
up
ip
link
add br
$A$B
type
bridge
# vlan_filtering 1 mcast_snooping 0
ip
link set
br
$A$B
.
$a
master br
$A$B
ip
link set
br
$A$B
.
$b
master br
$A$B
ip
link set
br
$A$B
up
}
namespace_demo/topo-B-A-C.sh
View file @
58707f40
...
...
@@ -2,10 +2,10 @@
# topo B-A-C creates the following network topology:
#
#
# ns:B
t
ns:A ns:C
# ns:B
ns:A ns:C
#
# B --- br0 --- A --- br1 --- C
# b
1 B1 A1 a1 a2 A2 C1 c1
# b
-a a-b a-c c-a
#
#
# should be run under unshare -mrun .
...
...
@@ -15,56 +15,29 @@
.
lib.sh
PID
=
$$
# B-br0-A
xunshare B
--
ip
link set
lo up
xnsenter B
--
ip
link
add b1
type
veth peer B1
xnsenter B
--
ip
link set
B1 netns
$PID
xnsenter B
--
ip
link set
b1 up
ip
link set
B1 up
# lo on everything
xunshare A
--
ip
link set
lo up
xnsenter A
--
ip
link
add a1
type
veth peer A1
xnsenter A
--
ip
link set
A1 netns
$PID
xnsenter A
--
ip
link set
a1 up
ip
link set
A1 up
ip
link
add br0
type
bridge
# vlan_filtering 1 mcast_snooping 0
ip
link set
B1 master br0
ip
link set
A1 master br0
ip
link set
br0 up
# A-br1-C
xnsenter A
--
ip
link
add a2
type
veth peer A2
xnsenter A
--
ip
link set
A2 netns
$PID
xnsenter A
--
ip
link set
a2 up
ip
link set
A2 up
xunshare B
--
ip
link set
lo up
xunshare C
--
ip
link set
lo up
xnsenter C
--
ip
link
add c1
type
veth peer C1
xnsenter C
--
ip
link set
C1 netns
$PID
xnsenter C
--
ip
link set
c1 up
ip
link set
C1 up
ip
link
add br1
type
bridge
# vlan_filtering 1 mcast_snooping 0
ip
link set
C1 master br1
ip
link set
A2 master br1
ip
link set
br1 up
# links
xlink B A
# B-A
xlink A C
# A-C
# addresses
xnsenter B
--
ip addr add 10.0.0.1/24 dev b
1
xnsenter A
--
ip addr add 10.0.0.2/24 dev a
1
xnsenter C
--
ip addr add 20.0.0.1/24 dev c
1
xnsenter A
--
ip addr add 20.0.0.2/24 dev a
2
xnsenter B
--
ip addr add 10.0.0.1/24 dev b
-a
xnsenter A
--
ip addr add 10.0.0.2/24 dev a
-b
xnsenter C
--
ip addr add 20.0.0.1/24 dev c
-a
xnsenter A
--
ip addr add 20.0.0.2/24 dev a
-c
# multicast routing
xnsenter B
--
ip route add 224.0.0.0/4 dev b
1
xnsenter C
--
ip route add 224.0.0.0/4 dev c
1
xnsenter B
--
ip route add 224.0.0.0/4 dev b
-a
xnsenter C
--
ip route add 224.0.0.0/4 dev c
-a
xnsenter A
--
ip route add 224.0.0.0/4 dev a
1
# NOTE on A 224.0.0.0/4 is routed
xnsenter A
--
ip route append 224.0.0.0/4 dev a
2
# to _both_ a1 and a2
xnsenter A
--
ip route add 224.0.0.0/4 dev a
-b
# NOTE on A 224.0.0.0/4 is routed
xnsenter A
--
ip route append 224.0.0.0/4 dev a
-c
# to _both_ a-b and a-c
# mount private /var/run so that smcrouted can be started
...
...
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