]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovs-monitor-ipsec.at
datapath: Strip down vport interface - ifIndex.
[mirror_ovs.git] / tests / ovs-monitor-ipsec.at
CommitLineData
b54bdbe9
BP
1AT_BANNER([ovs-monitor-ipsec])
2
3AT_SETUP([ovs-monitor-ipsec])
4AT_SKIP_IF([test $HAVE_PYTHON = no])
5
6OVS_PKGDATADIR=`pwd`; export OVS_PKGDATADIR
7cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
8
9trap 'kill `cat pid ovs-monitor-ipsec.pid`' 0
10
11mkdir etc etc/init.d etc/racoon etc/racoon/certs
12mkdir usr usr/sbin
13
14AT_DATA([etc/init.d/racoon], [dnl
15#! /bin/sh
16echo "racoon: $@" >&3
17exit 0
18])
19chmod +x etc/init.d/racoon
20
21AT_DATA([usr/sbin/setkey], [dnl
22#! /bin/sh
23exec >&3
24echo "setkey:"
25while read line; do
26 echo "> $line"
27done
28])
29chmod +x usr/sbin/setkey
30
31touch etc/racoon/certs/ovs-stale.pem
32
33ovs_vsctl () {
34 ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket "$@"
35}
36trim () { # Removes blank lines and lines starting with # from input.
37 sed -e '/^#/d' -e '/^[ ]*$/d' "$@"
38}
39
40###
41### Start ovsdb-server.
42###
43OVS_VSCTL_SETUP
44
45###
46### Start ovs-monitor-ipsec and wait for it to delete the stale cert.
47###
48AT_CHECK(
49 [$PYTHON $top_srcdir/debian/ovs-monitor-ipsec "--root-prefix=`pwd`" \
b153e667 50 "--pidfile=`pwd`/ovs-monitor-ipsec.pid" \
b54bdbe9
BP
51 unix:socket 2>log 3>actions &])
52AT_CAPTURE_FILE([log])
53AT_CAPTURE_FILE([actions])
54OVS_WAIT_UNTIL([test ! -f etc/racoon/certs/ovs-stale.pem])
55
56###
57### Add an ipsec_gre psk interface and check what ovs-monitor-ipsec does
58###
59AT_CHECK([ovs_vsctl \
60 -- add-br br0 \
61 -- add-port br0 gre0 \
62 -- set interface gre0 type=ipsec_gre \
63 options:remote_ip=1.2.3.4 \
64 options:psk=swordfish])
65OVS_WAIT_UNTIL([test -f actions && grep 'spdadd 1.2.3.4' actions >/dev/null])
66AT_CHECK([cat actions], [0], [dnl
67setkey:
68> flush;
69setkey:
70> spdflush;
71racoon: reload
72racoon: reload
73setkey:
74> spdadd 0.0.0.0/0 1.2.3.4 gre -P out ipsec esp/transport//require;
75> spdadd 1.2.3.4 0.0.0.0/0 gre -P in ipsec esp/transport//require;
76])
77AT_CHECK([trim etc/racoon/psk.txt], [0], [1.2.3.4 swordfish
78])
79AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
80path pre_shared_key "/etc/racoon/psk.txt";
81path certificate "/etc/racoon/certs";
82remote 1.2.3.4 {
83 exchange_mode main;
84 nat_traversal on;
85 proposal {
86 encryption_algorithm aes;
87 hash_algorithm sha1;
88 authentication_method pre_shared_key;
89 dh_group 2;
90 }
91}
92sainfo anonymous {
93 pfs_group 2;
94 lifetime time 1 hour;
95 encryption_algorithm aes;
96 authentication_algorithm hmac_sha1, hmac_md5;
97 compression_algorithm deflate;
98}
99])
100
101###
102### Delete the ipsec_gre interface and check what ovs-monitor-ipsec does
103###
104AT_CHECK([ovs_vsctl del-port gre0])
105OVS_WAIT_UNTIL([test `wc -l < actions` -ge 17])
106AT_CHECK([sed '1,9d' actions], [0], [dnl
107racoon: reload
108setkey:
109> spddelete 0.0.0.0/0 1.2.3.4 gre -P out;
110> spddelete 1.2.3.4 0.0.0.0/0 gre -P in;
111setkey:
112> dump ;
113setkey:
114> dump ;
115])
116AT_CHECK([trim etc/racoon/psk.txt], [0], [])
117AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
118path pre_shared_key "/etc/racoon/psk.txt";
119path certificate "/etc/racoon/certs";
120sainfo anonymous {
121 pfs_group 2;
122 lifetime time 1 hour;
123 encryption_algorithm aes;
124 authentication_algorithm hmac_sha1, hmac_md5;
125 compression_algorithm deflate;
126}
127])
128
129###
130### Add ipsec_gre certificate interface and check what ovs-monitor-ipsec does
131###
132AT_DATA([cert.pem], [dnl
133-----BEGIN CERTIFICATE-----
134(not a real certificate)
135-----END CERTIFICATE-----
136])
137AT_DATA([key.pem], [dnl
138-----BEGIN RSA PRIVATE KEY-----
139(not a real private key)
140-----END RSA PRIVATE KEY-----
141])
142AT_CHECK([ovs_vsctl \
143 -- add-port br0 gre1 \
144 -- set Interface gre1 type=ipsec_gre \
145 options:remote_ip=2.3.4.5 \
146 options:peer_cert='"-----BEGIN CERTIFICATE-----
147(not a real peer certificate)
148-----END CERTIFICATE-----
149"' \
150 options:certificate='"/cert.pem"' \
151 options:private_key='"/key.pem"'])
152OVS_WAIT_UNTIL([test `wc -l < actions` -ge 21])
153AT_CHECK([sed '1,17d' actions], [0], [dnl
154racoon: reload
155setkey:
156> spdadd 0.0.0.0/0 2.3.4.5 gre -P out ipsec esp/transport//require;
157> spdadd 2.3.4.5 0.0.0.0/0 gre -P in ipsec esp/transport//require;
158])
159AT_CHECK([trim etc/racoon/psk.txt], [0], [])
160AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
161path pre_shared_key "/etc/racoon/psk.txt";
162path certificate "/etc/racoon/certs";
163remote 2.3.4.5 {
164 exchange_mode main;
165 nat_traversal on;
166 ike_frag on;
167 certificate_type x509 "/cert.pem" "/key.pem";
168 my_identifier asn1dn;
169 peers_identifier asn1dn;
170 peers_certfile x509 "/etc/racoon/certs/ovs-2.3.4.5.pem";
171 verify_identifier on;
172 proposal {
173 encryption_algorithm aes;
174 hash_algorithm sha1;
175 authentication_method rsasig;
176 dh_group 2;
177 }
178}
179sainfo anonymous {
180 pfs_group 2;
181 lifetime time 1 hour;
182 encryption_algorithm aes;
183 authentication_algorithm hmac_sha1, hmac_md5;
184 compression_algorithm deflate;
185}
186])
187AT_CHECK([cat etc/racoon/certs/ovs-2.3.4.5.pem], [0], [dnl
188-----BEGIN CERTIFICATE-----
189(not a real peer certificate)
190-----END CERTIFICATE-----
191])
192
193###
194### Delete the ipsec_gre certificate interface.
195###
196AT_CHECK([ovs_vsctl del-port gre1])
197OVS_WAIT_UNTIL([test `wc -l < actions` -ge 29])
198AT_CHECK([sed '1,21d' actions], [0], [dnl
199racoon: reload
200setkey:
201> spddelete 0.0.0.0/0 2.3.4.5 gre -P out;
202> spddelete 2.3.4.5 0.0.0.0/0 gre -P in;
203setkey:
204> dump ;
205setkey:
206> dump ;
207])
208AT_CHECK([trim etc/racoon/psk.txt], [0], [])
209AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
210path pre_shared_key "/etc/racoon/psk.txt";
211path certificate "/etc/racoon/certs";
212sainfo anonymous {
213 pfs_group 2;
214 lifetime time 1 hour;
215 encryption_algorithm aes;
216 authentication_algorithm hmac_sha1, hmac_md5;
217 compression_algorithm deflate;
218}
219])
220AT_CHECK([test ! -f etc/racoon/certs/ovs-2.3.4.5.pem])
221
222AT_CLEANUP