Skip to content

Instantly share code, notes, and snippets.

@T-X
Created May 15, 2019 16:23
Show Gist options
  • Save T-X/b585768892bda7d652406c71365a2b27 to your computer and use it in GitHub Desktop.
Save T-X/b585768892bda7d652406c71365a2b27 to your computer and use it in GitHub Desktop.
Multicast Interface Table
Mif PhyIF Local-Address/Prefixlen Scope GenID Flags
0 wan0 fe80::11:22ff:fe00:1/64 5 3a862963 PIM QRY
fd5c:725:2841::1/64 0
Timers: PIM hello = 0:15, MLD query = 0:10
possible MLD version = 1
1 lan0 fe80::6432:1fff:fe52:2403/64 4 124c41ed QRY NO-NBR DR
fd5c:725:2841:101::1/64 0
Timers: PIM hello = 0:15, MLD query = 0:10
possible MLD version = 1
2 regist fe80::11:22ff:fe00:1/64 5 0 REGISTER
Timers: PIM hello = 0:00, MLD query = 0:00
possible MLD version = 1
PIM Neighbor List
Mif PhyIF Address Timer Prio GenID Flags
0 wan0 fe80::11:22ff:fe00:2 90 1 3a862963 D
fd5c:725:2841::2
MLD Querier List
Mif PhyIF Address Timer Last
0 wan0 fe80::11:22ff:fe00:1 255 35m46s
1 lan0 fe80::6432:1fff:fe52:2403 255 35m46s
Reported MLD Group
Mif PhyIF Group(Group-Timer,MLD-ver(Filter-Mode,Compat-Timer))/Source(TimerID)
0 wan0 ff05::2 (#461 (v1 EX #0))
(any source) (-)
1 lan0 ff05::2 (#463 (v1 EX #0))
(any source) (-)
1 lan0 ff13:23:42:ffff::123 (#460 (v1 EX #0))
(any source) (-)
Multicast Routing Table
Source Group RP-addr Flags
--------------------------(*,*,RP)--------------------------
Number of Groups: 0
Number of Cache MIRRORs: 0
---------------------------RP-Set----------------------------
Current BSR address: fd5c:725:2841::2 Prio: 0 Timeout: 125
RP-address(Upstream)/Group prefix Prio Hold Age
fd5c:725:2841:1::3(none)
ff13:23:42:ffff::/64 0 150 115
Multicast Interface Table
Mif PhyIF Local-Address/Prefixlen Scope GenID Flags
0 wan0 fe80::11:22ff:fe00:2/64 4 3a862963 PIM DR
fd5c:725:2841::2/64 0
Timers: PIM hello = 0:05, MLD query = 0:30
possible MLD version = 1
1 wan1 fe80::11:22ff:fe00:102/64 6 124c41ed PIM QRY
fd5c:725:2841:1::2/64 0
Timers: PIM hello = 0:05, MLD query = 1:35
possible MLD version = 1
2 lan0 fe80::1097:23ff:fe17:5967/64 7 7ffd9f20 QRY NO-NBR DR
fd5c:725:2841:102::1/64 0
Timers: PIM hello = 0:05, MLD query = 1:35
possible MLD version = 1
3 regist fe80::11:22ff:fe00:2/64 4 0 REGISTER
Timers: PIM hello = 0:00, MLD query = 0:00
possible MLD version = 1
PIM Neighbor List
Mif PhyIF Address Timer Prio GenID Flags
0 wan0 fe80::11:22ff:fe00:1 80 1 3a862963
fd5c:725:2841::1
1 wan1 fe80::11:22ff:fe00:103 80 1 3a862963 D
fd5c:725:2841:1::3
MLD Querier List
Mif PhyIF Address Timer Last
0 wan0 fe80::11:22ff:fe00:1 225 36m29s
1 wan1 fe80::11:22ff:fe00:102 255 36m29s
2 lan0 fe80::1097:23ff:fe17:5967 255 36m29s
Reported MLD Group
Mif PhyIF Group(Group-Timer,MLD-ver(Filter-Mode,Compat-Timer))/Source(TimerID)
0 wan0 ff05::2 (#508 (v1 EX #0))
(any source) (-)
1 wan1 ff05::2 (#510 (v1 EX #0))
(any source) (-)
2 lan0 ff05::2 (#507 (v1 EX #0))
(any source) (-)
2 lan0 ff13:23:42:ffff::123 (#506 (v1 EX #0))
(any source) (-)
Multicast Routing Table
Source Group RP-addr Flags
---------------------------(*,G)----------------------------
IN6ADDR_ANY ff13:23:42:ffff::123 fd5c:725:2841:1::3 WC RP
Joined oifs: ....
Pruned oifs: ....
Leaves oifs: ..l.
Asserted oifs: ....
Outgoing oifs: ..o.
Incoming : .I..
Upstream nbr: fe80::11:22ff:fe00:103
TIMERS: Entry=0 JP=10 RS=0 Assert=0
MIF 0 1 2 3 4 5 6 7 8 9
0 0 0 0 0
--------------------------(*,*,RP)--------------------------
Number of Groups: 1
Number of Cache MIRRORs: 0
---------------------------RP-Set----------------------------
Current BSR address: fd5c:725:2841::2 Prio: 0 Timeout: 45
RP-address(Upstream)/Group prefix Prio Hold Age
fd5c:725:2841:1::3(fe80::11:22ff:fe00:103%wan1)
ff13:23:42:ffff::/64 0 150 130
Multicast Interface Table
Mif PhyIF Local-Address/Prefixlen Scope GenID Flags
0 wan0 fe80::11:22ff:fe00:103/64 5 3a862963 PIM DR
fd5c:725:2841:1::3/64 0
Timers: PIM hello = 0:05, MLD query = 0:30
possible MLD version = 1
1 lan0 fe80::1c65:52ff:fe1f:373e/64 4 124c41ed QRY NO-NBR DR
fd5c:725:2841:103::1/64 0
Timers: PIM hello = 0:05, MLD query = 0:35
possible MLD version = 1
2 regist fe80::11:22ff:fe00:103/64 5 0 REGISTER
Timers: PIM hello = 0:00, MLD query = 0:00
possible MLD version = 1
PIM Neighbor List
Mif PhyIF Address Timer Prio GenID Flags
0 wan0 fe80::11:22ff:fe00:102 80 1 124c41ed
fd5c:725:2841:1::2
MLD Querier List
Mif PhyIF Address Timer Last
0 wan0 fe80::11:22ff:fe00:102 165 37m26s
1 lan0 fe80::1c65:52ff:fe1f:373e 255 37m26s
Reported MLD Group
Mif PhyIF Group(Group-Timer,MLD-ver(Filter-Mode,Compat-Timer))/Source(TimerID)
0 wan0 ff05::2 (#471 (v1 EX #0))
(any source) (-)
1 lan0 ff05::2 (#470 (v1 EX #0))
(any source) (-)
Multicast Routing Table
Source Group RP-addr Flags
---------------------------(*,G)----------------------------
IN6ADDR_ANY ff13:23:42:ffff::123 fd5c:725:2841:1::3 WC RP
Joined oifs: j..
Pruned oifs: ...
Leaves oifs: ...
Asserted oifs: ...
Outgoing oifs: o..
Incoming : ..I
Upstream nbr: NONE
TIMERS: Entry=160 JP=15 RS=0 Assert=0
MIF 0 1 2 3 4 5 6 7 8 9
0 160 0 0
---------------------------(S,G)----------------------------
fd5c:725:2841:103::2 ff13:23:42:ffff::123 fd5c:725:2841:1::3 SPT CACHE SG
Joined oifs: ...
Pruned oifs: ...
Leaves oifs: ...
Asserted oifs: ...
Outgoing oifs: o..
Incoming : .I.
Upstream nbr: NONE
TIMERS: Entry=195 JP=20 RS=0 Assert=0
MIF 0 1 2 3 4 5 6 7 8 9
0 0 0 0
--------------------------(*,*,RP)--------------------------
Number of Groups: 1
Number of Cache MIRRORs: 1
---------------------------RP-Set----------------------------
Current BSR address: fd5c:725:2841::2 Prio: 0 Timeout: 145
RP-address(Upstream)/Group prefix Prio Hold Age
fd5c:725:2841:1::3(myself)
ff13:23:42:ffff::/64 0 150 135
#!/bin/sh
PIMDEBUG="-d pim_bootstrap,pim_join_prune"
PIMD="/home/linus/dev-priv/pim6sd/src/pim6sd $PIMDEBUG"
NSR0="ip netns exec pimtest-router0"
NSR1="ip netns exec pimtest-router1"
NSR2="ip netns exec pimtest-router2"
NSC0="ip netns exec pimtest-client0"
NSC1="ip netns exec pimtest-client1"
NSC2="ip netns exec pimtest-client2"
setup() {
### Wiring
ip netns add pimtest-router0
ip netns add pimtest-router1
ip netns add pimtest-router2
ip netns add pimtest-client0
ip netns add pimtest-client1
ip netns add pimtest-client2
# router0 <-> router1 (wan0 <-> wan0)
$NSR0 ip link add wan0 type veth peer name wan1
$NSR0 ip link set addr 02:11:22:00:00:02 netns pimtest-router1 name wan0 up dev wan1
$NSR0 ip link set addr 02:11:22:00:00:01 up dev wan0
# router1 <-> router2 (wan1 <-> wan0)
$NSR1 ip link add wan1 type veth peer name wan2
$NSR1 ip link set addr 02:11:22:00:01:03 netns pimtest-router2 name wan0 up dev wan2
$NSR1 ip link set addr 02:11:22:00:01:02 up dev wan1
# lan0: router0 <-> client0
$NSC0 ip link add lan0 type veth peer name lan1
$NSC0 ip link set netns pimtest-router0 name lan0 up dev lan1
$NSC0 ip link set up dev lan0
# lan0: router1 <-> client1
$NSC1 ip link add lan0 type veth peer name lan1
$NSC1 ip link set netns pimtest-router1 name lan0 up dev lan1
$NSC1 ip link set up dev lan0
# lan0: router2 <-> client2
$NSC2 ip link add lan0 type veth peer name lan1
$NSC2 ip link set netns pimtest-router2 name lan0 up dev lan1
$NSC2 ip link set up dev lan0
### Addresses
$NSR0 ip address add fd5c:725:2841::1/64 dev wan0
$NSR1 ip address add fd5c:725:2841::2/64 dev wan0
$NSR1 ip address add fd5c:725:2841:1::2/64 dev wan1
$NSR2 ip address add fd5c:725:2841:1::3/64 dev wan0
$NSR0 ip address add fd5c:725:2841:101::1/64 dev lan0
$NSR1 ip address add fd5c:725:2841:102::1/64 dev lan0
$NSR2 ip address add fd5c:725:2841:103::1/64 dev lan0
$NSC0 ip address add fd5c:725:2841:101::2/64 dev lan0
$NSC1 ip address add fd5c:725:2841:102::2/64 dev lan0
$NSC2 ip address add fd5c:725:2841:103::2/64 dev lan0
### Routing
$NSR0 /bin/bash -c "echo 1 > /proc/sys/net/ipv6/conf/all/forwarding"
$NSR1 /bin/bash -c "echo 1 > /proc/sys/net/ipv6/conf/all/forwarding"
$NSR2 /bin/bash -c "echo 1 > /proc/sys/net/ipv6/conf/all/forwarding"
# router0 -> router2
$NSR0 ip -6 r add fd5c:725:2841:1::/64 via fd5c:725:2841::2
# router2 -> router0
$NSR2 ip -6 route add fd5c:725:2841::/64 via fd5c:725:2841:1::2
# router0 -> {client1, client2}
$NSR0 ip -6 r add fd5c:725:2841:102::/64 via fd5c:725:2841::2
$NSR0 ip -6 r add fd5c:725:2841:103::/64 via fd5c:725:2841::2
# router1 -> {client0, client2}
$NSR1 ip -6 r add fd5c:725:2841:101::/64 via fd5c:725:2841::1
$NSR1 ip -6 r add fd5c:725:2841:103::/64 via fd5c:725:2841:1::3
# router2 -> {client0, client0}
$NSR2 ip -6 r add fd5c:725:2841:101::/64 via fd5c:725:2841:1::2
$NSR2 ip -6 r add fd5c:725:2841:102::/64 via fd5c:725:2841:1::2
# client* -> *
$NSC0 ip -6 route add default via fd5c:725:2841:101::1
$NSC1 ip -6 route add default via fd5c:725:2841:102::1
$NSC2 ip -6 route add default via fd5c:725:2841:103::1
}
teardown() {
$NSR0 ip address flush dev wan0
$NSR1 ip address flush dev wan0
$NSR1 ip address flush dev wan1
$NSR2 ip address flush dev wan0
$NSR0 ip link del dev wan0
$NSR1 ip link del dev wan1
$NSR0 ip link del dev lan0
$NSR1 ip link del dev lan0
$NSR2 ip link del dev lan0
ip netns delete pimtest-router0
ip netns delete pimtest-router1
ip netns delete pimtest-router2
ip netns delete pimtest-client0
ip netns delete pimtest-client1
ip netns delete pimtest-client2
}
start_services() {
mkdir /tmp/pimtest 2> /dev/null
cat > /tmp/pimtest/router0.conf <<EOF
default_phyint_status disable;
phyint wan0 enable;
phyint lan0 enable;
EOF
cat > /tmp/pimtest/router1.conf <<EOF
default_phyint_status disable;
phyint wan0 enable;
phyint wan1 enable;
phyint lan0 enable;
cand_bootstrap_router wan0;
EOF
cat > /tmp/pimtest/router2.conf <<EOF
default_phyint_status disable;
phyint wan0 enable;
phyint lan0 enable;
cand_rp wan0;
group_prefix ff13:23:42:ffff::/64;
EOF
$NSR0 $PIMD -n -f /tmp/pimtest/router0.conf > /tmp/pimtest/router0.log 2>&1 &
echo "$!" > /tmp/pimtest/router0.pid
$NSR1 $PIMD -n -f /tmp/pimtest/router1.conf > /tmp/pimtest/router1.log 2>&1 &
echo "$!" > /tmp/pimtest/router1.pid
$NSR2 $PIMD -n -f /tmp/pimtest/router2.conf > /tmp/pimtest/router2.log 2>&1 &
echo "$!" > /tmp/pimtest/router2.pid
$NSC0 socat -u UDP6-RECV:1234,reuseaddr,ipv6-join-group="[ff13:23:42:ffff::123]:lan0" - &
echo "$!" > /tmp/pimtest/client0.pid
$NSC1 socat -u UDP6-RECV:1234,reuseaddr,ipv6-join-group="[ff13:23:42:ffff::123]:lan0" - &
echo "$!" > /tmp/pimtest/client1.pid
$NSC2 ping6 -q ff13:23:42:ffff::123 2> /dev/null &
echo "$!" > /tmp/pimtest/client2.pid
}
stop_services() {
[ -f /tmp/pimtest/router0.pid ] && \
kill $(cat /tmp/pimtest/router0.pid)
[ -f /tmp/pimtest/router1.pid ] && \
kill $(cat /tmp/pimtest/router1.pid)
[ -f /tmp/pimtest/router2.pid ] && \
kill $(cat /tmp/pimtest/router2.pid)
[ -f /tmp/pimtest/client0.pid ] && \
kill $(cat /tmp/pimtest/client0.pid)
[ -f /tmp/pimtest/client1.pid ] && \
kill $(cat /tmp/pimtest/client1.pid)
[ -f /tmp/pimtest/client2.pid ] && \
kill $(cat /tmp/pimtest/client2.pid)
rm /tmp/pimtest/router0.pid 2> /dev/null
rm /tmp/pimtest/router1.pid 2> /dev/null
rm /tmp/pimtest/router2.pid 2> /dev/null
rm /tmp/pimtest/client0.pid 2> /dev/null
rm /tmp/pimtest/client1.pid 2> /dev/null
rm /tmp/pimtest/client2.pid 2> /dev/null
rm /tmp/pimtest/router0.conf 2> /dev/null
rm /tmp/pimtest/router1.conf 2> /dev/null
rm /tmp/pimtest/router2.conf 2> /dev/null
}
stop_services
teardown
echo "Starting setup"
sleep 3
setup
start_services
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment