~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to tests/ovs-ofctl.at

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
AT_BANNER([ovs-ofctl])
2
2
 
 
3
AT_SETUP([ovs-ofctl parse-flows choice of protocol])
 
4
# This doesn't cover some potential vlan_tci test cases.
 
5
for test_case in \
 
6
    'tun_id=0                                    NXM,OXM' \
 
7
    'tun_src=1.2.3.4                             NXM,OXM' \
 
8
    'tun_dst=1.2.3.4                             NXM,OXM' \
 
9
    'tun_flags=0                                 none' \
 
10
    'tun_tos=0                                   none' \
 
11
    'tun_ttl=0                                   none' \
 
12
    'metadata=0                                  NXM,OXM' \
 
13
    'in_port=1                                   any' \
 
14
    'skb_priority=0                              none' \
 
15
    'skb_mark=1                                  none' \
 
16
    'reg0=0                                      NXM,OXM' \
 
17
    'reg1=1                                      NXM,OXM' \
 
18
    'reg2=2                                      NXM,OXM' \
 
19
    'reg3=3                                      NXM,OXM' \
 
20
    'reg4=4                                      NXM,OXM' \
 
21
    'reg5=5                                      NXM,OXM' \
 
22
    'reg6=6                                      NXM,OXM' \
 
23
    'reg7=7                                      NXM,OXM' \
 
24
    'dl_src=00:11:22:33:44:55                    any' \
 
25
    'dl_src=00:11:22:33:44:55/00:ff:ff:ff:ff:ff  NXM,OXM' \
 
26
    'dl_dst=00:11:22:33:44:55                    any' \
 
27
    'dl_dst=00:11:22:33:44:55/00:ff:ff:ff:ff:ff  NXM,OXM' \
 
28
    'dl_type=0x1234                              any' \
 
29
    'dl_type=0x0800                              any' \
 
30
    'dl_type=0x0806                              any' \
 
31
    'dl_type=0x86dd                              any' \
 
32
    'vlan_tci=0                                  any' \
 
33
    'vlan_tci=0x1009                             any' \
 
34
    'dl_vlan=9                                   any' \
 
35
    'vlan_vid=11                                 any' \
 
36
    'dl_vlan_pcp=6                               any' \
 
37
    'vlan_pcp=5                                  any' \
 
38
    'mpls,mpls_label=5                           NXM,OXM' \
 
39
    'mpls,mpls_tc=1                              NXM,OXM' \
 
40
    'mpls,mpls_bos=0                             NXM,OXM' \
 
41
    'ip,ip_src=1.2.3.4                           any' \
 
42
    'ip,ip_src=192.168.0.0/24                    any' \
 
43
    'ip,ip_src=192.0.168.0/255.0.255.0           NXM,OXM' \
 
44
    'ip,ip_dst=1.2.3.4                           any' \
 
45
    'ip,ip_dst=192.168.0.0/24                    any' \
 
46
    'ip,ip_dst=192.0.168.0/255.0.255.0           NXM,OXM' \
 
47
    'ipv6,ipv6_src=::1                           NXM,OXM' \
 
48
    'ipv6,ipv6_dst=::1                           NXM,OXM' \
 
49
    'ipv6,ipv6_label=5                           NXM,OXM' \
 
50
    'ip,nw_proto=1                               any' \
 
51
    'ipv6,nw_proto=1                             NXM,OXM' \
 
52
    'ip,nw_tos=0xf0                              any' \
 
53
    'ipv6,nw_tos=0xf0                            NXM,OXM' \
 
54
    'ip,nw_tos_shifted=0x3c                      any' \
 
55
    'ipv6,nw_tos_shifted=0x3c                    NXM,OXM' \
 
56
    'ip,nw_ecn=1                                 NXM,OXM' \
 
57
    'ipv6,nw_ecn=1                               NXM,OXM' \
 
58
    'ip,nw_ttl=5                                 NXM,OXM' \
 
59
    'ipv6,nw_ttl=5                               NXM,OXM' \
 
60
    'ip,ip_frag=no                               NXM,OXM' \
 
61
    'ipv6,ip_frag=no                             NXM,OXM' \
 
62
    'arp,arp_op=0                                any' \
 
63
    'arp,arp_spa=1.2.3.4                         any' \
 
64
    'arp,arp_tpa=1.2.3.4                         any' \
 
65
    'arp,arp_sha=00:11:22:33:44:55               NXM,OXM' \
 
66
    'arp,arp_tha=00:11:22:33:44:55               NXM,OXM' \
 
67
    'tcp,tcp_src=80                              any' \
 
68
    'tcp,tcp_src=0x1000/0x1000                   NXM,OXM' \
 
69
    'tcp6,tcp_src=80                             NXM,OXM' \
 
70
    'tcp6,tcp_src=0x1000/0x1000                  NXM,OXM' \
 
71
    'tcp,tcp_dst=80                              any' \
 
72
    'tcp,tcp_dst=0x1000/0x1000                   NXM,OXM' \
 
73
    'tcp6,tcp_dst=80                             NXM,OXM' \
 
74
    'tcp6,tcp_dst=0x1000/0x1000                  NXM,OXM' \
 
75
    'udp,udp_src=80                              any' \
 
76
    'udp,udp_src=0x1000/0x1000                   NXM,OXM' \
 
77
    'udp6,udp_src=80                             NXM,OXM' \
 
78
    'udp6,udp_src=0x1000/0x1000                  NXM,OXM' \
 
79
    'udp,udp_dst=80                              any' \
 
80
    'udp,udp_dst=0x1000/0x1000                   NXM,OXM' \
 
81
    'udp6,udp_dst=80                             NXM,OXM' \
 
82
    'udp6,udp_dst=0x1000/0x1000                  NXM,OXM' \
 
83
    'icmp,icmp_type=1                            any' \
 
84
    'icmp,icmp_type=1                            any' \
 
85
    'icmp6,icmpv6_type=1                         NXM,OXM' \
 
86
    'icmp6,icmpv6_code=2                         NXM,OXM'
 
87
do
 
88
    set $test_case
 
89
    echo
 
90
    echo "### test case: '$1' should have usable protocols '$2'"
 
91
    if test "$2" = none; then
 
92
      AT_CHECK([ovs-ofctl parse-flow "$1,actions=drop"], [1],
 
93
               [usable protocols: none
 
94
],
 
95
               [ovs-ofctl: no usable protocol
 
96
])
 
97
    else
 
98
      AT_CHECK_UNQUOTED([ovs-ofctl parse-flow "$1,actions=drop" | sed 1q], [0],
 
99
                        [usable protocols: $2
 
100
])
 
101
    fi
 
102
done
 
103
AT_CLEANUP
 
104
 
3
105
AT_SETUP([ovs-ofctl parse-flows (OpenFlow 1.0)])
4
106
AT_DATA([flows.txt], [[
5
107
# comment
6
 
tcp,tp_src=123,actions=flood
 
108
tcp,tp_src=123,out_port=5,actions=flood
7
109
in_port=LOCAL dl_vlan=9 dl_src=00:0A:E4:25:6B:B0 actions=drop
8
110
udp dl_vlan_pcp=7 idle_timeout=5 actions=strip_vlan output:0
9
111
tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
10
112
udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
11
113
cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
12
114
actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
13
 
actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
 
115
ip,actions=set_field:10.4.3.77->ip_src
14
116
in_port=0 actions=resubmit:0
 
117
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
15
118
]])
16
119
 
17
120
AT_CHECK([ovs-ofctl parse-flows flows.txt
19
122
AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0],
20
123
[[usable protocols: any
21
124
chosen protocol: OpenFlow10-table_id
22
 
OFPT_FLOW_MOD: ADD tcp,tp_src=123 actions=FLOOD
 
125
OFPT_FLOW_MOD: ADD tcp,tp_src=123 out_port:5 actions=FLOOD
23
126
OFPT_FLOW_MOD: ADD in_port=LOCAL,dl_vlan=9,dl_src=00:0a:e4:25:6b:b0 actions=drop
24
127
OFPT_FLOW_MOD: ADD udp,dl_vlan_pcp=7 idle:5 actions=strip_vlan,output:0
25
128
OFPT_FLOW_MOD: ADD tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
26
129
OFPT_FLOW_MOD: ADD udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
27
130
OFPT_FLOW_MOD: ADD priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
28
131
OFPT_FLOW_MOD: ADD actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
29
 
OFPT_FLOW_MOD: ADD actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[0..63],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[64..127]
 
132
OFPT_FLOW_MOD: ADD ip actions=load:0xa04034d->NXM_OF_IP_SRC[]
30
133
OFPT_FLOW_MOD: ADD in_port=0 actions=resubmit:0
 
134
OFPT_FLOW_MOD: ADD actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
31
135
]])
32
136
AT_CLEANUP
33
137
 
41
145
udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
42
146
cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
43
147
actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
44
 
actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
 
148
ipv6,actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
45
149
in_port=0 actions=resubmit:0
 
150
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
46
151
]])
47
152
 
48
153
AT_CHECK([ovs-ofctl --protocols OpenFlow12 parse-flows flows.txt
57
162
OFPT_FLOW_MOD (OF1.2): ADD table:255 udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
58
163
OFPT_FLOW_MOD (OF1.2): ADD table:255 priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
59
164
OFPT_FLOW_MOD (OF1.2): ADD table:255 actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
60
 
OFPT_FLOW_MOD (OF1.2): ADD table:255 actions=set_field:fe80:123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
 
165
OFPT_FLOW_MOD (OF1.2): ADD table:255 ipv6 actions=set_field:fe80:123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
61
166
OFPT_FLOW_MOD (OF1.2): ADD table:255 in_port=0 actions=resubmit:0
 
167
OFPT_FLOW_MOD (OF1.2): ADD table:255 actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
62
168
]])
63
169
AT_CLEANUP
64
170
 
116
222
check_overlap,actions=output:1,exit,output:2
117
223
actions=fin_timeout(idle_timeout=5,hard_timeout=15)
118
224
actions=controller(max_len=123,reason=invalid_ttl,id=555)
 
225
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
119
226
]])
120
227
 
121
228
AT_CHECK([ovs-ofctl parse-flows flows.txt
150
257
NXT_FLOW_MOD: ADD table:255 check_overlap actions=output:1,exit,output:2
151
258
NXT_FLOW_MOD: ADD table:255 actions=fin_timeout(idle_timeout=5,hard_timeout=15)
152
259
NXT_FLOW_MOD: ADD table:255 actions=controller(reason=invalid_ttl,max_len=123,id=555)
 
260
NXT_FLOW_MOD: ADD table:255 actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
153
261
]])
154
262
AT_CLEANUP
155
263
 
183
291
dl_dst=00:00:00:00:00:00/01:00:00:00:00:00,actions=drop
184
292
dl_dst=aa:bb:cc:dd:ee:ff/fe:ff:ff:ff:ff:ff,actions=drop
185
293
dl_dst=aa:bb:cc:dd:ee:ff/00:00:00:00:00:00,actions=drop
 
294
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
186
295
])
187
296
AT_CHECK([ovs-ofctl -F nxm parse-flows flows.txt], [0], [stdout])
188
297
AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0], [dnl
215
324
NXT_FLOW_MOD: ADD dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=drop
216
325
NXT_FLOW_MOD: ADD dl_dst=aa:bb:cc:dd:ee:ff/fe:ff:ff:ff:ff:ff actions=drop
217
326
NXT_FLOW_MOD: ADD actions=drop
 
327
NXT_FLOW_MOD: ADD actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
218
328
])
219
329
AT_CLEANUP
220
330
 
243
353
actions=drop
244
354
reg0=123,actions=move:NXM_NX_REG0[0..5]->NXM_NX_REG1[26..31],load:55->NXM_NX_REG2[0..31],move:NXM_NX_REG0[0..31]->NXM_NX_TUN_ID[0..31],move:NXM_NX_REG0[0..15]->NXM_OF_VLAN_TCI[]
245
355
actions=move:OXM_OF_ETH_DST[]->OXM_OF_ETH_SRC[]
246
 
actions=autopath(5,NXM_NX_REG0[])
 
356
actions=push:NXM_NX_REG0[0..31],pop:NXM_NX_REG0[]
247
357
vlan_tci=0x1123/0x1fff,actions=drop
 
358
actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
248
359
]])
249
360
AT_CHECK([ovs-ofctl -F nxm -mmm parse-flows flows.txt], [0], [stdout], [stderr])
250
361
AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0],
272
383
NXT_FLOW_MOD: ADD <any> actions=drop
273
384
NXT_FLOW_MOD: ADD NXM_NX_REG0(0000007b) actions=move:NXM_NX_REG0[0..5]->NXM_NX_REG1[26..31],load:0x37->NXM_NX_REG2[],move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],move:NXM_NX_REG0[0..15]->NXM_OF_VLAN_TCI[]
274
385
NXT_FLOW_MOD: ADD <any> actions=move:NXM_OF_ETH_DST[]->NXM_OF_ETH_SRC[]
275
 
NXT_FLOW_MOD: ADD <any> actions=autopath(5,NXM_NX_REG0[])
 
386
NXT_FLOW_MOD: ADD <any> actions=push:NXM_NX_REG0[],pop:NXM_NX_REG0[]
276
387
NXT_FLOW_MOD: ADD NXM_OF_VLAN_TCI_W(1123/1fff) actions=drop
 
388
NXT_FLOW_MOD: ADD <any> actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
277
389
]])
278
 
AT_CHECK([[sed 's/^[^|]*|[^|]*|//' stderr]], [0], [dnl
279
 
autopath|WARN|The autopath action is deprecated and may be removed in February 2013.  Please email dev@openvswitch.org with concerns.
280
 
])
281
390
AT_CLEANUP
282
391
 
283
392
AT_SETUP([ovs-ofctl parse-nx-match])
1469
1578
OXM_OF_VLAN_VID_W(1000/1000)    # Packets with any VID, any PCP
1470
1579
OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01)  # Packets with any VID, PCP=1.
1471
1580
 
 
1581
# IP TOS
 
1582
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_DSCP(f0)
 
1583
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_DSCP(41)
 
1584
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_DSCP(3f)
 
1585
OXM_OF_IP_DSCP(f0)
 
1586
 
1472
1587
# IP ECN
1473
1588
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_ECN(03)
1474
1589
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_ECN(06)
1665
1780
OXM_OF_VLAN_VID_W(1000/1000)
1666
1781
OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01)
1667
1782
 
 
1783
# IP TOS
 
1784
nx_pull_match() returned error OFPBMC_BAD_VALUE
 
1785
nx_pull_match() returned error OFPBMC_BAD_VALUE
 
1786
OXM_OF_ETH_TYPE(0800), OXM_OF_IP_DSCP(3f)
 
1787
nx_pull_match() returned error OFPBMC_BAD_PREREQ
 
1788
 
1668
1789
# IP ECN
1669
1790
OXM_OF_ETH_TYPE(0800), OXM_OF_IP_ECN(03)
1670
1791
nx_pull_match() returned error OFPBMC_BAD_VALUE