Improve 111_fastdp_encryption_2_test.sh

This commit is contained in:
Martynas Pumputis committed 2017-02-10 17:20:24 +00:00
1 parent f592e4b70a
commit 8211afe5d5
1 file changed
+12 -8
+12 -8
View File
@@ -1,30 +1,30 @@
#!/bin/bash
# TODO(mp) 1. test anti-replay 2. test sleeve <-> fastdp
# TODO(mp) test with --trusted-subnets
. "$(dirname "$0")/config.sh"
HOST1_IP=$($SSH $HOST1 getent ahosts $HOST1 | grep "RAW" | cut -d' ' -f1)
HOST2_IP=$($SSH $HOST2 getent ahosts $HOST2 | grep "RAW" | cut -d' ' -f1)
# Assume symmetry
IFACE=$($SSH $HOST1 ip -o route get $HOST2_IP | grep -o 'dev [^ ]*' | cut -d' ' -f2)
start_tcpdump() {
HOST=$1
PCAP=$2
run_on $HOST "sudo nohup tcpdump -i any -w $PCAP >/dev/null 2>&1 & echo \$! > $PCAP.pid"
run_on $HOST "sudo nohup tcpdump -i $IFACE -U -w $PCAP >/dev/null 2>&1 & echo \$! > $PCAP.pid"
}
stop_tcpdump() {
HOST=$1
PCAP=$2
$SSH $HOST "sudo kill \$(cat $PCAP.pid) && rm -f $PCAP.pid && sudo base64 $PCAP" \
$SSH $HOST "sudo kill -sSIGINT \$(cat $PCAP.pid) && rm -f $PCAP.pid && sudo base64 $PCAP" \
| base64 -d > $PCAP
}
# Checks whether all vxlan-tunneled traffic is encrypted.
# Checks whether all VXLAN-tunneled traffic is encrypted.
assert_pcap() {
PCAP=$1
# UDP port is not exposed in ESP
# VXLAN (UDP dst port 6784) packets should be encrypted
assert "tcpdump -r $PCAP 'src $HOST1_IP && dst $HOST2_IP && dst port 6784'" ""
assert "tcpdump -r $PCAP 'src $HOST2_IP && dst $HOST1_IP && dst port 6784'" ""
# ip_proto(ESP) = 50
@@ -55,6 +55,9 @@ start_container $HOST1 $C1/24 --name=c1
start_container $HOST2 $C2/24 --name=c2
assert_raises "exec_on $HOST1 c1 $PING $C2"
# Let tcpdump to flush captures...
sleep 1
stop_tcpdump $HOST1 $PCAP1
stop_tcpdump $HOST2 $PCAP2
@@ -66,6 +69,7 @@ weave_on $HOST2 reset
# the connection.
assert "$SSH $HOST1 sudo ip xfrm state" ""
assert "$SSH $HOST1 sudo ip xfrm policy" ""
assert "$SSH $HOST1 sudo iptables -t mangle -S WEAVE-IPSEC | grep '\-A'" ""
assert "$SSH $HOST1 sudo iptables -t mangle -S WEAVE-IPSEC-IN | grep '\-A'" ""
assert "$SSH $HOST1 sudo iptables -t mangle -S WEAVE-IPSEC-OUT | grep '\-A'" ""
end_suite