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
453abc48
Commit
453abc48
authored
May 06, 2022
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
My debug scripts/programs used to debug multicast routing in Linux kernel and overall
parent
3e684fcf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
218 additions
and
0 deletions
+218
-0
.gitignore
.gitignore
+1
-0
namespace_demo/linux-dbg
namespace_demo/linux-dbg
+5
-0
namespace_demo/linux-dbg.sh
namespace_demo/linux-dbg.sh
+5
-0
namespace_demo/topo-mr-debug.sh
namespace_demo/topo-mr-debug.sh
+207
-0
No files found.
.gitignore
View file @
453abc48
...
@@ -2,3 +2,4 @@ A
...
@@ -2,3 +2,4 @@ A
B
B
C
C
D
D
pim-dm_*.yaml
namespace_demo/linux-dbg
0 → 100755
View file @
453abc48
#!/bin/bash
~/src/wendelin/wendelin.core/t/qemu-runlinux
-v
\
~/src/linux/obj-qemu_debug/arch/x86/boot/bzImage
\
./linux-dbg.sh
namespace_demo/linux-dbg.sh
0 → 100755
View file @
453abc48
#!/bin/bash
mount
-t
tmpfs none t
cd
t
../topo-mr-debug.sh test_local
namespace_demo/topo-mr-debug.sh
0 → 100755
View file @
453abc48
#!/bin/bash -e
# topo mr-debug creates simple A-B topology as a playground for multicast routing debugging
# on A routes are setup in fully static way - without smcrouted
# on B smcrouted is running
#
# run as e.g. ./topo-mr-debug test_locallocal
# whether to use use mcast_rx/mcast_tx interfaces instead of lo
# see
#
# https://lab.nexedi.com/kirr/linux/commit/25bcc76020c5 and
# https://lab.nexedi.com/kirr/linux/commit/43eadf90a7a6
#
# for why lo does not work out of the box.
use_mcast_rxtx_instead_of_lo
=
y
# whether to use IPv4 or IPv6 for tests
IPvX
=
6
tx
=
tx
$IPvX
rx
=
rx
$IPvX
txrx
=
txrx
$IPvX
# ----------------------------------------
.
$(
dirname
$0
)
/lib.sh
if
[
$#
=
0
]
;
then
echo
"Usage:
$0
test_<...>"
exit
1
fi
xnewhost A
xnewhost B
xlink A B
# Bshow ... displays ... and runs it inside B.
Bshow
()
{
echo
-e
"
\n
>>>"
"
$@
"
xnsenter B
--
"
$@
"
}
if
[
$use_mcast_rxtx_instead_of_lo
=
n
]
;
then
mrx
=
lo
mtx
=
lo
else
mrx
=
mcast-rx
mtx
=
mcast-tx
# mrx <-> mtx veth pair
xnsenter B
--
ip
link
add
$mrx
type
veth peer name
$mtx
xnsenter B
--
ip
link set
$mrx
up
xnsenter B
--
ip
link set
$mtx
up
# programs from local host will be sending multicast via mtx (having default route for multicast addresses)
# those packets will be delivered back to local delivery via mrx <- mtx
# tell IPv4 routing not to reject them
# NOTE IPv6 does not need this
xnsenter B
--
sysctl net.ipv4.conf.mcast-rx.accept_local
=
1
fi
xnsenter A
--
ip addr add 1.0.0.1/24 dev a-b
xnsenter A
--
ip addr add 1::1/16 dev a-b
# A: hardcoded route to send multicast to (no need for IPv6 - it gets setup'ed automatically via A-B MLD)
xnsenter A
--
ip r add 224.0.0.0/4 dev a-b
xnsenter B
--
ip addr add 2.0.0.2/24 dev
$mtx
scope global
xnsenter B
--
ip addr add 2::2/16 dev
$mtx
scope global
# sleep a bit so that IPv6 address is activated for real on $mtx
# if we don't delay - vvv `ip -6 route ... dev $mtx src ...` fails with "Error: Invalid source address".
#
# XXX isn't it a kernel bug that we have to delay?
# XXX and why delay 3s? (with 1s it always fails, with 2s it still fails sometimes)
sleep
3
# from-external multicast traffic goes to lo
# from-us multicast traffic is sent to the world via lo too
# add explicit rule to route global multicast traffic to lo instead of relying on ad-hoc hack inside Linux kernel:
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/route.c?id=v5.18-rc5-28-ga7391ad35724#n2747
# (see "Apparently, routing tables are wrong. Assume, that the destination is on link." there)
# (present starting from very long ago: Linux 2.1.68 year=1997)
#
# As we are establishing route for multicast, also explicitly specify preferred
# source address with which to send from-us multicast traffic with.
#
# For table local pref ... - see IPv6 case vvv for the rationale. Probably for
# IPv4 this is not strictly required, but we still do it just in case.
xnsenter B
--
ip r add multicast 224.0.0.0/4 oif
$mtx
dev
$mtx
scope global
\
table
local
pref high metric 1
\
src 2.0.0.2
# for IPv6 similar explicit mcast route -> lo is required, because IPv6 routing does not have in-kernel ad-hoc that IPv4 has.
# NOTE Linux, unless patched, turns such lo-routes into rejects, so it won't work without patch to the kernel:
# https://lab.nexedi.com/kirr/linux/commit/25bcc76020c5
#
# Put this route into "local" table with highest possible preference to force
# the kernel to use it even if a neighbour node advertises via MLD its multicast capabilities.
# Upon receiving MLD messages the kernel creates `pref medium` routes in `table
# local`, so if we don't adjust "priority" of our route, it will become ignored.
#
# Also explicitly specify source address.
xnsenter B
--
ip r add multicast ff1e::/16 oif
$mtx
dev
$mtx
scope global
\
table
local
pref high metric 1
\
src 2::2
\
# debug dump of setup routing
Bdebug
()
{
Bshow ip
link
Bshow ip addr
Bshow ip rule
Bshow ip route show table all
;
# Bshow ip r get 2.0.0.17
Bshow ip
-d
r get 224.1.1.1
Bshow ip
-d
r get 224.1.1.1 fibmatch
Bshow ip
-d
r get 224.1.1.1 oif
$mtx
Bshow ip
-d
r get 224.1.1.1 oif
$mtx
fibmatch
# NOTE: fails without explicit multicast -> lo route
Bshow ip
-6
r show table
local
Bshow ip
-6
r show table main
Bshow ip
-6
r show cache
Bshow ip
-d
r get ff1e::1
Bshow ip
-d
r get ff1e::1 fibmatch
Bshow ip
-d
r get ff1e::1 oif
$mtx
Bshow ip
-d
r get ff1e::1 oif
$mtx
fibmatch
Bshow ip
-6
r show cache
Bshow ip mr
Bshow ip
-6
mr
}
#Bdebug
echo
echo
'---------------------------'
echo
# B: start and setup mrouted
Bstartmrouted
()
{
xnsenter B
--
smcrouted
-n
-l
debug &
sleep
1
xnsenter B
--
smcroutectl add b-a 1.0.0.1 224.0.0.0/4
$mtx
xnsenter B
--
smcroutectl add b-a 1::1 ff1e::/16
$mtx
# multicast originating from local host is forwarded to external interfaces
# NOTE when we are sending via mtx, the kernel does not notify mrouted about
# mtx - only about packets on mrx - so we hook into mrx instead of directly
# into mtx.
xnsenter B
--
smcroutectl add
$mrx
2.0.0.2 224.0.0.0/4 b-a
xnsenter B
--
smcroutectl add
$mrx
2::2 ff1e::/16 b-a
#(sleep 4 && Bmrtdump ) &
}
# debug dump from inside about what happens with (m)routing
Bmrtdump
()
{
Bshow smcroutectl
Bshow ip rule
Bshow ip route show table all
Bshow ip mr
Bshow ip r get 224.1.1.1 oif b-a
Bshow ip r get 224.1.1.1 oif
$mtx
;
#Bshow ip r get 224.1.1.1 from 1.0.0.1 oif lo # Network is unreachable
Bshow ip r get 224.1.1.1 from 1.0.0.1 iif b-a
#Bshow ip r get 224.1.1.1 iif b-a Invalid argument
#Bshow ip r get 224.1.1.1 Network is unreachable
#Bshow ip r get 224.1.1.1 fibmatch Network is unreachable
Bshow ip
-6
mr
Bshow ip
-6
r get ff1e::1 fibmatch
Bshow ip
-6
r get ff1e::1
#Bshow cat /proc/net/route
#Bshow cat /proc/net/fib_trie
#Bshow cat /proc/net/ipv6_route
}
# local->local delivery
test_locallocal
()
{
# Bstartmrouted - not started
#xnsenter B -- tshark -lni $mtx &
xnsenter B
--
$(
dirname
$0
)
/tmcast.py
$txrx
B
}
# test ext->local delivery
test_extlocal
()
{
Bstartmrouted
(
sleep
2
&&
echo
-e
"
\n\n\n\n\n
"
&&
xnsenter A
--
$(
dirname
$0
)
/tmcast.py
$tx
A
)
&
xnsenter B
--
$(
dirname
$0
)
/tmcast.py
$rx
}
# test ext<-local
test_localext
()
{
Bstartmrouted
(
echo
-e
"
\n\n\n\n\n
"
&&
xnsenter A
--
$(
dirname
$0
)
/tmcast.py
$rx
)
&
sleep
2
;
xnsenter B
--
$(
dirname
$0
)
/tmcast.py
$tx
B
}
# eval commandline arguments
"
$*
"
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