]> git.proxmox.com Git - mirror_ovs.git/blame - tests/tunnel-push-pop.at
tests: Fix race in MPLS translate.
[mirror_ovs.git] / tests / tunnel-push-pop.at
CommitLineData
a36de779
PS
1AT_BANNER([tunnel_push_pop])
2
3AT_SETUP([tunnel_push_pop - action])
4
7f9b8504 5OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00])
d32754b4
JR
6AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy], [0])
7AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \
a36de779
PS
8 options:remote_ip=1.1.2.92 options:key=123 ofport_request=2\
9 -- add-port int-br t1 -- set Interface t1 type=gre \
c876a4bb
RL
10 options:remote_ip=1.1.2.92 options:key=456 ofport_request=3\
11 -- add-port int-br t3 -- set Interface t3 type=vxlan \
8e45fe7c 12 options:remote_ip=1.1.2.93 options:out_key=flow options:csum=true ofport_request=4\
e5a1caee 13 -- add-port int-br t4 -- set Interface t4 type=geneve \
eaac0f22 14 options:remote_ip=flow options:key=123 ofport_request=5\
bf4bbd0d
PS
15 -- add-port int-br t5 -- set Interface t5 type=geneve \
16 options:remote_ip=1.1.2.93 options:out_key=flow options:egress_pkt_mark=1234 ofport_request=6\
c876a4bb 17 ], [0])
a36de779
PS
18
19AT_CHECK([ovs-appctl dpif/show], [0], [dnl
20dummy@ovs-dummy: hit:0 missed:0
21 br0:
e98d0cb3 22 br0 65534/100: (dummy-internal)
d32754b4 23 p0 1/1: (dummy)
a36de779 24 int-br:
e98d0cb3 25 int-br 65534/2: (dummy-internal)
d32754b4 26 t1 3/3: (gre: key=456, remote_ip=1.1.2.92)
a36de779 27 t2 2/4789: (vxlan: key=123, remote_ip=1.1.2.92)
8e45fe7c 28 t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=1.1.2.93)
eaac0f22 29 t4 5/6081: (geneve: key=123, remote_ip=flow)
bf4bbd0d 30 t5 6/6081: (geneve: egress_pkt_mark=1234, out_key=flow, remote_ip=1.1.2.93)
a36de779
PS
31])
32
7f9b8504
PS
33dnl First setup dummy interface IP address, then add the route
34dnl so that tnl-port table can get valid IP address for the device.
a36de779
PS
35AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
36])
80c4589a
PS
37AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:cafe::88/24], [0], [OK
38])
39
7f9b8504
PS
40AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0], [0], [OK
41])
a36de779 42
ed52ca57
PS
43AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0 pkt_mark=1234], [0], [OK
44])
45
a36de779
PS
46AT_CHECK([ovs-ofctl add-flow br0 action=normal])
47
80c4589a
PS
48dnl Check ARP request
49AT_CHECK([ovs-vsctl -- set Interface p0 options:pcap=p0.pcap])
50
51AT_CHECK([ovs-appctl netdev-dummy/receive int-br 'in_port(2),eth(src=aa:55:aa:55:00:00,dst=f8:bc:12:ff:ff:ff),eth_type(0x0800),ipv4(src=1.1.3.92,dst=1.1.3.88,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'])
e9407a81
DDP
52
53dnl Wait for the two ARP requests to be sent. Sometimes the system
54dnl can be slow (e.g. under valgrind)
55OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | sort | uniq | wc -l` -ge 2])
56
56e18591 57AT_CHECK([ovs-pcap p0.pcap > p0.pcap.txt 2>&1])
80c4589a 58
56e18591
PS
59AT_CHECK([cat p0.pcap.txt | grep 101025c | uniq], [0], [dnl
60ffffffffffffaa55aa55000008060001080006040001aa55aa550000010102580000000000000101025c
80c4589a 61])
56e18591
PS
62AT_CHECK([cat p0.pcap.txt | grep 101025d | uniq], [0], [dnl
63ffffffffffffaa55aa55000008060001080006040001aa55aa550000010102580000000000000101025d
80c4589a
PS
64])
65
a36de779 66dnl Check ARP Snoop
b23ddcc5
PS
67AT_CHECK([ovs-appctl netdev-dummy/receive br0 'recirc_id(0),in_port(100),eth(src=f8:bc:12:44:34:b6,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b6,tha=00:00:00:00:00:00)'])
68AT_CHECK([ovs-appctl netdev-dummy/receive br0 'recirc_id(0),in_port(100),eth(src=f8:bc:12:44:34:b7,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),arp(sip=1.1.2.93,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b7,tha=00:00:00:00:00:00)'])
a36de779 69
7eca52f1 70AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl
4673650f
TLSC
711.1.2.92 f8:bc:12:44:34:b6 br0
721.1.2.93 f8:bc:12:44:34:b7 br0
a36de779
PS
73])
74
6d9e94b5
AZ
75AT_CHECK([ovs-appctl tnl/ports/show |sort], [0], [dnl
76Listening ports:
7f9b8504
PS
77genev_sys_6081 (6081)
78gre_sys (3)
79vxlan_sys_4789 (4789)
6d9e94b5
AZ
80])
81
a36de779 82dnl Check VXLAN tunnel pop
7f9b8504 83AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=17,tos=0,ttl=64,frag=no),udp(src=51283,dst=4789)'], [0], [stdout])
a36de779
PS
84AT_CHECK([tail -1 stdout], [0],
85 [Datapath actions: tnl_pop(4789)
86])
87
88dnl Check GRE tunnel pop
7f9b8504 89AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
a36de779 90AT_CHECK([tail -1 stdout], [0],
d32754b4 91 [Datapath actions: tnl_pop(3)
a36de779
PS
92])
93
e5a1caee 94dnl Check Geneve tunnel pop
7f9b8504 95AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=17,tos=0,ttl=64,frag=no),udp(src=51283,dst=6081)'], [0], [stdout])
e5a1caee
JG
96AT_CHECK([tail -1 stdout], [0],
97 [Datapath actions: tnl_pop(6081)
98])
99
bf4bbd0d
PS
100dnl Check Geneve tunnel (t6) pop
101AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.2.96,dst=1.1.2.88,proto=17,tos=0,ttl=64,frag=no),udp(src=51283,dst=6081)'], [0], [stdout])
102AT_CHECK([tail -1 stdout], [0],
103 [Datapath actions: tnl_pop(6081)
104])
105
a36de779
PS
106dnl Check VXLAN tunnel push
107AT_CHECK([ovs-ofctl add-flow int-br action=2])
108AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
109AT_CHECK([tail -1 stdout], [0],
fa47c114 110 [Datapath actions: tnl_push(tnl_port(4789),header(size=50,type=4,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=4789,csum=0x0),vxlan(flags=0x8000000,vni=0x7b)),out_port(100))
a36de779
PS
111])
112
8e45fe7c 113dnl Check VXLAN tunnel push set tunnel id by flow and checksum
c876a4bb
RL
114AT_CHECK([ovs-ofctl add-flow int-br "actions=set_tunnel:124,4"])
115AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
116AT_CHECK([tail -1 stdout], [0],
fa47c114 117 [Datapath actions: tnl_push(tnl_port(4789),header(size=50,type=4,eth(dst=f8:bc:12:44:34:b7,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.93,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=4789,csum=0xffff),vxlan(flags=0x8000000,vni=0x7c)),out_port(100))
c876a4bb
RL
118])
119
a36de779
PS
120dnl Check GRE tunnel push
121AT_CHECK([ovs-ofctl add-flow int-br action=3])
122AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
123AT_CHECK([tail -1 stdout], [0],
fa47c114 124 [Datapath actions: tnl_push(tnl_port(3),header(size=42,type=3,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x2000,proto=0x6558),key=0x1c8)),out_port(100))
a36de779
PS
125])
126
e5a1caee 127dnl Check Geneve tunnel push
eaac0f22 128AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:1.1.2.92->tun_dst,5"])
e5a1caee
JG
129AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
130AT_CHECK([tail -1 stdout], [0],
fa47c114 131 [Datapath actions: tnl_push(tnl_port(6081),header(size=50,type=5,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=6081,csum=0x0),geneve(vni=0x7b)),out_port(100))
e5a1caee
JG
132])
133
bf4bbd0d
PS
134dnl Check Geneve tunnel push with pkt-mark
135AT_CHECK([ovs-ofctl add-flow int-br "actions=set_tunnel:234,6"])
136AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
137AT_CHECK([tail -1 stdout], [0],
138 [Datapath actions: set(skb_mark(0x4d2)),tnl_push(tnl_port(6081),header(size=50,type=5,eth(dst=f8:bc:12:44:34:b7,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.93,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=6081,csum=0x0),geneve(vni=0xea)),out_port(100))
139])
140
5bb08b0e 141dnl Check Geneve tunnel push with options
4e548ad9 142AT_CHECK([ovs-ofctl add-tlv-map int-br "{class=0xffff,type=0x80,len=4}->tun_metadata0"])
5bb08b0e
JG
143AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:1.1.2.92->tun_dst,set_field:0xa->tun_metadata0,5"])
144AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout])
145AT_CHECK([tail -1 stdout], [0],
fa47c114 146 [Datapath actions: tnl_push(tnl_port(6081),header(size=58,type=5,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=6081,csum=0x0),geneve(crit,vni=0x7b,options({class=0xffff,type=0x80,len=4,0xa}))),out_port(100))
5bb08b0e
JG
147])
148
6432e527 149dnl Check decapsulation of GRE packet
f41256d7 150AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
6432e527
JG
151ovs-appctl time/warp 1000
152
153AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl
d6e3feb5 154 port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
6432e527
JG
155])
156
157dnl Check GRE only accepts encapsulated Ethernet frames
f41256d7 158AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
6432e527
JG
159ovs-appctl time/warp 1000
160
161AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl
d6e3feb5 162 port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
6432e527
JG
163])
164
5bb08b0e 165dnl Check decapsulation of Geneve packet with options
2234a7db
JG
166AT_CAPTURE_FILE([ofctl_monitor.log])
167AT_CHECK([ovs-ofctl monitor int-br 65534 --detach --no-chdir --pidfile 2> ofctl_monitor.log])
168
5bb08b0e 169AT_CHECK([ovs-ofctl del-flows int-br])
2234a7db 170AT_CHECK([ovs-ofctl add-flow int-br "tun_metadata0=0xa/0xf,actions=5,controller"])
f41256d7 171AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab64080045000096794640004011ba5b0101025c01010258308817c1008200000400655800007b00ffff80010000000affff00010000000bfe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
5bb08b0e 172
2234a7db
JG
173OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
174OVS_APP_EXIT_AND_WAIT(ovs-ofctl)
175
176AT_CHECK([cat ofctl_monitor.log], [0], [dnl
6409e008 177NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=98 tun_id=0x7b,tun_src=1.1.2.92,tun_dst=1.1.2.88,tun_metadata0=0xa,in_port=5 (via action) data_len=98 (unbuffered)
2234a7db
JG
178icmp,vlan_tci=0x0000,dl_src=be:b6:f4:e1:49:4a,dl_dst=fe:71:d8:83:72:4f,nw_src=30.0.0.1,nw_dst=30.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum:4227
179])
180
5bb08b0e 181AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 5'], [0], [dnl
d6e3feb5 182 port 5: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
5bb08b0e 183])
f5ca7ec2 184AT_CHECK([ovs-appctl dpif/dump-flows int-br | grep 'in_port(6081)'], [0], [dnl
2b02d770 185tunnel(tun_id=0x7b,src=1.1.2.92,dst=1.1.2.88,geneve({class=0xffff,type=0x80,len=4,0xa/0xf}{class=0xffff,type=0,len=4}),flags(-df-csum+key)),recirc_id(0),in_port(6081),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
5bb08b0e
JG
186])
187
a36de779
PS
188OVS_VSWITCHD_STOP
189AT_CLEANUP
8a41d7c3
DDP
190
191AT_SETUP([tunnel_push_pop - packet_out])
192
193OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00])
194AT_CHECK([ovs-appctl vlog/set dpif_netdev:dbg])
195AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy])
196AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=geneve \
197 options:remote_ip=1.1.2.92 options:key=123 ofport_request=2 \
198 ])
199
200dnl First setup dummy interface IP address, then add the route
201dnl so that tnl-port table can get valid IP address for the device.
202AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
203])
204
205AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0], [0], [OK
206])
207
208AT_CHECK([ovs-ofctl add-flow br0 action=normal])
209
210dnl This ARP reply from p0 has two effects:
211dnl 1. The ARP cache will learn that 1.1.2.92 is at f8:bc:12:44:34:b6.
212dnl 2. The br0 mac learning will learn that f8:bc:12:44:34:b6 is on p0.
213AT_CHECK([ovs-appctl netdev-dummy/receive p0 'recirc_id(0),in_port(2),eth(src=f8:bc:12:44:34:b6,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b6,tha=00:00:00:00:00:00)'])
214
215AT_CHECK([ovs-vsctl -- set Interface p0 options:tx_pcap=p0.pcap])
216
217dnl Output to tunnel from a int-br internal port
218AT_CHECK([ovs-ofctl add-flow int-br "in_port=LOCAL,actions=output:2"])
219AT_CHECK([ovs-appctl netdev-dummy/receive int-br '50540000000a5054000000091234'])
220OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 50540000000a5054000000091234 | wc -l` -ge 1])
221
222dnl Output to tunnel from the controller
223AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" '50540000000a5054000000091235'])
224OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 50540000000a5054000000091235 | wc -l` -ge 1])
225
226OVS_VSWITCHD_STOP
227AT_CLEANUP