2 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /* "White box" tests for classifier.
19 * With very few exceptions, these tests obtain complete coverage of every
20 * basic block and every branch in the classifier implementation, e.g. a clean
21 * report from "gcov -b". (Covering the exceptions would require finding
22 * collisions in the hash function used for flow data, etc.)
24 * This test should receive a clean report from "valgrind --leak-check=full":
25 * it frees every heap block that it allocates.
30 #include "classifier.h"
34 #include "byte-order.h"
35 #include "classifier-private.h"
36 #include "command-line.h"
42 #include "unaligned.h"
45 static bool versioned = false;
47 /* Fields in a rule. */
49 /* struct flow all-caps */ \
50 /* member name name */ \
51 /* ----------- -------- */ \
52 CLS_FIELD(tunnel.tun_id, TUN_ID) \
53 CLS_FIELD(metadata, METADATA) \
54 CLS_FIELD(nw_src, NW_SRC) \
55 CLS_FIELD(nw_dst, NW_DST) \
56 CLS_FIELD(in_port, IN_PORT) \
57 CLS_FIELD(vlan_tci, VLAN_TCI) \
58 CLS_FIELD(dl_type, DL_TYPE) \
59 CLS_FIELD(tp_src, TP_SRC) \
60 CLS_FIELD(tp_dst, TP_DST) \
61 CLS_FIELD(dl_src, DL_SRC) \
62 CLS_FIELD(dl_dst, DL_DST) \
63 CLS_FIELD(nw_proto, NW_PROTO) \
64 CLS_FIELD(nw_tos, NW_DSCP)
68 * (These are also indexed into struct classifier's 'tables' array.) */
70 #define CLS_FIELD(MEMBER, NAME) CLS_F_IDX_##NAME,
76 /* Field information. */
78 int ofs; /* Offset in struct flow. */
79 int len; /* Length in bytes. */
80 const char *name; /* Name (for debugging). */
83 static const struct cls_field cls_fields[CLS_N_FIELDS] = {
84 #define CLS_FIELD(MEMBER, NAME) \
85 { offsetof(struct flow, MEMBER), \
86 sizeof ((struct flow *)0)->MEMBER, \
93 struct ovs_list list_node;
94 int aux; /* Auxiliary data. */
95 struct cls_rule cls_rule; /* Classifier rule data. */
98 static struct test_rule *
99 test_rule_from_cls_rule(const struct cls_rule *rule)
101 return rule ? CONTAINER_OF(rule, struct test_rule, cls_rule) : NULL;
105 test_rule_destroy(struct test_rule *rule)
108 cls_rule_destroy(&rule->cls_rule);
113 static struct test_rule *make_rule(int wc_fields, int priority, int value_pat);
114 static void free_rule(struct test_rule *);
115 static struct test_rule *clone_rule(const struct test_rule *);
117 /* Trivial (linear) classifier. */
120 size_t allocated_rules;
121 struct test_rule **rules;
125 tcls_init(struct tcls *tcls)
128 tcls->allocated_rules = 0;
133 tcls_destroy(struct tcls *tcls)
138 for (i = 0; i < tcls->n_rules; i++) {
139 test_rule_destroy(tcls->rules[i]);
146 tcls_is_empty(const struct tcls *tcls)
148 return tcls->n_rules == 0;
151 static struct test_rule *
152 tcls_insert(struct tcls *tcls, const struct test_rule *rule)
156 for (i = 0; i < tcls->n_rules; i++) {
157 const struct cls_rule *pos = &tcls->rules[i]->cls_rule;
158 if (cls_rule_equal(pos, &rule->cls_rule)) {
160 ovsrcu_postpone(free_rule, tcls->rules[i]);
161 tcls->rules[i] = clone_rule(rule);
162 return tcls->rules[i];
163 } else if (pos->priority < rule->cls_rule.priority) {
168 if (tcls->n_rules >= tcls->allocated_rules) {
169 tcls->rules = x2nrealloc(tcls->rules, &tcls->allocated_rules,
170 sizeof *tcls->rules);
172 if (i != tcls->n_rules) {
173 memmove(&tcls->rules[i + 1], &tcls->rules[i],
174 sizeof *tcls->rules * (tcls->n_rules - i));
176 tcls->rules[i] = clone_rule(rule);
178 return tcls->rules[i];
182 tcls_remove(struct tcls *cls, const struct test_rule *rule)
186 for (i = 0; i < cls->n_rules; i++) {
187 struct test_rule *pos = cls->rules[i];
189 test_rule_destroy(pos);
191 memmove(&cls->rules[i], &cls->rules[i + 1],
192 sizeof *cls->rules * (cls->n_rules - i - 1));
202 match(const struct cls_rule *wild_, const struct flow *fixed)
207 minimatch_expand(&wild_->match, &wild);
208 for (f_idx = 0; f_idx < CLS_N_FIELDS; f_idx++) {
211 if (f_idx == CLS_F_IDX_NW_SRC) {
212 eq = !((fixed->nw_src ^ wild.flow.nw_src)
213 & wild.wc.masks.nw_src);
214 } else if (f_idx == CLS_F_IDX_NW_DST) {
215 eq = !((fixed->nw_dst ^ wild.flow.nw_dst)
216 & wild.wc.masks.nw_dst);
217 } else if (f_idx == CLS_F_IDX_TP_SRC) {
218 eq = !((fixed->tp_src ^ wild.flow.tp_src)
219 & wild.wc.masks.tp_src);
220 } else if (f_idx == CLS_F_IDX_TP_DST) {
221 eq = !((fixed->tp_dst ^ wild.flow.tp_dst)
222 & wild.wc.masks.tp_dst);
223 } else if (f_idx == CLS_F_IDX_DL_SRC) {
224 eq = eth_addr_equal_except(fixed->dl_src, wild.flow.dl_src,
225 wild.wc.masks.dl_src);
226 } else if (f_idx == CLS_F_IDX_DL_DST) {
227 eq = eth_addr_equal_except(fixed->dl_dst, wild.flow.dl_dst,
228 wild.wc.masks.dl_dst);
229 } else if (f_idx == CLS_F_IDX_VLAN_TCI) {
230 eq = !((fixed->vlan_tci ^ wild.flow.vlan_tci)
231 & wild.wc.masks.vlan_tci);
232 } else if (f_idx == CLS_F_IDX_TUN_ID) {
233 eq = !((fixed->tunnel.tun_id ^ wild.flow.tunnel.tun_id)
234 & wild.wc.masks.tunnel.tun_id);
235 } else if (f_idx == CLS_F_IDX_METADATA) {
236 eq = !((fixed->metadata ^ wild.flow.metadata)
237 & wild.wc.masks.metadata);
238 } else if (f_idx == CLS_F_IDX_NW_DSCP) {
239 eq = !((fixed->nw_tos ^ wild.flow.nw_tos) &
240 (wild.wc.masks.nw_tos & IP_DSCP_MASK));
241 } else if (f_idx == CLS_F_IDX_NW_PROTO) {
242 eq = !((fixed->nw_proto ^ wild.flow.nw_proto)
243 & wild.wc.masks.nw_proto);
244 } else if (f_idx == CLS_F_IDX_DL_TYPE) {
245 eq = !((fixed->dl_type ^ wild.flow.dl_type)
246 & wild.wc.masks.dl_type);
247 } else if (f_idx == CLS_F_IDX_IN_PORT) {
248 eq = !((fixed->in_port.ofp_port
249 ^ wild.flow.in_port.ofp_port)
250 & wild.wc.masks.in_port.ofp_port);
262 static struct cls_rule *
263 tcls_lookup(const struct tcls *cls, const struct flow *flow)
267 for (i = 0; i < cls->n_rules; i++) {
268 struct test_rule *pos = cls->rules[i];
269 if (match(&pos->cls_rule, flow)) {
270 return &pos->cls_rule;
277 tcls_delete_matches(struct tcls *cls, const struct cls_rule *target)
281 for (i = 0; i < cls->n_rules; ) {
282 struct test_rule *pos = cls->rules[i];
283 if (!minimask_has_extra(pos->cls_rule.match.mask,
284 target->match.mask)) {
287 miniflow_expand(pos->cls_rule.match.flow, &flow);
288 if (match(target, &flow)) {
289 tcls_remove(cls, pos);
297 static ovs_be32 nw_src_values[] = { CONSTANT_HTONL(0xc0a80001),
298 CONSTANT_HTONL(0xc0a04455) };
299 static ovs_be32 nw_dst_values[] = { CONSTANT_HTONL(0xc0a80002),
300 CONSTANT_HTONL(0xc0a04455) };
301 static ovs_be64 tun_id_values[] = {
303 CONSTANT_HTONLL(UINT64_C(0xfedcba9876543210)) };
304 static ovs_be64 metadata_values[] = {
306 CONSTANT_HTONLL(UINT64_C(0xfedcba9876543210)) };
307 static ofp_port_t in_port_values[] = { OFP_PORT_C(1), OFPP_LOCAL };
308 static ovs_be16 vlan_tci_values[] = { CONSTANT_HTONS(101), CONSTANT_HTONS(0) };
309 static ovs_be16 dl_type_values[]
310 = { CONSTANT_HTONS(ETH_TYPE_IP), CONSTANT_HTONS(ETH_TYPE_ARP) };
311 static ovs_be16 tp_src_values[] = { CONSTANT_HTONS(49362),
312 CONSTANT_HTONS(80) };
313 static ovs_be16 tp_dst_values[] = { CONSTANT_HTONS(6667), CONSTANT_HTONS(22) };
314 static uint8_t dl_src_values[][ETH_ADDR_LEN] = {
315 { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 },
316 { 0x5e, 0x33, 0x7f, 0x5f, 0x1e, 0x99 } };
317 static uint8_t dl_dst_values[][ETH_ADDR_LEN] = {
318 { 0x4a, 0x27, 0x71, 0xae, 0x64, 0xc1 },
319 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
320 static uint8_t nw_proto_values[] = { IPPROTO_TCP, IPPROTO_ICMP };
321 static uint8_t nw_dscp_values[] = { 48, 0 };
323 static void *values[CLS_N_FIELDS][2];
328 values[CLS_F_IDX_TUN_ID][0] = &tun_id_values[0];
329 values[CLS_F_IDX_TUN_ID][1] = &tun_id_values[1];
331 values[CLS_F_IDX_METADATA][0] = &metadata_values[0];
332 values[CLS_F_IDX_METADATA][1] = &metadata_values[1];
334 values[CLS_F_IDX_IN_PORT][0] = &in_port_values[0];
335 values[CLS_F_IDX_IN_PORT][1] = &in_port_values[1];
337 values[CLS_F_IDX_VLAN_TCI][0] = &vlan_tci_values[0];
338 values[CLS_F_IDX_VLAN_TCI][1] = &vlan_tci_values[1];
340 values[CLS_F_IDX_DL_SRC][0] = dl_src_values[0];
341 values[CLS_F_IDX_DL_SRC][1] = dl_src_values[1];
343 values[CLS_F_IDX_DL_DST][0] = dl_dst_values[0];
344 values[CLS_F_IDX_DL_DST][1] = dl_dst_values[1];
346 values[CLS_F_IDX_DL_TYPE][0] = &dl_type_values[0];
347 values[CLS_F_IDX_DL_TYPE][1] = &dl_type_values[1];
349 values[CLS_F_IDX_NW_SRC][0] = &nw_src_values[0];
350 values[CLS_F_IDX_NW_SRC][1] = &nw_src_values[1];
352 values[CLS_F_IDX_NW_DST][0] = &nw_dst_values[0];
353 values[CLS_F_IDX_NW_DST][1] = &nw_dst_values[1];
355 values[CLS_F_IDX_NW_PROTO][0] = &nw_proto_values[0];
356 values[CLS_F_IDX_NW_PROTO][1] = &nw_proto_values[1];
358 values[CLS_F_IDX_NW_DSCP][0] = &nw_dscp_values[0];
359 values[CLS_F_IDX_NW_DSCP][1] = &nw_dscp_values[1];
361 values[CLS_F_IDX_TP_SRC][0] = &tp_src_values[0];
362 values[CLS_F_IDX_TP_SRC][1] = &tp_src_values[1];
364 values[CLS_F_IDX_TP_DST][0] = &tp_dst_values[0];
365 values[CLS_F_IDX_TP_DST][1] = &tp_dst_values[1];
368 #define N_NW_SRC_VALUES ARRAY_SIZE(nw_src_values)
369 #define N_NW_DST_VALUES ARRAY_SIZE(nw_dst_values)
370 #define N_TUN_ID_VALUES ARRAY_SIZE(tun_id_values)
371 #define N_METADATA_VALUES ARRAY_SIZE(metadata_values)
372 #define N_IN_PORT_VALUES ARRAY_SIZE(in_port_values)
373 #define N_VLAN_TCI_VALUES ARRAY_SIZE(vlan_tci_values)
374 #define N_DL_TYPE_VALUES ARRAY_SIZE(dl_type_values)
375 #define N_TP_SRC_VALUES ARRAY_SIZE(tp_src_values)
376 #define N_TP_DST_VALUES ARRAY_SIZE(tp_dst_values)
377 #define N_DL_SRC_VALUES ARRAY_SIZE(dl_src_values)
378 #define N_DL_DST_VALUES ARRAY_SIZE(dl_dst_values)
379 #define N_NW_PROTO_VALUES ARRAY_SIZE(nw_proto_values)
380 #define N_NW_DSCP_VALUES ARRAY_SIZE(nw_dscp_values)
382 #define N_FLOW_VALUES (N_NW_SRC_VALUES * \
386 N_VLAN_TCI_VALUES * \
392 N_NW_PROTO_VALUES * \
396 get_value(unsigned int *x, unsigned n_values)
398 unsigned int rem = *x % n_values;
404 compare_classifiers(struct classifier *cls, size_t n_invisible_rules,
405 cls_version_t version, struct tcls *tcls)
407 static const int confidence = 500;
410 assert(classifier_count(cls) == tcls->n_rules + n_invisible_rules);
411 for (i = 0; i < confidence; i++) {
412 const struct cls_rule *cr0, *cr1, *cr2;
414 struct flow_wildcards wc;
417 flow_wildcards_init_catchall(&wc);
418 x = random_range(N_FLOW_VALUES);
419 memset(&flow, 0, sizeof flow);
420 flow.nw_src = nw_src_values[get_value(&x, N_NW_SRC_VALUES)];
421 flow.nw_dst = nw_dst_values[get_value(&x, N_NW_DST_VALUES)];
422 flow.tunnel.tun_id = tun_id_values[get_value(&x, N_TUN_ID_VALUES)];
423 flow.metadata = metadata_values[get_value(&x, N_METADATA_VALUES)];
424 flow.in_port.ofp_port = in_port_values[get_value(&x,
426 flow.vlan_tci = vlan_tci_values[get_value(&x, N_VLAN_TCI_VALUES)];
427 flow.dl_type = dl_type_values[get_value(&x, N_DL_TYPE_VALUES)];
428 flow.tp_src = tp_src_values[get_value(&x, N_TP_SRC_VALUES)];
429 flow.tp_dst = tp_dst_values[get_value(&x, N_TP_DST_VALUES)];
430 memcpy(flow.dl_src, dl_src_values[get_value(&x, N_DL_SRC_VALUES)],
432 memcpy(flow.dl_dst, dl_dst_values[get_value(&x, N_DL_DST_VALUES)],
434 flow.nw_proto = nw_proto_values[get_value(&x, N_NW_PROTO_VALUES)];
435 flow.nw_tos = nw_dscp_values[get_value(&x, N_NW_DSCP_VALUES)];
437 /* This assertion is here to suppress a GCC 4.9 array-bounds warning */
438 ovs_assert(cls->n_tries <= CLS_MAX_TRIES);
440 cr0 = classifier_lookup(cls, version, &flow, &wc);
441 cr1 = tcls_lookup(tcls, &flow);
442 assert((cr0 == NULL) == (cr1 == NULL));
444 const struct test_rule *tr0 = test_rule_from_cls_rule(cr0);
445 const struct test_rule *tr1 = test_rule_from_cls_rule(cr1);
447 assert(cls_rule_equal(cr0, cr1));
448 assert(tr0->aux == tr1->aux);
450 /* Make sure the rule should have been visible. */
451 assert(cr0->cls_match);
452 assert(cls_match_visible_in_version(cr0->cls_match, version));
454 cr2 = classifier_lookup(cls, version, &flow, NULL);
460 destroy_classifier(struct classifier *cls)
462 struct test_rule *rule;
464 classifier_defer(cls);
465 CLS_FOR_EACH (rule, cls_rule, cls) {
466 if (classifier_remove(cls, &rule->cls_rule)) {
467 ovsrcu_postpone(free_rule, rule);
470 classifier_destroy(cls);
474 pvector_verify(const struct pvector *pvec)
476 void *ptr OVS_UNUSED;
477 int prev_priority = INT_MAX;
479 PVECTOR_FOR_EACH (ptr, pvec) {
480 int priority = cursor__.vector[cursor__.entry_idx].priority;
481 if (priority > prev_priority) {
482 ovs_abort(0, "Priority vector is out of order (%u > %u)",
483 priority, prev_priority);
485 prev_priority = priority;
490 trie_verify(const rcu_trie_ptr *trie, unsigned int ofs, unsigned int n_bits)
492 const struct trie_node *node = ovsrcu_get(struct trie_node *, trie);
495 assert(node->n_rules == 0 || node->n_bits > 0);
497 assert((ofs > 0 || (ofs == 0 && node->n_bits == 0)) && ofs <= n_bits);
500 + trie_verify(&node->edges[0], ofs, n_bits)
501 + trie_verify(&node->edges[1], ofs, n_bits);
507 verify_tries(struct classifier *cls)
508 OVS_NO_THREAD_SAFETY_ANALYSIS
510 unsigned int n_rules = 0;
513 for (i = 0; i < cls->n_tries; i++) {
514 n_rules += trie_verify(&cls->tries[i].root, 0,
515 cls->tries[i].field->n_bits);
517 assert(n_rules <= cls->n_rules);
521 check_tables(const struct classifier *cls, int n_tables, int n_rules,
522 int n_dups, int n_invisible, cls_version_t version)
523 OVS_NO_THREAD_SAFETY_ANALYSIS
525 const struct cls_subtable *table;
526 struct test_rule *test_rule;
527 int found_tables = 0;
528 int found_tables_with_visible_rules = 0;
531 int found_invisible = 0;
532 int found_visible_but_removable = 0;
533 int found_rules2 = 0;
535 pvector_verify(&cls->subtables);
536 CMAP_FOR_EACH (table, cmap_node, &cls->subtables_map) {
537 const struct cls_match *head;
538 int max_priority = INT_MIN;
539 unsigned int max_count = 0;
541 bool found_visible_rules = false;
542 const struct cls_subtable *iter;
544 /* Locate the subtable from 'subtables'. */
545 PVECTOR_FOR_EACH (iter, &cls->subtables) {
548 ovs_abort(0, "Subtable %p duplicated in 'subtables'.",
555 ovs_abort(0, "Subtable %p not found from 'subtables'.", table);
558 assert(!cmap_is_empty(&table->rules));
559 assert(trie_verify(&table->ports_trie, 0, table->ports_mask_len)
560 == (table->ports_mask_len ? cmap_count(&table->rules) : 0));
564 CMAP_FOR_EACH (head, cmap_node, &table->rules) {
565 int prev_priority = INT_MAX;
566 cls_version_t prev_version = 0;
567 const struct cls_match *rule, *prev;
568 bool found_visible_rules_in_list = false;
570 assert(head->priority <= table->max_priority);
572 if (head->priority > max_priority) {
573 max_priority = head->priority;
577 FOR_EACH_RULE_IN_LIST_PROTECTED(rule, prev, head) {
578 cls_version_t rule_version;
579 const struct cls_rule *found_rule;
581 /* Priority may not increase. */
582 assert(rule->priority <= prev_priority);
584 if (rule->priority == max_priority) {
588 /* Count invisible rules and visible duplicates. */
589 if (!cls_match_visible_in_version(rule, version)) {
592 if (cls_match_is_eventually_invisible(rule)) {
593 found_visible_but_removable++;
595 if (found_visible_rules_in_list) {
598 found_visible_rules_in_list = true;
599 found_visible_rules = true;
602 /* Rule must be visible in the version it was inserted. */
603 rule_version = rule->add_version;
604 assert(cls_match_visible_in_version(rule, rule_version));
606 /* We should always find the latest version of the rule,
607 * unless all rules have been marked for removal.
608 * Later versions must always be later in the list. */
609 found_rule = classifier_find_rule_exactly(cls, rule->cls_rule,
611 if (found_rule && found_rule != rule->cls_rule) {
613 assert(found_rule->priority == rule->priority);
615 /* Found rule may not have a lower version. */
616 assert(found_rule->cls_match->add_version >= rule_version);
618 /* This rule must not be visible in the found rule's
620 assert(!cls_match_visible_in_version(
621 rule, found_rule->cls_match->add_version));
624 if (rule->priority == prev_priority) {
625 /* Exact duplicate rule may not have a lower version. */
626 assert(rule_version >= prev_version);
628 /* Previous rule must not be visible in rule's version. */
629 assert(!cls_match_visible_in_version(prev, rule_version));
632 prev_priority = rule->priority;
633 prev_version = rule_version;
638 if (found_visible_rules) {
639 found_tables_with_visible_rules++;
642 assert(table->max_priority == max_priority);
643 assert(table->max_count == max_count);
646 assert(found_tables == cmap_count(&cls->subtables_map));
647 assert(found_tables == pvector_count(&cls->subtables));
648 assert(n_tables == -1 || n_tables == found_tables_with_visible_rules);
649 assert(n_rules == -1 || found_rules == n_rules + found_invisible);
650 assert(n_dups == -1 || found_dups == n_dups);
651 assert(found_invisible == n_invisible);
653 CLS_FOR_EACH (test_rule, cls_rule, cls) {
656 /* Iteration does not see removable rules. */
658 == found_rules2 + found_visible_but_removable + found_invisible);
661 static struct test_rule *
662 make_rule(int wc_fields, int priority, int value_pat)
664 const struct cls_field *f;
665 struct test_rule *rule;
668 match_init_catchall(&match);
669 for (f = &cls_fields[0]; f < &cls_fields[CLS_N_FIELDS]; f++) {
670 int f_idx = f - cls_fields;
671 int value_idx = (value_pat & (1u << f_idx)) != 0;
672 memcpy((char *) &match.flow + f->ofs,
673 values[f_idx][value_idx], f->len);
675 if (f_idx == CLS_F_IDX_NW_SRC) {
676 match.wc.masks.nw_src = OVS_BE32_MAX;
677 } else if (f_idx == CLS_F_IDX_NW_DST) {
678 match.wc.masks.nw_dst = OVS_BE32_MAX;
679 } else if (f_idx == CLS_F_IDX_TP_SRC) {
680 match.wc.masks.tp_src = OVS_BE16_MAX;
681 } else if (f_idx == CLS_F_IDX_TP_DST) {
682 match.wc.masks.tp_dst = OVS_BE16_MAX;
683 } else if (f_idx == CLS_F_IDX_DL_SRC) {
684 memset(match.wc.masks.dl_src, 0xff, ETH_ADDR_LEN);
685 } else if (f_idx == CLS_F_IDX_DL_DST) {
686 memset(match.wc.masks.dl_dst, 0xff, ETH_ADDR_LEN);
687 } else if (f_idx == CLS_F_IDX_VLAN_TCI) {
688 match.wc.masks.vlan_tci = OVS_BE16_MAX;
689 } else if (f_idx == CLS_F_IDX_TUN_ID) {
690 match.wc.masks.tunnel.tun_id = OVS_BE64_MAX;
691 } else if (f_idx == CLS_F_IDX_METADATA) {
692 match.wc.masks.metadata = OVS_BE64_MAX;
693 } else if (f_idx == CLS_F_IDX_NW_DSCP) {
694 match.wc.masks.nw_tos |= IP_DSCP_MASK;
695 } else if (f_idx == CLS_F_IDX_NW_PROTO) {
696 match.wc.masks.nw_proto = UINT8_MAX;
697 } else if (f_idx == CLS_F_IDX_DL_TYPE) {
698 match.wc.masks.dl_type = OVS_BE16_MAX;
699 } else if (f_idx == CLS_F_IDX_IN_PORT) {
700 match.wc.masks.in_port.ofp_port = u16_to_ofp(UINT16_MAX);
706 rule = xzalloc(sizeof *rule);
707 cls_rule_init(&rule->cls_rule, &match, wc_fields
708 ? (priority == INT_MIN ? priority + 1 :
709 priority == INT_MAX ? priority - 1 : priority)
714 static struct test_rule *
715 clone_rule(const struct test_rule *src)
717 struct test_rule *dst;
719 dst = xmalloc(sizeof *dst);
721 cls_rule_clone(&dst->cls_rule, &src->cls_rule);
726 free_rule(struct test_rule *rule)
728 cls_rule_destroy(&rule->cls_rule);
733 shuffle(int *p, size_t n)
735 for (; n > 1; n--, p++) {
736 int *q = &p[random_range(n)];
744 shuffle_u32s(uint32_t *p, size_t n)
746 for (; n > 1; n--, p++) {
747 uint32_t *q = &p[random_range(n)];
754 /* Classifier tests. */
756 static enum mf_field_id trie_fields[2] = {
757 MFF_IPV4_DST, MFF_IPV4_SRC
761 set_prefix_fields(struct classifier *cls)
764 classifier_set_prefix_fields(cls, trie_fields, ARRAY_SIZE(trie_fields));
768 /* Tests an empty classifier. */
770 test_empty(struct ovs_cmdl_context *ctx OVS_UNUSED)
772 struct classifier cls;
775 classifier_init(&cls, flow_segment_u64s);
776 set_prefix_fields(&cls);
778 assert(classifier_is_empty(&cls));
779 assert(tcls_is_empty(&tcls));
780 compare_classifiers(&cls, 0, CLS_MIN_VERSION, &tcls);
781 classifier_destroy(&cls);
785 /* Destroys a null classifier. */
787 test_destroy_null(struct ovs_cmdl_context *ctx OVS_UNUSED)
789 classifier_destroy(NULL);
792 /* Tests classification with one rule at a time. */
794 test_single_rule(struct ovs_cmdl_context *ctx OVS_UNUSED)
796 unsigned int wc_fields; /* Hilarious. */
798 for (wc_fields = 0; wc_fields < (1u << CLS_N_FIELDS); wc_fields++) {
799 struct classifier cls;
800 struct test_rule *rule, *tcls_rule;
803 rule = make_rule(wc_fields,
804 hash_bytes(&wc_fields, sizeof wc_fields, 0), 0);
805 classifier_init(&cls, flow_segment_u64s);
806 set_prefix_fields(&cls);
808 tcls_rule = tcls_insert(&tcls, rule);
810 classifier_insert(&cls, &rule->cls_rule, CLS_MIN_VERSION, NULL, 0);
811 compare_classifiers(&cls, 0, CLS_MIN_VERSION, &tcls);
812 check_tables(&cls, 1, 1, 0, 0, CLS_MIN_VERSION);
814 classifier_remove(&cls, &rule->cls_rule);
815 tcls_remove(&tcls, tcls_rule);
816 assert(classifier_is_empty(&cls));
817 assert(tcls_is_empty(&tcls));
818 compare_classifiers(&cls, 0, CLS_MIN_VERSION, &tcls);
820 ovsrcu_postpone(free_rule, rule);
821 classifier_destroy(&cls);
826 /* Tests replacing one rule by another. */
828 test_rule_replacement(struct ovs_cmdl_context *ctx OVS_UNUSED)
830 unsigned int wc_fields;
832 for (wc_fields = 0; wc_fields < (1u << CLS_N_FIELDS); wc_fields++) {
833 struct classifier cls;
834 struct test_rule *rule1;
835 struct test_rule *rule2;
838 rule1 = make_rule(wc_fields, OFP_DEFAULT_PRIORITY, UINT_MAX);
839 rule2 = make_rule(wc_fields, OFP_DEFAULT_PRIORITY, UINT_MAX);
843 classifier_init(&cls, flow_segment_u64s);
844 set_prefix_fields(&cls);
846 tcls_insert(&tcls, rule1);
847 classifier_insert(&cls, &rule1->cls_rule, CLS_MIN_VERSION, NULL, 0);
848 compare_classifiers(&cls, 0, CLS_MIN_VERSION, &tcls);
849 check_tables(&cls, 1, 1, 0, 0, CLS_MIN_VERSION);
853 tcls_insert(&tcls, rule2);
855 assert(test_rule_from_cls_rule(
856 classifier_replace(&cls, &rule2->cls_rule, CLS_MIN_VERSION,
858 ovsrcu_postpone(free_rule, rule1);
859 compare_classifiers(&cls, 0, CLS_MIN_VERSION, &tcls);
860 check_tables(&cls, 1, 1, 0, 0, CLS_MIN_VERSION);
861 classifier_defer(&cls);
862 classifier_remove(&cls, &rule2->cls_rule);
865 destroy_classifier(&cls);
870 factorial(int n_items)
875 for (i = 2; i <= n_items; i++) {
890 reverse(int *a, int n)
894 for (i = 0; i < n / 2; i++) {
901 next_permutation(int *a, int n)
905 for (k = n - 2; k >= 0; k--) {
906 if (a[k] < a[k + 1]) {
909 for (l = n - 1; ; l--) {
912 reverse(a + (k + 1), n - (k + 1));
921 /* Tests classification with rules that have the same matching criteria. */
923 test_many_rules_in_one_list (struct ovs_cmdl_context *ctx OVS_UNUSED)
925 enum { N_RULES = 3 };
928 for (n_pris = N_RULES; n_pris >= 1; n_pris--) {
929 int ops[N_RULES * 2];
935 for (i = 1; i < N_RULES; i++) {
936 pris[i] = pris[i - 1] + (n_pris > i);
939 for (i = 0; i < N_RULES * 2; i++) {
945 struct test_rule *rules[N_RULES];
946 struct test_rule *tcls_rules[N_RULES];
947 int pri_rules[N_RULES];
948 struct classifier cls;
950 cls_version_t version = CLS_MIN_VERSION;
951 size_t n_invisible_rules = 0;
955 for (i = 0; i < N_RULES; i++) {
956 rules[i] = make_rule(456, pris[i], 0);
957 tcls_rules[i] = NULL;
961 classifier_init(&cls, flow_segment_u64s);
962 set_prefix_fields(&cls);
965 for (i = 0; i < ARRAY_SIZE(ops); i++) {
966 struct test_rule *displaced_rule = NULL;
967 struct cls_rule *removable_rule = NULL;
971 if (!tcls_rules[j]) {
972 tcls_rules[j] = tcls_insert(&tcls, rules[j]);
974 /* Insert the new rule in the next version. */
977 displaced_rule = test_rule_from_cls_rule(
978 classifier_find_rule_exactly(&cls,
981 if (displaced_rule) {
982 /* Mark the old rule for removal after the current
984 cls_rule_make_invisible_in_version(
985 &displaced_rule->cls_rule, version);
987 removable_rule = &displaced_rule->cls_rule;
989 classifier_insert(&cls, &rules[j]->cls_rule, version,
992 displaced_rule = test_rule_from_cls_rule(
993 classifier_replace(&cls, &rules[j]->cls_rule,
996 if (pri_rules[pris[j]] >= 0) {
997 int k = pri_rules[pris[j]];
998 assert(displaced_rule != NULL);
999 assert(displaced_rule != rules[j]);
1000 assert(pris[j] == displaced_rule->cls_rule.priority);
1001 tcls_rules[k] = NULL;
1003 assert(displaced_rule == NULL);
1005 pri_rules[pris[j]] = j;
1008 /* Mark the rule for removal after the current
1011 cls_rule_make_invisible_in_version(
1012 &rules[j]->cls_rule, version);
1013 n_invisible_rules++;
1014 removable_rule = &rules[j]->cls_rule;
1016 classifier_remove(&cls, &rules[j]->cls_rule);
1018 tcls_remove(&tcls, tcls_rules[j]);
1019 tcls_rules[j] = NULL;
1020 pri_rules[pris[j]] = -1;
1022 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1024 for (m = 0; m < N_RULES; m++) {
1025 n += tcls_rules[m] != NULL;
1027 check_tables(&cls, n > 0, n, n - 1, n_invisible_rules,
1030 if (versioned && removable_rule) {
1031 /* Removable rule is no longer visible. */
1032 assert(removable_rule->cls_match);
1033 assert(!cls_match_visible_in_version(
1034 removable_rule->cls_match, version));
1035 classifier_remove(&cls, removable_rule);
1036 n_invisible_rules--;
1040 classifier_defer(&cls);
1041 for (i = 0; i < N_RULES; i++) {
1042 if (classifier_remove(&cls, &rules[i]->cls_rule)) {
1043 ovsrcu_postpone(free_rule, rules[i]);
1046 classifier_destroy(&cls);
1047 tcls_destroy(&tcls);
1048 } while (next_permutation(ops, ARRAY_SIZE(ops)));
1049 assert(n_permutations == (factorial(N_RULES * 2) >> N_RULES));
1054 count_ones(unsigned long int x)
1059 x = zero_rightmost_1bit(x);
1067 array_contains(int *array, int n, int value)
1071 for (i = 0; i < n; i++) {
1072 if (array[i] == value) {
1080 /* Tests classification with two rules at a time that fall into the same
1081 * table but different lists. */
1083 test_many_rules_in_one_table(struct ovs_cmdl_context *ctx OVS_UNUSED)
1087 for (iteration = 0; iteration < 50; iteration++) {
1088 enum { N_RULES = 20 };
1089 struct test_rule *rules[N_RULES];
1090 struct test_rule *tcls_rules[N_RULES];
1091 struct classifier cls;
1093 cls_version_t version = CLS_MIN_VERSION;
1094 size_t n_invisible_rules = 0;
1095 int value_pats[N_RULES];
1101 wcf = random_uint32() & ((1u << CLS_N_FIELDS) - 1);
1102 value_mask = ~wcf & ((1u << CLS_N_FIELDS) - 1);
1103 } while ((1 << count_ones(value_mask)) < N_RULES);
1105 classifier_init(&cls, flow_segment_u64s);
1106 set_prefix_fields(&cls);
1109 for (i = 0; i < N_RULES; i++) {
1110 int priority = random_range(INT_MAX);
1113 value_pats[i] = random_uint32() & value_mask;
1114 } while (array_contains(value_pats, i, value_pats[i]));
1117 rules[i] = make_rule(wcf, priority, value_pats[i]);
1118 tcls_rules[i] = tcls_insert(&tcls, rules[i]);
1120 classifier_insert(&cls, &rules[i]->cls_rule, version, NULL, 0);
1121 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1123 check_tables(&cls, 1, i + 1, 0, n_invisible_rules, version);
1126 for (i = 0; i < N_RULES; i++) {
1127 tcls_remove(&tcls, tcls_rules[i]);
1129 /* Mark the rule for removal after the current version. */
1131 cls_rule_make_invisible_in_version(&rules[i]->cls_rule,
1133 n_invisible_rules++;
1135 classifier_remove(&cls, &rules[i]->cls_rule);
1137 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1138 check_tables(&cls, i < N_RULES - 1, N_RULES - (i + 1), 0,
1139 n_invisible_rules, version);
1141 ovsrcu_postpone(free_rule, rules[i]);
1146 for (i = 0; i < N_RULES; i++) {
1147 classifier_remove(&cls, &rules[i]->cls_rule);
1148 n_invisible_rules--;
1150 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1151 check_tables(&cls, 0, 0, 0, n_invisible_rules, version);
1152 ovsrcu_postpone(free_rule, rules[i]);
1156 classifier_destroy(&cls);
1157 tcls_destroy(&tcls);
1161 /* Tests classification with many rules at a time that fall into random lists
1164 test_many_rules_in_n_tables(int n_tables)
1166 enum { MAX_RULES = 50 };
1171 assert(n_tables < 10);
1172 for (i = 0; i < n_tables; i++) {
1174 wcfs[i] = random_uint32() & ((1u << CLS_N_FIELDS) - 1);
1175 } while (array_contains(wcfs, i, wcfs[i]));
1178 for (iteration = 0; iteration < 30; iteration++) {
1179 int priorities[MAX_RULES];
1180 struct classifier cls;
1182 cls_version_t version = CLS_MIN_VERSION;
1183 size_t n_invisible_rules = 0;
1184 struct ovs_list list = OVS_LIST_INITIALIZER(&list);
1186 random_set_seed(iteration + 1);
1187 for (i = 0; i < MAX_RULES; i++) {
1188 priorities[i] = (i * 129) & INT_MAX;
1190 shuffle(priorities, ARRAY_SIZE(priorities));
1192 classifier_init(&cls, flow_segment_u64s);
1193 set_prefix_fields(&cls);
1196 for (i = 0; i < MAX_RULES; i++) {
1197 struct test_rule *rule;
1198 int priority = priorities[i];
1199 int wcf = wcfs[random_range(n_tables)];
1200 int value_pat = random_uint32() & ((1u << CLS_N_FIELDS) - 1);
1201 rule = make_rule(wcf, priority, value_pat);
1202 tcls_insert(&tcls, rule);
1203 classifier_insert(&cls, &rule->cls_rule, version, NULL, 0);
1204 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1205 check_tables(&cls, -1, i + 1, -1, n_invisible_rules, version);
1208 while (classifier_count(&cls) - n_invisible_rules > 0) {
1209 struct test_rule *target;
1210 struct test_rule *rule;
1211 size_t n_removable_rules = 0;
1213 target = clone_rule(tcls.rules[random_range(tcls.n_rules)]);
1215 CLS_FOR_EACH_TARGET (rule, cls_rule, &cls, &target->cls_rule,
1218 /* Mark the rule for removal after the current version. */
1219 cls_rule_make_invisible_in_version(&rule->cls_rule,
1221 n_removable_rules++;
1222 compare_classifiers(&cls, n_invisible_rules, version,
1224 check_tables(&cls, -1, -1, -1, n_invisible_rules, version);
1226 list_push_back(&list, &rule->list_node);
1227 } else if (classifier_remove(&cls, &rule->cls_rule)) {
1228 ovsrcu_postpone(free_rule, rule);
1233 n_invisible_rules += n_removable_rules;
1235 tcls_delete_matches(&tcls, &target->cls_rule);
1238 compare_classifiers(&cls, n_invisible_rules, version, &tcls);
1239 check_tables(&cls, -1, -1, -1, n_invisible_rules, version);
1242 struct test_rule *rule;
1244 /* Remove rules that are no longer visible. */
1245 LIST_FOR_EACH_POP (rule, list_node, &list) {
1246 classifier_remove(&cls, &rule->cls_rule);
1247 n_invisible_rules--;
1249 compare_classifiers(&cls, n_invisible_rules, version,
1251 check_tables(&cls, -1, -1, -1, n_invisible_rules, version);
1255 destroy_classifier(&cls);
1256 tcls_destroy(&tcls);
1261 test_many_rules_in_two_tables(struct ovs_cmdl_context *ctx OVS_UNUSED)
1263 test_many_rules_in_n_tables(2);
1267 test_many_rules_in_five_tables(struct ovs_cmdl_context *ctx OVS_UNUSED)
1269 test_many_rules_in_n_tables(5);
1272 /* Miniflow tests. */
1277 static const uint32_t values[] =
1278 { 0xffffffff, 0xaaaaaaaa, 0x55555555, 0x80000000,
1279 0x00000001, 0xface0000, 0x00d00d1e, 0xdeadbeef };
1281 return values[random_range(ARRAY_SIZE(values))];
1285 choose(unsigned int n, unsigned int *idxp)
1295 #define FLOW_U32S (FLOW_U64S * 2)
1298 init_consecutive_values(int n_consecutive, struct flow *flow,
1301 uint32_t *flow_u32 = (uint32_t *) flow;
1303 if (choose(FLOW_U32S - n_consecutive + 1, idxp)) {
1306 for (i = 0; i < n_consecutive; i++) {
1307 flow_u32[*idxp + i] = random_value();
1316 next_random_flow(struct flow *flow, unsigned int idx)
1318 uint32_t *flow_u32 = (uint32_t *) flow;
1321 memset(flow, 0, sizeof *flow);
1324 if (choose(1, &idx)) {
1328 /* All flows with a small number of consecutive nonzero values. */
1329 for (i = 1; i <= 4; i++) {
1330 if (init_consecutive_values(i, flow, &idx)) {
1335 /* All flows with a large number of consecutive nonzero values. */
1336 for (i = FLOW_U32S - 4; i <= FLOW_U32S; i++) {
1337 if (init_consecutive_values(i, flow, &idx)) {
1342 /* All flows with exactly two nonconsecutive nonzero values. */
1343 if (choose((FLOW_U32S - 1) * (FLOW_U32S - 2) / 2, &idx)) {
1346 for (ofs1 = 0; ofs1 < FLOW_U32S - 2; ofs1++) {
1349 for (ofs2 = ofs1 + 2; ofs2 < FLOW_U32S; ofs2++) {
1350 if (choose(1, &idx)) {
1351 flow_u32[ofs1] = random_value();
1352 flow_u32[ofs2] = random_value();
1360 /* 16 randomly chosen flows with N >= 3 nonzero values. */
1361 if (choose(16 * (FLOW_U32S - 4), &idx)) {
1362 int n = idx / 16 + 3;
1365 for (i = 0; i < n; i++) {
1366 flow_u32[i] = random_value();
1368 shuffle_u32s(flow_u32, FLOW_U32S);
1377 any_random_flow(struct flow *flow)
1379 static unsigned int max;
1381 while (next_random_flow(flow, max)) {
1386 next_random_flow(flow, random_range(max));
1390 toggle_masked_flow_bits(struct flow *flow, const struct flow_wildcards *mask)
1392 const uint32_t *mask_u32 = (const uint32_t *) &mask->masks;
1393 uint32_t *flow_u32 = (uint32_t *) flow;
1396 for (i = 0; i < FLOW_U32S; i++) {
1397 if (mask_u32[i] != 0) {
1401 bit = 1u << random_range(32);
1402 } while (!(bit & mask_u32[i]));
1409 wildcard_extra_bits(struct flow_wildcards *mask)
1411 uint32_t *mask_u32 = (uint32_t *) &mask->masks;
1414 for (i = 0; i < FLOW_U32S; i++) {
1415 if (mask_u32[i] != 0) {
1419 bit = 1u << random_range(32);
1420 } while (!(bit & mask_u32[i]));
1421 mask_u32[i] &= ~bit;
1427 test_miniflow(struct ovs_cmdl_context *ctx OVS_UNUSED)
1432 random_set_seed(0xb3faca38);
1433 for (idx = 0; next_random_flow(&flow, idx); idx++) {
1434 const uint64_t *flow_u64 = (const uint64_t *) &flow;
1435 struct miniflow *miniflow, *miniflow2, *miniflow3;
1436 struct flow flow2, flow3;
1437 struct flow_wildcards mask;
1438 struct minimask *minimask;
1441 /* Convert flow to miniflow. */
1442 miniflow = miniflow_create(&flow);
1444 /* Check that the flow equals its miniflow. */
1445 assert(miniflow_get_vid(miniflow) == vlan_tci_to_vid(flow.vlan_tci));
1446 for (i = 0; i < FLOW_U64S; i++) {
1447 assert(miniflow_get(miniflow, i) == flow_u64[i]);
1450 /* Check that the miniflow equals itself. */
1451 assert(miniflow_equal(miniflow, miniflow));
1453 /* Convert miniflow back to flow and verify that it's the same. */
1454 miniflow_expand(miniflow, &flow2);
1455 assert(flow_equal(&flow, &flow2));
1457 /* Check that copying a miniflow works properly. */
1458 miniflow2 = miniflow_clone(miniflow);
1459 assert(miniflow_equal(miniflow, miniflow2));
1460 assert(miniflow_hash(miniflow, 0) == miniflow_hash(miniflow2, 0));
1461 miniflow_expand(miniflow2, &flow3);
1462 assert(flow_equal(&flow, &flow3));
1464 /* Check that masked matches work as expected for identical flows and
1467 next_random_flow(&mask.masks, 1);
1468 } while (flow_wildcards_is_catchall(&mask));
1469 minimask = minimask_create(&mask);
1470 assert(minimask_is_catchall(minimask)
1471 == flow_wildcards_is_catchall(&mask));
1472 assert(miniflow_equal_in_minimask(miniflow, miniflow2, minimask));
1473 assert(miniflow_equal_flow_in_minimask(miniflow, &flow2, minimask));
1474 assert(miniflow_hash_in_minimask(miniflow, minimask, 0x12345678) ==
1475 flow_hash_in_minimask(&flow, minimask, 0x12345678));
1477 /* Check that masked matches work as expected for differing flows and
1479 toggle_masked_flow_bits(&flow2, &mask);
1480 assert(!miniflow_equal_flow_in_minimask(miniflow, &flow2, minimask));
1481 miniflow3 = miniflow_create(&flow2);
1482 assert(!miniflow_equal_in_minimask(miniflow, miniflow3, minimask));
1493 test_minimask_has_extra(struct ovs_cmdl_context *ctx OVS_UNUSED)
1495 struct flow_wildcards catchall;
1496 struct minimask *minicatchall;
1500 flow_wildcards_init_catchall(&catchall);
1501 minicatchall = minimask_create(&catchall);
1502 assert(minimask_is_catchall(minicatchall));
1504 random_set_seed(0x2ec7905b);
1505 for (idx = 0; next_random_flow(&flow, idx); idx++) {
1506 struct flow_wildcards mask;
1507 struct minimask *minimask;
1510 minimask = minimask_create(&mask);
1511 assert(!minimask_has_extra(minimask, minimask));
1512 assert(minimask_has_extra(minicatchall, minimask)
1513 == !minimask_is_catchall(minimask));
1514 if (!minimask_is_catchall(minimask)) {
1515 struct minimask *minimask2;
1517 wildcard_extra_bits(&mask);
1518 minimask2 = minimask_create(&mask);
1519 assert(minimask_has_extra(minimask2, minimask));
1520 assert(!minimask_has_extra(minimask, minimask2));
1531 test_minimask_combine(struct ovs_cmdl_context *ctx OVS_UNUSED)
1533 struct flow_wildcards catchall;
1534 struct minimask *minicatchall;
1538 flow_wildcards_init_catchall(&catchall);
1539 minicatchall = minimask_create(&catchall);
1540 assert(minimask_is_catchall(minicatchall));
1542 random_set_seed(0x181bf0cd);
1543 for (idx = 0; next_random_flow(&flow, idx); idx++) {
1544 struct minimask *minimask, *minimask2;
1545 struct flow_wildcards mask, mask2, combined, combined2;
1547 struct minimask minicombined;
1548 uint64_t storage[FLOW_U64S];
1553 minimask = minimask_create(&mask);
1555 minimask_combine(&m.minicombined, minimask, minicatchall, m.storage);
1556 assert(minimask_is_catchall(&m.minicombined));
1558 any_random_flow(&flow2);
1559 mask2.masks = flow2;
1560 minimask2 = minimask_create(&mask2);
1562 minimask_combine(&m.minicombined, minimask, minimask2, m.storage);
1563 flow_wildcards_and(&combined, &mask, &mask2);
1564 minimask_expand(&m.minicombined, &combined2);
1565 assert(flow_wildcards_equal(&combined, &combined2));
1574 static const struct ovs_cmdl_command commands[] = {
1575 /* Classifier tests. */
1576 {"empty", NULL, 0, 0, test_empty},
1577 {"destroy-null", NULL, 0, 0, test_destroy_null},
1578 {"single-rule", NULL, 0, 0, test_single_rule},
1579 {"rule-replacement", NULL, 0, 0, test_rule_replacement},
1580 {"many-rules-in-one-list", NULL, 0, 1, test_many_rules_in_one_list},
1581 {"many-rules-in-one-table", NULL, 0, 1, test_many_rules_in_one_table},
1582 {"many-rules-in-two-tables", NULL, 0, 0, test_many_rules_in_two_tables},
1583 {"many-rules-in-five-tables", NULL, 0, 0, test_many_rules_in_five_tables},
1585 /* Miniflow and minimask tests. */
1586 {"miniflow", NULL, 0, 0, test_miniflow},
1587 {"minimask_has_extra", NULL, 0, 0, test_minimask_has_extra},
1588 {"minimask_combine", NULL, 0, 0, test_minimask_combine},
1590 {NULL, NULL, 0, 0, NULL},
1594 test_classifier_main(int argc, char *argv[])
1596 struct ovs_cmdl_context ctx = {
1600 set_program_name(argv[0]);
1602 if (argc > 1 && !strcmp(argv[1], "--versioned")) {
1609 ovs_cmdl_run_command(&ctx, commands);
1612 OVSTEST_REGISTER("test-classifier", test_classifier_main);