@@ -26,25 +26,6 @@ do_ovn_ipsec_encryption_check () {
2626 DATE=$( date +" %Y-%m-%d" )
2727 PCAP_FILENAME=" ipsec-test-${DATE} .pcap"
2828
29- # TODO check with oc get network.operator.openshift.io/cluster -o=jsonpath='{.items[*].spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig}'
30- # once tests can be run with real cluster
31- if [ -z " $IPSEC_PODS " ]; then # || [ "$IPSEC_ENABLED" ]; then
32- echo " No ovn-ipsec pods exist, tunnel traffic will be unencrypted"
33- return 0
34- else
35- echo " ovn-ipsec is enabled, tunnel traffic should be encryted"
36- return 1
37- fi
38-
39- }
40-
41- do_ovn_ipsec_encryption_check () {
42- WORKER_NODES=($( get_worker_nodes_linux) )
43- DATE=$( date +" %Y-%m-%d" )
44- PCAP_FILENAME=" ipsec-test-${DATE} .pcap"
45-
46- # TODO check with oc get network.operator.openshift.io/cluster -o=jsonpath='{.items[*].spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig}'
47- # once tests can be run with real cluster
4829 if ! [ check_ovn_ipsec_enabled ]; then
4930 exit 0
5031 fi
@@ -55,6 +36,9 @@ do_ovn_ipsec_encryption_check () {
5536
5637 create_pod_on_node $client_debug_pod " ${WORKER_NODES[0]} "
5738 create_pod_on_node $server_debug_pod " ${WORKER_NODES[1]} "
39+
40+ global_namespace=$( oc get pod $client_debug_pod -o jsonpath={.metadata.namespace})
41+
5842 create_host_network_pod_on_node $sniffer_debug_pod " ${WORKER_NODES[1]} " " $global_namespace "
5943
6044 server_debug_pod_ip=$( get_pod_ip " $global_namespace " " $server_debug_pod " )
@@ -66,14 +50,13 @@ do_ovn_ipsec_encryption_check () {
6650 interface=${interface// $' \n ' / }
6751 echo " INFO: Ethernet Interface name is: ${interface} "
6852
69- echo " INFO: packet sniffing command is: tcpdump -i ${interface} -vv -c 2 -w ${PCAP_FILENAME} src \
70- $( kubectl get node " ${WORKER_NODES[0 ]} " -o jsonpath=' {.status.addresses[?(@.type=="InternalIP")].address}' ) \
71- && dst $( kubectl get node " ${WORKER_NODES[1]} " -o jsonpath= ' {.status.addresses[?(@.type=="InternalIP")].address} ' ) "
53+ tcpdump_expression= " src $( kubectl get node " ${WORKER_NODES[0]} " -o jsonpath= ' {.status.addresses[?(@.type=="InternalIP")].address} ' ) \
54+ and dst $( kubectl get node " ${WORKER_NODES[1 ]} " -o jsonpath=' {.status.addresses[?(@.type=="InternalIP")].address}' ) "
55+ tcpdump_command= " tcpdump -i ${interface} -vv -c 2 -w ${PCAP_FILENAME} ${tcpdump_expression} "
7256
57+ echo " INFO: packet sniffing command is: ${tcpdump_command} "
7358 # start sniffer in host networked pod, but only look for packets going over the tunnel from node1 -> node2
74-
75- oc rsh -n " $global_namespace " ${sniffer_debug_pod} timeout 30s tcpdump -i ${interface} -vv -c 2 -w " ${PCAP_FILENAME} " \
76- src " $( kubectl get node " ${WORKER_NODES[0]} " -o jsonpath=' {.status.addresses[?(@.type=="InternalIP")].address}' ) " and dst " $( kubectl get node " ${WORKER_NODES[1]} " -o jsonpath=' {.status.addresses[?(@.type=="InternalIP")].address}' ) " > /dev/null 2>&1 \
59+ oc rsh -n " $global_namespace " ${sniffer_debug_pod} timeout 30s ${tcpdump_command} > /dev/null 2>&1 \
7760 & PID=$!
7861
7962 echo " INFO: pinging server from client pod: oc rsh ${client_debug_pod} ping ${server_debug_pod_ip} -c 5 -W 2"
@@ -84,24 +67,22 @@ do_ovn_ipsec_encryption_check () {
8467
8568 oc cp -n " $global_namespace " --loglevel 1 ${sniffer_debug_pod} :/${PCAP_FILENAME} ./${logdir} /${PCAP_FILENAME} > /dev/null 2>&1 && PIDS+=($! )
8669
87- if [ -f " ${PCAP_FILENAME} " ]; then
88- if tshark -r " ${PCAP_FILENAME} " -T fields -e frame.protocols | grep -q " esp" ; then
70+ if [ -f " ./ ${logdir} / ${PCAP_FILENAME} " ]; then
71+ if tshark -r " ./ ${logdir} / ${PCAP_FILENAME} " -T fields -e frame.protocols | grep -q " esp" ; then
8972 echo " "
9073 echo " INFO:Tunnel traffic is encrypted with ovn-ipsec!"
9174 echo " "
9275 else
9376 echo " "
94- echo " INFO:Tunnel traffic is not encrypted, check pcap: ${ PCAP_FILENAME} for further details"
77+ echo " INFO:Tunnel traffic is not encrypted, check pcap: " ./ ${logdir} / ${ PCAP_FILENAME}" for further details"
9578 echo " "
9679 fi
9780 else
9881 echo " INFO:tcpdump error ${PCAP_FILENAME} wasn't written"
9982 fi
10083
10184 # # cleanup resources
102-
10385 oc delete pod $server_debug_pod $client_debug_pod $sniffer_debug_pod
104-
10586}
10687
10788help ()
@@ -135,6 +116,4 @@ while getopts ":h" option; do
135116 esac
136117done
137118
138- global_namespace=" ${1} "
139-
140119main
0 commit comments