Skip to content

Instantly share code, notes, and snippets.

@vi
Last active December 17, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vi/5640512 to your computer and use it in GitHub Desktop.
Save vi/5640512 to your computer and use it in GitHub Desktop.
Script to reproduce bug 58691 in linux kernel
#!/bin/bash
# Reproduce https://bugzilla.kernel.org/show_bug.cgi?id=58691
# Depends: sshd listening :22, ssh, unshare, setkey(ipsec-tools), iproute2, ip6_tunnel.ko, veth, radvd
modprobe ip6_tunnel
export MYPID=$$
rm /tmp/unshare_pid
while true; do
if [ -e /tmp/unshare_pid ]; then
#ip link set qqq_2 netns `cat /tmp/unshare_pid`
ip link set veth_cm mtu 1280 up
ip -6 addr add fc::1 dev veth_cm
ip -6 route add fc::2 dev veth_cm
setkey -c << EOF
spdadd fc::1 fc::2 any -P out ipsec esp/transport//require ah/transport//require ;
spdadd fc::2 fc::1 any -P in ipsec esp/transport//require ah/transport//require;
add fc::2 fc::1 esp 123457 -E rijndael-cbc 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::1 fc::2 esp 123457 -E rijndael-cbc 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::2 fc::1 ah 123456 -A hmac-sha256 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::1 fc::2 ah 123456 -A hmac-sha256 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
EOF
ip -6 tunnel add name qqq mode ipip6 local fc::1 remote fc::2 dev veth_cm
ip link set qqq mtu 1280 up
ip -4 addr add 192.168.72.1 dev qqq
ip -4 route add 192.168.72.2 dev qqq
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
cat > /tmp/bug_radvd.conf << \EOF
interface veth_cm {
AdvSendAdvert on;
AdvLinkMTU 1280;
MaxRtrAdvInterval 20;
MinRtrAdvInterval 5;
AdvDefaultLifetime 30;
AdvSourceLLAddress off;
AdvHomeAgentFlag on;
prefix 2001:470:7bd6:c004::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvValidLifetime 60;
AdvPreferredLifetime 30;
AdvRouterAddr off;
};
};
EOF
killall radvd
radvd -C /tmp/bug_radvd.conf
rm /tmp/unshare_pid
break;
else
sleep 0.1
fi
done &
unshare -n sh << \EOF2
ip link add name veth_c type veth peer name veth_cm
ip link set veth_cm netns $MYPID
echo $$ > /tmp/unshare_pid
#until ip link show qqq_2 2> /dev/null; do sleep 0.1; done
ip link set veth_c mtu 1280 up
ip -6 addr add fc::2 dev veth_c
ip -6 route add fc::1 dev veth_c
setkey -c << EOF
spdadd fc::1 fc::2 any -P in ipsec esp/transport//require ah/transport//require ;
spdadd fc::2 fc::1 any -P out ipsec esp/transport//require ah/transport//require;
add fc::2 fc::1 esp 123457 -E rijndael-cbc 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::1 fc::2 esp 123457 -E rijndael-cbc 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::2 fc::1 ah 123456 -A hmac-sha256 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
add fc::1 fc::2 ah 123456 -A hmac-sha256 0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF ;
EOF
ip -6 tunnel add name qqq mode ipip6 local fc::2 remote fc::1 dev veth_c
ip link set qqq mtu 1280 up
ip -4 addr add 192.168.72.2 dev qqq
ip -4 route add 192.168.72.1 dev qqq
echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
until ip -6 addr | grep 2001; do sleep 0.2; done
#bash -i < /dev/tty
ssh 192.168.72.1 < /dev/tty
EOF2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment