X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-classifier.c;h=fcafdb2dbdd202fd7317f94f78ef8fa37d98836c;hb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;hp=1cfd5cf6ec806078c404def8e4f374a5fb47f570;hpb=007948177581f3b3dad188221593d0e4bdca6ba0;p=sliver-openvswitch.git diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 1cfd5cf6e..fcafdb2db 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,12 +50,12 @@ CLS_FIELD(FWW_IN_PORT, in_port, IN_PORT) \ CLS_FIELD(0, vlan_tci, VLAN_TCI) \ CLS_FIELD(FWW_DL_TYPE, dl_type, DL_TYPE) \ - CLS_FIELD(FWW_TP_SRC, tp_src, TP_SRC) \ - CLS_FIELD(FWW_TP_DST, tp_dst, TP_DST) \ + CLS_FIELD(0, tp_src, TP_SRC) \ + CLS_FIELD(0, tp_dst, TP_DST) \ 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. * @@ -198,11 +198,17 @@ match(const struct cls_rule *wild, const struct flow *fixed) eq = !((fixed->nw_src ^ wild->flow.nw_src) & wild->wc.nw_src_mask); } else if (f_idx == CLS_F_IDX_NW_DST) { eq = !((fixed->nw_dst ^ wild->flow.nw_dst) & wild->wc.nw_dst_mask); + } else if (f_idx == CLS_F_IDX_TP_SRC) { + eq = !((fixed->tp_src ^ wild->flow.tp_src) & wild->wc.tp_src_mask); + } else if (f_idx == CLS_F_IDX_TP_DST) { + eq = !((fixed->tp_dst ^ wild->flow.tp_dst) & wild->wc.tp_dst_mask); } 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(); } @@ -263,7 +269,7 @@ static uint8_t dl_src_values[][6] = { { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 }, 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[] = { IPPROTO_TCP, IPPROTO_ICMP }; -static uint8_t nw_tos_values[] = { 49, 0 }; +static uint8_t nw_dscp_values[] = { 48, 0 }; static void *values[CLS_N_FIELDS][2]; @@ -297,8 +303,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]; @@ -318,7 +324,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 * \ @@ -331,7 +337,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) @@ -367,7 +373,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); @@ -401,7 +407,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; @@ -409,7 +414,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 +467,10 @@ make_rule(int wc_fields, unsigned int priority, int value_pat) rule->cls_rule.wc.nw_src_mask = htonl(UINT32_MAX); } else if (f_idx == CLS_F_IDX_NW_DST) { rule->cls_rule.wc.nw_dst_mask = htonl(UINT32_MAX); + } else if (f_idx == CLS_F_IDX_TP_SRC) { + rule->cls_rule.wc.tp_src_mask = htons(UINT16_MAX); + } else if (f_idx == CLS_F_IDX_TP_DST) { + rule->cls_rule.wc.tp_dst_mask = htons(UINT16_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) {