odp-util: Add tests for parsing and formatting ODP actions.
[sliver-openvswitch.git] / tests / odp.at
1 AT_BANNER([datapath parsing and formatting])
2
3 AT_SETUP([OVS datapath key parsing and formatting - valid forms])
4 dnl We could add a test for invalid forms, but that's less important.
5 AT_DATA([odp-base.txt], [dnl
6 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15)
7 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x1234)
8 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=5,tos=0x80,ttl=128,frag=no)
9 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=5,tos=0x81,ttl=128,frag=no)
10 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=5,tos=0x80,ttl=128,frag=first)
11 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=5,tos=0x80,ttl=128,frag=later)
12 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=6,tos=0,ttl=128,frag=no),tcp(src=80,dst=8080)
13 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=17,tos=0,ttl=128,frag=no),udp(src=81,dst=6632)
14 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0800),ipv4(src=35.8.2.41,dst=172.16.0.20,proto=1,tos=0,ttl=128,frag=no),icmp(type=1,code=2)
15 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=no)
16 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=10,tclass=0x71,hlimit=128,frag=no)
17 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=first)
18 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=later)
19 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=6,tclass=0,hlimit=128,frag=no),tcp(src=80,dst=8080)
20 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=17,tclass=0,hlimit=128,frag=no),udp(src=6630,dst=22)
21 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=1,code=2)
22 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=135,code=0),nd(target=::3)
23 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=135,code=0),nd(target=::3,sll=00:05:06:07:08:09)
24 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,tll=00:0a:0b:0c:0d:0e)
25 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,sll=00:05:06:07:08:09,tll=00:0a:0b:0c:0d:0e)
26 in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0806),arp(sip=1.2.3.4,tip=5.6.7.8,op=1,sha=00:0f:10:11:12:13,tha=00:14:15:16:17:18)
27 ])
28
29 (echo '# Valid forms without tun_id or VLAN header.'
30  cat odp-base.txt
31
32  echo
33  echo '# Valid forms with tun_id header.'
34  sed 's/^/tun_id(0x7f10354),/' odp-base.txt
35
36  echo
37  echo '# Valid forms with VLAN header.'
38  sed 's/\(eth([[^)]]*)\),*/\1,eth_type(0x8100),vlan(vid=99,pcp=7),encap(/
39 s/$/)/' odp-base.txt
40
41  echo
42  echo '# Valid forms with QoS priority.'
43  sed 's/^/priority(1234),/' odp-base.txt
44
45  echo
46  echo '# Valid forms with tun_id and VLAN headers.'
47  sed 's/^/tun_id(0xfedcba9876543210),/
48 s/\(eth([[^)]]*)\),*/\1,eth_type(0x8100),vlan(vid=99,pcp=7),encap(/
49 s/$/)/' odp-base.txt
50
51  echo
52  echo '# Valid forms with IP first fragment.'
53 sed -n 's/,frag=no),/,frag=first),/p' odp-base.txt
54
55  echo
56  echo '# Valid forms with IP later fragment.'
57 sed -n 's/,frag=no),.*/,frag=later)/p' odp-base.txt) > odp.txt
58 AT_CAPTURE_FILE([odp.txt])
59 AT_CHECK_UNQUOTED([test-odp parse-keys < odp.txt], [0], [`cat odp.txt`
60 ])
61 AT_CLEANUP
62
63 AT_SETUP([OVS datapath actions parsing and formatting - valid forms])
64 AT_DATA([actions.txt], [dnl
65 1,2,3
66 userspace(pid=555666777)
67 userspace(pid=6633,sFlow(vid=9,pcp=7,output=10))
68 userspace(pid=9765,slow_path())
69 userspace(pid=9765,slow_path(cfm))
70 userspace(pid=9765,slow_path(cfm,match))
71 userspace(pid=9123,userdata=0x815309)
72 set(tun_id(0x7f10354))
73 set(in_port(2))
74 set(eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15))
75 set(eth_type(0x1234))
76 set(ipv4(src=35.8.2.41,dst=172.16.0.20,proto=5,tos=0x80,ttl=128,frag=no))
77 set(tcp(src=80,dst=8080))
78 set(udp(src=81,dst=6632))
79 set(icmp(type=1,code=2))
80 set(ipv6(src=::1,dst=::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=no))
81 set(icmpv6(type=1,code=2))
82 push_vlan(vid=12,pcp=0)
83 push_vlan(vid=13,pcp=5,cfi=0)
84 push_vlan(tpid=0x9100,vid=13,pcp=5)
85 push_vlan(tpid=0x9100,vid=13,pcp=5,cfi=0)
86 pop_vlan
87 sample(sample=9.7%,actions(1,2,3,push_vlan(vid=1,pcp=2)))
88 ])
89 AT_CHECK_UNQUOTED([test-odp parse-actions < actions.txt], [0],
90   [`cat actions.txt`
91 ])
92 AT_CLEANUP