ovn-controller: Clean up bindings handling.
[cascardo/ovs.git] / tests / tunnel-push-pop.at
1 AT_BANNER([tunnel_push_pop])
2
3 AT_SETUP([tunnel_push_pop - action])
4
5 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00])
6 AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy], [0])
7 AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \
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 \
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 \
12                        options:remote_ip=1.1.2.93 options:out_key=flow options:csum=true ofport_request=4\
13                     -- add-port int-br t4 -- set Interface t4 type=geneve \
14                        options:remote_ip=flow options:key=123 ofport_request=5\
15                        ], [0])
16
17 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
18 dummy@ovs-dummy: hit:0 missed:0
19         br0:
20                 br0 65534/100: (dummy)
21                 p0 1/1: (dummy)
22         int-br:
23                 int-br 65534/2: (dummy)
24                 t1 3/3: (gre: key=456, remote_ip=1.1.2.92)
25                 t2 2/4789: (vxlan: key=123, remote_ip=1.1.2.92)
26                 t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=1.1.2.93)
27                 t4 5/6081: (geneve: key=123, remote_ip=flow)
28 ])
29
30 dnl First setup dummy interface IP address, then add the route
31 dnl so that tnl-port table can get valid IP address for the device.
32 AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
33 ])
34 AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:cafe::88/24], [0], [OK
35 ])
36
37 AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0], [0], [OK
38 ])
39
40 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
41
42 dnl Check ARP request
43 AT_CHECK([ovs-vsctl -- set Interface p0 options:pcap=p0.pcap])
44
45 AT_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)'])
46
47 dnl Wait for the two ARP requests to be sent. Sometimes the system
48 dnl can be slow (e.g. under valgrind)
49 OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | sort | uniq | wc -l` -ge 2])
50
51 AT_CHECK([ovs-pcap p0.pcap > p0.pcap.txt 2>&1])
52
53 AT_CHECK([cat p0.pcap.txt | grep 101025c | uniq], [0], [dnl
54 ffffffffffffaa55aa55000008060001080006040001aa55aa550000010102580000000000000101025c
55 ])
56 AT_CHECK([cat p0.pcap.txt | grep 101025d | uniq], [0], [dnl
57 ffffffffffffaa55aa55000008060001080006040001aa55aa550000010102580000000000000101025d
58 ])
59
60 dnl Check ARP Snoop
61 AT_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)'])
62 AT_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)'])
63
64 AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl
65 1.1.2.92                                      f8:bc:12:44:34:b6   br0
66 1.1.2.93                                      f8:bc:12:44:34:b7   br0
67 ])
68
69 AT_CHECK([ovs-appctl tnl/ports/show |sort], [0], [dnl
70 Listening ports:
71 genev_sys_6081 (6081)
72 gre_sys (3)
73 vxlan_sys_4789 (4789)
74 ])
75
76 dnl Check VXLAN tunnel pop
77 AT_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])
78 AT_CHECK([tail -1 stdout], [0],
79   [Datapath actions: tnl_pop(4789)
80 ])
81
82 dnl Check GRE tunnel pop
83 AT_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])
84 AT_CHECK([tail -1 stdout], [0],
85   [Datapath actions: tnl_pop(3)
86 ])
87
88 dnl Check Geneve tunnel pop
89 AT_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])
90 AT_CHECK([tail -1 stdout], [0],
91   [Datapath actions: tnl_pop(6081)
92 ])
93
94 dnl Check VXLAN tunnel push
95 AT_CHECK([ovs-ofctl add-flow int-br action=2])
96 AT_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])
97 AT_CHECK([tail -1 stdout], [0],
98   [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))
99 ])
100
101 dnl Check VXLAN tunnel push set tunnel id by flow and checksum
102 AT_CHECK([ovs-ofctl add-flow int-br "actions=set_tunnel:124,4"])
103 AT_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])
104 AT_CHECK([tail -1 stdout], [0],
105   [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))
106 ])
107
108 dnl Check GRE tunnel push
109 AT_CHECK([ovs-ofctl add-flow int-br action=3])
110 AT_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])
111 AT_CHECK([tail -1 stdout], [0],
112   [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))
113 ])
114
115 dnl Check Geneve tunnel push
116 AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:1.1.2.92->tun_dst,5"])
117 AT_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])
118 AT_CHECK([tail -1 stdout], [0],
119   [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))
120 ])
121
122 dnl Check Geneve tunnel push with options
123 AT_CHECK([ovs-ofctl add-tlv-map int-br "{class=0xffff,type=0x80,len=4}->tun_metadata0"])
124 AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:1.1.2.92->tun_dst,set_field:0xa->tun_metadata0,5"])
125 AT_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])
126 AT_CHECK([tail -1 stdout], [0],
127   [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))
128 ])
129
130 dnl Check decapsulation of GRE packet
131 AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
132 ovs-appctl time/warp 1000
133
134 AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port  3'], [0], [dnl
135   port  3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
136 ])
137
138 dnl Check GRE only accepts encapsulated Ethernet frames
139 AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
140 ovs-appctl time/warp 1000
141
142 AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port  3'], [0], [dnl
143   port  3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
144 ])
145
146 dnl Check decapsulation of Geneve packet with options
147 AT_CAPTURE_FILE([ofctl_monitor.log])
148 AT_CHECK([ovs-ofctl monitor int-br 65534 --detach --no-chdir --pidfile 2> ofctl_monitor.log])
149
150 AT_CHECK([ovs-ofctl del-flows int-br])
151 AT_CHECK([ovs-ofctl add-flow int-br "tun_metadata0=0xa/0xf,actions=5,controller"])
152 AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab64080045000096794640004011ba5b0101025c01010258308817c1008200000400655800007b00ffff80010000000affff00010000000bfe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
153
154 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
155 OVS_APP_EXIT_AND_WAIT(ovs-ofctl)
156
157 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
158 NXT_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)
159 icmp,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
160 ])
161
162 AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port  5'], [0], [dnl
163   port  5: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=?
164 ])
165 AT_CHECK([ovs-appctl dpif/dump-flows int-br], [0], [dnl
166 tunnel(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)),skb_mark(0),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))
167 ])
168
169 OVS_VSWITCHD_STOP
170 AT_CLEANUP
171
172 AT_SETUP([tunnel_push_pop - packet_out])
173
174 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00])
175 AT_CHECK([ovs-appctl vlog/set dpif_netdev:dbg])
176 AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy])
177 AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=geneve \
178                        options:remote_ip=1.1.2.92 options:key=123 ofport_request=2 \
179                        ])
180
181 dnl First setup dummy interface IP address, then add the route
182 dnl so that tnl-port table can get valid IP address for the device.
183 AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
184 ])
185
186 AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/24 br0], [0], [OK
187 ])
188
189 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
190
191 dnl This ARP reply from p0 has two effects:
192 dnl 1. The ARP cache will learn that 1.1.2.92 is at f8:bc:12:44:34:b6.
193 dnl 2. The br0 mac learning will learn that f8:bc:12:44:34:b6 is on p0.
194 AT_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)'])
195
196 AT_CHECK([ovs-vsctl -- set Interface p0 options:tx_pcap=p0.pcap])
197
198 dnl Output to tunnel from a int-br internal port
199 AT_CHECK([ovs-ofctl add-flow int-br "in_port=LOCAL,actions=output:2"])
200 AT_CHECK([ovs-appctl netdev-dummy/receive int-br '50540000000a5054000000091234'])
201 OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 50540000000a5054000000091234 | wc -l` -ge 1])
202
203 dnl Output to tunnel from the controller
204 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" '50540000000a5054000000091235'])
205 OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 50540000000a5054000000091235 | wc -l` -ge 1])
206
207 OVS_VSWITCHD_STOP
208 AT_CLEANUP