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
c9365643
Commit
c9365643
authored
May 02, 2022
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor xunshare/xnsenter into lib.sh and use it in topo-square as well
parent
9e784c62
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
69 deletions
+72
-69
.gitignore
.gitignore
+1
-0
namespace_demo/lib.sh
namespace_demo/lib.sh
+18
-0
namespace_demo/topo-B-A-C.sh
namespace_demo/topo-B-A-C.sh
+2
-18
namespace_demo/topo-square.sh
namespace_demo/topo-square.sh
+51
-51
No files found.
.gitignore
View file @
c9365643
A
B
C
D
namespace_demo/lib.sh
0 → 100644
View file @
c9365643
# lib.sh is library of common shell functions for topo-*
# `xunshare <dir> ...` -- unshare net/mount/... namespaces to be referenced by dir
xunshare
()
{
ref
=
$1
shift
rm
-rf
"
$ref
"
mkdir
"
$ref
"
touch
$ref
/mnt
$ref
/net
unshare
--mount
=
$ref
/mnt
--net
=
$ref
/net
"
$@
"
}
# `xnsenter <dir> ...` -- nsenter net/mount/... namespaces to be referenced by dir
xnsenter
()
{
ref
=
$1
shift
nsenter
--mount
=
$ref
/mnt
--net
=
$ref
/net
--wd
=
.
"
$@
"
}
namespace_demo/topo-B-A-C.sh
View file @
c9365643
...
...
@@ -13,25 +13,9 @@
#
# Based on https://github.com/troglobit/smcroute/tree/master/test
rm
-rf
A B C
mkdir
A B C
PID
=
$$
# `xunshare <dir> ...` -- unshare net/mount/... namespaces to be referenced by dir
xunshare
()
{
ref
=
$1
shift
touch
$ref
/mnt
$ref
/net
unshare
--mount
=
$ref
/mnt
--net
=
$ref
/net
"
$@
"
}
# `xnsenter <dir> ...` -- nsenter net/mount/... namespaces to be referenced by dir
xnsenter
()
{
ref
=
$1
shift
nsenter
--mount
=
$ref
/mnt
--net
=
$ref
/net
--wd
=
.
"
$@
"
}
.
lib.sh
PID
=
$$
# B-br0-A
xunshare B
--
ip
link set
lo up
...
...
namespace_demo/topo-square.sh
View file @
c9365643
...
...
@@ -19,25 +19,25 @@
#
#
# should be run under unshare -mrun .
# use
nsenter --net={A,B,C,D} to enter into network namespace
of A/B/C/D.
# use
xnsenter {A,B,C,D} to enter into namespaces
of A/B/C/D.
#
# Based on https://github.com/troglobit/smcroute/tree/master/test
rm
-f
A B C D
touch
A B C D
.
lib.sh
PID
=
$$
# A-br0-B
unshare
--net
=
B
--mount
=
B
--
ip
link set
lo up
nsenter
--net
=
B
--
ip
link
add ba
type
veth peer BA
nsenter
--net
=
B
--
ip
link set
BA netns
$PID
nsenter
--net
=
B
--
ip
link set
ba up
xunshare
B
--
ip
link set
lo up
xnsenter
B
--
ip
link
add ba
type
veth peer BA
xnsenter
B
--
ip
link set
BA netns
$PID
xnsenter
B
--
ip
link set
ba up
ip
link set
BA up
unshare
--net
=
A
--
ip
link set
lo up
nsenter
--net
=
A
--
ip
link
add ab
type
veth peer AB
nsenter
--net
=
A
--
ip
link set
AB netns
$PID
nsenter
--net
=
A
--
ip
link set
ab up
xunshare
A
--
ip
link set
lo up
xnsenter
A
--
ip
link
add ab
type
veth peer AB
xnsenter
A
--
ip
link set
AB netns
$PID
xnsenter
A
--
ip
link set
ab up
ip
link set
AB up
ip
link
add br0
type
bridge
# vlan_filtering 1 mcast_snooping 0
...
...
@@ -46,15 +46,15 @@ ip link set AB master br0
ip
link set
br0 up
# A-br1-C
nsenter
--net
=
A
--
ip
link
add ac
type
veth peer AC
nsenter
--net
=
A
--
ip
link set
AC netns
$PID
nsenter
--net
=
A
--
ip
link set
ac up
xnsenter
A
--
ip
link
add ac
type
veth peer AC
xnsenter
A
--
ip
link set
AC netns
$PID
xnsenter
A
--
ip
link set
ac up
ip
link set
AC up
unshare
--net
=
C
--
ip
link set
lo up
nsenter
--net
=
C
--
ip
link
add ca
type
veth peer CA
nsenter
--net
=
C
--
ip
link set
CA netns
$PID
nsenter
--net
=
C
--
ip
link set
ca up
xunshare
C
--
ip
link set
lo up
xnsenter
C
--
ip
link
add ca
type
veth peer CA
xnsenter
C
--
ip
link set
CA netns
$PID
xnsenter
C
--
ip
link set
ca up
ip
link set
CA up
ip
link
add br1
type
bridge
# vlan_filtering 1 mcast_snooping 0
...
...
@@ -63,15 +63,15 @@ ip link set AC master br1
ip
link set
br1 up
# C-br2-D
nsenter
--net
=
C
--
ip
link
add
cd type
veth peer CD
nsenter
--net
=
C
--
ip
link set
CD netns
$PID
nsenter
--net
=
C
--
ip
link set cd
up
xnsenter
C
--
ip
link
add
cd type
veth peer CD
xnsenter
C
--
ip
link set
CD netns
$PID
xnsenter
C
--
ip
link set cd
up
ip
link set
CD up
unshare
--net
=
D
--
ip
link set
lo up
nsenter
--net
=
D
--
ip
link
add dc
type
veth peer DC
nsenter
--net
=
D
--
ip
link set
DC netns
$PID
nsenter
--net
=
D
--
ip
link set
dc up
xunshare
D
--
ip
link set
lo up
xnsenter
D
--
ip
link
add dc
type
veth peer DC
xnsenter
D
--
ip
link set
DC netns
$PID
xnsenter
D
--
ip
link set
dc up
ip
link set
DC up
ip
link
add br2
type
bridge
# vlan_filtering 1 mcast_snooping 0
...
...
@@ -80,14 +80,14 @@ ip link set DC master br2
ip
link set
br2 up
# B-br3-D
nsenter
--net
=
B
--
ip
link
add bd
type
veth peer BD
nsenter
--net
=
B
--
ip
link set
BD netns
$PID
nsenter
--net
=
B
--
ip
link set
bd up
xnsenter
B
--
ip
link
add bd
type
veth peer BD
xnsenter
B
--
ip
link set
BD netns
$PID
xnsenter
B
--
ip
link set
bd up
ip
link set
BD up
nsenter
--net
=
D
--
ip
link
add db
type
veth peer DB
nsenter
--net
=
D
--
ip
link set
DB netns
$PID
nsenter
--net
=
D
--
ip
link set
db up
xnsenter
D
--
ip
link
add db
type
veth peer DB
xnsenter
D
--
ip
link set
DB netns
$PID
xnsenter
D
--
ip
link set
db up
ip
link set
DB up
ip
link
add br3
type
bridge
# vlan_filtering 1 mcast_snooping 0
...
...
@@ -96,21 +96,21 @@ ip link set DB master br3
ip
link set
br3 up
# addresses
nsenter
--net
=
B
--
ip addr add 10.0.0.1/24 dev ba
nsenter
--net
=
A
--
ip addr add 10.0.0.2/24 dev ab
nsenter
--net
=
C
--
ip addr add 20.0.0.1/24 dev ca
nsenter
--net
=
A
--
ip addr add 20.0.0.2/24 dev ac
nsenter
--net
=
B
--
ip addr add 30.0.0.1/24 dev bd
nsenter
--net
=
D
--
ip addr add 30.0.0.2/24 dev db
nsenter
--net
=
C
--
ip addr add 40.0.0.1/24 dev
cd
nsenter
--net
=
D
--
ip addr add 40.0.0.2/24 dev dc
xnsenter
B
--
ip addr add 10.0.0.1/24 dev ba
xnsenter
A
--
ip addr add 10.0.0.2/24 dev ab
xnsenter
C
--
ip addr add 20.0.0.1/24 dev ca
xnsenter
A
--
ip addr add 20.0.0.2/24 dev ac
xnsenter
B
--
ip addr add 30.0.0.1/24 dev bd
xnsenter
D
--
ip addr add 30.0.0.2/24 dev db
xnsenter
C
--
ip addr add 40.0.0.1/24 dev
cd
xnsenter
D
--
ip addr add 40.0.0.2/24 dev dc
# multicast routing
#
nsenter --net=
B -- ip route add 224.0.0.0/4 dev b1
#
nsenter --net=
C -- ip route add 224.0.0.0/4 dev c1
#
xnsenter
B -- ip route add 224.0.0.0/4 dev b1
#
xnsenter
C -- ip route add 224.0.0.0/4 dev c1
#
#
nsenter --net=
A -- ip route add 224.0.0.0/4 dev a1 # NOTE on A 224.0.0.0/4 is routed
#
nsenter --net=
A -- ip route append 224.0.0.0/4 dev a2 # to _both_ a1 and a2
#
xnsenter
A -- ip route add 224.0.0.0/4 dev a1 # NOTE on A 224.0.0.0/4 is routed
#
xnsenter
A -- ip route append 224.0.0.0/4 dev a2 # to _both_ a1 and a2
...
...
@@ -121,13 +121,13 @@ sed -e 's/IF0/ca/g' -e 's/IF1/cd/g' pim-dm.yaml.tmpl > pim-dm_C.yaml
sed
-e
's/IF0/dc/g'
-e
's/IF1/db/g'
pim-dm.yaml.tmpl
>
pim-dm_D.yaml
# we need to mount private /var/run in each namespace so that pim-dm can be started
#
nsenter --net=
A -- pim-dm -config pim-dm_A.yaml &
#
nsenter --net=
B -- pim-dm -config pim-dm_B.yaml &
#
nsenter --net=
C -- pim-dm -config pim-dm_C.yaml &
#
nsenter --net=
D -- pim-dm -config pim-dm_D.yaml &
#
xnsenter
A -- pim-dm -config pim-dm_A.yaml &
#
xnsenter
B -- pim-dm -config pim-dm_B.yaml &
#
xnsenter
C -- pim-dm -config pim-dm_C.yaml &
#
xnsenter
D -- pim-dm -config pim-dm_D.yaml &
# open terminals in A B C D for play
nsenter
--net
=
A
--
xfce4-terminal
--title
=
A &
nsenter
--net
=
B
--
xfce4-terminal
--title
=
B &
nsenter
--net
=
C
--
xfce4-terminal
--title
=
C &
nsenter
--net
=
D
--
xfce4-terminal
--title
=
D &
xnsenter
A
--
xfce4-terminal
--title
=
A &
xnsenter
B
--
xfce4-terminal
--title
=
B &
xnsenter
C
--
xfce4-terminal
--title
=
C &
xnsenter
D
--
xfce4-terminal
--title
=
D &
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