X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-classifier.c;h=1cfd5cf6ec806078c404def8e4f374a5fb47f570;hb=80df177a5f624a84f4c97bbe913511726c3e9bb8;hp=63a7adacc7db4c8be8818e08282393e145e5f12e;hpb=b9298d3f825703063c9538aa37407da43e1e4781;p=sliver-openvswitch.git diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 63a7adacc..1cfd5cf6e 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) \ @@ -201,6 +201,8 @@ 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 { NOT_REACHED(); } @@ -249,7 +251,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,7 +262,7 @@ 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_proto_values[] = { IPPROTO_TCP, IPPROTO_ICMP }; static uint8_t nw_tos_values[] = { 49, 0 }; static void *values[CLS_N_FIELDS][2]; @@ -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); }