X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-classifier.c;h=8dfe016c0ed8c099d37671f62b3a850b42e15c0f;hb=0d1abcdb3fb70d70866b700f66d3b36247066fc7;hp=63a7adacc7db4c8be8818e08282393e145e5f12e;hpb=b9298d3f825703063c9538aa37407da43e1e4781;p=sliver-openvswitch.git diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 63a7adacc..8dfe016c0 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ /* struct flow all-caps */ \ /* FWW_* bit(s) member name name */ \ /* -------------------------- ----------- -------- */ \ - CLS_FIELD(FWW_TUN_ID, tun_id, TUN_ID) \ + CLS_FIELD(0, tun_id, TUN_ID) \ CLS_FIELD(0, nw_src, NW_SRC) \ CLS_FIELD(0, nw_dst, NW_DST) \ CLS_FIELD(FWW_IN_PORT, in_port, IN_PORT) \ @@ -55,7 +55,7 @@ CLS_FIELD(FWW_DL_SRC, dl_src, DL_SRC) \ CLS_FIELD(FWW_DL_DST | FWW_ETH_MCAST, dl_dst, DL_DST) \ CLS_FIELD(FWW_NW_PROTO, nw_proto, NW_PROTO) \ - CLS_FIELD(FWW_NW_TOS, nw_tos, NW_TOS) + CLS_FIELD(FWW_NW_DSCP, nw_tos, NW_DSCP) /* Field indexes. * @@ -201,6 +201,10 @@ match(const struct cls_rule *wild, const struct flow *fixed) } else if (f_idx == CLS_F_IDX_VLAN_TCI) { eq = !((fixed->vlan_tci ^ wild->flow.vlan_tci) & wild->wc.vlan_tci_mask); + } else if (f_idx == CLS_F_IDX_TUN_ID) { + eq = !((fixed->tun_id ^ wild->flow.tun_id) & wild->wc.tun_id_mask); + } else if (f_idx == CLS_F_IDX_NW_DSCP) { + eq = !((fixed->nw_tos ^ wild->flow.nw_tos) & IP_DSCP_MASK); } else { NOT_REACHED(); } @@ -249,7 +253,7 @@ static ovs_be32 nw_dst_values[] = { CONSTANT_HTONL(0xc0a80002), static ovs_be64 tun_id_values[] = { 0, CONSTANT_HTONLL(UINT64_C(0xfedcba9876543210)) }; -static uint16_t in_port_values[] = { 1, ODPP_LOCAL }; +static uint16_t in_port_values[] = { 1, OFPP_LOCAL }; static ovs_be16 vlan_tci_values[] = { CONSTANT_HTONS(101), CONSTANT_HTONS(0) }; static ovs_be16 dl_type_values[] = { CONSTANT_HTONS(ETH_TYPE_IP), CONSTANT_HTONS(ETH_TYPE_ARP) }; @@ -260,8 +264,8 @@ static uint8_t dl_src_values[][6] = { { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 }, { 0x5e, 0x33, 0x7f, 0x5f, 0x1e, 0x99 } }; static uint8_t dl_dst_values[][6] = { { 0x4a, 0x27, 0x71, 0xae, 0x64, 0xc1 }, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; -static uint8_t nw_proto_values[] = { IP_TYPE_TCP, IP_TYPE_ICMP }; -static uint8_t nw_tos_values[] = { 49, 0 }; +static uint8_t nw_proto_values[] = { IPPROTO_TCP, IPPROTO_ICMP }; +static uint8_t nw_dscp_values[] = { 48, 0 }; static void *values[CLS_N_FIELDS][2]; @@ -295,8 +299,8 @@ init_values(void) values[CLS_F_IDX_NW_PROTO][0] = &nw_proto_values[0]; values[CLS_F_IDX_NW_PROTO][1] = &nw_proto_values[1]; - values[CLS_F_IDX_NW_TOS][0] = &nw_tos_values[0]; - values[CLS_F_IDX_NW_TOS][1] = &nw_tos_values[1]; + values[CLS_F_IDX_NW_DSCP][0] = &nw_dscp_values[0]; + values[CLS_F_IDX_NW_DSCP][1] = &nw_dscp_values[1]; values[CLS_F_IDX_TP_SRC][0] = &tp_src_values[0]; values[CLS_F_IDX_TP_SRC][1] = &tp_src_values[1]; @@ -316,7 +320,7 @@ init_values(void) #define N_DL_SRC_VALUES ARRAY_SIZE(dl_src_values) #define N_DL_DST_VALUES ARRAY_SIZE(dl_dst_values) #define N_NW_PROTO_VALUES ARRAY_SIZE(nw_proto_values) -#define N_NW_TOS_VALUES ARRAY_SIZE(nw_tos_values) +#define N_NW_DSCP_VALUES ARRAY_SIZE(nw_dscp_values) #define N_FLOW_VALUES (N_NW_SRC_VALUES * \ N_NW_DST_VALUES * \ @@ -329,7 +333,7 @@ init_values(void) N_DL_SRC_VALUES * \ N_DL_DST_VALUES * \ N_NW_PROTO_VALUES * \ - N_NW_TOS_VALUES) + N_NW_DSCP_VALUES) static unsigned int get_value(unsigned int *x, unsigned n_values) @@ -365,7 +369,7 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls) memcpy(flow.dl_dst, dl_dst_values[get_value(&x, N_DL_DST_VALUES)], ETH_ADDR_LEN); flow.nw_proto = nw_proto_values[get_value(&x, N_NW_PROTO_VALUES)]; - flow.nw_tos = nw_tos_values[get_value(&x, N_NW_TOS_VALUES)]; + flow.nw_tos = nw_dscp_values[get_value(&x, N_NW_DSCP_VALUES)]; cr0 = classifier_lookup(cls, &flow); cr1 = tcls_lookup(tcls, &flow); @@ -399,7 +403,6 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules, int n_dups) { const struct cls_table *table; - struct flow_wildcards exact_wc; struct test_rule *test_rule; struct cls_cursor cursor; int found_tables = 0; @@ -407,7 +410,6 @@ check_tables(const struct classifier *cls, int found_dups = 0; int found_rules2 = 0; - flow_wildcards_init_exact(&exact_wc); HMAP_FOR_EACH (table, hmap_node, &cls->tables) { const struct cls_rule *head; @@ -463,6 +465,8 @@ make_rule(int wc_fields, unsigned int priority, int value_pat) rule->cls_rule.wc.nw_dst_mask = htonl(UINT32_MAX); } else if (f_idx == CLS_F_IDX_VLAN_TCI) { rule->cls_rule.wc.vlan_tci_mask = htons(UINT16_MAX); + } else if (f_idx == CLS_F_IDX_TUN_ID) { + rule->cls_rule.wc.tun_id_mask = htonll(UINT64_MAX); } else { NOT_REACHED(); } @@ -522,7 +526,7 @@ test_single_rule(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_init(&tcls); tcls_rule = tcls_insert(&tcls, rule); - assert(!classifier_insert(&cls, &rule->cls_rule)); + classifier_insert(&cls, &rule->cls_rule); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); @@ -558,7 +562,7 @@ test_rule_replacement(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) classifier_init(&cls); tcls_init(&tcls); tcls_insert(&tcls, rule1); - assert(!classifier_insert(&cls, &rule1->cls_rule)); + classifier_insert(&cls, &rule1->cls_rule); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); tcls_destroy(&tcls); @@ -566,7 +570,7 @@ test_rule_replacement(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_init(&tcls); tcls_insert(&tcls, rule2); assert(test_rule_from_cls_rule( - classifier_insert(&cls, &rule2->cls_rule)) == rule1); + classifier_replace(&cls, &rule2->cls_rule)) == rule1); free(rule1); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); @@ -677,7 +681,7 @@ test_many_rules_in_one_list (int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_rules[j] = tcls_insert(&tcls, rules[j]); displaced_rule = test_rule_from_cls_rule( - classifier_insert(&cls, &rules[j]->cls_rule)); + classifier_replace(&cls, &rules[j]->cls_rule)); if (pri_rules[pris[j]] >= 0) { int k = pri_rules[pris[j]]; assert(displaced_rule != NULL); @@ -777,7 +781,7 @@ test_many_rules_in_one_table(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) rules[i] = make_rule(wcf, priority, value_pats[i]); tcls_rules[i] = tcls_insert(&tcls, rules[i]); - assert(!classifier_insert(&cls, &rules[i]->cls_rule)); + classifier_insert(&cls, &rules[i]->cls_rule); check_tables(&cls, 1, i + 1, 0); compare_classifiers(&cls, &tcls); @@ -835,7 +839,7 @@ test_many_rules_in_n_tables(int n_tables) int value_pat = rand() & ((1u << CLS_N_FIELDS) - 1); rule = make_rule(wcf, priority, value_pat); tcls_insert(&tcls, rule); - assert(!classifier_insert(&cls, &rule->cls_rule)); + classifier_insert(&cls, &rule->cls_rule); check_tables(&cls, -1, i + 1, -1); compare_classifiers(&cls, &tcls); }